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

Side by Side Diff: Source/core/fetch/ResourceLoadPriorityOptimizer.cpp

Issue 899163003: Move rendering/RenderObject to layout/LayoutObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/fetch/ResourceLoadPriorityOptimizer.h ('k') | Source/core/frame/Frame.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/fetch/ResourceLoadPriorityOptimizer.h" 32 #include "core/fetch/ResourceLoadPriorityOptimizer.h"
33 #include "core/rendering/RenderObject.h" 33 #include "core/layout/LayoutObject.h"
34 #include "platform/TraceEvent.h" 34 #include "platform/TraceEvent.h"
35 35
36 #include "wtf/Vector.h" 36 #include "wtf/Vector.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 ResourceLoadPriorityOptimizer* ResourceLoadPriorityOptimizer::resourceLoadPriori tyOptimizer() 40 ResourceLoadPriorityOptimizer* ResourceLoadPriorityOptimizer::resourceLoadPriori tyOptimizer()
41 { 41 {
42 DEFINE_STATIC_LOCAL(ResourceLoadPriorityOptimizer, s_renderLoadOptimizer, () ); 42 DEFINE_STATIC_LOCAL(ResourceLoadPriorityOptimizer, s_renderLoadOptimizer, () );
43 return &s_renderLoadOptimizer; 43 return &s_renderLoadOptimizer;
(...skipping 11 matching lines...) Expand all
55 } 55 }
56 56
57 ResourceLoadPriorityOptimizer::ResourceLoadPriorityOptimizer() 57 ResourceLoadPriorityOptimizer::ResourceLoadPriorityOptimizer()
58 { 58 {
59 } 59 }
60 60
61 ResourceLoadPriorityOptimizer::~ResourceLoadPriorityOptimizer() 61 ResourceLoadPriorityOptimizer::~ResourceLoadPriorityOptimizer()
62 { 62 {
63 } 63 }
64 64
65 void ResourceLoadPriorityOptimizer::addRenderObject(RenderObject* renderer) 65 void ResourceLoadPriorityOptimizer::addLayoutObject(LayoutObject* renderer)
66 { 66 {
67 m_objects.add(renderer); 67 m_objects.add(renderer);
68 renderer->setHasPendingResourceUpdate(true); 68 renderer->setHasPendingResourceUpdate(true);
69 } 69 }
70 70
71 void ResourceLoadPriorityOptimizer::removeRenderObject(RenderObject* renderer) 71 void ResourceLoadPriorityOptimizer::removeLayoutObject(LayoutObject* renderer)
72 { 72 {
73 if (!renderer->hasPendingResourceUpdate()) 73 if (!renderer->hasPendingResourceUpdate())
74 return; 74 return;
75 m_objects.remove(renderer); 75 m_objects.remove(renderer);
76 renderer->setHasPendingResourceUpdate(false); 76 renderer->setHasPendingResourceUpdate(false);
77 } 77 }
78 78
79 void ResourceLoadPriorityOptimizer::updateAllImageResourcePriorities() 79 void ResourceLoadPriorityOptimizer::updateAllImageResourcePriorities()
80 { 80 {
81 TRACE_EVENT0("blink", "ResourceLoadPriorityOptimizer::updateAllImageResource Priorities"); 81 TRACE_EVENT0("blink", "ResourceLoadPriorityOptimizer::updateAllImageResource Priorities");
82 82
83 m_imageResources.clear(); 83 m_imageResources.clear();
84 84
85 Vector<RenderObject*> objectsToRemove; 85 Vector<LayoutObject*> objectsToRemove;
86 for (const auto& renderObject : m_objects) { 86 for (const auto& layoutObject : m_objects) {
87 if (!renderObject->updateImageLoadingPriorities()) 87 if (!layoutObject->updateImageLoadingPriorities())
88 objectsToRemove.append(renderObject); 88 objectsToRemove.append(layoutObject);
89 } 89 }
90 m_objects.removeAll(objectsToRemove); 90 m_objects.removeAll(objectsToRemove);
91 91
92 updateImageResourcesWithLoadPriority(); 92 updateImageResourcesWithLoadPriority();
93 } 93 }
94 94
95 void ResourceLoadPriorityOptimizer::updateImageResourcesWithLoadPriority() 95 void ResourceLoadPriorityOptimizer::updateImageResourcesWithLoadPriority()
96 { 96 {
97 for (const auto& resource : m_imageResources) { 97 for (const auto& resource : m_imageResources) {
98 ResourceLoadPriority priority = resource.value->status == Visible ? 98 ResourceLoadPriority priority = resource.value->status == Visible ?
(...skipping 17 matching lines...) Expand all
116 screenArea += static_cast<uint32_t>(screenRect.width() * screenRect.heig ht()); 116 screenArea += static_cast<uint32_t>(screenRect.width() * screenRect.heig ht());
117 117
118 ImageResourceMap::AddResult result = m_imageResources.add(img->identifier(), adoptPtr(new ResourceAndVisibility(img, status, screenArea))); 118 ImageResourceMap::AddResult result = m_imageResources.add(img->identifier(), adoptPtr(new ResourceAndVisibility(img, status, screenArea)));
119 if (!result.isNewEntry && status == Visible) { 119 if (!result.isNewEntry && status == Visible) {
120 result.storedValue->value->status = Visible; 120 result.storedValue->value->status = Visible;
121 result.storedValue->value->screenArea += screenArea; 121 result.storedValue->value->screenArea += screenArea;
122 } 122 }
123 } 123 }
124 124
125 } 125 }
OLDNEW
« no previous file with comments | « Source/core/fetch/ResourceLoadPriorityOptimizer.h ('k') | Source/core/frame/Frame.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698