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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 1378743002: Refactor the API for setting dynamic resource load priorities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better names / cleanup Created 5 years, 2 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
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) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 if (!info.isComputingShape()) { 1349 if (!info.isComputingShape()) {
1350 info.markShapeAsDirty(); 1350 info.markShapeAsDirty();
1351 markShapeOutsideDependentsForLayout(); 1351 markShapeOutsideDependentsForLayout();
1352 } 1352 }
1353 } 1353 }
1354 1354
1355 if (!invalidatePaintOfLayerRectsForImage(image, style()->backgroundLayers(), true)) 1355 if (!invalidatePaintOfLayerRectsForImage(image, style()->backgroundLayers(), true))
1356 invalidatePaintOfLayerRectsForImage(image, style()->maskLayers(), false) ; 1356 invalidatePaintOfLayerRectsForImage(image, style()->maskLayers(), false) ;
1357 } 1357 }
1358 1358
1359 ResourcePriority LayoutBox::computeResourcePriority() const
1360 {
1361 LayoutRect viewBounds = viewRect();
1362 LayoutRect objectBounds = LayoutRect(absoluteContentBox());
1363
1364 // The object bounds might be empty right now, so intersects will fail since it doesn't deal
1365 // with empty rects. Use LayoutRect::contains in that case.
1366 bool isVisible;
1367 if (!objectBounds.isEmpty())
1368 isVisible = viewBounds.intersects(objectBounds);
1369 else
1370 isVisible = viewBounds.contains(objectBounds);
1371
1372 LayoutRect screenRect;
1373 if (!objectBounds.isEmpty()) {
1374 screenRect = viewBounds;
1375 screenRect.intersect(objectBounds);
1376 }
1377
1378 int screenArea = 0;
1379 if (!screenRect.isEmpty() && isVisible)
1380 screenArea = static_cast<uint32_t>(screenRect.width() * screenRect.heigh t());
1381 return ResourcePriority(isVisible ? ResourcePriority::Visible : ResourcePrio rity::NotVisible, screenArea);
1382 }
1383
1359 bool LayoutBox::invalidatePaintOfLayerRectsForImage(WrappedImagePtr image, const FillLayer& layers, bool drawingBackground) 1384 bool LayoutBox::invalidatePaintOfLayerRectsForImage(WrappedImagePtr image, const FillLayer& layers, bool drawingBackground)
1360 { 1385 {
1361 if (drawingBackground && (isDocumentElement() || backgroundStolenForBeingBod y())) 1386 if (drawingBackground && (isDocumentElement() || backgroundStolenForBeingBod y()))
1362 return false; 1387 return false;
1363 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex t()) { 1388 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex t()) {
1364 if (curLayer->image() && image == curLayer->image()->data()) { 1389 if (curLayer->image() && image == curLayer->image()->data()) {
1365 bool maybeAnimated = curLayer->image()->cachedImage() && curLayer->i mage()->cachedImage()->image() && curLayer->image()->cachedImage()->image()->may beAnimated(); 1390 bool maybeAnimated = curLayer->image()->cachedImage() && curLayer->i mage()->cachedImage()->image() && curLayer->image()->cachedImage()->image()->may beAnimated();
1366 if (maybeAnimated && drawingBackground) 1391 if (maybeAnimated && drawingBackground)
1367 setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull); 1392 setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull);
1368 else 1393 else
(...skipping 3440 matching lines...) Expand 10 before | Expand all | Expand 10 after
4809 StyleImage* borderImage = style()->borderImage().image(); 4834 StyleImage* borderImage = style()->borderImage().image();
4810 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded(); 4835 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded();
4811 } 4836 }
4812 4837
4813 ShapeOutsideInfo* LayoutBox::shapeOutsideInfo() const 4838 ShapeOutsideInfo* LayoutBox::shapeOutsideInfo() const
4814 { 4839 {
4815 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr; 4840 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr;
4816 } 4841 }
4817 4842
4818 } // namespace blink 4843 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698