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

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

Issue 2229643002: Don't invalidate paint on background image change if it's obscured (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@BackgroundObscured
Patch Set: - Created 4 years, 4 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 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 { 1477 {
1478 BoxPainter(*this).paintMask(paintInfo, paintOffset); 1478 BoxPainter(*this).paintMask(paintInfo, paintOffset);
1479 } 1479 }
1480 1480
1481 void LayoutBox::imageChanged(WrappedImagePtr image, const IntRect*) 1481 void LayoutBox::imageChanged(WrappedImagePtr image, const IntRect*)
1482 { 1482 {
1483 // TODO(chrishtr): support PaintInvalidationDelayedFull for animated border images. 1483 // TODO(chrishtr): support PaintInvalidationDelayedFull for animated border images.
1484 if ((style()->borderImage().image() && style()->borderImage().image()->data( ) == image) 1484 if ((style()->borderImage().image() && style()->borderImage().image()->data( ) == image)
1485 || (style()->maskBoxImage().image() && style()->maskBoxImage().image()-> data() == image)) { 1485 || (style()->maskBoxImage().image() && style()->maskBoxImage().image()-> data() == image)) {
1486 setShouldDoFullPaintInvalidation(); 1486 setShouldDoFullPaintInvalidation();
1487 return; 1487 } else if (!invalidatePaintOfImageLayers(image, style()->backgroundLayers()) ) {
1488 invalidatePaintOfImageLayers(image, style()->maskLayers());
1488 } 1489 }
1489 1490
1490 ShapeValue* shapeOutsideValue = style()->shapeOutside(); 1491 ShapeValue* shapeOutsideValue = style()->shapeOutside();
chrishtr 2016/08/09 16:05:17 I guess you're fixing a bug also that this code di
Xianzhu 2016/08/09 18:51:48 There might be a bug if background and shape-outsi
1491 if (!frameView()->isInPerformLayout() && isFloating() && shapeOutsideValue & & shapeOutsideValue->image() && shapeOutsideValue->image()->data() == image) { 1492 if (!frameView()->isInPerformLayout() && isFloating() && shapeOutsideValue & & shapeOutsideValue->image() && shapeOutsideValue->image()->data() == image) {
1492 ShapeOutsideInfo& info = ShapeOutsideInfo::ensureInfo(*this); 1493 ShapeOutsideInfo& info = ShapeOutsideInfo::ensureInfo(*this);
1493 if (!info.isComputingShape()) { 1494 if (!info.isComputingShape()) {
1494 info.markShapeAsDirty(); 1495 info.markShapeAsDirty();
1495 markShapeOutsideDependentsForLayout(); 1496 markShapeOutsideDependentsForLayout();
1496 } 1497 }
1497 } 1498 }
1498
1499 if (!invalidatePaintOfLayerRectsForImage(image, style()->backgroundLayers(), true))
1500 invalidatePaintOfLayerRectsForImage(image, style()->maskLayers(), false) ;
1501 } 1499 }
1502 1500
1503 ResourcePriority LayoutBox::computeResourcePriority() const 1501 ResourcePriority LayoutBox::computeResourcePriority() const
1504 { 1502 {
1505 LayoutRect viewBounds = viewRect(); 1503 LayoutRect viewBounds = viewRect();
1506 LayoutRect objectBounds = LayoutRect(absoluteContentBox()); 1504 LayoutRect objectBounds = LayoutRect(absoluteContentBox());
1507 1505
1508 // The object bounds might be empty right now, so intersects will fail since it doesn't deal 1506 // The object bounds might be empty right now, so intersects will fail since it doesn't deal
1509 // with empty rects. Use LayoutRect::contains in that case. 1507 // with empty rects. Use LayoutRect::contains in that case.
1510 bool isVisible; 1508 bool isVisible;
1511 if (!objectBounds.isEmpty()) 1509 if (!objectBounds.isEmpty())
1512 isVisible = viewBounds.intersects(objectBounds); 1510 isVisible = viewBounds.intersects(objectBounds);
1513 else 1511 else
1514 isVisible = viewBounds.contains(objectBounds); 1512 isVisible = viewBounds.contains(objectBounds);
1515 1513
1516 LayoutRect screenRect; 1514 LayoutRect screenRect;
1517 if (!objectBounds.isEmpty()) { 1515 if (!objectBounds.isEmpty()) {
1518 screenRect = viewBounds; 1516 screenRect = viewBounds;
1519 screenRect.intersect(objectBounds); 1517 screenRect.intersect(objectBounds);
1520 } 1518 }
1521 1519
1522 int screenArea = 0; 1520 int screenArea = 0;
1523 if (!screenRect.isEmpty() && isVisible) 1521 if (!screenRect.isEmpty() && isVisible)
1524 screenArea = static_cast<uint32_t>(screenRect.width() * screenRect.heigh t()); 1522 screenArea = static_cast<uint32_t>(screenRect.width() * screenRect.heigh t());
1525 return ResourcePriority(isVisible ? ResourcePriority::Visible : ResourcePrio rity::NotVisible, screenArea); 1523 return ResourcePriority(isVisible ? ResourcePriority::Visible : ResourcePrio rity::NotVisible, screenArea);
1526 } 1524 }
1527 1525
1528 bool LayoutBox::invalidatePaintOfLayerRectsForImage(WrappedImagePtr image, const FillLayer& layers, bool drawingBackground) 1526 bool LayoutBox::invalidatePaintOfImageLayers(WrappedImagePtr image, const FillLa yer& layers)
1529 { 1527 {
1530 if (drawingBackground && (isDocumentElement() || backgroundStolenForBeingBod y())) 1528 bool isBackground = &layers == &styleRef().backgroundLayers();
eae 2016/08/09 14:41:48 NIT: Comparing references like this is a little od
Xianzhu 2016/08/09 18:51:48 We have FillLayer::operator== that compares the va
1529 if (isBackground && (isDocumentElement() || backgroundStolenForBeingBody()))
Stephen Chennney 2016/08/09 14:22:31 if (isBackground) { if (isDocumentElement() || .
Xianzhu 2016/08/09 18:51:48 Done.
1531 return false; 1530 return false;
1531
1532 if (isBackground) {
1533 invalidateBackgroundObscurationStatus();
1534 if (backgroundIsKnownToBeObscured())
1535 return false;
1536 }
1537
1532 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex t()) { 1538 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex t()) {
1533 if (curLayer->image() && image == curLayer->image()->data()) { 1539 if (curLayer->image() && image == curLayer->image()->data()) {
1534 bool maybeAnimated = curLayer->image()->cachedImage() && curLayer->i mage()->cachedImage()->getImage() && curLayer->image()->cachedImage()->getImage( )->maybeAnimated(); 1540 bool maybeAnimated = curLayer->image()->cachedImage() && curLayer->i mage()->cachedImage()->getImage() && curLayer->image()->cachedImage()->getImage( )->maybeAnimated();
1535 if (maybeAnimated && drawingBackground) 1541 if (maybeAnimated && isBackground) {
1536 setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull); 1542 setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull);
1537 else 1543 } else {
1538 setShouldDoFullPaintInvalidation(); 1544 setShouldDoFullPaintInvalidation();
1539 1545 return true;
1540 if (drawingBackground) 1546 }
1541 invalidateBackgroundObscurationStatus();
1542 return true;
1543 } 1547 }
1544 } 1548 }
1545 return false; 1549 return false;
1546 } 1550 }
1547 1551
1548 bool LayoutBox::intersectsVisibleViewport() 1552 bool LayoutBox::intersectsVisibleViewport()
1549 { 1553 {
1550 LayoutRect rect = visualOverflowRect(); 1554 LayoutRect rect = visualOverflowRect();
1551 LayoutView* layoutView = view(); 1555 LayoutView* layoutView = view();
1552 while (layoutView->frame()->ownerLayoutObject()) 1556 while (layoutView->frame()->ownerLayoutObject())
(...skipping 3434 matching lines...) Expand 10 before | Expand all | Expand 10 after
4987 m_rareData->m_snapAreas->remove(&snapArea); 4991 m_rareData->m_snapAreas->remove(&snapArea);
4988 } 4992 }
4989 } 4993 }
4990 4994
4991 SnapAreaSet* LayoutBox::snapAreas() const 4995 SnapAreaSet* LayoutBox::snapAreas() const
4992 { 4996 {
4993 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; 4997 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr;
4994 } 4998 }
4995 4999
4996 } // namespace blink 5000 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698