WebKit/gtk/webkit/webkitwebinspector.cpp
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2  * Copyright (C) 2008 Gustavo Noronha Silva
       
     3  * Copyright (C) 2008, 2009 Holger Hans Peter Freyther
       
     4  * Copyright (C) 2009 Collabora Ltd.
       
     5  *
       
     6  * This library is free software; you can redistribute it and/or
       
     7  * modify it under the terms of the GNU Library General Public
       
     8  * License as published by the Free Software Foundation; either
       
     9  * version 2 of the License, or (at your option) any later version.
       
    10  *
       
    11  * This library is distributed in the hope that it will be useful,
       
    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    14  * Library General Public License for more details.
       
    15  *
       
    16  * You should have received a copy of the GNU Library General Public License
       
    17  * along with this library; see the file COPYING.LIB.  If not, write to
       
    18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    19  * Boston, MA 02110-1301, USA.
       
    20  */
       
    21 
       
    22 #include "config.h"
       
    23 #include "webkitwebinspector.h"
       
    24 
       
    25 #include "FocusController.h"
       
    26 #include "Frame.h"
       
    27 #include <glib/gi18n-lib.h>
       
    28 #include "HitTestRequest.h"
       
    29 #include "HitTestResult.h"
       
    30 #include "InspectorClientGtk.h"
       
    31 #include "IntPoint.h"
       
    32 #include "Page.h"
       
    33 #include "RenderLayer.h"
       
    34 #include "RenderView.h"
       
    35 #include "webkitmarshal.h"
       
    36 #include "webkitprivate.h"
       
    37 
       
    38 /**
       
    39  * SECTION:webkitwebinspector
       
    40  * @short_description: Access to the WebKit Inspector
       
    41  *
       
    42  * The WebKit Inspector is a graphical tool to inspect and change
       
    43  * the content of a #WebKitWebView. It also includes an interactive
       
    44  * JavaScriptDebugger. Using this class one can get a GtkWidget which
       
    45  * can be embedded into an application to show the inspector.
       
    46  *
       
    47  * The inspector is available when the #WebKitWebSettings of the
       
    48  * #WebKitWebView has set the #WebKitWebSettings:enable-developer-extras
       
    49  * to true otherwise no inspector is available.
       
    50  *
       
    51  * <informalexample><programlisting>
       
    52  * /<!-- -->* Enable the developer extras *<!-- -->/
       
    53  * WebKitWebSettings *setting = webkit_web_view_get_settings (WEBKIT_WEB_VIEW(my_webview));
       
    54  * g_object_set (G_OBJECT(settings), "enable-developer-extras", TRUE, NULL);
       
    55  *
       
    56  * /<!-- -->* load some data or reload to be able to inspect the page*<!-- -->/
       
    57  * webkit_web_view_open (WEBKIT_WEB_VIEW(my_webview), "http://www.gnome.org");
       
    58  *
       
    59  * /<!-- -->* Embed the inspector somewhere *<!-- -->/
       
    60  * WebKitWebInspector *inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW(my_webview));
       
    61  * g_signal_connect (G_OBJECT (inspector), "inspect-web-view", G_CALLBACK(create_gtk_window_around_it), NULL);
       
    62  * g_signal_connect (G_OBJECT (inspector), "show-window", G_CALLBACK(show_inpector_window), NULL));
       
    63  * g_signal_connect (G_OBJECT (inspector), "notify::inspected-uri", G_CALLBACK(inspected_uri_changed_do_stuff), NULL);
       
    64  * </programlisting></informalexample>
       
    65  */
       
    66 
       
    67 using namespace WebKit;
       
    68 using namespace WebCore;
       
    69 
       
    70 enum {
       
    71     INSPECT_WEB_VIEW,
       
    72     SHOW_WINDOW,
       
    73     ATTACH_WINDOW,
       
    74     DETACH_WINDOW,
       
    75     CLOSE_WINDOW,
       
    76     FINISHED,
       
    77     LAST_SIGNAL
       
    78 };
       
    79 
       
    80 static guint webkit_web_inspector_signals[LAST_SIGNAL] = { 0, };
       
    81 
       
    82 enum {
       
    83     PROP_0,
       
    84 
       
    85     PROP_WEB_VIEW,
       
    86     PROP_INSPECTED_URI,
       
    87     PROP_JAVASCRIPT_PROFILING_ENABLED,
       
    88     PROP_TIMELINE_PROFILING_ENABLED    
       
    89 };
       
    90 
       
    91 G_DEFINE_TYPE(WebKitWebInspector, webkit_web_inspector, G_TYPE_OBJECT)
       
    92 
       
    93 struct _WebKitWebInspectorPrivate {
       
    94     WebCore::Page* page;
       
    95     WebKitWebView* inspector_view;
       
    96     gchar* inspected_uri;
       
    97 };
       
    98 
       
    99 #define WEBKIT_WEB_INSPECTOR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_INSPECTOR, WebKitWebInspectorPrivate))
       
   100 
       
   101 static void webkit_web_inspector_finalize(GObject* object);
       
   102 
       
   103 static void webkit_web_inspector_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec);
       
   104 
       
   105 static void webkit_web_inspector_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec);
       
   106 
       
   107 static gboolean webkit_inspect_web_view_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)
       
   108 {
       
   109     gboolean continueEmission = TRUE;
       
   110     gpointer newWebView = g_value_get_object(handlerReturn);
       
   111     g_value_set_object(returnAccu, newWebView);
       
   112 
       
   113     if (newWebView)
       
   114         continueEmission = FALSE;
       
   115 
       
   116     return continueEmission;
       
   117 }
       
   118 
       
   119 static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass)
       
   120 {
       
   121     GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
       
   122     gobject_class->finalize = webkit_web_inspector_finalize;
       
   123     gobject_class->set_property = webkit_web_inspector_set_property;
       
   124     gobject_class->get_property = webkit_web_inspector_get_property;
       
   125 
       
   126     /**
       
   127      * WebKitWebInspector::inspect-web-view:
       
   128      * @web_inspector: the object on which the signal is emitted
       
   129      * @web_view: the #WebKitWebView which will be inspected
       
   130      * @return: a newly allocated #WebKitWebView or %NULL
       
   131      *
       
   132      * Emitted when the user activates the 'inspect' context menu item
       
   133      * to inspect a web view. The application which is interested in
       
   134      * the inspector should create a window, or otherwise add the
       
   135      * #WebKitWebView it creates to an existing window.
       
   136      *
       
   137      * You don't need to handle the reference count of the
       
   138      * #WebKitWebView instance you create; the widget to which you add
       
   139      * it will do that.
       
   140      *
       
   141      * Since: 1.0.3
       
   142      */
       
   143     webkit_web_inspector_signals[INSPECT_WEB_VIEW] = g_signal_new("inspect-web-view",
       
   144             G_TYPE_FROM_CLASS(klass),
       
   145             (GSignalFlags)G_SIGNAL_RUN_LAST,
       
   146             0,
       
   147             webkit_inspect_web_view_request_handled,
       
   148             NULL,
       
   149             webkit_marshal_OBJECT__OBJECT,
       
   150             WEBKIT_TYPE_WEB_VIEW , 1,
       
   151             WEBKIT_TYPE_WEB_VIEW);
       
   152 
       
   153     /**
       
   154      * WebKitWebInspector::show-window:
       
   155      * @web_inspector: the object on which the signal is emitted
       
   156      * @return: %TRUE if the signal has been handled
       
   157      *
       
   158      * Emitted when the inspector window should be displayed. Notice
       
   159      * that the window must have been created already by handling
       
   160      * #WebKitWebInspector::inspect-web-view.
       
   161      *
       
   162      * Since: 1.0.3
       
   163      */
       
   164     webkit_web_inspector_signals[SHOW_WINDOW] = g_signal_new("show-window",
       
   165             G_TYPE_FROM_CLASS(klass),
       
   166             (GSignalFlags)G_SIGNAL_RUN_LAST,
       
   167             0,
       
   168             g_signal_accumulator_true_handled,
       
   169             NULL,
       
   170             webkit_marshal_BOOLEAN__VOID,
       
   171             G_TYPE_BOOLEAN , 0);
       
   172 
       
   173     /**
       
   174      * WebKitWebInspector::attach-window:
       
   175      * @web_inspector: the object on which the signal is emitted
       
   176      * @return: %TRUE if the signal has been handled
       
   177      *
       
   178      * Emitted when the inspector should appear at the same window as
       
   179      * the #WebKitWebView being inspected.
       
   180      *
       
   181      * Since: 1.0.3
       
   182      */
       
   183     webkit_web_inspector_signals[ATTACH_WINDOW] = g_signal_new("attach-window",
       
   184             G_TYPE_FROM_CLASS(klass),
       
   185             (GSignalFlags)G_SIGNAL_RUN_LAST,
       
   186             0,
       
   187             g_signal_accumulator_true_handled,
       
   188             NULL,
       
   189             webkit_marshal_BOOLEAN__VOID,
       
   190             G_TYPE_BOOLEAN , 0);
       
   191 
       
   192     /**
       
   193      * WebKitWebInspector::detach-window:
       
   194      * @web_inspector: the object on which the signal is emitted
       
   195      * @return: %TRUE if the signal has been handled
       
   196      *
       
   197      * Emitted when the inspector should appear in a separate window.
       
   198      *
       
   199      * Since: 1.0.3
       
   200      */
       
   201     webkit_web_inspector_signals[DETACH_WINDOW] = g_signal_new("detach-window",
       
   202             G_TYPE_FROM_CLASS(klass),
       
   203             (GSignalFlags)G_SIGNAL_RUN_LAST,
       
   204             0,
       
   205             g_signal_accumulator_true_handled,
       
   206             NULL,
       
   207             webkit_marshal_BOOLEAN__VOID,
       
   208             G_TYPE_BOOLEAN , 0);
       
   209 
       
   210     /**
       
   211      * WebKitWebInspector::close-window:
       
   212      * @web_inspector: the object on which the signal is emitted
       
   213      * @return: %TRUE if the signal has been handled
       
   214      *
       
   215      * Emitted when the inspector window should be closed. You can
       
   216      * destroy the window or hide it so that it can be displayed again
       
   217      * by handling #WebKitWebInspector::show-window later on.
       
   218      *
       
   219      * Notice that the inspected #WebKitWebView may no longer exist
       
   220      * when this signal is emitted.
       
   221      *
       
   222      * Notice, too, that if you decide to destroy the window,
       
   223      * #WebKitWebInspector::inspect-web-view will be emmited again, when the user
       
   224      * inspects an element.
       
   225      *
       
   226      * Since: 1.0.3
       
   227      */
       
   228     webkit_web_inspector_signals[CLOSE_WINDOW] = g_signal_new("close-window",
       
   229             G_TYPE_FROM_CLASS(klass),
       
   230             (GSignalFlags)G_SIGNAL_RUN_LAST,
       
   231             0,
       
   232             g_signal_accumulator_true_handled,
       
   233             NULL,
       
   234             webkit_marshal_BOOLEAN__VOID,
       
   235             G_TYPE_BOOLEAN , 0);
       
   236 
       
   237     /**
       
   238      * WebKitWebInspector::finished:
       
   239      * @web_inspector: the object on which the signal is emitted
       
   240      *
       
   241      * Emitted when the inspection is done. You should release your
       
   242      * references on the inspector at this time. The inspected
       
   243      * #WebKitWebView may no longer exist when this signal is emitted.
       
   244      *
       
   245      * Since: 1.0.3
       
   246      */
       
   247     webkit_web_inspector_signals[FINISHED] = g_signal_new("finished",
       
   248             G_TYPE_FROM_CLASS(klass),
       
   249             (GSignalFlags)G_SIGNAL_RUN_LAST,
       
   250             0,
       
   251             NULL,
       
   252             NULL,
       
   253             g_cclosure_marshal_VOID__VOID,
       
   254             G_TYPE_NONE , 0);
       
   255 
       
   256     /*
       
   257      * properties
       
   258      */
       
   259 
       
   260     /**
       
   261      * WebKitWebInspector:web-view:
       
   262      *
       
   263      * The Web View that renders the Web Inspector itself.
       
   264      *
       
   265      * Since: 1.0.3
       
   266      */
       
   267     g_object_class_install_property(gobject_class, PROP_WEB_VIEW,
       
   268                                     g_param_spec_object("web-view",
       
   269                                                         _("Web View"),
       
   270                                                         _("The Web View that renders the Web Inspector itself"),
       
   271                                                         WEBKIT_TYPE_WEB_VIEW,
       
   272                                                         WEBKIT_PARAM_READABLE));
       
   273 
       
   274     /**
       
   275      * WebKitWebInspector:inspected-uri:
       
   276      *
       
   277      * The URI that is currently being inspected.
       
   278      *
       
   279      * Since: 1.0.3
       
   280      */
       
   281     g_object_class_install_property(gobject_class, PROP_INSPECTED_URI,
       
   282                                     g_param_spec_string("inspected-uri",
       
   283                                                         _("Inspected URI"),
       
   284                                                         _("The URI that is currently being inspected"),
       
   285                                                         NULL,
       
   286                                                         WEBKIT_PARAM_READABLE));
       
   287 
       
   288     /**
       
   289     * WebKitWebInspector:javascript-profiling-enabled
       
   290     *
       
   291     * This is enabling JavaScript profiling in the Inspector. This means
       
   292     * that Console.profiles will return the profiles.
       
   293     *
       
   294     * Since: 1.1.1
       
   295     */
       
   296     g_object_class_install_property(gobject_class,
       
   297                                     PROP_JAVASCRIPT_PROFILING_ENABLED,
       
   298                                     g_param_spec_boolean(
       
   299                                         "javascript-profiling-enabled",
       
   300                                         _("Enable JavaScript profiling"),
       
   301                                         _("Profile the executed JavaScript."),
       
   302                                         FALSE,
       
   303                                         WEBKIT_PARAM_READWRITE));
       
   304 
       
   305     /**
       
   306     * WebKitWebInspector:timeline-profiling-enabled
       
   307     *
       
   308     * This is enabling Timeline profiling in the Inspector.
       
   309     *
       
   310     * Since: 1.1.17
       
   311     */
       
   312     g_object_class_install_property(gobject_class,
       
   313                                     PROP_TIMELINE_PROFILING_ENABLED,
       
   314                                     g_param_spec_boolean(
       
   315                                         "timeline-profiling-enabled",
       
   316                                         _("Enable Timeline profiling"),
       
   317                                         _("Profile the WebCore instrumentation."),
       
   318                                         FALSE,
       
   319                                         WEBKIT_PARAM_READWRITE));
       
   320 
       
   321     g_type_class_add_private(klass, sizeof(WebKitWebInspectorPrivate));
       
   322 }
       
   323 
       
   324 static void webkit_web_inspector_init(WebKitWebInspector* web_inspector)
       
   325 {
       
   326     web_inspector->priv = WEBKIT_WEB_INSPECTOR_GET_PRIVATE(web_inspector);
       
   327 }
       
   328 
       
   329 static void webkit_web_inspector_finalize(GObject* object)
       
   330 {
       
   331     WebKitWebInspector* web_inspector = WEBKIT_WEB_INSPECTOR(object);
       
   332     WebKitWebInspectorPrivate* priv = web_inspector->priv;
       
   333 
       
   334     if (priv->inspector_view)
       
   335         g_object_unref(priv->inspector_view);
       
   336 
       
   337     if (priv->inspected_uri)
       
   338         g_free(priv->inspected_uri);
       
   339 
       
   340     G_OBJECT_CLASS(webkit_web_inspector_parent_class)->finalize(object);
       
   341 }
       
   342 
       
   343 static void webkit_web_inspector_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
       
   344 {
       
   345     WebKitWebInspector* web_inspector = WEBKIT_WEB_INSPECTOR(object);
       
   346     WebKitWebInspectorPrivate* priv = web_inspector->priv;
       
   347 
       
   348     switch(prop_id) {
       
   349     case PROP_JAVASCRIPT_PROFILING_ENABLED: {
       
   350 #if ENABLE(JAVASCRIPT_DEBUGGER)
       
   351         bool enabled = g_value_get_boolean(value);
       
   352         WebCore::InspectorController* controller = priv->page->inspectorController();
       
   353         if (enabled)
       
   354             controller->enableProfiler();
       
   355         else
       
   356             controller->disableProfiler();
       
   357 #else
       
   358         g_message("PROP_JAVASCRIPT_PROFILING_ENABLED is not work because of the javascript debugger is disabled\n");
       
   359 #endif
       
   360         break;
       
   361     }
       
   362     case PROP_TIMELINE_PROFILING_ENABLED: {
       
   363         bool enabled = g_value_get_boolean(value);
       
   364         WebCore::InspectorController* controller = priv->page->inspectorController();
       
   365         if (enabled)
       
   366             controller->startTimelineProfiler();
       
   367         else
       
   368             controller->stopTimelineProfiler();
       
   369         break;
       
   370     }
       
   371     default:
       
   372         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
       
   373         break;
       
   374     }
       
   375 }
       
   376 
       
   377 static void webkit_web_inspector_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
       
   378 {
       
   379     WebKitWebInspector* web_inspector = WEBKIT_WEB_INSPECTOR(object);
       
   380     WebKitWebInspectorPrivate* priv = web_inspector->priv;
       
   381 
       
   382     switch (prop_id) {
       
   383     case PROP_WEB_VIEW:
       
   384         g_value_set_object(value, priv->inspector_view);
       
   385         break;
       
   386     case PROP_INSPECTED_URI:
       
   387         g_value_set_string(value, priv->inspected_uri);
       
   388         break;
       
   389     case PROP_JAVASCRIPT_PROFILING_ENABLED:
       
   390 #if ENABLE(JAVASCRIPT_DEBUGGER)
       
   391         g_value_set_boolean(value, priv->page->inspectorController()->profilerEnabled());
       
   392 #else
       
   393         g_message("PROP_JAVASCRIPT_PROFILING_ENABLED is not work because of the javascript debugger is disabled\n");
       
   394 #endif
       
   395         break;
       
   396     case PROP_TIMELINE_PROFILING_ENABLED:
       
   397         g_value_set_boolean(value, priv->page->inspectorController()->timelineAgent() != 0);
       
   398         break;
       
   399     default:
       
   400         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
       
   401         break;
       
   402     }
       
   403 }
       
   404 
       
   405 // internal use only
       
   406 void webkit_web_inspector_set_web_view(WebKitWebInspector *web_inspector, WebKitWebView *web_view)
       
   407 {
       
   408     g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(web_inspector));
       
   409     g_return_if_fail(WEBKIT_IS_WEB_VIEW(web_view));
       
   410 
       
   411     WebKitWebInspectorPrivate* priv = web_inspector->priv;
       
   412 
       
   413     if (priv->inspector_view)
       
   414         g_object_unref(priv->inspector_view);
       
   415 
       
   416     g_object_ref(web_view);
       
   417     priv->inspector_view = web_view;
       
   418 }
       
   419 
       
   420 /**
       
   421  * webkit_web_inspector_get_web_view:
       
   422  *
       
   423  * Obtains the #WebKitWebView that is used to render the
       
   424  * inspector. The #WebKitWebView instance is created by the
       
   425  * application, by handling the #WebKitWebInspector::inspect-web-view signal. This means
       
   426  * that this method may return %NULL if the user hasn't inspected
       
   427  * anything.
       
   428  *
       
   429  * Returns: the #WebKitWebView instance that is used to render the
       
   430  * inspector or %NULL if it is not yet created.
       
   431  *
       
   432  * Since: 1.0.3
       
   433  **/
       
   434 WebKitWebView* webkit_web_inspector_get_web_view(WebKitWebInspector *web_inspector)
       
   435 {
       
   436     WebKitWebInspectorPrivate* priv = web_inspector->priv;
       
   437 
       
   438     return priv->inspector_view;
       
   439 }
       
   440 
       
   441 // internal use only
       
   442 void webkit_web_inspector_set_inspected_uri(WebKitWebInspector* web_inspector, const gchar* inspected_uri)
       
   443 {
       
   444     g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(web_inspector));
       
   445 
       
   446     WebKitWebInspectorPrivate* priv = web_inspector->priv;
       
   447 
       
   448     g_free(priv->inspected_uri);
       
   449     priv->inspected_uri = g_strdup(inspected_uri);
       
   450 }
       
   451 
       
   452 /**
       
   453  * webkit_web_inspector_get_inspected_uri:
       
   454  *
       
   455  * Obtains the URI that is currently being inspected.
       
   456  *
       
   457  * Returns: a pointer to the URI as an internally allocated string; it
       
   458  * should not be freed, modified or stored.
       
   459  *
       
   460  * Since: 1.0.3
       
   461  **/
       
   462 const gchar* webkit_web_inspector_get_inspected_uri(WebKitWebInspector *web_inspector)
       
   463 {
       
   464     WebKitWebInspectorPrivate* priv = web_inspector->priv;
       
   465 
       
   466     return priv->inspected_uri;
       
   467 }
       
   468 
       
   469 void
       
   470 webkit_web_inspector_set_inspector_client(WebKitWebInspector* web_inspector, WebCore::Page* page)
       
   471 {
       
   472     WebKitWebInspectorPrivate* priv = web_inspector->priv;
       
   473 
       
   474     priv->page = page;
       
   475 }
       
   476 
       
   477 /**
       
   478  * webkit_web_inspector_show:
       
   479  * @web_inspector: the #WebKitWebInspector that will be shown
       
   480  *
       
   481  * Causes the Web Inspector to be shown.
       
   482  *
       
   483  * Since: 1.1.17
       
   484  */
       
   485 void webkit_web_inspector_show(WebKitWebInspector* webInspector)
       
   486 {
       
   487     g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(webInspector));
       
   488 
       
   489     WebKitWebInspectorPrivate* priv = webInspector->priv;
       
   490 
       
   491     Frame* frame = priv->page->focusController()->focusedOrMainFrame();
       
   492     FrameView* view = frame->view();
       
   493 
       
   494     if (!view)
       
   495         return;
       
   496 
       
   497     priv->page->inspectorController()->show();
       
   498 }
       
   499 
       
   500 /**
       
   501  * webkit_web_inspector_inspect_coordinates:
       
   502  * @web_inspector: the #WebKitWebInspector that will do the inspection
       
   503  * @x: the X coordinate of the node to be inspected
       
   504  * @y: the Y coordinate of the node to be inspected
       
   505  *
       
   506  * Causes the Web Inspector to inspect the node that is located at the
       
   507  * given coordinates of the widget. The coordinates should be relative
       
   508  * to the #WebKitWebView widget, not to the scrollable content, and
       
   509  * may be obtained from a #GdkEvent directly.
       
   510  *
       
   511  * This means @x, and @y being zero doesn't guarantee you will hit the
       
   512  * left-most top corner of the content, since the contents may have
       
   513  * been scrolled.
       
   514  *
       
   515  * Since: 1.1.17
       
   516  */
       
   517 void webkit_web_inspector_inspect_coordinates(WebKitWebInspector* webInspector, gdouble x, gdouble y)
       
   518 {
       
   519     g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(webInspector));
       
   520     g_return_if_fail(x >= 0 && y >= 0);
       
   521 
       
   522     WebKitWebInspectorPrivate* priv = webInspector->priv;
       
   523 
       
   524     Frame* frame = priv->page->focusController()->focusedOrMainFrame();
       
   525     FrameView* view = frame->view();
       
   526 
       
   527     if (!view)
       
   528         return;
       
   529 
       
   530     HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
       
   531     IntPoint documentPoint = view->windowToContents(IntPoint(static_cast<int>(x), static_cast<int>(y)));
       
   532     HitTestResult result(documentPoint);
       
   533 
       
   534     frame->contentRenderer()->layer()->hitTest(request, result);
       
   535     priv->page->inspectorController()->inspect(result.innerNonSharedNode());
       
   536 }
       
   537 
       
   538 /**
       
   539  * webkit_web_inspector_close:
       
   540  * @web_inspector: the #WebKitWebInspector that will be closed
       
   541  *
       
   542  * Causes the Web Inspector to be closed.
       
   543  *
       
   544  * Since: 1.1.17
       
   545  */
       
   546 void webkit_web_inspector_close(WebKitWebInspector* webInspector)
       
   547 {
       
   548     g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(webInspector));
       
   549 
       
   550     WebKitWebInspectorPrivate* priv = webInspector->priv;
       
   551     priv->page->inspectorController()->close();
       
   552 }
       
   553 
       
   554 void webkit_web_inspector_execute_script(WebKitWebInspector* webInspector, long callId, const gchar* script)
       
   555 {
       
   556     g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(webInspector));
       
   557     g_return_if_fail(script);
       
   558 
       
   559     WebKitWebInspectorPrivate* priv = webInspector->priv;
       
   560     priv->page->inspectorController()->evaluateForTestInFrontend(callId, script);
       
   561 }