Changeset 129105 in webkit


Ignore:
Timestamp:
Sep 20, 2012 1:33:46 AM (12 years ago)
Author:
apavlov@chromium.org
Message:

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.

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r129097 r129105  
     12012-09-18  Alexander Pavlov  <apavlov@chromium.org>
     2
     3        Web Inspector: Use and process the actual ScriptId in the protocol EventListener object
     4        https://bugs.webkit.org/show_bug.cgi?id=93271
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        - Use the actual script identifier in the "location" object's "scriptId" field
     9          for the DOM.EventListener protocol type, but send the script URL in the new "sourceName" field.
     10        - Use 0-based lines in the "location" object's "lineNumber" field for linkifyRawLocation() to work correctly.
     11        - Fixed formatting of links to listener locations to contain "(program)" rather than empty string.
     12
     13        * bindings/js/ScriptEventListener.cpp:
     14        (WebCore::eventListenerHandlerLocation):
     15        * bindings/js/ScriptEventListener.h:
     16        (WebCore):
     17        * bindings/v8/ScriptEventListener.cpp:
     18        (WebCore::eventListenerHandlerLocation):
     19        * bindings/v8/ScriptEventListener.h:
     20        (WebCore):
     21        * inspector/Inspector.json:
     22        * inspector/InspectorDOMAgent.cpp:
     23        (WebCore::InspectorDOMAgent::buildObjectForEventListener):
     24        * inspector/front-end/BreakpointsSidebarPane.js:
     25        * inspector/front-end/EventListenersSidebarPane.js:
     26        * inspector/front-end/Linkifier.js:
     27        (WebInspector.Linkifier.DefaultFormatter.prototype.formatLiveAnchor):
     28        * inspector/front-end/ResourceUtils.js:
     29        (WebInspector.formatLinkText): Use "(program)" if URL is empty.
     30
    1312012-09-19  Dan Bernstein  <mitz@apple.com>
    232
  • trunk/Source/WebCore/bindings/js/ScriptEventListener.cpp

    r127191 r129105  
    107107}
    108108
    109 bool eventListenerHandlerLocation(Document* document, EventListener* eventListener, String& sourceName, int& lineNumber)
     109bool eventListenerHandlerLocation(Document* document, EventListener* eventListener, String& sourceName, String& scriptId, int& lineNumber)
    110110{
    111111    const JSEventListener* jsListener = JSEventListener::cast(eventListener);
     
    123123    if (!funcExecutable)
    124124        return false;
    125     lineNumber = funcExecutable->lineNo();
     125    lineNumber = funcExecutable->lineNo() - 1;
     126    intptr_t funcSourceId = funcExecutable->sourceID();
     127    scriptId = funcSourceId == SourceProvider::nullID ? "" : String::number(funcSourceId);
    126128    sourceName = funcExecutable->sourceURL();
    127129    return true;
  • trunk/Source/WebCore/bindings/js/ScriptEventListener.h

    r117195 r129105  
    4747    PassRefPtr<JSLazyEventListener> createAttributeEventListener(Frame*, const Attribute&);
    4848    String eventListenerHandlerBody(Document*, EventListener*);
    49     bool eventListenerHandlerLocation(Document*, EventListener*, String& sourceName, int& lineNumber);
     49    bool eventListenerHandlerLocation(Document*, EventListener*, String& sourceName, String& scriptId, int& lineNumber);
    5050} // namespace WebCore
    5151
  • trunk/Source/WebCore/bindings/v8/ScriptEventListener.cpp

    r127062 r129105  
    105105}
    106106
    107 bool eventListenerHandlerLocation(Document* document, EventListener* listener, String& sourceName, int& lineNumber)
     107bool eventListenerHandlerLocation(Document* document, EventListener* listener, String& sourceName, String& scriptId, int& lineNumber)
    108108{
    109109    if (listener->type() != EventListener::JSEventListenerType)
     
    119119
    120120    v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(object);
     121    v8::Handle<v8::Value> scriptIdValue = function->GetScriptId();
     122    scriptId = toWebCoreStringWithNullOrUndefinedCheck(scriptIdValue);
    121123    v8::ScriptOrigin origin = function->GetScriptOrigin();
    122     if (!origin.ResourceName().IsEmpty()) {
     124    if (origin.ResourceName()->IsString() && !origin.ResourceName().IsEmpty())
    123125        sourceName = toWebCoreString(origin.ResourceName());
    124         lineNumber = function->GetScriptLineNumber() + 1;
    125         return true;
    126     }
    127     return false;
     126    else
     127        sourceName = "";
     128    lineNumber = function->GetScriptLineNumber();
     129    return true;
    128130}
    129131
  • trunk/Source/WebCore/bindings/v8/ScriptEventListener.h

    r117195 r129105  
    4747    PassRefPtr<V8LazyEventListener> createAttributeEventListener(Frame*, const Attribute&);
    4848    String eventListenerHandlerBody(Document*, EventListener*);
    49     bool eventListenerHandlerLocation(Document*, EventListener*, String& sourceName, int& lineNumber);
     49    bool eventListenerHandlerLocation(Document*, EventListener*, String& sourceName, String& scriptId, int& lineNumber);
    5050
    5151} // namespace WebCore
  • trunk/Source/WebCore/inspector/Inspector.json

    r128992 r129105  
    15891589                    { "name": "nodeId", "$ref": "NodeId", "description": "Target <code>DOMNode</code> id." },
    15901590                    { "name": "handlerBody", "type": "string", "description": "Event handler function body." },
    1591                     { "name": "location", "$ref": "Debugger.Location", "optional": true, "description": "Handler code location." }
     1591                    { "name": "location", "$ref": "Debugger.Location", "optional": true, "description": "Handler code location." },
     1592                    { "name": "sourceName", "type": "string", "optional": true, "description": "Source script URL." }
    15921593                ],
    15931594                "description": "DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. DOMNode is a base node mirror type."
  • trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp

    r128572 r129105  
    13051305        .setHandlerBody(eventListenerHandlerBody(node->document(), eventListener.get()));
    13061306    String sourceName;
     1307    String scriptId;
    13071308    int lineNumber;
    1308     if (eventListenerHandlerLocation(node->document(), eventListener.get(), sourceName, lineNumber)) {
     1309    if (eventListenerHandlerLocation(node->document(), eventListener.get(), sourceName, scriptId, lineNumber)) {
    13091310        RefPtr<TypeBuilder::Debugger::Location> location = TypeBuilder::Debugger::Location::create()
    1310             .setScriptId(sourceName)
     1311            .setScriptId(scriptId)
    13111312            .setLineNumber(lineNumber);
    13121313        value->setLocation(location);
     1314        if (!sourceName.isEmpty())
     1315            value->setSourceName(sourceName);
    13131316    }
    13141317    return value.release();
  • trunk/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js

    r126012 r129105  
    7373        element.appendChild(checkbox);
    7474
    75         var url = uiLocation.uiSourceCode.url;
    76         var displayName = url ? WebInspector.displayNameForURL(url) : WebInspector.UIString("(program)");
    77         var labelElement = document.createTextNode(displayName + ":" + (uiLocation.lineNumber + 1));
     75        var labelElement = document.createTextNode(WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber));
    7876        element.appendChild(labelElement);
    7977
  • trunk/Source/WebCore/inspector/front-end/CallStackSidebarPane.js

    r121021 r129105  
    179179    _update: function(uiLocation)
    180180    {
    181         this.subtitle = WebInspector.displayNameForURL(uiLocation.uiSourceCode.url) + ":" + (uiLocation.lineNumber + 1);
     181        this.subtitle = WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber);
    182182    },
    183183
  • trunk/Source/WebCore/inspector/front-end/EventListenersSidebarPane.js

    r126430 r129105  
    205205            if (typeof this.eventListener.handlerBody !== "undefined")
    206206                properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("listenerBody", this.eventListener.handlerBody));
    207             if (this.eventListener.location) {
    208                 properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("sourceName", this.eventListener.location.scriptId));
    209                 properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("lineNumber", this.eventListener.location.lineNumber));
    210             }
     207            if (this.eventListener.sourceName)
     208                properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("sourceName", this.eventListener.sourceName));
     209            if (this.eventListener.location)
     210                properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("lineNumber", this.eventListener.location.lineNumber + 1));
    211211
    212212            this.updateProperties(properties);
     
    240240        if (this.eventListener.location) {
    241241            this.subtitleElement.removeChildren();
    242             // FIXME(62725): eventListener.location should be a debugger Location.
    243             var url = this.eventListener.location.scriptId;
    244             var lineNumber = this.eventListener.location.lineNumber - 1;
    245             var columnNumber = 0;
    246             var urlElement = linkifier.linkifyLocation(url, lineNumber, columnNumber);
     242            var urlElement;
     243            if (this.eventListener.location.scriptId)
     244                urlElement = linkifier.linkifyRawLocation(this.eventListener.location);
     245            if (!urlElement) {
     246                var url = this.eventListener.sourceName;
     247                var lineNumber = this.eventListener.location.lineNumber;
     248                var columnNumber = 0;
     249                urlElement = linkifier.linkifyLocation(url, lineNumber, columnNumber);
     250            }
    247251            this.subtitleElement.appendChild(urlElement);
    248252        } else {
  • trunk/Source/WebCore/inspector/front-end/Linkifier.js

    r126572 r129105  
    122122    formatLiveAnchor: function(anchor, uiLocation)
    123123    {
    124         anchor.textContent = WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber);
    125 
    126124        var text = WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber);
    127125        if (this._maxLength)
  • trunk/Source/WebCore/inspector/front-end/ResourceUtils.js

    r126579 r129105  
    193193WebInspector.formatLinkText = function(url, lineNumber)
    194194{
    195     var text = WebInspector.displayNameForURL(url);
     195    var text = url ? WebInspector.displayNameForURL(url) : WebInspector.UIString("(program)");
    196196    if (typeof lineNumber === "number")
    197197        text += ":" + (lineNumber + 1);
Note: See TracChangeset for help on using the changeset viewer.