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

Side by Side Diff: Source/core/rendering/RenderBlock.cpp

Issue 109153003: Raise the loading priority of in-viewport images. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Changes from review. Created 7 years 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 | « Source/core/rendering/RenderBlock.h ('k') | Source/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 14 matching lines...) Expand all
25 #include "core/rendering/RenderBlock.h" 25 #include "core/rendering/RenderBlock.h"
26 26
27 #include "HTMLNames.h" 27 #include "HTMLNames.h"
28 #include "core/accessibility/AXObjectCache.h" 28 #include "core/accessibility/AXObjectCache.h"
29 #include "core/dom/Document.h" 29 #include "core/dom/Document.h"
30 #include "core/dom/Element.h" 30 #include "core/dom/Element.h"
31 #include "core/events/OverflowEvent.h" 31 #include "core/events/OverflowEvent.h"
32 #include "core/dom/shadow/ShadowRoot.h" 32 #include "core/dom/shadow/ShadowRoot.h"
33 #include "core/editing/Editor.h" 33 #include "core/editing/Editor.h"
34 #include "core/editing/FrameSelection.h" 34 #include "core/editing/FrameSelection.h"
35 #include "core/fetch/ResourceLoadPriorityOptimizer.h"
35 #include "core/frame/Frame.h" 36 #include "core/frame/Frame.h"
36 #include "core/frame/FrameView.h" 37 #include "core/frame/FrameView.h"
37 #include "core/page/Page.h" 38 #include "core/page/Page.h"
38 #include "core/page/Settings.h" 39 #include "core/page/Settings.h"
39 #include "core/rendering/FastTextAutosizer.h" 40 #include "core/rendering/FastTextAutosizer.h"
40 #include "core/rendering/GraphicsContextAnnotator.h" 41 #include "core/rendering/GraphicsContextAnnotator.h"
41 #include "core/rendering/HitTestLocation.h" 42 #include "core/rendering/HitTestLocation.h"
42 #include "core/rendering/HitTestResult.h" 43 #include "core/rendering/HitTestResult.h"
43 #include "core/rendering/InlineIterator.h" 44 #include "core/rendering/InlineIterator.h"
44 #include "core/rendering/InlineTextBox.h" 45 #include "core/rendering/InlineTextBox.h"
45 #include "core/rendering/LayoutRectRecorder.h" 46 #include "core/rendering/LayoutRectRecorder.h"
46 #include "core/rendering/LayoutRepainter.h" 47 #include "core/rendering/LayoutRepainter.h"
47 #include "core/rendering/PaintInfo.h" 48 #include "core/rendering/PaintInfo.h"
48 #include "core/rendering/RenderCombineText.h" 49 #include "core/rendering/RenderCombineText.h"
49 #include "core/rendering/RenderDeprecatedFlexibleBox.h" 50 #include "core/rendering/RenderDeprecatedFlexibleBox.h"
50 #include "core/rendering/RenderFlexibleBox.h" 51 #include "core/rendering/RenderFlexibleBox.h"
51 #include "core/rendering/RenderInline.h" 52 #include "core/rendering/RenderInline.h"
52 #include "core/rendering/RenderLayer.h" 53 #include "core/rendering/RenderLayer.h"
53 #include "core/rendering/RenderMarquee.h" 54 #include "core/rendering/RenderMarquee.h"
54 #include "core/rendering/RenderNamedFlowThread.h" 55 #include "core/rendering/RenderNamedFlowThread.h"
55 #include "core/rendering/RenderRegion.h" 56 #include "core/rendering/RenderRegion.h"
56 #include "core/rendering/RenderTableCell.h" 57 #include "core/rendering/RenderTableCell.h"
57 #include "core/rendering/RenderTextFragment.h" 58 #include "core/rendering/RenderTextFragment.h"
58 #include "core/rendering/RenderTheme.h" 59 #include "core/rendering/RenderTheme.h"
59 #include "core/rendering/RenderView.h" 60 #include "core/rendering/RenderView.h"
60 #include "core/rendering/shapes/ShapeOutsideInfo.h" 61 #include "core/rendering/shapes/ShapeOutsideInfo.h"
62 #include "core/rendering/style/ContentData.h"
63 #include "core/rendering/style/RenderStyle.h"
61 #include "platform/geometry/FloatQuad.h" 64 #include "platform/geometry/FloatQuad.h"
62 #include "platform/geometry/TransformState.h" 65 #include "platform/geometry/TransformState.h"
63 #include "platform/graphics/GraphicsContextStateSaver.h" 66 #include "platform/graphics/GraphicsContextStateSaver.h"
64 #include "wtf/StdLibExtras.h" 67 #include "wtf/StdLibExtras.h"
65 #include "wtf/TemporaryChange.h" 68 #include "wtf/TemporaryChange.h"
66 69
67 using namespace std; 70 using namespace std;
68 using namespace WTF; 71 using namespace WTF;
69 using namespace Unicode; 72 using namespace Unicode;
70 73
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 continue; 165 continue;
163 HashSet<RenderBlock*>* containerSet = it->value.get(); 166 HashSet<RenderBlock*>* containerSet = it->value.get();
164 ASSERT(containerSet->contains(block)); 167 ASSERT(containerSet->contains(block));
165 containerSet->remove(block); 168 containerSet->remove(block);
166 if (containerSet->isEmpty()) 169 if (containerSet->isEmpty())
167 containerMap->remove(it); 170 containerMap->remove(it);
168 } 171 }
169 } 172 }
170 } 173 }
171 174
175 static void appendImageIfNotNull(Vector<ImageResource*>& imageResources, const S tyleImage* styleImage)
176 {
177 if (styleImage && styleImage->cachedImage())
178 imageResources.append(styleImage->cachedImage());
179 }
180
181 static void appendLayers(Vector<ImageResource*>& images, const FillLayer* styleL ayer)
182 {
183 for (const FillLayer* layer = styleLayer; layer; layer = layer->next()) {
184 appendImageIfNotNull(images, layer->image());
185 }
186 }
187
172 RenderBlock::~RenderBlock() 188 RenderBlock::~RenderBlock()
173 { 189 {
174 if (hasColumns()) 190 if (hasColumns())
175 gColumnInfoMap->take(this); 191 gColumnInfoMap->take(this);
176 if (gPercentHeightDescendantsMap) 192 if (gPercentHeightDescendantsMap)
177 removeBlockFromDescendantAndContainerMaps(this, gPercentHeightDescendant sMap, gPercentHeightContainerMap); 193 removeBlockFromDescendantAndContainerMaps(this, gPercentHeightDescendant sMap, gPercentHeightContainerMap);
178 if (gPositionedDescendantsMap) 194 if (gPositionedDescendantsMap)
179 removeBlockFromDescendantAndContainerMaps(this, gPositionedDescendantsMa p, gPositionedContainerMap); 195 removeBlockFromDescendantAndContainerMaps(this, gPositionedDescendantsMa p, gPositionedContainerMap);
180 } 196 }
181 197
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 return; 1261 return;
1246 1262
1247 // It's safe to check for control clip here, since controls can never be tab le cells. 1263 // It's safe to check for control clip here, since controls can never be tab le cells.
1248 // If we have a lightweight clip, there can never be any overflow from child ren. 1264 // If we have a lightweight clip, there can never be any overflow from child ren.
1249 if (hasControlClip() && m_overflow) 1265 if (hasControlClip() && m_overflow)
1250 clearLayoutOverflow(); 1266 clearLayoutOverflow();
1251 1267
1252 invalidateBackgroundObscurationStatus(); 1268 invalidateBackgroundObscurationStatus();
1253 } 1269 }
1254 1270
1271 void RenderBlock::didLayout(ResourceLoadPriorityOptimizer& optimizer)
1272 {
1273 RenderBox::didLayout(optimizer);
1274 updateStyleImageLoadingPriorities(optimizer);
1275 }
1276
1277 void RenderBlock::didScroll(ResourceLoadPriorityOptimizer& optimizer)
1278 {
1279 RenderBox::didScroll(optimizer);
1280 updateStyleImageLoadingPriorities(optimizer);
1281 }
1282
1283 void RenderBlock::updateStyleImageLoadingPriorities(ResourceLoadPriorityOptimize r& optimizer)
1284 {
1285 RenderStyle* blockStyle = style();
1286 if (!blockStyle)
1287 return;
1288
1289 Vector<ImageResource*> images;
1290
1291 appendLayers(images, blockStyle->backgroundLayers());
1292 appendLayers(images, blockStyle->maskLayers());
1293
1294 const ContentData* contentData = blockStyle->contentData();
1295 if (contentData && contentData->isImage()) {
1296 const ImageContentData* imageContentData = static_cast<const ImageConten tData*>(contentData);
1297 appendImageIfNotNull(images, imageContentData->image());
1298 }
1299 if (blockStyle->boxReflect())
1300 appendImageIfNotNull(images, blockStyle->boxReflect()->mask().image());
1301 appendImageIfNotNull(images, blockStyle->listStyleImage());
1302 appendImageIfNotNull(images, blockStyle->borderImageSource());
1303 appendImageIfNotNull(images, blockStyle->maskBoxImageSource());
1304
1305 if (images.isEmpty())
1306 return;
1307
1308 LayoutRect viewBounds = viewRect();
1309 LayoutRect objectBounds = absoluteContentBox();
1310 // The object bounds might be empty right now, so intersects will fail since it doesn't deal
1311 // with empty rects. Use LayoutRect::contains in that case.
1312 bool isVisible;
1313 if (!objectBounds.isEmpty())
1314 isVisible = viewBounds.intersects(objectBounds);
1315 else
1316 isVisible = viewBounds.contains(objectBounds);
1317
1318 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ?
1319 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer:: NotVisible;
1320
1321 for (Vector<ImageResource*>::iterator it = images.begin(), end = images.end( ); it != end; ++it)
1322 optimizer.notifyImageResourceVisibility(*it, status);
1323 }
1324
1255 void RenderBlock::relayoutShapeDescendantIfMoved(RenderBlock* child, LayoutSize offset) 1325 void RenderBlock::relayoutShapeDescendantIfMoved(RenderBlock* child, LayoutSize offset)
1256 { 1326 {
1257 LayoutUnit left = isHorizontalWritingMode() ? offset.width() : offset.height (); 1327 LayoutUnit left = isHorizontalWritingMode() ? offset.width() : offset.height ();
1258 if (!left || !child || child->shapeInsideInfo() || !layoutShapeInsideInfo()) 1328 if (!left || !child || child->shapeInsideInfo() || !layoutShapeInsideInfo())
1259 return; 1329 return;
1260 // Propagate layout markers only up to the child, as we are still in the mid dle 1330 // Propagate layout markers only up to the child, as we are still in the mid dle
1261 // of a layout pass 1331 // of a layout pass
1262 child->setNormalChildNeedsLayout(true); 1332 child->setNormalChildNeedsLayout(true);
1263 child->markShapeInsideDescendantsForLayout(); 1333 child->markShapeInsideDescendantsForLayout();
1264 child->layoutIfNeeded(); 1334 child->layoutIfNeeded();
(...skipping 4469 matching lines...) Expand 10 before | Expand all | Expand 10 after
5734 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 5804 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
5735 { 5805 {
5736 showRenderObject(); 5806 showRenderObject();
5737 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 5807 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
5738 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 5808 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
5739 } 5809 }
5740 5810
5741 #endif 5811 #endif
5742 5812
5743 } // namespace WebCore 5813 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | Source/core/rendering/RenderImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698