Modified: trunk/LayoutTests/ChangeLog (137367 => 137368)
--- trunk/LayoutTests/ChangeLog 2012-12-11 23:16:18 UTC (rev 137367)
+++ trunk/LayoutTests/ChangeLog 2012-12-11 23:22:05 UTC (rev 137368)
@@ -1,3 +1,16 @@
+2012-12-11 Xianzhu Wang <[email protected]>
+
+ Incorrect position of layers for fixed position elements when page is scaled smaller than viewport
+ https://bugs.webkit.org/show_bug.cgi?id=104294
+
+ Reviewed by James Robinson.
+
+ Test the case that a page containing a composited fixed position element originally bigger than the viewport
+ is scaled down to be smaller than the viewport.
+
+ * compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport.html: Added.
+ * compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport-expected.html: Added.
+
2012-12-11 Adam Klein <[email protected]>
Mark more tests as flaky for Chromium
Added: trunk/LayoutTests/compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport-expected.html (0 => 137368)
--- trunk/LayoutTests/compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport-expected.html (rev 0)
+++ trunk/LayoutTests/compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport-expected.html 2012-12-11 23:22:05 UTC (rev 137368)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+ body {
+ width: 1000px;
+ height: 800px;
+ }
+</style>
+<script>
+ if (window.internals)
+ window.internals.setPageScaleFactor(0.5, 0, 0);
+</script>
+</head>
+<body>
+ On success, the blue reference box should be invisible (covered by the fixed box).
+</body>
+</html>
Added: trunk/LayoutTests/compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport.html (0 => 137368)
--- trunk/LayoutTests/compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport.html (rev 0)
+++ trunk/LayoutTests/compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport.html 2012-12-11 23:22:05 UTC (rev 137368)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+ body {
+ width: 1000px;
+ height: 800px;
+ }
+ .reference {
+ position: absolute;
+ left: 51px;
+ top: 51px;
+ width: 98px;
+ height: 98px;
+ background-color: blue;
+ }
+ .fixed {
+ position: fixed;
+ left: 50px;
+ top: 50px;
+ width: 100px;
+ height: 100px;
+ background-color: white;
+ }
+</style>
+<script>
+ if (window.internals) {
+ window.internals.settings.setEnableCompositingForFixedPosition(true);
+ window.internals.settings.setFixedPositionCreatesStackingContext(true);
+ window.internals.setPageScaleFactor(0.5, 0, 0);
+ }
+</script>
+</head>
+<body>
+ On success, the blue reference box should be invisible (covered by the fixed box).
+ <div class="reference"></div>
+ <div class="fixed"></div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (137367 => 137368)
--- trunk/Source/WebCore/ChangeLog 2012-12-11 23:16:18 UTC (rev 137367)
+++ trunk/Source/WebCore/ChangeLog 2012-12-11 23:22:05 UTC (rev 137368)
@@ -1,3 +1,19 @@
+2012-12-11 Xianzhu Wang <[email protected]>
+
+ Incorrect position of layers for fixed position elements when page is scaled smaller than viewport
+ https://bugs.webkit.org/show_bug.cgi?id=104294
+
+ Reviewed by James Robinson.
+
+ Fixed issue in scrollOffsetForFixedPosition when contentRect is smaller than visibleContentRect.
+ This happens when a page originally bigger than viewport is scaled down to smaller than the viewport.
+
+ Test: compositing/geometry/fixed-position-composited-page-scale-smaller-than-viewport.html
+
+ * page/scrolling/ScrollingCoordinator.cpp:
+ (WebCore::fixedPositionScrollOffset): Moved common code in scrollOffsetForFixedPosition here. Fixed issue when contentsSize < visibleContentSize.
+ (WebCore::scrollOffsetForFixedPosition):
+
2012-12-11 Beth Dakin <[email protected]>
https://bugs.webkit.org/show_bug.cgi?id=104725
Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp (137367 => 137368)
--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp 2012-12-11 23:16:18 UTC (rev 137367)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp 2012-12-11 23:22:05 UTC (rev 137368)
@@ -65,37 +65,32 @@
return adoptRef(new ScrollingCoordinator(page));
}
-static int fixedPositionScrollOffset(int scrollPosition, int maxValue, int scrollOrigin, float dragFactor)
+static int fixedPositionScrollOffset(int visibleContentSize, int contentsSize, int scrollPosition, int scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame)
{
- if (!maxValue)
+ int maxValue = contentsSize - visibleContentSize;
+ if (maxValue <= 0)
return 0;
if (!scrollOrigin) {
- if (scrollPosition < 0)
- scrollPosition = 0;
- else if (scrollPosition > maxValue)
+ if (scrollPosition <= 0)
+ return 0;
+ if (scrollPosition > maxValue)
scrollPosition = maxValue;
} else {
- if (scrollPosition > 0)
- scrollPosition = 0;
- else if (scrollPosition < -maxValue)
+ if (scrollPosition >= 0)
+ return 0;
+ if (scrollPosition < -maxValue)
scrollPosition = -maxValue;
}
-
- return scrollPosition * dragFactor;
+
+ float dragFactor = fixedElementsLayoutRelativeToFrame ? 1 : (contentsSize - visibleContentSize * frameScaleFactor) / maxValue;
+ return scrollPosition * dragFactor / frameScaleFactor;
}
IntSize scrollOffsetForFixedPosition(const IntRect& visibleContentRect, const IntSize& contentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame)
{
- IntSize maxOffset(contentsSize.width() - visibleContentRect.width(), contentsSize.height() - visibleContentRect.height());
-
- FloatSize dragFactor = fixedElementsLayoutRelativeToFrame ? FloatSize(1, 1) : FloatSize(
- (contentsSize.width() - visibleContentRect.width() * frameScaleFactor) / maxOffset.width(),
- (contentsSize.height() - visibleContentRect.height() * frameScaleFactor) / maxOffset.height());
-
- int x = fixedPositionScrollOffset(scrollPosition.x(), maxOffset.width(), scrollOrigin.x(), dragFactor.width() / frameScaleFactor);
- int y = fixedPositionScrollOffset(scrollPosition.y(), maxOffset.height(), scrollOrigin.y(), dragFactor.height() / frameScaleFactor);
-
+ int x = fixedPositionScrollOffset(visibleContentRect.width(), contentsSize.width(), scrollPosition.x(), scrollOrigin.x(), frameScaleFactor, fixedElementsLayoutRelativeToFrame);
+ int y = fixedPositionScrollOffset(visibleContentRect.height(), contentsSize.height(), scrollPosition.y(), scrollOrigin.y(), frameScaleFactor, fixedElementsLayoutRelativeToFrame);
return IntSize(x, y);
}