Title: [141481] trunk/Source
Revision
141481
Author
[email protected]
Date
2013-01-31 13:57:00 -0800 (Thu, 31 Jan 2013)

Log Message

[BlackBerry] Bing Images viewport causes layout "fun"
https://bugs.webkit.org/show_bug.cgi?id=108393

Patch by Jacky Jiang  <[email protected]>.
Reviewed by Yong Li.
Internally reviewed by Arvid Nilsson and partially reviewed by Konrad Piascik.

Source/WebCore:

PR: 277855
On bing.com image search page, JS generated styles for the divs which
contained images based on the window.screen and window.innerWidth.
Unfortunately the styles for the divs weren't good enough on our device
which resulted in three images being overlapped in the same viewport.
On our port, we calculate the screen rect base on the physical screen
pixels. However, iOS and lastest Android Chrome port already changed it
to density-independent (logical) pixels. And also to my knowledge that
some websites would generate bad styles for us as well through
@media device-width/device-height.
To be consistent and fix such kinds of issues, we should use
density-independent pixels instead of physical screen pixels. Mainly
ported from Chrome port change r139356. The patch will affect
screen.width/height, window.outerWidth/outerHeight and
@media device-width/device-height.

* platform/blackberry/PlatformScreenBlackBerry.cpp:
(WebCore):
(WebCore::toUserSpace):
(WebCore::screenAvailableRect):
(WebCore::screenRect):

Source/WebKit/blackberry:

PR: 277855
Set applyPageScaleFactorInCompositor settting to false by default.
Scale down chrome window rect to density-independent pixels.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::didChangeSettings):
* Api/WebSettings.cpp:
(WebKit):
(BlackBerry::WebKit::WebSettings::standardSettings):
(BlackBerry::WebKit::WebSettings::applyDeviceScaleFactorInCompositor):
(BlackBerry::WebKit::WebSettings::setApplyPageScaleFactorInCompositor):
* Api/WebSettings.h:
* WebCoreSupport/ChromeClientBlackBerry.cpp:
(WebCore::ChromeClientBlackBerry::windowRect):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (141480 => 141481)


--- trunk/Source/WebCore/ChangeLog	2013-01-31 21:52:04 UTC (rev 141480)
+++ trunk/Source/WebCore/ChangeLog	2013-01-31 21:57:00 UTC (rev 141481)
@@ -1,3 +1,33 @@
+2013-01-31  Jacky Jiang  <[email protected]>
+
+        [BlackBerry] Bing Images viewport causes layout "fun"
+        https://bugs.webkit.org/show_bug.cgi?id=108393
+
+        Reviewed by Yong Li.
+        Internally reviewed by Arvid Nilsson and partially reviewed by Konrad Piascik.
+
+        PR: 277855
+        On bing.com image search page, JS generated styles for the divs which
+        contained images based on the window.screen and window.innerWidth.
+        Unfortunately the styles for the divs weren't good enough on our device
+        which resulted in three images being overlapped in the same viewport.
+        On our port, we calculate the screen rect base on the physical screen
+        pixels. However, iOS and lastest Android Chrome port already changed it
+        to density-independent (logical) pixels. And also to my knowledge that
+        some websites would generate bad styles for us as well through
+        @media device-width/device-height.
+        To be consistent and fix such kinds of issues, we should use
+        density-independent pixels instead of physical screen pixels. Mainly
+        ported from Chrome port change r139356. The patch will affect
+        screen.width/height, window.outerWidth/outerHeight and
+        @media device-width/device-height.
+
+        * platform/blackberry/PlatformScreenBlackBerry.cpp:
+        (WebCore):
+        (WebCore::toUserSpace):
+        (WebCore::screenAvailableRect):
+        (WebCore::screenRect):
+
 2013-01-31  Max Vujovic  <[email protected]>
 
         [CSS Shaders] Parse custom filter function with the at-rule reference syntax

Modified: trunk/Source/WebCore/platform/blackberry/PlatformScreenBlackBerry.cpp (141480 => 141481)


--- trunk/Source/WebCore/platform/blackberry/PlatformScreenBlackBerry.cpp	2013-01-31 21:52:04 UTC (rev 141480)
+++ trunk/Source/WebCore/platform/blackberry/PlatformScreenBlackBerry.cpp	2013-01-31 21:57:00 UTC (rev 141481)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2009, 2010, 2011 Research In Motion Limited. All rights reserved.
+ * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -20,7 +21,11 @@
 #include "PlatformScreen.h"
 
 #include "FloatRect.h"
