Modified: trunk/Source/WebKit/ChangeLog (102948 => 102949)
--- trunk/Source/WebKit/ChangeLog 2011-12-15 17:21:56 UTC (rev 102948)
+++ trunk/Source/WebKit/ChangeLog 2011-12-15 17:33:03 UTC (rev 102949)
@@ -1,3 +1,23 @@
+2011-12-15 Adam Treat <[email protected]>
+
+ Reviewed by Rob Buis.
+
+ https://bugs.webkit.org/show_bug.cgi?id=74609
+ PR 122703
+
+ For certain configurations of webpage content and zoom level we were
+ failing to produce a valid backingstore matrix by being to strict on
+ whether a given matrix fits the preferred matrix orientation.
+ This patch fixes this by insisting on storing a candidate divisor
+ whether or not it agrees with the preferred matrix orientation and then
+ comparing all subsequent divisors.
+
+ * blackberry/Api/BackingStore.cpp:
+ (BlackBerry::WebKit::divisorIsPerfectWidth):
+ (BlackBerry::WebKit::divisorIsPerfectHeight):
+ (BlackBerry::WebKit::divisorIsPreferredDirection):
+ (BlackBerry::WebKit::bestDivisor):
+
2011-12-14 Jacky Jiang <[email protected]>
[BlackBerry] Refactor code and add some debug messages in backing store
Modified: trunk/Source/WebKit/blackberry/Api/BackingStore.cpp (102948 => 102949)
--- trunk/Source/WebKit/blackberry/Api/BackingStore.cpp 2011-12-15 17:21:56 UTC (rev 102948)
+++ trunk/Source/WebKit/blackberry/Api/BackingStore.cpp 2011-12-15 17:33:03 UTC (rev 102949)
@@ -86,6 +86,23 @@
return divisors;
}
+static bool divisorIsPerfectWidth(Divisor divisor, Platform::IntSize size, int tileWidth)
+{
+ return size.width() <= divisor.first * tileWidth && abs(size.width() - divisor.first * tileWidth) < tileWidth;
+}
+
+static bool divisorIsPerfectHeight(Divisor divisor, Platform::IntSize size, int tileHeight)
+{
+ return size.height() <= divisor.second * tileHeight && abs(size.height() - divisor.second * tileHeight) < tileHeight;
+}
+
+static bool divisorIsPreferredDirection(Divisor divisor, BackingStorePrivate::TileMatrixDirection direction)
+{
+ if (direction == BackingStorePrivate::Vertical)
+ return divisor.second > divisor.first;
+ return divisor.first > divisor.second;
+}
+
// Compute best divisor given the ratio determined by size.
static Divisor bestDivisor(Platform::IntSize size, int tileWidth, int tileHeight,
int minimumNumberOfTilesWide, int minimumNumberOfTilesHigh,
@@ -110,35 +127,34 @@
for (size_t i = 0; i < divisorList.size(); ++i) {
Divisor divisor = divisorList[i];
- bool divisorWidthIsPerfect = size.width() <= divisor.first * tileWidth && abs(size.width() - divisor.first * tileWidth) < tileWidth;
- bool divisorHeightIsPerfect = size.height() <= divisor.second * tileHeight && abs(size.height() - divisor.second * tileHeight) < tileHeight;
- bool divisorWidthIsValid = divisor.first >= minimumNumberOfTilesWide || divisorWidthIsPerfect;
- bool divisorHeightIsValid = divisor.second >= minimumNumberOfTilesHigh || divisorHeightIsPerfect;
- if (!divisorWidthIsValid || !divisorHeightIsValid)
+ const bool isPerfectWidth = divisorIsPerfectWidth(divisor, size, tileWidth);
+ const bool isPerfectHeight = divisorIsPerfectHeight(divisor, size, tileHeight);
+ const bool isValidWidth = divisor.first >= minimumNumberOfTilesWide || isPerfectWidth;
+ const bool isValidHeight = divisor.second >= minimumNumberOfTilesHigh || isPerfectHeight;
+ if (!isValidWidth || !isValidHeight)
continue;
- if (divisor.first > divisor.second && direction == BackingStorePrivate::Vertical && !divisorHeightIsPerfect)
- continue;
-
- if (divisor.second > divisor.first && direction == BackingStorePrivate::Horizontal && !divisorWidthIsPerfect)
- continue;
-
- if (divisorWidthIsPerfect || divisorHeightIsPerfect) {
+ if (isPerfectWidth || isPerfectHeight) {
bestDivisor = divisor; // Found a perfect fit!
#if DEBUG_TILEMATRIX
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical, "bestDivisor found perfect size widthPerfect=%s heightPerfect=%s",
- divisorWidthIsPerfect ? "true" : "false",
- divisorHeightIsPerfect ? "true" : "false");
+ BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical, "bestDivisor found perfect size isPerfectWidth=%s isPerfectHeight=%s",
+ isPerfectWidth ? "true" : "false",
+ isPerfectHeight ? "true" : "false");
#endif
break;
}
// Store basis of comparison.
- if (!bestDivisor.first && !bestDivisor.second) {
+ if (!bestDivisor.first || !bestDivisor.second) {
bestDivisor = divisor;
continue;
}
+ // If the current best divisor agrees with the preferred tile matrix direction,
+ // then continue if the current candidate does not.
+ if (divisorIsPreferredDirection(bestDivisor, direction) && !divisorIsPreferredDirection(divisor, direction))
+ continue;
+
// Compare ratios.
float diff1 = fabs((static_cast<float>(divisor.first) / static_cast<float>(divisor.second)) - ratio);
float diff2 = fabs((static_cast<float>(bestDivisor.first) / static_cast<float>(bestDivisor.second)) - ratio);