Title: [93314] trunk/Source/WebKit2
Revision
93314
Author
[email protected]
Date
2011-08-18 09:43:14 -0700 (Thu, 18 Aug 2011)

Log Message

Make WebPageProxy keep track of the current device scale factor

The device scale factor is no longer considered part of WebPageProxy's "view state". It now
has its own setter/getter. This made the code a little simpler and more similar to the page
scale factor. Each port-specific WebKit2 view is now responsible for calling
WebPageProxy::setDeviceScaleFactor whenever it thinks the device scale factor might have
changed.

Fixes <http://webkit.org/b/66466> WebKit2 requires every port-specific view to keep track of
the current device scale factor

Reviewed by Anders Carlsson.

* UIProcess/API/efl/PageClientImpl.cpp:
* UIProcess/API/efl/PageClientImpl.h:
* UIProcess/API/gtk/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.mm:
* UIProcess/PageClient.h:
* UIProcess/qt/QtWebPageProxy.h:
* UIProcess/win/WebView.h:
Removed deviceScaleFactor.

* UIProcess/API/mac/WKView.mm:
(-[WKView _deviceScaleFactor]): Added. Code came from PageClientImpl::deviceScaleFactor.
(-[WKView _windowDidChangeResolution:]): Changed to call WebPageProxy::setDeviceScaleFactor.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy): Initialize m_deviceScaleFactor.
(WebKit::WebPageProxy::viewStateDidChange): Removed device-scale-factor-related code.
(WebKit::WebPageProxy::setDeviceScaleFactor): Added. Records the new device scale factor and
tells the DrawingAreaProxy about it if it's actually changed.
(WebKit::WebPageProxy::creationParameters): Use m_deviceScaleFactor instead of calling out
to the PageClient.

* UIProcess/WebPageProxy.h: Added m_deviceScaleFactor and setDeviceScaleFactor, which
replaces the DeviceScaleFactor ViewStateFlag.
(WebKit::WebPageProxy::deviceScaleFactor): Inlined this now-simple getter.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (93313 => 93314)


--- trunk/Source/WebKit2/ChangeLog	2011-08-18 16:39:12 UTC (rev 93313)
+++ trunk/Source/WebKit2/ChangeLog	2011-08-18 16:43:14 UTC (rev 93314)
@@ -1,3 +1,44 @@
+2011-08-18  Adam Roben  <[email protected]>
+
+        Make WebPageProxy keep track of the current device scale factor
+
+        The device scale factor is no longer considered part of WebPageProxy's "view state". It now
+        has its own setter/getter. This made the code a little simpler and more similar to the page
+        scale factor. Each port-specific WebKit2 view is now responsible for calling
+        WebPageProxy::setDeviceScaleFactor whenever it thinks the device scale factor might have
+        changed.
+
+        Fixes <http://webkit.org/b/66466> WebKit2 requires every port-specific view to keep track of
+        the current device scale factor
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/efl/PageClientImpl.cpp:
+        * UIProcess/API/efl/PageClientImpl.h:
+        * UIProcess/API/gtk/PageClientImpl.h:
+        * UIProcess/API/mac/PageClientImpl.h:
+        * UIProcess/API/mac/PageClientImpl.mm:
+        * UIProcess/PageClient.h:
+        * UIProcess/qt/QtWebPageProxy.h:
+        * UIProcess/win/WebView.h:
+        Removed deviceScaleFactor.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _deviceScaleFactor]): Added. Code came from PageClientImpl::deviceScaleFactor.
+        (-[WKView _windowDidChangeResolution:]): Changed to call WebPageProxy::setDeviceScaleFactor.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy): Initialize m_deviceScaleFactor.
+        (WebKit::WebPageProxy::viewStateDidChange): Removed device-scale-factor-related code.
+        (WebKit::WebPageProxy::setDeviceScaleFactor): Added. Records the new device scale factor and
+        tells the DrawingAreaProxy about it if it's actually changed.
+        (WebKit::WebPageProxy::creationParameters): Use m_deviceScaleFactor instead of calling out
+        to the PageClient.
+
+        * UIProcess/WebPageProxy.h: Added m_deviceScaleFactor and setDeviceScaleFactor, which
+        replaces the DeviceScaleFactor ViewStateFlag.
+        (WebKit::WebPageProxy::deviceScaleFactor): Inlined this now-simple getter.
+
 2011-08-17  Adam Roben  <[email protected]>
 
         Make WebCore keep track of the current device scale factor

