Title: [109002] trunk/Source
Revision
109002
Author
timo...@apple.com
Date
2012-02-27 09:51:06 -0800 (Mon, 27 Feb 2012)

Log Message

Add WKInspector API to know when the Web Inspector is the frontmost window.

https://webkit.org/b/79649

Reviewed by John Sullivan.

Source/WebCore: Updated for WebKit2 string changes.

* English.lproj/Localizable.strings: Updated.

Source/WebKit2: Also makes the Safari Develop menu items work when the Web Inspector is frontmost.

* UIProcess/API/C/WKInspector.cpp:
(WKInspectorIsFront): Added. Call WebInspectorProxy::isFront.
* UIProcess/API/C/WKInspector.h:
* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::isFront): Added. Call platformIsFront.
* UIProcess/WebInspectorProxy.h:
* UIProcess/efl/WebInspectorEfl.cpp:
(WebKit::WebInspectorProxy::platformIsFront): Added stub.
* UIProcess/gtk/WebInspectorGtk.cpp:
(WebKit::WebInspectorProxy::platformIsFront): Added stub.
* UIProcess/mac/WebInspectorProxyMac.mm:
(-[WKWebInspectorProxyObjCAdapter showWebInspector:]): Added. Makes the Develop menu items in Safari work when
the Web Inspector window is front.
(-[WKWebInspectorProxyObjCAdapter showErrorConsole:]): Added. Ditto.
(-[WKWebInspectorProxyObjCAdapter showResources:]): Added. Ditto.
(-[WKWebInspectorProxyObjCAdapter viewSource:]): Added. Ditto.
(-[WKWebInspectorProxyObjCAdapter toggleDebuggingJavaScript:]): Added. Ditto.
(-[WKWebInspectorProxyObjCAdapter toggleProfilingJavaScript:]): Added. Ditto.
(-[WKWebInspectorProxyObjCAdapter validateUserInterfaceItem:]): Added. Update the menu item titles.
(WebKit::WebInspectorProxy::platformIsFront): Added. Return if visible and the window is main.
* UIProcess/qt/WebInspectorProxyQt.cpp:
(WebKit::WebInspectorProxy::platformIsFront): Added stub.
* UIProcess/win/WebInspectorProxyWin.cpp:
(WebKit::WebInspectorProxy::platformIsFront): Added stub.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (109001 => 109002)


--- trunk/Source/WebCore/ChangeLog	2012-02-27 17:42:51 UTC (rev 109001)
+++ trunk/Source/WebCore/ChangeLog	2012-02-27 17:51:06 UTC (rev 109002)
@@ -1,3 +1,13 @@
+2012-02-27  Timothy Hatcher  <timo...@apple.com>
+
+        Updated for WebKit2 string changes.
+
+        https://webkit.org/b/79649
+
+        Reviewed by John Sullivan.
+
+        * English.lproj/Localizable.strings: Updated.
+
 2012-02-27  Pavel Feldman  <pfeld...@google.com>
 
         Web Inspector: Ctrl+K should not zoom in

Modified: trunk/Source/WebCore/English.lproj/Localizable.strings (109001 => 109002)


--- trunk/Source/WebCore/English.lproj/Localizable.strings	2012-02-27 17:42:51 UTC (rev 109001)
+++ trunk/Source/WebCore/English.lproj/Localizable.strings	2012-02-27 17:51:06 UTC (rev 109002)
@@ -100,9 +100,6 @@
 /* Copy Image context menu item */
 "Copy Image" = "Copy Image";
 
-/* Copy Image Address menu item */
-"Copy Image Address" = "Copy Image Address";
-
 /* Copy Link context menu item */
 "Copy Link" = "Copy Link";
 
@@ -163,6 +160,9 @@
 /* menu item title */
 "Hide Substitutions" = "Hide Substitutions";
 
+/* title for Hide Web Inspector menu item */
+"Hide Web Inspector" = "Hide Web Inspector";
+
 /* The default, default character encoding */
 "ISO-8859-1" = "ISO-8859-1";
 

