Make WebCore keep track of the current device scale factor
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Aug 2011 13:26:12 +0000 (13:26 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Aug 2011 13:26:12 +0000 (13:26 +0000)
Fixes <http://webkit.org/b/66413> WebCore requires every WebKit port to keep track of the
device scale factor

Reviewed by Darin Adler.

Source/WebCore:

* WebCore.exp.in: Removed Frame::deviceScaleFactorChanged, added Page::setDeviceScaleFactor.

* css/MediaQueryEvaluator.cpp:
(WebCore::device_pixel_ratioMediaFeatureEval):
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::HTMLCanvasElement):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::devicePixelRatio):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::addDashboardRegions):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::deviceScaleFactor):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::addDashboardRegions):
Changed to get the device scale factor from Page.

* loader/EmptyClients.h:
* page/Chrome.cpp:
* page/Chrome.h:
* page/ChromeClient.h:
Removed Chrome[Client]::deviceScaleFactor.

* page/Frame.cpp:
* page/Frame.h:
Removed deviceScaleFactorChanged. Made deviceOrPageScaleFactorChanged public.

* page/Page.cpp:
(WebCore::Page::Page): Initialize m_deviceScaleFactor.
(WebCore::Page::setDeviceScaleFactor): Added. Code came from
Frame::deviceScaleFactorChanged.

* page/Page.h: Added m_deviceScaleFactor.
(WebCore::Page::deviceScaleFactor): Added simple getter.

Source/WebKit/chromium:

* src/ChromeClientImpl.cpp:
* src/ChromeClientImpl.h:
Removed deviceScaleFactor.

Source/WebKit/efl:

* WebCoreSupport/ChromeClientEfl.cpp:
* WebCoreSupport/ChromeClientEfl.h:
Removed deviceScaleFactor.

Source/WebKit/gtk:

* WebCoreSupport/ChromeClientGtk.cpp:
* WebCoreSupport/ChromeClientGtk.h:
Removed deviceScaleFactor.

Source/WebKit/haiku:

* WebCoreSupport/ChromeClientHaiku.cpp:
* WebCoreSupport/ChromeClientHaiku.h:
Removed deviceScaleFactor.

Source/WebKit/mac:

* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
Moved code to calculate the device scale factor from here...

* WebView/WebView.mm:
(-[WebView _deviceScaleFactor]):
...to here.

(-[WebView _windowDidChangeResolution:]): Now calls Page::setDeviceScaleFactor.

Source/WebKit/qt:

* Api/qwebpage.cpp:
(QWebPagePrivate::QWebPagePrivate): Removed pixelRatio.
(QWebPage::viewportAttributesForSize): Now calls Page::setDeviceScaleFactor.

* Api/qwebpage_p.h: Removed pixelRatio.

* WebCoreSupport/ChromeClientQt.cpp:
* WebCoreSupport/ChromeClientQt.h:
Removed deviceScaleFactor.

Source/WebKit/win:

* WebCoreSupport/WebChromeClient.cpp:
* WebCoreSupport/WebChromeClient.h:
Removed deviceScaleFactor.

Source/WebKit/wince:

* WebCoreSupport/ChromeClientWinCE.cpp:
* WebCoreSupport/ChromeClientWinCE.h:
Removed deviceScaleFactor.

Source/WebKit/wx:

* WebKitSupport/ChromeClientWx.cpp:
* WebKitSupport/ChromeClientWx.h:
Removed deviceScaleFactor.

Source/WebKit2:

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
* WebProcess/WebCoreSupport/WebChromeClient.h:
Removed deviceScaleFactor.

* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::sendDidUpdateBackingStoreState):
(WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode):
(WebKit::DrawingAreaImpl::display):
* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::updateFindIndicator):
(WebKit::FindController::hideFindIndicator):
* WebProcess/WebPage/ca/LayerTreeHostCA.cpp:
(WebKit::LayerTreeHostCA::deviceScaleFactor):
Changed to get the device scale factor from WebCore.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::setDeviceScaleFactor):
* WebProcess/WebPage/WebPage.h:
Removed m_deviceScaleFactor. We always get the scale factor from WebCore now.

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

54 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/css/MediaQueryEvaluator.cpp
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/loader/EmptyClients.h
Source/WebCore/page/Chrome.cpp
Source/WebCore/page/Chrome.h
Source/WebCore/page/ChromeClient.h
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Frame.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/ChromeClientImpl.cpp
Source/WebKit/chromium/src/ChromeClientImpl.h
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp
Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.h
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h
Source/WebKit/haiku/ChangeLog
Source/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.cpp
Source/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebChromeClient.h
Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/qt/Api/qwebpage.cpp
Source/WebKit/qt/Api/qwebpage_p.h
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp
Source/WebKit/win/WebCoreSupport/WebChromeClient.h
Source/WebKit/wince/ChangeLog
Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.cpp
Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.h
Source/WebKit/wx/ChangeLog
Source/WebKit/wx/WebKitSupport/ChromeClientWx.cpp
Source/WebKit/wx/WebKitSupport/ChromeClientWx.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
Source/WebKit2/WebProcess/WebPage/FindController.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp

