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

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

Issue 1304063016: Refactor the API for setting dynamic resource load priorities (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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
« no previous file with comments | « Source/core/layout/LayoutBox.h ('k') | Source/core/layout/LayoutImage.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutBox.cpp
diff --git a/Source/core/layout/LayoutBox.cpp b/Source/core/layout/LayoutBox.cpp
index 2a122f6b790c015e80886a9b36a752d39729caae..c68e9d1a31ae2c62ced5fbe02223c209b8f34bda 100644
--- a/Source/core/layout/LayoutBox.cpp
+++ b/Source/core/layout/LayoutBox.cpp
@@ -1342,6 +1342,31 @@ void LayoutBox::imageChanged(WrappedImagePtr image, const IntRect*)
invalidatePaintOfLayerRectsForImage(image, style()->maskLayers(), false);
}
+ResourcePriority LayoutBox::updatePriority(Resource*)
+{
+ LayoutRect viewBounds = viewRect();
+ LayoutRect objectBounds = LayoutRect(absoluteContentBox());
+
+ // The object bounds might be empty right now, so intersects will fail since it doesn't deal
+ // with empty rects. Use LayoutRect::contains in that case.
+ bool isVisible;
+ if (!objectBounds.isEmpty())
+ isVisible = viewBounds.intersects(objectBounds);
+ else
+ isVisible = viewBounds.contains(objectBounds);
+
+ LayoutRect screenRect;
+ if (!objectBounds.isEmpty()) {
+ screenRect = viewBounds;
+ screenRect.intersect(objectBounds);
+ }
+
+ int screenArea = 0;
+ if (!screenRect.isEmpty() && isVisible)
+ screenArea = static_cast<uint32_t>(screenRect.width() * screenRect.height());
+ return ResourcePriority(isVisible ? ResourcePriority::Visible : ResourcePriority::NotVisible, screenArea);
+}
+
bool LayoutBox::invalidatePaintOfLayerRectsForImage(WrappedImagePtr image, const FillLayer& layers, bool drawingBackground)
{
if (drawingBackground && (isDocumentElement() || backgroundStolenForBeingBody()))
« no previous file with comments | « Source/core/layout/LayoutBox.h ('k') | Source/core/layout/LayoutImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698