Modified: trunk/Source/WebKit2/ChangeLog (109001 => 109002)


--- trunk/Source/WebKit2/ChangeLog	2012-02-27 17:42:51 UTC (rev 109001)
+++ trunk/Source/WebKit2/ChangeLog	2012-02-27 17:51:06 UTC (rev 109002)
@@ -1,3 +1,38 @@
+2012-02-27  Timothy Hatcher  <timo...@apple.com>
+
+        Add WKInspector API to know when the Web Inspector is the frontmost window.
+
+        Also makes the Safari Develop menu items work when the Web Inspector is frontmost.
+
+        https://webkit.org/b/79649
+
+        Reviewed by John Sullivan.
+
+        * UIProcess/API/C/WKInspector.cpp:
+        (WKInspectorIsFront): Added. Call WebInspectorProxy::isFront.
+        * UIProcess/API/C/WKInspector.h:
+        * UIProcess/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorProxy::isFront): Added. Call platformIsFront.
+        * UIProcess/WebInspectorProxy.h:
+        * UIProcess/efl/WebInspectorEfl.cpp:
+        (WebKit::WebInspectorProxy::platformIsFront): Added stub.
+        * UIProcess/gtk/WebInspectorGtk.cpp:
+        (WebKit::WebInspectorProxy::platformIsFront): Added stub.
+        * UIProcess/mac/WebInspectorProxyMac.mm:
+        (-[WKWebInspectorProxyObjCAdapter showWebInspector:]): Added. Makes the Develop menu items in Safari work when
+        the Web Inspector window is front.
+        (-[WKWebInspectorProxyObjCAdapter showErrorConsole:]): Added. Ditto.
+        (-[WKWebInspectorProxyObjCAdapter showResources:]): Added. Ditto.
+        (-[WKWebInspectorProxyObjCAdapter viewSource:]): Added. Ditto.
+        (-[WKWebInspectorProxyObjCAdapter toggleDebuggingJavaScript:]): Added. Ditto.
+        (-[WKWebInspectorProxyObjCAdapter toggleProfilingJavaScript:]): Added. Ditto.
+        (-[WKWebInspectorProxyObjCAdapter validateUserInterfaceItem:]): Added. Update the menu item titles.
+        (WebKit::WebInspectorProxy::platformIsFront): Added. Return if visible and the window is main.
+        * UIProcess/qt/WebInspectorProxyQt.cpp:
+        (WebKit::WebInspectorProxy::platformIsFront): Added stub.
+        * UIProcess/win/WebInspectorProxyWin.cpp:
+        (WebKit::WebInspectorProxy::platformIsFront): Added stub.
+
 2012-02-26  YoungTaeck Song  <youngtaeck.s...@samsung.com>
 
         [EFL][WK2] Add InjectedBundleEfl.cpp

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKInspector.cpp (109001 => 109002)


--- trunk/Source/WebKit2/UIProcess/API/C/WKInspector.cpp	2012-02-27 17:42:51 UTC (rev 109001)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKInspector.cpp	2012-02-27 17:51:06 UTC (rev 109002)
@@ -48,6 +48,11 @@
     return toImpl(inspectorRef)->isVisible();
 }
 
+bool WKInspectorIsFront(WKInspectorRef inspectorRef)
+{
+    return toImpl(inspectorRef)->isFront();
+}
+
 void WKInspectorShow(WKInspectorRef inspectorRef)
 {
     toImpl(inspectorRef)->show();

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKInspector.h (109001 => 109002)


--- trunk/Source/WebKit2/UIProcess/API/C/WKInspector.h	2012-02-27 17:42:51 UTC (rev 109001)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKInspector.h	2012-02-27 17:51:06 UTC (rev 109002)
@@ -43,6 +43,7 @@
 WK_EXPORT WKPageRef WKInspectorGetPage(WKInspectorRef inspector);
 
 WK_EXPORT bool WKInspectorIsVisible(WKInspectorRef inspector);
+WK_EXPORT bool WKInspectorIsFront(WKInspectorRef inspector);
 WK_EXPORT void WKInspectorShow(WKInspectorRef inspector);
 WK_EXPORT void WKInspectorClose(WKInspectorRef inspector);
 

Modified: trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp (109001 => 109002)


--- trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp	2012-02-27 17:42:51 UTC (rev 109001)
+++ trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp	2012-02-27 17:51:06 UTC (rev 109002)
@@ -100,6 +100,14 @@
 }
 
 // Public APIs
