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

Side by Side Diff: sky/engine/core/rendering/RenderBlock.cpp

Issue 710743006: Remove ResourceLoadPriorityOptimizer. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « sky/engine/core/rendering/RenderBlock.h ('k') | sky/engine/core/rendering/RenderImage.h » ('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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 12 matching lines...) Expand all
23 23
24 #include "config.h" 24 #include "config.h"
25 #include "core/rendering/RenderBlock.h" 25 #include "core/rendering/RenderBlock.h"
26 26
27 #include "core/dom/Document.h" 27 #include "core/dom/Document.h"
28 #include "core/dom/Element.h" 28 #include "core/dom/Element.h"
29 #include "core/dom/StyleEngine.h" 29 #include "core/dom/StyleEngine.h"
30 #include "core/dom/shadow/ShadowRoot.h" 30 #include "core/dom/shadow/ShadowRoot.h"
31 #include "core/editing/Editor.h" 31 #include "core/editing/Editor.h"
32 #include "core/editing/FrameSelection.h" 32 #include "core/editing/FrameSelection.h"
33 #include "core/fetch/ResourceLoadPriorityOptimizer.h"
34 #include "core/frame/FrameView.h" 33 #include "core/frame/FrameView.h"
35 #include "core/frame/LocalFrame.h" 34 #include "core/frame/LocalFrame.h"
36 #include "core/page/Page.h" 35 #include "core/page/Page.h"
37 #include "core/frame/Settings.h" 36 #include "core/frame/Settings.h"
38 #include "core/rendering/GraphicsContextAnnotator.h" 37 #include "core/rendering/GraphicsContextAnnotator.h"
39 #include "core/rendering/HitTestLocation.h" 38 #include "core/rendering/HitTestLocation.h"
40 #include "core/rendering/HitTestResult.h" 39 #include "core/rendering/HitTestResult.h"
41 #include "core/rendering/InlineIterator.h" 40 #include "core/rendering/InlineIterator.h"
42 #include "core/rendering/InlineTextBox.h" 41 #include "core/rendering/InlineTextBox.h"
43 #include "core/rendering/PaintInfo.h" 42 #include "core/rendering/PaintInfo.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 continue; 108 continue;
110 HashSet<RenderBlock*>* containerSet = it->value.get(); 109 HashSet<RenderBlock*>* containerSet = it->value.get();
111 ASSERT(containerSet->contains(block)); 110 ASSERT(containerSet->contains(block));
112 containerSet->remove(block); 111 containerSet->remove(block);
113 if (containerSet->isEmpty()) 112 if (containerSet->isEmpty())
114 containerMap->remove(it); 113 containerMap->remove(it);
115 } 114 }
116 } 115 }
117 } 116 }
118 117
119 static void appendImageIfNotNull(Vector<ImageResource*>& imageResources, const S tyleImage* styleImage)
120 {
121 if (styleImage && styleImage->cachedImage()) {
122 ImageResource* imageResource = styleImage->cachedImage();
123 if (imageResource && !imageResource->isLoaded())
124 imageResources.append(styleImage->cachedImage());
125 }
126 }
127
128 static void appendLayers(Vector<ImageResource*>& images, const FillLayer& styleL ayer)
129 {
130 for (const FillLayer* layer = &styleLayer; layer; layer = layer->next())
131 appendImageIfNotNull(images, layer->image());
132 }
133
134 static void appendImagesFromStyle(Vector<ImageResource*>& images, RenderStyle& b lockStyle)
135 {
136 appendLayers(images, blockStyle.backgroundLayers());
137 appendLayers(images, blockStyle.maskLayers());
138
139 appendImageIfNotNull(images, blockStyle.listStyleImage());
140 appendImageIfNotNull(images, blockStyle.borderImageSource());
141 appendImageIfNotNull(images, blockStyle.maskBoxImageSource());
142 }
143
144 void RenderBlock::removeFromGlobalMaps() 118 void RenderBlock::removeFromGlobalMaps()
145 { 119 {
146 if (gPercentHeightDescendantsMap) 120 if (gPercentHeightDescendantsMap)
147 removeBlockFromDescendantAndContainerMaps(this, gPercentHeightDescendant sMap, gPercentHeightContainerMap); 121 removeBlockFromDescendantAndContainerMaps(this, gPercentHeightDescendant sMap, gPercentHeightContainerMap);
148 if (gPositionedDescendantsMap) 122 if (gPositionedDescendantsMap)
149 removeBlockFromDescendantAndContainerMaps(this, gPositionedDescendantsMa p, gPositionedContainerMap); 123 removeBlockFromDescendantAndContainerMaps(this, gPositionedDescendantsMa p, gPositionedContainerMap);
150 } 124 }
151 125
152 RenderBlock::~RenderBlock() 126 RenderBlock::~RenderBlock()
153 { 127 {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 currCont->setStyle(newStyle); 242 currCont->setStyle(newStyle);
269 currCont->setContinuation(nextCont); 243 currCont->setContinuation(nextCont);
270 } 244 }
271 } 245 }
272 246
273 propagateStyleToAnonymousChildren(true); 247 propagateStyleToAnonymousChildren(true);
274 248
275 // It's possible for our border/padding to change, but for the overall logic al width of the block to 249 // It's possible for our border/padding to change, but for the overall logic al width of the block to
276 // end up being the same. We keep track of this change so in layoutBlock, we can know to set relayoutChildren=true. 250 // end up being the same. We keep track of this change so in layoutBlock, we can know to set relayoutChildren=true.
277 m_hasBorderOrPaddingLogicalWidthChanged = oldStyle && diff.needsFullLayout() && needsLayout() && borderOrPaddingLogicalWidthChanged(oldStyle, newStyle); 251 m_hasBorderOrPaddingLogicalWidthChanged = oldStyle && diff.needsFullLayout() && needsLayout() && borderOrPaddingLogicalWidthChanged(oldStyle, newStyle);
278
279 // If the style has unloaded images, want to notify the ResourceLoadPriority Optimizer so that
280 // network priorities can be set.
281 Vector<ImageResource*> images;
282 appendImagesFromStyle(images, *newStyle);
283 if (images.isEmpty())
284 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->removeRe nderObject(this);
285 else
286 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->addRende rObject(this);
287 } 252 }
288 253
289 void RenderBlock::invalidateTreeIfNeeded(const PaintInvalidationState& paintInva lidationState) 254 void RenderBlock::invalidateTreeIfNeeded(const PaintInvalidationState& paintInva lidationState)
290 { 255 {
291 // Note, we don't want to early out here using shouldCheckForInvalidationAft erLayout as 256 // Note, we don't want to early out here using shouldCheckForInvalidationAft erLayout as
292 // we have to make sure we go through any positioned objects as they won't b e seen in 257 // we have to make sure we go through any positioned objects as they won't b e seen in
293 // the normal tree walk. 258 // the normal tree walk.
294 259
295 RenderBox::invalidateTreeIfNeeded(paintInvalidationState); 260 RenderBox::invalidateTreeIfNeeded(paintInvalidationState);
296 261
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 layoutBlock(false); 844 layoutBlock(false);
880 845
881 // It's safe to check for control clip here, since controls can never be tab le cells. 846 // It's safe to check for control clip here, since controls can never be tab le cells.
882 // If we have a lightweight clip, there can never be any overflow from child ren. 847 // If we have a lightweight clip, there can never be any overflow from child ren.
883 if (hasControlClip() && m_overflow) 848 if (hasControlClip() && m_overflow)
884 clearLayoutOverflow(); 849 clearLayoutOverflow();
885 850
886 invalidateBackgroundObscurationStatus(); 851 invalidateBackgroundObscurationStatus();
887 } 852 }
888 853
889 bool RenderBlock::updateImageLoadingPriorities()
890 {
891 Vector<ImageResource*> images;
892 appendImagesFromStyle(images, *style());
893
894 if (images.isEmpty())
895 return false;
896
897 LayoutRect viewBounds = viewRect();
898 LayoutRect objectBounds = absoluteContentBox();
899 // The object bounds might be empty right now, so intersects will fail since it doesn't deal
900 // with empty rects. Use LayoutRect::contains in that case.
901 bool isVisible;
902 if (!objectBounds.isEmpty())
903 isVisible = viewBounds.intersects(objectBounds);
904 else
905 isVisible = viewBounds.contains(objectBounds);
906
907 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ?
908 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer:: NotVisible;
909
910 LayoutRect screenArea;
911 if (!objectBounds.isEmpty()) {
912 screenArea = viewBounds;
913 screenArea.intersect(objectBounds);
914 }
915
916 for (Vector<ImageResource*>::iterator it = images.begin(), end = images.end( ); it != end; ++it)
917 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyIm ageResourceVisibility(*it, status, screenArea);
918
919 return true;
920 }
921
922 bool RenderBlock::widthAvailableToChildrenHasChanged() 854 bool RenderBlock::widthAvailableToChildrenHasChanged()
923 { 855 {
924 bool widthAvailableToChildrenHasChanged = m_hasBorderOrPaddingLogicalWidthCh anged; 856 bool widthAvailableToChildrenHasChanged = m_hasBorderOrPaddingLogicalWidthCh anged;
925 m_hasBorderOrPaddingLogicalWidthChanged = false; 857 m_hasBorderOrPaddingLogicalWidthChanged = false;
926 858
927 // If we use border-box sizing, have percentage padding, and our parent has changed width then the width available to our children has changed even 859 // If we use border-box sizing, have percentage padding, and our parent has changed width then the width available to our children has changed even
928 // though our own width has remained the same. 860 // though our own width has remained the same.
929 widthAvailableToChildrenHasChanged |= style()->boxSizing() == BORDER_BOX && needsPreferredWidthsRecalculation() && view()->layoutState()->containingBlockLog icalWidthChanged(); 861 widthAvailableToChildrenHasChanged |= style()->boxSizing() == BORDER_BOX && needsPreferredWidthsRecalculation() && view()->layoutState()->containingBlockLog icalWidthChanged();
930 862
931 return widthAvailableToChildrenHasChanged; 863 return widthAvailableToChildrenHasChanged;
(...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 2851 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
2920 { 2852 {
2921 showRenderObject(); 2853 showRenderObject();
2922 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 2854 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
2923 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 2855 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
2924 } 2856 }
2925 2857
2926 #endif 2858 #endif
2927 2859
2928 } // namespace blink 2860 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBlock.h ('k') | sky/engine/core/rendering/RenderImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698