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

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

Issue 86533002: Raise the loading priority of in-viewport images. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Changes from review + replace layout test. 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/platform/graphics/GraphicsContextStateSaver.h" 40 #include "core/platform/graphics/GraphicsContextStateSaver.h"
40 #include "core/rendering/FastTextAutosizer.h" 41 #include "core/rendering/FastTextAutosizer.h"
41 #include "core/rendering/GraphicsContextAnnotator.h" 42 #include "core/rendering/GraphicsContextAnnotator.h"
42 #include "core/rendering/HitTestLocation.h" 43 #include "core/rendering/HitTestLocation.h"
43 #include "core/rendering/HitTestResult.h" 44 #include "core/rendering/HitTestResult.h"
44 #include "core/rendering/InlineIterator.h" 45 #include "core/rendering/InlineIterator.h"
45 #include "core/rendering/InlineTextBox.h" 46 #include "core/rendering/InlineTextBox.h"
46 #include "core/rendering/LayoutRectRecorder.h" 47 #include "core/rendering/LayoutRectRecorder.h"
47 #include "core/rendering/LayoutRepainter.h" 48 #include "core/rendering/LayoutRepainter.h"
48 #include "core/rendering/PaintInfo.h" 49 #include "core/rendering/PaintInfo.h"
49 #include "core/rendering/RenderCombineText.h" 50 #include "core/rendering/RenderCombineText.h"
50 #include "core/rendering/RenderDeprecatedFlexibleBox.h" 51 #include "core/rendering/RenderDeprecatedFlexibleBox.h"
51 #include "core/rendering/RenderFlexibleBox.h" 52 #include "core/rendering/RenderFlexibleBox.h"
52 #include "core/rendering/RenderInline.h" 53 #include "core/rendering/RenderInline.h"
53 #include "core/rendering/RenderLayer.h" 54 #include "core/rendering/RenderLayer.h"
54 #include "core/rendering/RenderMarquee.h" 55 #include "core/rendering/RenderMarquee.h"
55 #include "core/rendering/RenderNamedFlowThread.h" 56 #include "core/rendering/RenderNamedFlowThread.h"
56 #include "core/rendering/RenderRegion.h" 57 #include "core/rendering/RenderRegion.h"
57 #include "core/rendering/RenderTableCell.h" 58 #include "core/rendering/RenderTableCell.h"
58 #include "core/rendering/RenderTextFragment.h" 59 #include "core/rendering/RenderTextFragment.h"
59 #include "core/rendering/RenderTheme.h" 60 #include "core/rendering/RenderTheme.h"
60 #include "core/rendering/RenderView.h" 61 #include "core/rendering/RenderView.h"
61 #include "core/rendering/shapes/ShapeOutsideInfo.h" 62 #include "core/rendering/shapes/ShapeOutsideInfo.h"
63 #include "core/rendering/style/ContentData.h"
64 #include "core/rendering/style/RenderStyle.h"
62 #include "platform/geometry/FloatQuad.h" 65 #include "platform/geometry/FloatQuad.h"
63 #include "platform/geometry/TransformState.h" 66 #include "platform/geometry/TransformState.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
71 namespace WebCore { 74 namespace WebCore {
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 return; 1255 return;
1253 1256
1254 // It's safe to check for control clip here, since controls can never be tab le cells. 1257 // It's safe to check for control clip here, since controls can never be tab le cells.
1255 // If we have a lightweight clip, there can never be any overflow from child ren. 1258 // If we have a lightweight clip, there can never be any overflow from child ren.
1256 if (hasControlClip() && m_overflow) 1259 if (hasControlClip() && m_overflow)
1257 clearLayoutOverflow(); 1260 clearLayoutOverflow();
1258 1261
1259 invalidateBackgroundObscurationStatus(); 1262 invalidateBackgroundObscurationStatus();
1260 } 1263 }
1261 1264
1265 void RenderBlock::didLayout(ResourceLoadPriorityOptimizer& optimizer)
1266 {
1267 RenderBox::didLayout(optimizer);
1268 updateStyleImageLoadingPriorities(optimizer);
1269 }
1270
1271 void RenderBlock::didScroll(ResourceLoadPriorityOptimizer& optimizer)
1272 {
1273 RenderBox::didScroll(optimizer);
1274 updateStyleImageLoadingPriorities(optimizer);
1275 }
1276
1277 void RenderBlock::updateStyleImageLoadingPriorities(ResourceLoadPriorityOptimize r& optimizer)
1278 {
1279 RenderStyle* blockStyle = style();
1280 if (!blockStyle)
1281 return;
1282
1283 LayoutRect objectBounds = absoluteContentBox();
1284 LayoutRect viewBounds = viewRect();
1285
1286 // The object bounds might be empty right now, so intersects will fail since it doesn't deal
1287 // with empty rects. Use LayoutRect::contains in that case.
1288 bool isVisible;
1289 if (!objectBounds.isEmpty())
1290 isVisible = viewBounds.intersects(objectBounds);
1291 else
1292 isVisible = viewBounds.contains(objectBounds);
1293
1294 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ?
1295 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer:: NotVisible;
1296
1297 for (FillLayer* layer = blockStyle->accessBackgroundLayers(); layer; layer = layer->next()) {
1298 if (layer->image()) {
1299 ImageResource* img = layer->image()->cachedImage();
1300 if (img) {
1301 optimizer.notifyImageResourceVisibility(img, status);
1302 }
1303 }
1304 }
1305 for (FillLayer* layer = blockStyle->accessMaskLayers(); layer; layer = layer ->next()) {
1306 if (layer->image()) {
1307 ImageResource* img = layer->image()->cachedImage();
1308 if (img) {
1309 optimizer.notifyImageResourceVisibility(img, status);
1310 }
1311 }
1312 }
1313 ContentData* contentData = const_cast<ContentData*>(blockStyle->contentData( ));
1314 if (contentData && contentData->isImage()) {
1315 ImageContentData* imageContentData = static_cast<ImageContentData*>(cont entData);
1316 if (imageContentData->image() && imageContentData->image()->cachedImage( ))
1317 optimizer.notifyImageResourceVisibility(imageContentData->image()->c achedImage(), status);
1318 }
1319 if (blockStyle->boxReflect()) {
1320 if (blockStyle->boxReflect()->mask().image()) {
1321 if (blockStyle->boxReflect()->mask().image()->cachedImage()) {
1322 optimizer.notifyImageResourceVisibility(blockStyle->boxReflect() ->mask().image()->cachedImage(), status);
1323 }
1324 }
1325 }
1326 if (blockStyle->listStyleImage() && blockStyle->listStyleImage()->cachedImag e())
1327 optimizer.notifyImageResourceVisibility(blockStyle->listStyleImage()->ca chedImage(), status);
1328 if (blockStyle->borderImageSource() && blockStyle->borderImageSource()->cach edImage())
1329 optimizer.notifyImageResourceVisibility(blockStyle->borderImageSource()- >cachedImage(), status);
1330 if (blockStyle->maskBoxImageSource() && blockStyle->maskBoxImageSource()->ca chedImage())
1331 optimizer.notifyImageResourceVisibility(blockStyle->maskBoxImageSource() ->cachedImage(), status);
1332 }
1333
1262 void RenderBlock::relayoutShapeDescendantIfMoved(RenderBlock* child, LayoutSize offset) 1334 void RenderBlock::relayoutShapeDescendantIfMoved(RenderBlock* child, LayoutSize offset)
1263 { 1335 {
1264 LayoutUnit left = isHorizontalWritingMode() ? offset.width() : offset.height (); 1336 LayoutUnit left = isHorizontalWritingMode() ? offset.width() : offset.height ();
1265 if (!left || !child || child->shapeInsideInfo() || !layoutShapeInsideInfo()) 1337 if (!left || !child || child->shapeInsideInfo() || !layoutShapeInsideInfo())
1266 return; 1338 return;
1267 // Propagate layout markers only up to the child, as we are still in the mid dle 1339 // Propagate layout markers only up to the child, as we are still in the mid dle
1268 // of a layout pass 1340 // of a layout pass
1269 child->setNormalChildNeedsLayout(true); 1341 child->setNormalChildNeedsLayout(true);
1270 child->markShapeInsideDescendantsForLayout(); 1342 child->markShapeInsideDescendantsForLayout();
1271 child->layoutIfNeeded(); 1343 child->layoutIfNeeded();
(...skipping 4511 matching lines...) Expand 10 before | Expand all | Expand 10 after
5783 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 5855 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
5784 { 5856 {
5785 showRenderObject(); 5857 showRenderObject();
5786 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 5858 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
5787 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 5859 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
5788 } 5860 }
5789 5861
5790 #endif 5862 #endif
5791 5863
5792 } // namespace WebCore 5864 } // 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