+bool WebInspectorProxy::isFront()
+{
+    if (!m_page)
+        return false;
+
+    return platformIsFront();
+}
+
 void WebInspectorProxy::show()
 {
     if (!m_page)

Modified: trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h (109001 => 109002)


--- trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h	2012-02-27 17:42:51 UTC (rev 109001)
+++ trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h	2012-02-27 17:51:06 UTC (rev 109002)
@@ -80,6 +80,8 @@
     WebPageProxy* page() const { return m_page; }
 
     bool isVisible() const { return m_isVisible; }
+    bool isFront();
+
     void show();
     void close();
     
@@ -126,6 +128,7 @@
     void platformOpen();
     void platformDidClose();
     void platformBringToFront();
+    bool platformIsFront();
     void platformInspectedURLChanged(const String&);
     unsigned platformInspectedWindowHeight();
     void platformAttach();

Modified: trunk/Source/WebKit2/UIProcess/efl/WebInspectorEfl.cpp (109001 => 109002)


--- trunk/Source/WebKit2/UIProcess/efl/WebInspectorEfl.cpp	2012-02-27 17:42:51 UTC (rev 109001)
+++ trunk/Source/WebKit2/UIProcess/efl/WebInspectorEfl.cpp	2012-02-27 17:51:06 UTC (rev 109002)
@@ -54,6 +54,12 @@
     notImplemented();
 }
 
+bool WebInspectorProxy::platformIsFront()
+{
+    notImplemented();
+    return false;
+}
+
 void WebInspectorProxy::platformInspectedURLChanged(const String&)
 {
     notImplemented();

Modified: trunk/Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp (109001 => 109002)


--- trunk/Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp	2012-02-27 17:42:51 UTC (rev 109001)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp	2012-02-27 17:51:06 UTC (rev 109002)
@@ -110,6 +110,12 @@
     notImplemented();
 }
 
+bool WebInspectorProxy::platformIsFront()
+{
+    notImplemented();
+    return false;
+}
+
 void WebInspectorProxy::platformInspectedURLChanged(const String& url)
 {
     GOwnPtr<gchar> title(g_strdup_printf("%s - %s", _("Web Inspector"), url.utf8().data()));

Modified: trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm (109001 => 109002)


--- trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm	2012-02-27 17:42:51 UTC (rev 109001)
+++ trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm	2012-02-27 17:51:06 UTC (rev 109002)
@@ -83,6 +83,67 @@
     _inspectorProxy->inspectedViewFrameDidChange();
 }
 
