WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-45271-20100922213526.patch (text/plain), 69.45 KB, created by
Peter Rybin
on 2010-09-22 10:35:29 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Peter Rybin
Created:
2010-09-22 10:35:29 PDT
Size:
69.45 KB
patch
obsolete
>diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog >index 3490748e4873cf2aaf943b963a6585fdef89178c..8d5b6c378e2d5a342c692693131b312dc0ca9ea4 100644 >--- a/JavaScriptCore/ChangeLog >+++ b/JavaScriptCore/ChangeLog >@@ -1,3 +1,36 @@ >+2010-09-20 Peter Rybin <peter.rybin@gmail.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ HTML parser should provide script column position within HTML document to JavaScript engine >+ https://bugs.webkit.org/show_bug.cgi?id=45271 >+ >+ Adds HTMLPosition* classes -- a structure that stores line/column/generation >+ level coordinates inside HTML document. Adds *BasedNumber classes -- typesafe int >+ wrappers that emphasize whether int number is used as zero-based or >+ one-based. >+ >+ * GNUmakefile.am: >+ * JavaScriptCore.gypi: >+ * wtf/CMakeLists.txt: >+ * wtf/HTMLPosition.cpp: Added. >+ * wtf/HTMLPosition.h: Added. >+ (WTF::HTMLPosition::HTMLPosition): >+ (WTF::HTMLPosition::minimumPosition): >+ (WTF::HTMLPosition::belowRangePosition): >+ (WTF::ZeroBasedNumber::fromZeroBasedInt): >+ (WTF::ZeroBasedNumber::ZeroBasedNumber): >+ (WTF::ZeroBasedNumber::zeroBasedInt): >+ (WTF::OneBasedNumber::fromOneBasedInt): >+ (WTF::OneBasedNumber::OneBasedNumber): >+ (WTF::OneBasedNumber::oneBasedInt): >+ (WTF::OneBasedNumber::convertAsZeroBasedInt): >+ (WTF::OneBasedNumber::convertToZeroBased): >+ (WTF::toZeroBasedHTMLPosition): >+ (WTF::toOneBasedHTMLPosition): >+ (WTF::ZeroBasedNumber::convertToOneBased): >+ * wtf/wtf.pri: >+ > 2010-09-19 Gavin Barraclough <barraclough@apple.com> > > Windows build fix pt 2. >diff --git a/JavaScriptCore/GNUmakefile.am b/JavaScriptCore/GNUmakefile.am >index dd2ba21d9d5db92eef75c6c2ed8d3bd405058c4e..4c2e77c789703bdcaa9c8b2416716cb9d2e297f4 100644 >--- a/JavaScriptCore/GNUmakefile.am >+++ b/JavaScriptCore/GNUmakefile.am >@@ -453,6 +453,8 @@ javascriptcore_sources += \ > JavaScriptCore/wtf/HashTable.cpp \ > JavaScriptCore/wtf/HashTable.h \ > JavaScriptCore/wtf/HashTraits.h \ >+ JavaScriptCore/wtf/HTMLPosition.cpp \ >+ JavaScriptCore/wtf/HTMLPosition.h \ > JavaScriptCore/wtf/ListHashSet.h \ > JavaScriptCore/wtf/ListRefPtr.h \ > JavaScriptCore/wtf/Locker.h \ >diff --git a/JavaScriptCore/JavaScriptCore.gypi b/JavaScriptCore/JavaScriptCore.gypi >index 462960d51dd6dbe402d5863d208c1328cbc15ace..6e1c1a90877c37e4ee8964c57a26325baa667a9f 100644 >--- a/JavaScriptCore/JavaScriptCore.gypi >+++ b/JavaScriptCore/JavaScriptCore.gypi >@@ -384,6 +384,8 @@ > 'wtf/HashTable.cpp', > 'wtf/HashTable.h', > 'wtf/HashTraits.h', >+ 'wtf/HTMLPosition.h', >+ 'wtf/HTMLPosition.cpp', > 'wtf/ListHashSet.h', > 'wtf/ListRefPtr.h', > 'wtf/Locker.h', >diff --git a/JavaScriptCore/wtf/CMakeLists.txt b/JavaScriptCore/wtf/CMakeLists.txt >index 896794ef41e8f021840994ac35247872b2dae169..d067a7a436eb293c6197783ae868886c8acb05f3 100644 >--- a/JavaScriptCore/wtf/CMakeLists.txt >+++ b/JavaScriptCore/wtf/CMakeLists.txt >@@ -4,6 +4,7 @@ SET(WTF_SOURCES > CurrentTime.cpp > FastMalloc.cpp > HashTable.cpp >+ HTMLPosition.cpp > MainThread.cpp > MD5.cpp > RandomNumber.cpp >diff --git a/JavaScriptCore/wtf/HTMLPosition.cpp b/JavaScriptCore/wtf/HTMLPosition.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..0e1a2509190214921c6484ae79ce61c1997b39fd >--- /dev/null >+++ b/JavaScriptCore/wtf/HTMLPosition.cpp >@@ -0,0 +1,37 @@ >+/* >+ * Copyright (C) 2010, Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "HTMLPosition.h" >+ >+namespace WTF { >+ >+const ZeroBasedNumber ZeroBasedNumber::s_base(0); >+const ZeroBasedNumber ZeroBasedNumber::s_belowBase(-1); >+ >+const OneBasedNumber OneBasedNumber::s_base(1); >+const OneBasedNumber OneBasedNumber::s_belowBase(0); >+ >+ >+} // namespace WTF >diff --git a/JavaScriptCore/wtf/HTMLPosition.h b/JavaScriptCore/wtf/HTMLPosition.h >new file mode 100644 >index 0000000000000000000000000000000000000000..3f2a843ff5e2c833639e749d918530309e20c639 >--- /dev/null >+++ b/JavaScriptCore/wtf/HTMLPosition.h >@@ -0,0 +1,147 @@ >+/* >+ * Copyright (C) 2010, Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef HTMLPosition_h >+#define HTMLPosition_h >+ >+#include <wtf/Assertions.h> >+ >+namespace WTF { >+ >+ >+/* >+ * HTML position >+ * >+ * HTMLPosition structure specifies coordinates within an HTML resource. It is used mostly >+ * for saving script source position. The third field 'generation' reflects the fact >+ * that any part of HTML document can be generated on the fly, by a 'document.write' >+ * call. While elements of the generated part may still have coordinates (probably), >+ * we need to distinguish them from coordinates in the original HTML source. >+ * So generation == 0 means that coordinates apply to downloaded HTML file, >+ * generation == 1 applies to a HTML elements generated, generation == 2 to elements >+ * generated from a script in a generated part and so on. >+ * >+ * >+ * >+ * 0-based and 1-based >+ * >+ * Line and column numbers could be interpreted as zero-based or 1-based. Since >+ * both practices coexist in WebKit source base, 'int' type should be replaced with >+ * a dedicated wrapper types, so that compiler helped us with this ambiguity. >+ * >+ * Here we introduce 2 types of numbers: ZeroBasedNumber and OneBasedNumber and >+ * 2 corresponding types of HTMLPosition structure. While only one type ought to be enough, >+ * this is done to keep transition to the new types as transparent as possible: >+ * e.g. in areas where 0-based integers are used, HTMLPosition0 should be introduced. This >+ * way all changes will remain trackable. >+ * Later HTMLPosition0 and HTMLPosition1 can be merged together quite easily. >+ */ >+ >+template<typename NUMBER> >+class HTMLPosition { >+public: >+ HTMLPosition(NUMBER line, NUMBER column, int generation) >+ : m_line(line) >+ , m_column(column) >+ , m_generation(generation) >+ { >+ } >+ HTMLPosition() {} >+ >+ // A 'minimum' value of position, used as a default value. >+ static HTMLPosition<NUMBER> minimumPosition() { return HTMLPosition<NUMBER>(NUMBER::s_base, NUMBER::s_base, 0); } >+ >+ // A value with line value less than a minimum; used as an impossible position. >+ static HTMLPosition<NUMBER> belowRangePosition() { return HTMLPosition<NUMBER>(NUMBER::s_belowBase, NUMBER::s_base, 0); } >+ >+ NUMBER m_line; >+ NUMBER m_column; >+ int m_generation; >+}; >+ >+ >+class OneBasedNumber; >+ >+// An int wrapper that always reminds you that the number should be 0-based >+class ZeroBasedNumber { >+public: >+ static ZeroBasedNumber fromZeroBasedInt(int zeroBasedInt) { return ZeroBasedNumber(zeroBasedInt); } >+ >+ ZeroBasedNumber() {} >+ >+ int zeroBasedInt() const { return m_value; } >+ >+ OneBasedNumber convertToOneBased() const; >+ >+ static const ZeroBasedNumber s_base; // 0 >+ static const ZeroBasedNumber s_belowBase; // -1 >+ >+private: >+ ZeroBasedNumber(int value) : m_value(value) {} >+ int m_value; >+}; >+ >+// An int wrapper that always reminds you that the number should be 1-based >+class OneBasedNumber { >+public: >+ static OneBasedNumber fromOneBasedInt(int oneBasedInt) { return OneBasedNumber(oneBasedInt); } >+ OneBasedNumber() {} >+ >+ int oneBasedInt() const { return m_value; } >+ int convertAsZeroBasedInt() const { return m_value - 1; } >+ ZeroBasedNumber convertToZeroBased() const { return ZeroBasedNumber::fromZeroBasedInt(m_value - 1); } >+ >+ static const OneBasedNumber s_base; // 1 >+ static const OneBasedNumber s_belowBase; // 0 >+ >+private: >+ OneBasedNumber(int value) : m_value(value) {} >+ int m_value; >+}; >+ >+typedef HTMLPosition<ZeroBasedNumber> HTMLPosition0; >+typedef HTMLPosition<OneBasedNumber> HTMLPosition1; >+ >+inline HTMLPosition0 toZeroBasedHTMLPosition(const HTMLPosition1& position) >+{ >+ return HTMLPosition0(position.m_line.convertToZeroBased(), position.m_column.convertToZeroBased(), position.m_generation); >+} >+ >+inline HTMLPosition1 toOneBasedHTMLPosition(const HTMLPosition0& position) >+{ >+ return HTMLPosition1(position.m_line.convertToOneBased(), position.m_column.convertToOneBased(), position.m_generation); >+} >+ >+inline OneBasedNumber ZeroBasedNumber::convertToOneBased() const >+{ >+ return OneBasedNumber::fromOneBasedInt(m_value + 1); >+} >+ >+} >+ >+ >+using WTF::HTMLPosition0; >+using WTF::HTMLPosition1; >+ >+#endif // HTMLPosition_h >diff --git a/JavaScriptCore/wtf/wtf.pri b/JavaScriptCore/wtf/wtf.pri >index 84ac20e3fc9fe4b5ca24f95392f7ba1e91801340..efe330e9d8cbca607636d56553fb7f7568c4a1a6 100644 >--- a/JavaScriptCore/wtf/wtf.pri >+++ b/JavaScriptCore/wtf/wtf.pri >@@ -8,6 +8,7 @@ SOURCES += \ > wtf/dtoa.cpp \ > wtf/FastMalloc.cpp \ > wtf/HashTable.cpp \ >+ wtf/HTMLPosition.cpp \ > wtf/MD5.cpp \ > wtf/MainThread.cpp \ > wtf/qt/MainThreadQt.cpp \ >diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog >index 895afb3f6d8ddc088401f8cb77e75bc7c898503e..47569bdb9c35daa8c97bcbb460be6197252a5368 100644 >--- a/WebCore/ChangeLog >+++ b/WebCore/ChangeLog >@@ -1,3 +1,98 @@ >+2010-09-20 Peter Rybin <peter.rybin@gmail.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ HTML parser should provide script column position within HTML document to JavaScript engine >+ https://bugs.webkit.org/show_bug.cgi?id=45271 >+ >+ Replaces line number with HTMLPosition struct so that script engine >+ gets script starting line/column. >+ Extends SegmentedString to provide current column and current line. >+ >+ * bindings/js/ScriptSourceCode.h: >+ (WebCore::ScriptSourceCode::ScriptSourceCode): >+ * bindings/v8/ScheduledAction.cpp: >+ (WebCore::ScheduledAction::ScheduledAction): >+ * bindings/v8/ScriptController.cpp: >+ (WebCore::ScriptController::eventHandlerPosition): >+ * bindings/v8/ScriptController.h: >+ * bindings/v8/ScriptEventListener.cpp: >+ (WebCore::createAttributeEventListener): >+ * bindings/v8/ScriptSourceCode.h: >+ (WebCore::ScriptSourceCode::ScriptSourceCode): >+ (WebCore::ScriptSourceCode::startLine): >+ (WebCore::ScriptSourceCode::startPosition): >+ * bindings/v8/V8LazyEventListener.cpp: >+ (WebCore::V8LazyEventListener::V8LazyEventListener): >+ (WebCore::V8LazyEventListener::prepareListenerObject): >+ * bindings/v8/V8LazyEventListener.h: >+ (WebCore::V8LazyEventListener::create): >+ * bindings/v8/V8Proxy.cpp: >+ (WebCore::V8Proxy::compileScript): >+ (WebCore::V8Proxy::evaluate): >+ (WebCore::V8Proxy::runScript): >+ * bindings/v8/V8Proxy.h: >+ * bindings/v8/WorkerContextExecutionProxy.cpp: >+ (WebCore::WorkerContextExecutionProxy::evaluate): >+ (WebCore::WorkerContextExecutionProxy::runScript): >+ * bindings/v8/WorkerContextExecutionProxy.h: >+ * bindings/v8/WorkerScriptController.cpp: >+ (WebCore::WorkerScriptController::evaluate): >+ * dom/PendingScript.cpp: >+ (WebCore::PendingScript::releaseElementAndClear): >+ * dom/PendingScript.h: >+ (WebCore::PendingScript::PendingScript): >+ (WebCore::PendingScript::operator=): >+ (WebCore::PendingScript::startingPosition): >+ * dom/ScriptableDocumentParser.h: >+ * dom/XMLDocumentParser.h: >+ * dom/XMLDocumentParserLibxml2.cpp: >+ (WebCore::XMLDocumentParser::XMLDocumentParser): >+ (WebCore::XMLDocumentParser::startElementNs): >+ (WebCore::XMLDocumentParser::endElementNs): >+ (WebCore::XMLDocumentParser::lineNumber): >+ (WebCore::XMLDocumentParser::columnNumber): >+ (WebCore::XMLDocumentParser::htmlPosition): >+ * dom/XMLDocumentParserQt.cpp: >+ (WebCore::XMLDocumentParser::XMLDocumentParser): >+ (WebCore::XMLDocumentParser::htmlPosition): >+ (WebCore::XMLDocumentParser::parseStartElement): >+ (WebCore::XMLDocumentParser::parseEndElement): >+ * html/parser/HTMLDocumentParser.cpp: >+ (WebCore::HTMLDocumentParser::HTMLDocumentParser): >+ (WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder): >+ (WebCore::HTMLDocumentParser::htmlPosition): >+ * html/parser/HTMLDocumentParser.h: >+ * html/parser/HTMLInputStream.h: >+ (WebCore::HTMLInputStream::HTMLInputStream): >+ (WebCore::HTMLInputStream::getInsertionLevel): >+ (WebCore::HTMLInputStream::setInsertionLevel): >+ (WebCore::InsertionPointRecord::InsertionPointRecord): >+ (WebCore::InsertionPointRecord::~InsertionPointRecord): >+ * html/parser/HTMLScriptRunner.cpp: >+ (WebCore::HTMLScriptRunner::sourceFromPendingScript): >+ (WebCore::HTMLScriptRunner::execute): >+ (WebCore::HTMLScriptRunner::runScript): >+ * html/parser/HTMLScriptRunner.h: >+ * html/parser/HTMLTreeBuilder.cpp: >+ (WebCore::HTMLTreeBuilder::HTMLTreeBuilder): >+ (WebCore::HTMLTreeBuilder::takeScriptToProcess): >+ (WebCore::HTMLTreeBuilder::processEndTag): >+ (WebCore::HTMLTreeBuilder::processScriptStartTag): >+ * html/parser/HTMLTreeBuilder.h: >+ (WebCore::HTMLTreeBuilder::create): >+ * platform/text/SegmentedString.cpp: >+ (WebCore::SegmentedString::operator=): >+ (WebCore::SegmentedString::advanceSlowCase): >+ (WebCore::SegmentedString::getCurrentLine): >+ (WebCore::SegmentedString::getCurrentColumn): >+ (WebCore::SegmentedString::setCurrentPosition): >+ * platform/text/SegmentedString.h: >+ (WebCore::SegmentedString::SegmentedString): >+ (WebCore::SegmentedString::advancePastNewline): >+ (WebCore::SegmentedString::advance): >+ (WebCore::SegmentedString::numberOfCharactersConsumed): >+ > 2010-09-20 Pavel Podivilov <podivilov@chromium.org> > > Reviewed by Pavel Feldman. >diff --git a/WebCore/bindings/js/ScriptSourceCode.h b/WebCore/bindings/js/ScriptSourceCode.h >index 32d6298cdbda772daa13e1033e3cf0aa40f594b2..79c095ef1621be2a0106b6e08d211736aef376be 100644 >--- a/WebCore/bindings/js/ScriptSourceCode.h >+++ b/WebCore/bindings/js/ScriptSourceCode.h >@@ -35,15 +35,16 @@ > #include "ScriptSourceProvider.h" > #include "StringSourceProvider.h" > #include "KURL.h" >+#include <wtf/HTMLPosition.h> > #include <wtf/RefPtr.h> > > namespace WebCore { > > class ScriptSourceCode { > public: >- ScriptSourceCode(const String& source, const KURL& url = KURL(), int startLine = 1) >+ ScriptSourceCode(const String& source, const KURL& url = KURL(), const HTMLPosition1& startPosition = HTMLPosition1::minimumPosition()) > : m_provider(StringSourceProvider::create(source, url.isNull() ? String() : url.string())) >- , m_code(m_provider, startLine) >+ , m_code(m_provider, startPosition.m_line.oneBasedInt()) > , m_url(url) > { > } >diff --git a/WebCore/bindings/v8/ScheduledAction.cpp b/WebCore/bindings/v8/ScheduledAction.cpp >index dcd0bb3377181318420c1073be251a9e584ba4b7..112de52d3baf8daef6cafb2a21095d79dfc35e45 100644 >--- a/WebCore/bindings/v8/ScheduledAction.cpp >+++ b/WebCore/bindings/v8/ScheduledAction.cpp >@@ -45,7 +45,7 @@ namespace WebCore { > > ScheduledAction::ScheduledAction(v8::Handle<v8::Context> context, v8::Handle<v8::Function> func, int argc, v8::Handle<v8::Value> argv[]) > : m_context(context) >- , m_code(String(), KURL(), 0) >+ , m_code(String(), KURL(), HTMLPosition1::belowRangePosition()) > { > m_function = v8::Persistent<v8::Function>::New(func); > >diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp >index 556b5c6ea91b7a0212c4e9b2bb2b9edde2bfa546..33bd0cefdbdd97ef65bc888d9219d92b934843ed 100644 >--- a/WebCore/bindings/v8/ScriptController.cpp >+++ b/WebCore/bindings/v8/ScriptController.cpp >@@ -260,20 +260,12 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode, Shoul > return ScriptValue(object); > } > >-int ScriptController::eventHandlerLineNumber() const >+HTMLPosition0 ScriptController::eventHandlerPosition() const > { > ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentParser(); > if (parser) >- return parser->lineNumber(); >- return 0; >-} >- >-int ScriptController::eventHandlerColumnNumber() const >-{ >- ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentParser(); >- if (parser) >- return parser->columnNumber(); >- return 0; >+ return parser->htmlPosition(); >+ return HTMLPosition0::minimumPosition(); > } > > void ScriptController::finishedWithEvent(Event* event) >diff --git a/WebCore/bindings/v8/ScriptController.h b/WebCore/bindings/v8/ScriptController.h >index 3bc42efb03f9a8c80c1654a52ec3e1c772c48f23..d987d2c097b1d4943c24c14c86017d246a9284ac 100644 >--- a/WebCore/bindings/v8/ScriptController.h >+++ b/WebCore/bindings/v8/ScriptController.h >@@ -155,8 +155,7 @@ public: > > void finishedWithEvent(Event*); > >- int eventHandlerLineNumber() const; >- int eventHandlerColumnNumber() const; >+ HTMLPosition0 eventHandlerPosition() const; > > void setProcessingTimerCallback(bool processingTimerCallback) { m_processingTimerCallback = processingTimerCallback; } > // FIXME: Currently we don't use the parameter world at all. >diff --git a/WebCore/bindings/v8/ScriptEventListener.cpp b/WebCore/bindings/v8/ScriptEventListener.cpp >index 72df79ded3ed47cff1a27b5953a359963c77a630..5ba8f7cdca05d2c7cd7fb7d2626239b115377ec0 100644 >--- a/WebCore/bindings/v8/ScriptEventListener.cpp >+++ b/WebCore/bindings/v8/ScriptEventListener.cpp >@@ -50,8 +50,8 @@ PassRefPtr<V8LazyEventListener> createAttributeEventListener(Node* node, Attribu > if (attr->isNull()) > return 0; > >- int lineNumber = 1; >- int columnNumber = 0; >+ // TODO(peter.rybin): very strange: we initialize zero-based number with '1'. >+ HTMLPosition0 position(WTF::ZeroBasedNumber::fromZeroBasedInt(1), WTF::ZeroBasedNumber::s_base, 0); > String sourceURL; > > if (Frame* frame = node->document()->frame()) { >@@ -64,12 +64,11 @@ PassRefPtr<V8LazyEventListener> createAttributeEventListener(Node* node, Attribu > return 0; > } > >- lineNumber = scriptController->eventHandlerLineNumber(); >- columnNumber = scriptController->eventHandlerColumnNumber(); >+ position = scriptController->eventHandlerPosition(); > sourceURL = node->document()->url().string(); > } > >- return V8LazyEventListener::create(attr->localName().string(), node->isSVGElement(), attr->value(), sourceURL, lineNumber, columnNumber, WorldContextHandle(UseMainWorld)); >+ return V8LazyEventListener::create(attr->localName().string(), node->isSVGElement(), attr->value(), sourceURL, position, WorldContextHandle(UseMainWorld)); > } > > PassRefPtr<V8LazyEventListener> createAttributeEventListener(Frame* frame, Attribute* attr) >@@ -81,10 +80,6 @@ PassRefPtr<V8LazyEventListener> createAttributeEventListener(Frame* frame, Attri > if (attr->isNull()) > return 0; > >- int lineNumber = 1; >- int columnNumber = 0; >- String sourceURL; >- > ScriptController* scriptController = frame->script(); > if (!scriptController->canExecuteScripts(AboutToExecuteScript)) > return 0; >@@ -94,10 +89,9 @@ PassRefPtr<V8LazyEventListener> createAttributeEventListener(Frame* frame, Attri > return 0; > } > >- lineNumber = scriptController->eventHandlerLineNumber(); >- columnNumber = scriptController->eventHandlerColumnNumber(); >- sourceURL = frame->document()->url().string(); >- return V8LazyEventListener::create(attr->localName().string(), frame->document()->isSVGDocument(), attr->value(), sourceURL, lineNumber, columnNumber, WorldContextHandle(UseMainWorld)); >+ HTMLPosition0 position = scriptController->eventHandlerPosition(); >+ String sourceURL = frame->document()->url().string(); >+ return V8LazyEventListener::create(attr->localName().string(), frame->document()->isSVGDocument(), attr->value(), sourceURL, position, WorldContextHandle(UseMainWorld)); > } > > String eventListenerHandlerBody(Document* document, EventListener* listener) >diff --git a/WebCore/bindings/v8/ScriptSourceCode.h b/WebCore/bindings/v8/ScriptSourceCode.h >index dbc9d5e6fc6007fcfdd66024db07826c66263b5b..fbc8865fe2da9a59577a079919e6036be3974137 100644 >--- a/WebCore/bindings/v8/ScriptSourceCode.h >+++ b/WebCore/bindings/v8/ScriptSourceCode.h >@@ -35,16 +35,17 @@ > #include "CachedScript.h" > #include "KURL.h" > #include "PlatformString.h" >+#include <wtf/HTMLPosition.h> > > namespace WebCore { > > class ScriptSourceCode { > public: >- ScriptSourceCode(const String& source, const KURL& url = KURL(), int startLine = 1) >+ ScriptSourceCode(const String& source, const KURL& url = KURL(), const HTMLPosition1& startPosition = HTMLPosition1::minimumPosition()) > : m_source(source) > , m_cachedScript(0) > , m_url(url) >- , m_startLine(startLine) >+ , m_startPosition(startPosition) > { > } > >@@ -54,7 +55,7 @@ public: > : m_source(cs->script()) > , m_cachedScript(cs) > , m_url(ParsedURLString, cs->url()) >- , m_startLine(1) >+ , m_startPosition(HTMLPosition1::minimumPosition()) > { > } > >@@ -63,13 +64,14 @@ public: > const String& source() const { return m_source; } > CachedScript* cachedScript() const { return m_cachedScript.get(); } > const KURL& url() const { return m_url; } >- int startLine() const { return m_startLine; } >+ int startLine() const { return m_startPosition.m_line.oneBasedInt(); } >+ const HTMLPosition1& startPosition() const { return m_startPosition; } > > private: > String m_source; > CachedResourceHandle<CachedScript> m_cachedScript; > KURL m_url; >- int m_startLine; >+ HTMLPosition1 m_startPosition; > }; > > } // namespace WebCore >diff --git a/WebCore/bindings/v8/V8LazyEventListener.cpp b/WebCore/bindings/v8/V8LazyEventListener.cpp >index 7f13c5a8fb27d33bbf1d3410a013ebc795d93d23..319700956244cdd28d3bc148923853be13f72c0f 100644 >--- a/WebCore/bindings/v8/V8LazyEventListener.cpp >+++ b/WebCore/bindings/v8/V8LazyEventListener.cpp >@@ -41,14 +41,13 @@ > > namespace WebCore { > >-V8LazyEventListener::V8LazyEventListener(const String& functionName, bool isSVGEvent, const String& code, const String sourceURL, int lineNumber, int columnNumber, const WorldContextHandle& worldContext) >+V8LazyEventListener::V8LazyEventListener(const String& functionName, bool isSVGEvent, const String& code, const String sourceURL, HTMLPosition0 position, const WorldContextHandle& worldContext) > : V8AbstractEventListener(true, worldContext) > , m_functionName(functionName) > , m_isSVGEvent(isSVGEvent) > , m_code(code) > , m_sourceURL(sourceURL) >- , m_lineNumber(lineNumber) >- , m_columnNumber(columnNumber) >+ , m_position(position) > { > } > >@@ -114,7 +113,7 @@ void V8LazyEventListener::prepareListenerObject(ScriptExecutionContext* context) > // Insert '\n' otherwise //-style comments could break the handler. > code.append( "\n}).call(this, evt);}}}})"); > v8::Handle<v8::String> codeExternalString = v8ExternalString(code); >- v8::Handle<v8::Script> script = V8Proxy::compileScript(codeExternalString, m_sourceURL, m_lineNumber); >+ v8::Handle<v8::Script> script = V8Proxy::compileScript(codeExternalString, m_sourceURL, m_position); > if (!script.IsEmpty()) { > v8::Local<v8::Value> value = proxy->runScript(script, false); > if (!value.IsEmpty()) { >diff --git a/WebCore/bindings/v8/V8LazyEventListener.h b/WebCore/bindings/v8/V8LazyEventListener.h >index f174d23bf131b010ee4f59bc42527ee8674a0608..9645b9e6d9d115e34a608c7512c4d7d0073a29a4 100644 >--- a/WebCore/bindings/v8/V8LazyEventListener.h >+++ b/WebCore/bindings/v8/V8LazyEventListener.h >@@ -34,6 +34,7 @@ > #include "PlatformString.h" > #include "V8AbstractEventListener.h" > #include <v8.h> >+#include <wtf/HTMLPosition.h> > #include <wtf/PassRefPtr.h> > > namespace WebCore { >@@ -45,9 +46,9 @@ namespace WebCore { > // A V8LazyEventListener is always a HTML event handler. > class V8LazyEventListener : public V8AbstractEventListener { > public: >- static PassRefPtr<V8LazyEventListener> create(const String& functionName, bool isSVGEvent, const String& code, const String& sourceURL, int lineNumber, int columnNumber, const WorldContextHandle& worldContext) >+ static PassRefPtr<V8LazyEventListener> create(const String& functionName, bool isSVGEvent, const String& code, const String& sourceURL, HTMLPosition0 position, const WorldContextHandle& worldContext) > { >- return adoptRef(new V8LazyEventListener(functionName, isSVGEvent, code, sourceURL, lineNumber, columnNumber, worldContext)); >+ return adoptRef(new V8LazyEventListener(functionName, isSVGEvent, code, sourceURL, position, worldContext)); > } > > virtual bool isLazy() const { return true; } >@@ -56,7 +57,7 @@ namespace WebCore { > virtual void prepareListenerObject(ScriptExecutionContext*); > > private: >- V8LazyEventListener(const String& functionName, bool isSVGEvent, const String& code, const String sourceURL, int lineNumber, int columnNumber, const WorldContextHandle& worldContext); >+ V8LazyEventListener(const String& functionName, bool isSVGEvent, const String& code, const String sourceURL, HTMLPosition0 position, const WorldContextHandle& worldContext); > > virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*); > >@@ -70,8 +71,7 @@ namespace WebCore { > bool m_isSVGEvent; > String m_code; > String m_sourceURL; >- int m_lineNumber; >- int m_columnNumber; >+ HTMLPosition0 m_position; > }; > > } // namespace WebCore >diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp >index a776ee7d73fb92d486e677d085dae163797db84d..f4ef04cab55af432e304b6f2fe4b6dc7b3783f0c 100644 >--- a/WebCore/bindings/v8/V8Proxy.cpp >+++ b/WebCore/bindings/v8/V8Proxy.cpp >@@ -238,12 +238,15 @@ V8Proxy::~V8Proxy() > windowShell()->destroyGlobal(); > } > >-v8::Handle<v8::Script> V8Proxy::compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine, v8::ScriptData* scriptData) >+v8::Handle<v8::Script> V8Proxy::compileScript(v8::Handle<v8::String> code, const String& fileName, HTMLPosition0 scriptStartPosition, v8::ScriptData* scriptData) > { > const uint16_t* fileNameString = fromWebCoreString(fileName); >- v8::Handle<v8::String> name = v8::String::New(fileNameString, fileName.length()); >- v8::Handle<v8::Integer> line = v8::Integer::New(baseLine); >- v8::ScriptOrigin origin(name, line); >+ v8::Handle<v8::String> name; >+ if (!scriptStartPosition.m_generation) >+ name = v8::String::New(fileNameString, fileName.length()); >+ v8::Handle<v8::Integer> line = v8::Integer::New(scriptStartPosition.m_line.zeroBasedInt()); >+ v8::Handle<v8::Integer> column = v8::Integer::New(scriptStartPosition.m_column.zeroBasedInt()); >+ v8::ScriptOrigin origin(name, line, column); > v8::Handle<v8::Script> script = v8::Script::Compile(code, &origin, scriptData); > return script; > } >@@ -399,7 +402,7 @@ v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* nod > > // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at > // 1, whereas v8 starts at 0. >- v8::Handle<v8::Script> script = compileScript(code, source.url(), source.startLine() - 1, scriptData.get()); >+ v8::Handle<v8::Script> script = compileScript(code, source.url(), WTF::toZeroBasedHTMLPosition(source.startPosition()), scriptData.get()); > #if PLATFORM(CHROMIUM) > PlatformBridge::traceEventEnd("v8.compile", node, ""); > >@@ -434,7 +437,7 @@ v8::Local<v8::Value> V8Proxy::runScript(v8::Handle<v8::Script> script, bool isIn > // FIXME: Ideally, we should be able to re-use the origin of the > // script passed to us as the argument instead of using an empty string > // and 0 baseLine. >- script = compileScript(code, "", 0); >+ script = compileScript(code, "", HTMLPosition0::minimumPosition()); > } > > if (handleOutOfMemory()) >diff --git a/WebCore/bindings/v8/V8Proxy.h b/WebCore/bindings/v8/V8Proxy.h >index 7b4d6f6cde91910d14636c736437232f43f2e9a4..5178415e70d01b37bb1e1a71ef572564547b9d00 100644 >--- a/WebCore/bindings/v8/V8Proxy.h >+++ b/WebCore/bindings/v8/V8Proxy.h >@@ -288,7 +288,7 @@ namespace WebCore { > > static v8::Handle<v8::Value> checkNewLegal(const v8::Arguments&); > >- static v8::Handle<v8::Script> compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine, v8::ScriptData* = 0); >+ static v8::Handle<v8::Script> compileScript(v8::Handle<v8::String> code, const String& fileName, HTMLPosition0 scriptStartPosition, v8::ScriptData* = 0); > > // If the exception code is different from zero, a DOM exception is > // schedule to be thrown. >diff --git a/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp b/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp >index 16e0b4101efdc35ae7441817b0687db6b5a65a25..de23a11619381c9eb08682c2155f35cf152140cf 100644 >--- a/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp >+++ b/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp >@@ -184,7 +184,7 @@ bool WorkerContextExecutionProxy::forgetV8EventObject(Event* event) > return false; > } > >-ScriptValue WorkerContextExecutionProxy::evaluate(const String& script, const String& fileName, int baseLine, WorkerContextExecutionState* state) >+ScriptValue WorkerContextExecutionProxy::evaluate(const String& script, const String& fileName, HTMLPosition0 scriptStartPosition, WorkerContextExecutionState* state) > { > v8::HandleScope hs; > >@@ -196,7 +196,7 @@ ScriptValue WorkerContextExecutionProxy::evaluate(const String& script, const St > v8::TryCatch exceptionCatcher; > > v8::Local<v8::String> scriptString = v8ExternalString(script); >- v8::Handle<v8::Script> compiledScript = V8Proxy::compileScript(scriptString, fileName, baseLine); >+ v8::Handle<v8::Script> compiledScript = V8Proxy::compileScript(scriptString, fileName, scriptStartPosition); > v8::Local<v8::Value> result = runScript(compiledScript); > > if (!exceptionCatcher.CanContinue()) >@@ -227,7 +227,7 @@ v8::Local<v8::Value> WorkerContextExecutionProxy::runScript(v8::Handle<v8::Scrip > // Compute the source string and prevent against infinite recursion. > if (m_recursion >= kMaxRecursionDepth) { > v8::Local<v8::String> code = v8ExternalString("throw RangeError('Recursion too deep')"); >- script = V8Proxy::compileScript(code, "", 0); >+ script = V8Proxy::compileScript(code, "", HTMLPosition0::minimumPosition()); > } > > if (V8Proxy::handleOutOfMemory()) >diff --git a/WebCore/bindings/v8/WorkerContextExecutionProxy.h b/WebCore/bindings/v8/WorkerContextExecutionProxy.h >index 58824b9eef6f4914084c777161e23f6e30abe283..d7ffb0c802cb66bad76bb3ed15e0f0e9014b3180 100644 >--- a/WebCore/bindings/v8/WorkerContextExecutionProxy.h >+++ b/WebCore/bindings/v8/WorkerContextExecutionProxy.h >@@ -36,6 +36,7 @@ > > #include "ScriptValue.h" > #include <v8.h> >+#include <wtf/HTMLPosition.h> > #include <wtf/OwnPtr.h> > #include <wtf/Vector.h> > >@@ -66,7 +67,7 @@ namespace WebCore { > void trackEvent(Event*); > > // Evaluate a script file in the current execution environment. >- ScriptValue evaluate(const String& script, const String& fileName, int baseLine, WorkerContextExecutionState*); >+ ScriptValue evaluate(const String& script, const String& fileName, HTMLPosition0 scriptStartPosition, WorkerContextExecutionState*); > > // Returns a local handle of the context. > v8::Local<v8::Context> context() { return v8::Local<v8::Context>::New(m_context); } >diff --git a/WebCore/bindings/v8/WorkerScriptController.cpp b/WebCore/bindings/v8/WorkerScriptController.cpp >index 7db0d8d373709b2e973b67e7723e4fc311fbca59..80aec31fffec82e81fe93a8eed82fa038729b688 100644 >--- a/WebCore/bindings/v8/WorkerScriptController.cpp >+++ b/WebCore/bindings/v8/WorkerScriptController.cpp >@@ -75,7 +75,7 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, > } > > WorkerContextExecutionState state; >- ScriptValue result = m_proxy->evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startLine() - 1, &state); >+ ScriptValue result = m_proxy->evaluate(sourceCode.source(), sourceCode.url().string(), WTF::toZeroBasedHTMLPosition(sourceCode.startPosition()), &state); > if (state.hadException) { > if (exception) > *exception = state.exception; >diff --git a/WebCore/dom/PendingScript.cpp b/WebCore/dom/PendingScript.cpp >index 42e225a7f32a1b0cdc1bc3451b65497a46135689..74c5791e3b2defa7247ae5a0ee9342c2827d19e1 100644 >--- a/WebCore/dom/PendingScript.cpp >+++ b/WebCore/dom/PendingScript.cpp >@@ -40,7 +40,7 @@ PendingScript::~PendingScript() > PassRefPtr<Element> PendingScript::releaseElementAndClear() > { > setCachedScript(0); >- m_startingLineNumber = 0; >+ m_startingPosition = HTMLPosition1::belowRangePosition(); > m_watchingForLoad = false; > return m_element.release(); > } >diff --git a/WebCore/dom/PendingScript.h b/WebCore/dom/PendingScript.h >index 44e1e4928676d796022dd29054576015b7a26e44..d2ae428d5f6a28acb9ac4fa648123f58e1d71e2f 100644 >--- a/WebCore/dom/PendingScript.h >+++ b/WebCore/dom/PendingScript.h >@@ -28,6 +28,7 @@ > > #include "CachedResourceClient.h" > #include "CachedResourceHandle.h" >+#include <wtf/HTMLPosition.h> > #include <wtf/PassRefPtr.h> > > namespace WebCore { >@@ -43,14 +44,14 @@ class Element; > class PendingScript : public CachedResourceClient { > public: > PendingScript() >- : m_startingLineNumber(0) >+ : m_startingPosition(HTMLPosition1::belowRangePosition()) > , m_watchingForLoad(false) > { > } > > PendingScript(const PendingScript& other) > : CachedResourceClient(other) >- , m_startingLineNumber(other.m_startingLineNumber) >+ , m_startingPosition(other.m_startingPosition) > , m_watchingForLoad(other.m_watchingForLoad) > , m_element(other.m_element) > { >@@ -64,7 +65,7 @@ public: > if (this == &other) > return *this; > >- m_startingLineNumber = other.m_startingLineNumber; >+ m_startingPosition = other.m_startingPosition; > m_watchingForLoad = other.m_watchingForLoad; > m_element = other.m_element; > setCachedScript(other.cachedScript()); >@@ -74,7 +75,7 @@ public: > > // FIXME: No setter means this is never set to anything other than 0. > // This is either unnecessary or incorrect. >- int startingLineNumber() const { return m_startingLineNumber; } >+ HTMLPosition1 startingPosition() const { return m_startingPosition; } > > bool watchingForLoad() const { return m_watchingForLoad; } > void setWatchingForLoad(bool b) { m_watchingForLoad = b; } >@@ -89,7 +90,7 @@ public: > virtual void notifyFinished(CachedResource*); > > private: >- int m_startingLineNumber; // Only used for inline script tags. >+ HTMLPosition1 m_startingPosition; // Only used for inline script tags. > bool m_watchingForLoad; > RefPtr<Element> m_element; > CachedResourceHandle<CachedScript> m_cachedScript; >diff --git a/WebCore/dom/ScriptableDocumentParser.h b/WebCore/dom/ScriptableDocumentParser.h >index 8b1630412104e4e45a01323dd2255e6564e34045..f9f2f471631ac8ecf2fa2d24aefa88513bc1f9cf 100644 >--- a/WebCore/dom/ScriptableDocumentParser.h >+++ b/WebCore/dom/ScriptableDocumentParser.h >@@ -27,10 +27,10 @@ > #define ScriptableDocumentParser_h > > #include "DecodedDataDocumentParser.h" >+#include <wtf/HTMLPosition.h> > > namespace WebCore { > >-class SegmentedString; > class XSSAuditor; > > class ScriptableDocumentParser : public DecodedDataDocumentParser { >@@ -47,7 +47,7 @@ public: > > // These are used to expose the current line/column to the scripting system. > virtual int lineNumber() const = 0; >- virtual int columnNumber() const = 0; >+ virtual HTMLPosition0 htmlPosition() const = 0; > > XSSAuditor* xssAuditor() const { return m_xssAuditor; } > void setXSSAuditor(XSSAuditor* auditor) { m_xssAuditor = auditor; } >diff --git a/WebCore/dom/XMLDocumentParser.h b/WebCore/dom/XMLDocumentParser.h >index e0770badbaff7ba11020addc71249ef3dec820d4..f8fde2396c7f982e6912e15d7fde7501c7bc3a44 100644 >--- a/WebCore/dom/XMLDocumentParser.h >+++ b/WebCore/dom/XMLDocumentParser.h >@@ -102,7 +102,7 @@ namespace WebCore { > // WMLErrorHandling uses these functions. > virtual bool wellFormed() const { return !m_sawError; } > virtual int lineNumber() const; >- virtual int columnNumber() const; >+ HTMLPosition0 htmlPosition() const; > > static bool supportsXMLVersion(const String&); > >@@ -129,6 +129,8 @@ namespace WebCore { > > bool appendFragmentSource(const String&); > >+ int columnNumber() const; >+ > #if USE(QXMLSTREAM) > private: > void parse(); >@@ -208,7 +210,7 @@ public: > > CachedResourceHandle<CachedScript> m_pendingScript; > RefPtr<Element> m_scriptElement; >- int m_scriptStartLine; >+ HTMLPosition1 m_scriptStartPosition; > > bool m_parsingFragment; > AtomicString m_defaultNamespaceURI; >diff --git a/WebCore/dom/XMLDocumentParserLibxml2.cpp b/WebCore/dom/XMLDocumentParserLibxml2.cpp >index 5539072ee58cba015f3b6ce5d44ccb71db3f15fb..ae99c20a4e6709b2ecb57567ba119d640b368bc5 100644 >--- a/WebCore/dom/XMLDocumentParserLibxml2.cpp >+++ b/WebCore/dom/XMLDocumentParserLibxml2.cpp >@@ -558,7 +558,7 @@ XMLDocumentParser::XMLDocumentParser(Document* document, FrameView* frameView) > , m_lastErrorLine(0) > , m_lastErrorColumn(0) > , m_pendingScript(0) >- , m_scriptStartLine(0) >+ , m_scriptStartPosition(HTMLPosition1::belowRangePosition()) > , m_parsingFragment(false) > , m_scriptingPermission(FragmentScriptingAllowed) > { >@@ -585,7 +585,7 @@ XMLDocumentParser::XMLDocumentParser(DocumentFragment* fragment, Element* parent > , m_lastErrorLine(0) > , m_lastErrorColumn(0) > , m_pendingScript(0) >- , m_scriptStartLine(0) >+ , m_scriptStartPosition(HTMLPosition1::belowRangePosition()) > , m_parsingFragment(true) > , m_scriptingPermission(scriptingPermission) > { >@@ -817,7 +817,7 @@ void XMLDocumentParser::startElementNs(const xmlChar* xmlLocalName, const xmlCha > > ScriptElement* scriptElement = toScriptElement(newElement.get()); > if (scriptElement) >- m_scriptStartLine = lineNumber(); >+ m_scriptStartPosition = toOneBasedHTMLPosition(htmlPosition()); > > m_currentNode->deprecatedParserAddChild(newElement.get()); > >@@ -903,7 +903,7 @@ void XMLDocumentParser::endElementNs() > } else > m_scriptElement = 0; > } else >- m_view->frame()->script()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), document()->url(), m_scriptStartLine)); >+ m_view->frame()->script()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), document()->url(), m_scriptStartPosition)); > > // JavaScript may have detached the parser > if (isDetached()) >@@ -1369,12 +1369,26 @@ void* xmlDocPtrForString(CachedResourceLoader* cachedResourceLoader, const Strin > > int XMLDocumentParser::lineNumber() const > { >- return context() ? context()->input->line : 1; >+ // FIXME: the implementation probably returns 1-based int, but method should return 0-based. >+ // New "- 1" fixes this. Is it correct? >+ return (context() ? context()->input->line : 1) - 1; > } > > int XMLDocumentParser::columnNumber() const > { >- return context() ? context()->input->col : 1; >+ // FIXME: the implementation probably returns 1-based int, but method should return 0-based. >+ // New "- 1" fixes this. Is it correct? >+ return (context() ? context()->input->col : 1) - 1; >+} >+ >+HTMLPosition0 XMLDocumentParser::htmlPosition() const >+{ >+ xmlParserCtxtPtr context = this->context(); >+ if (context) { >+ return HTMLPosition0(WTF::OneBasedNumber::fromOneBasedInt(context->input->line).convertToZeroBased(), >+ WTF::OneBasedNumber::fromOneBasedInt(context->input->col).convertToZeroBased(), 0); >+ } >+ return HTMLPosition0::minimumPosition(); > } > > void XMLDocumentParser::stopParsing() >diff --git a/WebCore/dom/XMLDocumentParserQt.cpp b/WebCore/dom/XMLDocumentParserQt.cpp >index 75a20be3541cf527ee54984d2148281ad0824f64..cb0e126aedf237b395fd42b29beb28df775ba892 100644 >--- a/WebCore/dom/XMLDocumentParserQt.cpp >+++ b/WebCore/dom/XMLDocumentParserQt.cpp >@@ -103,7 +103,7 @@ XMLDocumentParser::XMLDocumentParser(Document* document, FrameView* frameView) > , m_lastErrorLine(0) > , m_lastErrorColumn(0) > , m_pendingScript(0) >- , m_scriptStartLine(0) >+ , m_scriptStartPosition(HTMLPosition1::belowRangePosition()) > , m_parsingFragment(false) > , m_scriptingPermission(FragmentScriptingAllowed) > { >@@ -130,7 +130,7 @@ XMLDocumentParser::XMLDocumentParser(DocumentFragment* fragment, Element* parent > , m_lastErrorLine(0) > , m_lastErrorColumn(0) > , m_pendingScript(0) >- , m_scriptStartLine(0) >+ , m_scriptStartPosition(HTMLPosition1::belowRangePosition()) > , m_parsingFragment(true) > , m_scriptingPermission(permission) > { >@@ -232,6 +232,11 @@ int XMLDocumentParser::columnNumber() const > return m_stream.columnNumber(); > } > >+HTMLPosition0 XMLDocumentParser::htmlPosition() >+{ >+ return HTMLPosition0(WTF::ZeroBasedNumber(lineNumber()), WTF::ZeroBasedNumber(columnNumber()), 0); >+} >+ > void XMLDocumentParser::stopParsing() > { > ScriptableDocumentParser::stopParsing(); >@@ -516,7 +521,7 @@ void XMLDocumentParser::parseStartElement() > > ScriptElement* scriptElement = toScriptElement(newElement.get()); > if (scriptElement) >- m_scriptStartLine = lineNumber(); >+ m_scriptStartPosition = WTF::toOneBasedHTMLPosition(htmlPosition()); > > m_currentNode->deprecatedParserAddChild(newElement.get()); > >@@ -588,7 +593,7 @@ void XMLDocumentParser::parseEndElement() > } else > m_scriptElement = 0; > } else >- m_view->frame()->script()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), document()->url(), m_scriptStartLine)); >+ m_view->frame()->script()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), document()->url(), m_scriptStartPosition)); > } > m_requestingScript = false; > popCurrentNode(); >@@ -709,4 +714,3 @@ void XMLDocumentParser::parseDtd() > > } > } >- >diff --git a/WebCore/html/parser/HTMLDocumentParser.cpp b/WebCore/html/parser/HTMLDocumentParser.cpp >index 325d7a374f854d726474b1737d5017033fb06100..ed0234d3111d64518d5823c6602e533b96702759 100644 >--- a/WebCore/html/parser/HTMLDocumentParser.cpp >+++ b/WebCore/html/parser/HTMLDocumentParser.cpp >@@ -81,7 +81,7 @@ HTMLDocumentParser::HTMLDocumentParser(HTMLDocument* document, bool reportErrors > : ScriptableDocumentParser(document) > , m_tokenizer(HTMLTokenizer::create()) > , m_scriptRunner(HTMLScriptRunner::create(document, this)) >- , m_treeBuilder(HTMLTreeBuilder::create(m_tokenizer.get(), document, reportErrors)) >+ , m_treeBuilder(HTMLTreeBuilder::create(m_tokenizer.get(), this, document, reportErrors)) > , m_parserScheduler(HTMLParserScheduler::create(this)) > , m_endWasDelayed(false) > , m_writeNestingLevel(0) >@@ -93,7 +93,7 @@ HTMLDocumentParser::HTMLDocumentParser(HTMLDocument* document, bool reportErrors > HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission scriptingPermission) > : ScriptableDocumentParser(fragment->document()) > , m_tokenizer(HTMLTokenizer::create()) >- , m_treeBuilder(HTMLTreeBuilder::create(m_tokenizer.get(), fragment, contextElement, scriptingPermission)) >+ , m_treeBuilder(HTMLTreeBuilder::create(m_tokenizer.get(), this, fragment, contextElement, scriptingPermission)) > , m_endWasDelayed(false) > , m_writeNestingLevel(0) > { >@@ -193,12 +193,12 @@ bool HTMLDocumentParser::runScriptsForPausedTreeBuilder() > { > ASSERT(m_treeBuilder->isPaused()); > >- int scriptStartLine = 0; >- RefPtr<Element> scriptElement = m_treeBuilder->takeScriptToProcess(scriptStartLine); >+ HTMLPosition1 scriptStartPosition = HTMLPosition1::belowRangePosition(); >+ RefPtr<Element> scriptElement = m_treeBuilder->takeScriptToProcess(scriptStartPosition); > // We will not have a scriptRunner when parsing a DocumentFragment. > if (!m_scriptRunner) > return true; >- return m_scriptRunner->execute(scriptElement.release(), scriptStartLine); >+ return m_scriptRunner->execute(scriptElement.release(), scriptStartPosition); > } > > void HTMLDocumentParser::pumpTokenizer(SynchronousMode mode) >@@ -414,9 +414,14 @@ int HTMLDocumentParser::lineNumber() const > return m_tokenizer->lineNumber(); > } > >-int HTMLDocumentParser::columnNumber() const >+HTMLPosition0 HTMLDocumentParser::htmlPosition() const > { >- return m_tokenizer->columnNumber(); >+ int line = m_input.current().currentLine(); >+ int column = m_input.current().currentColumn(); >+ int generation = m_writeNestingLevel; >+ >+ return HTMLPosition0(WTF::ZeroBasedNumber::fromZeroBasedInt(line), >+ WTF::ZeroBasedNumber::fromZeroBasedInt(column), generation); > } > > bool HTMLDocumentParser::isWaitingForScripts() const >diff --git a/WebCore/html/parser/HTMLDocumentParser.h b/WebCore/html/parser/HTMLDocumentParser.h >index e1f2efe24f13885bfe46e2980cda2c325318ce02..11f281a5a74843e5a976c83997a06f93691cc60b 100644 >--- a/WebCore/html/parser/HTMLDocumentParser.h >+++ b/WebCore/html/parser/HTMLDocumentParser.h >@@ -31,6 +31,7 @@ > #include "HTMLInputStream.h" > #include "HTMLScriptRunnerHost.h" > #include "HTMLToken.h" >+#include "HTMLTreeBuilder.h" > #include "ScriptableDocumentParser.h" > #include "SegmentedString.h" > #include "Timer.h" >@@ -44,12 +45,11 @@ class HTMLDocument; > class HTMLParserScheduler; > class HTMLTokenizer; > class HTMLScriptRunner; >-class HTMLTreeBuilder; > class HTMLPreloadScanner; > class ScriptController; > class ScriptSourceCode; > >-class HTMLDocumentParser : public ScriptableDocumentParser, HTMLScriptRunnerHost, CachedResourceClient { >+class HTMLDocumentParser : public ScriptableDocumentParser, HTMLScriptRunnerHost, CachedResourceClient, HTMLTreeBuilder::HTMLPositionProvider { > public: > static PassRefPtr<HTMLDocumentParser> create(HTMLDocument* document, bool reportErrors) > { >@@ -90,7 +90,7 @@ private: > virtual bool isExecutingScript() const; > virtual void executeScriptsWaitingForStylesheets(); > virtual int lineNumber() const; >- virtual int columnNumber() const; >+ virtual HTMLPosition0 htmlPosition() const; > > // HTMLScriptRunnerHost > virtual void watchForLoad(CachedResource*); >diff --git a/WebCore/html/parser/HTMLInputStream.h b/WebCore/html/parser/HTMLInputStream.h >index a709bd9bd5b21d117eefa451288b26b0fb7941f4..3b9a4c6598838c5f710ba0c631c66df134aea63e 100644 >--- a/WebCore/html/parser/HTMLInputStream.h >+++ b/WebCore/html/parser/HTMLInputStream.h >@@ -94,6 +94,7 @@ public: > } > > SegmentedString& current() { return m_first; } >+ const SegmentedString& current() const { return m_first; } > > void splitInto(SegmentedString& next) > { >@@ -133,17 +134,24 @@ public: > explicit InsertionPointRecord(HTMLInputStream& inputStream) > : m_inputStream(&inputStream) > { >+ m_line = m_inputStream->current().currentLine(); >+ m_column = m_inputStream->current().currentColumn(); > m_inputStream->splitInto(m_next); >+ // Generated script part inherits current position. >+ m_inputStream->current().setCurrentPosition(m_line, m_column); > } > > ~InsertionPointRecord() > { > m_inputStream->mergeFrom(m_next); >+ m_inputStream->current().setCurrentPosition(m_line, m_column); > } > > private: > HTMLInputStream* m_inputStream; > SegmentedString m_next; >+ int m_line; >+ int m_column; > }; > > } >diff --git a/WebCore/html/parser/HTMLScriptRunner.cpp b/WebCore/html/parser/HTMLScriptRunner.cpp >index 4f54f4292870acd53854fc4710870dd9df14f2d1..332c21fd9564ce9ed56475b09e11d47c0e33e48d 100644 >--- a/WebCore/html/parser/HTMLScriptRunner.cpp >+++ b/WebCore/html/parser/HTMLScriptRunner.cpp >@@ -98,7 +98,7 @@ ScriptSourceCode HTMLScriptRunner::sourceFromPendingScript(const PendingScript& > return ScriptSourceCode(script.cachedScript()); > } > errorOccurred = false; >- return ScriptSourceCode(script.element()->textContent(), documentURLForScriptExecution(m_document), script.startingLineNumber()); >+ return ScriptSourceCode(script.element()->textContent(), documentURLForScriptExecution(m_document), script.startingPosition()); > } > > bool HTMLScriptRunner::isPendingScriptReady(const PendingScript& script) >@@ -170,13 +170,13 @@ void HTMLScriptRunner::stopWatchingForLoad(PendingScript& pendingScript) > > // This function should match 10.2.5.11 "An end tag whose tag name is 'script'" > // Script handling lives outside the tree builder to keep the each class simple. >-bool HTMLScriptRunner::execute(PassRefPtr<Element> scriptElement, int startLine) >+bool HTMLScriptRunner::execute(PassRefPtr<Element> scriptElement, const HTMLPosition1& scriptStartPosition) > { > ASSERT(scriptElement); > // FIXME: If scripting is disabled, always just return true; > > // Try to execute the script given to us. >- runScript(scriptElement.get(), startLine); >+ runScript(scriptElement.get(), scriptStartPosition); > > if (haveParsingBlockingScript()) { > if (m_scriptNestingLevel) >@@ -288,7 +288,7 @@ bool HTMLScriptRunner::requestPendingScript(PendingScript& pendingScript, Elemen > > // This method is meant to match the HTML5 definition of "running a script" > // http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#running-a-script >-void HTMLScriptRunner::runScript(Element* script, int startingLineNumber) >+void HTMLScriptRunner::runScript(Element* script, const HTMLPosition1& scriptStartPosition) > { > ASSERT(m_document); > ASSERT(!haveParsingBlockingScript()); >@@ -315,7 +315,7 @@ void HTMLScriptRunner::runScript(Element* script, int startingLineNumber) > // See https://bugs.webkit.org/show_bug.cgi?id=40047 > // ASSERT(document()->haveStylesheetsLoaded()); > ASSERT(isExecutingScript()); >- ScriptSourceCode sourceCode(script->textContent(), documentURLForScriptExecution(m_document), startingLineNumber); >+ ScriptSourceCode sourceCode(script->textContent(), documentURLForScriptExecution(m_document), scriptStartPosition); > executeScript(sourceCode); > } > } >diff --git a/WebCore/html/parser/HTMLScriptRunner.h b/WebCore/html/parser/HTMLScriptRunner.h >index be21dd2421b1d4427b0847b0b911c1fe97c6f765..4369a5e0cce7f8c1cb4db00de70d72a5d21761e8 100644 >--- a/WebCore/html/parser/HTMLScriptRunner.h >+++ b/WebCore/html/parser/HTMLScriptRunner.h >@@ -28,6 +28,7 @@ > > #include "PendingScript.h" > #include <wtf/Deque.h> >+#include <wtf/HTMLPosition.h> > #include <wtf/Noncopyable.h> > #include <wtf/PassRefPtr.h> > >@@ -52,7 +53,7 @@ public: > void detach(); > > // Processes the passed in script and any pending scripts if possible. >- bool execute(PassRefPtr<Element> scriptToProcess, int scriptStartLine); >+ bool execute(PassRefPtr<Element> scriptToProcess, const HTMLPosition1& scriptStartPosition); > > bool executeScriptsWaitingForLoad(CachedResource*); > bool hasScriptsWaitingForStylesheets() const { return m_hasScriptsWaitingForStylesheets; } >@@ -76,7 +77,7 @@ private: > void requestDeferredScript(Element*); > bool requestPendingScript(PendingScript&, Element*) const; > >- void runScript(Element*, int startingLineNumber); >+ void runScript(Element*, const HTMLPosition1& scriptStartPosition); > > // Helpers for dealing with HTMLScriptRunnerHost > void watchForLoad(PendingScript&); >diff --git a/WebCore/html/parser/HTMLTreeBuilder.cpp b/WebCore/html/parser/HTMLTreeBuilder.cpp >index afac2a0d809f549c37f44ba81201d62081046ec3..79e9ea63c9c517e02f6eabe4c314f3f089e7f159 100644 >--- a/WebCore/html/parser/HTMLTreeBuilder.cpp >+++ b/WebCore/html/parser/HTMLTreeBuilder.cpp >@@ -49,12 +49,15 @@ > #include "XLinkNames.h" > #include "XMLNSNames.h" > #include "XMLNames.h" >+#include <wtf/Assertions.h> > > namespace WebCore { > > using namespace HTMLNames; > > static const int uninitializedLineNumberValue = -1; >+static const HTMLPosition0 uninitializedPositionValue0 = HTMLPosition0::belowRangePosition(); >+static const HTMLPosition1 uninitializedPositionValue1(WTF::OneBasedNumber::fromOneBasedInt(-1), WTF::OneBasedNumber::s_base, -1); > > namespace { > >@@ -323,7 +326,7 @@ private: > }; > > >-HTMLTreeBuilder::HTMLTreeBuilder(HTMLTokenizer* tokenizer, HTMLDocument* document, bool reportErrors) >+HTMLTreeBuilder::HTMLTreeBuilder(HTMLTokenizer* tokenizer, HTMLPositionProvider* htmlPositionProvider, HTMLDocument* document, bool reportErrors) > : m_framesetOk(true) > , m_document(document) > , m_tree(document, FragmentScriptingAllowed, false) >@@ -333,14 +336,15 @@ HTMLTreeBuilder::HTMLTreeBuilder(HTMLTokenizer* tokenizer, HTMLDocument* documen > , m_originalInsertionMode(InitialMode) > , m_secondaryInsertionMode(InitialMode) > , m_tokenizer(tokenizer) >- , m_scriptToProcessStartLine(uninitializedLineNumberValue) >- , m_lastScriptElementStartLine(uninitializedLineNumberValue) >+ , m_scriptToProcessStartPosition(uninitializedPositionValue1) >+ , m_lastScriptElementStartPosition(uninitializedPositionValue0) >+ , m_htmlPositionProvider(htmlPositionProvider) > { > } > > // FIXME: Member variables should be grouped into self-initializing structs to > // minimize code duplication between these constructors. >-HTMLTreeBuilder::HTMLTreeBuilder(HTMLTokenizer* tokenizer, DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission scriptingPermission) >+HTMLTreeBuilder::HTMLTreeBuilder(HTMLTokenizer* tokenizer, HTMLPositionProvider* htmlPositionProvider, DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission scriptingPermission) > : m_framesetOk(true) > , m_fragmentContext(fragment, contextElement, scriptingPermission) > , m_document(m_fragmentContext.document()) >@@ -351,8 +355,9 @@ HTMLTreeBuilder::HTMLTreeBuilder(HTMLTokenizer* tokenizer, DocumentFragment* fra > , m_originalInsertionMode(InitialMode) > , m_secondaryInsertionMode(InitialMode) > , m_tokenizer(tokenizer) >- , m_scriptToProcessStartLine(uninitializedLineNumberValue) >- , m_lastScriptElementStartLine(uninitializedLineNumberValue) >+ , m_scriptToProcessStartPosition(uninitializedPositionValue1) >+ , m_lastScriptElementStartPosition(uninitializedPositionValue0) >+ , m_htmlPositionProvider(htmlPositionProvider) > { > if (contextElement) { > // Steps 4.2-4.6 of the HTML5 Fragment Case parsing algorithm: >@@ -413,15 +418,15 @@ HTMLTreeBuilder::FragmentParsingContext::~FragmentParsingContext() > { > } > >-PassRefPtr<Element> HTMLTreeBuilder::takeScriptToProcess(int& scriptStartLine) >+PassRefPtr<Element> HTMLTreeBuilder::takeScriptToProcess(HTMLPosition1& scriptStartPosition) > { > // Unpause ourselves, callers may pause us again when processing the script. > // The HTML5 spec is written as though scripts are executed inside the tree > // builder. We pause the parser to exit the tree builder, and then resume > // before running scripts. > m_isPaused = false; >- scriptStartLine = m_scriptToProcessStartLine; >- m_scriptToProcessStartLine = uninitializedLineNumberValue; >+ scriptStartPosition = m_scriptToProcessStartPosition; >+ m_scriptToProcessStartPosition = uninitializedPositionValue1; > return m_scriptToProcess.release(); > } > >@@ -2199,7 +2204,7 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token) > m_isPaused = true; > ASSERT(m_tree.currentElement()->hasTagName(scriptTag)); > m_scriptToProcess = m_tree.currentElement(); >- m_scriptToProcessStartLine = m_lastScriptElementStartLine + 1; >+ m_scriptToProcessStartPosition = WTF::toOneBasedHTMLPosition(m_lastScriptElementStartPosition); > m_tree.openElements()->pop(); > if (isParsingFragment() && m_fragmentContext.scriptingPermission() == FragmentScriptingNotAllowed) > m_scriptToProcess->removeAllChildren(); >@@ -2739,7 +2744,15 @@ void HTMLTreeBuilder::processScriptStartTag(AtomicHTMLToken& token) > m_tree.insertScriptElement(token); > m_tokenizer->setState(HTMLTokenizer::ScriptDataState); > m_originalInsertionMode = m_insertionMode; >- m_lastScriptElementStartLine = m_tokenizer->lineNumber(); >+ >+ HTMLPosition0 position = m_htmlPositionProvider->htmlPosition(); >+ >+ // We should stop using HTMLTokenizer for getting line number; >+ // column number is tracked by m_scriptableDocumentParser, so we should switch to it. >+ ASSERT(m_tokenizer->lineNumber() == position.m_line.zeroBasedInt()); >+ >+ m_lastScriptElementStartPosition = position; >+ > setInsertionMode(TextMode); > } > >diff --git a/WebCore/html/parser/HTMLTreeBuilder.h b/WebCore/html/parser/HTMLTreeBuilder.h >index d522ea8eb1a50e427ffce0acc819dc519aae25f0..7cd24f12f2cb569b291f6691137a4baa84853f4d 100644 >--- a/WebCore/html/parser/HTMLTreeBuilder.h >+++ b/WebCore/html/parser/HTMLTreeBuilder.h >@@ -32,6 +32,8 @@ > #include "HTMLElementStack.h" > #include "HTMLFormattingElementList.h" > #include "HTMLTokenizer.h" >+#include "ScriptableDocumentParser.h" >+#include <wtf/HTMLPosition.h> > #include <wtf/Noncopyable.h> > #include <wtf/OwnPtr.h> > #include <wtf/PassOwnPtr.h> >@@ -51,13 +53,19 @@ class Node; > > class HTMLTreeBuilder : public Noncopyable { > public: >- static PassOwnPtr<HTMLTreeBuilder> create(HTMLTokenizer* tokenizer, HTMLDocument* document, bool reportErrors) >+ >+ class HTMLPositionProvider { >+ public: >+ virtual HTMLPosition0 htmlPosition() const = 0; >+ }; >+ >+ static PassOwnPtr<HTMLTreeBuilder> create(HTMLTokenizer* tokenizer, HTMLPositionProvider* htmlPositionProvider, HTMLDocument* document, bool reportErrors) > { >- return adoptPtr(new HTMLTreeBuilder(tokenizer, document, reportErrors)); >+ return adoptPtr(new HTMLTreeBuilder(tokenizer, htmlPositionProvider, document, reportErrors)); > } >- static PassOwnPtr<HTMLTreeBuilder> create(HTMLTokenizer* tokenizer, DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission scriptingPermission) >+ static PassOwnPtr<HTMLTreeBuilder> create(HTMLTokenizer* tokenizer, HTMLPositionProvider* htmlPositionProvider, DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission scriptingPermission) > { >- return adoptPtr(new HTMLTreeBuilder(tokenizer, fragment, contextElement, scriptingPermission)); >+ return adoptPtr(new HTMLTreeBuilder(tokenizer, htmlPositionProvider, fragment, contextElement, scriptingPermission)); > } > ~HTMLTreeBuilder(); > >@@ -71,7 +79,7 @@ public: > void constructTreeFromAtomicToken(AtomicHTMLToken&); > > // Must be called when parser is paused before calling the parser again. >- PassRefPtr<Element> takeScriptToProcess(int& scriptStartLine); >+ PassRefPtr<Element> takeScriptToProcess(HTMLPosition1& scriptStartPosition); > > // Done, close any open tags, etc. > void finished(); >@@ -110,8 +118,8 @@ private: > AfterAfterFramesetMode, > }; > >- HTMLTreeBuilder(HTMLTokenizer*, HTMLDocument*, bool reportErrors); >- HTMLTreeBuilder(HTMLTokenizer*, DocumentFragment*, Element* contextElement, FragmentScriptingPermission); >+ HTMLTreeBuilder(HTMLTokenizer*, HTMLPositionProvider*, HTMLDocument*, bool reportErrors); >+ HTMLTreeBuilder(HTMLTokenizer*, HTMLPositionProvider*, DocumentFragment*, Element* contextElement, FragmentScriptingPermission); > > bool isParsingFragment() const { return !!m_fragmentContext.fragment(); } > >@@ -246,12 +254,13 @@ private: > HTMLTokenizer* m_tokenizer; > > RefPtr<Element> m_scriptToProcess; // <script> tag which needs processing before resuming the parser. >- int m_scriptToProcessStartLine; // Starting line number of the script tag needing processing. >+ HTMLPosition1 m_scriptToProcessStartPosition; // Starting line number of the script tag needing processing. > > // FIXME: We probably want to remove this member. Originally, it was > // created to service the legacy tree builder, but it seems to be used for > // some other things now. >- int m_lastScriptElementStartLine; >+ HTMLPosition0 m_lastScriptElementStartPosition; >+ HTMLPositionProvider* m_htmlPositionProvider; > }; > > } >diff --git a/WebCore/platform/text/SegmentedString.cpp b/WebCore/platform/text/SegmentedString.cpp >index b9ff5037a982afd64d98215a786b05e0625d1598..11a0a59b3401531a393ed2af55aee643af8db0ec 100644 >--- a/WebCore/platform/text/SegmentedString.cpp >+++ b/WebCore/platform/text/SegmentedString.cpp >@@ -53,6 +53,9 @@ const SegmentedString& SegmentedString::operator=(const SegmentedString &other) > m_currentChar = other.m_currentChar; > m_closed = other.m_closed; > m_numberOfCharactersConsumedPriorToCurrentString = other.m_numberOfCharactersConsumedPriorToCurrentString; >+ m_lineBeginCharactersConsumedValue = other.m_lineBeginCharactersConsumedValue; >+ m_currentLine = other.m_currentLine; >+ > return *this; > } > >@@ -229,12 +232,32 @@ void SegmentedString::advanceSlowCase(int& lineNumber) > m_pushedChar1 = m_pushedChar2; > m_pushedChar2 = 0; > } else if (m_currentString.m_current) { >- if (*m_currentString.m_current++ == '\n' && m_currentString.doNotExcludeLineNumbers()) >- ++lineNumber; >+ if (*m_currentString.m_current++ == '\n' && m_currentString.doNotExcludeLineNumbers()) { >+ ++lineNumber; >+ ++m_currentLine; >+ m_lineBeginCharactersConsumedValue = numberOfCharactersConsumed(); >+ } > if (--m_currentString.m_length == 0) > advanceSubstring(); > } > m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current; > } > >+int SegmentedString::currentLine() const >+{ >+ return m_currentLine; >+} >+ >+int SegmentedString::currentColumn() const >+{ >+ return numberOfCharactersConsumed() - m_lineBeginCharactersConsumedValue; >+} >+ >+void SegmentedString::setCurrentPosition(int line, int column) >+{ >+ m_currentLine = line; >+ m_lineBeginCharactersConsumedValue = numberOfCharactersConsumed() - column; >+} >+ >+ > } >diff --git a/WebCore/platform/text/SegmentedString.h b/WebCore/platform/text/SegmentedString.h >index 91c2cbe3f9cf699076f82d06a18017a17841fbe6..4e999fa6ac48b0c8bc89f5ae2b480730be9b252a 100644 >--- a/WebCore/platform/text/SegmentedString.h >+++ b/WebCore/platform/text/SegmentedString.h >@@ -75,6 +75,8 @@ public: > , m_pushedChar2(0) > , m_currentChar(0) > , m_numberOfCharactersConsumedPriorToCurrentString(0) >+ , m_lineBeginCharactersConsumedValue(0) >+ , m_currentLine(0) > , m_composite(false) > , m_closed(false) > { >@@ -86,6 +88,8 @@ public: > , m_currentString(str) > , m_currentChar(m_currentString.m_current) > , m_numberOfCharactersConsumedPriorToCurrentString(0) >+ , m_lineBeginCharactersConsumedValue(0) >+ , m_currentLine(0) > , m_composite(false) > , m_closed(false) > { >@@ -155,7 +159,11 @@ public: > { > ASSERT(*current() == '\n'); > if (!m_pushedChar1 && m_currentString.m_length > 1) { >- lineNumber += m_currentString.doNotExcludeLineNumbers(); >+ if (m_currentString.doNotExcludeLineNumbers()) { >+ ++lineNumber; >+ ++m_currentLine; >+ m_lineBeginCharactersConsumedValue = numberOfCharactersConsumed(); >+ } > --m_currentString.m_length; > m_currentChar = ++m_currentString.m_current; > return; >@@ -177,7 +185,11 @@ public: > void advance(int& lineNumber) > { > if (!m_pushedChar1 && m_currentString.m_length > 1) { >- lineNumber += (*m_currentString.m_current == '\n') & m_currentString.doNotExcludeLineNumbers(); >+ if ((*m_currentString.m_current == '\n') & m_currentString.doNotExcludeLineNumbers()) { >+ ++lineNumber; >+ ++m_currentLine; >+ m_lineBeginCharactersConsumedValue = numberOfCharactersConsumed(); >+ } > --m_currentString.m_length; > m_currentChar = ++m_currentString.m_current; > return; >@@ -191,7 +203,7 @@ public: > > bool escaped() const { return m_pushedChar1; } > >- int numberOfCharactersConsumed() >+ int numberOfCharactersConsumed() const > { > // We don't currently handle the case when there are pushed character. > ASSERT(!m_pushedChar1); >@@ -203,6 +215,11 @@ public: > const UChar& operator*() const { return *current(); } > const UChar* operator->() const { return current(); } > >+ >+ int currentColumn() const; >+ int currentLine() const; >+ void setCurrentPosition(int line, int column); >+ > private: > void append(const SegmentedSubstring&); > void prepend(const SegmentedSubstring&); >@@ -247,6 +264,8 @@ private: > SegmentedSubstring m_currentString; > const UChar* m_currentChar; > int m_numberOfCharactersConsumedPriorToCurrentString; >+ int m_lineBeginCharactersConsumedValue; >+ int m_currentLine; > Deque<SegmentedSubstring> m_substrings; > bool m_composite; > bool m_closed; >diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog >index 47b0e63d080b71b12648838e2e061142b7f5cdec..2eb490e9e4f150d9a4c1dcbe59698f1feb57870e 100644 >--- a/WebKit/chromium/ChangeLog >+++ b/WebKit/chromium/ChangeLog >@@ -1,3 +1,17 @@ >+2010-09-20 Peter Rybin <peter.rybin@gmail.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ HTML parser should provide script column position within HTML document to JavaScript engine >+ https://bugs.webkit.org/show_bug.cgi?id=45271 >+ >+ Replaces script line number with HTMLPosition structure. >+ >+ * src/WebFrameImpl.cpp: >+ (WebKit::WebFrameImpl::executeScript): >+ (WebKit::WebFrameImpl::executeScriptInIsolatedWorld): >+ (WebKit::WebFrameImpl::executeScriptAndReturnValue): >+ > 2010-09-19 Sheriff Bot <webkit.review.bot@gmail.com> > > Unreviewed, rolling out r67749. >diff --git a/WebKit/chromium/src/WebFrameImpl.cpp b/WebKit/chromium/src/WebFrameImpl.cpp >index 2d42f4b753f6c8dfa0bbc381cf8bc595d935ca19..b4eb42dab4e8614c4f378d0492e0ec2f0a2dbeaf 100644 >--- a/WebKit/chromium/src/WebFrameImpl.cpp >+++ b/WebKit/chromium/src/WebFrameImpl.cpp >@@ -731,8 +731,9 @@ void WebFrameImpl::bindToWindowObject(const WebString& name, NPObject* object) > > void WebFrameImpl::executeScript(const WebScriptSource& source) > { >+ HTMLPosition1 position(WTF::OneBasedNumber::fromOneBasedInt(source.startLine), WTF::OneBasedNumber::s_base, 0); > m_frame->script()->executeScript( >- ScriptSourceCode(source.code, source.url, source.startLine)); >+ ScriptSourceCode(source.code, source.url, position)); > } > > void WebFrameImpl::executeScriptInIsolatedWorld( >@@ -742,8 +743,9 @@ void WebFrameImpl::executeScriptInIsolatedWorld( > Vector<ScriptSourceCode> sources; > > for (unsigned i = 0; i < numSources; ++i) { >+ HTMLPosition1 position(WTF::OneBasedNumber::fromOneBasedInt(sourcesIn[i].startLine), WTF::OneBasedNumber::s_base, 0); > sources.append(ScriptSourceCode( >- sourcesIn[i].code, sourcesIn[i].url, sourcesIn[i].startLine)); >+ sourcesIn[i].code, sourcesIn[i].url, position)); > } > > m_frame->script()->evaluateInIsolatedWorld(worldId, sources, extensionGroup); >@@ -795,8 +797,9 @@ void WebFrameImpl::collectGarbage() > v8::Handle<v8::Value> WebFrameImpl::executeScriptAndReturnValue( > const WebScriptSource& source) > { >+ HTMLPosition1 position(WTF::OneBasedNumber::fromOneBasedInt(source.startLine), WTF::OneBasedNumber::s_base, 0); > return m_frame->script()->executeScript( >- ScriptSourceCode(source.code, source.url, source.startLine)).v8Value(); >+ ScriptSourceCode(source.code, source.url, position)).v8Value(); > } > > // Returns the V8 context for this frame, or an empty handle if there is none.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 45271
:
66657
|
66663
|
66664
|
68076
|
68392
|
68589
|
68715
|
68746
|
70071
|
70250
|
71204
|
71294
|
71655
|
73489