Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1321)

Unified Diff: Source/core/layout/LayoutImage.cpp

Issue 1008043002: [S.P.] Don't draw frames of animated images that are offscreen. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/layout/LayoutImage.cpp
diff --git a/Source/core/layout/LayoutImage.cpp b/Source/core/layout/LayoutImage.cpp
index 047eb6b8a95183bb4146c7c6b91b1f001c26e477..92e92d2ae409206b6c09447c5227012af0f99493 100644
--- a/Source/core/layout/LayoutImage.cpp
+++ b/Source/core/layout/LayoutImage.cpp
@@ -40,6 +40,7 @@
#include "core/html/HTMLMapElement.h"
#include "core/layout/HitTestResult.h"
#include "core/layout/Layer.h"
+#include "core/layout/LayoutPart.h"
#include "core/layout/LayoutView.h"
#include "core/layout/PaintInfo.h"
#include "core/layout/TextRunConstructor.h"
@@ -176,6 +177,30 @@ void LayoutImage::invalidatePaintAndMarkForLayoutIfNeeded()
contentChanged(ImageChanged);
}
+bool LayoutImage::rectIntersectsVisibleViewport(const LayoutRect& localRect)
+{
+ LayoutRect rect = localRect;
+ LayoutView* layoutView = view();
+ while (layoutView->frame()->ownerLayoutObject())
+ layoutView = layoutView->frame()->ownerLayoutObject()->view();
+ mapRectToPaintInvalidationBacking(layoutView, rect, 0);
+ return rect.intersects(LayoutRect(layoutView->frameView()->visualViewportRect()));
+}
+
+PaintInvalidationReason LayoutImage::invalidatePaintIfNeeded(const PaintInvalidationState& paintInvalidationState, const LayoutBoxModelObject& paintInvalidationContainer)
+{
+ if (!RuntimeEnabledFeatures::slimmingPaintEnabled())
+ return LayoutReplaced::invalidatePaintIfNeeded(paintInvalidationState, paintInvalidationContainer);
+
+ if (!imageResource() || !imageResource()->image() || !imageResource()->image()->maybeAnimated()
+ || rectIntersectsVisibleViewport(visualOverflowRect())) {
+ return LayoutReplaced::invalidatePaintIfNeeded(paintInvalidationState, paintInvalidationContainer);
+ }
+
+ return PaintInvalidationDelayedFull;
chrishtr 2015/03/16 23:07:41 Since this method overrides invalidatePaintIfNeede
chrishtr 2015/03/17 23:55:56 Correct. That is the intention of the CL.
+}
+
+
void LayoutImage::notifyFinished(Resource* newImage)
{
if (!m_imageResource)

Powered by Google App Engine
This is Rietveld 408576698