Commit 07bfede5 authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

2010-10-25 Sheriff Bot <webkit.review.bot@gmail.com>

        Unreviewed, rolling out r70451.
        http://trac.webkit.org/changeset/70451
        https://bugs.webkit.org/show_bug.cgi?id=48249

        Broke set-unloaded-frame-location.html under Qt (Requested by
        caseq on #webkit).

        * GNUmakefile.am:
        * JavaScriptCore.gypi:
        * JavaScriptCore.xcodeproj/project.pbxproj:
        * wtf/text/TextPosition.h: Removed.
2010-10-25  Sheriff Bot  <webkit.review.bot@gmail.com>

        Unreviewed, rolling out r70451.
        http://trac.webkit.org/changeset/70451
        https://bugs.webkit.org/show_bug.cgi?id=48249

        Broke set-unloaded-frame-location.html under Qt (Requested by
        caseq on #webkit).

        * ForwardingHeaders/wtf/text/TextPosition.h: Removed.
2010-10-25  Sheriff Bot  <webkit.review.bot@gmail.com>

        Unreviewed, rolling out r70451.
        http://trac.webkit.org/changeset/70451
        https://bugs.webkit.org/show_bug.cgi?id=48249

        Broke set-unloaded-frame-location.html under Qt (Requested by
        caseq on #webkit).

        * ForwardingHeaders/wtf/text/TextPosition.h: Removed.
        * bindings/js/ScriptSourceCode.h:
        (WebCore::ScriptSourceCode::ScriptSourceCode):
        * bindings/v8/ScheduledAction.cpp:
        (WebCore::ScheduledAction::ScheduledAction):
        * bindings/v8/ScriptController.cpp:
        (WebCore::ScriptController::eventHandlerLineNumber):
        (WebCore::ScriptController::eventHandlerColumnNumber):
        * bindings/v8/ScriptController.h:
        * bindings/v8/ScriptEventListener.cpp:
        (WebCore::createAttributeEventListener):
        * bindings/v8/ScriptSourceCode.h:
        (WebCore::ScriptSourceCode::ScriptSourceCode):
        (WebCore::ScriptSourceCode::startLine):
        * 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::startingLineNumber):
        * dom/ScriptableDocumentParser.h:
        * dom/XMLDocumentParser.h:
        * dom/XMLDocumentParserLibxml2.cpp:
        (WebCore::XMLDocumentParser::XMLDocumentParser):
        (WebCore::XMLDocumentParser::startElementNs):
        (WebCore::XMLDocumentParser::endElementNs):
        (WebCore::XMLDocumentParser::lineNumber):
        (WebCore::XMLDocumentParser::columnNumber):
        * dom/XMLDocumentParserQt.cpp:
        (WebCore::XMLDocumentParser::XMLDocumentParser):
        (WebCore::XMLDocumentParser::parseStartElement):
        (WebCore::XMLDocumentParser::parseEndElement):
        * html/parser/HTMLDocumentParser.cpp:
        (WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder):
        (WebCore::HTMLDocumentParser::columnNumber):
        * html/parser/HTMLDocumentParser.h:
        * 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:
2010-10-25  Sheriff Bot  <webkit.review.bot@gmail.com>

        Unreviewed, rolling out r70451.
        http://trac.webkit.org/changeset/70451
        https://bugs.webkit.org/show_bug.cgi?id=48249

        Broke set-unloaded-frame-location.html under Qt (Requested by
        caseq on #webkit).

        * src/WebFrameImpl.cpp:
        (WebKit::WebFrameImpl::executeScript):
        (WebKit::WebFrameImpl::executeScriptInIsolatedWorld):
        (WebKit::WebFrameImpl::executeScriptAndReturnValue):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70463 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e02133af
2010-10-25 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r70451.
http://trac.webkit.org/changeset/70451
https://bugs.webkit.org/show_bug.cgi?id=48249
Broke set-unloaded-frame-location.html under Qt (Requested by
caseq on #webkit).
* GNUmakefile.am:
* JavaScriptCore.gypi:
* JavaScriptCore.xcodeproj/project.pbxproj:
* wtf/text/TextPosition.h: Removed.
2010-10-25 Patrick Gansterer <paroga@webkit.org>
Reviewed by David Kilzer.
......
......@@ -518,7 +518,6 @@ javascriptcore_sources += \
JavaScriptCore/wtf/text/StringImpl.cpp \
JavaScriptCore/wtf/text/StringImpl.h \
JavaScriptCore/wtf/text/StringStatics.cpp \
JavaScriptCore/wtf/text/TextPosition.h \
JavaScriptCore/wtf/text/WTFString.cpp \
JavaScriptCore/wtf/text/WTFString.h \
JavaScriptCore/wtf/ThreadIdentifierDataPthreads.cpp \
......
......@@ -461,7 +461,6 @@
'wtf/text/StringImpl.cpp',
'wtf/text/StringImpl.h',
'wtf/text/StringStatics.cpp',
'wtf/text/TextPosition.h',
'wtf/text/WTFString.cpp',
'wtf/text/WTFString.h',
'wtf/unicode/Collator.h',
......
......@@ -555,7 +555,6 @@
E1EE793D0D6C9B9200FEA3BA /* ThreadingPthreads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1EE793C0D6C9B9200FEA3BA /* ThreadingPthreads.cpp */; };
E1EF79AA0CE97BA60088D500 /* UTF8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1EF79A80CE97BA60088D500 /* UTF8.cpp */; };
E48E0F2D0F82151700A8CA37 /* FastAllocBase.h in Headers */ = {isa = PBXBuildFile; fileRef = E48E0F2C0F82151700A8CA37 /* FastAllocBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
F3BD31ED126735770065467F /* TextPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = F3BD31D0126730180065467F /* TextPosition.h */; settings = {ATTRIBUTES = (Private, ); }; };
FE1B447A0ECCD73B004F4DD1 /* StdLibExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1B44790ECCD73B004F4DD1 /* StdLibExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
/* End PBXBuildFile section */
......@@ -1145,7 +1144,6 @@
E1EF79A80CE97BA60088D500 /* UTF8.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UTF8.cpp; sourceTree = "<group>"; };
E1EF79A90CE97BA60088D500 /* UTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UTF8.h; sourceTree = "<group>"; };
E48E0F2C0F82151700A8CA37 /* FastAllocBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FastAllocBase.h; sourceTree = "<group>"; };
F3BD31D0126730180065467F /* TextPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextPosition.h; path = text/TextPosition.h; sourceTree = "<group>"; };
F5BB2BC5030F772101FCFE1D /* Completion.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Completion.h; sourceTree = "<group>"; tabWidth = 8; };
F5C290E60284F98E018635CA /* JavaScriptCorePrefix.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = JavaScriptCorePrefix.h; sourceTree = "<group>"; tabWidth = 8; };
F68EBB8C0255D4C601FF60F7 /* config.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; tabWidth = 8; };
......@@ -1862,7 +1860,6 @@
868BFA07117CEFD100B908B1 /* StringImpl.h */,
86B99AE2117E578100DF5A90 /* StringImplBase.h */,
8626BECE11928E3900782FAB /* StringStatics.cpp */,
F3BD31D0126730180065467F /* TextPosition.h */,
868BFA15117CF19900B908B1 /* WTFString.cpp */,
868BFA16117CF19900B908B1 /* WTFString.h */,
);
......@@ -2352,7 +2349,6 @@
90213E3E123A40C200D422F3 /* MemoryStatistics.h in Headers */,
A730B6121250068F009D25B1 /* StrictEvalActivation.h in Headers */,
933F5CDC1269229B0049191E /* NullPtr.h in Headers */,
F3BD31ED126735770065467F /* TextPosition.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
/*
* 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 TextPosition_h
#define TextPosition_h
#include <wtf/Assertions.h>
namespace WTF {
/*
* Text Position
*
* TextPosition structure specifies coordinates within an text resource. It is used mostly
* for saving script source position.
*
* Later TextPosition0 and TextPosition1 and both number types can be merged together quite easily.
*
* 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 TextPosition 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, TextPosition0 should be introduced. This
* way all changes will remain trackable.
*
* Later both number types can be merged in one type quite easily.
*
* For type safety and for the future type merge it is important that all operations in API
* that accept or return integer have a name explicitly defining base of integer. For this reason
* int-receiving constructors are hidden from API.
*/
template<typename NUMBER>
class TextPosition {
public:
TextPosition(NUMBER line, NUMBER column)
: m_line(line)
, m_column(column)
{
}
TextPosition() {}
// A 'minimum' value of position, used as a default value.
static TextPosition<NUMBER> minimumPosition() { return TextPosition<NUMBER>(NUMBER::base(), NUMBER::base()); }
// A value with line value less than a minimum; used as an impossible position.
static TextPosition<NUMBER> belowRangePosition() { return TextPosition<NUMBER>(NUMBER::belowBase(), NUMBER::base()); }
NUMBER m_line;
NUMBER m_column;
};
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 ZeroBasedNumber base() { return 0; }
static ZeroBasedNumber belowBase() { return -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 OneBasedNumber base() { return 1; }
static OneBasedNumber belowBase() { return 0; }
private:
OneBasedNumber(int value) : m_value(value) {}
int m_value;
};
typedef TextPosition<ZeroBasedNumber> TextPosition0;
typedef TextPosition<OneBasedNumber> TextPosition1;
inline TextPosition0 toZeroBasedTextPosition(const TextPosition1& position)
{
return TextPosition0(position.m_line.convertToZeroBased(), position.m_column.convertToZeroBased());
}
inline TextPosition1 toOneBasedTextPosition(const TextPosition0& position)
{
return TextPosition1(position.m_line.convertToOneBased(), position.m_column.convertToOneBased());
}
inline OneBasedNumber ZeroBasedNumber::convertToOneBased() const
{
return OneBasedNumber::fromOneBasedInt(m_value + 1);
}
}
using WTF::TextPosition0;
using WTF::TextPosition1;
#endif // TextPosition_h
2010-10-25 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r70451.
http://trac.webkit.org/changeset/70451
https://bugs.webkit.org/show_bug.cgi?id=48249
Broke set-unloaded-frame-location.html under Qt (Requested by
caseq on #webkit).
* ForwardingHeaders/wtf/text/TextPosition.h: Removed.
2010-10-16 Patrick Gansterer <paroga@webkit.org>
Reviewed by Adam Barth.
......
2010-10-25 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r70451.
http://trac.webkit.org/changeset/70451
https://bugs.webkit.org/show_bug.cgi?id=48249
Broke set-unloaded-frame-location.html under Qt (Requested by
caseq on #webkit).
* ForwardingHeaders/wtf/text/TextPosition.h: Removed.
* bindings/js/ScriptSourceCode.h:
(WebCore::ScriptSourceCode::ScriptSourceCode):
* bindings/v8/ScheduledAction.cpp:
(WebCore::ScheduledAction::ScheduledAction):
* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::eventHandlerLineNumber):
(WebCore::ScriptController::eventHandlerColumnNumber):
* bindings/v8/ScriptController.h:
* bindings/v8/ScriptEventListener.cpp:
(WebCore::createAttributeEventListener):
* bindings/v8/ScriptSourceCode.h:
(WebCore::ScriptSourceCode::ScriptSourceCode):
(WebCore::ScriptSourceCode::startLine):
* 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::startingLineNumber):
* dom/ScriptableDocumentParser.h:
* dom/XMLDocumentParser.h:
* dom/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::XMLDocumentParser):
(WebCore::XMLDocumentParser::startElementNs):
(WebCore::XMLDocumentParser::endElementNs):
(WebCore::XMLDocumentParser::lineNumber):
(WebCore::XMLDocumentParser::columnNumber):
* dom/XMLDocumentParserQt.cpp:
(WebCore::XMLDocumentParser::XMLDocumentParser):
(WebCore::XMLDocumentParser::parseStartElement):
(WebCore::XMLDocumentParser::parseEndElement):
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder):
(WebCore::HTMLDocumentParser::columnNumber):
* html/parser/HTMLDocumentParser.h:
* 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:
2010-10-25 Kwang Yul Seo <skyul@company100.net>
 