index 8d1f2f6..b8400d5 100644 (file)
@@ -1,3 +1,46 @@
+2011-08-17  Adam Roben  <aroben@apple.com>
+
+        Make WebCore keep track of the current device scale factor
+
+        Fixes <http://webkit.org/b/66413> WebCore requires every WebKit port to keep track of the
+        device scale factor
+
+        Reviewed by Darin Adler.
+
+        * WebCore.exp.in: Removed Frame::deviceScaleFactorChanged, added Page::setDeviceScaleFactor.
+
+        * css/MediaQueryEvaluator.cpp:
+        (WebCore::device_pixel_ratioMediaFeatureEval):
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::HTMLCanvasElement):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::devicePixelRatio):
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::addDashboardRegions):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::deviceScaleFactor):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::addDashboardRegions):
+        Changed to get the device scale factor from Page.
+
+        * loader/EmptyClients.h:
+        * page/Chrome.cpp:
+        * page/Chrome.h:
+        * page/ChromeClient.h:
+        Removed Chrome[Client]::deviceScaleFactor.
+
+        * page/Frame.cpp:
+        * page/Frame.h:
+        Removed deviceScaleFactorChanged. Made deviceOrPageScaleFactorChanged public.
+
+        * page/Page.cpp:
+        (WebCore::Page::Page): Initialize m_deviceScaleFactor.
+        (WebCore::Page::setDeviceScaleFactor): Added. Code came from
+        Frame::deviceScaleFactorChanged.
+
+        * page/Page.h: Added m_deviceScaleFactor.
+        (WebCore::Page::deviceScaleFactor): Added simple getter.
+
 2011-08-18  Darin Adler  <darin@apple.com>
 
         SVG and HTML editing have conflicting inline isWhitespace functions
index 6b2f099..48592b6 100644 (file)
@@ -706,6 +706,7 @@ __ZN7WebCore4Page16setDefersLoadingEb
 __ZN7WebCore4Page17willMoveOffscreenEv
 __ZN7WebCore4Page18removeSchedulePairEN3WTF10PassRefPtrINS_12SchedulePairEEE
 __ZN7WebCore4Page19visitedStateChangedEPNS_9PageGroupEy
+__ZN7WebCore4Page20setDeviceScaleFactorEf
 __ZN7WebCore4Page20unmarkAllTextMatchesEv
 __ZN7WebCore4Page21markAllMatchesForTextERKN3WTF6StringEjbj
 __ZN7WebCore4Page22allVisitedStateChangedEPNS_9PageGroupE
@@ -737,7 +738,6 @@ __ZN7WebCore5Frame14frameForWidgetEPKNS_6WidgetE
 __ZN7WebCore5Frame17setPageZoomFactorEf
 __ZN7WebCore5Frame17setTextZoomFactorEf
 __ZN7WebCore5Frame23visiblePositionForPointERKNS_8IntPointE
-__ZN7WebCore5Frame24deviceScaleFactorChangedEv
 __ZN7WebCore5Frame25matchLabelsAgainstElementEP7NSArrayPNS_7ElementE
 __ZN7WebCore5Frame25setPageAndTextZoomFactorsEff
 __ZN7WebCore5Frame27resizePageRectsKeepingRatioERKNS_9FloatSizeES3_
index d709b23..28fc36f 100644 (file)
@@ -291,9 +291,9 @@ static bool device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, F
 static bool device_pixel_ratioMediaFeatureEval(CSSValue *value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)
 {
     if (value)
-        return value->isPrimitiveValue() && compareValue(frame->page()->chrome()->deviceScaleFactor(), static_cast<CSSPrimitiveValue*>(value)->getFloatValue(), op);
+        return value->isPrimitiveValue() && compareValue(frame->page()->deviceScaleFactor(), static_cast<CSSPrimitiveValue*>(value)->getFloatValue(), op);
 
-    return frame->page()->chrome()->deviceScaleFactor() != 0;
+    return frame->page()->deviceScaleFactor() != 0;
 }
 
 static bool gridMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op)
