Changeset 181426 in webkit
- Timestamp:
- Mar 11, 2015, 9:49:05 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 11 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector-protocol/console/warnings-errors-expected.txt (added)
-
LayoutTests/inspector-protocol/console/warnings-errors.html (added)
-
LayoutTests/inspector-protocol/resources/errors.css (added)
-
LayoutTests/inspector-protocol/resources/errors.js (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSParser.cpp (modified) (11 diffs)
-
Source/WebCore/css/CSSParser.h (modified) (7 diffs)
-
Source/WebCore/css/StyleSheetContents.cpp (modified) (2 diffs)
-
Source/WebCore/css/StyleSheetContents.h (modified) (2 diffs)
-
Source/WebCore/dom/InlineStyleSheetOwner.cpp (modified) (3 diffs)
-
Source/WebCore/dom/InlineStyleSheetOwner.h (modified) (1 diff)
-
Source/WebCore/inspector/InspectorStyleSheet.cpp (modified) (1 diff)
-
Source/WebInspectorUI/ChangeLog (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r181425 r181426 1 2015-03-11 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: CSS parser errors in the console should include column numbers 4 https://bugs.webkit.org/show_bug.cgi?id=114313 5 6 Reviewed by Darin Adler. 7 8 Test errors in both external and inline CSS and Scripts to ensure they have 9 expected line:column information. 10 11 * inspector-protocol/console/warnings-errors-expected.txt: Added. 12 * inspector-protocol/console/warnings-errors.html: Added. 13 * inspector-protocol/resources/errors.css: Added. 14 * inspector-protocol/resources/errors.js: Added. 15 1 16 2015-03-11 Simon Fraser <simon.fraser@apple.com> 2 17 -
trunk/Source/WebCore/ChangeLog
r181423 r181426 1 2015-03-11 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: CSS parser errors in the console should include column numbers 4 https://bugs.webkit.org/show_bug.cgi?id=114313 5 6 Reviewed by Darin Adler. 7 8 Test: inspector-protocol/console/warnings-errors.html 9 10 * css/CSSParser.h: 11 (WebCore::CSSParser::currentCharacterOffset): 12 Get the current character offset depending on the source type. 13 Add instance variables to track column position and start 14 line / column for inline stylesheets. 15 16 * css/CSSParser.cpp: 17 (WebCore::CSSParser::CSSParser): 18 (WebCore::CSSParser::parseSheet): 19 Initialize new instance variables. 20 21 (WebCore::CSSParser::currentLocation): 22 Update to include column information for the token. Also, if we are on the 23 first line we may need to take into account a start column offset as well. 24 25 (WebCore::CSSParser::realLex): 26 Set the token's start column. 27 When bumping the line number, reset the column offset for the next 28 line with the next character. 29 30 (WebCore::CSSParser::syntaxError): 31 (WebCore::CSSParser::logError): 32 Include column information. 33 34 * css/StyleSheetContents.cpp: 35 (WebCore::StyleSheetContents::parseAuthorStyleSheet): 36 (WebCore::StyleSheetContents::parseString): 37 (WebCore::StyleSheetContents::parseStringAtPosition): 38 Include column information. 39 40 * css/StyleSheetContents.h: 41 * dom/InlineStyleSheetOwner.cpp: 42 (WebCore::InlineStyleSheetOwner::InlineStyleSheetOwner): 43 (WebCore::InlineStyleSheetOwner::createSheet): 44 Save and use column information later on. 45 46 * dom/InlineStyleSheetOwner.h: 47 * inspector/InspectorStyleSheet.cpp: 48 (WebCore::InspectorStyleSheet::ensureSourceData): 49 Updated parser signature needs starting column and no longer has optional parameters. 50 1 51 2015-03-11 Eric Carlson <eric.carlson@apple.com> 2 52 -
trunk/Source/WebCore/css/CSSParser.cpp
r181389 r181426 331 331 , m_lineNumber(0) 332 332 , m_tokenStartLineNumber(0) 333 , m_tokenStartColumnNumber(0) 333 334 , m_lastSelectorLineNumber(0) 335 , m_columnOffsetForLine(0) 336 , m_sheetStartLineNumber(0) 337 , m_sheetStartColumnNumber(0) 334 338 , m_allowImportRules(true) 335 339 , m_allowNamespaceDeclarations(true) … … 430 434 } 431 435 432 void CSSParser::parseSheet(StyleSheetContents* sheet, const String& string, int startLineNumber, RuleSourceDataList* ruleSourceDataResult, bool logErrors)436 void CSSParser::parseSheet(StyleSheetContents* sheet, const String& string, const TextPosition& textPosition, RuleSourceDataList* ruleSourceDataResult, bool logErrors) 433 437 { 434 438 setStyleSheet(sheet); … … 440 444 m_logErrors = logErrors && sheet->singleOwnerDocument() && !sheet->baseURL().isEmpty() && sheet->singleOwnerDocument()->page(); 441 445 m_ignoreErrorsInDeclaration = false; 442 m_lineNumber = startLineNumber; 446 m_sheetStartLineNumber = textPosition.m_line.zeroBasedInt(); 447 m_sheetStartColumnNumber = textPosition.m_column.zeroBasedInt(); 448 m_lineNumber = m_sheetStartLineNumber; 449 m_columnOffsetForLine = 0; 443 450 setupParser("", string, ""); 444 451 cssyyparse(this); … … 10484 10491 Location location; 10485 10492 location.lineNumber = m_tokenStartLineNumber; 10493 location.columnNumber = m_tokenStartColumnNumber; 10494 10495 ASSERT(location.lineNumber >= 0); 10496 ASSERT(location.columnNumber >= 0); 10497 10498 if (location.lineNumber == m_sheetStartLineNumber) 10499 location.columnNumber += m_sheetStartColumnNumber; 10500 10486 10501 if (is8BitSource()) 10487 10502 location.token.init(tokenStart<LChar>(), currentCharacter<LChar>() - tokenStart<LChar>()); 10488 10503 else 10489 10504 location.token.init(tokenStart<UChar>(), currentCharacter<UChar>() - tokenStart<UChar>()); 10505 10490 10506 return location; 10491 10507 } … … 11359 11375 setTokenStart(result); 11360 11376 m_tokenStartLineNumber = m_lineNumber; 11377 m_tokenStartColumnNumber = tokenStartOffset() - m_columnOffsetForLine; 11361 11378 m_token = *currentCharacter<SrcCharacterType>(); 11362 11379 ++currentCharacter<SrcCharacterType>(); … … 11581 11598 --currentCharacter<SrcCharacterType>(); 11582 11599 do { 11583 if (*currentCharacter<SrcCharacterType>() == '\n') 11600 if (*currentCharacter<SrcCharacterType>() == '\n') { 11584 11601 ++m_lineNumber; 11602 m_columnOffsetForLine = currentCharacterOffset() + 1; 11603 } 11585 11604 ++currentCharacter<SrcCharacterType>(); 11586 11605 } while (*currentCharacter<SrcCharacterType>() <= ' ' && (typesOfASCIICharacters[*currentCharacter<SrcCharacterType>()] == CharacterWhiteSpace)); … … 11651 11670 ++currentCharacter<SrcCharacterType>(); 11652 11671 while (currentCharacter<SrcCharacterType>()[0] != '*' || currentCharacter<SrcCharacterType>()[1] != '/') { 11653 if (*currentCharacter<SrcCharacterType>() == '\n') 11672 if (*currentCharacter<SrcCharacterType>() == '\n') { 11654 11673 ++m_lineNumber; 11655 if (*currentCharacter<SrcCharacterType>() == '\0') { 11674 m_columnOffsetForLine = currentCharacterOffset() + 1; 11675 } else if (*currentCharacter<SrcCharacterType>() == '\0') { 11656 11676 // Unterminated comments are simply ignored. 11657 11677 currentCharacter<SrcCharacterType>() -= 2; … … 11870 11890 if (!isLoggingErrors()) 11871 11891 return; 11892 11872 11893 StringBuilder builder; 11873 11894 switch (error) { … … 11875 11896 builder.appendLiteral("Invalid CSS property declaration at: "); 11876 11897 break; 11877 11878 11898 default: 11879 11899 builder.appendLiteral("Unexpected CSS token: "); 11900 break; 11880 11901 } 11881 11902 … … 11885 11906 builder.append(location.token.characters16(), location.token.length()); 11886 11907 11887 logError(builder.toString(), location.lineNumber );11908 logError(builder.toString(), location.lineNumber, location.columnNumber); 11888 11909 11889 11910 m_ignoreErrorsInDeclaration = true; … … 11895 11916 } 11896 11917 11897 void CSSParser::logError(const String& message, int lineNumber) 11898 { 11899 // FIXME: <http://webkit.org/b/114313> CSS parser console message errors should include column numbers. 11918 void CSSParser::logError(const String& message, int lineNumber, int columnNumber) 11919 { 11900 11920 PageConsoleClient& console = m_styleSheet->singleOwnerDocument()->page()->console(); 11901 console.addMessage(MessageSource::CSS, MessageLevel::Warning, message, m_styleSheet->baseURL().string(), lineNumber + 1, 0);11921 console.addMessage(MessageSource::CSS, MessageLevel::Warning, message, m_styleSheet->baseURL().string(), lineNumber + 1, columnNumber + 1); 11902 11922 } 11903 11923 -
trunk/Source/WebCore/css/CSSParser.h
r181389 r181426 41 41 #include <wtf/Vector.h> 42 42 #include <wtf/text/AtomicString.h> 43 #include <wtf/text/TextPosition.h> 43 44 44 45 #if ENABLE(CSS_GRID_LAYOUT) … … 106 107 WEBCORE_EXPORT ~CSSParser(); 107 108 108 void parseSheet(StyleSheetContents*, const String&, int startLineNumber = 0, RuleSourceDataList* = nullptr, bool = false);109 void parseSheet(StyleSheetContents*, const String&, const TextPosition&, RuleSourceDataList*, bool logErrors); 109 110 PassRefPtr<StyleRuleBase> parseRule(StyleSheetContents*, const String&); 110 111 PassRefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetContents*, const String&); … … 465 466 inline UChar tokenStartChar(); 466 467 468 inline unsigned currentCharacterOffset(); 469 467 470 template <typename CharacterType> 468 471 inline bool isIdentifierStart(); … … 593 596 int m_lineNumber; 594 597 int m_tokenStartLineNumber; 598 int m_tokenStartColumnNumber; 595 599 int m_lastSelectorLineNumber; 600 int m_columnOffsetForLine; 601 602 int m_sheetStartLineNumber; 603 int m_sheetStartColumnNumber; 596 604 597 605 bool m_allowImportRules; … … 643 651 644 652 bool isLoggingErrors(); 645 void logError(const String& message, int lineNumber );653 void logError(const String& message, int lineNumber, int columnNumber); 646 654 647 655 bool validateCalculationUnit(ValueWithCalculation&, Units); … … 687 695 struct CSSParser::Location { 688 696 int lineNumber; 697 int columnNumber; 689 698 CSSParserString token; 690 699 }; … … 715 724 } 716 725 726 unsigned CSSParser::currentCharacterOffset() 727 { 728 if (is8BitSource()) 729 return m_currentCharacter8 - m_dataStart8.get(); 730 return m_currentCharacter16 - m_dataStart16.get(); 731 } 732 717 733 inline UChar CSSParser::tokenStartChar() 718 734 { -
trunk/Source/WebCore/css/StyleSheetContents.cpp
r181389 r181426 292 292 293 293 CSSParser p(parserContext()); 294 p.parseSheet(this, sheetText, 0, 0, true);294 p.parseSheet(this, sheetText, TextPosition(), nullptr, true); 295 295 296 296 // If we're loading a stylesheet cross-origin, and the MIME type is not standard, require the CSS … … 317 317 bool StyleSheetContents::parseString(const String& sheetText) 318 318 { 319 return parseStringAt Line(sheetText, 0, false);320 } 321 322 bool StyleSheetContents::parseStringAt Line(const String& sheetText, int startLineNumber, bool createdByParser)319 return parseStringAtPosition(sheetText, TextPosition(), false); 320 } 321 322 bool StyleSheetContents::parseStringAtPosition(const String& sheetText, const TextPosition& textPosition, bool createdByParser) 323 323 { 324 324 CSSParser p(parserContext()); 325 p.parseSheet(this, sheetText, startLineNumber, 0, createdByParser); 326 325 p.parseSheet(this, sheetText, textPosition, nullptr, createdByParser); 327 326 return true; 328 327 } -
trunk/Source/WebCore/css/StyleSheetContents.h
r181389 r181426 29 29 #include <wtf/Vector.h> 30 30 #include <wtf/text/AtomicStringHash.h> 31 #include <wtf/text/TextPosition.h> 31 32 32 33 namespace WebCore { … … 63 64 void parseAuthorStyleSheet(const CachedCSSStyleSheet*, const SecurityOrigin*); 64 65 WEBCORE_EXPORT bool parseString(const String&); 65 bool parseStringAt Line(const String&, int startLineNumber, bool);66 bool parseStringAtPosition(const String&, const TextPosition&, bool createdByParser); 66 67 67 68 bool isCacheable() const; -
trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp
r181389 r181426 36 36 : m_isParsingChildren(createdByParser) 37 37 , m_loading(false) 38 , m_start LineNumber(WTF::OrdinalNumber::beforeFirst())38 , m_startTextPosition(WTF::OrdinalNumber::beforeFirst(), WTF::OrdinalNumber::beforeFirst()) 39 39 { 40 40 if (createdByParser && document.scriptableDocumentParser() && !document.isInDocumentWrite()) 41 m_start LineNumber = document.scriptableDocumentParser()->textPosition().m_line;41 m_startTextPosition = document.scriptableDocumentParser()->textPosition(); 42 42 } 43 43 … … 124 124 if (!isValidCSSContentType(element, m_contentType)) 125 125 return; 126 if (!document.contentSecurityPolicy()->allowInlineStyle(document.url(), m_start LineNumber))126 if (!document.contentSecurityPolicy()->allowInlineStyle(document.url(), m_startTextPosition.m_line)) 127 127 return; 128 128 … … 145 145 m_sheet->setMediaQueries(mediaQueries.release()); 146 146 m_sheet->setTitle(element.title()); 147 m_sheet->contents().parseStringAt Line(text, m_startLineNumber.zeroBasedInt(), m_isParsingChildren);147 m_sheet->contents().parseStringAtPosition(text, m_startTextPosition, m_isParsingChildren); 148 148 149 149 m_loading = false; -
trunk/Source/WebCore/dom/InlineStyleSheetOwner.h
r181389 r181426 58 58 bool m_isParsingChildren; 59 59 bool m_loading; 60 WTF:: OrdinalNumber m_startLineNumber;60 WTF::TextPosition m_startTextPosition; 61 61 AtomicString m_contentType; 62 62 AtomicString m_media; -
trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp
r181389 r181426 1107 1107 RefPtr<StyleSheetContents> newStyleSheet = StyleSheetContents::create(); 1108 1108 auto ruleSourceDataResult = std::make_unique<RuleSourceDataList>(); 1109 createCSSParser(m_pageStyleSheet->ownerDocument())->parseSheet(newStyleSheet.get(), m_parsedStyleSheet->text(), 0, ruleSourceDataResult.get());1109 createCSSParser(m_pageStyleSheet->ownerDocument())->parseSheet(newStyleSheet.get(), m_parsedStyleSheet->text(), TextPosition(), ruleSourceDataResult.get(), false); 1110 1110 m_parsedStyleSheet->setSourceData(WTF::move(ruleSourceDataResult)); 1111 1111 return m_parsedStyleSheet->hasSourceData(); -
trunk/Source/WebInspectorUI/ChangeLog
r181389 r181426 1 2015-03-11 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: CSS parser errors in the console should include column numbers 4 https://bugs.webkit.org/show_bug.cgi?id=114313 5 6 Reviewed by Darin Adler. 7 8 * UserInterface/Views/ConsoleMessageImpl.js: 9 (WebInspector.ConsoleMessageImpl.prototype._linkifyLocation): 10 Column numbers in console messages are also 1 based and should be adjusted. 11 1 12 2015-03-11 Commit Queue <commit-queue@webkit.org> 2 13 -
trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js
r181389 r181426 200 200 // ConsoleMessage stack trace line numbers are one-based. 201 201 lineNumber = lineNumber ? lineNumber - 1 : 0; 202 columnNumber = columnNumber ? columnNumber - 1 : 0; 202 203 203 204 return WebInspector.linkifyLocation(url, lineNumber, columnNumber, "console-message-url");
Note:
See TracChangeset
for help on using the changeset viewer.