+#include "Frame.h"
+#include "FrameView.h"
 #include "NotImplemented.h"
+#include "Page.h"
+#include "Settings.h"
 #include "Widget.h"
 
 #include <BlackBerryPlatformScreen.h>
@@ -42,14 +47,29 @@
     return 24;
 }
 
+// Use logical (density-independent) pixels instead of physical screen pixels.
+static FloatRect toUserSpace(FloatRect rect, Widget* widget)
+{
+    if (widget->isFrameView()) {
+        Page* page = static_cast<FrameView*>(widget)->frame()->page();
+        if (page && !page->settings()->applyDeviceScaleFactorInCompositor())
+            rect.scale(1 / page->deviceScaleFactor());
+    }
+    return rect;
+}
+
 FloatRect screenAvailableRect(Widget* widget)
 {
-    return FloatRect(FloatPoint(), FloatSize(IntSize(BlackBerry::Platform::Graphics::Screen::primaryScreen()->size())));
+    if (!widget)
+        return FloatRect();
+    return toUserSpace(IntRect(IntPoint::zero(), IntSize(BlackBerry::Platform::Graphics::Screen::primaryScreen()->size())), widget);
 }
 
 FloatRect screenRect(Widget* widget)
 {
-    return FloatRect(FloatPoint(), FloatSize(IntSize(BlackBerry::Platform::Graphics::Screen::primaryScreen()->size())));
+    if (!widget)
+        return FloatRect();
+    return toUserSpace(IntRect(IntPoint::zero(), IntSize(BlackBerry::Platform::Graphics::Screen::primaryScreen()->size())), widget);
 }
 
 void screenColorProfile(ColorProfile&)

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (141480 => 141481)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-01-31 21:52:04 UTC (rev 141480)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-01-31 21:57:00 UTC (rev 141481)
@@ -6003,6 +6003,7 @@
 
     coreSettings->setShouldUseCrossOriginProtocolCheck(!webSettings->allowCrossSiteRequests());
     coreSettings->setWebSecurityEnabled(!webSettings->allowCrossSiteRequests());
+    coreSettings->setApplyPageScaleFactorInCompositor(webSettings->applyDeviceScaleFactorInCompositor());
 
     cookieManager().setPrivateMode(webSettings->isPrivateBrowsingEnabled());
 

Modified: trunk/Source/WebKit/blackberry/Api/WebSettings.cpp (141480 => 141481)


--- trunk/Source/WebKit/blackberry/Api/WebSettings.cpp	2013-01-31 21:52:04 UTC (rev 141480)
+++ trunk/Source/WebKit/blackberry/Api/WebSettings.cpp	2013-01-31 21:57:00 UTC (rev 141481)
@@ -36,6 +36,7 @@
 namespace WebKit {
 
 DEFINE_STATIC_LOCAL(String, BlackBerryAllowCrossSiteRequests, (ASCIILiteral("BlackBerryAllowCrossSiteRequests")));
+DEFINE_STATIC_LOCAL(String, BlackBerryApplyDeviceScaleFactorInCompositor, (ASCIILiteral("BlackBerryApplyDeviceScaleFactorInCompositor")));
 DEFINE_STATIC_LOCAL(String, BlackBerryAsynchronousSpellChecking, (ASCIILiteral("BlackBerryAsynchronousSpellChecking")));
 DEFINE_STATIC_LOCAL(String, BlackBerryBackgroundColor, (ASCIILiteral("BlackBerryBackgroundColor")));
 DEFINE_STATIC_LOCAL(String, BlackBerryCookiesEnabled, (ASCIILiteral("BlackBerryCookiesEnabled")));
@@ -179,6 +180,7 @@
     settings->m_private->setBoolean(BlackBerryCredentialAutofillEnabled, false);
     settings->m_private->setBoolean(BlackBerryFormAutofillEnabled, false);
     settings->m_private->setBoolean(BlackBerryAsynchronousSpellChecking, true);
+    settings->m_private->setBoolean(BlackBerryApplyDeviceScaleFactorInCompositor, false);
 
     if (BlackBerry::Platform::DeviceInfo::instance()->isMobile()) {
         WebCore::FloatSize currentPPI = Platform::Graphics::Screen::primaryScreen()->pixelsPerInch(-1);
@@ -842,5 +844,15 @@
     m_private->setDouble(BlackBerryDevicePixelRatio, ratio);
 }
 
+bool WebSettings::applyDeviceScaleFactorInCompositor() const
+{
+    return m_private->getBoolean(BlackBerryApplyDeviceScaleFactorInCompositor);
+}
+
+void WebSettings::setApplyPageScaleFactorInCompositor(bool applyDeviceScaleFactorInCompositor)
+{
+    m_private->setBoolean(BlackBerryApplyDeviceScaleFactorInCompositor, applyDeviceScaleFactorInCompositor);
+}
+
 } // namespace WebKit
 } // namespace BlackBerry

