Title: [108794] trunk/Source/WebCore
Revision
108794
Author
[email protected]
Date
2012-02-24 07:28:51 -0800 (Fri, 24 Feb 2012)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (108793 => 108794)


--- trunk/Source/WebCore/ChangeLog	2012-02-24 15:03:23 UTC (rev 108793)
+++ trunk/Source/WebCore/ChangeLog	2012-02-24 15:28:51 UTC (rev 108794)
@@ -1,3 +1,34 @@
+2012-02-24  Pavel Feldman  <[email protected]>
+
+        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  <[email protected]>
 
         Refactor EventHandler::handleGestureEvent.

Modified: trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp (108793 => 108794)


--- trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp	2012-02-24 15:03:23 UTC (rev 108793)
+++ trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp	2012-02-24 15:28:51 UTC (rev 108794)
@@ -181,6 +181,11 @@
         m_client->bringToFront();
 }
 
+void InspectorFrontendHost::setZoomFactor(float zoom)
+{
+    m_frontendPage->mainFrame()->setPageAndTextZoomFactors(zoom, 1);
+}
+
 void InspectorFrontendHost::inspectedURLChanged(const String& newURL)
 {
     if (m_client)

Modified: trunk/Source/WebCore/inspector/InspectorFrontendHost.h (108793 => 108794)


--- trunk/Source/WebCore/inspector/InspectorFrontendHost.h	2012-02-24 15:03:23 UTC (rev 108793)
+++ trunk/Source/WebCore/inspector/InspectorFrontendHost.h	2012-02-24 15:28:51 UTC (rev 108794)
@@ -63,6 +63,7 @@
     void requestSetDockSide(const String&);
     void closeWindow();
     void bringToFront();
+    void setZoomFactor(float);
     void inspectedURLChanged(const String&);
 
     void setAttachedWindowHeight(unsigned height);

Modified: trunk/Source/WebCore/inspector/InspectorFrontendHost.idl (108793 => 108794)


--- trunk/Source/WebCore/inspector/InspectorFrontendHost.idl	2012-02-24 15:03:23 UTC (rev 108793)
+++ trunk/Source/WebCore/inspector/InspectorFrontendHost.idl	2012-02-24 15:28:51 UTC (rev 108794)
@@ -37,6 +37,7 @@
         void loaded();
         void closeWindow();
         void bringToFront();
+        void setZoomFactor(in float zoom);
         void inspectedURLChanged(in DOMString newURL);
 
         void requestAttachWindow();

Modified: trunk/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js (108793 => 108794)


--- trunk/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js	2012-02-24 15:03:23 UTC (rev 108793)
+++ trunk/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js	2012-02-24 15:28:51 UTC (rev 108794)
@@ -36,6 +36,7 @@
 WebInspector.InspectorFrontendHostStub = function()
 {
     this._attachedWindowHeight = 0;
+    this.isStub = true;
 }
 
 WebInspector.InspectorFrontendHostStub.prototype = {
@@ -160,6 +161,10 @@
     loadResourceSynchronously: function(url)
     {
         return "";
+    },
+
+    setZoomFactor: function(zoom)
+    {
     }
 }
 

Modified: trunk/Source/WebCore/inspector/front-end/Settings.js (108793 => 108794)


--- trunk/Source/WebCore/inspector/front-end/Settings.js	2012-02-24 15:03:23 UTC (rev 108793)
+++ trunk/Source/WebCore/inspector/front-end/Settings.js	2012-02-24 15:28:51 UTC (rev 108794)
@@ -90,6 +90,7 @@
     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.

Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (108793 => 108794)


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2012-02-24 15:03:23 UTC (rev 108793)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2012-02-24 15:28:51 UTC (rev 108794)
@@ -306,6 +306,30 @@
         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 @@
     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 @@
     }
 
     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 @@
                 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;
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to