Modified: trunk/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp (93313 => 93314)


--- trunk/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp	2011-08-18 16:39:12 UTC (rev 93313)
+++ trunk/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp	2011-08-18 16:43:14 UTC (rev 93314)
@@ -255,9 +255,4 @@
     notImplemented();
 }
 
-float PageClientImpl::deviceScaleFactor() const
-{
-    return 0.0;
-}
-
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h (93313 => 93314)


--- trunk/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h	2011-08-18 16:39:12 UTC (rev 93313)
+++ trunk/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h	2011-08-18 16:43:14 UTC (rev 93314)
@@ -98,8 +98,6 @@
     virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned);
     virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned);
 
-    virtual float deviceScaleFactor() const;
-
 private:
     RefPtr<WebPageProxy> m_page;
     Evas_Object* m_viewObject;

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h (93313 => 93314)


--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h	2011-08-18 16:39:12 UTC (rev 93313)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h	2011-08-18 16:43:14 UTC (rev 93314)
@@ -84,7 +84,6 @@
     virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut);
     virtual void didChangeScrollbarsForMainFrame() const;
     virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);
-    virtual float deviceScaleFactor() const { return 1; }
     virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&, const AtomicString&, Vector<WTF::String>&);
     virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned);
     virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned);

Modified: trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h (93313 => 93314)


--- trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h	2011-08-18 16:39:12 UTC (rev 93313)
+++ trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h	2011-08-18 16:43:14 UTC (rev 93314)
@@ -120,8 +120,6 @@
     virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel);
     virtual void recordAutocorrectionResponse(WebCore::EditorClient::AutocorrectionResponseType, const String& replacedString, const String& replacementString);
 
-    virtual float deviceScaleFactor() const;
-    
     virtual WKView* wkView() const { return m_wkView; }
 
     WKView* m_wkView;

Modified: trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm (93313 => 93314)


--- trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm	2011-08-18 16:39:12 UTC (rev 93313)
+++ trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm	2011-08-18 16:43:14 UTC (rev 93314)
@@ -462,20 +462,6 @@
 #endif
 }
 
-float PageClientImpl::deviceScaleFactor() const
-{
-    NSWindow *window = [m_wkView window];
-#if !defined(BUILDING_ON_SNOW_LEOPARD)
-    if (window)
-        return [window backingScaleFactor];
-    return [[NSScreen mainScreen] backingScaleFactor];
-#else
-    if (window)
-        return [window userSpaceScaleFactor];
-    return [[NSScreen mainScreen] userSpaceScaleFactor];
-#endif
-}
-
 bool PageClientImpl::executeSavedCommandBySelector(const String& selectorString)
 {
     return [m_wkView _executeSavedCommandBySelector:NSSelectorFromString(selectorString)];

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (93313 => 93314)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2011-08-18 16:39:12 UTC (rev 93313)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2011-08-18 16:43:14 UTC (rev 93314)
@@ -1836,9 +1836,23 @@
     _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
 }
 
+- (float)_deviceScaleFactor
+{
+    NSWindow *window = [self window];
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+    if (window)
+        return [window backingScaleFactor];
+    return [[NSScreen mainScreen] backingScaleFactor];
+#else
+    if (window)
+        return [window userSpaceScaleFactor];
+    return [[NSScreen mainScreen] userSpaceScaleFactor];
+#endif
+}
+
 - (void)_windowDidChangeResolution:(NSNotification *)notification
 {
-    _data->_page->viewStateDidChange(WebPageProxy::DeviceScaleFactor);
+    _data->_page->setDeviceScaleFactor([self _deviceScaleFactor]);
 }
 
 static void drawPageBackground(CGContextRef context, WebPageProxy* page, const IntRect& rect)

Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (93313 => 93314)


--- trunk/Source/WebKit2/UIProcess/PageClient.h	2011-08-18 16:39:12 UTC (rev 93313)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h	2011-08-18 16:43:14 UTC (rev 93314)
@@ -185,8 +185,6 @@
     virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects) = 0;
     virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) = 0;
     virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) = 0;
