| 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 Apple Inc. All rights reserved. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2010 Google Inc. All rights reserved. | 7 * Copyright (C) 2010 Google Inc. 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 202 |
| 203 // A continuation of this LayoutObject should be destroyed at subclasses. | 203 // A continuation of this LayoutObject should be destroyed at subclasses. |
| 204 ASSERT(!continuation()); | 204 ASSERT(!continuation()); |
| 205 | 205 |
| 206 if (isPositioned()) { | 206 if (isPositioned()) { |
| 207 // Don't use this->view() because the document's layoutView has been set to | 207 // Don't use this->view() because the document's layoutView has been set to |
| 208 // 0 during destruction. | 208 // 0 during destruction. |
| 209 if (LocalFrame* frame = this->frame()) { | 209 if (LocalFrame* frame = this->frame()) { |
| 210 if (FrameView* frameView = frame->view()) { | 210 if (FrameView* frameView = frame->view()) { |
| 211 if (style()->hasViewportConstrainedPosition()) | 211 if (style()->hasViewportConstrainedPosition()) |
| 212 frameView->removeViewportConstrainedObject(this); | 212 frameView->removeViewportConstrainedObject(*this); |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| 217 LayoutObject::willBeDestroyed(); | 217 LayoutObject::willBeDestroyed(); |
| 218 | 218 |
| 219 destroyLayer(); | 219 destroyLayer(); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void LayoutBoxModelObject::styleWillChange(StyleDifference diff, | 222 void LayoutBoxModelObject::styleWillChange(StyleDifference diff, |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 // position constraints then. | 398 // position constraints then. |
| 399 if (layer()) | 399 if (layer()) |
| 400 layer()->setNeedsCompositingInputsUpdate(); | 400 layer()->setNeedsCompositingInputsUpdate(); |
| 401 | 401 |
| 402 // TODO(pdr): When slimming paint v2 is enabled, we will need to | 402 // TODO(pdr): When slimming paint v2 is enabled, we will need to |
| 403 // invalidate the scroll paint property subtree for this so main thread | 403 // invalidate the scroll paint property subtree for this so main thread |
| 404 // scroll reasons are recomputed. | 404 // scroll reasons are recomputed. |
| 405 } else { | 405 } else { |
| 406 // This may get re-added to viewport constrained objects if the object | 406 // This may get re-added to viewport constrained objects if the object |
| 407 // went from sticky to fixed. | 407 // went from sticky to fixed. |
| 408 frameView->removeViewportConstrainedObject(this); | 408 frameView->removeViewportConstrainedObject(*this); |
| 409 | 409 |
| 410 // Remove sticky constraints for this layer. | 410 // Remove sticky constraints for this layer. |
| 411 if (layer()) { | 411 if (layer()) { |
| 412 DisableCompositingQueryAsserts disabler; | 412 DisableCompositingQueryAsserts disabler; |
| 413 if (const PaintLayer* ancestorOverflowLayer = | 413 if (const PaintLayer* ancestorOverflowLayer = |
| 414 layer()->ancestorOverflowLayer()) { | 414 layer()->ancestorOverflowLayer()) { |
| 415 if (PaintLayerScrollableArea* scrollableArea = | 415 if (PaintLayerScrollableArea* scrollableArea = |
| 416 ancestorOverflowLayer->getScrollableArea()) | 416 ancestorOverflowLayer->getScrollableArea()) |
| 417 scrollableArea->invalidateStickyConstraintsFor(layer()); | 417 scrollableArea->invalidateStickyConstraintsFor(layer()); |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 | 420 |
| 421 // TODO(pdr): When slimming paint v2 is enabled, we will need to | 421 // TODO(pdr): When slimming paint v2 is enabled, we will need to |
| 422 // invalidate the scroll paint property subtree for this so main thread | 422 // invalidate the scroll paint property subtree for this so main thread |
| 423 // scroll reasons are recomputed. | 423 // scroll reasons are recomputed. |
| 424 } | 424 } |
| 425 } | 425 } |
| 426 | 426 |
| 427 if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) { | 427 if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) { |
| 428 if (newStyleIsViewportConstained && layer()) | 428 if (newStyleIsViewportConstained && layer()) |
| 429 frameView->addViewportConstrainedObject(this); | 429 frameView->addViewportConstrainedObject(*this); |
| 430 else | 430 else |
| 431 frameView->removeViewportConstrainedObject(this); | 431 frameView->removeViewportConstrainedObject(*this); |
| 432 } | 432 } |
| 433 } | 433 } |
| 434 } | 434 } |
| 435 | 435 |
| 436 void LayoutBoxModelObject::invalidateStickyConstraints() { | 436 void LayoutBoxModelObject::invalidateStickyConstraints() { |
| 437 PaintLayer* enclosing = enclosingLayer(); | 437 PaintLayer* enclosing = enclosingLayer(); |
| 438 | 438 |
| 439 if (PaintLayerScrollableArea* scrollableArea = | 439 if (PaintLayerScrollableArea* scrollableArea = |
| 440 enclosing->getScrollableArea()) { | 440 enclosing->getScrollableArea()) { |
| 441 scrollableArea->invalidateAllStickyConstraints(); | 441 scrollableArea->invalidateAllStickyConstraints(); |
| 442 // If this object doesn't have a layer and its enclosing layer is a scroller | 442 // If this object doesn't have a layer and its enclosing layer is a scroller |
| 443 // then we don't need to invalidate the sticky constraints on the ancestor | 443 // then we don't need to invalidate the sticky constraints on the ancestor |
| 444 // scroller because the enclosing scroller won't have changed size. | 444 // scroller because the enclosing scroller won't have changed size. |
| 445 if (!layer()) | 445 if (!layer()) |
| 446 return; | 446 return; |
| 447 } | 447 } |
| 448 | 448 |
| 449 // This intentionally uses the stale ancestor overflow layer compositing input | 449 // This intentionally uses the stale ancestor overflow layer compositing input |
| 450 // as if we have saved constraints for this layer they were saved in the | 450 // as if we have saved constraints for this layer they were saved in the |
| 451 // previous frame. | 451 // previous frame. |
| 452 DisableCompositingQueryAsserts disabler; | 452 DisableCompositingQueryAsserts disabler; |
| 453 if (const PaintLayer* ancestorOverflowLayer = | 453 if (const PaintLayer* ancestorOverflowLayer = |
| 454 enclosing->ancestorOverflowLayer()) | 454 enclosing->ancestorOverflowLayer()) |
| 455 ancestorOverflowLayer->getScrollableArea() | 455 ancestorOverflowLayer->getScrollableArea() |
| 456 ->invalidateAllStickyConstraints(); | 456 ->invalidateAllStickyConstraints(); |
| 457 } | 457 } |
| 458 | 458 |
| 459 void LayoutBoxModelObject::createLayer() { | 459 void LayoutBoxModelObject::createLayer() { |
| 460 ASSERT(!m_layer); | 460 ASSERT(!m_layer); |
| 461 m_layer = WTF::makeUnique<PaintLayer>(this); | 461 m_layer = WTF::makeUnique<PaintLayer>(*this); |
| 462 setHasLayer(true); | 462 setHasLayer(true); |
| 463 m_layer->insertOnlyThisLayerAfterStyleChange(); | 463 m_layer->insertOnlyThisLayerAfterStyleChange(); |
| 464 } | 464 } |
| 465 | 465 |
| 466 void LayoutBoxModelObject::destroyLayer() { | 466 void LayoutBoxModelObject::destroyLayer() { |
| 467 setHasLayer(false); | 467 setHasLayer(false); |
| 468 m_layer = nullptr; | 468 m_layer = nullptr; |
| 469 } | 469 } |
| 470 | 470 |
| 471 bool LayoutBoxModelObject::hasSelfPaintingLayer() const { | 471 bool LayoutBoxModelObject::hasSelfPaintingLayer() const { |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 MapCoordinatesFlags flags = 0; | 804 MapCoordinatesFlags flags = 0; |
| 805 skippedContainersOffset = | 805 skippedContainersOffset = |
| 806 toFloatSize(locationContainer | 806 toFloatSize(locationContainer |
| 807 ->localToAncestorQuadWithoutTransforms( | 807 ->localToAncestorQuadWithoutTransforms( |
| 808 FloatQuad(), containingBlock, flags) | 808 FloatQuad(), containingBlock, flags) |
| 809 .boundingBox() | 809 .boundingBox() |
| 810 .location()); | 810 .location()); |
| 811 LayoutBox* scrollAncestor = | 811 LayoutBox* scrollAncestor = |
| 812 layer()->ancestorOverflowLayer()->isRootLayer() | 812 layer()->ancestorOverflowLayer()->isRootLayer() |
| 813 ? nullptr | 813 ? nullptr |
| 814 : toLayoutBox(layer()->ancestorOverflowLayer()->layoutObject()); | 814 : &toLayoutBox(layer()->ancestorOverflowLayer()->layoutObject()); |
| 815 | 815 |
| 816 LayoutUnit maxContainerWidth = | 816 LayoutUnit maxContainerWidth = |
| 817 containingBlock->isLayoutView() | 817 containingBlock->isLayoutView() |
| 818 ? containingBlock->logicalWidth() | 818 ? containingBlock->logicalWidth() |
| 819 : containingBlock->containingBlockLogicalWidthForContent(); | 819 : containingBlock->containingBlockLogicalWidthForContent(); |
| 820 // Sticky positioned element ignore any override logical width on the | 820 // Sticky positioned element ignore any override logical width on the |
| 821 // containing block, as they don't call containingBlockLogicalWidthForContent. | 821 // containing block, as they don't call containingBlockLogicalWidthForContent. |
| 822 // It's unclear whether this is totally fine. | 822 // It's unclear whether this is totally fine. |
| 823 // Compute the container-relative area within which the sticky element is | 823 // Compute the container-relative area within which the sticky element is |
| 824 // allowed to move. | 824 // allowed to move. |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 StickyPositionScrollingConstraints::AnchorEdgeBottom); | 963 StickyPositionScrollingConstraints::AnchorEdgeBottom); |
| 964 } | 964 } |
| 965 scrollableArea->stickyConstraintsMap().set(layer(), constraints); | 965 scrollableArea->stickyConstraintsMap().set(layer(), constraints); |
| 966 } | 966 } |
| 967 | 967 |
| 968 FloatRect LayoutBoxModelObject::computeStickyConstrainingRect() const { | 968 FloatRect LayoutBoxModelObject::computeStickyConstrainingRect() const { |
| 969 if (layer()->ancestorOverflowLayer()->isRootLayer()) | 969 if (layer()->ancestorOverflowLayer()->isRootLayer()) |
| 970 return view()->frameView()->visibleContentRect(); | 970 return view()->frameView()->visibleContentRect(); |
| 971 | 971 |
| 972 LayoutBox* enclosingClippingBox = | 972 LayoutBox* enclosingClippingBox = |
| 973 toLayoutBox(layer()->ancestorOverflowLayer()->layoutObject()); | 973 layer()->ancestorOverflowLayer()->layoutBox(); |
| 974 DCHECK(enclosingClippingBox); |
| 974 FloatRect constrainingRect; | 975 FloatRect constrainingRect; |
| 975 constrainingRect = | 976 constrainingRect = |
| 976 FloatRect(enclosingClippingBox->overflowClipRect(LayoutPoint(DoublePoint( | 977 FloatRect(enclosingClippingBox->overflowClipRect(LayoutPoint(DoublePoint( |
| 977 enclosingClippingBox->getScrollableArea()->scrollPosition())))); | 978 enclosingClippingBox->getScrollableArea()->scrollPosition())))); |
| 978 constrainingRect.move( | 979 constrainingRect.move( |
| 979 -enclosingClippingBox->borderLeft() + enclosingClippingBox->paddingLeft(), | 980 -enclosingClippingBox->borderLeft() + enclosingClippingBox->paddingLeft(), |
| 980 -enclosingClippingBox->borderTop() + enclosingClippingBox->paddingTop()); | 981 -enclosingClippingBox->borderTop() + enclosingClippingBox->paddingTop()); |
| 981 constrainingRect.contract( | 982 constrainingRect.contract( |
| 982 FloatSize(enclosingClippingBox->paddingLeft() + | 983 FloatSize(enclosingClippingBox->paddingLeft() + |
| 983 enclosingClippingBox->paddingRight(), | 984 enclosingClippingBox->paddingRight(), |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 if (rootElementStyle->hasBackground()) | 1368 if (rootElementStyle->hasBackground()) |
| 1368 return false; | 1369 return false; |
| 1369 | 1370 |
| 1370 if (node() != document().firstBodyElement()) | 1371 if (node() != document().firstBodyElement()) |
| 1371 return false; | 1372 return false; |
| 1372 | 1373 |
| 1373 return true; | 1374 return true; |
| 1374 } | 1375 } |
| 1375 | 1376 |
| 1376 } // namespace blink | 1377 } // namespace blink |
| OLD | NEW |