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

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

Issue 1304063016: Refactor the API for setting dynamic resource load priorities (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutBox.h ('k') | Source/core/layout/LayoutImage.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) 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 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 if (!info.isComputingShape()) { 1335 if (!info.isComputingShape()) {
1336 info.markShapeAsDirty(); 1336 info.markShapeAsDirty();
1337 markShapeOutsideDependentsForLayout(); 1337 markShapeOutsideDependentsForLayout();
1338 } 1338 }
1339 } 1339 }
1340 1340
1341 if (!invalidatePaintOfLayerRectsForImage(image, style()->backgroundLayers(), true)) 1341 if (!invalidatePaintOfLayerRectsForImage(image, style()->backgroundLayers(), true))
1342 invalidatePaintOfLayerRectsForImage(image, style()->maskLayers(), false) ; 1342 invalidatePaintOfLayerRectsForImage(image, style()->maskLayers(), false) ;
1343 } 1343 }
1344 1344
1345 ResourcePriority LayoutBox::updatePriority(Resource*)
1346 {
1347 LayoutRect viewBounds = viewRect();
1348 LayoutRect objectBounds = LayoutRect(absoluteContentBox());
1349
1350 // The object bounds might be empty right now, so intersects will fail since it doesn't deal
1351 // with empty rects. Use LayoutRect::contains in that case.
1352 bool isVisible;
1353 if (!objectBounds.isEmpty())
1354 isVisible = viewBounds.intersects(objectBounds);
1355 else
1356 isVisible = viewBounds.contains(objectBounds);
1357
1358 LayoutRect screenRect;
1359 if (!objectBounds.isEmpty()) {
1360 screenRect = viewBounds;
1361 screenRect.intersect(objectBounds);
1362 }
1363
1364 int screenArea = 0;
1365 if (!screenRect.isEmpty() && isVisible)
1366 screenArea = static_cast<uint32_t>(screenRect.width() * screenRect.heigh t());
1367 return ResourcePriority(isVisible ? ResourcePriority::Visible : ResourcePrio rity::NotVisible, screenArea);
1368 }
1369
1345 bool LayoutBox::invalidatePaintOfLayerRectsForImage(WrappedImagePtr image, const FillLayer& layers, bool drawingBackground) 1370 bool LayoutBox::invalidatePaintOfLayerRectsForImage(WrappedImagePtr image, const FillLayer& layers, bool drawingBackground)
1346 { 1371 {
1347 if (drawingBackground && (isDocumentElement() || backgroundStolenForBeingBod y())) 1372 if (drawingBackground && (isDocumentElement() || backgroundStolenForBeingBod y()))
1348 return false; 1373 return false;
1349 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex t()) { 1374 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex t()) {
1350 if (curLayer->image() && image == curLayer->image()->data()) { 1375 if (curLayer->image() && image == curLayer->image()->data()) {
1351 bool maybeAnimated = curLayer->image()->cachedImage() && curLayer->i mage()->cachedImage()->image() && curLayer->image()->cachedImage()->image()->may beAnimated(); 1376 bool maybeAnimated = curLayer->image()->cachedImage() && curLayer->i mage()->cachedImage()->image() && curLayer->image()->cachedImage()->image()->may beAnimated();
1352 if (maybeAnimated && drawingBackground) 1377 if (maybeAnimated && drawingBackground)
1353 setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull); 1378 setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull);
1354 else 1379 else
(...skipping 3384 matching lines...) Expand 10 before | Expand all | Expand 10 after
4739 StyleImage* borderImage = style()->borderImage().image(); 4764 StyleImage* borderImage = style()->borderImage().image();
4740 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded(); 4765 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded();
4741 } 4766 }
4742 4767
4743 ShapeOutsideInfo* LayoutBox::shapeOutsideInfo() const 4768 ShapeOutsideInfo* LayoutBox::shapeOutsideInfo() const
4744 { 4769 {
4745 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr; 4770 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr;
4746 } 4771 }
4747 4772
4748 } // namespace blink 4773 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutBox.h ('k') | Source/core/layout/LayoutImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698