Modified: trunk/Source/WebKit/blackberry/Api/WebSettings.h (141480 => 141481)


--- trunk/Source/WebKit/blackberry/Api/WebSettings.h	2013-01-31 21:52:04 UTC (rev 141480)
+++ trunk/Source/WebKit/blackberry/Api/WebSettings.h	2013-01-31 21:57:00 UTC (rev 141481)
@@ -244,6 +244,9 @@
     bool isBackingStoreEnabled() const;
     void setBackingStoreEnabled(bool);
 
+    bool applyDeviceScaleFactorInCompositor() const;
+    void setApplyPageScaleFactorInCompositor(bool);
+
 private:
     WebSettingsPrivate* m_private;
     WebSettings();

Modified: trunk/Source/WebKit/blackberry/ChangeLog (141480 => 141481)


--- trunk/Source/WebKit/blackberry/ChangeLog	2013-01-31 21:52:04 UTC (rev 141480)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2013-01-31 21:57:00 UTC (rev 141481)
@@ -1,3 +1,26 @@
+2013-01-31  Jacky Jiang  <[email protected]>
+
+        [BlackBerry] Bing Images viewport causes layout "fun"
+        https://bugs.webkit.org/show_bug.cgi?id=108393
+
+        Reviewed by Yong Li.
+        Internally reviewed by Arvid Nilsson and partially reviewed by Konrad Piascik.
+
+        PR: 277855
+        Set applyPageScaleFactorInCompositor settting to false by default.
+        Scale down chrome window rect to density-independent pixels.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::didChangeSettings):
+        * Api/WebSettings.cpp:
+        (WebKit):
+        (BlackBerry::WebKit::WebSettings::standardSettings):
+        (BlackBerry::WebKit::WebSettings::applyDeviceScaleFactorInCompositor):
+        (BlackBerry::WebKit::WebSettings::setApplyPageScaleFactorInCompositor):
+        * Api/WebSettings.h:
+        * WebCoreSupport/ChromeClientBlackBerry.cpp:
+        (WebCore::ChromeClientBlackBerry::windowRect):
+
 2013-01-31  Enrica Casucci  <[email protected]>
 
         WebKit2: provide new bundle APIs to allow bundle clients to be notified of pasteboard access.

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp (141480 => 141481)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp	2013-01-31 21:52:04 UTC (rev 141480)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp	2013-01-31 21:57:00 UTC (rev 141481)
@@ -54,6 +54,7 @@
 #include "SVGZoomAndPan.h"
 #include "SearchPopupMenuBlackBerry.h"
 #include "SecurityOrigin.h"
+#include "Settings.h"
 #include "SharedPointer.h"
 #include "ViewportArguments.h"
 #include "WebPage.h"
@@ -165,7 +166,11 @@
     if (Window* window = m_webPagePrivate->m_client->window())
         windowSize = window->windowSize();
 
-    return FloatRect(0, 0, windowSize.width(), windowSize.height());
+    // Use logical (density-independent) pixels instead of physical screen pixels.
+    FloatRect rect = FloatRect(0, 0, windowSize.width(), windowSize.height());
+    if (!m_webPagePrivate->m_page->settings()->applyDeviceScaleFactorInCompositor())
+        rect.scale(1 / m_webPagePrivate->m_page->deviceScaleFactor());
+    return rect;
 }
 
 FloatRect ChromeClientBlackBerry::pageRect()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to