| Index: Source/core/rendering/RenderBlock.cpp
|
| diff --git a/Source/core/rendering/RenderBlock.cpp b/Source/core/rendering/RenderBlock.cpp
|
| index 5f0eb9c7f4b07ca76caf9e01d55a68562f1ef96b..17b01671130324d95200dc9288aba0cf605ab528 100644
|
| --- a/Source/core/rendering/RenderBlock.cpp
|
| +++ b/Source/core/rendering/RenderBlock.cpp
|
| @@ -32,6 +32,7 @@
|
| #include "core/dom/shadow/ShadowRoot.h"
|
| #include "core/editing/Editor.h"
|
| #include "core/editing/FrameSelection.h"
|
| +#include "core/fetch/ResourceLoadPriorityOptimizer.h"
|
| #include "core/frame/Frame.h"
|
| #include "core/frame/FrameView.h"
|
| #include "core/page/Page.h"
|
| @@ -58,6 +59,8 @@
|
| #include "core/rendering/RenderTheme.h"
|
| #include "core/rendering/RenderView.h"
|
| #include "core/rendering/shapes/ShapeOutsideInfo.h"
|
| +#include "core/rendering/style/ContentData.h"
|
| +#include "core/rendering/style/RenderStyle.h"
|
| #include "platform/geometry/FloatQuad.h"
|
| #include "platform/geometry/TransformState.h"
|
| #include "platform/graphics/GraphicsContextStateSaver.h"
|
| @@ -169,6 +172,19 @@ static void removeBlockFromDescendantAndContainerMaps(RenderBlock* block, Tracke
|
| }
|
| }
|
|
|
| +static void appendImageIfNotNull(Vector<ImageResource*>& imageResources, const StyleImage* styleImage)
|
| +{
|
| + if (styleImage && styleImage->cachedImage())
|
| + imageResources.append(styleImage->cachedImage());
|
| +}
|
| +
|
| +static void appendLayers(Vector<ImageResource*>& images, const FillLayer* styleLayer)
|
| +{
|
| + for (const FillLayer* layer = styleLayer; layer; layer = layer->next()) {
|
| + appendImageIfNotNull(images, layer->image());
|
| + }
|
| +}
|
| +
|
| RenderBlock::~RenderBlock()
|
| {
|
| if (hasColumns())
|
| @@ -1252,6 +1268,60 @@ void RenderBlock::layout()
|
| invalidateBackgroundObscurationStatus();
|
| }
|
|
|
| +void RenderBlock::didLayout(ResourceLoadPriorityOptimizer& optimizer)
|
| +{
|
| + RenderBox::didLayout(optimizer);
|
| + updateStyleImageLoadingPriorities(optimizer);
|
| +}
|
| +
|
| +void RenderBlock::didScroll(ResourceLoadPriorityOptimizer& optimizer)
|
| +{
|
| + 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());
|
| +
|
| + if (images.isEmpty())
|
| + return;
|
| +
|
| + LayoutRect viewBounds = viewRect();
|
| + LayoutRect objectBounds = 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);
|
| +
|
| + ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ?
|
| + ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer::NotVisible;
|
| +
|
| + for (Vector<ImageResource*>::iterator it = images.begin(), end = images.end(); it != end; ++it)
|
| + optimizer.notifyImageResourceVisibility(*it, status);
|
| +}
|
| +
|
| void RenderBlock::relayoutShapeDescendantIfMoved(RenderBlock* child, LayoutSize offset)
|
| {
|
| LayoutUnit left = isHorizontalWritingMode() ? offset.width() : offset.height();
|
|
|