Title: [160374] trunk
Revision
160374
Author
commit-qu...@webkit.org
Date
2013-12-10 10:53:51 -0800 (Tue, 10 Dec 2013)

Log Message

PageConsole::addMessage should automatically determine column number alongside line number
https://bugs.webkit.org/show_bug.cgi?id=114319

Patch by László Langó <la...@inf.u-szeged.hu> on 2013-12-10
Reviewed by Joseph Pecoraro.

Source/WebCore:

* dom/InlineStyleSheetOwner.cpp:
(WebCore::InlineStyleSheetOwner::InlineStyleSheetOwner):
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::ScriptElement):
* dom/ScriptableDocumentParser.h:
* dom/StyledElement.cpp:
(WebCore::StyledElement::styleAttributeChanged):
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser):
(WebCore::HTMLDocumentParser::pumpPendingSpeculations):
* html/parser/HTMLDocumentParser.h:
* inspector/InspectorResourceAgent.cpp:
(WebCore::InspectorResourceAgent::buildInitiatorObject):
* page/Console.cpp:
(WebCore::internalAddMessage):
* page/PageConsole.cpp:
(WebCore::PageConsole::printSourceURLAndPosition):
(WebCore::PageConsole::addMessage):
* page/PageConsole.h:
* xml/parser/XMLDocumentParser.h:
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::error):

LayoutTests:

* inspector-protocol/page/deny-X-FrameOption-expected.txt: Added.
* inspector-protocol/page/deny-X-FrameOption.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (160373 => 160374)


--- trunk/LayoutTests/ChangeLog	2013-12-10 18:49:42 UTC (rev 160373)
+++ trunk/LayoutTests/ChangeLog	2013-12-10 18:53:51 UTC (rev 160374)
@@ -1,3 +1,13 @@
+2013-12-10  László Langó  <la...@inf.u-szeged.hu>
+
+        PageConsole::addMessage should automatically determine column number alongside line number
+        https://bugs.webkit.org/show_bug.cgi?id=114319
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector-protocol/page/deny-X-FrameOption-expected.txt: Added.
+        * inspector-protocol/page/deny-X-FrameOption.html: Added.
+
 2013-12-10  Michał Pakuła vel Rutka  <m.pak...@samsung.com>
 
         Unreviewed EFL gardening

Added: trunk/LayoutTests/inspector-protocol/page/deny-X-FrameOption-expected.txt (0 => 160374)


--- trunk/LayoutTests/inspector-protocol/page/deny-X-FrameOption-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector-protocol/page/deny-X-FrameOption-expected.txt	2013-12-10 18:53:51 UTC (rev 160374)
@@ -0,0 +1,4 @@
+CONSOLE MESSAGE: Refused to display 'deny-X-FrameOption.html' in a frame because it set 'X-Frame-Options' to 'deny'.
+
+deny-X-FrameOption.html:0:0
+

Added: trunk/LayoutTests/inspector-protocol/page/deny-X-FrameOption.html (0 => 160374)


--- trunk/LayoutTests/inspector-protocol/page/deny-X-FrameOption.html	                        (rev 0)
+++ trunk/LayoutTests/inspector-protocol/page/deny-X-FrameOption.html	2013-12-10 18:53:51 UTC (rev 160374)
@@ -0,0 +1,31 @@
+<html>
+<head>
+<script type="text/_javascript_" src=""
+<script>
+function test()
+{
+    InspectorTest.importScript("../../../../inspector-protocol/resources/console-helper.js");
+    InspectorTest.sendCommand("Console.enable", {});
+
+    InspectorTest.eventHandler["Console.messageAdded"] = function(messageObject)
+    {
+        var simplifiedMessage = ConsoleHelper.simplifiedConsoleMessage(messageObject);
+        // FIXME The line and column values will be zeros until this fix:
+        // https://bugs.webkit.org/show_bug.cgi?id=125340
+        // After this probably we should update the expected.txt.
+        InspectorTest.log(simplifiedMessage.location);
+
+        InspectorTest.completeTest();
+    }
+}
+</script>
+</head>
+<body _onload_="runTest()">
+  <iframe id=foo></iframe>
+  <script>
+    var fooFrame = document.getElementById('foo');
+    var fooDoc = fooFrame.contentWindow.document;
+    fooDoc.write('<meta http-equiv="X-Frame-Options" content="deny"/>');
+  </script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (160373 => 160374)


