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

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

Issue 1378743002: Refactor the API for setting dynamic resource load priorities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better names / cleanup Created 5 years, 2 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: third_party/WebKit/Source/core/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index ad71db13458161a2ef732ee814a8300450a65c6b..2852e51bd4b59ce7431c9bd8e6d5d0a9d1c4897d 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -1356,6 +1356,31 @@ void LayoutBox::imageChanged(WrappedImagePtr image, const IntRect*)
invalidatePaintOfLayerRectsForImage(image, style()->maskLayers(), false);
}
+ResourcePriority LayoutBox::computeResourcePriority() const
+{
+ 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 | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698