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

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: 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
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/ColumnInfo.h" 41 #include "core/rendering/ColumnInfo.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/ShapeInsideInfo.h" 62 #include "core/rendering/shapes/ShapeInsideInfo.h"
62 #include "core/rendering/shapes/ShapeOutsideInfo.h" 63 #include "core/rendering/shapes/ShapeOutsideInfo.h"
64 #include "core/rendering/style/ContentData.h"
65 #include "core/rendering/style/RenderStyle.h"
63 #include "platform/geometry/FloatQuad.h" 66 #include "platform/geometry/FloatQuad.h"
64 #include "platform/geometry/TransformState.h" 67 #include "platform/geometry/TransformState.h"
65 #include "wtf/StdLibExtras.h" 68 #include "wtf/StdLibExtras.h"
66 #include "wtf/TemporaryChange.h" 69 #include "wtf/TemporaryChange.h"
67 70
68 using namespace std; 71 using namespace std;
69 using namespace WTF; 72 using namespace WTF;
70 using namespace Unicode; 73 using namespace Unicode;
71 74
72 namespace WebCore { 75 namespace WebCore {
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 return; 1250 return;
1248 1251
1249 // It's safe to check for control clip here, since controls can never be tab le cells. 1252 // It's safe to check for control clip here, since controls can never be tab le cells.
1250 // If we have a lightweight clip, there can never be any overflow from child ren. 1253 // If we have a lightweight clip, there can never be any overflow from child ren.
1251 if (hasControlClip() && m_overflow) 1254 if (hasControlClip() && m_overflow)
1252 clearLayoutOverflow(); 1255 clearLayoutOverflow();
1253 1256
1254 invalidateBackgroundObscurationStatus(); 1257 invalidateBackgroundObscurationStatus();
1255 } 1258 }
1256 1259
1260 void RenderBlock::didLayout(ResourceLoadPriorityOptimizer& optimizer)
1261 {
1262 RenderBox::didLayout(optimizer);
1263 updateStyleImageLoadingPriorities(optimizer);
1264 }
1265
1266 void RenderBlock::didScroll(ResourceLoadPriorityOptimizer& optimizer)
1267 {
1268 RenderBox::didScroll(optimizer);
1269 updateStyleImageLoadingPriorities(optimizer);
1270 }
1271
1272 void RenderBlock::updateStyleImageLoadingPriorities(ResourceLoadPriorityOptimize r& optimizer)
1273 {
1274 RenderStyle* blockStyle = style();
1275
1276 if (blockStyle) {
1277 LayoutRect objectBox = absoluteContentBox();
1278 LayoutRect viewBox = viewRect();
1279
1280 bool visible = viewBox.intersects(objectBox);
1281
1282 for (FillLayer* layer = blockStyle->accessBackgroundLayers(); layer; lay er = layer->next()) {
1283 if (layer->image()) {
1284 ImageResource* img = layer->image()->cachedImage();
1285 if (img) {
1286 optimizer.notifyImageResourceVisibility(img, visible);
1287 }
1288 }
1289 }
1290 for (FillLayer* layer = blockStyle->accessMaskLayers(); layer; layer = l ayer->next()) {
1291 if (layer->image()) {
1292 ImageResource* img = layer->image()->cachedImage();
1293 if (img) {
1294 optimizer.notifyImageResourceVisibility(img, visible);
1295 }
1296 }
1297 }
1298 ContentData* contentData = const_cast<ContentData*>(blockStyle->contentD ata());
1299 if (contentData && contentData->isImage()) {
1300 ImageContentData* imageContentData = static_cast<ImageContentData*>( contentData);
1301 if (imageContentData->image() && imageContentData->image()->cachedIm age())
1302 optimizer.notifyImageResourceVisibility(imageContentData->image( )->cachedImage(), visible);
1303 }
1304 if (blockStyle->boxReflect()) {
1305 if (blockStyle->boxReflect()->mask().image()) {
1306 if (blockStyle->boxReflect()->mask().image()->cachedImage()) {
1307 optimizer.notifyImageResourceVisibility(blockStyle->boxRefle ct()->mask().image()->cachedImage(), visible);
1308 }
1309 }
1310 }
1311 if (blockStyle->listStyleImage() && blockStyle->listStyleImage()->cached Image())
1312 optimizer.notifyImageResourceVisibility(blockStyle->listStyleImage() ->cachedImage(), visible);
1313 if (blockStyle->borderImageSource() && blockStyle->borderImageSource()-> cachedImage())
1314 optimizer.notifyImageResourceVisibility(blockStyle->borderImageSourc e()->cachedImage(), visible);
1315 if (blockStyle->maskBoxImageSource() && blockStyle->maskBoxImageSource() ->cachedImage())
1316 optimizer.notifyImageResourceVisibility(blockStyle->maskBoxImageSour ce()->cachedImage(), visible);
1317 }
1318 }
1319
1257 void RenderBlock::relayoutShapeDescendantIfMoved(RenderBlock* child, LayoutSize offset) 1320 void RenderBlock::relayoutShapeDescendantIfMoved(RenderBlock* child, LayoutSize offset)
1258 { 1321 {
1259 LayoutUnit left = isHorizontalWritingMode() ? offset.width() : offset.height (); 1322 LayoutUnit left = isHorizontalWritingMode() ? offset.width() : offset.height ();
1260 if (!left || !child || child->shapeInsideInfo() || !layoutShapeInsideInfo()) 1323 if (!left || !child || child->shapeInsideInfo() || !layoutShapeInsideInfo())
1261 return; 1324 return;
1262 // Propagate layout markers only up to the child, as we are still in the mid dle 1325 // Propagate layout markers only up to the child, as we are still in the mid dle
1263 // of a layout pass 1326 // of a layout pass
1264 child->setNormalChildNeedsLayout(true); 1327 child->setNormalChildNeedsLayout(true);
1265 child->markShapeInsideDescendantsForLayout(); 1328 child->markShapeInsideDescendantsForLayout();
1266 child->layoutIfNeeded(); 1329 child->layoutIfNeeded();
(...skipping 4507 matching lines...) Expand 10 before | Expand all | Expand 10 after
5774 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 5837 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
5775 { 5838 {
5776 showRenderObject(); 5839 showRenderObject();
5777 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 5840 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
5778 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 5841 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
5779 } 5842 }
5780 5843
5781 #endif 5844 #endif
5782 5845
5783 } // namespace WebCore 5846 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698