| Index: Source/core/fetch/ResourceLoadPriorityOptimizer.cpp
|
| diff --git a/Source/core/rendering/SubtreeLayoutScope.cpp b/Source/core/fetch/ResourceLoadPriorityOptimizer.cpp
|
| similarity index 53%
|
| copy from Source/core/rendering/SubtreeLayoutScope.cpp
|
| copy to Source/core/fetch/ResourceLoadPriorityOptimizer.cpp
|
| index d650513a1c89e451b77d327e77d8809077432bf9..29882526a7c3c9c29648936219152a8f0d5d5aef 100644
|
| --- a/Source/core/rendering/SubtreeLayoutScope.cpp
|
| +++ b/Source/core/fetch/ResourceLoadPriorityOptimizer.cpp
|
| @@ -29,52 +29,51 @@
|
| */
|
|
|
| #include "config.h"
|
| -#include "core/rendering/SubtreeLayoutScope.h"
|
| -
|
| -#include "core/frame/FrameView.h"
|
| -#include "core/rendering/RenderObject.h"
|
| +#include "core/fetch/ResourceLoadPriorityOptimizer.h"
|
|
|
| namespace WebCore {
|
|
|
| -SubtreeLayoutScope::SubtreeLayoutScope(RenderObject* root)
|
| - : m_root(root)
|
| +ResourceLoadPriorityOptimizer::ResourceAndVisibility::ResourceAndVisibility(ImageResource* image, VisibilityStatus v)
|
| + : imageResource(image)
|
| + , status(v)
|
| {
|
| - RELEASE_ASSERT(m_root->document().view()->isInLayout());
|
| }
|
|
|
| -SubtreeLayoutScope::~SubtreeLayoutScope()
|
| +ResourceLoadPriorityOptimizer::ResourceAndVisibility::~ResourceAndVisibility()
|
| {
|
| - // Partial layout early-exits layout and will leave the tree as needing layout.
|
| - if (m_root->frameView()->partialLayout().isStopping()) {
|
| - ASSERT(m_root->needsLayout());
|
| - return;
|
| - }
|
| -
|
| - RELEASE_ASSERT(!m_root->needsLayout());
|
| +}
|
|
|
| -#ifndef NDEBUG
|
| - for (HashSet<RenderObject*>::iterator it = m_renderersToLayout.begin(); it != m_renderersToLayout.end(); ++it)
|
| - (*it)->assertRendererLaidOut();
|
| -#endif
|
| +ResourceLoadPriorityOptimizer::ResourceLoadPriorityOptimizer()
|
| +{
|
| }
|
|
|
| -void SubtreeLayoutScope::setNeedsLayout(RenderObject* descendant)
|
| +ResourceLoadPriorityOptimizer::~ResourceLoadPriorityOptimizer()
|
| {
|
| - ASSERT(descendant->isDescendantOf(m_root));
|
| - descendant->setNeedsLayout(MarkContainingBlockChain, this);
|
| + updateImageResourcesWithLoadPriority();
|
| }
|
|
|
| -void SubtreeLayoutScope::setChildNeedsLayout(RenderObject* descendant)
|
| +void ResourceLoadPriorityOptimizer::updateImageResourcesWithLoadPriority()
|
| {
|
| - ASSERT(descendant->isDescendantOf(m_root));
|
| - descendant->setChildNeedsLayout(MarkContainingBlockChain, this);
|
| + for (ImageResourceMap::iterator it = m_imageResources.begin(); it != m_imageResources.end(); ++it) {
|
| + ResourceLoadPriority priority = it->value->status == Visible ?
|
| + ResourceLoadPriorityLow : ResourceLoadPriorityVeryLow;
|
| +
|
| + if (priority != it->value->imageResource->resourceRequest().priority()) {
|
| + it->value->imageResource->resourceRequest().setPriority(priority);
|
| + it->value->imageResource->didChangePriority(priority);
|
| + }
|
| + }
|
| + m_imageResources.clear();
|
| }
|
|
|
| -void SubtreeLayoutScope::addRendererToLayout(RenderObject* renderer)
|
| +void ResourceLoadPriorityOptimizer::notifyImageResourceVisibility(ImageResource* img, VisibilityStatus status)
|
| {
|
| -#ifndef NDEBUG
|
| - m_renderersToLayout.add(renderer);
|
| -#endif
|
| + if (!img || img->isLoaded())
|
| + return;
|
| +
|
| + ImageResourceMap::AddResult result = m_imageResources.add(img->identifier(), adoptPtr(new ResourceAndVisibility(img, status)));
|
| + if (!result.isNewEntry && status == Visible)
|
| + result.iterator->value->status = status;
|
| }
|
|
|
| }
|
|
|