Title: [120473] trunk/Source/WebKit/blackberry
Revision
120473
Author
[email protected]
Date
2012-06-15 10:10:06 -0700 (Fri, 15 Jun 2012)

Log Message

[BlackBerry] Certain web pages (i.e., http://www.cloudtweaks.com/) are allowed to be wider than the screen
https://bugs.webkit.org/show_bug.cgi?id=89211

Reviewed by Rob Buis.
Patch by Jacky Jiang <[email protected]>

PR: 135215
Make simpler rules for zoom to fit scale:
- Zoom to fit horizontally first without clamping the contents width.
- Zoom to fit vertically instead without clamping the contents height
  if the horizontal zoom to fit can cause a grey area below the web
  page. Get rid of the virtual viewport guard as there may be cases
  that zooming can cause a grey area without a virtual viewport.
- Clamp the scale by the minimum zoom to fit scale 0.25 and apply
  this rule to image documents as well. This minimum scale can be
  changed if there is a better vaule in the future.
In this way, we can get rid of the issue that many web pages don't fit
the screen.

Reviewed internally by Arvid Nilsson.

* Api/WebPage.cpp:
(WebKit):
(BlackBerry::WebKit::WebPagePrivate::zoomToFitScale):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (120472 => 120473)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-06-15 16:57:11 UTC (rev 120472)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-06-15 17:10:06 UTC (rev 120473)
@@ -207,6 +207,8 @@
 
 const double minimumExpandingRatio = 0.15;
 
+const double minimumZoomToFitScale = 0.25;
+
 // Helper function to parse a URL and fill in missing parts.
 static KURL parseUrl(const String& url)
 {
@@ -1672,31 +1674,13 @@
 
 double WebPagePrivate::zoomToFitScale() const
 {
-    // We must clamp the contents for this calculation so that we do not allow an
-    // arbitrarily small zoomToFitScale much like we clamp the fixedLayoutSize()
-    // so that we do not have arbitrarily large layout size.
-    // If we have a specified viewport, we may need to be able to zoom out more.
-    int contentWidth = std::min(contentsSize().width(), std::max(m_virtualViewportWidth, static_cast<int>(defaultMaxLayoutSize().width())));
+    int contentWidth = contentsSize().width();
+    int contentHeight = contentsSize().height();
+    double zoomToFitScale = contentWidth > 0.0 ? static_cast<double>(m_actualVisibleWidth) / contentWidth : 1.0;
+    if (contentHeight * zoomToFitScale < static_cast<double>(m_defaultLayoutSize.height()))
+        zoomToFitScale = contentHeight > 0 ? static_cast<double>(m_defaultLayoutSize.height()) / contentHeight : 1.0;
 
-    // defaultMaxLayoutSize().width() is a safeguard for excessively large page layouts that
-    // is too restrictive for image documents. In this case, the document width is sufficient.
-    Document* doc = m_page->mainFrame()->document();
-    if (doc && doc->isImageDocument())
-       contentWidth = contentsSize().width();
-
-    // If we have a virtual viewport and its aspect ratio caused content to layout
-    // wider than the default layout aspect ratio we need to zoom to fit the content height
-    // in order to avoid showing a grey area below the web page.
-    // Without virtual viewport we can never get into this situation.
-    if (hasVirtualViewport()) {
-        int contentHeight = std::min(contentsSize().height(), std::max(m_virtualViewportHeight, static_cast<int>(defaultMaxLayoutSize().height())));
-
-        // Aspect ratio check without division.
-        if (contentWidth * m_defaultLayoutSize.height() > contentHeight * m_defaultLayoutSize.width())
-            return contentHeight > 0 ? static_cast<double>(m_defaultLayoutSize.height()) / contentHeight : 1.0;
-    }
-
-    return contentWidth > 0.0 ? static_cast<double>(m_actualVisibleWidth) / contentWidth : 1.0;
+    return std::max(zoomToFitScale, minimumZoomToFitScale);
 }
 
 double WebPage::zoomToFitScale() const

Modified: trunk/Source/WebKit/blackberry/ChangeLog (120472 => 120473)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-06-15 16:57:11 UTC (rev 120472)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-06-15 17:10:06 UTC (rev 120473)
@@ -1,3 +1,30 @@
+2012-06-15  Jacky Jiang  <[email protected]>
+
+        [BlackBerry] Certain web pages (i.e., http://www.cloudtweaks.com/) are allowed to be wider than the screen
+        https://bugs.webkit.org/show_bug.cgi?id=89211
+
+        Reviewed by Rob Buis.
+        Patch by Jacky Jiang <[email protected]>
+
+        PR: 135215
+        Make simpler rules for zoom to fit scale:
+        - Zoom to fit horizontally first without clamping the contents width.
+        - Zoom to fit vertically instead without clamping the contents height
+          if the horizontal zoom to fit can cause a grey area below the web
+          page. Get rid of the virtual viewport guard as there may be cases
+          that zooming can cause a grey area without a virtual viewport.
+        - Clamp the scale by the minimum zoom to fit scale 0.25 and apply
+          this rule to image documents as well. This minimum scale can be
+          changed if there is a better vaule in the future.
+        In this way, we can get rid of the issue that many web pages don't fit
+        the screen.
+
+        Reviewed internally by Arvid Nilsson.
+
+        * Api/WebPage.cpp:
+        (WebKit):
+        (BlackBerry::WebKit::WebPagePrivate::zoomToFitScale):
+
 2012-06-15  Yong Li  <[email protected]>
 
         [BlackBerry] Remove BackingStoreClient::scrollsHorizontally/scrollsVeritically()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to