Chromium Code Reviews| Index: Source/core/rendering/RenderBlock.cpp |
| diff --git a/Source/core/rendering/RenderBlock.cpp b/Source/core/rendering/RenderBlock.cpp |
| index 38838c1289af1a2f928bb616ffd4224e5833b54c..bb6a4328893c4daac90fbf1c08a14fd7f119b646 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) |
|
esprehn
2014/01/15 01:27:45
RenerStyle& blockStyle
shatch
2014/01/15 19:28:52
Done.
|
| +{ |
| + 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()->removeRenderObject(this); |
| 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()->removeRenderObject(this); |
|
esprehn
2014/01/15 01:27:45
This isn't good, you're going to hit the hash tabl
shatch
2014/01/15 19:28:52
Done.
|
| + else |
| + 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()->notifyImageResourceVisibility(*it, status); |
| + |
| + return true; |
| } |
| void RenderBlock::relayoutShapeDescendantIfMoved(RenderBlock* child, LayoutSize offset) |