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 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
966 LayoutSize offset = LayoutSize(-scrolledContentOffset()); | 966 LayoutSize offset = LayoutSize(-scrolledContentOffset()); |
967 if (UNLIKELY(hasFlippedBlocksWritingMode())) { | 967 if (UNLIKELY(hasFlippedBlocksWritingMode())) { |
968 if (isHorizontalWritingMode()) | 968 if (isHorizontalWritingMode()) |
969 offset.setHeight(-offset.height()); | 969 offset.setHeight(-offset.height()); |
970 else | 970 else |
971 offset.setWidth(-offset.width()); | 971 offset.setWidth(-offset.width()); |
972 } | 972 } |
973 rect.move(offset); | 973 rect.move(offset); |
974 } | 974 } |
975 | 975 |
976 void LayoutBox::applyOverflowClip(LayoutRect& rect) const | 976 bool LayoutBox::applyOverflowClip(LayoutRect& rect, bool edgeInclusive) const |
977 { | 977 { |
978 ASSERT(hasLayer()); | 978 ASSERT(hasLayer()); |
979 ASSERT(hasOverflowClip()); | 979 ASSERT(hasOverflowClip()); |
980 | 980 |
981 flipForWritingMode(rect); | 981 flipForWritingMode(rect); |
982 | 982 |
983 // size() is inaccurate if we're in the middle of a layout of this LayoutBox , so use the | 983 // size() is inaccurate if we're in the middle of a layout of this LayoutBox , so use the |
984 // layer's size instead. Even if the layer's size is wrong, the layer itself will issue paint invalidations | 984 // layer's size instead. Even if the layer's size is wrong, the layer itself will issue paint invalidations |
985 // anyway if its size does change. | 985 // anyway if its size does change. |
986 LayoutRect clipRect(LayoutPoint(), LayoutSize(layer()->size())); | 986 LayoutRect clipRect(LayoutPoint(), LayoutSize(layer()->size())); |
987 rect = intersection(rect, clipRect); | 987 bool doesIntersect; |
988 flipForWritingMode(rect); | 988 if (edgeInclusive) { |
989 doesIntersect = rect.inclusiveIntersect(clipRect); | |
990 } else { | |
991 rect.intersect(clipRect); | |
992 doesIntersect = !rect.isEmpty(); | |
eae
2016/03/22 00:13:50
LayoutRect::intersects will only ever return true
szager1
2016/03/22 00:55:48
That's not true:
bool LayoutRect::intersects(cons
eae
2016/03/22 17:54:15
Oh, my bad. You're right. Never mind!
| |
993 } | |
994 if (doesIntersect) | |
995 flipForWritingMode(rect); | |
996 return doesIntersect; | |
989 } | 997 } |
990 | 998 |
991 void LayoutBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layou tUnit& maxLogicalWidth) const | 999 void LayoutBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layou tUnit& maxLogicalWidth) const |
992 { | 1000 { |
993 minLogicalWidth = minPreferredLogicalWidth() - borderAndPaddingLogicalWidth( ); | 1001 minLogicalWidth = minPreferredLogicalWidth() - borderAndPaddingLogicalWidth( ); |
994 maxLogicalWidth = maxPreferredLogicalWidth() - borderAndPaddingLogicalWidth( ); | 1002 maxLogicalWidth = maxPreferredLogicalWidth() - borderAndPaddingLogicalWidth( ); |
995 } | 1003 } |
996 | 1004 |
997 LayoutUnit LayoutBox::minPreferredLogicalWidth() const | 1005 LayoutUnit LayoutBox::minPreferredLogicalWidth() const |
998 { | 1006 { |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1467 } | 1475 } |
1468 return false; | 1476 return false; |
1469 } | 1477 } |
1470 | 1478 |
1471 bool LayoutBox::intersectsVisibleViewport() | 1479 bool LayoutBox::intersectsVisibleViewport() |
1472 { | 1480 { |
1473 LayoutRect rect = visualOverflowRect(); | 1481 LayoutRect rect = visualOverflowRect(); |
1474 LayoutView* layoutView = view(); | 1482 LayoutView* layoutView = view(); |
1475 while (layoutView->frame()->ownerLayoutObject()) | 1483 while (layoutView->frame()->ownerLayoutObject()) |
1476 layoutView = layoutView->frame()->ownerLayoutObject()->view(); | 1484 layoutView = layoutView->frame()->ownerLayoutObject()->view(); |
1477 mapToVisibleRectInAncestorSpace(layoutView, rect, nullptr); | 1485 mapToVisibleRectInAncestorSpace(layoutView, rect, nullptr, false); |
1478 return rect.intersects(LayoutRect(layoutView->frameView()->getScrollableArea ()->visibleContentRectDouble())); | 1486 return rect.intersects(LayoutRect(layoutView->frameView()->getScrollableArea ()->visibleContentRectDouble())); |
1479 } | 1487 } |
1480 | 1488 |
1481 PaintInvalidationReason LayoutBox::invalidatePaintIfNeeded(const PaintInvalidati onState& paintInvalidationState) | 1489 PaintInvalidationReason LayoutBox::invalidatePaintIfNeeded(const PaintInvalidati onState& paintInvalidationState) |
1482 { | 1490 { |
1483 if (isFloating()) | 1491 if (isFloating()) |
1484 paintInvalidationState.enclosingSelfPaintingLayer(*this).setNeedsPaintPh aseFloat(); | 1492 paintInvalidationState.enclosingSelfPaintingLayer(*this).setNeedsPaintPh aseFloat(); |
1485 | 1493 |
1486 if (hasBoxDecorationBackground() | 1494 if (hasBoxDecorationBackground() |
1487 // We also paint overflow controls in background phase. | 1495 // We also paint overflow controls in background phase. |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1918 LayoutRect LayoutBox::clippedOverflowRectForPaintInvalidation(const LayoutBoxMod elObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalid ationState) const | 1926 LayoutRect LayoutBox::clippedOverflowRectForPaintInvalidation(const LayoutBoxMod elObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalid ationState) const |
1919 { | 1927 { |
1920 if (style()->visibility() != VISIBLE) { | 1928 if (style()->visibility() != VISIBLE) { |
1921 PaintLayer* layer = enclosingLayer(); | 1929 PaintLayer* layer = enclosingLayer(); |
1922 layer->updateDescendantDependentFlags(); | 1930 layer->updateDescendantDependentFlags(); |
1923 if (layer->subtreeIsInvisible()) | 1931 if (layer->subtreeIsInvisible()) |
1924 return LayoutRect(); | 1932 return LayoutRect(); |
1925 } | 1933 } |
1926 | 1934 |
1927 LayoutRect r = visualOverflowRect(); | 1935 LayoutRect r = visualOverflowRect(); |
1928 mapToVisibleRectInAncestorSpace(paintInvalidationContainer, r, paintInvalida tionState); | 1936 mapToVisibleRectInAncestorSpace(paintInvalidationContainer, r, paintInvalida tionState, false); |
1929 return r; | 1937 return r; |
1930 } | 1938 } |
1931 | 1939 |
1932 void LayoutBox::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* ance stor, LayoutRect& rect, const PaintInvalidationState* paintInvalidationState) co nst | 1940 bool LayoutBox::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* ance stor, LayoutRect& rect, const PaintInvalidationState* paintInvalidationState, bo ol edgeInclusive) const |
1933 { | 1941 { |
1934 // The rect we compute at each step is shifted by our x/y offset in the pare nt container's coordinate space. | 1942 // The rect we compute at each step is shifted by our x/y offset in the pare nt container's coordinate space. |
1935 // Only when we cross a writing mode boundary will we have to possibly flipF orWritingMode (to convert into a more appropriate | 1943 // Only when we cross a writing mode boundary will we have to possibly flipF orWritingMode (to convert into a more appropriate |
1936 // offset corner for the enclosing container). This allows for a fully RL or BT document to issue paint invalidations | 1944 // offset corner for the enclosing container). This allows for a fully RL or BT document to issue paint invalidations |
1937 // properly even during layout, since the rect remains flipped all the way u ntil the end. | 1945 // properly even during layout, since the rect remains flipped all the way u ntil the end. |
1938 // | 1946 // |
1939 // LayoutView::computeRectForPaintInvalidation then converts the rect to phy sical coordinates. We also convert to | 1947 // LayoutView::computeRectForPaintInvalidation then converts the rect to phy sical coordinates. We also convert to |
1940 // physical when we hit a paintInvalidationContainer boundary. Therefore the final rect returned is always in the | 1948 // physical when we hit a paintInvalidationContainer boundary. Therefore the final rect returned is always in the |
1941 // physical coordinate space of the paintInvalidationContainer. | 1949 // physical coordinate space of the paintInvalidationContainer. |
1942 const ComputedStyle& styleToUse = styleRef(); | 1950 const ComputedStyle& styleToUse = styleRef(); |
1943 | 1951 |
1944 EPosition position = styleToUse.position(); | 1952 EPosition position = styleToUse.position(); |
1945 | 1953 |
1946 // We need to inflate the paint invalidation rect before we use paintInvalid ationState, | 1954 // We need to inflate the paint invalidation rect before we use paintInvalid ationState, |
1947 // else we would forget to inflate it for the current layoutObject. FIXME: I f these were | 1955 // else we would forget to inflate it for the current layoutObject. FIXME: I f these were |
1948 // included into the visual overflow for repaint, we wouldn't have this issu e. | 1956 // included into the visual overflow for repaint, we wouldn't have this issu e. |
1949 inflatePaintInvalidationRectForReflectionAndFilter(rect); | 1957 inflatePaintInvalidationRectForReflectionAndFilter(rect); |
1950 | 1958 |
1951 if (paintInvalidationState && paintInvalidationState->canMapToAncestor(ances tor) && position != FixedPosition) { | 1959 if (paintInvalidationState && paintInvalidationState->canMapToAncestor(ances tor) && position != FixedPosition) { |
1952 paintInvalidationState->mapObjectRectToAncestor(*this, ancestor, rect); | 1960 return paintInvalidationState->mapObjectRectToAncestor(*this, ancestor, rect, edgeInclusive); |
1953 return; | |
1954 } | 1961 } |
1955 | 1962 |
1956 if (ancestor == this) { | 1963 if (ancestor == this) { |
1957 if (ancestor->style()->isFlippedBlocksWritingMode()) | 1964 if (ancestor->style()->isFlippedBlocksWritingMode()) |
1958 flipForWritingMode(rect); | 1965 flipForWritingMode(rect); |
1959 return; | 1966 return true; |
1960 } | 1967 } |
1961 | 1968 |
1962 bool containerSkipped; | 1969 bool containerSkipped; |
1963 LayoutObject* container = this->container(ancestor, &containerSkipped); | 1970 LayoutObject* container = this->container(ancestor, &containerSkipped); |
1964 if (!container) | 1971 if (!container) |
1965 return; | 1972 return true; |
1966 | 1973 |
1967 if (isWritingModeRoot()) | 1974 if (isWritingModeRoot()) |
1968 flipForWritingMode(rect); | 1975 flipForWritingMode(rect); |
1969 | 1976 |
1970 LayoutPoint topLeft = rect.location(); | 1977 LayoutPoint topLeft = rect.location(); |
1971 topLeft.move(locationOffset()); | 1978 topLeft.move(locationOffset()); |
1972 | 1979 |
1973 // We are now in our parent container's coordinate space. Apply our transfo rm to obtain a bounding box | 1980 // We are now in our parent container's coordinate space. Apply our transfo rm to obtain a bounding box |
1974 // in the parent's coordinate space that encloses us. | 1981 // in the parent's coordinate space that encloses us. |
1975 if (hasLayer() && layer()->transform()) { | 1982 if (hasLayer() && layer()->transform()) { |
(...skipping 11 matching lines...) Expand all Loading... | |
1987 // flag on the LayoutObject has been cleared, so use the one on the styl e(). | 1994 // flag on the LayoutObject has been cleared, so use the one on the styl e(). |
1988 topLeft += layer()->offsetForInFlowPosition(); | 1995 topLeft += layer()->offsetForInFlowPosition(); |
1989 } | 1996 } |
1990 | 1997 |
1991 // FIXME: We ignore the lightweight clipping rect that controls use, since i f |o| is in mid-layout, | 1998 // FIXME: We ignore the lightweight clipping rect that controls use, since i f |o| is in mid-layout, |
1992 // its controlClipRect will be wrong. For overflow clip we use the values ca ched by the layer. | 1999 // its controlClipRect will be wrong. For overflow clip we use the values ca ched by the layer. |
1993 rect.setLocation(topLeft); | 2000 rect.setLocation(topLeft); |
1994 if (container->hasOverflowClip()) { | 2001 if (container->hasOverflowClip()) { |
1995 LayoutBox* containerBox = toLayoutBox(container); | 2002 LayoutBox* containerBox = toLayoutBox(container); |
1996 containerBox->mapScrollingContentsRectToBoxSpace(rect); | 2003 containerBox->mapScrollingContentsRectToBoxSpace(rect); |
1997 if (container != ancestor) | 2004 if (container != ancestor && !containerBox->applyOverflowClip(rect, edge Inclusive)) |
1998 containerBox->applyOverflowClip(rect); | 2005 return false; |
1999 if (rect.isEmpty()) | |
2000 return; | |
2001 } | 2006 } |
2002 | 2007 |
2003 if (containerSkipped) { | 2008 if (containerSkipped) { |
2004 // If the paintInvalidationContainer is below o, then we need to map the rect into paintInvalidationContainer's coordinates. | 2009 // If the paintInvalidationContainer is below o, then we need to map the rect into paintInvalidationContainer's coordinates. |
2005 LayoutSize containerOffset = ancestor->offsetFromAncestorContainer(conta iner); | 2010 LayoutSize containerOffset = ancestor->offsetFromAncestorContainer(conta iner); |
2006 rect.move(-containerOffset); | 2011 rect.move(-containerOffset); |
2007 // If the paintInvalidationContainer is fixed, then the rect is already in its coordinates so doesn't need viewport-adjusting. | 2012 // If the paintInvalidationContainer is fixed, then the rect is already in its coordinates so doesn't need viewport-adjusting. |
2008 if (ancestor->style()->position() != FixedPosition && container->isLayou tView()) | 2013 if (ancestor->style()->position() != FixedPosition && container->isLayou tView()) |
2009 toLayoutView(container)->adjustViewportConstrainedOffset(rect, Layou tView::toViewportConstrainedPosition(position)); | 2014 toLayoutView(container)->adjustViewportConstrainedOffset(rect, Layou tView::toViewportConstrainedPosition(position)); |
2010 return; | 2015 return true; |
2011 } | 2016 } |
2012 | 2017 |
2013 if (container->isLayoutView()) | 2018 if (container->isLayoutView()) |
2014 toLayoutView(container)->mapToVisibleRectInAncestorSpace(ancestor, rect, LayoutView::toViewportConstrainedPosition(position), paintInvalidationState); | 2019 return toLayoutView(container)->mapToVisibleRectInAncestorSpace(ancestor , rect, LayoutView::toViewportConstrainedPosition(position), paintInvalidationSt ate, edgeInclusive); |
2015 else | 2020 else |
2016 container->mapToVisibleRectInAncestorSpace(ancestor, rect, paintInvalida tionState); | 2021 return container->mapToVisibleRectInAncestorSpace(ancestor, rect, paintI nvalidationState, edgeInclusive); |
2017 } | 2022 } |
2018 | 2023 |
2019 void LayoutBox::inflatePaintInvalidationRectForReflectionAndFilter(LayoutRect& p aintInvalidationRect) const | 2024 void LayoutBox::inflatePaintInvalidationRectForReflectionAndFilter(LayoutRect& p aintInvalidationRect) const |
2020 { | 2025 { |
2021 if (hasReflection()) | 2026 if (hasReflection()) |
2022 paintInvalidationRect.unite(reflectedRect(paintInvalidationRect)); | 2027 paintInvalidationRect.unite(reflectedRect(paintInvalidationRect)); |
2023 | 2028 |
2024 if (layer() && layer()->hasFilter()) | 2029 if (layer() && layer()->hasFilter()) |
2025 paintInvalidationRect.expand(layer()->filterOutsets()); | 2030 paintInvalidationRect.expand(layer()->filterOutsets()); |
2026 } | 2031 } |
(...skipping 2677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4704 | 4709 |
4705 void LayoutBox::clearPercentHeightDescendants() | 4710 void LayoutBox::clearPercentHeightDescendants() |
4706 { | 4711 { |
4707 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde r(this)) { | 4712 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde r(this)) { |
4708 if (curr->isBox()) | 4713 if (curr->isBox()) |
4709 toLayoutBox(curr)->removeFromPercentHeightContainer(); | 4714 toLayoutBox(curr)->removeFromPercentHeightContainer(); |
4710 } | 4715 } |
4711 } | 4716 } |
4712 | 4717 |
4713 } // namespace blink | 4718 } // namespace blink |
OLD | NEW |