Web Inspector: map Ctrl/Cmd +/- to zoom in hosted mode.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2012 15:28:51 +0000 (15:28 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2012 15:28:51 +0000 (15:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79475

(In remote front-end mode, default zoom actions are working.)

Reviewed by Yury Semikhatsky.

* inspector/InspectorFrontendHost.cpp:
(WebCore::InspectorFrontendHost::setZoomFactor):
(WebCore):
* inspector/InspectorFrontendHost.h:
(InspectorFrontendHost):
* inspector/InspectorFrontendHost.idl:
* inspector/front-end/InspectorFrontendHostStub.js:
(.WebInspector.InspectorFrontendHostStub):
(.WebInspector.InspectorFrontendHostStub.prototype.loadResourceSynchronously):
(.WebInspector.InspectorFrontendHostStub.prototype.setZoomFactor):
* inspector/front-end/Settings.js:
(WebInspector.Settings):
* inspector/front-end/inspector.js:
(WebInspector._initializeCapability):
(WebInspector._zoomIn):
(WebInspector._zoomOut):
(WebInspector._resetZoom):
(WebInspector._requestZoom.set InspectorFrontendHost):
(WebInspector._requestZoom):
(WebInspector._doLoadedDoneWithCapabilities.get if):
(WebInspector.documentKeyDown):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108794 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorFrontendHost.cpp
Source/WebCore/inspector/InspectorFrontendHost.h
Source/WebCore/inspector/InspectorFrontendHost.idl
Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js
Source/WebCore/inspector/front-end/Settings.js
Source/WebCore/inspector/front-end/inspector.js

index 227e624..805461c 100644 (file)
@@ -1,3 +1,34 @@
+2012-02-24  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: map Ctrl/Cmd +/- to zoom in hosted mode.
+        https://bugs.webkit.org/show_bug.cgi?id=79475
+
+        (In remote front-end mode, default zoom actions are working.)
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/InspectorFrontendHost.cpp:
+        (WebCore::InspectorFrontendHost::setZoomFactor):
+        (WebCore):
+        * inspector/InspectorFrontendHost.h:
+        (InspectorFrontendHost):
+        * inspector/InspectorFrontendHost.idl:
+        * inspector/front-end/InspectorFrontendHostStub.js:
+        (.WebInspector.InspectorFrontendHostStub):
+        (.WebInspector.InspectorFrontendHostStub.prototype.loadResourceSynchronously):
+        (.WebInspector.InspectorFrontendHostStub.prototype.setZoomFactor):
+        * inspector/front-end/Settings.js:
+        (WebInspector.Settings):
+        * inspector/front-end/inspector.js:
+        (WebInspector._initializeCapability):
+        (WebInspector._zoomIn):
+        (WebInspector._zoomOut):
+        (WebInspector._resetZoom):
+        (WebInspector._requestZoom.set InspectorFrontendHost):
+        (WebInspector._requestZoom):
+        (WebInspector._doLoadedDoneWithCapabilities.get if):
+        (WebInspector.documentKeyDown):
+
 2012-02-24  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
 
         Refactor EventHandler::handleGestureEvent.
index 01705e8..8872abd 100644 (file)
@@ -181,6 +181,11 @@ void InspectorFrontendHost::bringToFront()
         m_client->bringToFront();
 }
 
+void InspectorFrontendHost::setZoomFactor(float zoom)
+{
+    m_frontendPage->mainFrame()->setPageAndTextZoomFactors(zoom, 1);
+}
+
 void InspectorFrontendHost::inspectedURLChanged(const String& newURL)
 {
     if (m_client)
index 5886885..17d9d32 100644 (file)
@@ -63,6 +63,7 @@ public:
     void requestSetDockSide(const String&);
     void closeWindow();
     void bringToFront();
+    void setZoomFactor(float);
     void inspectedURLChanged(const String&);
 
     void setAttachedWindowHeight(unsigned height);
index 5a05720..1127c3b 100644 (file)
@@ -37,6 +37,7 @@ module core {
         void loaded();
         void closeWindow();
         void bringToFront();
+        void setZoomFactor(in float zoom);
         void inspectedURLChanged(in DOMString newURL);
 
         void requestAttachWindow();
index 6e9b12e..11915d2 100644 (file)
@@ -36,6 +36,7 @@ if (!window.InspectorFrontendHost) {
 WebInspector.InspectorFrontendHostStub = function()
 {
     this._attachedWindowHeight = 0;
+    this.isStub = true;
 }
 
 WebInspector.InspectorFrontendHostStub.prototype = {
@@ -160,6 +161,10 @@ WebInspector.InspectorFrontendHostStub.prototype = {
     loadResourceSynchronously: function(url)
     {
         return "";
+    },
+
+    setZoomFactor: function(zoom)
+    {
     }
 }
 
index fba3c0f..2ba464e 100644 (file)
@@ -90,6 +90,7 @@ WebInspector.Settings = function()
     this.dockToRight = this.createSetting("dockToRight", false);
     this.emulateTouchEvents = this.createSetting("emulateTouchEvents", false);
     this.showPaintRects = this.createSetting("showPaintRects", false);
+    this.zoomLevel = this.createSetting("zoomLevel", 0);
 
     // If there are too many breakpoints in a storage, it is likely due to a recent bug that caused
     // periodical breakpoints duplication leading to inspector slowness.
index 05fa8e2..673ce97 100644 (file)
@@ -306,6 +306,30 @@ var WebInspector = {
         Capabilities[name] = result;
         if (callback)
             callback();
+    },
+
+    _zoomIn: function()
+    {
+        ++this._zoomLevel;
+        this._requestZoom();
+    },
+
+    _zoomOut: function()
+    {
+        --this._zoomLevel;
+        this._requestZoom();
+    },
+
+    _resetZoom: function()
+    {
+        this._zoomLevel = 0;
+        this._requestZoom();
+    },
+
+    _requestZoom: function()
+    {
+        WebInspector.settings.zoomLevel.set(this._zoomLevel);
+        InspectorFrontendHost.setZoomFactor(Math.pow(1.2, this._zoomLevel));
     }
 }
 
@@ -403,6 +427,10 @@ WebInspector._doLoadedDoneWithCapabilities = function()
     if (Capabilities.nativeInstrumentationEnabled)
         this.domBreakpointsSidebarPane = new WebInspector.DOMBreakpointsSidebarPane();
 
+    this._zoomLevel = WebInspector.settings.zoomLevel.get();
+    if (this._zoomLevel)
+        this._requestZoom();
+
     this._createPanels();
     this._createGlobalStatusBarItems();
 
@@ -672,6 +700,7 @@ WebInspector.documentKeyDown = function(event)
     }
 
     var isMac = WebInspector.isMac();
+    var hasCtrlOrMeta = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event);
     switch (event.keyIdentifier) {
         case "U+001B": // Escape key
             if (event.target.hasStyleClass("text-prompt") || !WebInspector.isInEditMode(event)) {
@@ -693,6 +722,24 @@ WebInspector.documentKeyDown = function(event)
                 event.preventDefault();
             }
             break;
+        case "U+004B": // +
+            if (hasCtrlOrMeta && !InspectorFrontendHost.isStub) {
+                WebInspector._zoomIn();
+                event.preventDefault();
+            }
+            break;
+        case "U+004D": // -
+            if (hasCtrlOrMeta && !InspectorFrontendHost.isStub) {
+                WebInspector._zoomOut();
+                event.preventDefault();
+            }
+            break;
+        case "U+0030": // 0
+            if (hasCtrlOrMeta && !InspectorFrontendHost.isStub) {
+                WebInspector._resetZoom();
+                event.preventDefault();
+            }
+            break;
     }
 }