Unreviewed build fix for r70095.
#ifndef WebCore_FWD_TextPosition_h
#define WebCore_FWD_TextPosition_h
#include <JavaScriptCore/TextPosition.h>
#endif
......@@ -35,16 +35,15 @@
#include "ScriptSourceProvider.h"
#include "StringSourceProvider.h"
#include "KURL.h"
#include <wtf/text/TextPosition.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class ScriptSourceCode {
public:
ScriptSourceCode(const String& source, const KURL& url = KURL(), const TextPosition1& startPosition = TextPosition1::minimumPosition())
ScriptSourceCode(const String& source, const KURL& url = KURL(), int startLine = 1)
: m_provider(StringSourceProvider::create(source, url.isNull() ? String() : url.string()))
, m_code(m_provider, startPosition.m_line.oneBasedInt())
, m_code(m_provider, startLine)
, m_url(url)
{
}
......
......@@ -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(), TextPosition1::belowRangePosition())
, m_code(String(), KURL(), 0)
{
m_function = v8::Persistent<v8::Function>::New(func);
......
......@@ -262,12 +262,20 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode, Shoul
return ScriptValue(object);
}
TextPosition0 ScriptController::eventHandlerPosition() const
int ScriptController::eventHandlerLineNumber() const
{
ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentParser();
if (parser)
return parser->textPosition();
return TextPosition0::minimumPosition();
return parser->lineNumber();
return 0;
}
int ScriptController::eventHandlerColumnNumber() const
{
ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentParser();
if (parser)
return parser->columnNumber();
return 0;
}
void ScriptController::finishedWithEvent(Event* event)
......
......@@ -155,7 +155,8 @@ public:
void finishedWithEvent(Event*);
TextPosition0 eventHandlerPosition() const;
int eventHandlerLineNumber() const;
int eventHandlerColumnNumber() const;
void setProcessingTimerCallback(bool processingTimerCallback) { m_processingTimerCallback = processingTimerCallback; }
// FIXME: Currently we don't use the parameter world at all.
......
......@@ -50,8 +50,8 @@ PassRefPtr<V8LazyEventListener> createAttributeEventListener(Node* node, Attribu
if (attr->isNull())
return 0;
// FIXME: Very strange: we initialize zero-based number with '1'.
TextPosition0 position(WTF::ZeroBasedNumber::fromZeroBasedInt(1), WTF::ZeroBasedNumber::base());
int lineNumber = 1;
int columnNumber = 0;
String sourceURL;
if (Frame* frame = node->document()->frame()) {
......@@ -64,11 +64,12 @@ PassRefPtr<V8LazyEventListener> createAttributeEventListener(Node* node, Attribu
return 0;
}
position = scriptController->eventHandlerPosition();
lineNumber = scriptController->eventHandlerLineNumber();
columnNumber = scriptController->eventHandlerColumnNumber();
sourceURL = node->document()->url().string();
}
return V8LazyEventListener::create(attr->localName().string(), node->isSVGElement(), attr->value(), sourceURL, position, WorldContextHandle(UseMainWorld));
return V8LazyEventListener::create(attr->localName().string(), node->isSVGElement(), attr->value(), sourceURL, lineNumber, columnNumber, WorldContextHandle(UseMainWorld));
}
PassRefPtr<V8LazyEventListener> createAttributeEventListener(Frame* frame, Attribute* attr)
......@@ -80,6 +81,10 @@ 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;
......@@ -89,9 +94,10 @@ PassRefPtr<V8LazyEventListener> createAttributeEventListener(Frame* frame, Attri
return 0;
}
TextPosition0 position = scriptController->eventHandlerPosition();
String sourceURL = frame->document()->url().string();
return V8LazyEventListener::create(attr->localName().string(), frame->document()->isSVGDocument(), attr->value(), sourceURL, position, WorldContextHandle(UseMainWorld));
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));
}
String eventListenerHandlerBody(Document* document, EventListener* listener)
......
......@@ -35,17 +35,16 @@
#include "CachedScript.h"
#include "KURL.h"
#include "PlatformString.h"
#include <wtf/text/TextPosition.h>
namespace WebCore {
class ScriptSourceCode {
public:
ScriptSourceCode(const String& source, const KURL& url = KURL(), const TextPosition1& startPosition = TextPosition1::minimumPosition())
ScriptSourceCode(const String& source, const KURL& url = KURL(), int startLine = 1)
: m_source(source)
, m_cachedScript(0)
, m_url(url)
, m_startPosition(startPosition)
, m_startLine(startLine)
{
}
......@@ -55,7 +54,7 @@ public:
: m_source(cs->script())
, m_cachedScript(cs)
, m_url(ParsedURLString, cs->url())
, m_startPosition(TextPosition1::minimumPosition())
, m_startLine(1)
{
}
......@@ -64,14 +63,13 @@ 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_startPosition.m_line.oneBasedInt(); }
const TextPosition1& startPosition() const { return m_startPosition; }
int startLine() const { return m_startLine; }
private:
String m_source;
CachedResourceHandle<CachedScript> m_cachedScript;
KURL m_url;
TextPosition1 m_startPosition;
int m_startLine;
};
} // namespace WebCore
......
......@@ -41,13 +41,14 @@
namespace WebCore {
V8LazyEventListener::V8LazyEventListener(const String& functionName, bool isSVGEvent, const String& code, const String sourceURL, const TextPosition0& position, const WorldContextHandle& worldContext)
V8LazyEventListener::V8LazyEventListener(const String& functionName, bool isSVGEvent, const String& code, const String sourceURL, int lineNumber, int columnNumber, const WorldContextHandle& worldContext)
: V8AbstractEventListener(true, worldContext)
, m_functionName(functionName)
, m_isSVGEvent(isSVGEvent)
, m_code(code)
, m_sourceURL(sourceURL)
, m_position(position)
, m_lineNumber(lineNumber)
, m_columnNumber(columnNumber)
{
}
......@@ -113,7 +114,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_position);
v8::Handle<v8::Script> script = V8Proxy::compileScript(codeExternalString, m_sourceURL, m_lineNumber);
if (!script.IsEmpty()) {
v8::Local<v8::Value> value = proxy->runScript(script, false);
if (!value.IsEmpty()) {
......
......@@ -34,7 +34,6 @@
#include "PlatformString.h"
#include "V8AbstractEventListener.h"
#include <v8.h>
#include <wtf/text/TextPosition.h>
#include <wtf/PassRefPtr.h>
namespace WebCore {
......@@ -46,9 +45,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, const TextPosition0& position, const WorldContextHandle& worldContext)
static PassRefPtr<V8LazyEventListener> create(const String& functionName, bool isSVGEvent, const String& code, const String& sourceURL, int lineNumber, int columnNumber, const WorldContextHandle& worldContext)
{
return adoptRef(new V8LazyEventListener(functionName, isSVGEvent, code, sourceURL, position, worldContext));
return adoptRef(new V8LazyEventListener(functionName, isSVGEvent, code, sourceURL, lineNumber, columnNumber, worldContext));
}
virtual bool isLazy() const { return true; }
......@@ -57,7 +56,7 @@ namespace WebCore {
virtual void prepareListenerObject(ScriptExecutionContext*);
private:
V8LazyEventListener(const String& functionName, bool isSVGEvent, const String& code, const String sourceURL, const TextPosition0& position, const WorldContextHandle& worldContext);
V8LazyEventListener(const String& functionName, bool isSVGEvent, const String& code, const String sourceURL, int lineNumber, int columnNumber, const WorldContextHandle& worldContext);
virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
......@@ -71,7 +70,8 @@ namespace WebCore {
bool m_isSVGEvent;
String m_code;
String m_sourceURL;
TextPosition0 m_position;
int m_lineNumber;
int m_columnNumber;
};
} // namespace WebCore
......
......@@ -236,13 +236,12 @@ V8Proxy::~V8Proxy()
windowShell()->destroyGlobal();
}
v8::Handle<v8::Script> V8Proxy::compileScript(v8::Handle<v8::String> code, const String& fileName, const TextPosition0& scriptStartPosition, v8::ScriptData* scriptData)
v8::Handle<v8::Script> V8Proxy::compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine, 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(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::Integer> line = v8::Integer::New(baseLine);
v8::ScriptOrigin origin(name, line);
v8::Handle<v8::Script> script = v8::Script::Compile(code, &origin, scriptData);
return script;
}
......@@ -395,7 +394,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(), WTF::toZeroBasedTextPosition(source.startPosition()), scriptData.get());
v8::Handle<v8::Script> script = compileScript(code, source.url(), source.startLine() - 1, scriptData.get());
#if PLATFORM(CHROMIUM)
PlatformBridge::traceEventEnd("v8.compile", node, "");
......@@ -427,7 +426,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, "", TextPosition0::minimumPosition());
script = compileScript(code, "", 0);
}
if (handleOutOfMemory())
......
......@@ -279,7 +279,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, const TextPosition0& scriptStartPosition, v8::ScriptData* = 0);
static v8::Handle<v8::Script> compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine, v8::ScriptData* = 0);
// If the exception code is different from zero, a DOM exception is
// schedule to be thrown.
......
......@@ -184,7 +184,7 @@ bool WorkerContextExecutionProxy::forgetV8EventObject(Event* event)
return false;
}
ScriptValue WorkerContextExecutionProxy::evaluate(const String& script, const String& fileName, const TextPosition0& scriptStartPosition, WorkerContextExecutionState* state)
ScriptValue WorkerContextExecutionProxy::evaluate(const String& script,<