--- trunk/Source/WebCore/ChangeLog	2013-12-10 18:49:42 UTC (rev 160373)
+++ trunk/Source/WebCore/ChangeLog	2013-12-10 18:53:51 UTC (rev 160374)
@@ -1,3 +1,33 @@
+2013-12-10  László Langó  <la...@inf.u-szeged.hu>
+
+        PageConsole::addMessage should automatically determine column number alongside line number
+        https://bugs.webkit.org/show_bug.cgi?id=114319
+
+        Reviewed by Joseph Pecoraro.
+
+        * dom/InlineStyleSheetOwner.cpp:
+        (WebCore::InlineStyleSheetOwner::InlineStyleSheetOwner):
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::ScriptElement):
+        * dom/ScriptableDocumentParser.h:
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::styleAttributeChanged):
+        * html/parser/HTMLDocumentParser.cpp:
+        (WebCore::HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser):
+        (WebCore::HTMLDocumentParser::pumpPendingSpeculations):
+        * html/parser/HTMLDocumentParser.h:
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::InspectorResourceAgent::buildInitiatorObject):
+        * page/Console.cpp:
+        (WebCore::internalAddMessage):
+        * page/PageConsole.cpp:
+        (WebCore::PageConsole::printSourceURLAndPosition):
+        (WebCore::PageConsole::addMessage):
+        * page/PageConsole.h:
+        * xml/parser/XMLDocumentParser.h:
+        * xml/parser/XMLDocumentParserLibxml2.cpp:
+        (WebCore::XMLDocumentParser::error):
+
 2013-12-10  Andreas Kling  <akl...@apple.com>
 
         Jettison all StyleResolver data on memory pressure.

Modified: trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp (160373 => 160374)


--- trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp	2013-12-10 18:49:42 UTC (rev 160373)
+++ trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp	2013-12-10 18:53:51 UTC (rev 160374)
@@ -38,7 +38,7 @@
     , m_startLineNumber(WTF::OrdinalNumber::beforeFirst())
 {
     if (createdByParser && document.scriptableDocumentParser() && !document.isInDocumentWrite())
-        m_startLineNumber = document.scriptableDocumentParser()->lineNumber();
+        m_startLineNumber = document.scriptableDocumentParser()->textPosition().m_line;
 }
 
 InlineStyleSheetOwner::~InlineStyleSheetOwner()

Modified: trunk/Source/WebCore/dom/ScriptElement.cpp (160373 => 160374)


--- trunk/Source/WebCore/dom/ScriptElement.cpp	2013-12-10 18:49:42 UTC (rev 160373)
+++ trunk/Source/WebCore/dom/ScriptElement.cpp	2013-12-10 18:53:51 UTC (rev 160374)
@@ -75,7 +75,7 @@
 {
     ASSERT(m_element);
     if (parserInserted && m_element->document().scriptableDocumentParser() && !m_element->document().isInDocumentWrite())
-        m_startLineNumber = m_element->document().scriptableDocumentParser()->lineNumber();
+        m_startLineNumber = m_element->document().scriptableDocumentParser()->textPosition().m_line;
 }
 
 ScriptElement::~ScriptElement()

Modified: trunk/Source/WebCore/dom/ScriptableDocumentParser.h (160373 => 160374)


--- trunk/Source/WebCore/dom/ScriptableDocumentParser.h	2013-12-10 18:49:42 UTC (rev 160373)
+++ trunk/Source/WebCore/dom/ScriptableDocumentParser.h	2013-12-10 18:53:51 UTC (rev 160374)
@@ -44,8 +44,6 @@
 
     virtual bool isWaitingForScripts() const = 0;
 
-    // These are used to expose the current line/column to the scripting system.
-    virtual OrdinalNumber lineNumber() const = 0;
     virtual TextPosition textPosition() const = 0;
 
     void setWasCreatedByScript(bool wasCreatedByScript) { m_wasCreatedByScript = wasCreatedByScript; }

Modified: trunk/Source/WebCore/dom/StyledElement.cpp (160373 => 160374)


--- trunk/Source/WebCore/dom/StyledElement.cpp	2013-12-10 18:49:42 UTC (rev 160373)
+++ trunk/Source/WebCore/dom/StyledElement.cpp	2013-12-10 18:53:51 UTC (rev 160374)
@@ -195,7 +195,7 @@
 {
     WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst();
     if (document().scriptableDocumentParser() && !document().isInDocumentWrite())
-        startLineNumber = document().scriptableDocumentParser()->lineNumber();
+        startLineNumber = document().scriptableDocumentParser()->textPosition().m_line;
 
     if (newStyleString.isNull()) {
         if (PropertySetCSSStyleDeclaration* cssomWrapper = inlineStyleCSSOMWrapper())

Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp (160373 => 160374)


--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp	2013-12-10 18:49:42 UTC (rev 160373)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp	2013-12-10 18:53:51 UTC (rev 160374)
@@ -314,13 +314,13 @@
     // but we need to ensure it isn't deleted yet.
     Ref<HTMLDocumentParser> protect(*this);
 
-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteHTML(document(), lineNumber().zeroBasedInt());
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteHTML(document(), textPosition().m_line.zeroBasedInt());
 
     ASSERT(m_speculations.isEmpty());
     chunk->preloads.clear(); // We don't need to preload because we're going to parse immediately.
     processParsedChunkFromBackgroundParser(chunk);
 
-    InspectorInstrumentation::didWriteHTML(cookie, lineNumber().zeroBasedInt());
+    InspectorInstrumentation::didWriteHTML(cookie, textPosition().m_line.zeroBasedInt());
 }
 
 void HTMLDocumentParser::validateSpeculations(OwnPtr<ParsedChunk> chunk)
@@ -458,7 +458,7 @@
     ASSERT(!m_lastChunkBeforeScript);
 
     // FIXME: Pass in current input length.
-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteHTML(document(), lineNumber().zeroBasedInt());
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteHTML(document(), textPosition().m_line.zeroBasedInt());
 
     double startTime = monotonicallyIncreasingTime();
 
@@ -474,7 +474,7 @@
         }
     }
 
