Diff
Modified: branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog (179124 => 179125)
--- branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog 2015-01-26 18:33:31 UTC (rev 179124)
+++ branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog 2015-01-26 18:33:47 UTC (rev 179125)
@@ -1,5 +1,33 @@
2015-01-26 David Kilzer <[email protected]>
+ Merge r177135.
+
+ 2014-12-10 Chris Dumez <[email protected]>
+
+ http://omfgdogs.info/ only animates when you resize the window
+ https://bugs.webkit.org/show_bug.cgi?id=139435
+ <rdar://problem/19190493>
+
+ Reviewed by Simon Fraser.
+
+ Add layout tests to make sure a gif image is still animated if:
+ - It is used as a background image of a 0-height html element
+ - It is used as a background image of a 0-height body element that
+ is delegated to the root (because the root has no background)
+
+ Also add a layout test to make sure we still stop the gif animation
+ if it is used as background image of a body that is outside the
+ viewport.
+
+ * fast/images/animated-gif-body-delegated-background-image-expected.txt: Added.
+ * fast/images/animated-gif-body-delegated-background-image.html: Added.
+ * fast/images/animated-gif-body-outside-viewport-expected.txt: Added.
+ * fast/images/animated-gif-body-outside-viewport.html: Added.
+ * fast/images/animated-gif-html-background-image-expected.txt: Added.
+ * fast/images/animated-gif-html-background-image.html: Added.
+
+2015-01-26 David Kilzer <[email protected]>
+
Merge r177292.
2014-12-15 Myles C. Maxfield <[email protected]>
Added: branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-body-delegated-background-image-expected.txt (0 => 179125)
--- branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-body-delegated-background-image-expected.txt (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-body-delegated-background-image-expected.txt 2015-01-26 18:33:47 UTC (rev 179125)
@@ -0,0 +1,11 @@
+Make sure the background image of the body element is animated if the body has 0 height and the background is delegated to the root
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS bodyHeight is "0px"
+PASS isBackgroundAnimated is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-body-delegated-background-image.html (0 => 179125)
--- branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-body-delegated-background-image.html (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-body-delegated-background-image.html 2015-01-26 18:33:47 UTC (rev 179125)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body style="background-image: url('resources/animated.gif'); background-repeat: repeat; height: 100%; width: 100%;" _onload_="runTest()">
+<script>
+// The test passes if the background image is animated.
+jsTestIsAsync = true;
+
+function checkBackgroundAnimated() {
+ isBackgroundAnimated = !internals.hasPausedImageAnimations(document.body);
+ bodyHeight = window.getComputedStyle(document.body)["height"];
+ description("Make sure the background image of the body element is animated if the body has 0 height and the background is delegated to the root");
+ shouldBeEqualToString("bodyHeight", "0px");
+ shouldBeTrue("isBackgroundAnimated");
+ finishJSTest();
+}
+
+function imageLoaded() {
+ setTimeout(checkBackgroundAnimated, 200);
+}
+
+function runTest() {
+ if (!window.internals)
+ return;
+
+ var img = new Image();
+ // Make sure the image is loaded before we check if it is animated.
+ img._onload_ = imageLoaded;
+ img.src = ""
+}
+</script>
+<script src=""
+</body>
+</html>
Added: branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-body-outside-viewport-expected.txt (0 => 179125)
--- branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-body-outside-viewport-expected.txt (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-body-outside-viewport-expected.txt 2015-01-26 18:33:47 UTC (rev 179125)
@@ -0,0 +1,12 @@
+Make sure the background image of a body element that is outside the viewport is not animated
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS isBackgroundAnimated is false
+Scroll down so that the body becomes visible.
+PASS isBackgroundAnimated is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-body-outside-viewport.html (0 => 179125)
--- branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-body-outside-viewport.html (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-body-outside-viewport.html 2015-01-26 18:33:47 UTC (rev 179125)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html style="background-color: green; width: 1600px; height: 1200px">
+<head>
+<script src=""
+</head>
+<body style="background-image: url('resources/animated.gif'); background-repeat: repeat; position: relative; left: 0px; top: 700px; width: 200px; height: 200px" _onload_="runTest()">
+<script>
+jsTestIsAsync = true;
+
+function checkBackgroundAnimated() {
+ isBackgroundAnimated = !internals.hasPausedImageAnimations(document.body);
+ shouldBeTrue("isBackgroundAnimated");
+ finishJSTest();
+}
+
+function checkBackgroundNotAnimated() {
+ isBackgroundAnimated = !internals.hasPausedImageAnimations(document.body);
+ description("Make sure the background image of a body element that is outside the viewport is not animated");
+ shouldBeFalse("isBackgroundAnimated");
+
+ debug("Scroll down so that the body becomes visible.");
+ window.scrollBy(0, 600);
+ setTimeout(checkBackgroundAnimated, 0);
+}
+
+function imageLoaded() {
+ setTimeout(checkBackgroundNotAnimated, 200);
+}
+
+function runTest() {
+ if (!window.internals)
+ return;
+
+ var img = new Image();
+ // Make sure the image is loaded before we check if it is animated.
+ img._onload_ = imageLoaded;
+ img.src = ""
+}
+</script>
+<script src=""
+</body>
+</html>
Added: branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-html-background-image-expected.txt (0 => 179125)
--- branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-html-background-image-expected.txt (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-html-background-image-expected.txt 2015-01-26 18:33:47 UTC (rev 179125)
@@ -0,0 +1,11 @@
+Make sure the background image of the html element is animated if the html element has 0 height
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS htmlHeight is "0px"
+PASS isBackgroundAnimated is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-html-background-image.html (0 => 179125)
--- branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-html-background-image.html (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/fast/images/animated-gif-html-background-image.html 2015-01-26 18:33:47 UTC (rev 179125)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html style="background-image: url('resources/animated.gif'); background-repeat: repeat; height: 0">
+<head>
+<script src=""
+</head>
+<body _onload_="runTest()">
+<script>
+jsTestIsAsync = true;
+
+function checkBackgroundAnimated() {
+ isBackgroundAnimated = !internals.hasPausedImageAnimations(document.documentElement);
+ htmlHeight = window.getComputedStyle(document.documentElement)["height"];
+ description("Make sure the background image of the html element is animated if the html element has 0 height");
+ shouldBeEqualToString("htmlHeight", "0px");
+ shouldBeTrue("isBackgroundAnimated");
+ finishJSTest();
+}
+
+function imageLoaded() {
+ setTimeout(checkBackgroundAnimated, 200);
+}
+
+function runTest() {
+ if (!window.internals)
+ return;
+
+ var img = new Image();
+ // Make sure the image is loaded before we check if it is animated.
+ img._onload_ = imageLoaded;
+ img.src = ""
+}
+</script>
+<script src=""
+</body>
+</html>
Modified: branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog (179124 => 179125)
--- branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog 2015-01-26 18:33:31 UTC (rev 179124)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog 2015-01-26 18:33:47 UTC (rev 179125)
@@ -1,5 +1,39 @@
2015-01-26 David Kilzer <[email protected]>
+ Merge r177135.
+
+ 2014-12-10 Chris Dumez <[email protected]>
+
+ http://omfgdogs.info/ only animates when you resize the window
+ https://bugs.webkit.org/show_bug.cgi?id=139435
+ <rdar://problem/19190493>
+
+ Reviewed by Simon Fraser.
+
+ After r163928, we would fail to animate a gif if:
+ - it is used as a background image of a 0-height html element
+ - it is used as a background image of a 0-height body element whose
+ background is delegated to the root (because the root has no
+ background).
+
+ This is because in such cases, shouldRepaintForImageAnimation()
+ should use the background rect instead of the renderer's overflow
+ rect to determine if the image is inside the viewport. Both cases
+ are addressed in this patch.
+
+ Tests: fast/images/animated-gif-body-delegated-background-image.html
+ fast/images/animated-gif-body-outside-viewport.html
+ fast/images/animated-gif-html-background-image.html
+
+ * rendering/RenderElement.cpp:
+ (WebCore::shouldRepaintForImageAnimation):
+ * testing/Internals.cpp:
+ (WebCore::Internals::hasPausedImageAnimations):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
+2015-01-26 David Kilzer <[email protected]>
+
Merge r177292.
2014-12-15 Myles C. Maxfield <[email protected]>
Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderElement.cpp (179124 => 179125)
--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderElement.cpp 2015-01-26 18:33:31 UTC (rev 179124)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderElement.cpp 2015-01-26 18:33:47 UTC (rev 179125)
@@ -1298,9 +1298,24 @@
return false;
if (renderer.style().visibility() != VISIBLE)
return false;
- if (!visibleRect.intersects(renderer.absoluteBoundingBoxRect()))
+ if (renderer.view().frameView().isOffscreen())
return false;
+ // Use background rect if we are the root or if we are the body and the background is propagated to the root.
+ // FIXME: This is overly conservative as the image may not be a background-image, in which case it will not
+ // be propagated to the root. At this point, we unfortunately don't have access to the image anymore so we
+ // can no longer check if it is a background image.
+ bool backgroundIsPaintedByRoot = renderer.isRoot();
+ if (renderer.isBody()) {
+ // FIXME: Should share body background propagation code.
+ RenderElement* rootObject = renderer.document().documentElement() ? renderer.document().documentElement()->renderer() : nullptr;
+ backgroundIsPaintedByRoot = &rootObject->rendererForRootBackground() == &renderer;
+
+ }
+ LayoutRect backgroundPaintingRect = backgroundIsPaintedByRoot ? renderer.view().backgroundRect(&renderer.view()) : renderer.absoluteClippedOverflowRect();
+ if (!visibleRect.intersects(enclosingIntRect(backgroundPaintingRect)))
+ return false;
+
return true;
}
@@ -1308,6 +1323,9 @@
{
auto visibleRect = view().frameView().visibleContentRect();
if (!shouldRepaintForImageAnimation(*this, visibleRect)) {
+ // FIXME: It would be better to pass the image along with the renderer
+ // so that we can be smarter about detecting if the image is inside the
+ // viewport in repaintForPausedImageAnimationsIfNeeded().
view().addRendererWithPausedImageAnimations(*this);
return;
}
Modified: branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.cpp (179124 => 179125)
--- branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.cpp 2015-01-26 18:33:31 UTC (rev 179124)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.cpp 2015-01-26 18:33:47 UTC (rev 179125)
@@ -525,6 +525,15 @@
return representation;
}
+bool Internals::hasPausedImageAnimations(Element* element, ExceptionCode& ec)
+{
+ if (!element) {
+ ec = INVALID_ACCESS_ERR;
+ return false;
+ }
+ return element->renderer() && element->renderer()->hasPausedImageAnimations();
+}
+
PassRefPtr<CSSComputedStyleDeclaration> Internals::computedStyleIncludingVisitedInfo(Node* node, ExceptionCode& ec) const
{
if (!node) {
Modified: branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.h (179124 => 179125)
--- branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.h 2015-01-26 18:33:31 UTC (rev 179124)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.h 2015-01-26 18:33:47 UTC (rev 179125)
@@ -73,6 +73,7 @@
static void resetToConsistentState(Page*);
String elementRenderTreeAsText(Element*, ExceptionCode&);
+ bool hasPausedImageAnimations(Element*, ExceptionCode&);
String address(Node*);
Modified: branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.idl (179124 => 179125)
--- branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.idl 2015-01-26 18:33:31 UTC (rev 179124)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.idl 2015-01-26 18:33:47 UTC (rev 179125)
@@ -29,6 +29,9 @@
] interface Internals {
DOMString address(Node node);
+ // Animated image pausing testing.
+ [RaisesException] boolean hasPausedImageAnimations(Element element);
+
[RaisesException] DOMString elementRenderTreeAsText(Element element);
boolean isPreloaded(DOMString url);
boolean isLoadingFromMemoryCache(DOMString url);