+// These methods can be used by UI elements such as menu items and toolbar buttons when the inspector is the main/key window.
+// These methods are really only implemented to keep  UI elements enabled and working.
+
+- (void)showWebInspector:(id)sender
+{
+    // This method is a toggle, so it will close the Web Inspector if it is already front. Since the window delegate is handling
+    // the action, we know it is already showing, so we only need to support close here. To keep this working with older Safari
+    // builds the method name is still just "showWebInspector:" instead of something like "toggleWebInspector:".
+    ASSERT(_inspectorProxy->isFront());
+    _inspectorProxy->close();
+}
+
+- (void)showErrorConsole:(id)sender
+{
+    _inspectorProxy->showConsole();
+}
+
+- (void)showResources:(id)sender
+{
+    _inspectorProxy->showResources();
+}
+
+- (void)viewSource:(id)sender
+{
+    _inspectorProxy->showMainResourceForFrame(_inspectorProxy->page()->mainFrame());
+}
+
+- (void)toggleDebuggingJavaScript:(id)sender
+{
+    _inspectorProxy->toggleJavaScriptDebugging();
+}
+
+- (void)toggleProfilingJavaScript:(id)sender
+{
+    _inspectorProxy->toggleJavaScriptProfiling();
+}
+
+- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
+{
+    BOOL isMenuItem = [(id)item isKindOfClass:[NSMenuItem class]];
+    NSMenuItem *menuItem = (NSMenuItem *)item;
+    if ([item action] == @selector(showWebInspector:) && isMenuItem) {
+        // This action is a toggle, so it will close the Web Inspector if it is already front. Since the window delegate is handling
+        // the action, we know it is already showing, so we only need to update the title to mention hide.
+        ASSERT(_inspectorProxy->isFront());
+        [menuItem setTitle:WEB_UI_STRING("Hide Web Inspector", "title for Hide Web Inspector menu item")];
+    } else if ([item action] == @selector(toggleDebuggingJavaScript:) && isMenuItem) {
+        if (_inspectorProxy->isDebuggingJavaScript())
+            [menuItem setTitle:WEB_UI_STRING("Stop Debugging _javascript_", "title for Stop Debugging _javascript_ menu item")];
+        else
+            [menuItem setTitle:WEB_UI_STRING("Start Debugging _javascript_", "title for Start Debugging _javascript_ menu item")];
+    } else if ([item action] == @selector(toggleProfilingJavaScript:) && isMenuItem) {
+        if (_inspectorProxy->isProfilingJavaScript())
+            [menuItem setTitle:WEB_UI_STRING("Stop Profiling _javascript_", "title for Stop Profiling _javascript_ menu item")];
+        else
+            [menuItem setTitle:WEB_UI_STRING("Start Profiling _javascript_", "title for Start Profiling _javascript_ menu item")];
+    }
+
+    return YES;
+}
+
 @end
 
 @interface WKWebInspectorWKView : WKView
@@ -191,10 +252,16 @@
 
 void WebInspectorProxy::platformBringToFront()
 {
-    // FIXME: this will not bring a background tab in Safari to the front, only its window.
+    // FIXME <rdar://problem/10937688>: this will not bring a background tab in Safari to the front, only its window.
     [m_inspectorView.get().window makeKeyAndOrderFront:nil];
 }
 
+bool WebInspectorProxy::platformIsFront()
+{
+    // FIXME <rdar://problem/10937688>: this will not return false for a background tab in Safari, only a background window.
+    return m_isVisible && [m_inspectorView.get().window isMainWindow];
+}
+
 void WebInspectorProxy::platformInspectedURLChanged(const String& urlString)
 {
     m_urlString = urlString;

Modified: trunk/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp (109001 => 109002)


--- trunk/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp	2012-02-27 17:42:51 UTC (rev 109001)
+++ trunk/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp	2012-02-27 17:51:06 UTC (rev 109002)
@@ -54,6 +54,12 @@
     notImplemented();
 }
 
+bool WebInspectorProxy::platformIsFront()
+{
+    notImplemented();
+    return false;
+}
+
 void WebInspectorProxy::platformInspectedURLChanged(const String&)
 {
     notImplemented();

Modified: trunk/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp (109001 => 109002)


--- trunk/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp	2012-02-27 17:42:51 UTC (rev 109001)
+++ trunk/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp	2012-02-27 17:51:06 UTC (rev 109002)
@@ -33,6 +33,7 @@
 #include "WebProcessProxy.h"
 #include "WebView.h"
 #include <WebCore/InspectorFrontendClientLocal.h>
+#include <WebCore/NotImplemented.h>
 #include <WebCore/WebCoreInstanceHandle.h>
 #include <WebCore/WindowMessageBroadcaster.h>
 #include <wtf/PassRefPtr.h>
@@ -240,6 +241,12 @@
     ::SetWindowPos(parentWindow, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
 }
 
+bool WebInspectorProxy::platformIsFront()
+{
+    notImplemented();
+    return false;
+}
+
 void WebInspectorProxy::platformInspectedURLChanged(const String& urlString)
 {
     // FIXME: this should be made localizable once WebKit2 supports it. <rdar://problem/8728860>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to