-    InspectorInstrumentation::didWriteHTML(cookie, lineNumber().zeroBasedInt());
+    InspectorInstrumentation::didWriteHTML(cookie, textPosition().m_line.zeroBasedInt());
 }
 
 #endif // ENABLE(THREADED_HTML_PARSER)
@@ -828,16 +828,6 @@
     return m_scriptRunner->isExecutingScript();
 }
 
-OrdinalNumber HTMLDocumentParser::lineNumber() const
-{
-#if ENABLE(THREADED_HTML_PARSER)
-    if (m_haveBackgroundParser)
-        return m_textPosition.m_line;
-#endif
-
-    return m_input.current().currentLine();
-}
-
 TextPosition HTMLDocumentParser::textPosition() const
 {
 #if ENABLE(THREADED_HTML_PARSER)

Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.h (160373 => 160374)


--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.h	2013-12-10 18:49:42 UTC (rev 160373)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.h	2013-12-10 18:53:51 UTC (rev 160374)
@@ -80,7 +80,6 @@
     HTMLTokenizer* tokenizer() const { return m_tokenizer.get(); }
 
     virtual TextPosition textPosition() const;
-    virtual OrdinalNumber lineNumber() const;
 
     virtual void suspendScheduledTasks();
     virtual void resumeScheduledTasks();

Modified: trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp (160373 => 160374)


--- trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp	2013-12-10 18:49:42 UTC (rev 160373)
+++ trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp	2013-12-10 18:53:51 UTC (rev 160374)
@@ -454,7 +454,7 @@
         RefPtr<TypeBuilder::Network::Initiator> initiatorObject = TypeBuilder::Network::Initiator::create()
             .setType(TypeBuilder::Network::Initiator::Type::Parser);
         initiatorObject->setUrl(document->url().string());
-        initiatorObject->setLineNumber(document->scriptableDocumentParser()->lineNumber().oneBasedInt());
+        initiatorObject->setLineNumber(document->scriptableDocumentParser()->textPosition().m_line.oneBasedInt());
         return initiatorObject;
     }
 

Modified: trunk/Source/WebCore/page/Console.cpp (160373 => 160374)


--- trunk/Source/WebCore/page/Console.cpp	2013-12-10 18:49:42 UTC (rev 160373)
+++ trunk/Source/WebCore/page/Console.cpp	2013-12-10 18:53:51 UTC (rev 160374)
@@ -92,7 +92,7 @@
     if (!page->settings().logsPageMessagesToSystemConsoleEnabled() && !PageConsole::shouldPrintExceptions())
         return;
 
