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

Unified Diff: Source/core/rendering/RenderBlock.cpp

Issue 131233003: Refactor ResourceLoadPriorityOptimizer to avoid walking render tree (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Changes from review. Created 6 years, 11 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: Source/core/rendering/RenderBlock.cpp
diff --git a/Source/core/rendering/RenderBlock.cpp b/Source/core/rendering/RenderBlock.cpp
index 38838c1289af1a2f928bb616ffd4224e5833b54c..b3a65b9bf6e1533664c38be4bcfaef6dcbbd4a11 100644
--- a/Source/core/rendering/RenderBlock.cpp
+++ b/Source/core/rendering/RenderBlock.cpp
@@ -182,8 +182,11 @@ static void removeBlockFromDescendantAndContainerMaps(RenderBlock* block, Tracke
static void appendImageIfNotNull(Vector<ImageResource*>& imageResources, const StyleImage* styleImage)
{
- if (styleImage && styleImage->cachedImage())
- imageResources.append(styleImage->cachedImage());
+ if (styleImage && styleImage->cachedImage()) {
+ ImageResource* imageResource = styleImage->cachedImage();
+ if (imageResource && !imageResource->isLoaded())
+ imageResources.append(styleImage->cachedImage());
+ }
}
static void appendLayers(Vector<ImageResource*>& images, const FillLayer* styleLayer)
@@ -193,8 +196,26 @@ static void appendLayers(Vector<ImageResource*>& images, const FillLayer* styleL
}
}
+static void appendImagesFromStyle(Vector<ImageResource*>& images, RenderStyle& blockStyle)
+{
+ appendLayers(images, blockStyle.backgroundLayers());
+ appendLayers(images, blockStyle.maskLayers());
+
+ const ContentData* contentData = blockStyle.contentData();
+ if (contentData && contentData->isImage()) {
+ const ImageContentData* imageContentData = static_cast<const ImageContentData*>(contentData);
+ appendImageIfNotNull(images, imageContentData->image());
+ }
+ if (blockStyle.boxReflect())
+ appendImageIfNotNull(images, blockStyle.boxReflect()->mask().image());
+ appendImageIfNotNull(images, blockStyle.listStyleImage());
+ appendImageIfNotNull(images, blockStyle.borderImageSource());
+ appendImageIfNotNull(images, blockStyle.maskBoxImageSource());
+}
+
RenderBlock::~RenderBlock()
{
+ ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->removeRenderObject(this);
ojan 2014/01/23 06:32:59 Is this needed with the RenderObject destructor al
if (hasColumns())
gColumnInfoMap->take(this);
if (gPercentHeightDescendantsMap)
@@ -326,6 +347,15 @@ void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty
// It's possible for our border/padding to change, but for the overall logical width of the block to
// end up being the same. We keep track of this change so in layoutBlock, we can know to set relayoutChildren=true.
m_hasBorderOrPaddingLogicalWidthChanged = oldStyle && diff == StyleDifferenceLayout && needsLayout() && borderOrPaddingLogicalWidthChanged(oldStyle, newStyle);
+
+ // If the style has unloaded images, want to notify the ResourceLoadPriorityOptimizer so that
+ // network priorities can be set.
+ Vector<ImageResource*> images;
+ appendImagesFromStyle(images, *newStyle);
+ if (images.isEmpty())
+ ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->removeRenderObject(this);
+ else
+ ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->addRenderObject(this);
}
RenderBlock* RenderBlock::continuationBefore(RenderObject* beforeChild)
@@ -1266,42 +1296,13 @@ void RenderBlock::layout()
invalidateBackgroundObscurationStatus();
}
-void RenderBlock::didLayout(ResourceLoadPriorityOptimizer& optimizer)
-{
- RenderBox::didLayout(optimizer);
- updateStyleImageLoadingPriorities(optimizer);
-}
-
-void RenderBlock::didScroll(ResourceLoadPriorityOptimizer& optimizer)
+bool RenderBlock::updateImageLoadingPriorities()
{
- RenderBox::didScroll(optimizer);
- updateStyleImageLoadingPriorities(optimizer);
-}
-
-void RenderBlock::updateStyleImageLoadingPriorities(ResourceLoadPriorityOptimizer& optimizer)
-{
- RenderStyle* blockStyle = style();
- if (!blockStyle)
- return;
-
Vector<ImageResource*> images;
-
- appendLayers(images, blockStyle->backgroundLayers());
- appendLayers(images, blockStyle->maskLayers());
-
- const ContentData* contentData = blockStyle->contentData();
- if (contentData && contentData->isImage()) {
- const ImageContentData* imageContentData = static_cast<const ImageContentData*>(contentData);
- appendImageIfNotNull(images, imageContentData->image());
- }
- if (blockStyle->boxReflect())
- appendImageIfNotNull(images, blockStyle->boxReflect()->mask().image());
- appendImageIfNotNull(images, blockStyle->listStyleImage());
- appendImageIfNotNull(images, blockStyle->borderImageSource());
- appendImageIfNotNull(images, blockStyle->maskBoxImageSource());
+ appendImagesFromStyle(images, *style());
if (images.isEmpty())
- return;
+ return false;
LayoutRect viewBounds = viewRect();
LayoutRect objectBounds = absoluteContentBox();
@@ -1317,7 +1318,9 @@ void RenderBlock::updateStyleImageLoadingPriorities(ResourceLoadPriorityOptimize
ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer::NotVisible;
for (Vector<ImageResource*>::iterator it = images.begin(), end = images.end(); it != end; ++it)
- optimizer.notifyImageResourceVisibility(*it, status);
+ ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyImageResourceVisibility(*it, status);
+
+ return true;
}
void RenderBlock::relayoutShapeDescendantIfMoved(RenderBlock* child, LayoutSize offset)

Powered by Google App Engine
This is Rietveld 408576698