Title: [134304] trunk/Source/WebKit/blackberry
- Revision
- 134304
- Author
- [email protected]
- Date
- 2012-11-12 14:22:13 -0800 (Mon, 12 Nov 2012)
Log Message
[BlackBerry] When opening an image it does not scale to fit our window
https://bugs.webkit.org/show_bug.cgi?id=101778
Jacky Jiang <[email protected]>.
Reviewed by Rob Buis.
Internally reviewed by Konrad Piascik.
PR: 230935
For image document, the actual image size can be different with the
contents size. Zoom the document based on the image width so that
images can fit the screen horizontally. Set 2.0 as the maximum zoom to
fit scale for image document so that very small images won't get
ridiculous large scales during the initial load.
* Api/WebPage.cpp:
(WebKit):
(BlackBerry::WebKit::WebPagePrivate::zoomToFitScale):
Modified Paths
Diff
Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (134303 => 134304)
--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2012-11-12 22:21:47 UTC (rev 134303)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2012-11-12 22:22:13 UTC (rev 134304)
@@ -72,6 +72,7 @@
#include "HTTPParsers.h"
#include "HistoryItem.h"
#include "IconDatabaseClientBlackBerry.h"
+#include "ImageDocument.h"
#include "InPageSearchManager.h"
#include "InRegionScrollableArea.h"
#include "InRegionScroller_p.h"
@@ -222,6 +223,7 @@
const double minimumExpandingRatio = 0.15;
const double minimumZoomToFitScale = 0.25;
+const double maximumImageDocumentZoomToFitScale = 2;
// Helper function to parse a URL and fill in missing parts.
static KURL parseUrl(const String& url)
@@ -1662,12 +1664,24 @@
double WebPagePrivate::zoomToFitScale() const
{
int contentWidth = contentsSize().width();
+
+ // For image document, zoom to fit the screen based on the actual image width
+ // instead of the contents width within a maximum scale .
+ Document* doc = m_page->mainFrame()->document();
+ bool isImageDocument = doc && doc->isImageDocument();
+ if (isImageDocument)
+ contentWidth = static_cast<ImageDocument*>(doc)->imageSize().width();
+
+ double zoomToFitScale = contentWidth > 0.0 ? static_cast<double>(m_actualVisibleWidth) / contentWidth : 1.0;
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;
+ zoomToFitScale = std::max(zoomToFitScale, minimumZoomToFitScale);
- return std::max(zoomToFitScale, minimumZoomToFitScale);
+ if (!isImageDocument)
+ return zoomToFitScale;
+
+ return std::min(zoomToFitScale, maximumImageDocumentZoomToFitScale);
}
double WebPagePrivate::initialScale() const
Modified: trunk/Source/WebKit/blackberry/ChangeLog (134303 => 134304)
--- trunk/Source/WebKit/blackberry/ChangeLog 2012-11-12 22:21:47 UTC (rev 134303)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2012-11-12 22:22:13 UTC (rev 134304)
@@ -1,3 +1,22 @@
+2012-11-12 Jacky Jiang <[email protected]>
+
+ [BlackBerry] When opening an image it does not scale to fit our window
+ https://bugs.webkit.org/show_bug.cgi?id=101778
+
+ Reviewed by Rob Buis.
+ Internally reviewed by Konrad Piascik.
+
+ PR: 230935
+ For image document, the actual image size can be different with the
+ contents size. Zoom the document based on the image width so that
+ images can fit the screen horizontally. Set 2.0 as the maximum zoom to
+ fit scale for image document so that very small images won't get
+ ridiculous large scales during the initial load.
+
+ * Api/WebPage.cpp:
+ (WebKit):
+ (BlackBerry::WebKit::WebPagePrivate::zoomToFitScale):
+
2012-11-12 Nima Ghanavatian <[email protected]>
[BlackBerry] Use keyevents instead of editor commands for backspace
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes