<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[181367] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/181367">181367</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-03-10 23:11:10 -0700 (Tue, 10 Mar 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Web Inspector: CSS parser errors in the console should include column numbers
https://bugs.webkit.org/show_bug.cgi?id=114313
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-03-10
Reviewed by Benjamin Poulain.
Source/WebCore:
Test: inspector-protocol/console/warnings-errors.html
* css/CSSParser.h:
(WebCore::CSSParser::currentCharacterOffset):
Get the current character offset depending on the source type.
Add instance variables to track column position and start
line / column for inline stylesheets.
* css/CSSParser.cpp:
(WebCore::CSSParser::CSSParser):
(WebCore::CSSParser::parseSheet):
Initialize new instance variables.
(WebCore::CSSParser::currentLocation):
Update to include column information. Also, if we are on the first line
we may need to take into account a start column offset as well.
(WebCore::CSSParser::realLex):
When bumping the line number, reset the column offset for the next
line with the next character.
(WebCore::CSSParser::syntaxError):
(WebCore::CSSParser::logError):
Include column information.
* css/StyleSheetContents.cpp:
(WebCore::StyleSheetContents::parseAuthorStyleSheet):
(WebCore::StyleSheetContents::parseString):
(WebCore::StyleSheetContents::parseStringAtLineAndColumn):
Include column information.
* css/StyleSheetContents.h:
* dom/InlineStyleSheetOwner.cpp:
(WebCore::InlineStyleSheetOwner::InlineStyleSheetOwner):
(WebCore::InlineStyleSheetOwner::createSheet):
Save and use column information later on.
* dom/InlineStyleSheetOwner.h:
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::ensureSourceData):
Updated parser signature needs starting column and no longer has optional parameters.
Source/WebInspectorUI:
* UserInterface/Views/ConsoleMessageImpl.js:
(WebInspector.ConsoleMessageImpl.prototype._linkifyLocation):
Column numbers in console messages are also 1 based and should be adjusted.
LayoutTests:
Test errors in both external and inline CSS and Scripts to ensure they have
expected line:column information.
* inspector-protocol/console/warnings-errors-expected.txt: Added.
* inspector-protocol/console/warnings-errors.html: Added.
* inspector-protocol/resources/errors.css: Added.
* inspector-protocol/resources/errors.js: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSParsercpp">trunk/Source/WebCore/css/CSSParser.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSParserh">trunk/Source/WebCore/css/CSSParser.h</a></li>
<li><a href="#trunkSourceWebCorecssStyleSheetContentscpp">trunk/Source/WebCore/css/StyleSheetContents.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleSheetContentsh">trunk/Source/WebCore/css/StyleSheetContents.h</a></li>
<li><a href="#trunkSourceWebCoredomInlineStyleSheetOwnercpp">trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp</a></li>
<li><a href="#trunkSourceWebCoredomInlineStyleSheetOwnerh">trunk/Source/WebCore/dom/InlineStyleSheetOwner.h</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorStyleSheetcpp">trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsConsoleMessageImpljs">trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsinspectorprotocolconsolewarningserrorsexpectedtxt">trunk/LayoutTests/inspector-protocol/console/warnings-errors-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorprotocolconsolewarningserrorshtml">trunk/LayoutTests/inspector-protocol/console/warnings-errors.html</a></li>
<li><a href="#trunkLayoutTestsinspectorprotocolresourceserrorscss">trunk/LayoutTests/inspector-protocol/resources/errors.css</a></li>
<li><a href="#trunkLayoutTestsinspectorprotocolresourceserrorsjs">trunk/LayoutTests/inspector-protocol/resources/errors.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (181366 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-03-11 05:56:24 UTC (rev 181366)
+++ trunk/LayoutTests/ChangeLog        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2015-03-10 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: CSS parser errors in the console should include column numbers
+ https://bugs.webkit.org/show_bug.cgi?id=114313
+
+ Reviewed by Benjamin Poulain.
+
+ Test errors in both external and inline CSS and Scripts to ensure they have
+ expected line:column information.
+
+ * inspector-protocol/console/warnings-errors-expected.txt: Added.
+ * inspector-protocol/console/warnings-errors.html: Added.
+ * inspector-protocol/resources/errors.css: Added.
+ * inspector-protocol/resources/errors.js: Added.
+
</ins><span class="cx"> 2015-03-10 Gyuyoung Kim <gyuyoung.kim@samsung.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed EFL gardening on 10th Mar.
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorprotocolconsolewarningserrorsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector-protocol/console/warnings-errors-expected.txt (0 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector-protocol/console/warnings-errors-expected.txt         (rev 0)
+++ trunk/LayoutTests/inspector-protocol/console/warnings-errors-expected.txt        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+CONSOLE MESSAGE: line 1: error script
+CONSOLE MESSAGE: line 1: warn script
+CONSOLE MESSAGE: line 5: error script
+CONSOLE MESSAGE: line 6: warn script
+CONSOLE MESSAGE: line 15: TypeError: undefined is not an object (evaluating '[].x.x')
+CONSOLE MESSAGE: line 17: warn 1
+CONSOLE MESSAGE: line 17: error 1
+CONSOLE MESSAGE: line 18: error 2
+Tests that CSS/JavaScript errors and warnings are sent to the console with line and column information.
+{"source":"css","level":"warning","text":"Invalid CSS property declaration at: *","location":"warnings-errors.html:5:20"}
+{"source":"css","level":"warning","text":"Invalid CSS property declaration at: *","location":"warnings-errors.html:6:14"}
+{"source":"css","level":"warning","text":"Invalid CSS property declaration at: *","location":"warnings-errors.html:7:7"}
+{"source":"css","level":"warning","text":"Invalid CSS property declaration at: *","location":"warnings-errors.html:9:8"}
+{"source":"css","level":"warning","text":"Invalid CSS property declaration at: *","location":"errors.css:1:7"}
+{"source":"css","level":"warning","text":"Invalid CSS property declaration at: *","location":"errors.css:1:29"}
+{"source":"css","level":"warning","text":"Invalid CSS property declaration at: *","location":"errors.css:4:5"}
+{"source":"console-api","level":"error","text":"error script","location":"errors.js:1:14","parameters":[{"type":"string"}]}
+{"source":"console-api","level":"warning","text":"warn script","location":"errors.js:1:44","parameters":[{"type":"string"}]}
+{"source":"console-api","level":"error","text":"error script","location":"errors.js:5:18","parameters":[{"type":"string"}]}
+{"source":"console-api","level":"warning","text":"warn script","location":"errors.js:6:17","parameters":[{"type":"string"}]}
+{"source":"javascript","level":"error","text":"TypeError: undefined is not an object (evaluating '[].x.x')","location":"warnings-errors.html:15:18"}
+{"source":"console-api","level":"warning","text":"warn 1","location":"warnings-errors.html:17:13","parameters":[{"type":"string"}]}
+{"source":"console-api","level":"error","text":"error 1","location":"warnings-errors.html:17:38","parameters":[{"type":"string"}]}
+{"source":"console-api","level":"error","text":"error 2","location":"warnings-errors.html:18:17","parameters":[{"type":"string"}]}
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorprotocolconsolewarningserrorshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector-protocol/console/warnings-errors.html (0 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector-protocol/console/warnings-errors.html         (rev 0)
+++ trunk/LayoutTests/inspector-protocol/console/warnings-errors.html        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+<html>
+<head>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
+<link rel="stylesheet" href="../resources/errors.css">
+ <style> div { * color: red; }</style>
+<style>div { * color: red; }
+div { * color: red; }
+ div {
+ *
+ color:
+ red;
+ }
+</style>
+<script src="../resources/errors.js" type="text/javascript" charset="utf-8"></script>
+ <script> [].x.x </script>
+<script>
+console.warn("warn 1"); console.error("error 1");
+ console.error("error 2");
+</script>
+<script>
+function test()
+{
+ InspectorTest.importScript("../../../../inspector-protocol/resources/console-helper.js");
+
+ InspectorTest.sendCommand("Console.enable", {});
+
+ var consoleMessageCount = 0;
+ const expectedConsoleMessages = 15;
+
+ InspectorTest.eventHandler["Console.messageAdded"] = function(messageObject)
+ {
+ var simplifiedMessage = ConsoleHelper.simplifiedConsoleMessage(messageObject);
+ InspectorTest.log(JSON.stringify(simplifiedMessage));
+
+ if (++consoleMessageCount === expectedConsoleMessages)
+ InspectorTest.completeTest();
+ }
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>
+Tests that CSS/JavaScript errors and warnings are sent to the console with line and column information.<br>
+</p>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorprotocolresourceserrorscss"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector-protocol/resources/errors.css (0 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector-protocol/resources/errors.css         (rev 0)
+++ trunk/LayoutTests/inspector-protocol/resources/errors.css        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+div { * color: red; } div { * color: red; }
+
+div {
+ *
+ color:
+ red;
+}
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorprotocolresourceserrorsjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector-protocol/resources/errors.js (0 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector-protocol/resources/errors.js         (rev 0)
+++ trunk/LayoutTests/inspector-protocol/resources/errors.js        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+console.error("error script"); console.warn("warn script");
+
+
+function foo() {
+ console.error("error script");
+ console.warn("warn script");
+}
+
+foo();
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (181366 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-03-11 05:56:24 UTC (rev 181366)
+++ trunk/Source/WebCore/ChangeLog        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -1,3 +1,52 @@
</span><ins>+2015-03-10 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: CSS parser errors in the console should include column numbers
+ https://bugs.webkit.org/show_bug.cgi?id=114313
+
+ Reviewed by Benjamin Poulain.
+
+ Test: inspector-protocol/console/warnings-errors.html
+
+ * css/CSSParser.h:
+ (WebCore::CSSParser::currentCharacterOffset):
+ Get the current character offset depending on the source type.
+ Add instance variables to track column position and start
+ line / column for inline stylesheets.
+
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::CSSParser):
+ (WebCore::CSSParser::parseSheet):
+ Initialize new instance variables.
+
+ (WebCore::CSSParser::currentLocation):
+ Update to include column information. Also, if we are on the first line
+ we may need to take into account a start column offset as well.
+
+ (WebCore::CSSParser::realLex):
+ When bumping the line number, reset the column offset for the next
+ line with the next character.
+
+ (WebCore::CSSParser::syntaxError):
+ (WebCore::CSSParser::logError):
+ Include column information.
+
+ * css/StyleSheetContents.cpp:
+ (WebCore::StyleSheetContents::parseAuthorStyleSheet):
+ (WebCore::StyleSheetContents::parseString):
+ (WebCore::StyleSheetContents::parseStringAtLineAndColumn):
+ Include column information.
+
+ * css/StyleSheetContents.h:
+ * dom/InlineStyleSheetOwner.cpp:
+ (WebCore::InlineStyleSheetOwner::InlineStyleSheetOwner):
+ (WebCore::InlineStyleSheetOwner::createSheet):
+ Save and use column information later on.
+
+ * dom/InlineStyleSheetOwner.h:
+ * inspector/InspectorStyleSheet.cpp:
+ (WebCore::InspectorStyleSheet::ensureSourceData):
+ Updated parser signature needs starting column and no longer has optional parameters.
+
</ins><span class="cx"> 2015-03-10 Darin Adler <darin@apple.com>
</span><span class="cx">
</span><span class="cx"> Try to fix the GTK build.
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSParser.cpp (181366 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSParser.cpp        2015-03-11 05:56:24 UTC (rev 181366)
+++ trunk/Source/WebCore/css/CSSParser.cpp        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -331,6 +331,9 @@
</span><span class="cx"> , m_lineNumber(0)
</span><span class="cx"> , m_tokenStartLineNumber(0)
</span><span class="cx"> , m_lastSelectorLineNumber(0)
</span><ins>+ , m_columnOffsetForLine(0)
+ , m_sheetStartLineNumber(0)
+ , m_sheetStartColumnNumber(0)
</ins><span class="cx"> , m_allowImportRules(true)
</span><span class="cx"> , m_allowNamespaceDeclarations(true)
</span><span class="cx"> #if ENABLE(CSS_DEVICE_ADAPTATION)
</span><span class="lines">@@ -429,7 +432,7 @@
</span><span class="cx"> m_lexFunc = &CSSParser::realLex<UChar>;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void CSSParser::parseSheet(StyleSheetContents* sheet, const String& string, int startLineNumber, RuleSourceDataList* ruleSourceDataResult, bool logErrors)
</del><ins>+void CSSParser::parseSheet(StyleSheetContents* sheet, const String& string, int startLineNumber, int startColumnNumber, RuleSourceDataList* ruleSourceDataResult, bool logErrors)
</ins><span class="cx"> {
</span><span class="cx"> setStyleSheet(sheet);
</span><span class="cx"> m_defaultNamespace = starAtom; // Reset the default namespace.
</span><span class="lines">@@ -440,6 +443,9 @@
</span><span class="cx"> m_logErrors = logErrors && sheet->singleOwnerDocument() && !sheet->baseURL().isEmpty() && sheet->singleOwnerDocument()->page();
</span><span class="cx"> m_ignoreErrorsInDeclaration = false;
</span><span class="cx"> m_lineNumber = startLineNumber;
</span><ins>+ m_columnOffsetForLine = 0;
+ m_sheetStartLineNumber = startLineNumber;
+ m_sheetStartColumnNumber = startColumnNumber;
</ins><span class="cx"> setupParser("", string, "");
</span><span class="cx"> cssyyparse(this);
</span><span class="cx"> sheet->shrinkToFit();
</span><span class="lines">@@ -10483,10 +10489,19 @@
</span><span class="cx"> {
</span><span class="cx"> Location location;
</span><span class="cx"> location.lineNumber = m_tokenStartLineNumber;
</span><ins>+ location.columnNumber = tokenStartOffset() - m_columnOffsetForLine;
+
+ ASSERT(location.lineNumber >= 0);
+ ASSERT(location.columnNumber >= 0);
+
+ if (m_tokenStartLineNumber == m_sheetStartLineNumber)
+ location.columnNumber += m_sheetStartColumnNumber;
+
</ins><span class="cx"> if (is8BitSource())
</span><span class="cx"> location.token.init(tokenStart<LChar>(), currentCharacter<LChar>() - tokenStart<LChar>());
</span><span class="cx"> else
</span><span class="cx"> location.token.init(tokenStart<UChar>(), currentCharacter<UChar>() - tokenStart<UChar>());
</span><ins>+
</ins><span class="cx"> return location;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -11580,9 +11595,12 @@
</span><span class="cx"> // Might start with a '\n'.
</span><span class="cx"> --currentCharacter<SrcCharacterType>();
</span><span class="cx"> do {
</span><del>- if (*currentCharacter<SrcCharacterType>() == '\n')
</del><ins>+ if (*currentCharacter<SrcCharacterType>() == '\n') {
</ins><span class="cx"> ++m_lineNumber;
</span><del>- ++currentCharacter<SrcCharacterType>();
</del><ins>+ ++currentCharacter<SrcCharacterType>();
+ m_columnOffsetForLine = currentCharacterOffset();
+ } else
+ ++currentCharacter<SrcCharacterType>();
</ins><span class="cx"> } while (*currentCharacter<SrcCharacterType>() <= ' ' && (typesOfASCIICharacters[*currentCharacter<SrcCharacterType>()] == CharacterWhiteSpace));
</span><span class="cx"> break;
</span><span class="cx">
</span><span class="lines">@@ -11650,8 +11668,12 @@
</span><span class="cx"> if (*currentCharacter<SrcCharacterType>() == '*') {
</span><span class="cx"> ++currentCharacter<SrcCharacterType>();
</span><span class="cx"> while (currentCharacter<SrcCharacterType>()[0] != '*' || currentCharacter<SrcCharacterType>()[1] != '/') {
</span><del>- if (*currentCharacter<SrcCharacterType>() == '\n')
</del><ins>+ if (*currentCharacter<SrcCharacterType>() == '\n') {
</ins><span class="cx"> ++m_lineNumber;
</span><ins>+ ++currentCharacter<SrcCharacterType>();
+ m_columnOffsetForLine = currentCharacterOffset();
+ continue;
+ }
</ins><span class="cx"> if (*currentCharacter<SrcCharacterType>() == '\0') {
</span><span class="cx"> // Unterminated comments are simply ignored.
</span><span class="cx"> currentCharacter<SrcCharacterType>() -= 2;
</span><span class="lines">@@ -11869,14 +11891,15 @@
</span><span class="cx"> {
</span><span class="cx"> if (!isLoggingErrors())
</span><span class="cx"> return;
</span><ins>+
</ins><span class="cx"> StringBuilder builder;
</span><span class="cx"> switch (error) {
</span><span class="cx"> case PropertyDeclarationError:
</span><span class="cx"> builder.appendLiteral("Invalid CSS property declaration at: ");
</span><span class="cx"> break;
</span><del>-
</del><span class="cx"> default:
</span><span class="cx"> builder.appendLiteral("Unexpected CSS token: ");
</span><ins>+ break;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (location.token.is8Bit())
</span><span class="lines">@@ -11884,7 +11907,7 @@
</span><span class="cx"> else
</span><span class="cx"> builder.append(location.token.characters16(), location.token.length());
</span><span class="cx">
</span><del>- logError(builder.toString(), location.lineNumber);
</del><ins>+ logError(builder.toString(), location.lineNumber, location.columnNumber);
</ins><span class="cx">
</span><span class="cx"> m_ignoreErrorsInDeclaration = true;
</span><span class="cx"> }
</span><span class="lines">@@ -11894,11 +11917,10 @@
</span><span class="cx"> return m_logErrors && !m_ignoreErrorsInDeclaration;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void CSSParser::logError(const String& message, int lineNumber)
</del><ins>+void CSSParser::logError(const String& message, int lineNumber, int columnNumber)
</ins><span class="cx"> {
</span><del>- // FIXME: <http://webkit.org/b/114313> CSS parser console message errors should include column numbers.
</del><span class="cx"> PageConsoleClient& console = m_styleSheet->singleOwnerDocument()->page()->console();
</span><del>- console.addMessage(MessageSource::CSS, MessageLevel::Warning, message, m_styleSheet->baseURL().string(), lineNumber + 1, 0);
</del><ins>+ console.addMessage(MessageSource::CSS, MessageLevel::Warning, message, m_styleSheet->baseURL().string(), lineNumber + 1, columnNumber + 1);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PassRefPtr<StyleRuleKeyframes> CSSParser::createKeyframesRule(const String& name, std::unique_ptr<Vector<RefPtr<StyleKeyframe>>> popKeyframes)
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSParser.h (181366 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSParser.h        2015-03-11 05:56:24 UTC (rev 181366)
+++ trunk/Source/WebCore/css/CSSParser.h        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -105,7 +105,7 @@
</span><span class="cx">
</span><span class="cx"> WEBCORE_EXPORT ~CSSParser();
</span><span class="cx">
</span><del>- void parseSheet(StyleSheetContents*, const String&, int startLineNumber = 0, RuleSourceDataList* = nullptr, bool = false);
</del><ins>+ void parseSheet(StyleSheetContents*, const String&, int startLineNumber, int startColumnNumber, RuleSourceDataList*, bool logErrors);
</ins><span class="cx"> PassRefPtr<StyleRuleBase> parseRule(StyleSheetContents*, const String&);
</span><span class="cx"> PassRefPtr<StyleKeyframe> parseKeyframeRule(StyleSheetContents*, const String&);
</span><span class="cx"> bool parseSupportsCondition(const String&);
</span><span class="lines">@@ -464,6 +464,8 @@
</span><span class="cx"> inline unsigned tokenStartOffset();
</span><span class="cx"> inline UChar tokenStartChar();
</span><span class="cx">
</span><ins>+ inline unsigned currentCharacterOffset();
+
</ins><span class="cx"> template <typename CharacterType>
</span><span class="cx"> inline bool isIdentifierStart();
</span><span class="cx">
</span><span class="lines">@@ -593,7 +595,11 @@
</span><span class="cx"> int m_lineNumber;
</span><span class="cx"> int m_tokenStartLineNumber;
</span><span class="cx"> int m_lastSelectorLineNumber;
</span><ins>+ int m_columnOffsetForLine;
</ins><span class="cx">
</span><ins>+ int m_sheetStartLineNumber;
+ int m_sheetStartColumnNumber;
+
</ins><span class="cx"> bool m_allowImportRules;
</span><span class="cx"> bool m_allowNamespaceDeclarations;
</span><span class="cx">
</span><span class="lines">@@ -642,7 +648,7 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> bool isLoggingErrors();
</span><del>- void logError(const String& message, int lineNumber);
</del><ins>+ void logError(const String& message, int lineNumber, int columnNumber);
</ins><span class="cx">
</span><span class="cx"> bool validateCalculationUnit(ValueWithCalculation&, Units);
</span><span class="cx">
</span><span class="lines">@@ -686,6 +692,7 @@
</span><span class="cx">
</span><span class="cx"> struct CSSParser::Location {
</span><span class="cx"> int lineNumber;
</span><ins>+ int columnNumber;
</ins><span class="cx"> CSSParserString token;
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -714,6 +721,13 @@
</span><span class="cx"> return m_tokenStart.ptr16 - m_dataStart16.get();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+inline unsigned CSSParser::currentCharacterOffset()
+{
+ if (is8BitSource())
+ return m_currentCharacter8 - m_dataStart8.get();
+ return m_currentCharacter16 - m_dataStart16.get();
+}
+
</ins><span class="cx"> inline UChar CSSParser::tokenStartChar()
</span><span class="cx"> {
</span><span class="cx"> if (is8BitSource())
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleSheetContentscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleSheetContents.cpp (181366 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleSheetContents.cpp        2015-03-11 05:56:24 UTC (rev 181366)
+++ trunk/Source/WebCore/css/StyleSheetContents.cpp        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -291,7 +291,7 @@
</span><span class="cx"> String sheetText = cachedStyleSheet->sheetText(&hasValidMIMEType);
</span><span class="cx">
</span><span class="cx"> CSSParser p(parserContext());
</span><del>- p.parseSheet(this, sheetText, 0, 0, true);
</del><ins>+ p.parseSheet(this, sheetText, 0, 0, nullptr, true);
</ins><span class="cx">
</span><span class="cx"> // If we're loading a stylesheet cross-origin, and the MIME type is not standard, require the CSS
</span><span class="cx"> // to at least start with a syntactically valid CSS rule.
</span><span class="lines">@@ -316,13 +316,13 @@
</span><span class="cx">
</span><span class="cx"> bool StyleSheetContents::parseString(const String& sheetText)
</span><span class="cx"> {
</span><del>- return parseStringAtLine(sheetText, 0, false);
</del><ins>+ return parseStringAtLineAndColumn(sheetText, 0, 0, false);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-bool StyleSheetContents::parseStringAtLine(const String& sheetText, int startLineNumber, bool createdByParser)
</del><ins>+bool StyleSheetContents::parseStringAtLineAndColumn(const String& sheetText, int startLineNumber, int startColumnNumber, bool createdByParser)
</ins><span class="cx"> {
</span><span class="cx"> CSSParser p(parserContext());
</span><del>- p.parseSheet(this, sheetText, startLineNumber, 0, createdByParser);
</del><ins>+ p.parseSheet(this, sheetText, startLineNumber, startColumnNumber, nullptr, createdByParser);
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleSheetContentsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleSheetContents.h (181366 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleSheetContents.h        2015-03-11 05:56:24 UTC (rev 181366)
+++ trunk/Source/WebCore/css/StyleSheetContents.h        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -62,7 +62,7 @@
</span><span class="cx">
</span><span class="cx"> void parseAuthorStyleSheet(const CachedCSSStyleSheet*, const SecurityOrigin*);
</span><span class="cx"> WEBCORE_EXPORT bool parseString(const String&);
</span><del>- bool parseStringAtLine(const String&, int startLineNumber, bool);
</del><ins>+ bool parseStringAtLineAndColumn(const String&, int startLineNumber, int startColumnNumber, bool createdByParser);
</ins><span class="cx">
</span><span class="cx"> bool isCacheable() const;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoredomInlineStyleSheetOwnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp (181366 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp        2015-03-11 05:56:24 UTC (rev 181366)
+++ trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -35,10 +35,10 @@
</span><span class="cx"> InlineStyleSheetOwner::InlineStyleSheetOwner(Document& document, bool createdByParser)
</span><span class="cx"> : m_isParsingChildren(createdByParser)
</span><span class="cx"> , m_loading(false)
</span><del>- , m_startLineNumber(WTF::OrdinalNumber::beforeFirst())
</del><ins>+ , m_startTextPosition(WTF::OrdinalNumber::beforeFirst(), WTF::OrdinalNumber::beforeFirst())
</ins><span class="cx"> {
</span><span class="cx"> if (createdByParser && document.scriptableDocumentParser() && !document.isInDocumentWrite())
</span><del>- m_startLineNumber = document.scriptableDocumentParser()->textPosition().m_line;
</del><ins>+ m_startTextPosition = document.scriptableDocumentParser()->textPosition();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> InlineStyleSheetOwner::~InlineStyleSheetOwner()
</span><span class="lines">@@ -123,7 +123,7 @@
</span><span class="cx">
</span><span class="cx"> if (!isValidCSSContentType(element, m_contentType))
</span><span class="cx"> return;
</span><del>- if (!document.contentSecurityPolicy()->allowInlineStyle(document.url(), m_startLineNumber))
</del><ins>+ if (!document.contentSecurityPolicy()->allowInlineStyle(document.url(), m_startTextPosition.m_line))
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> RefPtr<MediaQuerySet> mediaQueries;
</span><span class="lines">@@ -144,7 +144,7 @@
</span><span class="cx"> m_sheet = CSSStyleSheet::createInline(element, URL(), document.inputEncoding());
</span><span class="cx"> m_sheet->setMediaQueries(mediaQueries.release());
</span><span class="cx"> m_sheet->setTitle(element.title());
</span><del>- m_sheet->contents().parseStringAtLine(text, m_startLineNumber.zeroBasedInt(), m_isParsingChildren);
</del><ins>+ m_sheet->contents().parseStringAtLineAndColumn(text, m_startTextPosition.m_line.zeroBasedInt(), m_startTextPosition.m_column.zeroBasedInt(), m_isParsingChildren);
</ins><span class="cx">
</span><span class="cx"> m_loading = false;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoredomInlineStyleSheetOwnerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/InlineStyleSheetOwner.h (181366 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/InlineStyleSheetOwner.h        2015-03-11 05:56:24 UTC (rev 181366)
+++ trunk/Source/WebCore/dom/InlineStyleSheetOwner.h        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -57,7 +57,7 @@
</span><span class="cx">
</span><span class="cx"> bool m_isParsingChildren;
</span><span class="cx"> bool m_loading;
</span><del>- WTF::OrdinalNumber m_startLineNumber;
</del><ins>+ WTF::TextPosition m_startTextPosition;
</ins><span class="cx"> AtomicString m_contentType;
</span><span class="cx"> AtomicString m_media;
</span><span class="cx"> RefPtr<CSSStyleSheet> m_sheet;
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorStyleSheetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (181366 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp        2015-03-11 05:56:24 UTC (rev 181366)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -1106,7 +1106,7 @@
</span><span class="cx">
</span><span class="cx"> RefPtr<StyleSheetContents> newStyleSheet = StyleSheetContents::create();
</span><span class="cx"> auto ruleSourceDataResult = std::make_unique<RuleSourceDataList>();
</span><del>- createCSSParser(m_pageStyleSheet->ownerDocument())->parseSheet(newStyleSheet.get(), m_parsedStyleSheet->text(), 0, ruleSourceDataResult.get());
</del><ins>+ createCSSParser(m_pageStyleSheet->ownerDocument())->parseSheet(newStyleSheet.get(), m_parsedStyleSheet->text(), 0, 0, ruleSourceDataResult.get(), false);
</ins><span class="cx"> m_parsedStyleSheet->setSourceData(WTF::move(ruleSourceDataResult));
</span><span class="cx"> return m_parsedStyleSheet->hasSourceData();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (181366 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2015-03-11 05:56:24 UTC (rev 181366)
+++ trunk/Source/WebInspectorUI/ChangeLog        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -1,5 +1,16 @@
</span><span class="cx"> 2015-03-10 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><ins>+ Web Inspector: CSS parser errors in the console should include column numbers
+ https://bugs.webkit.org/show_bug.cgi?id=114313
+
+ Reviewed by Benjamin Poulain.
+
+ * UserInterface/Views/ConsoleMessageImpl.js:
+ (WebInspector.ConsoleMessageImpl.prototype._linkifyLocation):
+ Column numbers in console messages are also 1 based and should be adjusted.
+
+2015-03-10 Joseph Pecoraro <pecoraro@apple.com>
+
</ins><span class="cx"> Web Inspector: console.error output broken, does not produce ObjectTree
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=142554
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsConsoleMessageImpljs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js (181366 => 181367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js        2015-03-11 05:56:24 UTC (rev 181366)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js        2015-03-11 06:11:10 UTC (rev 181367)
</span><span class="lines">@@ -199,6 +199,7 @@
</span><span class="cx"> {
</span><span class="cx"> // ConsoleMessage stack trace line numbers are one-based.
</span><span class="cx"> lineNumber = lineNumber ? lineNumber - 1 : 0;
</span><ins>+ columnNumber = columnNumber ? columnNumber - 1 : 0;
</ins><span class="cx">
</span><span class="cx"> return WebInspector.linkifyLocation(url, lineNumber, columnNumber, "console-message-url");
</span><span class="cx"> },
</span></span></pre>
</div>
</div>
</body>
</html>