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

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

Issue 1826853007: LayoutBox::mapContentsRectToVisibleRectInBorderBoxSpace() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pi
Patch Set: Enable comparison, DO NOT CQ Created 4 years, 8 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 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 } 951 }
952 952
953 IntSize LayoutBox::scrolledContentOffset() const 953 IntSize LayoutBox::scrolledContentOffset() const
954 { 954 {
955 ASSERT(hasOverflowClip()); 955 ASSERT(hasOverflowClip());
956 ASSERT(hasLayer()); 956 ASSERT(hasLayer());
957 // FIXME: Return DoubleSize here. crbug.com/414283. 957 // FIXME: Return DoubleSize here. crbug.com/414283.
958 return flooredIntSize(getScrollableArea()->scrollOffset()); 958 return flooredIntSize(getScrollableArea()->scrollOffset());
959 } 959 }
960 960
961 void LayoutBox::mapScrollingContentsRectToBoxSpace(LayoutRect& rect) const 961 bool LayoutBox::mapContentsRectToVisibleRectInBorderBoxSpace(LayoutRect& rect, V isibleRectFlags visibleRectFlags) const
962 { 962 {
963 ASSERT(hasLayer()); 963 if (!hasOverflowClip())
964 ASSERT(hasOverflowClip()); 964 return true;
965 965
966 // Apply reverse of scroll offset.
966 LayoutSize offset = LayoutSize(-scrolledContentOffset()); 967 LayoutSize offset = LayoutSize(-scrolledContentOffset());
967 if (UNLIKELY(hasFlippedBlocksWritingMode())) { 968 if (UNLIKELY(hasFlippedBlocksWritingMode())) {
968 if (isHorizontalWritingMode()) 969 if (isHorizontalWritingMode())
969 offset.setHeight(-offset.height()); 970 offset.setHeight(-offset.height());
970 else 971 else
971 offset.setWidth(-offset.width()); 972 offset.setWidth(-offset.width());
972 } 973 }
973 rect.move(offset); 974 rect.move(offset);
974 }
975 975
976 bool LayoutBox::applyOverflowClip(LayoutRect& rect, VisibleRectFlags visibleRect Flags) const 976 if (usesCompositedScrolling())
chrishtr 2016/03/28 16:34:31 I don't think this isn't right. These methods shou
Xianzhu 2016/03/28 17:35:21 Why? I think we should treat composited scrolling
chrishtr 2016/03/28 18:02:04 Because the concept of a visible rect should not t
Xianzhu 2016/03/28 18:15:37 Our current condition of applying clipping is "con
chrishtr 2016/03/28 19:28:53 I don't think case 1b is required at this point. i
Xianzhu 2016/03/28 19:42:10 The case is overflow:hidden which seems to to caus
Xianzhu 2016/03/28 19:43:01 The case is overflow:hidden which seems not to cau
chrishtr 2016/03/28 20:38:58 How about: if (container == ancestor) if (conta
Xianzhu 2016/03/28 21:12:08 It should work. It just looks weird to pass 'ances
chrishtr 2016/03/28 22:09:58 So you think it's good to try that in this patch?
977 { 977 return true;
978 ASSERT(hasLayer());
979 ASSERT(hasOverflowClip());
980 978
979 // Apply clip.
981 flipForWritingMode(rect); 980 flipForWritingMode(rect);
982
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
985 // anyway if its size does change.
986 LayoutRect clipRect(LayoutPoint(), LayoutSize(layer()->size())); 981 LayoutRect clipRect(LayoutPoint(), LayoutSize(layer()->size()));
987 bool doesIntersect; 982 bool doesIntersect;
988 if (visibleRectFlags & EdgeInclusive) { 983 if (visibleRectFlags & EdgeInclusive) {
989 doesIntersect = rect.inclusiveIntersect(clipRect); 984 doesIntersect = rect.inclusiveIntersect(clipRect);
990 } else { 985 } else {
991 rect.intersect(clipRect); 986 rect.intersect(clipRect);
992 doesIntersect = !rect.isEmpty(); 987 doesIntersect = !rect.isEmpty();
993 } 988 }
994 if (doesIntersect) 989 if (doesIntersect)
995 flipForWritingMode(rect); 990 flipForWritingMode(rect);
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 return LayoutRect(); 1927 return LayoutRect();
1933 } 1928 }
1934 1929
1935 return visualOverflowRect(); 1930 return visualOverflowRect();
1936 } 1931 }
1937 1932
1938 bool LayoutBox::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* ance stor, LayoutRect& rect, VisibleRectFlags visibleRectFlags) const 1933 bool LayoutBox::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* ance stor, LayoutRect& rect, VisibleRectFlags visibleRectFlags) const
1939 { 1934 {
1940 // The rect we compute at each step is shifted by our x/y offset in the pare nt container's coordinate space. 1935 // The rect we compute at each step is shifted by our x/y offset in the pare nt container's coordinate space.
1941 // Only when we cross a writing mode boundary will we have to possibly flipF orWritingMode (to convert into a more appropriate 1936 // Only when we cross a writing mode boundary will we have to possibly flipF orWritingMode (to convert into a more appropriate
1942 // offset corner for the enclosing container). This allows for a fully RL or BT document to issue paint invalidations 1937 // offset corner for the enclosing container). This allows for a fully RL or BT document to issue paint invalidations
chrishtr 2016/03/28 18:02:04 The sentence "This allows..." refers to invalidati
Xianzhu 2016/03/28 21:12:08 Acknowledged.
1943 // properly even during layout, since the rect remains flipped all the way u ntil the end. 1938 // properly even during layout, since the rect remains flipped all the way u ntil the end.
1944 // 1939 //
1945 // LayoutView::computeRectForPaintInvalidation then converts the rect to phy sical coordinates. We also convert to 1940 // We convert to physical when we hit the ancestor. Therefore the final rect returned is always in the
1946 // physical when we hit the ancestor. Therefore the final rect returned is a lways in the
1947 // physical coordinate space of the ancestor. 1941 // physical coordinate space of the ancestor.
1948 const ComputedStyle& styleToUse = styleRef(); 1942 const ComputedStyle& styleToUse = styleRef();
1949 1943
1950 EPosition position = styleToUse.position(); 1944 EPosition position = styleToUse.position();
1951 1945
1952 // We need to inflate the paint invalidation rect before we use paintInvalid ationState, 1946 // We need to inflate the paint invalidation rect before we use paintInvalid ationState,
1953 // else we would forget to inflate it for the current layoutObject. FIXME: I f these were 1947 // else we would forget to inflate it for the current layoutObject. FIXME: I f these were
1954 // included into the visual overflow for paint invalidation, we wouldn't hav e this issue. 1948 // included into the visual overflow for paint invalidation, we wouldn't hav e this issue.
1955 inflatePaintInvalidationRectForReflectionAndFilter(rect); 1949 inflatePaintInvalidationRectForReflectionAndFilter(rect);
1956 1950
1957 if (ancestor == this) { 1951 if (ancestor == this)
1958 if (ancestor->style()->isFlippedBlocksWritingMode())
1959 flipForWritingMode(rect);
1960 return true; 1952 return true;
1961 }
1962 1953
1963 bool containerSkipped; 1954 bool containerSkipped;
1964 LayoutObject* container = this->container(ancestor, &containerSkipped); 1955 LayoutObject* container = this->container(ancestor, &containerSkipped);
1965 if (!container) 1956 if (!container)
1966 return true; 1957 return true;
1967 1958
1968 if (isWritingModeRoot())
1969 flipForWritingMode(rect);
1970
1971 LayoutPoint topLeft = rect.location(); 1959 LayoutPoint topLeft = rect.location();
1972 topLeft.move(locationOffset()); 1960 topLeft.move(locationOffset());
1973 1961
1974 // We are now in our parent container's coordinate space. Apply our transfo rm to obtain a bounding box 1962 // We are now in our parent container's coordinate space. Apply our transfo rm to obtain a bounding box
1975 // in the parent's coordinate space that encloses us. 1963 // in the parent's coordinate space that encloses us.
1976 if (hasLayer() && layer()->transform()) { 1964 if (hasLayer() && layer()->transform()) {
1977 rect = LayoutRect(layer()->transform()->mapRect(pixelSnappedIntRect(rect ))); 1965 rect = LayoutRect(layer()->transform()->mapRect(pixelSnappedIntRect(rect )));
1978 topLeft = rect.location(); 1966 topLeft = rect.location();
1979 topLeft.move(locationOffset()); 1967 topLeft.move(locationOffset());
1980 } 1968 }
1981 1969
1982 if (position == AbsolutePosition && container->isInFlowPositioned() && conta iner->isLayoutInline()) { 1970 if (position == AbsolutePosition && container->isInFlowPositioned() && conta iner->isLayoutInline()) {
1983 topLeft += toLayoutInline(container)->offsetForInFlowPositionedInline(*t his); 1971 topLeft += toLayoutInline(container)->offsetForInFlowPositionedInline(*t his);
1984 } else if (styleToUse.hasInFlowPosition() && layer()) { 1972 } else if (styleToUse.hasInFlowPosition() && layer()) {
1985 // Apply the relative position offset when invalidating a rectangle. Th e layer 1973 // Apply the relative position offset when invalidating a rectangle. Th e layer
1986 // is translated, but the layout box isn't, so we need to do this to get the 1974 // is translated, but the layout box isn't, so we need to do this to get the
1987 // right dirty rect. Since this is called from LayoutObject::setStyle, the relative position 1975 // right dirty rect. Since this is called from LayoutObject::setStyle, the relative position
1988 // flag on the LayoutObject has been cleared, so use the one on the styl e(). 1976 // flag on the LayoutObject has been cleared, so use the one on the styl e().
1989 topLeft += layer()->offsetForInFlowPosition(); 1977 topLeft += layer()->offsetForInFlowPosition();
1990 } 1978 }
1991 1979
1992 // FIXME: We ignore the lightweight clipping rect that controls use, since i f |o| is in mid-layout,
1993 // its controlClipRect will be wrong. For overflow clip we use the values ca ched by the layer.
1994 rect.setLocation(topLeft); 1980 rect.setLocation(topLeft);
1995 if (container->hasOverflowClip()) { 1981
1982 if (container->isBox()) {
1996 LayoutBox* containerBox = toLayoutBox(container); 1983 LayoutBox* containerBox = toLayoutBox(container);
1997 containerBox->mapScrollingContentsRectToBoxSpace(rect); 1984 if (!containerBox->mapContentsRectToVisibleRectInBorderBoxSpace(rect, vi sibleRectFlags))
1998 if (container != ancestor && !containerBox->applyOverflowClip(rect, visi bleRectFlags))
1999 return false; 1985 return false;
1986
1987 if (containerBox == ancestor || containerBox->isWritingModeRoot())
chrishtr 2016/03/28 16:34:31 Why also if containerBox == ancestor? Why does thi
Xianzhu 2016/03/28 17:35:21 1. The function is to map the rect in physical coo
chrishtr 2016/03/28 18:02:04 Makes sense, thanks for explaining.
Xianzhu 2016/03/28 18:15:37 I'd like to explore always-physical-coordinates wa
1988 containerBox->flipForWritingMode(rect);
2000 } 1989 }
2001 1990
2002 if (containerSkipped) { 1991 if (containerSkipped) {
2003 // If the paintInvalidationContainer is below o, then we need to map the rect into paintInvalidationContainer's coordinates. 1992 // If the ancestor is below o, then we need to map the rect into paintIn validationContainer's coordinates.
2004 LayoutSize containerOffset = ancestor->offsetFromAncestorContainer(conta iner); 1993 LayoutSize containerOffset = ancestor->offsetFromAncestorContainer(conta iner);
2005 rect.move(-containerOffset); 1994 rect.move(-containerOffset);
2006 // If the paintInvalidationContainer is fixed, then the rect is already in its coordinates so doesn't need viewport-adjusting. 1995 // If the ancestor is fixed, then the rect is already in its coordinates so doesn't need viewport-adjusting.
2007 if (ancestor->style()->position() != FixedPosition && container->isLayou tView() && position == FixedPosition) 1996 if (ancestor->style()->position() != FixedPosition && container->isLayou tView() && position == FixedPosition)
2008 toLayoutView(container)->adjustOffsetForFixedPosition(rect); 1997 toLayoutView(container)->adjustOffsetForFixedPosition(rect);
2009 return true; 1998 return true;
2010 } 1999 }
2011 2000
2012 if (container->isLayoutView()) 2001 if (container->isLayoutView())
2013 return toLayoutView(container)->mapToVisibleRectInAncestorSpace(ancestor , rect, position == FixedPosition ? IsFixed : 0, visibleRectFlags); 2002 return toLayoutView(container)->mapToVisibleRectInAncestorSpace(ancestor , rect, position == FixedPosition ? IsFixed : 0, visibleRectFlags);
2014 else 2003 else
2015 return container->mapToVisibleRectInAncestorSpace(ancestor, rect, visibl eRectFlags); 2004 return container->mapToVisibleRectInAncestorSpace(ancestor, rect, visibl eRectFlags);
2016 } 2005 }
(...skipping 2686 matching lines...) Expand 10 before | Expand all | Expand 10 after
4703 4692
4704 void LayoutBox::clearPercentHeightDescendants() 4693 void LayoutBox::clearPercentHeightDescendants()
4705 { 4694 {
4706 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde r(this)) { 4695 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde r(this)) {
4707 if (curr->isBox()) 4696 if (curr->isBox())
4708 toLayoutBox(curr)->removeFromPercentHeightContainer(); 4697 toLayoutBox(curr)->removeFromPercentHeightContainer();
4709 } 4698 }
4710 } 4699 }
4711 4700
4712 } // namespace blink 4701 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698