Title: [102656] trunk/Source/WebCore
Revision
102656
Author
[email protected]
Date
2011-12-12 20:07:48 -0800 (Mon, 12 Dec 2011)

Log Message

Implement the _javascript_Core bindings for eventListenerHandlerLocation
https://bugs.webkit.org/show_bug.cgi?id=74313

Patch by Konrad Piascik <[email protected]> on 2011-12-12
Reviewed by Geoffrey Garen.

Open any page in Web Inspector and look at the event listeners. They should now
link to the script which created them.

* bindings/js/ScriptEventListener.cpp:
(WebCore::eventListenerHandlerLocation):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (102655 => 102656)


--- trunk/Source/WebCore/ChangeLog	2011-12-13 03:48:54 UTC (rev 102655)
+++ trunk/Source/WebCore/ChangeLog	2011-12-13 04:07:48 UTC (rev 102656)
@@ -1,3 +1,18 @@
+2011-12-12  Konrad Piascik  <[email protected]>
+
+        2011-12-12  Konrad Piascik  <[email protected]>
+
+        Implement the _javascript_Core bindings for eventListenerHandlerLocation
+        https://bugs.webkit.org/show_bug.cgi?id=74313
+
+        Reviewed by Geoffrey Garen.
+
+        Open any page in Web Inspector and look at the event listeners. They should now
+        link to the script which created them.
+
+        * bindings/js/ScriptEventListener.cpp:
+        (WebCore::eventListenerHandlerLocation):
+
 2011-12-12  Yosifumi Inoue  <[email protected]>
 
         RenderTheme should have a function for disabled text color adjustment

Modified: trunk/Source/WebCore/bindings/js/ScriptEventListener.cpp (102655 => 102656)


--- trunk/Source/WebCore/bindings/js/ScriptEventListener.cpp	2011-12-13 03:48:54 UTC (rev 102655)
+++ trunk/Source/WebCore/bindings/js/ScriptEventListener.cpp	2011-12-13 04:07:48 UTC (rev 102656)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -36,6 +37,8 @@
 #include "EventListener.h"
 #include "JSNode.h"
 #include "Frame.h"
+#include <runtime/Executable.h>
+#include <runtime/JSFunction.h>
 #include <runtime/JSLock.h>
 
 using namespace JSC;
@@ -103,10 +106,23 @@
     return ustringToString(jsFunction->toString(scriptStateFromNode(jsListener->isolatedWorld(), document)));
 }
 
-bool eventListenerHandlerLocation(Document*, EventListener*, String&, int&)
+bool eventListenerHandlerLocation(Document* document, EventListener* eventListener, String& sourceName, int& lineNumber)
 {
-    // FIXME: Add support for getting function location.
-    return false;
+    const JSEventListener* jsListener = JSEventListener::cast(eventListener);
+    if (!jsListener)
+        return false;
+    JSC::JSObject* jsObject = jsListener->jsFunction(document);
+    if (!jsObject)
+        return false;
+    JSC::JSFunction* jsFunction = static_cast<JSFunction*>(jsObject);
+    if (!jsFunction || jsFunction->isHostFunction())
+        return false;
+    JSC::FunctionExecutable* funcExecutable = jsFunction->jsExecutable();
+    if (!funcExecutable)
+        return false;
+    lineNumber = funcExecutable->lineNo();
+    sourceName = ustringToString(funcExecutable->sourceURL());
+    return true;
 }
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to