Diff
Modified: trunk/Source/WebCore/ChangeLog (129104 => 129105)
--- trunk/Source/WebCore/ChangeLog 2012-09-20 08:31:45 UTC (rev 129104)
+++ trunk/Source/WebCore/ChangeLog 2012-09-20 08:33:46 UTC (rev 129105)
@@ -1,3 +1,33 @@
+2012-09-18 Alexander Pavlov <[email protected]>
+
+ Web Inspector: Use and process the actual ScriptId in the protocol EventListener object
+ https://bugs.webkit.org/show_bug.cgi?id=93271
+
+ Reviewed by Yury Semikhatsky.
+
+ - Use the actual script identifier in the "location" object's "scriptId" field
+ for the DOM.EventListener protocol type, but send the script URL in the new "sourceName" field.
+ - Use 0-based lines in the "location" object's "lineNumber" field for linkifyRawLocation() to work correctly.
+ - Fixed formatting of links to listener locations to contain "(program)" rather than empty string.
+
+ * bindings/js/ScriptEventListener.cpp:
+ (WebCore::eventListenerHandlerLocation):
+ * bindings/js/ScriptEventListener.h:
+ (WebCore):
+ * bindings/v8/ScriptEventListener.cpp:
+ (WebCore::eventListenerHandlerLocation):
+ * bindings/v8/ScriptEventListener.h:
+ (WebCore):
+ * inspector/Inspector.json:
+ * inspector/InspectorDOMAgent.cpp:
+ (WebCore::InspectorDOMAgent::buildObjectForEventListener):
+ * inspector/front-end/BreakpointsSidebarPane.js:
+ * inspector/front-end/EventListenersSidebarPane.js:
+ * inspector/front-end/Linkifier.js:
+ (WebInspector.Linkifier.DefaultFormatter.prototype.formatLiveAnchor):
+ * inspector/front-end/ResourceUtils.js:
+ (WebInspector.formatLinkText): Use "(program)" if URL is empty.
+
2012-09-19 Dan Bernstein <[email protected]>
WebCore part of adding a setting and API for disabling screen font substitution
Modified: trunk/Source/WebCore/bindings/js/ScriptEventListener.cpp (129104 => 129105)
--- trunk/Source/WebCore/bindings/js/ScriptEventListener.cpp 2012-09-20 08:31:45 UTC (rev 129104)
+++ trunk/Source/WebCore/bindings/js/ScriptEventListener.cpp 2012-09-20 08:33:46 UTC (rev 129105)
@@ -106,7 +106,7 @@
return jsFunction->toString(scriptState)->value(scriptState);
}
-bool eventListenerHandlerLocation(Document* document, EventListener* eventListener, String& sourceName, int& lineNumber)
+bool eventListenerHandlerLocation(Document* document, EventListener* eventListener, String& sourceName, String& scriptId, int& lineNumber)
{
const JSEventListener* jsListener = JSEventListener::cast(eventListener);
ASSERT(jsListener);
@@ -122,7 +122,9 @@
JSC::FunctionExecutable* funcExecutable = jsFunction->jsExecutable();
if (!funcExecutable)
return false;
- lineNumber = funcExecutable->lineNo();
+ lineNumber = funcExecutable->lineNo() - 1;
+ intptr_t funcSourceId = funcExecutable->sourceID();
+ scriptId = funcSourceId == SourceProvider::nullID ? "" : String::number(funcSourceId);
sourceName = funcExecutable->sourceURL();
return true;
}
Modified: trunk/Source/WebCore/bindings/js/ScriptEventListener.h (129104 => 129105)
--- trunk/Source/WebCore/bindings/js/ScriptEventListener.h 2012-09-20 08:31:45 UTC (rev 129104)
+++ trunk/Source/WebCore/bindings/js/ScriptEventListener.h 2012-09-20 08:33:46 UTC (rev 129105)
@@ -46,7 +46,7 @@
PassRefPtr<JSLazyEventListener> createAttributeEventListener(Node*, const Attribute&);
PassRefPtr<JSLazyEventListener> createAttributeEventListener(Frame*, const Attribute&);
String eventListenerHandlerBody(Document*, EventListener*);
- bool eventListenerHandlerLocation(Document*, EventListener*, String& sourceName, int& lineNumber);
+ bool eventListenerHandlerLocation(Document*, EventListener*, String& sourceName, String& scriptId, int& lineNumber);
} // namespace WebCore
#endif // ScriptEventListener_h
Modified: trunk/Source/WebCore/bindings/v8/ScriptEventListener.cpp (129104 => 129105)
--- trunk/Source/WebCore/bindings/v8/ScriptEventListener.cpp 2012-09-20 08:31:45 UTC (rev 129104)
+++ trunk/Source/WebCore/bindings/v8/ScriptEventListener.cpp 2012-09-20 08:33:46 UTC (rev 129105)
@@ -104,7 +104,7 @@
return toWebCoreStringWithNullCheck(function);
}
-bool eventListenerHandlerLocation(Document* document, EventListener* listener, String& sourceName, int& lineNumber)
+bool eventListenerHandlerLocation(Document* document, EventListener* listener, String& sourceName, String& scriptId, int& lineNumber)
{
if (listener->type() != EventListener::JSEventListenerType)
return false;
@@ -118,13 +118,15 @@
return false;
v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(object);
+ v8::Handle<v8::Value> scriptIdValue = function->GetScriptId();
+ scriptId = toWebCoreStringWithNullOrUndefinedCheck(scriptIdValue);
v8::ScriptOrigin origin = function->GetScriptOrigin();
- if (!origin.ResourceName().IsEmpty()) {
+ if (origin.ResourceName()->IsString() && !origin.ResourceName().IsEmpty())
sourceName = toWebCoreString(origin.ResourceName());
- lineNumber = function->GetScriptLineNumber() + 1;
- return true;
- }
- return false;
+ else
+ sourceName = "";
+ lineNumber = function->GetScriptLineNumber();
+ return true;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/v8/ScriptEventListener.h (129104 => 129105)
--- trunk/Source/WebCore/bindings/v8/ScriptEventListener.h 2012-09-20 08:31:45 UTC (rev 129104)
+++ trunk/Source/WebCore/bindings/v8/ScriptEventListener.h 2012-09-20 08:33:46 UTC (rev 129105)
@@ -46,7 +46,7 @@
PassRefPtr<V8LazyEventListener> createAttributeEventListener(Node*, const Attribute&);
PassRefPtr<V8LazyEventListener> createAttributeEventListener(Frame*, const Attribute&);
String eventListenerHandlerBody(Document*, EventListener*);
- bool eventListenerHandlerLocation(Document*, EventListener*, String& sourceName, int& lineNumber);
+ bool eventListenerHandlerLocation(Document*, EventListener*, String& sourceName, String& scriptId, int& lineNumber);
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/Inspector.json (129104 => 129105)
--- trunk/Source/WebCore/inspector/Inspector.json 2012-09-20 08:31:45 UTC (rev 129104)
+++ trunk/Source/WebCore/inspector/Inspector.json 2012-09-20 08:33:46 UTC (rev 129105)
@@ -1588,7 +1588,8 @@
{ "name": "isAttribute", "type": "boolean", "description": "<code>EventListener</code>'s isAttribute." },
{ "name": "nodeId", "$ref": "NodeId", "description": "Target <code>DOMNode</code> id." },
{ "name": "handlerBody", "type": "string", "description": "Event handler function body." },
- { "name": "location", "$ref": "Debugger.Location", "optional": true, "description": "Handler code location." }
+ { "name": "location", "$ref": "Debugger.Location", "optional": true, "description": "Handler code location." },
+ { "name": "sourceName", "type": "string", "optional": true, "description": "Source script URL." }
],
"description": "DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. DOMNode is a base node mirror type."
},
Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (129104 => 129105)
--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2012-09-20 08:31:45 UTC (rev 129104)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2012-09-20 08:33:46 UTC (rev 129105)
@@ -1304,12 +1304,15 @@
.setNodeId(pushNodePathToFrontend(node))
.setHandlerBody(eventListenerHandlerBody(node->document(), eventListener.get()));
String sourceName;
+ String scriptId;
int lineNumber;
- if (eventListenerHandlerLocation(node->document(), eventListener.get(), sourceName, lineNumber)) {
+ if (eventListenerHandlerLocation(node->document(), eventListener.get(), sourceName, scriptId, lineNumber)) {
RefPtr<TypeBuilder::Debugger::Location> location = TypeBuilder::Debugger::Location::create()
- .setScriptId(sourceName)
+ .setScriptId(scriptId)
.setLineNumber(lineNumber);
value->setLocation(location);
+ if (!sourceName.isEmpty())
+ value->setSourceName(sourceName);
}
return value.release();
}
Modified: trunk/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js (129104 => 129105)
--- trunk/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js 2012-09-20 08:31:45 UTC (rev 129104)
+++ trunk/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js 2012-09-20 08:33:46 UTC (rev 129105)
@@ -72,9 +72,7 @@
checkbox.addEventListener("click", this._breakpointCheckboxClicked.bind(this, breakpoint), false);
element.appendChild(checkbox);
- var url = ""
- var displayName = url ? WebInspector.displayNameForURL(url) : WebInspector.UIString("(program)");
- var labelElement = document.createTextNode(displayName + ":" + (uiLocation.lineNumber + 1));
+ var labelElement = document.createTextNode(WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber));
element.appendChild(labelElement);
var snippetElement = document.createElement("div");
Modified: trunk/Source/WebCore/inspector/front-end/CallStackSidebarPane.js (129104 => 129105)
--- trunk/Source/WebCore/inspector/front-end/CallStackSidebarPane.js 2012-09-20 08:31:45 UTC (rev 129104)
+++ trunk/Source/WebCore/inspector/front-end/CallStackSidebarPane.js 2012-09-20 08:33:46 UTC (rev 129105)
@@ -178,7 +178,7 @@
WebInspector.CallStackSidebarPane.Placard.prototype = {
_update: function(uiLocation)
{
- this.subtitle = WebInspector.displayNameForURL(uiLocation.uiSourceCode.url) + ":" + (uiLocation.lineNumber + 1);
+ this.subtitle = WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber);
},
_placardContextMenu: function(event)
Modified: trunk/Source/WebCore/inspector/front-end/EventListenersSidebarPane.js (129104 => 129105)
--- trunk/Source/WebCore/inspector/front-end/EventListenersSidebarPane.js 2012-09-20 08:31:45 UTC (rev 129104)
+++ trunk/Source/WebCore/inspector/front-end/EventListenersSidebarPane.js 2012-09-20 08:33:46 UTC (rev 129105)
@@ -204,10 +204,10 @@
properties.push(new WebInspector.RemoteObjectProperty("node", nodeObject));
if (typeof this.eventListener.handlerBody !== "undefined")
properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("listenerBody", this.eventListener.handlerBody));
- if (this.eventListener.location) {
- properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("sourceName", this.eventListener.location.scriptId));
- properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("lineNumber", this.eventListener.location.lineNumber));
- }
+ if (this.eventListener.sourceName)
+ properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("sourceName", this.eventListener.sourceName));
+ if (this.eventListener.location)
+ properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("lineNumber", this.eventListener.location.lineNumber + 1));
this.updateProperties(properties);
}
@@ -239,11 +239,15 @@
// Requires that Function.toString() return at least the function's signature.
if (this.eventListener.location) {
this.subtitleElement.removeChildren();
- // FIXME(62725): eventListener.location should be a debugger Location.
- var url = ""
- var lineNumber = this.eventListener.location.lineNumber - 1;
- var columnNumber = 0;
- var urlElement = linkifier.linkifyLocation(url, lineNumber, columnNumber);
+ var urlElement;
+ if (this.eventListener.location.scriptId)
+ urlElement = linkifier.linkifyRawLocation(this.eventListener.location);
+ if (!urlElement) {
+ var url = ""
+ var lineNumber = this.eventListener.location.lineNumber;
+ var columnNumber = 0;
+ urlElement = linkifier.linkifyLocation(url, lineNumber, columnNumber);
+ }
this.subtitleElement.appendChild(urlElement);
} else {
var match = this.eventListener.handlerBody.match(/function ([^\(]+?)\(/);
Modified: trunk/Source/WebCore/inspector/front-end/Linkifier.js (129104 => 129105)
--- trunk/Source/WebCore/inspector/front-end/Linkifier.js 2012-09-20 08:31:45 UTC (rev 129104)
+++ trunk/Source/WebCore/inspector/front-end/Linkifier.js 2012-09-20 08:33:46 UTC (rev 129105)
@@ -121,8 +121,6 @@
*/
formatLiveAnchor: function(anchor, uiLocation)
{
- anchor.textContent = WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber);
-
var text = WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber);
if (this._maxLength)
text = text.trimMiddle(this._maxLength);
Modified: trunk/Source/WebCore/inspector/front-end/ResourceUtils.js (129104 => 129105)
--- trunk/Source/WebCore/inspector/front-end/ResourceUtils.js 2012-09-20 08:31:45 UTC (rev 129104)
+++ trunk/Source/WebCore/inspector/front-end/ResourceUtils.js 2012-09-20 08:33:46 UTC (rev 129105)
@@ -192,7 +192,7 @@
*/
WebInspector.formatLinkText = function(url, lineNumber)
{
- var text = WebInspector.displayNameForURL(url);
+ var text = url ? WebInspector.displayNameForURL(url) : WebInspector.UIString("(program)");
if (typeof lineNumber === "number")
text += ":" + (lineNumber + 1);
return text;