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

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

Issue 1484163002: Raster display item lists via a visual rect RTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to head and flip for LayoutInline. Created 4 years, 6 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 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 result.expand(-verticalScrollbarWidth(), 0); 984 result.expand(-verticalScrollbarWidth(), 0);
985 return result; 985 return result;
986 } 986 }
987 987
988 bool LayoutBox::mapScrollingContentsRectToBoxSpace(LayoutRect& rect, ApplyOverfl owClipFlag applyOverflowClip, VisualRectFlags visualRectFlags) const 988 bool LayoutBox::mapScrollingContentsRectToBoxSpace(LayoutRect& rect, ApplyOverfl owClipFlag applyOverflowClip, VisualRectFlags visualRectFlags) const
989 { 989 {
990 if (!hasOverflowClip()) 990 if (!hasOverflowClip())
991 return true; 991 return true;
992 992
993 LayoutSize offset = LayoutSize(-scrolledContentOffset()); 993 LayoutSize offset = LayoutSize(-scrolledContentOffset());
994 if (UNLIKELY(hasFlippedBlocksWritingMode()))
995 offset.setWidth(-offset.width());
996 rect.move(offset); 994 rect.move(offset);
997 995
998 if (applyOverflowClip == ApplyNonScrollOverflowClip && scrollsOverflow()) 996 if (applyOverflowClip == ApplyNonScrollOverflowClip && scrollsOverflow())
999 return true; 997 return true;
1000 998
1001 flipForWritingMode(rect);
1002
1003 LayoutRect clipRect = overflowClipRect(LayoutPoint()); 999 LayoutRect clipRect = overflowClipRect(LayoutPoint());
1004 1000
1005 bool doesIntersect; 1001 bool doesIntersect;
1006 if (visualRectFlags & EdgeInclusive) { 1002 if (visualRectFlags & EdgeInclusive) {
1007 doesIntersect = rect.inclusiveIntersect(clipRect); 1003 doesIntersect = rect.inclusiveIntersect(clipRect);
1008 } else { 1004 } else {
1009 rect.intersect(clipRect); 1005 rect.intersect(clipRect);
1010 doesIntersect = !rect.isEmpty(); 1006 doesIntersect = !rect.isEmpty();
1011 } 1007 }
1012 if (doesIntersect)
1013 flipForWritingMode(rect);
1014 return doesIntersect; 1008 return doesIntersect;
1015 } 1009 }
1016 1010
1017 void LayoutBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layou tUnit& maxLogicalWidth) const 1011 void LayoutBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layou tUnit& maxLogicalWidth) const
1018 { 1012 {
1019 minLogicalWidth = minPreferredLogicalWidth() - borderAndPaddingLogicalWidth( ); 1013 minLogicalWidth = minPreferredLogicalWidth() - borderAndPaddingLogicalWidth( );
1020 maxLogicalWidth = maxPreferredLogicalWidth() - borderAndPaddingLogicalWidth( ); 1014 maxLogicalWidth = maxPreferredLogicalWidth() - borderAndPaddingLogicalWidth( );
1021 } 1015 }
1022 1016
1023 LayoutUnit LayoutBox::minPreferredLogicalWidth() const 1017 LayoutUnit LayoutBox::minPreferredLogicalWidth() const
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 if (parent == ancestorToStopAt) 2033 if (parent == ancestorToStopAt)
2040 break; 2034 break;
2041 } 2035 }
2042 rect.move(-offsetFromContainer); 2036 rect.move(-offsetFromContainer);
2043 } 2037 }
2044 2038
2045 bool LayoutBox::mapToVisualRectInAncestorSpace(const LayoutBoxModelObject* ances tor, LayoutRect& rect, VisualRectFlags visualRectFlags) const 2039 bool LayoutBox::mapToVisualRectInAncestorSpace(const LayoutBoxModelObject* ances tor, LayoutRect& rect, VisualRectFlags visualRectFlags) const
2046 { 2040 {
2047 inflateVisualRectForReflectionAndFilter(rect); 2041 inflateVisualRectForReflectionAndFilter(rect);
2048 2042
2049 if (ancestor == this) { 2043 if (ancestor == this)
2050 // The final rect returned is always in the physical coordinate space of the ancestor.
2051 flipForWritingMode(rect);
2052 return true; 2044 return true;
2053 }
2054 2045
2055 bool ancestorSkipped; 2046 bool ancestorSkipped;
2056 bool filterOrReflectionSkipped; 2047 bool filterOrReflectionSkipped;
2057 LayoutObject* container = this->container(ancestor, &ancestorSkipped, &filte rOrReflectionSkipped); 2048 LayoutObject* container = this->container(ancestor, &ancestorSkipped, &filte rOrReflectionSkipped);
2058 if (!container) 2049 if (!container)
2059 return true; 2050 return true;
2060 2051
2061 if (filterOrReflectionSkipped) 2052 if (filterOrReflectionSkipped)
2062 inflateVisualRectForReflectionAndFilterUnderContainer(rect, *container, ancestor); 2053 inflateVisualRectForReflectionAndFilterUnderContainer(rect, *container, ancestor);
2063 2054
2064 // The rect we compute at each step is shifted by our x/y offset in the pare nt container's coordinate space.
2065 // Only when we cross a writing mode boundary will we have to possibly flipF orWritingMode (to convert into a more
2066 // appropriate offset corner for the enclosing container).
2067 if (isWritingModeRoot()) {
2068 flipForWritingMode(rect);
2069 // Then flip rect currently in physical direction to container's block d irection.
2070 if (container->styleRef().isFlippedBlocksWritingMode())
2071 rect.setX(m_frameRect.width() - rect.maxX());
2072 }
2073
2074 LayoutPoint topLeft = rect.location(); 2055 LayoutPoint topLeft = rect.location();
2075 topLeft.move(locationOffset()); 2056 if (!(isInline() && isLayoutInline()))
2057 topLeft.moveBy(topLeftLocation());
2076 2058
2077 // We are now in our parent container's coordinate space. Apply our transfo rm to obtain a bounding box 2059 // We are now in our parent container's coordinate space. Apply our transfo rm to obtain a bounding box
2078 // in the parent's coordinate space that encloses us. 2060 // in the parent's coordinate space that encloses us.
2079 if (hasLayer() && layer()->transform()) { 2061 if (hasLayer() && layer()->transform()) {
2080 rect = LayoutRect(layer()->transform()->mapRect(pixelSnappedIntRect(rect ))); 2062 rect = LayoutRect(layer()->transform()->mapRect(pixelSnappedIntRect(rect )));
2081 topLeft = rect.location(); 2063 topLeft = rect.location();
2082 topLeft.move(locationOffset()); 2064 topLeft.moveBy(topLeftLocation());
2083 } 2065 }
2084 2066
2085 const ComputedStyle& styleToUse = styleRef(); 2067 const ComputedStyle& styleToUse = styleRef();
2086 EPosition position = styleToUse.position(); 2068 EPosition position = styleToUse.position();
2087 if (position == AbsolutePosition && container->isInFlowPositioned() && conta iner->isLayoutInline()) { 2069 if (position == AbsolutePosition && container->isInFlowPositioned() && conta iner->isLayoutInline()) {
2088 topLeft += toLayoutInline(container)->offsetForInFlowPositionedInline(*t his); 2070 topLeft += toLayoutInline(container)->offsetForInFlowPositionedInline(*t his);
2089 } else if (styleToUse.hasInFlowPosition() && layer()) { 2071 } else if (styleToUse.hasInFlowPosition() && layer()) {
2090 // Apply the relative position offset when invalidating a rectangle. Th e layer 2072 // Apply the relative position offset when invalidating a rectangle. Th e layer
2091 // is translated, but the layout box isn't, so we need to do this to get the 2073 // is translated, but the layout box isn't, so we need to do this to get the
2092 // right dirty rect. Since this is called from LayoutObject::setStyle, the relative position 2074 // right dirty rect. Since this is called from LayoutObject::setStyle, the relative position
2093 // flag on the LayoutObject has been cleared, so use the one on the styl e(). 2075 // flag on the LayoutObject has been cleared, so use the one on the styl e().
2094 topLeft += layer()->offsetForInFlowPosition(); 2076 topLeft += layer()->offsetForInFlowPosition();
2095 } 2077 }
2096 2078
2097 // FIXME: We ignore the lightweight clipping rect that controls use, since i f |o| is in mid-layout, 2079 // FIXME: We ignore the lightweight clipping rect that controls use, since i f |o| is in mid-layout,
2098 // its controlClipRect will be wrong. For overflow clip we use the values ca ched by the layer. 2080 // its controlClipRect will be wrong. For overflow clip we use the values ca ched by the layer.
2099 rect.setLocation(topLeft); 2081 rect.setLocation(topLeft);
2100 2082
2101 if (container->isBox() && !toLayoutBox(container)->mapScrollingContentsRectT oBoxSpace(rect, container == ancestor ? ApplyNonScrollOverflowClip : ApplyOverfl owClip, visualRectFlags)) 2083 if (container->isBox() && !toLayoutBox(container)->mapScrollingContentsRectT oBoxSpace(rect, container == ancestor ? ApplyNonScrollOverflowClip : ApplyOverfl owClip, visualRectFlags))
2102 return false; 2084 return false;
2103 2085
2104 if (ancestorSkipped) { 2086 if (ancestorSkipped) {
2105 // If the ancestor is below o, then we need to map the rect into ancesto r's coordinates. 2087 // If the ancestor is below the container, then we need to map the rect into ancestor's coordinates.
2106 LayoutSize containerOffset = ancestor->offsetFromAncestorContainer(conta iner); 2088 LayoutSize containerOffset = ancestor->offsetFromAncestorContainer(conta iner);
2107 rect.move(-containerOffset); 2089 rect.move(-containerOffset);
2108 // If the ancestor is fixed, then the rect is already in its coordinates so doesn't need viewport-adjusting. 2090 // If the ancestor is fixed, then the rect is already in its coordinates so doesn't need viewport-adjusting.
2109 if (ancestor->style()->position() != FixedPosition && container->isLayou tView() && position == FixedPosition) 2091 if (ancestor->style()->position() != FixedPosition && container->isLayou tView() && position == FixedPosition)
2110 toLayoutView(container)->adjustOffsetForFixedPosition(rect); 2092 toLayoutView(container)->adjustOffsetForFixedPosition(rect);
2111 return true; 2093 return true;
2112 } 2094 }
2113 2095
2114 if (container->isLayoutView()) 2096 if (container->isLayoutView())
2115 return toLayoutView(container)->mapToVisualRectInAncestorSpace(ancestor, rect, position == FixedPosition ? IsFixed : 0, visualRectFlags); 2097 return toLayoutView(container)->mapToVisualRectInAncestorSpace(ancestor, rect, position == FixedPosition ? IsFixed : 0, visualRectFlags);
(...skipping 2762 matching lines...) Expand 10 before | Expand all | Expand 10 after
4878 m_rareData->m_snapAreas->remove(&snapArea); 4860 m_rareData->m_snapAreas->remove(&snapArea);
4879 } 4861 }
4880 } 4862 }
4881 4863
4882 SnapAreaSet* LayoutBox::snapAreas() const 4864 SnapAreaSet* LayoutBox::snapAreas() const
4883 { 4865 {
4884 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; 4866 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr;
4885 } 4867 }
4886 4868
4887 } // namespace blink 4869 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698