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 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 } | 932 } |
933 | 933 |
934 IntSize LayoutBox::scrolledContentOffset() const | 934 IntSize LayoutBox::scrolledContentOffset() const |
935 { | 935 { |
936 ASSERT(hasOverflowClip()); | 936 ASSERT(hasOverflowClip()); |
937 ASSERT(hasLayer()); | 937 ASSERT(hasLayer()); |
938 // FIXME: Return DoubleSize here. crbug.com/414283. | 938 // FIXME: Return DoubleSize here. crbug.com/414283. |
939 return flooredIntSize(layer()->scrollableArea()->scrollOffset()); | 939 return flooredIntSize(layer()->scrollableArea()->scrollOffset()); |
940 } | 940 } |
941 | 941 |
| 942 void LayoutBox::applyCachedScrollOffsetForPaintInvalidation(LayoutRect& paintRec
t) const |
| 943 { |
| 944 ASSERT(hasLayer()); |
| 945 ASSERT(hasOverflowClip()); |
| 946 |
| 947 LayoutSize offset = LayoutSize(-scrolledContentOffset()); |
| 948 if (UNLIKELY(hasFlippedBlocksWritingMode())) { |
| 949 if (isHorizontalWritingMode()) |
| 950 offset.setHeight(-offset.height()); |
| 951 else |
| 952 offset.setWidth(-offset.width()); |
| 953 } |
| 954 paintRect.move(offset); |
| 955 } |
| 956 |
942 void LayoutBox::applyCachedClipAndScrollOffsetForPaintInvalidation(LayoutRect& p
aintRect) const | 957 void LayoutBox::applyCachedClipAndScrollOffsetForPaintInvalidation(LayoutRect& p
aintRect) const |
943 { | 958 { |
944 ASSERT(hasLayer()); | 959 ASSERT(hasLayer()); |
945 ASSERT(hasOverflowClip()); | 960 ASSERT(hasOverflowClip()); |
946 | 961 |
| 962 applyCachedScrollOffsetForPaintInvalidation(paintRect); |
947 flipForWritingMode(paintRect); | 963 flipForWritingMode(paintRect); |
948 paintRect.move(-scrolledContentOffset()); // For overflow:auto/scroll/hidden
. | |
949 | |
950 // Do not clip scroll layer contents because the compositor expects the whol
e layer | |
951 // to be always invalidated in-time. | |
952 if (usesCompositedScrolling()) { | |
953 flipForWritingMode(paintRect); | |
954 return; | |
955 } | |
956 | 964 |
957 // size() is inaccurate if we're in the middle of a layout of this LayoutBox
, so use the | 965 // size() is inaccurate if we're in the middle of a layout of this LayoutBox
, so use the |
958 // layer's size instead. Even if the layer's size is wrong, the layer itself
will issue paint invalidations | 966 // layer's size instead. Even if the layer's size is wrong, the layer itself
will issue paint invalidations |
959 // anyway if its size does change. | 967 // anyway if its size does change. |
960 LayoutRect clipRect(LayoutPoint(), LayoutSize(layer()->size())); | 968 LayoutRect clipRect(LayoutPoint(), LayoutSize(layer()->size())); |
961 paintRect = intersection(paintRect, clipRect); | 969 paintRect = intersection(paintRect, clipRect); |
962 flipForWritingMode(paintRect); | 970 flipForWritingMode(paintRect); |
963 } | 971 } |
964 | 972 |
965 void LayoutBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layou
tUnit& maxLogicalWidth) const | 973 void LayoutBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layou
tUnit& maxLogicalWidth) const |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 } | 1427 } |
1420 return false; | 1428 return false; |
1421 } | 1429 } |
1422 | 1430 |
1423 bool LayoutBox::intersectsVisibleViewport() | 1431 bool LayoutBox::intersectsVisibleViewport() |
1424 { | 1432 { |
1425 LayoutRect rect = visualOverflowRect(); | 1433 LayoutRect rect = visualOverflowRect(); |
1426 LayoutView* layoutView = view(); | 1434 LayoutView* layoutView = view(); |
1427 while (layoutView->frame()->ownerLayoutObject()) | 1435 while (layoutView->frame()->ownerLayoutObject()) |
1428 layoutView = layoutView->frame()->ownerLayoutObject()->view(); | 1436 layoutView = layoutView->frame()->ownerLayoutObject()->view(); |
1429 mapRectToPaintInvalidationBacking(layoutView, rect, 0); | 1437 mapToVisibleRectInContainerSpace(layoutView, rect, 0); |
1430 return rect.intersects(LayoutRect(layoutView->frameView()->scrollableArea()-
>visibleContentRectDouble())); | 1438 return rect.intersects(LayoutRect(layoutView->frameView()->scrollableArea()-
>visibleContentRectDouble())); |
1431 } | 1439 } |
1432 | 1440 |
1433 PaintInvalidationReason LayoutBox::invalidatePaintIfNeeded(PaintInvalidationStat
e& paintInvalidationState, const LayoutBoxModelObject& paintInvalidationContaine
r) | 1441 PaintInvalidationReason LayoutBox::invalidatePaintIfNeeded(PaintInvalidationStat
e& paintInvalidationState, const LayoutBoxModelObject& paintInvalidationContaine
r) |
1434 { | 1442 { |
1435 PaintInvalidationReason fullInvalidationReason = fullPaintInvalidationReason
(); | 1443 PaintInvalidationReason fullInvalidationReason = fullPaintInvalidationReason
(); |
1436 // If the current paint invalidation reason is PaintInvalidationDelayedFull,
then this paint invalidation can delayed if the | 1444 // If the current paint invalidation reason is PaintInvalidationDelayedFull,
then this paint invalidation can delayed if the |
1437 // LayoutBox in question is not on-screen. The logic to decide whether this
is appropriate exists at the site of the original | 1445 // LayoutBox in question is not on-screen. The logic to decide whether this
is appropriate exists at the site of the original |
1438 // paint invalidation that chose PaintInvalidationDelayedFull. | 1446 // paint invalidation that chose PaintInvalidationDelayedFull. |
1439 if (fullInvalidationReason == PaintInvalidationDelayedFull) { | 1447 if (fullInvalidationReason == PaintInvalidationDelayedFull) { |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1849 LayoutRect LayoutBox::clippedOverflowRectForPaintInvalidation(const LayoutBoxMod
elObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalid
ationState) const | 1857 LayoutRect LayoutBox::clippedOverflowRectForPaintInvalidation(const LayoutBoxMod
elObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalid
ationState) const |
1850 { | 1858 { |
1851 if (style()->visibility() != VISIBLE) { | 1859 if (style()->visibility() != VISIBLE) { |
1852 PaintLayer* layer = enclosingLayer(); | 1860 PaintLayer* layer = enclosingLayer(); |
1853 layer->updateDescendantDependentFlags(); | 1861 layer->updateDescendantDependentFlags(); |
1854 if (layer->subtreeIsInvisible()) | 1862 if (layer->subtreeIsInvisible()) |
1855 return LayoutRect(); | 1863 return LayoutRect(); |
1856 } | 1864 } |
1857 | 1865 |
1858 LayoutRect r = visualOverflowRect(); | 1866 LayoutRect r = visualOverflowRect(); |
1859 mapRectToPaintInvalidationBacking(paintInvalidationContainer, r, paintInvali
dationState); | 1867 mapToVisibleRectInContainerSpace(paintInvalidationContainer, r, paintInvalid
ationState); |
1860 return r; | 1868 return r; |
1861 } | 1869 } |
1862 | 1870 |
1863 void LayoutBox::mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* pa
intInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* paintI
nvalidationState) const | 1871 void LayoutBox::mapToVisibleRectInContainerSpace(const LayoutBoxModelObject* pai
ntInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* paintIn
validationState) const |
1864 { | 1872 { |
1865 // The rect we compute at each step is shifted by our x/y offset in the pare
nt container's coordinate space. | 1873 // The rect we compute at each step is shifted by our x/y offset in the pare
nt container's coordinate space. |
1866 // Only when we cross a writing mode boundary will we have to possibly flipF
orWritingMode (to convert into a more appropriate | 1874 // Only when we cross a writing mode boundary will we have to possibly flipF
orWritingMode (to convert into a more appropriate |
1867 // offset corner for the enclosing container). This allows for a fully RL or
BT document to issue paint invalidations | 1875 // offset corner for the enclosing container). This allows for a fully RL or
BT document to issue paint invalidations |
1868 // properly even during layout, since the rect remains flipped all the way u
ntil the end. | 1876 // properly even during layout, since the rect remains flipped all the way u
ntil the end. |
1869 // | 1877 // |
1870 // LayoutView::computeRectForPaintInvalidation then converts the rect to phy
sical coordinates. We also convert to | 1878 // LayoutView::computeRectForPaintInvalidation then converts the rect to phy
sical coordinates. We also convert to |
1871 // physical when we hit a paintInvalidationContainer boundary. Therefore the
final rect returned is always in the | 1879 // physical when we hit a paintInvalidationContainer boundary. Therefore the
final rect returned is always in the |
1872 // physical coordinate space of the paintInvalidationContainer. | 1880 // physical coordinate space of the paintInvalidationContainer. |
1873 const ComputedStyle& styleToUse = styleRef(); | 1881 const ComputedStyle& styleToUse = styleRef(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1927 // right dirty rect. Since this is called from LayoutObject::setStyle,
the relative position | 1935 // right dirty rect. Since this is called from LayoutObject::setStyle,
the relative position |
1928 // flag on the LayoutObject has been cleared, so use the one on the styl
e(). | 1936 // flag on the LayoutObject has been cleared, so use the one on the styl
e(). |
1929 topLeft += layer()->offsetForInFlowPosition(); | 1937 topLeft += layer()->offsetForInFlowPosition(); |
1930 } | 1938 } |
1931 | 1939 |
1932 // FIXME: We ignore the lightweight clipping rect that controls use, since i
f |o| is in mid-layout, | 1940 // FIXME: We ignore the lightweight clipping rect that controls use, since i
f |o| is in mid-layout, |
1933 // its controlClipRect will be wrong. For overflow clip we use the values ca
ched by the layer. | 1941 // its controlClipRect will be wrong. For overflow clip we use the values ca
ched by the layer. |
1934 rect.setLocation(topLeft); | 1942 rect.setLocation(topLeft); |
1935 if (o->hasOverflowClip()) { | 1943 if (o->hasOverflowClip()) { |
1936 LayoutBox* containerBox = toLayoutBox(o); | 1944 LayoutBox* containerBox = toLayoutBox(o); |
1937 containerBox->applyCachedClipAndScrollOffsetForPaintInvalidation(rect); | 1945 if (o == paintInvalidationContainer) |
| 1946 containerBox->applyCachedScrollOffsetForPaintInvalidation(rect); |
| 1947 else |
| 1948 containerBox->applyCachedClipAndScrollOffsetForPaintInvalidation(rec
t); |
1938 if (rect.isEmpty()) | 1949 if (rect.isEmpty()) |
1939 return; | 1950 return; |
1940 } | 1951 } |
1941 | 1952 |
1942 if (containerSkipped) { | 1953 if (containerSkipped) { |
1943 // If the paintInvalidationContainer is below o, then we need to map the
rect into paintInvalidationContainer's coordinates. | 1954 // If the paintInvalidationContainer is below o, then we need to map the
rect into paintInvalidationContainer's coordinates. |
1944 LayoutSize containerOffset = paintInvalidationContainer->offsetFromAnces
torContainer(o); | 1955 LayoutSize containerOffset = paintInvalidationContainer->offsetFromAnces
torContainer(o); |
1945 rect.move(-containerOffset); | 1956 rect.move(-containerOffset); |
1946 // If the paintInvalidationContainer is fixed, then the rect is already
in its coordinates so doesn't need viewport-adjusting. | 1957 // If the paintInvalidationContainer is fixed, then the rect is already
in its coordinates so doesn't need viewport-adjusting. |
1947 if (paintInvalidationContainer->style()->position() != FixedPosition &&
o->isLayoutView()) | 1958 if (paintInvalidationContainer->style()->position() != FixedPosition &&
o->isLayoutView()) |
1948 toLayoutView(o)->adjustViewportConstrainedOffset(rect, LayoutView::v
iewportConstrainedPosition(position)); | 1959 toLayoutView(o)->adjustViewportConstrainedOffset(rect, LayoutView::v
iewportConstrainedPosition(position)); |
1949 return; | 1960 return; |
1950 } | 1961 } |
1951 | 1962 |
1952 if (o->isLayoutView()) | 1963 if (o->isLayoutView()) |
1953 toLayoutView(o)->mapRectToPaintInvalidationBacking(paintInvalidationCont
ainer, rect, LayoutView::viewportConstrainedPosition(position), paintInvalidatio
nState); | 1964 toLayoutView(o)->mapToVisibleRectInContainerSpace(paintInvalidationConta
iner, rect, LayoutView::viewportConstrainedPosition(position), paintInvalidation
State); |
1954 else | 1965 else |
1955 o->mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, p
aintInvalidationState); | 1966 o->mapToVisibleRectInContainerSpace(paintInvalidationContainer, rect, pa
intInvalidationState); |
1956 } | 1967 } |
1957 | 1968 |
1958 void LayoutBox::inflatePaintInvalidationRectForReflectionAndFilter(LayoutRect& p
aintInvalidationRect) const | 1969 void LayoutBox::inflatePaintInvalidationRectForReflectionAndFilter(LayoutRect& p
aintInvalidationRect) const |
1959 { | 1970 { |
1960 if (hasReflection()) | 1971 if (hasReflection()) |
1961 paintInvalidationRect.unite(reflectedRect(paintInvalidationRect)); | 1972 paintInvalidationRect.unite(reflectedRect(paintInvalidationRect)); |
1962 | 1973 |
1963 if (layer() && layer()->hasFilter()) | 1974 if (layer() && layer()->hasFilter()) |
1964 paintInvalidationRect.expand(layer()->filterOutsets()); | 1975 paintInvalidationRect.expand(layer()->filterOutsets()); |
1965 } | 1976 } |
(...skipping 2891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4857 } | 4868 } |
4858 | 4869 |
4859 void LayoutBox::clearPreviousPaintInvalidationRects() | 4870 void LayoutBox::clearPreviousPaintInvalidationRects() |
4860 { | 4871 { |
4861 LayoutBoxModelObject::clearPreviousPaintInvalidationRects(); | 4872 LayoutBoxModelObject::clearPreviousPaintInvalidationRects(); |
4862 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) | 4873 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) |
4863 scrollableArea->clearPreviousPaintInvalidationRects(); | 4874 scrollableArea->clearPreviousPaintInvalidationRects(); |
4864 } | 4875 } |
4865 | 4876 |
4866 } // namespace blink | 4877 } // namespace blink |
OLD | NEW |