-
-    virtual float deviceScaleFactor() const = 0;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (93313 => 93314)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2011-08-18 16:39:12 UTC (rev 93313)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2011-08-18 16:43:14 UTC (rev 93314)
@@ -153,6 +153,7 @@
     , m_textZoomFactor(1)
     , m_pageZoomFactor(1)
     , m_pageScaleFactor(1)
+    , m_deviceScaleFactor(1)
     , m_drawsBackground(true)
     , m_drawsTransparentBackground(false)
     , m_areMemoryCacheClientCallsEnabled(true)
@@ -682,9 +683,6 @@
         }
     }
 
-    if (flags & DeviceScaleFactor)
-        m_drawingArea->deviceScaleFactorDidChange();
-
     updateBackingStoreDiscardableState();
 }
 
@@ -1217,9 +1215,16 @@
     process()->send(Messages::WebPage::ScalePage(scale, origin), m_pageID);
 }
 
-float WebPageProxy::deviceScaleFactor() const
+void WebPageProxy::setDeviceScaleFactor(float scaleFactor)
 {
-    return m_pageClient->deviceScaleFactor();
+    if (!isValid())
+        return;
+
+    if (m_deviceScaleFactor == scaleFactor)
+        return;
+
+    m_deviceScaleFactor = scaleFactor;
+    m_drawingArea->deviceScaleFactorDidChange();
 }
 
 void WebPageProxy::setUseFixedLayout(bool fixed)
@@ -3089,7 +3094,7 @@
     parameters.highestUsedBackForwardItemID = WebBackForwardListItem::highedUsedItemID();
     parameters.canRunBeforeUnloadConfirmPanel = m_uiClient.canRunBeforeUnloadConfirmPanel();
     parameters.canRunModal = m_uiClient.canRunModal();
-    parameters.deviceScaleFactor = m_pageClient->deviceScaleFactor();
+    parameters.deviceScaleFactor = m_deviceScaleFactor;
 
 #if PLATFORM(MAC)
     parameters.isSmartInsertDeleteEnabled = m_isSmartInsertDeleteEnabled;

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (93313 => 93314)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2011-08-18 16:39:12 UTC (rev 93313)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2011-08-18 16:43:14 UTC (rev 93314)
@@ -274,7 +274,6 @@
         ViewIsFocused = 1 << 1,
         ViewIsVisible = 1 << 2,
         ViewIsInWindow = 1 << 3,
-        DeviceScaleFactor = 1 << 4,
     };
     typedef unsigned ViewStateFlags;
     void viewStateDidChange(ViewStateFlags flags);
@@ -387,7 +386,8 @@
     void scalePage(double scale, const WebCore::IntPoint& origin);
     double pageScaleFactor() const { return m_pageScaleFactor; }
 
-    float deviceScaleFactor() const;
+    void setDeviceScaleFactor(float);
+    float deviceScaleFactor() const { return m_deviceScaleFactor; }
 
     void setUseFixedLayout(bool);
     void setFixedLayoutSize(const WebCore::IntSize&);
@@ -862,6 +862,7 @@
     double m_textZoomFactor;
     double m_pageZoomFactor;
     double m_pageScaleFactor;
+    float m_deviceScaleFactor;
 
     bool m_drawsBackground;
     bool m_drawsTransparentBackground;

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h (93313 => 93314)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h	2011-08-18 16:39:12 UTC (rev 93313)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h	2011-08-18 16:43:14 UTC (rev 93314)
@@ -126,7 +126,6 @@
     virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);
     virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) { }
     virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) { }
-    virtual float deviceScaleFactor() const { return 1; }
 
     virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
 

Modified: trunk/Source/WebKit2/UIProcess/win/WebView.h (93313 => 93314)


--- trunk/Source/WebKit2/UIProcess/win/WebView.h	2011-08-18 16:39:12 UTC (rev 93313)
+++ trunk/Source/WebKit2/UIProcess/win/WebView.h	2011-08-18 16:43:14 UTC (rev 93314)
@@ -173,7 +173,6 @@
     virtual void displayView();
     virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
     virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);
-    virtual float deviceScaleFactor() const { return 1; }
     
     virtual WebCore::IntSize viewSize();
     virtual bool isViewWindowActive();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to