Chromium Code Reviews| 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())) |