-    PageConsole::printSourceURLAndLine(lastCaller.sourceURL(), lastCaller.lineNumber());
+    PageConsole::printSourceURLAndPosition(lastCaller.sourceURL(), lastCaller.lineNumber());
     PageConsole::printMessageSourceAndLevelPrefix(ConsoleAPIMessageSource, level);
 
     for (size_t i = 0; i < arguments->argumentCount(); ++i) {

Modified: trunk/Source/WebCore/page/PageConsole.cpp (160373 => 160374)


--- trunk/Source/WebCore/page/PageConsole.cpp	2013-12-10 18:49:42 UTC (rev 160373)
+++ trunk/Source/WebCore/page/PageConsole.cpp	2013-12-10 18:53:51 UTC (rev 160374)
@@ -64,11 +64,11 @@
 {
 }
 
-void PageConsole::printSourceURLAndLine(const String& sourceURL, unsigned lineNumber)
+void PageConsole::printSourceURLAndPosition(const String& sourceURL, unsigned lineNumber, unsigned columnNumber)
 {
     if (!sourceURL.isEmpty()) {
-        if (lineNumber > 0)
-            printf("%s:%d: ", sourceURL.utf8().data(), lineNumber);
+        if (lineNumber > 0 && columnNumber > 0)
+            printf("%s:%u:%u: ", sourceURL.utf8().data(), lineNumber, columnNumber);
         else
             printf("%s: ", sourceURL.utf8().data());
     }
@@ -142,18 +142,22 @@
     String url;
     if (document)
         url = ""
-    // FIXME: <http://webkit.org/b/114319> PageConsole::addMessage should automatically determine column number alongside line number.
     // FIXME: The below code attempts to determine line numbers for parser generated errors, but this is not the only reason why we can get here.
     // For example, if we are still parsing and get a WebSocket network error, it will be erroneously attributed to a line where parsing was paused.
     // Also, we should determine line numbers for script generated messages (e.g. calling getImageData on a canvas).
     // We probably need to split this function into multiple ones, as appropriate for different call sites. Or maybe decide based on MessageSource.
+    // https://bugs.webkit.org/show_bug.cgi?id=125340
     unsigned line = 0;
+    unsigned column = 0;
     if (document && document->parsing() && !document->isInDocumentWrite() && document->scriptableDocumentParser()) {
         ScriptableDocumentParser* parser = document->scriptableDocumentParser();
-        if (!parser->isWaitingForScripts() && !JSMainThreadExecState::currentState())
-            line = parser->lineNumber().oneBasedInt();
+        if (!parser->isWaitingForScripts() && !JSMainThreadExecState::currentState()) {
+            TextPosition position = parser->textPosition();
+            line = position.m_line.oneBasedInt();
+            column = position.m_column.oneBasedInt();
+        }
     }
-    addMessage(source, level, message, url, line, 0, 0, 0, requestIdentifier);
+    addMessage(source, level, message, url, line, column, 0, 0, requestIdentifier);
 }
 
 void PageConsole::addMessage(MessageSource source, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack)
@@ -182,7 +186,7 @@
     if (!m_page.settings().logsPageMessagesToSystemConsoleEnabled() && !shouldPrintExceptions())
         return;
 
-    printSourceURLAndLine(url, lineNumber);
+    printSourceURLAndPosition(url, lineNumber, columnNumber);
     printMessageSourceAndLevelPrefix(source, level);
 
     printf(" %s\n", message.utf8().data());

Modified: trunk/Source/WebCore/page/PageConsole.h (160373 => 160374)


--- trunk/Source/WebCore/page/PageConsole.h	2013-12-10 18:49:42 UTC (rev 160373)
+++ trunk/Source/WebCore/page/PageConsole.h	2013-12-10 18:53:51 UTC (rev 160374)
@@ -48,7 +48,7 @@
     PageConsole(Page&);
     ~PageConsole();
 
-    static void printSourceURLAndLine(const String& sourceURL, unsigned lineNumber);
+    static void printSourceURLAndPosition(const String& sourceURL, unsigned lineNumber, unsigned columnNumber = 0);
     static void printMessageSourceAndLevelPrefix(MessageSource, MessageLevel);
 
     void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, PassRefPtr<ScriptCallStack> = 0, JSC::ExecState* = 0, unsigned long requestIdentifier = 0);

Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParser.h (160373 => 160374)


--- trunk/Source/WebCore/xml/parser/XMLDocumentParser.h	2013-12-10 18:49:42 UTC (rev 160373)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParser.h	2013-12-10 18:53:51 UTC (rev 160374)
@@ -105,8 +105,6 @@
         virtual bool isWaitingForScripts() const;
         virtual void stopParsing();
         virtual void detach();
-        virtual OrdinalNumber lineNumber() const;
-        OrdinalNumber columnNumber() const;
 
         // from CachedResourceClient
         virtual void notifyFinished(CachedResource*);

Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (160373 => 160374)


--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp	2013-12-10 18:49:42 UTC (rev 160373)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp	2013-12-10 18:53:51 UTC (rev 160374)
@@ -972,8 +972,9 @@
     vsnprintf(m, sizeof(m) - 1, message, args);
 #endif
 
+    TextPosition position = textPosition();
     if (m_parserPaused)
-        m_pendingCallbacks->appendErrorCallback(type, reinterpret_cast<const xmlChar*>(m), lineNumber(), columnNumber());
+        m_pendingCallbacks->appendErrorCallback(type, reinterpret_cast<const xmlChar*>(m), position.m_line, position.m_column);
     else
         handleError(type, m, textPosition());
 
@@ -1426,16 +1427,6 @@
 }
 #endif
 
-OrdinalNumber XMLDocumentParser::lineNumber() const
-{
-    return OrdinalNumber::fromOneBasedInt(context() ? context()->input->line : 1);
-}
-
-OrdinalNumber XMLDocumentParser::columnNumber() const
-{
-    return OrdinalNumber::fromOneBasedInt(context() ? context()->input->col : 1);
-}
-
 TextPosition XMLDocumentParser::textPosition() const
 {
     xmlParserCtxtPtr context = this->context();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to