index 1a0cb21..a23c86a 100644 (file)
@@ -79,7 +79,7 @@ HTMLCanvasElement::HTMLCanvasElement(const QualifiedName& tagName, Document* doc
     , m_size(DefaultWidth, DefaultHeight)
     , m_rendererIsCanvas(false)
     , m_ignoreReset(false)
-    , m_deviceScaleFactor(document->frame() ? document->frame()->page()->chrome()->deviceScaleFactor() : 1)
+    , m_deviceScaleFactor(document->frame() ? document->frame()->page()->deviceScaleFactor() : 1)
     , m_originClean(true)
     , m_hasCreatedImageBuffer(false)
 {
index 00171a3..6ef2092 100644 (file)
@@ -97,8 +97,6 @@ public:
 
     virtual FloatRect pageRect() { return FloatRect(); }
 
-    virtual float deviceScaleFactor() { return 1.f; }
-
     virtual void focus() { }
     virtual void unfocus() { }
 
index efec62e..1b7ad29 100644 (file)
@@ -151,11 +151,6 @@ FloatRect Chrome::pageRect() const
     return m_client->pageRect();
 }
 
-float Chrome::deviceScaleFactor()
-{
-    return m_client->deviceScaleFactor();
-}
-
 void Chrome::focus() const
 {
     m_client->focus();
index 67777ad..aee23fd 100644 (file)
@@ -97,8 +97,6 @@ namespace WebCore {
 
         FloatRect pageRect() const;
         
-        float deviceScaleFactor();
-
         void focus() const;
         void unfocus() const;
 
index 84c3774..e36cf82 100644 (file)
@@ -88,8 +88,6 @@ namespace WebCore {
         
         virtual FloatRect pageRect() = 0;
         
-        virtual float deviceScaleFactor() = 0;
-    
         virtual void focus() = 0;
         virtual void unfocus() = 0;
 
index b85f1ea..43c2375 100644 (file)
@@ -1342,7 +1342,7 @@ double DOMWindow::devicePixelRatio() const
     if (!page)
         return 0.0;
 
-    return page->chrome()->deviceScaleFactor();
+    return page->deviceScaleFactor();
 }
 
 #if ENABLE(DATABASE)
index 0a4b196..674db28 100644 (file)
@@ -1103,17 +1103,6 @@ void Frame::scalePage(float scale, const LayoutPoint& origin)
     }
 }
 
-void Frame::deviceScaleFactorChanged()
-{
-    if (!m_page)
-        return;
-    m_page->setNeedsRecalcStyleInAllFrames();
-
-#if USE(ACCELERATED_COMPOSITING)
-    deviceOrPageScaleFactorChanged();
-#endif
-}
-
 void Frame::notifyChromeClientWheelEventHandlerCountChanged() const
 {
     // Ensure that this method is being called on the main frame of the page.
index 4750049..a632988 100644 (file)
@@ -167,7 +167,9 @@ namespace WebCore {
         // FIXME: These functions should move to Page.
         void scalePage(float scale, const LayoutPoint& origin);
         float pageScaleFactor() const { return m_pageScaleFactor; }
-        void deviceScaleFactorChanged();
+#if USE(ACCELERATED_COMPOSITING)
+        void deviceOrPageScaleFactorChanged();
+#endif
 
 #if ENABLE(ORIENTATION_EVENTS)
         // Orientation is the interface orientation in degrees. Some examples are:
@@ -219,10 +221,6 @@ namespace WebCore {
         void injectUserScriptsForWorld(DOMWrapperWorld*, const UserScriptVector&, UserScriptInjectionTime);
         void lifeSupportTimerFired(Timer<Frame>*);
 
-#if USE(ACCELERATED_COMPOSITING)
-        void deviceOrPageScaleFactorChanged();
-#endif
-
         HashSet<FrameDestructionObserver*> m_destructionObservers;
 
         Page* m_page;
index f466c7d..ef8d50e 100644 (file)
@@ -147,6 +147,7 @@ Page::Page(PageClients& pageClients)
     , m_cookieEnabled(true)
     , m_areMemoryCacheClientCallsEnabled(true)
     , m_mediaVolume(1)
+    , m_deviceScaleFactor(1)
     , m_javaScriptURLsAreAllowed(true)
     , m_didLoadUserStyleSheet(false)
     , m_userStyleSheetModificationTime(0)
@@ -584,6 +585,19 @@ void Page::setMediaVolume(float volume)
     }
 }
 
+void Page::setDeviceScaleFactor(float scaleFactor)
+{
+    if (m_deviceScaleFactor == scaleFactor)
+        return;
+
+    m_deviceScaleFactor = scaleFactor;
+    setNeedsRecalcStyleInAllFrames();
+
+#if USE(ACCELERATED_COMPOSITING)
+    m_mainFrame->deviceOrPageScaleFactorChanged();
+#endif
+}
+
 void Page::didMoveOnscreen()
 {
     for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
index 4200dfa..9b20c81 100644 (file)
@@ -239,6 +239,9 @@ namespace WebCore {
         float mediaVolume() const { return m_mediaVolume; }
         void setMediaVolume(float volume);
 
+        float deviceScaleFactor() const { return m_deviceScaleFactor; }
+        void setDeviceScaleFactor(float);
+
         // Notifications when the Page starts and stops being presented via a native window.
         void didMoveOnscreen();
         void willMoveOffscreen();
@@ -362,6 +365,8 @@ namespace WebCore {
         bool m_areMemoryCacheClientCallsEnabled;
         float m_mediaVolume;
 
+        float m_deviceScaleFactor;
+
         bool m_javaScriptURLsAreAllowed;
 
         String m_userStyleSheetPath;
index 6a255ab..c89f596 100644 (file)
@@ -1539,7 +1539,7 @@ void RenderInline::addDashboardRegions(Vector<DashboardRegionValue>& regions)
         region.bounds.setY(absPos.y() + region.bounds.y());
 
         if (frame()) {
-            float deviceScaleFactor = frame()->page()->chrome()->deviceScaleFactor();
+            float deviceScaleFactor = frame()->page()->deviceScaleFactor();
             if (deviceScaleFactor != 1.0f) {
                 region.bounds.scale(deviceScaleFactor);
                 region.clip.scale(deviceScaleFactor);
index c378b2a..b95d12e 100644 (file)
@@ -1561,7 +1561,7 @@ float RenderLayerCompositor::deviceScaleFactor() const
     Page* page = frame->page();
     if (!page)
         return 1;
-    return page->chrome()->deviceScaleFactor();
+    return page->deviceScaleFactor();
 }
 
 float RenderLayerCompositor::pageScaleFactor() const
index af2f261..ad35be5 100644 (file)
@@ -2396,7 +2396,7 @@ void RenderObject::addDashboardRegions(Vector<DashboardRegionValue>& regions)
         region.bounds.setY(absPos.y() + styleRegion.offset.top().value());
 
         if (frame()) {
-            float deviceScaleFactor = frame()->page()->chrome()->deviceScaleFactor();
+            float deviceScaleFactor = frame()->page()->deviceScaleFactor();
             if (deviceScaleFactor != 1.0f) {
                 region.bounds.scale(deviceScaleFactor);
                 region.clip.scale(deviceScaleFactor);
index 43c46ed..a443e13 100644 (file)
@@ -1,3 +1,16 @@
+2011-08-17  Adam Roben  <aroben@apple.com>
+
+        Make WebCore keep track of the current device scale factor
+
+        Fixes <http://webkit.org/b/66413> WebCore requires every WebKit port to keep track of the
+        device scale factor
+
+        Reviewed by Darin Adler.
+
+        * src/ChromeClientImpl.cpp:
+        * src/ChromeClientImpl.h:
+        Removed deviceScaleFactor.
+
 2011-08-18  Steve Block  <steveblock@google.com>
 
         Remove a superfluous 'using' from WebBindings.cpp
index 6b2d227..bd7d361 100644 (file)
@@ -205,18 +205,6 @@ FloatRect ChromeClientImpl::pageRect()
     return windowRect();
 }
 
-float ChromeClientImpl::deviceScaleFactor()
-{
-    // This is supposed to return the scale factor of the device. It looks like
-    // the implementor of the graphics layer is responsible for doing most of the
-    // operations associated with scaling. However, this value is used ins some
-    // cases by WebCore. For example, this is used as a scaling factor in canvas
-    // so that things drawn in it are scaled just like the web page is.
-    //
-    // We don't currently implement scaling, so just return 1.0 (no scaling).
-    return 1.0;
-}
-
 void ChromeClientImpl::focus()
 {
     if (m_webView->client())
index 68091e1..0fb32b6 100644 (file)
@@ -65,7 +65,6 @@ public:
     virtual void setWindowRect(const WebCore::FloatRect&);
     virtual WebCore::FloatRect windowRect();
     virtual WebCore::FloatRect pageRect();
-    virtual float deviceScaleFactor();
     virtual void focus();
     virtual void unfocus();
     virtual bool canTakeFocus(WebCore::FocusDirection);
index ff18f6a..4382625 100755 (executable)
@@ -1,3 +1,16 @@
+2011-08-17  Adam Roben  <aroben@apple.com>
+
+        Make WebCore keep track of the current device scale factor
+
+        Fixes <http://webkit.org/b/66413> WebCore requires every WebKit port to keep track of the
+        device scale factor
+
+        Reviewed by Darin Adler.
+
+        * WebCoreSupport/ChromeClientEfl.cpp:
+        * WebCoreSupport/ChromeClientEfl.h:
+        Removed deviceScaleFactor.
+
 2011-08-15  Dmitry Titov  <dimich@chromium.org>
 
         FrameLoaderClient::transferLoadingResourceFromPage does not have enough parameters
index cadea80..f82b183 100644 (file)
@@ -128,12 +128,6 @@ FloatRect ChromeClientEfl::pageRect()
     return ewk_view_page_rect_get(m_view);
 }
 
-float ChromeClientEfl::deviceScaleFactor()
-{
-    notImplemented();
-    return 1.0;
-}
-
 void ChromeClientEfl::focus()
 {
     evas_object_focus_set(m_view, EINA_TRUE);
index fc726b9..8257d0a 100644 (file)
@@ -45,8 +45,6 @@ public:
 
     virtual FloatRect pageRect();
 
-    virtual float deviceScaleFactor();
-
     virtual void focus();
     virtual void unfocus();
 
index 66b988c..497262c 100644 (file)
@@ -1,3 +1,16 @@
+2011-08-17  Adam Roben  <aroben@apple.com>
+
+        Make WebCore keep track of the current device scale factor
+
+        Fixes <http://webkit.org/b/66413> WebCore requires every WebKit port to keep track of the
+        device scale factor
+
+        Reviewed by Darin Adler.
+
+        * WebCoreSupport/ChromeClientGtk.cpp:
+        * WebCoreSupport/ChromeClientGtk.h:
+        Removed deviceScaleFactor.
+
 2011-08-16  Gustavo Noronha Silva  <gustavo.noronha@collabora.com>
 
         Add javascriptcoregtk to the introspection build, to fix it.
index 4fc790a..86480ea 100644 (file)
@@ -137,12 +137,6 @@ FloatRect ChromeClient::pageRect()
     return IntRect(allocation.x, allocation.y, allocation.width, allocation.height);
 }
 
-float ChromeClient::deviceScaleFactor()
-{
-    // Not implementable
-    return 1.0;
-}
-
 void ChromeClient::focus()
 {
     gtk_widget_grab_focus(GTK_WIDGET(m_webView));
index e58a7cd..ef4982a 100644 (file)
@@ -48,8 +48,6 @@ namespace WebKit {
 
         virtual WebCore::FloatRect pageRect();
 
-        virtual float deviceScaleFactor();
-
         virtual void focus();
         virtual void unfocus();
 
index 312971b..b2d6ec3 100644 (file)
@@ -1,3 +1,16 @@
+2011-08-17  Adam Roben  <aroben@apple.com>
+
+        Make WebCore keep track of the current device scale factor
+
+        Fixes <http://webkit.org/b/66413> WebCore requires every WebKit port to keep track of the
+        device scale factor
+
+        Reviewed by Darin Adler.
+
+        * WebCoreSupport/ChromeClientHaiku.cpp:
+        * WebCoreSupport/ChromeClientHaiku.h:
+        Removed deviceScaleFactor.
+
 2011-08-15  Dmitry Titov  <dimich@chromium.org>
 
         FrameLoaderClient::transferLoadingResourceFromPage does not have enough parameters
index 224869b..88136b9 100644 (file)
@@ -78,12 +78,6 @@ FloatRect ChromeClientHaiku::pageRect()
     return FloatRect(0, 0, 200, 200);
 }
 
-float ChromeClientHaiku::deviceScaleFactor()
-{
-    notImplemented();
-    return 1.0;
-}
-
 void ChromeClientHaiku::focus()
 {
     notImplemented();
index eb2c4ef..6398c9d 100644 (file)
@@ -51,8 +51,6 @@ namespace WebCore {
 
         virtual FloatRect pageRect();
 
-        virtual float deviceScaleFactor();
-
         virtual void focus();
         virtual void unfocus();
 
index aee657e..0d212c7 100644 (file)
@@ -1,3 +1,22 @@
+2011-08-17  Adam Roben  <aroben@apple.com>
+
+        Make WebCore keep track of the current device scale factor
+
+        Fixes <http://webkit.org/b/66413> WebCore requires every WebKit port to keep track of the
+        device scale factor
+
+        Reviewed by Darin Adler.
+
+        * WebCoreSupport/WebChromeClient.h:
+        * WebCoreSupport/WebChromeClient.mm:
+        Moved code to calculate the device scale factor from here...
+
+        * WebView/WebView.mm:
+        (-[WebView _deviceScaleFactor]):
+        ...to here.
+
+        (-[WebView _windowDidChangeResolution:]): Now calls Page::setDeviceScaleFactor.
+
 2011-08-17  Dan Bernstein  <mitz@apple.com>
 
         Removed some code that is not needed when building for Leopard or later.
index bd95d47..29e1305 100644 (file)
@@ -45,8 +45,6 @@ public:
 
     virtual WebCore::FloatRect pageRect();
 
-    virtual float deviceScaleFactor();
-
     virtual void focus();
     virtual void unfocus();
     
index a495ce2..ba6d51a 100644 (file)
@@ -176,20 +176,6 @@ FloatRect WebChromeClient::pageRect()
     return [m_webView frame];
 }
 
-float WebChromeClient::deviceScaleFactor()
-{
-    NSWindow *window = [m_webView window];
-#if !defined(BUILDING_ON_LEOPARD) && !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 WebChromeClient::focus()
 {
     [[m_webView _UIDelegateForwarder] webViewFocus:m_webView];
index 7377a9a..53a1d56 100644 (file)
@@ -3382,9 +3382,23 @@ static NSString * const windowDidChangeResolutionNotification = @"NSWindowDidCha
         [self close];
 }
 
+- (float)_deviceScaleFactor
+{
+    NSWindow *window = [self window];
+#if !defined(BUILDING_ON_LEOPARD) && !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
 {
-    _private->page->mainFrame()->deviceScaleFactorChanged();
+    _private->page->setDeviceScaleFactor([self _deviceScaleFactor]);
 }
 
 - (void)setPreferences:(WebPreferences *)prefs
index bbc2139..23147c0 100644 (file)
@@ -307,7 +307,6 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
     , selectTrailingWhitespaceEnabled(false)
     , linkPolicy(QWebPage::DontDelegateLinks)
     , viewportSize(QSize(0, 0))
-    , pixelRatio(1)
 #ifndef QT_NO_CONTEXTMENU
     , currentContextMenu(0)
 #endif
@@ -2569,7 +2568,7 @@ QWebPage::ViewportAttributes QWebPage::viewportAttributesForSize(const QSize& av
     result.m_devicePixelRatio = conf.devicePixelRatio;
     result.m_isUserScalable = static_cast<bool>(conf.userScalable);
 
-    d->pixelRatio = conf.devicePixelRatio;
+    d->page->setDeviceScaleFactor(conf.devicePixelRatio);
 
     return result;
 }
index 86f54b7..3c00e52 100644 (file)
@@ -191,7 +191,6 @@ public:
 
     QSize viewportSize;
     QSize fixedLayoutSize;
-    qreal pixelRatio;
 
     QWebHistory history;
     QWebHitTestResult hitTestResult;
index c120883..b8f2f6b 100644 (file)
@@ -1,3 +1,22 @@
+2011-08-17  Adam Roben  <aroben@apple.com>
+
+        Make WebCore keep track of the current device scale factor
+
+        Fixes <http://webkit.org/b/66413> WebCore requires every WebKit port to keep track of the
+        device scale factor
+
+        Reviewed by Darin Adler.
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::QWebPagePrivate): Removed pixelRatio.
+        (QWebPage::viewportAttributesForSize): Now calls Page::setDeviceScaleFactor.
+
+        * Api/qwebpage_p.h: Removed pixelRatio.
+
+        * WebCoreSupport/ChromeClientQt.cpp:
+        * WebCoreSupport/ChromeClientQt.h:
+        Removed deviceScaleFactor.
+
 2011-08-18  Chang Shu  <cshu@webkit.org>
 
         Add support of setPasswordEchoEnabled and setPasswordEchoDuration for password echo feature
index fd7b910..09a9377 100644 (file)
@@ -146,13 +146,6 @@ FloatRect ChromeClientQt::pageRect()
     return FloatRect(QRectF(QPointF(0, 0), m_webPage->viewportSize()));
 }
 
-float ChromeClientQt::deviceScaleFactor()
-{
-    if (!m_webPage)
-        return 1;
-    return m_webPage->d->pixelRatio;
-}
-
 void ChromeClientQt::focus()
 {
     if (!m_webPage)
index 1fd3cd2..2bad806 100644 (file)
@@ -68,8 +68,6 @@ public:
 
     virtual FloatRect pageRect();
 
-    virtual float deviceScaleFactor();
-
     virtual void focus();
     virtual void unfocus();
 
index 4c399b6..fcf1f0a 100644 (file)
@@ -1,3 +1,16 @@
+2011-08-17  Adam Roben  <aroben@apple.com>
+
+        Make WebCore keep track of the current device scale factor
+
+        Fixes <http://webkit.org/b/66413> WebCore requires every WebKit port to keep track of the
+        device scale factor
+
+        Reviewed by Darin Adler.
+
+        * WebCoreSupport/WebChromeClient.cpp:
+        * WebCoreSupport/WebChromeClient.h:
+        Removed deviceScaleFactor.
+
 2011-08-15  Dmitry Titov  <dimich@chromium.org>
 
         FrameLoaderClient::transferLoadingResourceFromPage does not have enough parameters
index a7053f2..517a4f0 100644 (file)
@@ -118,12 +118,6 @@ FloatRect WebChromeClient::pageRect()
     return rect;
 }
 
-float WebChromeClient::deviceScaleFactor()
-{
-    // Windows doesn't support UI scaling.
-    return 1.0;
-}
-
 void WebChromeClient::focus()
 {
     IWebUIDelegate* uiDelegate = 0;
index 0e222b8..ae997b8 100644 (file)
@@ -48,8 +48,6 @@ public:
     virtual WebCore::FloatRect windowRect();
     
     virtual WebCore::FloatRect pageRect();
-    
-    virtual float deviceScaleFactor();
 
     virtual void focus();
     virtual void unfocus();
index 63cbda2..a3e3667 100644 (file)
@@ -1,3 +1,16 @@
+2011-08-17  Adam Roben  <aroben@apple.com>
+
+        Make WebCore keep track of the current device scale factor
+
+        Fixes <http://webkit.org/b/66413> WebCore requires every WebKit port to keep track of the
+        device scale factor
+
+        Reviewed by Darin Adler.
+
+        * WebCoreSupport/ChromeClientWinCE.cpp:
+        * WebCoreSupport/ChromeClientWinCE.h:
+        Removed deviceScaleFactor.
+
 2011-08-15  Dmitry Titov  <dimich@chromium.org>
 
         FrameLoaderClient::transferLoadingResourceFromPage does not have enough parameters
index 8fb32a3..ff205f5 100644 (file)
@@ -70,11 +70,6 @@ FloatRect ChromeClientWinCE::pageRect()
     return windowRect();
 }
 
-float ChromeClientWinCE::deviceScaleFactor()
-{
-    return 1.0;
-}
-
 void ChromeClientWinCE::focus()
 {
     notImplemented();
index 03f72f0..06c578e 100644 (file)
@@ -43,8 +43,6 @@ public:
 
     virtual WebCore::FloatRect pageRect();
 
-    virtual float deviceScaleFactor();
-
     virtual void focus();
     virtual void unfocus();
 
index 5df8874..1e82e80 100644 (file)
@@ -1,3 +1,16 @@
+2011-08-17  Adam Roben  <aroben@apple.com>
+
+        Make WebCore keep track of the current device scale factor
+
+        Fixes <http://webkit.org/b/66413> WebCore requires every WebKit port to keep track of the
+        device scale factor
+
+        Reviewed by Darin Adler.
+
+        * WebKitSupport/ChromeClientWx.cpp:
+        * WebKitSupport/ChromeClientWx.h:
+        Removed deviceScaleFactor.
+
 2011-08-15  Dmitry Titov  <dimich@chromium.org>
 
         FrameLoaderClient::transferLoadingResourceFromPage does not have enough parameters
index 345a6e3..9750c55 100644 (file)
@@ -107,12 +107,6 @@ FloatRect ChromeClientWx::pageRect()
     return FloatRect();
 }
 
-float ChromeClientWx::deviceScaleFactor()
-{
-    notImplemented();
-    return 1.0;
-}
-
 void ChromeClientWx::focus()
 {
     notImplemented();
index 981b18d..793ee4a 100644 (file)
@@ -48,8 +48,6 @@ public:
 
     virtual FloatRect pageRect();
 
-    virtual float deviceScaleFactor();
-
     virtual void focus();
     virtual void unfocus();
 
index e6b81ed..9ed7ad8 100644 (file)
@@ -1,3 +1,33 @@
+2011-08-17  Adam Roben  <aroben@apple.com>
+
+        Make WebCore keep track of the current device scale factor
+
+        Fixes <http://webkit.org/b/66413> WebCore requires every WebKit port to keep track of the
+        device scale factor
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        Removed deviceScaleFactor.
+
+        * WebProcess/WebPage/DrawingAreaImpl.cpp:
+        (WebKit::DrawingAreaImpl::sendDidUpdateBackingStoreState):
+        (WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode):
+        (WebKit::DrawingAreaImpl::display):
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::FindController::updateFindIndicator):
+        (WebKit::FindController::hideFindIndicator):
+        * WebProcess/WebPage/ca/LayerTreeHostCA.cpp:
+        (WebKit::LayerTreeHostCA::deviceScaleFactor):
+        Changed to get the device scale factor from WebCore.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+        (WebKit::WebPage::setDeviceScaleFactor):
+        * WebProcess/WebPage/WebPage.h:
+        Removed m_deviceScaleFactor. We always get the scale factor from WebCore now.
+
 2011-08-17  Anders Carlsson  <andersca@apple.com>
 
         Remove unused Core Animation related classes
index a92d5a7..cbbd9e8 100644 (file)
@@ -116,11 +116,6 @@ FloatRect WebChromeClient::pageRect()
     return FloatRect(FloatPoint(), m_page->size());
 }
 
-float WebChromeClient::deviceScaleFactor()
-{
-    return m_page->deviceScaleFactor();
-}
-
 void WebChromeClient::focus()
 {
     m_page->send(Messages::WebPageProxy::SetFocus(true));
index 9420b14..4d5f2ce 100644 (file)
@@ -57,8 +57,6 @@ private:
     
     virtual WebCore::FloatRect pageRect();
     
-    virtual float deviceScaleFactor();
-    
     virtual void focus();
     virtual void unfocus();
     
index 5e4d040..8086df7 100644 (file)
@@ -359,7 +359,7 @@ void DrawingAreaImpl::sendDidUpdateBackingStoreState()
 
     if (m_isPaintingSuspended || m_layerTreeHost) {
         updateInfo.viewSize = m_webPage->size();
-        updateInfo.deviceScaleFactor = m_webPage->deviceScaleFactor();
+        updateInfo.deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
 
         if (m_layerTreeHost) {
             layerTreeContext = m_layerTreeHost->layerTreeContext();
@@ -466,7 +466,7 @@ void DrawingAreaImpl::exitAcceleratedCompositingMode()
     UpdateInfo updateInfo;
     if (m_isPaintingSuspended) {
         updateInfo.viewSize = m_webPage->size();
-        updateInfo.deviceScaleFactor = m_webPage->deviceScaleFactor();
+        updateInfo.deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
     } else
         display(updateInfo);
 
@@ -617,13 +617,13 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo)
         return;
 
     updateInfo.viewSize = m_webPage->size();
-    updateInfo.deviceScaleFactor = m_webPage->deviceScaleFactor();
+    updateInfo.deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
 
     IntRect bounds = m_dirtyRegion.bounds();
     ASSERT(m_webPage->bounds().contains(bounds));
 
     IntSize bitmapSize = bounds.size();
-    bitmapSize.scale(m_webPage->deviceScaleFactor());
+    bitmapSize.scale(m_webPage->corePage()->deviceScaleFactor());
     RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bitmapSize, ShareableBitmap::SupportsAlpha);
     if (!bitmap)
         return;
@@ -646,7 +646,7 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo)
     m_scrollOffset = IntSize();
 
     OwnPtr<GraphicsContext> graphicsContext = createGraphicsContext(bitmap.get());
-    graphicsContext->scale(FloatSize(m_webPage->deviceScaleFactor(), m_webPage->deviceScaleFactor()));
+    graphicsContext->scale(FloatSize(m_webPage->corePage()->deviceScaleFactor(), m_webPage->corePage()->deviceScaleFactor()));
 
     updateInfo.updateRectBounds = bounds;
 
index 02d84ac..49e2f65 100644 (file)
@@ -177,7 +177,7 @@ bool FindController::updateFindIndicator(Frame* selectedFrame, bool isShowingOve
     selectedFrame->selection()->getClippedVisibleTextRectangles(textRects);
 
     IntSize backingStoreSize = selectionRect.size();
-    backingStoreSize.scale(m_webPage->deviceScaleFactor());
+    backingStoreSize.scale(m_webPage->corePage()->deviceScaleFactor());
 
     // Create a backing store and paint the find indicator text into it.
     RefPtr<ShareableBitmap> findIndicatorTextBackingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);
@@ -185,7 +185,7 @@ bool FindController::updateFindIndicator(Frame* selectedFrame, bool isShowingOve
         return false;
     
     OwnPtr<GraphicsContext> graphicsContext = findIndicatorTextBackingStore->createGraphicsContext();
-    graphicsContext->scale(FloatSize(m_webPage->deviceScaleFactor(), m_webPage->deviceScaleFactor()));
+    graphicsContext->scale(FloatSize(m_webPage->corePage()->deviceScaleFactor(), m_webPage->corePage()->deviceScaleFactor()));
 
     IntRect paintRect = selectionRect;
     paintRect.move(selectedFrame->view()->frameRect().x(), selectedFrame->view()->frameRect().y());
@@ -212,7 +212,7 @@ bool FindController::updateFindIndicator(Frame* selectedFrame, bool isShowingOve
         textRectsInSelectionRectCoordinates.append(textRectInSelectionRectCoordinates);
     }            
     
-    m_webPage->send(Messages::WebPageProxy::SetFindIndicator(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, m_webPage->deviceScaleFactor(), handle, !isShowingOverlay));
+    m_webPage->send(Messages::WebPageProxy::SetFindIndicator(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, m_webPage->corePage()->deviceScaleFactor(), handle, !isShowingOverlay));
     m_isShowingFindIndicator = true;
 
     return true;
@@ -224,7 +224,7 @@ void FindController::hideFindIndicator()
         return;
 
     ShareableBitmap::Handle handle;
-    m_webPage->send(Messages::WebPageProxy::SetFindIndicator(FloatRect(), Vector<FloatRect>(), m_webPage->deviceScaleFactor(), handle, false));
+    m_webPage->send(Messages::WebPageProxy::SetFindIndicator(FloatRect(), Vector<FloatRect>(), m_webPage->corePage()->deviceScaleFactor(), handle, false));
     m_isShowingFindIndicator = false;
 }
 
index 57bf8f8..db6a190 100644 (file)
@@ -186,7 +186,6 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
     , m_canRunBeforeUnloadConfirmPanel(parameters.canRunBeforeUnloadConfirmPanel)
     , m_canRunModal(parameters.canRunModal)
     , m_isRunningModal(false)
-    , m_deviceScaleFactor(parameters.deviceScaleFactor)
     , m_cachedMainFrameIsPinnedToLeftSide(false)
     , m_cachedMainFrameIsPinnedToRightSide(false)
     , m_isShowingContextMenu(false)
@@ -789,11 +788,7 @@ double WebPage::pageScaleFactor() const
 
 void WebPage::setDeviceScaleFactor(float scaleFactor)
 {
-    if (m_deviceScaleFactor == scaleFactor)
-        return;
-
-    m_deviceScaleFactor = scaleFactor;
-    m_page->mainFrame()->deviceScaleFactorChanged();
+    m_page->setDeviceScaleFactor(scaleFactor);
 }
 
 void WebPage::setUseFixedLayout(bool fixed)
index 4ed2b97..3f42d41 100644 (file)
@@ -410,7 +410,6 @@ public:
     void runModal();
 
     void setDeviceScaleFactor(float);
-    float deviceScaleFactor() const { return m_deviceScaleFactor; }
 
     void setMemoryCacheMessagesEnabled(bool);
 
@@ -665,8 +664,6 @@ private:
     bool m_canRunModal;
     bool m_isRunningModal;
 
-    float m_deviceScaleFactor;
-
     bool m_cachedMainFrameIsPinnedToLeftSide;
     bool m_cachedMainFrameIsPinnedToRightSide;
 
index a527022..68491e7 100644 (file)
@@ -214,7 +214,7 @@ bool LayerTreeHostCA::showRepaintCounter() const
 
 float LayerTreeHostCA::deviceScaleFactor() const
 {
-    return m_webPage->deviceScaleFactor();
+    return m_webPage->corePage()->deviceScaleFactor();
 }
 
 void LayerTreeHostCA::performScheduledLayerFlush()