Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1474 } | 1474 } |
| 1475 | 1475 |
| 1476 void LayoutBox::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintOf fset) const | 1476 void LayoutBox::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintOf fset) const |
| 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 ((styleRef().borderImage().image() && styleRef().borderImage().image()->d ata() == image) |
| 1485 || (style()->maskBoxImage().image() && style()->maskBoxImage().image()-> data() == image)) { | 1485 || (styleRef().maskBoxImage().image() && styleRef().maskBoxImage().image ()->data() == image)) { |
| 1486 setShouldDoFullPaintInvalidation(); | 1486 setShouldDoFullPaintInvalidation(); |
| 1487 return; | 1487 } else { |
| 1488 for (const FillLayer* layer = &styleRef().maskLayers(); layer; layer = l ayer->next()) { | |
| 1489 if (layer->image() && image == layer->image()->data()) { | |
| 1490 setShouldDoFullPaintInvalidation(); | |
| 1491 break; | |
| 1492 } | |
| 1493 } | |
| 1494 } | |
| 1495 | |
| 1496 if (!isDocumentElement() && !backgroundStolenForBeingBody()) { | |
| 1497 for (const FillLayer* layer = &styleRef().backgroundLayers(); layer; lay er = layer->next()) { | |
| 1498 if (layer->image() && image == layer->image()->data()) { | |
| 1499 invalidateBackgroundObscurationStatus(); | |
| 1500 bool maybeAnimated = layer->image()->cachedImage() && layer->ima ge()->cachedImage()->getImage() && layer->image()->cachedImage()->getImage()->ma ybeAnimated(); | |
| 1501 if (maybeAnimated) | |
| 1502 setMayNeedPaintInvalidationAnimatgedBackgroundImage(); | |
| 1503 else | |
| 1504 setShouldDoFullPaintInvalidation(); | |
| 1505 break; | |
| 1506 } | |
| 1507 } | |
| 1488 } | 1508 } |
| 1489 | 1509 |
| 1490 ShapeValue* shapeOutsideValue = style()->shapeOutside(); | 1510 ShapeValue* shapeOutsideValue = style()->shapeOutside(); |
| 1491 if (!frameView()->isInPerformLayout() && isFloating() && shapeOutsideValue & & shapeOutsideValue->image() && shapeOutsideValue->image()->data() == image) { | 1511 if (!frameView()->isInPerformLayout() && isFloating() && shapeOutsideValue & & shapeOutsideValue->image() && shapeOutsideValue->image()->data() == image) { |
| 1492 ShapeOutsideInfo& info = ShapeOutsideInfo::ensureInfo(*this); | 1512 ShapeOutsideInfo& info = ShapeOutsideInfo::ensureInfo(*this); |
| 1493 if (!info.isComputingShape()) { | 1513 if (!info.isComputingShape()) { |
| 1494 info.markShapeAsDirty(); | 1514 info.markShapeAsDirty(); |
| 1495 markShapeOutsideDependentsForLayout(); | 1515 markShapeOutsideDependentsForLayout(); |
| 1496 } | 1516 } |
| 1497 } | 1517 } |
| 1498 | |
| 1499 if (!invalidatePaintOfLayerRectsForImage(image, style()->backgroundLayers(), true)) | |
|
chrishtr
2016/08/09 22:07:54
Why is it ok to delete this?
Xianzhu
2016/08/09 23:07:14
Line 1499 became line 1487-1494. Line 1500 became
| |
| 1500 invalidatePaintOfLayerRectsForImage(image, style()->maskLayers(), false) ; | |
| 1501 } | 1518 } |
| 1502 | 1519 |
| 1503 ResourcePriority LayoutBox::computeResourcePriority() const | 1520 ResourcePriority LayoutBox::computeResourcePriority() const |
| 1504 { | 1521 { |
| 1505 LayoutRect viewBounds = viewRect(); | 1522 LayoutRect viewBounds = viewRect(); |
| 1506 LayoutRect objectBounds = LayoutRect(absoluteContentBox()); | 1523 LayoutRect objectBounds = LayoutRect(absoluteContentBox()); |
| 1507 | 1524 |
| 1508 // The object bounds might be empty right now, so intersects will fail since it doesn't deal | 1525 // 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. | 1526 // with empty rects. Use LayoutRect::contains in that case. |
| 1510 bool isVisible; | 1527 bool isVisible; |
| 1511 if (!objectBounds.isEmpty()) | 1528 if (!objectBounds.isEmpty()) |
| 1512 isVisible = viewBounds.intersects(objectBounds); | 1529 isVisible = viewBounds.intersects(objectBounds); |
| 1513 else | 1530 else |
| 1514 isVisible = viewBounds.contains(objectBounds); | 1531 isVisible = viewBounds.contains(objectBounds); |
| 1515 | 1532 |
| 1516 LayoutRect screenRect; | 1533 LayoutRect screenRect; |
| 1517 if (!objectBounds.isEmpty()) { | 1534 if (!objectBounds.isEmpty()) { |
| 1518 screenRect = viewBounds; | 1535 screenRect = viewBounds; |
| 1519 screenRect.intersect(objectBounds); | 1536 screenRect.intersect(objectBounds); |
| 1520 } | 1537 } |
| 1521 | 1538 |
| 1522 int screenArea = 0; | 1539 int screenArea = 0; |
| 1523 if (!screenRect.isEmpty() && isVisible) | 1540 if (!screenRect.isEmpty() && isVisible) |
| 1524 screenArea = static_cast<uint32_t>(screenRect.width() * screenRect.heigh t()); | 1541 screenArea = static_cast<uint32_t>(screenRect.width() * screenRect.heigh t()); |
| 1525 return ResourcePriority(isVisible ? ResourcePriority::Visible : ResourcePrio rity::NotVisible, screenArea); | 1542 return ResourcePriority(isVisible ? ResourcePriority::Visible : ResourcePrio rity::NotVisible, screenArea); |
| 1526 } | 1543 } |
| 1527 | 1544 |
| 1528 bool LayoutBox::invalidatePaintOfLayerRectsForImage(WrappedImagePtr image, const FillLayer& layers, bool drawingBackground) | 1545 bool LayoutBox::intersectsVisibleViewport() const |
| 1529 { | |
| 1530 if (drawingBackground && (isDocumentElement() || backgroundStolenForBeingBod y())) | |
| 1531 return false; | |
| 1532 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex t()) { | |
| 1533 if (curLayer->image() && image == curLayer->image()->data()) { | |
| 1534 bool maybeAnimated = curLayer->image()->cachedImage() && curLayer->i mage()->cachedImage()->getImage() && curLayer->image()->cachedImage()->getImage( )->maybeAnimated(); | |
| 1535 if (maybeAnimated && drawingBackground) | |
| 1536 setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull); | |
| 1537 else | |
| 1538 setShouldDoFullPaintInvalidation(); | |
| 1539 | |
| 1540 if (drawingBackground) | |
| 1541 invalidateBackgroundObscurationStatus(); | |
| 1542 return true; | |
| 1543 } | |
| 1544 } | |
| 1545 return false; | |
| 1546 } | |
| 1547 | |
| 1548 bool LayoutBox::intersectsVisibleViewport() | |
| 1549 { | 1546 { |
| 1550 LayoutRect rect = visualOverflowRect(); | 1547 LayoutRect rect = visualOverflowRect(); |
| 1551 LayoutView* layoutView = view(); | 1548 LayoutView* layoutView = view(); |
| 1552 while (layoutView->frame()->ownerLayoutObject()) | 1549 while (layoutView->frame()->ownerLayoutObject()) |
| 1553 layoutView = layoutView->frame()->ownerLayoutObject()->view(); | 1550 layoutView = layoutView->frame()->ownerLayoutObject()->view(); |
| 1554 mapToVisualRectInAncestorSpace(layoutView, rect); | 1551 mapToVisualRectInAncestorSpace(layoutView, rect); |
| 1555 return rect.intersects(LayoutRect(layoutView->frameView()->getScrollableArea ()->visibleContentRectDouble())); | 1552 return rect.intersects(LayoutRect(layoutView->frameView()->getScrollableArea ()->visibleContentRectDouble())); |
| 1556 } | 1553 } |
| 1557 | 1554 |
| 1558 PaintInvalidationReason LayoutBox::invalidatePaintIfNeeded(const PaintInvalidati onState& paintInvalidationState) | 1555 PaintInvalidationReason LayoutBox::invalidatePaintIfNeeded(const PaintInvalidati onState& paintInvalidationState) |
| 1559 { | 1556 { |
| 1560 if (hasBoxDecorationBackground() | 1557 if (hasBoxDecorationBackground() |
| 1561 // We also paint overflow controls in background phase. | 1558 // We also paint overflow controls in background phase. |
| 1562 || (hasOverflowClip() && getScrollableArea()->hasOverflowControls())) { | 1559 || (hasOverflowClip() && getScrollableArea()->hasOverflowControls())) { |
| 1563 PaintLayer& layer = paintInvalidationState.paintingLayer(); | 1560 PaintLayer& layer = paintInvalidationState.paintingLayer(); |
| 1564 if (layer.layoutObject() != this) | 1561 if (layer.layoutObject() != this) |
| 1565 layer.setNeedsPaintPhaseDescendantBlockBackgrounds(); | 1562 layer.setNeedsPaintPhaseDescendantBlockBackgrounds(); |
| 1566 } | 1563 } |
| 1567 | 1564 |
| 1568 PaintInvalidationReason fullInvalidationReason = fullPaintInvalidationReason (); | |
| 1569 // If the current paint invalidation reason is PaintInvalidationDelayedFull, then this paint invalidation can delayed if the | |
| 1570 // LayoutBox in question is not on-screen. The logic to decide whether this is appropriate exists at the site of the original | |
| 1571 // paint invalidation that chose PaintInvalidationDelayedFull. | |
| 1572 if (fullInvalidationReason == PaintInvalidationDelayedFull) { | |
| 1573 if (!intersectsVisibleViewport()) | |
| 1574 return PaintInvalidationDelayedFull; | |
| 1575 | |
| 1576 // Reset state back to regular full paint invalidation if the object is onscreen. | |
| 1577 setShouldDoFullPaintInvalidation(PaintInvalidationFull); | |
| 1578 } | |
| 1579 | |
| 1580 PaintInvalidationReason reason = LayoutBoxModelObject::invalidatePaintIfNeed ed(paintInvalidationState); | 1565 PaintInvalidationReason reason = LayoutBoxModelObject::invalidatePaintIfNeed ed(paintInvalidationState); |
| 1581 | 1566 |
| 1582 if (PaintLayerScrollableArea* area = getScrollableArea()) | 1567 if (PaintLayerScrollableArea* area = getScrollableArea()) |
| 1583 area->invalidatePaintOfScrollControlsIfNeeded(paintInvalidationState); | 1568 area->invalidatePaintOfScrollControlsIfNeeded(paintInvalidationState); |
| 1584 | 1569 |
| 1585 // This is for the next invalidatePaintIfNeeded so must be at the end. | 1570 // This is for the next invalidatePaintIfNeeded so must be at the end. |
| 1586 savePreviousBoxSizesIfNeeded(); | 1571 savePreviousBoxSizesIfNeeded(); |
| 1587 return reason; | 1572 return reason; |
| 1588 } | 1573 } |
| 1589 | 1574 |
| (...skipping 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3971 if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layerForV erticalScrollbar()) | 3956 if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layerForV erticalScrollbar()) |
| 3972 return true; | 3957 return true; |
| 3973 } | 3958 } |
| 3974 return false; | 3959 return false; |
| 3975 } | 3960 } |
| 3976 | 3961 |
| 3977 PaintInvalidationReason LayoutBox::getPaintInvalidationReason(const PaintInvalid ationState& paintInvalidationState, | 3962 PaintInvalidationReason LayoutBox::getPaintInvalidationReason(const PaintInvalid ationState& paintInvalidationState, |
| 3978 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec t& newBounds, const LayoutPoint& newLocation) const | 3963 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec t& newBounds, const LayoutPoint& newLocation) const |
| 3979 { | 3964 { |
| 3980 PaintInvalidationReason invalidationReason = LayoutBoxModelObject::getPaintI nvalidationReason(paintInvalidationState, oldBounds, oldLocation, newBounds, new Location); | 3965 PaintInvalidationReason invalidationReason = LayoutBoxModelObject::getPaintI nvalidationReason(paintInvalidationState, oldBounds, oldLocation, newBounds, new Location); |
| 3981 if (isFullPaintInvalidationReason(invalidationReason)) | 3966 |
| 3967 if (isFullPaintInvalidationReason(invalidationReason) && invalidationReason != PaintInvalidationDelayedFull) | |
| 3982 return invalidationReason; | 3968 return invalidationReason; |
| 3983 | 3969 |
| 3970 if (mayNeedPaintInvalidationAnimatedBackgroundImage() && !backgroundIsKnownT oBeObscured()) | |
| 3971 invalidationReason = PaintInvalidationDelayedFull; | |
| 3972 | |
| 3973 // If the current paint invalidation reason is PaintInvalidationDelayedFull, then this paint invalidation can delayed if the | |
| 3974 // LayoutBox in question is not on-screen. The logic to decide whether this is appropriate exists at the site of the original | |
| 3975 // paint invalidation that chose PaintInvalidationDelayedFull. | |
| 3976 if (invalidationReason == PaintInvalidationDelayedFull) { | |
| 3977 // Do regular full paint invalidation if the object is onscreen. | |
| 3978 return intersectsVisibleViewport() ? PaintInvalidationFull : PaintInvali dationDelayedFull; | |
| 3979 } | |
| 3980 | |
| 3984 if (isLayoutView()) { | 3981 if (isLayoutView()) { |
| 3985 const LayoutView* layoutView = toLayoutView(this); | 3982 const LayoutView* layoutView = toLayoutView(this); |
| 3986 // In normal compositing mode, root background doesn't need to be invali dated for | 3983 // In normal compositing mode, root background doesn't need to be invali dated for |
| 3987 // box changes, because the background always covers the whole document rect | 3984 // box changes, because the background always covers the whole document rect |
| 3988 // and clipping is done by compositor()->m_containerLayer. Also the scro llbars | 3985 // and clipping is done by compositor()->m_containerLayer. Also the scro llbars |
| 3989 // are always composited. There are no other box decoration on the Layou tView thus | 3986 // are always composited. There are no other box decoration on the Layou tView thus |
| 3990 // we can safely exit here. | 3987 // we can safely exit here. |
| 3991 if (layoutView->usesCompositing() && (!document().settings() || !documen t().settings()->rootLayerScrolls())) | 3988 if (layoutView->usesCompositing() && (!document().settings() || !documen t().settings()->rootLayerScrolls())) |
| 3992 return invalidationReason; | 3989 return invalidationReason; |
| 3993 } | 3990 } |
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4987 m_rareData->m_snapAreas->remove(&snapArea); | 4984 m_rareData->m_snapAreas->remove(&snapArea); |
| 4988 } | 4985 } |
| 4989 } | 4986 } |
| 4990 | 4987 |
| 4991 SnapAreaSet* LayoutBox::snapAreas() const | 4988 SnapAreaSet* LayoutBox::snapAreas() const |
| 4992 { | 4989 { |
| 4993 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; | 4990 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; |
| 4994 } | 4991 } |
| 4995 | 4992 |
| 4996 } // namespace blink | 4993 } // namespace blink |
| OLD | NEW |