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

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: 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
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 4e6ea451ddf87c2f79d158ea61560174f8cdd6c7..27c8ef9d7ab8361aef3d9e47731f6074d123c2ce 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -1351,6 +1351,31 @@ void LayoutBox::imageChanged(WrappedImagePtr image, const IntRect*)
invalidatePaintOfLayerRectsForImage(image, style()->maskLayers(), false);
}
+ResourcePriority LayoutBox::updatePriority(Resource*)
Nate Chapin 2015/10/07 19:40:40 Merge the basically identical logic in LayoutImage
esprehn 2015/10/08 05:39:11 You ignore the argument, why pass it at all? This
Nate Chapin 2015/10/08 21:26:37 I was thinking that the return value might depend
+{
+ 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()))

Powered by Google App Engine
This is Rietveld 408576698