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

Side by Side Diff: Source/core/layout/LayoutImage.cpp

Issue 1026823002: [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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com)
6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. 9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved.
10 * 10 *
(...skipping 21 matching lines...) Expand all
32 #include "core/editing/FrameSelection.h" 32 #include "core/editing/FrameSelection.h"
33 #include "core/fetch/ImageResource.h" 33 #include "core/fetch/ImageResource.h"
34 #include "core/fetch/ResourceLoadPriorityOptimizer.h" 34 #include "core/fetch/ResourceLoadPriorityOptimizer.h"
35 #include "core/fetch/ResourceLoader.h" 35 #include "core/fetch/ResourceLoader.h"
36 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
37 #include "core/html/HTMLAreaElement.h" 37 #include "core/html/HTMLAreaElement.h"
38 #include "core/html/HTMLImageElement.h" 38 #include "core/html/HTMLImageElement.h"
39 #include "core/html/HTMLInputElement.h" 39 #include "core/html/HTMLInputElement.h"
40 #include "core/html/HTMLMapElement.h" 40 #include "core/html/HTMLMapElement.h"
41 #include "core/layout/HitTestResult.h" 41 #include "core/layout/HitTestResult.h"
42 #include "core/layout/LayoutPart.h"
42 #include "core/layout/LayoutView.h" 43 #include "core/layout/LayoutView.h"
43 #include "core/layout/PaintInfo.h" 44 #include "core/layout/PaintInfo.h"
44 #include "core/layout/TextRunConstructor.h" 45 #include "core/layout/TextRunConstructor.h"
45 #include "core/page/Page.h" 46 #include "core/page/Page.h"
46 #include "core/paint/ImagePainter.h" 47 #include "core/paint/ImagePainter.h"
47 #include "core/svg/graphics/SVGImage.h" 48 #include "core/svg/graphics/SVGImage.h"
48 #include "platform/fonts/Font.h" 49 #include "platform/fonts/Font.h"
49 #include "platform/fonts/FontCache.h" 50 #include "platform/fonts/FontCache.h"
50 51
51 namespace blink { 52 namespace blink {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // early. It may be that layout hasn't even taken place once yet. 169 // early. It may be that layout hasn't even taken place once yet.
169 updateInnerContentRect(); 170 updateInnerContentRect();
170 } 171 }
171 172
172 setShouldDoFullPaintInvalidation(); 173 setShouldDoFullPaintInvalidation();
173 174
174 // Tell any potential compositing layers that the image needs updating. 175 // Tell any potential compositing layers that the image needs updating.
175 contentChanged(ImageChanged); 176 contentChanged(ImageChanged);
176 } 177 }
177 178
179 bool LayoutImage::intersectsVisibleViewport()
180 {
181 LayoutRect rect = visualOverflowRect();
182 LayoutView* layoutView = view();
183 while (layoutView->frame()->ownerLayoutObject())
184 layoutView = layoutView->frame()->ownerLayoutObject()->view();
185 mapRectToPaintInvalidationBacking(layoutView, rect, 0);
186 return rect.intersects(LayoutRect(layoutView->frameView()->visualViewportRec t()));
187 }
188
189 PaintInvalidationReason LayoutImage::invalidatePaintIfNeeded(PaintInvalidationSt ate& paintInvalidationState, const LayoutBoxModelObject& paintInvalidationContai ner)
190 {
191 if (!RuntimeEnabledFeatures::slimmingPaintEnabled())
192 return LayoutReplaced::invalidatePaintIfNeeded(paintInvalidationState, p aintInvalidationContainer);
193
194 if (!imageResource() || !imageResource()->image() || !imageResource()->image ()->maybeAnimated()
195 || intersectsVisibleViewport()) {
196 return LayoutReplaced::invalidatePaintIfNeeded(paintInvalidationState, p aintInvalidationContainer);
197 }
198
199 return PaintInvalidationDelayedFull;
200 }
201
202
178 void LayoutImage::notifyFinished(Resource* newImage) 203 void LayoutImage::notifyFinished(Resource* newImage)
179 { 204 {
180 if (!m_imageResource) 205 if (!m_imageResource)
181 return; 206 return;
182 207
183 if (documentBeingDestroyed()) 208 if (documentBeingDestroyed())
184 return; 209 return;
185 210
186 invalidateBackgroundObscurationStatus(); 211 invalidateBackgroundObscurationStatus();
187 212
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 return 0; 388 return 0;
364 389
365 ImageResource* cachedImage = m_imageResource->cachedImage(); 390 ImageResource* cachedImage = m_imageResource->cachedImage();
366 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) 391 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( ))
367 return toSVGImage(cachedImage->image())->embeddedContentBox(); 392 return toSVGImage(cachedImage->image())->embeddedContentBox();
368 393
369 return 0; 394 return 0;
370 } 395 }
371 396
372 } // namespace blink 397 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutImage.h ('k') | Source/core/layout/LayoutMultiColumnSpannerPlaceholder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698