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

Side by Side Diff: sky/engine/core/rendering/RenderBox.cpp

Issue 688213002: First pass at removing dead vertical writing mode code. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « sky/engine/core/rendering/RenderBox.h ('k') | sky/engine/core/rendering/RenderBoxModelObject.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 if (isFloating() && !isOutOfFlowPositioned() && newStyle.hasOutOfFlo wPosition()) 131 if (isFloating() && !isOutOfFlowPositioned() && newStyle.hasOutOfFlo wPosition())
132 removeFloatingOrPositionedChildFromBlockLists(); 132 removeFloatingOrPositionedChildFromBlockLists();
133 } 133 }
134 } 134 }
135 135
136 RenderBoxModelObject::styleWillChange(diff, newStyle); 136 RenderBoxModelObject::styleWillChange(diff, newStyle);
137 } 137 }
138 138
139 void RenderBox::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle ) 139 void RenderBox::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle )
140 { 140 {
141 // Horizontal writing mode definition is updated in RenderBoxModelObject::up dateFromStyle,
142 // (as part of the RenderBoxModelObject::styleDidChange call below). So, we can safely cache the horizontal
143 // writing mode value before style change here.
144 bool oldHorizontalWritingMode = isHorizontalWritingMode();
145
146 RenderBoxModelObject::styleDidChange(diff, oldStyle); 141 RenderBoxModelObject::styleDidChange(diff, oldStyle);
147 142
148 RenderStyle* newStyle = style(); 143 RenderStyle* newStyle = style();
149 if (needsLayout() && oldStyle) { 144 if (needsLayout() && oldStyle) {
150 RenderBlock::removePercentHeightDescendantIfNeeded(this); 145 RenderBlock::removePercentHeightDescendantIfNeeded(this);
151 146
152 // Normally we can do optimized positioning layout for absolute/fixed po sitioned objects. There is one special case, however, which is 147 // Normally we can do optimized positioning layout for absolute/fixed po sitioned objects. There is one special case, however, which is
153 // when the positioned object's margin-before is changed. In this case t he parent has to get a layout in order to run margin collapsing 148 // when the positioned object's margin-before is changed. In this case t he parent has to get a layout in order to run margin collapsing
154 // to determine the new static position. 149 // to determine the new static position.
155 if (isOutOfFlowPositioned() && newStyle->hasStaticBlockPosition(isHorizo ntalWritingMode()) && oldStyle->marginBefore() != newStyle->marginBefore() 150 if (isOutOfFlowPositioned() && newStyle->hasStaticBlockPosition() && old Style->marginBefore() != newStyle->marginBefore()
156 && parent() && !parent()->normalChildNeedsLayout()) 151 && parent() && !parent()->normalChildNeedsLayout())
157 parent()->setChildNeedsLayout(); 152 parent()->setChildNeedsLayout();
158 } 153 }
159 154
160 if (RenderBlock::hasPercentHeightContainerMap() && slowFirstChild()
161 && oldHorizontalWritingMode != isHorizontalWritingMode())
162 RenderBlock::clearPercentHeightDescendantsFrom(this);
163
164 // If our zoom factor changes and we have a defined scrollLeft/Top, we need to adjust that value into the 155 // If our zoom factor changes and we have a defined scrollLeft/Top, we need to adjust that value into the
165 // new zoomed coordinate space. 156 // new zoomed coordinate space.
166 if (hasOverflowClip() && oldStyle && newStyle && oldStyle->effectiveZoom() ! = newStyle->effectiveZoom() && layer()) { 157 if (hasOverflowClip() && oldStyle && newStyle && oldStyle->effectiveZoom() ! = newStyle->effectiveZoom() && layer()) {
167 if (int left = layer()->scrollableArea()->scrollXOffset()) { 158 if (int left = layer()->scrollableArea()->scrollXOffset()) {
168 left = (left / oldStyle->effectiveZoom()) * newStyle->effectiveZoom( ); 159 left = (left / oldStyle->effectiveZoom()) * newStyle->effectiveZoom( );
169 layer()->scrollableArea()->scrollToXOffset(left); 160 layer()->scrollableArea()->scrollToXOffset(left);
170 } 161 }
171 if (int top = layer()->scrollableArea()->scrollYOffset()) { 162 if (int top = layer()->scrollableArea()->scrollYOffset()) {
172 top = (top / oldStyle->effectiveZoom()) * newStyle->effectiveZoom(); 163 top = (top / oldStyle->effectiveZoom()) * newStyle->effectiveZoom();
173 layer()->scrollableArea()->scrollToYOffset(top); 164 layer()->scrollableArea()->scrollToYOffset(top);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 return 0; 503 return 0;
513 504
514 return layer()->scrollableArea()->horizontalScrollbarHeight(); 505 return layer()->scrollableArea()->horizontalScrollbarHeight();
515 } 506 }
516 507
517 int RenderBox::instrinsicScrollbarLogicalWidth() const 508 int RenderBox::instrinsicScrollbarLogicalWidth() const
518 { 509 {
519 if (!hasOverflowClip()) 510 if (!hasOverflowClip())
520 return 0; 511 return 0;
521 512
522 if (isHorizontalWritingMode() && style()->overflowY() == OSCROLL) { 513 if (style()->overflowY() == OSCROLL) {
523 ASSERT(layer()->scrollableArea() && layer()->scrollableArea()->hasVertic alScrollbar()); 514 ASSERT(layer()->scrollableArea() && layer()->scrollableArea()->hasVertic alScrollbar());
524 return verticalScrollbarWidth(); 515 return verticalScrollbarWidth();
525 } 516 }
526 517
527 if (!isHorizontalWritingMode() && style()->overflowX() == OSCROLL) {
528 ASSERT(layer()->scrollableArea() && layer()->scrollableArea()->hasHorizo ntalScrollbar());
529 return horizontalScrollbarHeight();
530 }
531
532 return 0; 518 return 0;
533 } 519 }
534 520
535 bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float delta) 521 bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float delta)
536 { 522 {
537 // Presumably the same issue as in setScrollTop. See crbug.com/343132. 523 // Presumably the same issue as in setScrollTop. See crbug.com/343132.
538 DisableCompositingQueryAsserts disabler; 524 DisableCompositingQueryAsserts disabler;
539 if (!layer() || !layer()->scrollableArea()) 525 if (!layer() || !layer()->scrollableArea())
540 return false; 526 return false;
541 return layer()->scrollableArea()->scroll(direction, granularity, delta); 527 return layer()->scrollableArea()->scroll(direction, granularity, delta);
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 1498
1513 RenderBlock* cb = containingBlock(); 1499 RenderBlock* cb = containingBlock();
1514 if (cb->hasOverrideHeight()) 1500 if (cb->hasOverrideHeight())
1515 return cb->overrideLogicalContentHeight(); 1501 return cb->overrideLogicalContentHeight();
1516 1502
1517 RenderStyle* containingBlockStyle = cb->style(); 1503 RenderStyle* containingBlockStyle = cb->style();
1518 Length logicalHeightLength = containingBlockStyle->logicalHeight(); 1504 Length logicalHeightLength = containingBlockStyle->logicalHeight();
1519 1505
1520 // FIXME: For now just support fixed heights. Eventually should support per centage heights as well. 1506 // FIXME: For now just support fixed heights. Eventually should support per centage heights as well.
1521 if (!logicalHeightLength.isFixed()) { 1507 if (!logicalHeightLength.isFixed()) {
1522 LayoutUnit fillFallbackExtent = containingBlockStyle->isHorizontalWritin gMode() 1508 LayoutUnit fillFallbackExtent = view()->frameView()->unscaledVisibleCont entSize().height();
1523 ? view()->frameView()->unscaledVisibleContentSize().height()
1524 : view()->frameView()->unscaledVisibleContentSize().width();
1525 LayoutUnit fillAvailableExtent = containingBlock()->availableLogicalHeig ht(ExcludeMarginBorderPadding); 1509 LayoutUnit fillAvailableExtent = containingBlock()->availableLogicalHeig ht(ExcludeMarginBorderPadding);
1526 return std::min(fillAvailableExtent, fillFallbackExtent); 1510 return std::min(fillAvailableExtent, fillFallbackExtent);
1527 } 1511 }
1528 1512
1529 // Use the content box logical height as specified by the style. 1513 // Use the content box logical height as specified by the style.
1530 return cb->adjustContentBoxLogicalHeightForBoxSizing(logicalHeightLength.val ue()); 1514 return cb->adjustContentBoxLogicalHeightForBoxSizing(logicalHeightLength.val ue());
1531 } 1515 }
1532 1516
1533 void RenderBox::mapLocalToContainer(const RenderLayerModelObject* paintInvalidat ionContainer, TransformState& transformState, MapCoordinatesFlags mode, const Pa intInvalidationState* paintInvalidationState) const 1517 void RenderBox::mapLocalToContainer(const RenderLayerModelObject* paintInvalidat ionContainer, TransformState& transformState, MapCoordinatesFlags mode, const Pa intInvalidationState* paintInvalidationState) const
1534 { 1518 {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 { 1597 {
1614 if (isOutOfFlowPositioned()) { 1598 if (isOutOfFlowPositioned()) {
1615 // Cache the x position only if we were an INLINE type originally. 1599 // Cache the x position only if we were an INLINE type originally.
1616 bool wasInline = style()->isOriginalDisplayInlineType(); 1600 bool wasInline = style()->isOriginalDisplayInlineType();
1617 if (wasInline) { 1601 if (wasInline) {
1618 // The value is cached in the xPos of the box. We only need this va lue if 1602 // The value is cached in the xPos of the box. We only need this va lue if
1619 // our object was inline originally, since otherwise it would have e nded up underneath 1603 // our object was inline originally, since otherwise it would have e nded up underneath
1620 // the inlines. 1604 // the inlines.
1621 RootInlineBox& root = box->root(); 1605 RootInlineBox& root = box->root();
1622 root.block().setStaticInlinePositionForChild(this, LayoutUnit::fromF loatRound(box->logicalLeft())); 1606 root.block().setStaticInlinePositionForChild(this, LayoutUnit::fromF loatRound(box->logicalLeft()));
1623 if (style()->hasStaticInlinePosition(box->isHorizontal())) 1607 if (style()->hasStaticInlinePosition())
1624 setChildNeedsLayout(MarkOnlyThis); // Just go ahead and mark the positioned object as needing layout, so it will update its position properly. 1608 setChildNeedsLayout(MarkOnlyThis); // Just go ahead and mark the positioned object as needing layout, so it will update its position properly.
1625 } else { 1609 } else {
1626 // Our object was a block originally, so we make our normal flow pos ition be 1610 // Our object was a block originally, so we make our normal flow pos ition be
1627 // just below the line box (as though all the inlines that came befo re us got 1611 // just below the line box (as though all the inlines that came befo re us got
1628 // wrapped in an anonymous block, which is what would have happened had we been 1612 // wrapped in an anonymous block, which is what would have happened had we been
1629 // in flow). This value was cached in the y() of the box. 1613 // in flow). This value was cached in the y() of the box.
1630 layer()->setStaticBlockPosition(box->logicalTop()); 1614 layer()->setStaticBlockPosition(box->logicalTop());
1631 if (style()->hasStaticBlockPosition(box->isHorizontal())) 1615 if (style()->hasStaticBlockPosition())
1632 setChildNeedsLayout(MarkOnlyThis); // Just go ahead and mark the positioned object as needing layout, so it will update its position properly. 1616 setChildNeedsLayout(MarkOnlyThis); // Just go ahead and mark the positioned object as needing layout, so it will update its position properly.
1633 } 1617 }
1634 1618
1635 if (container()->isRenderInline()) 1619 if (container()->isRenderInline())
1636 moveWithEdgeOfInlineContainerIfNecessary(box->isHorizontal()); 1620 moveWithEdgeOfInlineContainerIfNecessary();
1637 1621
1638 // Nuke the box. 1622 // Nuke the box.
1639 box->remove(DontMarkLineBoxes); 1623 box->remove(DontMarkLineBoxes);
1640 box->destroy(); 1624 box->destroy();
1641 } else if (isReplaced()) { 1625 } else if (isReplaced()) {
1642 setLocation(roundedLayoutPoint(box->topLeft())); 1626 setLocation(roundedLayoutPoint(box->topLeft()));
1643 setInlineBoxWrapper(box); 1627 setInlineBoxWrapper(box);
1644 } 1628 }
1645 } 1629 }
1646 1630
1647 void RenderBox::moveWithEdgeOfInlineContainerIfNecessary(bool isHorizontal) 1631 void RenderBox::moveWithEdgeOfInlineContainerIfNecessary()
1648 { 1632 {
1649 ASSERT(isOutOfFlowPositioned() && container()->isRenderInline() && container ()->isRelPositioned()); 1633 ASSERT(isOutOfFlowPositioned() && container()->isRenderInline() && container ()->isRelPositioned());
1650 // If this object is inside a relative positioned inline and its inline posi tion is an explicit offset from the edge of its container 1634 // If this object is inside a relative positioned inline and its inline posi tion is an explicit offset from the edge of its container
1651 // then it will need to move if its inline container has changed width. We d o not track if the width has changed 1635 // then it will need to move if its inline container has changed width. We d o not track if the width has changed
1652 // but if we are here then we are laying out lines inside it, so it probably has - mark our object for layout so that it can 1636 // but if we are here then we are laying out lines inside it, so it probably has - mark our object for layout so that it can
1653 // move to the new offset created by the new width. 1637 // move to the new offset created by the new width.
1654 if (!normalChildNeedsLayout() && !style()->hasStaticInlinePosition(isHorizon tal)) 1638 if (!normalChildNeedsLayout() && !style()->hasStaticInlinePosition())
1655 setChildNeedsLayout(MarkOnlyThis); 1639 setChildNeedsLayout(MarkOnlyThis);
1656 } 1640 }
1657 1641
1658 void RenderBox::deleteLineBoxWrapper() 1642 void RenderBox::deleteLineBoxWrapper()
1659 { 1643 {
1660 if (inlineBoxWrapper()) { 1644 if (inlineBoxWrapper()) {
1661 if (!documentBeingDestroyed()) 1645 if (!documentBeingDestroyed())
1662 inlineBoxWrapper()->remove(); 1646 inlineBoxWrapper()->remove();
1663 inlineBoxWrapper()->destroy(); 1647 inlineBoxWrapper()->destroy();
1664 ASSERT(m_rareData); 1648 ASSERT(m_rareData);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 return; 1797 return;
1814 } 1798 }
1815 1799
1816 bool treatAsReplaced = shouldComputeSizeAsReplaced(); 1800 bool treatAsReplaced = shouldComputeSizeAsReplaced();
1817 1801
1818 RenderStyle* styleToUse = style(); 1802 RenderStyle* styleToUse = style();
1819 Length logicalWidthLength = treatAsReplaced ? Length(computeReplacedLogicalW idth(), Fixed) : styleToUse->logicalWidth(); 1803 Length logicalWidthLength = treatAsReplaced ? Length(computeReplacedLogicalW idth(), Fixed) : styleToUse->logicalWidth();
1820 1804
1821 RenderBlock* cb = containingBlock(); 1805 RenderBlock* cb = containingBlock();
1822 LayoutUnit containerLogicalWidth = std::max<LayoutUnit>(0, containingBlockLo gicalWidthForContent()); 1806 LayoutUnit containerLogicalWidth = std::max<LayoutUnit>(0, containingBlockLo gicalWidthForContent());
1823 bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHo rizontalWritingMode(); 1807 // FIXME(sky): Remove
1808 bool hasPerpendicularContainingBlock = false;
1824 1809
1825 if (isInline() && !isInlineBlock()) { 1810 if (isInline() && !isInlineBlock()) {
1826 // just calculate margins 1811 // just calculate margins
1827 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar ginStart(), containerLogicalWidth); 1812 computedValues.m_margins.m_start = minimumValueForLength(styleToUse->mar ginStart(), containerLogicalWidth);
1828 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi nEnd(), containerLogicalWidth); 1813 computedValues.m_margins.m_end = minimumValueForLength(styleToUse->margi nEnd(), containerLogicalWidth);
1829 if (treatAsReplaced) 1814 if (treatAsReplaced)
1830 computedValues.m_extent = std::max<LayoutUnit>(floatValueForLength(l ogicalWidthLength, 0) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth ()); 1815 computedValues.m_extent = std::max<LayoutUnit>(floatValueForLength(l ogicalWidthLength, 0) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth ());
1831 return; 1816 return;
1832 } 1817 }
1833 1818
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 // In the case of columns that have a stretch alignment, we go ahead and lay out at the 1928 // In the case of columns that have a stretch alignment, we go ahead and lay out at the
1944 // stretched size to avoid an extra layout when applying alignment. 1929 // stretched size to avoid an extra layout when applying alignment.
1945 if (parent()->isFlexibleBox()) { 1930 if (parent()->isFlexibleBox()) {
1946 // For multiline columns, we need to apply align-content first, so we ca n't stretch now. 1931 // For multiline columns, we need to apply align-content first, so we ca n't stretch now.
1947 if (!parent()->style()->isColumnFlexDirection() || parent()->style()->fl exWrap() != FlexNoWrap) 1932 if (!parent()->style()->isColumnFlexDirection() || parent()->style()->fl exWrap() != FlexNoWrap)
1948 return true; 1933 return true;
1949 if (!columnFlexItemHasStretchAlignment(this)) 1934 if (!columnFlexItemHasStretchAlignment(this))
1950 return true; 1935 return true;
1951 } 1936 }
1952 1937
1953 if (isHorizontalWritingMode() != containingBlock()->isHorizontalWritingMode( ))
1954 return true;
1955
1956 return false; 1938 return false;
1957 } 1939 }
1958 1940
1959 void RenderBox::computeMarginsForDirection(MarginDirection flowDirection, const RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd, Length marginStartLength, Length marginEndLength) const 1941 void RenderBox::computeMarginsForDirection(MarginDirection flowDirection, const RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd, Length marginStartLength, Length marginEndLength) const
1960 { 1942 {
1961 if (flowDirection == BlockDirection || isFloating() || isInline()) { 1943 if (flowDirection == BlockDirection || isFloating() || isInline()) {
1962 // Margins are calculated with respect to the logical width of 1944 // Margins are calculated with respect to the logical width of
1963 // the containing block (8.3) 1945 // the containing block (8.3)
1964 // Inline blocks/tables and floats don't have their margins increased. 1946 // Inline blocks/tables and floats don't have their margins increased.
1965 marginStart = minimumValueForLength(marginStartLength, containerWidth); 1947 marginStart = minimumValueForLength(marginStartLength, containerWidth);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 if (isOutOfFlowPositioned()) 2034 if (isOutOfFlowPositioned())
2053 computePositionedLogicalHeight(computedValues); 2035 computePositionedLogicalHeight(computedValues);
2054 else { 2036 else {
2055 RenderBlock* cb = containingBlock(); 2037 RenderBlock* cb = containingBlock();
2056 2038
2057 // If we are perpendicular to our containing block then we need to resol ve our block-start and block-end margins so that if they 2039 // If we are perpendicular to our containing block then we need to resol ve our block-start and block-end margins so that if they
2058 // are 'auto' we are centred or aligned within the inline flow containin g block: this is done by computing the margins as though they are inline. 2040 // are 'auto' we are centred or aligned within the inline flow containin g block: this is done by computing the margins as though they are inline.
2059 // Note that as this is the 'sizing phase' we are using our own writing mode rather than the containing block's. We use the containing block's 2041 // Note that as this is the 'sizing phase' we are using our own writing mode rather than the containing block's. We use the containing block's
2060 // writing mode when figuring out the block-direction margins for positi oning in |computeAndSetBlockDirectionMargins| (i.e. margin collapsing etc.). 2042 // writing mode when figuring out the block-direction margins for positi oning in |computeAndSetBlockDirectionMargins| (i.e. margin collapsing etc.).
2061 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthog onal-flows 2043 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthog onal-flows
2062 MarginDirection flowDirection = isHorizontalWritingMode() != cb->isHoriz ontalWritingMode() ? InlineDirection : BlockDirection; 2044 // FIXME(sky): Remove MarginDirection enum.
2045 MarginDirection flowDirection = BlockDirection;
2063 2046
2064 bool treatAsReplaced = shouldComputeSizeAsReplaced(); 2047 bool treatAsReplaced = shouldComputeSizeAsReplaced();
2065 bool checkMinMaxHeight = false; 2048 bool checkMinMaxHeight = false;
2066 2049
2067 // The parent box is flexing us, so it has increased or decreased our he ight. We have to 2050 // The parent box is flexing us, so it has increased or decreased our he ight. We have to
2068 // grab our cached flexible height. 2051 // grab our cached flexible height.
2069 // FIXME: Account for block-flow in flexible boxes. 2052 // FIXME: Account for block-flow in flexible boxes.
2070 // https://bugs.webkit.org/show_bug.cgi?id=46418 2053 // https://bugs.webkit.org/show_bug.cgi?id=46418
2071 if (hasOverrideHeight() && parent()->isFlexibleBox()) 2054 if (hasOverrideHeight() && parent()->isFlexibleBox())
2072 h = Length(overrideLogicalContentHeight(), Fixed); 2055 h = Length(overrideLogicalContentHeight(), Fixed);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 return height.value(); 2126 return height.value();
2144 if (height.isPercent()) 2127 if (height.isPercent())
2145 return computePercentageLogicalHeight(height); 2128 return computePercentageLogicalHeight(height);
2146 return -1; 2129 return -1;
2147 } 2130 }
2148 2131
2149 bool RenderBox::skipContainingBlockForPercentHeightCalculation(const RenderBox* containingBlock) const 2132 bool RenderBox::skipContainingBlockForPercentHeightCalculation(const RenderBox* containingBlock) const
2150 { 2133 {
2151 if (!containingBlock->isAnonymousBlock()) 2134 if (!containingBlock->isAnonymousBlock())
2152 return false; 2135 return false;
2153 return !containingBlock->isOutOfFlowPositioned() && containingBlock->style() ->logicalHeight().isAuto() && isHorizontalWritingMode() == containingBlock->isHo rizontalWritingMode(); 2136 return !containingBlock->isOutOfFlowPositioned() && containingBlock->style() ->logicalHeight().isAuto();
2154 } 2137 }
2155 2138
2156 LayoutUnit RenderBox::computePercentageLogicalHeight(const Length& height) const 2139 LayoutUnit RenderBox::computePercentageLogicalHeight(const Length& height) const
2157 { 2140 {
2158 LayoutUnit availableHeight = -1; 2141 LayoutUnit availableHeight = -1;
2159 2142
2160 bool skippedAutoHeightContainingBlock = false; 2143 bool skippedAutoHeightContainingBlock = false;
2161 RenderBlock* cb = containingBlock(); 2144 RenderBlock* cb = containingBlock();
2162 const RenderBox* containingBlockChild = this; 2145 const RenderBox* containingBlockChild = this;
2163 LayoutUnit rootMarginBorderPaddingHeight = 0; 2146 LayoutUnit rootMarginBorderPaddingHeight = 0;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 2348
2366 LayoutUnit RenderBox::availableLogicalHeight(AvailableLogicalHeightType heightTy pe) const 2349 LayoutUnit RenderBox::availableLogicalHeight(AvailableLogicalHeightType heightTy pe) const
2367 { 2350 {
2368 // http://www.w3.org/TR/CSS2/visudet.html#propdef-height - We are interested in the content height. 2351 // http://www.w3.org/TR/CSS2/visudet.html#propdef-height - We are interested in the content height.
2369 return constrainContentBoxLogicalHeightByMinMax(availableLogicalHeightUsing( style()->logicalHeight(), heightType), -1); 2352 return constrainContentBoxLogicalHeightByMinMax(availableLogicalHeightUsing( style()->logicalHeight(), heightType), -1);
2370 } 2353 }
2371 2354
2372 LayoutUnit RenderBox::availableLogicalHeightUsing(const Length& h, AvailableLogi calHeightType heightType) const 2355 LayoutUnit RenderBox::availableLogicalHeightUsing(const Length& h, AvailableLogi calHeightType heightType) const
2373 { 2356 {
2374 if (isRenderView()) 2357 if (isRenderView())
2375 return isHorizontalWritingMode() ? toRenderView(this)->frameView()->unsc aledVisibleContentSize().height() : toRenderView(this)->frameView()->unscaledVis ibleContentSize().width(); 2358 return toRenderView(this)->frameView()->unscaledVisibleContentSize().hei ght();
2376 2359
2377 if (h.isPercent() && isOutOfFlowPositioned()) { 2360 if (h.isPercent() && isOutOfFlowPositioned()) {
2378 // FIXME: This is wrong if the containingBlock has a perpendicular writi ng mode. 2361 // FIXME: This is wrong if the containingBlock has a perpendicular writi ng mode.
2379 LayoutUnit availableHeight = containingBlockLogicalHeightForPositioned(c ontainingBlock()); 2362 LayoutUnit availableHeight = containingBlockLogicalHeightForPositioned(c ontainingBlock());
2380 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, avail ableHeight)); 2363 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, avail ableHeight));
2381 } 2364 }
2382 2365
2383 LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeigh tUsing(h, -1); 2366 LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeigh tUsing(h, -1);
2384 if (heightIncludingScrollbar != -1) 2367 if (heightIncludingScrollbar != -1)
2385 return std::max<LayoutUnit>(0, adjustContentBoxLogicalHeightForBoxSizing (heightIncludingScrollbar) - scrollbarLogicalHeight()); 2368 return std::max<LayoutUnit>(0, adjustContentBoxLogicalHeightForBoxSizing (heightIncludingScrollbar) - scrollbarLogicalHeight());
(...skipping 23 matching lines...) Expand all
2409 LayoutUnit marginAfter; 2392 LayoutUnit marginAfter;
2410 computeMarginsForDirection(BlockDirection, containingBlock, containingBlockL ogicalWidthForContent(), logicalHeight(), marginBefore, marginAfter, 2393 computeMarginsForDirection(BlockDirection, containingBlock, containingBlockL ogicalWidthForContent(), logicalHeight(), marginBefore, marginAfter,
2411 style()->marginBeforeUsing(containingBlock->style()), 2394 style()->marginBeforeUsing(containingBlock->style()),
2412 style()->marginAfterUsing(containingBlock->style())); 2395 style()->marginAfterUsing(containingBlock->style()));
2413 // Note that in this 'positioning phase' of the layout we are using the cont aining block's writing mode rather than our own when calculating margins. 2396 // Note that in this 'positioning phase' of the layout we are using the cont aining block's writing mode rather than our own when calculating margins.
2414 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthogonal -flows 2397 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthogonal -flows
2415 containingBlock->setMarginBeforeForChild(this, marginBefore); 2398 containingBlock->setMarginBeforeForChild(this, marginBefore);
2416 containingBlock->setMarginAfterForChild(this, marginAfter); 2399 containingBlock->setMarginAfterForChild(this, marginAfter);
2417 } 2400 }
2418 2401
2419 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo delObject* containingBlock, bool checkForPerpendicularWritingMode) const 2402 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo delObject* containingBlock) const
2420 { 2403 {
2421 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting Mode() != isHorizontalWritingMode())
2422 return containingBlockLogicalHeightForPositioned(containingBlock, false) ;
2423
2424 if (containingBlock->isBox()) 2404 if (containingBlock->isBox())
2425 return toRenderBox(containingBlock)->clientLogicalWidth(); 2405 return toRenderBox(containingBlock)->clientLogicalWidth();
2426 2406
2427 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ()); 2407 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ());
2428 2408
2429 const RenderInline* flow = toRenderInline(containingBlock); 2409 const RenderInline* flow = toRenderInline(containingBlock);
2430 InlineFlowBox* first = flow->firstLineBox(); 2410 InlineFlowBox* first = flow->firstLineBox();
2431 InlineFlowBox* last = flow->lastLineBox(); 2411 InlineFlowBox* last = flow->lastLineBox();
2432 2412
2433 // If the containing block is empty, return a width of 0. 2413 // If the containing block is empty, return a width of 0.
2434 if (!first || !last) 2414 if (!first || !last)
2435 return 0; 2415 return 0;
2436 2416
2437 LayoutUnit fromLeft; 2417 LayoutUnit fromLeft;
2438 LayoutUnit fromRight; 2418 LayoutUnit fromRight;
2439 if (containingBlock->style()->isLeftToRightDirection()) { 2419 if (containingBlock->style()->isLeftToRightDirection()) {
2440 fromLeft = first->logicalLeft() + first->borderLogicalLeft(); 2420 fromLeft = first->logicalLeft() + first->borderLogicalLeft();
2441 fromRight = last->logicalLeft() + last->logicalWidth() - last->borderLog icalRight(); 2421 fromRight = last->logicalLeft() + last->logicalWidth() - last->borderLog icalRight();
2442 } else { 2422 } else {
2443 fromRight = first->logicalLeft() + first->logicalWidth() - first->border LogicalRight(); 2423 fromRight = first->logicalLeft() + first->logicalWidth() - first->border LogicalRight();
2444 fromLeft = last->logicalLeft() + last->borderLogicalLeft(); 2424 fromLeft = last->logicalLeft() + last->borderLogicalLeft();
2445 } 2425 }
2446 2426
2447 return std::max<LayoutUnit>(0, fromRight - fromLeft); 2427 return std::max<LayoutUnit>(0, fromRight - fromLeft);
2448 } 2428 }
2449 2429
2450 LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM odelObject* containingBlock, bool checkForPerpendicularWritingMode) const 2430 LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM odelObject* containingBlock) const
2451 { 2431 {
2452 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting Mode() != isHorizontalWritingMode())
2453 return containingBlockLogicalWidthForPositioned(containingBlock, false);
2454
2455 if (containingBlock->isBox()) { 2432 if (containingBlock->isBox()) {
2456 const RenderBlock* cb = containingBlock->isRenderBlock() ? 2433 const RenderBlock* cb = containingBlock->isRenderBlock() ?
2457 toRenderBlock(containingBlock) : containingBlock->containingBlock(); 2434 toRenderBlock(containingBlock) : containingBlock->containingBlock();
2458 return cb->clientLogicalHeight(); 2435 return cb->clientLogicalHeight();
2459 } 2436 }
2460 2437
2461 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ()); 2438 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ());
2462 2439
2463 const RenderInline* flow = toRenderInline(containingBlock); 2440 const RenderInline* flow = toRenderInline(containingBlock);
2464 InlineFlowBox* first = flow->firstLineBox(); 2441 InlineFlowBox* first = flow->firstLineBox();
2465 InlineFlowBox* last = flow->lastLineBox(); 2442 InlineFlowBox* last = flow->lastLineBox();
2466 2443
2467 // If the containing block is empty, return a height of 0. 2444 // If the containing block is empty, return a height of 0.
2468 if (!first || !last) 2445 if (!first || !last)
2469 return 0; 2446 return 0;
2470 2447
2471 LayoutUnit heightResult;
2472 LayoutRect boundingBox = flow->linesBoundingBox(); 2448 LayoutRect boundingBox = flow->linesBoundingBox();
2473 if (containingBlock->isHorizontalWritingMode()) 2449 LayoutUnit heightResult = boundingBox.height();
2474 heightResult = boundingBox.height();
2475 else
2476 heightResult = boundingBox.width();
2477 heightResult -= (containingBlock->borderBefore() + containingBlock->borderAf ter()); 2450 heightResult -= (containingBlock->borderBefore() + containingBlock->borderAf ter());
2478 return heightResult; 2451 return heightResult;
2479 } 2452 }
2480 2453
2481 static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh t, const RenderBox* child, const RenderBoxModelObject* containerBlock, LayoutUni t containerLogicalWidth) 2454 static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh t, const RenderBox* child, const RenderBoxModelObject* containerBlock, LayoutUni t containerLogicalWidth)
2482 { 2455 {
2483 if (!logicalLeft.isAuto() || !logicalRight.isAuto()) 2456 if (!logicalLeft.isAuto() || !logicalRight.isAuto())
2484 return; 2457 return;
2485 2458
2486 // FIXME: The static distance computation has not been patched for mixed wri ting modes yet. 2459 // FIXME: The static distance computation has not been patched for mixed wri ting modes yet.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2555 // relative positioned inline. 2528 // relative positioned inline.
2556 const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(containe r()); 2529 const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(containe r());
2557 2530
2558 const LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForPosit ioned(containerBlock); 2531 const LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForPosit ioned(containerBlock);
2559 2532
2560 // Use the container block's direction except when calculating the static di stance 2533 // Use the container block's direction except when calculating the static di stance
2561 // This conforms with the reference results for abspos-replaced-width-margin -000.htm 2534 // This conforms with the reference results for abspos-replaced-width-margin -000.htm
2562 // of the CSS 2.1 test suite 2535 // of the CSS 2.1 test suite
2563 TextDirection containerDirection = containerBlock->style()->direction(); 2536 TextDirection containerDirection = containerBlock->style()->direction();
2564 2537
2565 bool isHorizontal = isHorizontalWritingMode();
2566 const LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth(); 2538 const LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth();
2567 const Length marginLogicalLeft = isHorizontal ? style()->marginLeft() : styl e()->marginTop(); 2539 const Length marginLogicalLeft = style()->marginLeft();
2568 const Length marginLogicalRight = isHorizontal ? style()->marginRight() : st yle()->marginBottom(); 2540 const Length marginLogicalRight = style()->marginRight();
2569 2541
2570 Length logicalLeftLength = style()->logicalLeft(); 2542 Length logicalLeftLength = style()->logicalLeft();
2571 Length logicalRightLength = style()->logicalRight(); 2543 Length logicalRightLength = style()->logicalRight();
2572 2544
2573 /*-------------------------------------------------------------------------- -*\ 2545 /*-------------------------------------------------------------------------- -*\
2574 * For the purposes of this section and the next, the term "static position" 2546 * For the purposes of this section and the next, the term "static position"
2575 * (of an element) refers, roughly, to the position an element would have ha d 2547 * (of an element) refers, roughly, to the position an element would have ha d
2576 * in the normal flow. More precisely: 2548 * in the normal flow. More precisely:
2577 * 2549 *
2578 * * The static position for 'left' is the distance from the left edge of th e 2550 * * The static position for 'left' is the distance from the left edge of th e
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2640 2612
2641 computedValues.m_extent += bordersPlusPadding; 2613 computedValues.m_extent += bordersPlusPadding;
2642 } 2614 }
2643 2615
2644 static void computeLogicalLeftPositionedOffset(LayoutUnit& logicalLeftPos, const RenderBox* child, LayoutUnit logicalWidthValue, const RenderBoxModelObject* con tainerBlock, LayoutUnit containerLogicalWidth) 2616 static void computeLogicalLeftPositionedOffset(LayoutUnit& logicalLeftPos, const RenderBox* child, LayoutUnit logicalWidthValue, const RenderBoxModelObject* con tainerBlock, LayoutUnit containerLogicalWidth)
2645 { 2617 {
2646 // Deal with differing writing modes here. Our offset needs to be in the co ntaining block's coordinate space. If the containing block is flipped 2618 // Deal with differing writing modes here. Our offset needs to be in the co ntaining block's coordinate space. If the containing block is flipped
2647 // along this axis, then we need to flip the coordinate. This can only happ en if the containing block is both a flipped mode and perpendicular to us. 2619 // along this axis, then we need to flip the coordinate. This can only happ en if the containing block is both a flipped mode and perpendicular to us.
2648 if (containerBlock->isHorizontalWritingMode() != child->isHorizontalWritingM ode() && containerBlock->style()->isFlippedBlocksWritingMode()) { 2620 if (containerBlock->isHorizontalWritingMode() != child->isHorizontalWritingM ode() && containerBlock->style()->isFlippedBlocksWritingMode()) {
2649 logicalLeftPos = containerLogicalWidth - logicalWidthValue - logicalLeft Pos; 2621 logicalLeftPos = containerLogicalWidth - logicalWidthValue - logicalLeft Pos;
2650 logicalLeftPos += (child->isHorizontalWritingMode() ? containerBlock->bo rderRight() : containerBlock->borderBottom()); 2622 logicalLeftPos += containerBlock->borderRight();
2651 } else { 2623 } else {
2652 logicalLeftPos += (child->isHorizontalWritingMode() ? containerBlock->bo rderLeft() : containerBlock->borderTop()); 2624 logicalLeftPos += containerBlock->borderLeft();
2653 } 2625 }
2654 } 2626 }
2655 2627
2656 void RenderBox::shrinkToFitWidth(const LayoutUnit availableSpace, const LayoutUn it logicalLeftValue, const LayoutUnit bordersPlusPadding, LogicalExtentComputedV alues& computedValues) const 2628 void RenderBox::shrinkToFitWidth(const LayoutUnit availableSpace, const LayoutUn it logicalLeftValue, const LayoutUnit bordersPlusPadding, LogicalExtentComputedV alues& computedValues) const
2657 { 2629 {
2658 // FIXME: would it be better to have shrink-to-fit in one step? 2630 // FIXME: would it be better to have shrink-to-fit in one step?
2659 LayoutUnit preferredWidth = maxPreferredLogicalWidth() - bordersPlusPadding; 2631 LayoutUnit preferredWidth = maxPreferredLogicalWidth() - bordersPlusPadding;
2660 LayoutUnit preferredMinWidth = minPreferredLogicalWidth() - bordersPlusPaddi ng; 2632 LayoutUnit preferredMinWidth = minPreferredLogicalWidth() - bordersPlusPaddi ng;
2661 LayoutUnit availableWidth = availableSpace - logicalLeftValue; 2633 LayoutUnit availableWidth = availableSpace - logicalLeftValue;
2662 computedValues.m_extent = std::min(std::max(preferredMinWidth, availableWidt h), preferredWidth); 2634 computedValues.m_extent = std::min(std::max(preferredMinWidth, availableWidt h), preferredWidth);
2663 } 2635 }
2664 2636
2665 void RenderBox::computePositionedLogicalWidthUsing(Length logicalWidth, const Re nderBoxModelObject* containerBlock, TextDirection containerDirection, 2637 void RenderBox::computePositionedLogicalWidthUsing(Length logicalWidth, const Re nderBoxModelObject* containerBlock, TextDirection containerDirection,
2666 LayoutUnit containerLogicalWi dth, LayoutUnit bordersPlusPadding, 2638 LayoutUnit containerLogicalWi dth, LayoutUnit bordersPlusPadding,
2667 const Length& logicalLeft, co nst Length& logicalRight, const Length& marginLogicalLeft, 2639 const Length& logicalLeft, co nst Length& logicalRight, const Length& marginLogicalLeft,
2668 const Length& marginLogicalRi ght, LogicalExtentComputedValues& computedValues) const 2640 const Length& marginLogicalRi ght, LogicalExtentComputedValues& computedValues) const
2669 { 2641 {
2670 if (logicalWidth.isIntrinsic()) 2642 if (logicalWidth.isIntrinsic())
2671 logicalWidth = Length(computeIntrinsicLogicalWidthUsing(logicalWidth, co ntainerLogicalWidth, bordersPlusPadding) - bordersPlusPadding, Fixed); 2643 logicalWidth = Length(computeIntrinsicLogicalWidthUsing(logicalWidth, co ntainerLogicalWidth, bordersPlusPadding) - bordersPlusPadding, Fixed);
2672 2644
2673 // 'left' and 'right' cannot both be 'auto' because one would of been 2645 // 'left' and 'right' cannot both be 'auto' because one would of been
2674 // converted to the static position already 2646 // converted to the static position already
2675 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto())); 2647 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto()));
2676 2648
2677 LayoutUnit logicalLeftValue = 0; 2649 LayoutUnit logicalLeftValue = 0;
2678 2650
2679 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth ForPositioned(containerBlock, false); 2651 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth ForPositioned(containerBlock);
2680 2652
2681 bool logicalWidthIsAuto = logicalWidth.isIntrinsicOrAuto(); 2653 bool logicalWidthIsAuto = logicalWidth.isIntrinsicOrAuto();
2682 bool logicalLeftIsAuto = logicalLeft.isAuto(); 2654 bool logicalLeftIsAuto = logicalLeft.isAuto();
2683 bool logicalRightIsAuto = logicalRight.isAuto(); 2655 bool logicalRightIsAuto = logicalRight.isAuto();
2684 LayoutUnit& marginLogicalLeftValue = style()->isLeftToRightDirection() ? com putedValues.m_margins.m_start : computedValues.m_margins.m_end; 2656 LayoutUnit& marginLogicalLeftValue = style()->isLeftToRightDirection() ? com putedValues.m_margins.m_start : computedValues.m_margins.m_end;
2685 LayoutUnit& marginLogicalRightValue = style()->isLeftToRightDirection() ? co mputedValues.m_margins.m_end : computedValues.m_margins.m_start; 2657 LayoutUnit& marginLogicalRightValue = style()->isLeftToRightDirection() ? co mputedValues.m_margins.m_end : computedValues.m_margins.m_start;
2686 if (!logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAuto) { 2658 if (!logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAuto) {
2687 /*---------------------------------------------------------------------- -*\ 2659 /*---------------------------------------------------------------------- -*\
2688 * If none of the three is 'auto': If both 'margin-left' and 'margin- 2660 * If none of the three is 'auto': If both 'margin-left' and 'margin-
2689 * right' are 'auto', solve the equation under the extra constraint that 2661 * right' are 'auto', solve the equation under the extra constraint that
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
2976 const Length& logicalTop, co nst Length& logicalBottom, const Length& marginBefore, 2948 const Length& logicalTop, co nst Length& logicalBottom, const Length& marginBefore,
2977 const Length& marginAfter, L ogicalExtentComputedValues& computedValues) const 2949 const Length& marginAfter, L ogicalExtentComputedValues& computedValues) const
2978 { 2950 {
2979 // 'top' and 'bottom' cannot both be 'auto' because 'top would of been 2951 // 'top' and 'bottom' cannot both be 'auto' because 'top would of been
2980 // converted to the static position in computePositionedLogicalHeight() 2952 // converted to the static position in computePositionedLogicalHeight()
2981 ASSERT(!(logicalTop.isAuto() && logicalBottom.isAuto())); 2953 ASSERT(!(logicalTop.isAuto() && logicalBottom.isAuto()));
2982 2954
2983 LayoutUnit logicalHeightValue; 2955 LayoutUnit logicalHeightValue;
2984 LayoutUnit contentLogicalHeight = logicalHeight - bordersPlusPadding; 2956 LayoutUnit contentLogicalHeight = logicalHeight - bordersPlusPadding;
2985 2957
2986 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth ForPositioned(containerBlock, false); 2958 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth ForPositioned(containerBlock);
2987 2959
2988 LayoutUnit logicalTopValue = 0; 2960 LayoutUnit logicalTopValue = 0;
2989 2961
2990 bool logicalHeightIsAuto = logicalHeightLength.isAuto(); 2962 bool logicalHeightIsAuto = logicalHeightLength.isAuto();
2991 bool logicalTopIsAuto = logicalTop.isAuto(); 2963 bool logicalTopIsAuto = logicalTop.isAuto();
2992 bool logicalBottomIsAuto = logicalBottom.isAuto(); 2964 bool logicalBottomIsAuto = logicalBottom.isAuto();
2993 2965
2994 LayoutUnit resolvedLogicalHeight; 2966 LayoutUnit resolvedLogicalHeight;
2995 if (logicalHeightLength.isIntrinsic()) 2967 if (logicalHeightLength.isIntrinsic())
2996 resolvedLogicalHeight = computeIntrinsicLogicalContentHeightUsing(logica lHeightLength, contentLogicalHeight, bordersPlusPadding); 2968 resolvedLogicalHeight = computeIntrinsicLogicalContentHeightUsing(logica lHeightLength, contentLogicalHeight, bordersPlusPadding);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
3101 // CSS 2.1: Section 10.3.8 "Absolutely positioned, replaced elements" 3073 // CSS 2.1: Section 10.3.8 "Absolutely positioned, replaced elements"
3102 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-replaced-wi dth> 3074 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-replaced-wi dth>
3103 // (block-style-comments in this function correspond to text from the spec a nd 3075 // (block-style-comments in this function correspond to text from the spec a nd
3104 // the numbers correspond to numbers in spec) 3076 // the numbers correspond to numbers in spec)
3105 3077
3106 // We don't use containingBlock(), since we may be positioned by an enclosin g 3078 // We don't use containingBlock(), since we may be positioned by an enclosin g
3107 // relative positioned inline. 3079 // relative positioned inline.
3108 const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(containe r()); 3080 const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(containe r());
3109 3081
3110 const LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForPosit ioned(containerBlock); 3082 const LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForPosit ioned(containerBlock);
3111 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth ForPositioned(containerBlock, false); 3083 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth ForPositioned(containerBlock);
3112 3084
3113 // To match WinIE, in quirks mode use the parent's 'direction' property 3085 // To match WinIE, in quirks mode use the parent's 'direction' property
3114 // instead of the the container block's. 3086 // instead of the the container block's.
3115 TextDirection containerDirection = containerBlock->style()->direction(); 3087 TextDirection containerDirection = containerBlock->style()->direction();
3116 3088
3117 // Variables to solve. 3089 // Variables to solve.
3118 bool isHorizontal = isHorizontalWritingMode(); 3090 bool isHorizontal = isHorizontalWritingMode();
3119 Length logicalLeft = style()->logicalLeft(); 3091 Length logicalLeft = style()->logicalLeft();
3120 Length logicalRight = style()->logicalRight(); 3092 Length logicalRight = style()->logicalRight();
3121 Length marginLogicalLeft = isHorizontal ? style()->marginLeft() : style()->m arginTop(); 3093 Length marginLogicalLeft = isHorizontal ? style()->marginLeft() : style()->m arginTop();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
3269 // The following is based off of the W3C Working Draft from April 11, 2006 o f 3241 // The following is based off of the W3C Working Draft from April 11, 2006 o f
3270 // CSS 2.1: Section 10.6.5 "Absolutely positioned, replaced elements" 3242 // CSS 2.1: Section 10.6.5 "Absolutely positioned, replaced elements"
3271 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-replaced-he ight> 3243 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-replaced-he ight>
3272 // (block-style-comments in this function correspond to text from the spec a nd 3244 // (block-style-comments in this function correspond to text from the spec a nd
3273 // the numbers correspond to numbers in spec) 3245 // the numbers correspond to numbers in spec)
3274 3246
3275 // We don't use containingBlock(), since we may be positioned by an enclosin g relpositioned inline. 3247 // We don't use containingBlock(), since we may be positioned by an enclosin g relpositioned inline.
3276 const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(containe r()); 3248 const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(containe r());
3277 3249
3278 const LayoutUnit containerLogicalHeight = containingBlockLogicalHeightForPos itioned(containerBlock); 3250 const LayoutUnit containerLogicalHeight = containingBlockLogicalHeightForPos itioned(containerBlock);
3279 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth ForPositioned(containerBlock, false); 3251 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth ForPositioned(containerBlock);
3280 3252
3281 // Variables to solve. 3253 // Variables to solve.
3282 Length marginBefore = style()->marginBefore(); 3254 Length marginBefore = style()->marginBefore();
3283 Length marginAfter = style()->marginAfter(); 3255 Length marginAfter = style()->marginAfter();
3284 LayoutUnit& marginBeforeAlias = computedValues.m_margins.m_before; 3256 LayoutUnit& marginBeforeAlias = computedValues.m_margins.m_before;
3285 LayoutUnit& marginAfterAlias = computedValues.m_margins.m_after; 3257 LayoutUnit& marginAfterAlias = computedValues.m_margins.m_after;
3286 3258
3287 Length logicalTop = style()->logicalTop(); 3259 Length logicalTop = style()->logicalTop();
3288 Length logicalBottom = style()->logicalBottom(); 3260 Length logicalBottom = style()->logicalBottom();
3289 3261
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
3874 return rect; 3846 return rect;
3875 } 3847 }
3876 3848
3877 LayoutRect RenderBox::layoutOverflowRectForPropagation(RenderStyle* parentStyle) const 3849 LayoutRect RenderBox::layoutOverflowRectForPropagation(RenderStyle* parentStyle) const
3878 { 3850 {
3879 // Only propagate interior layout overflow if we don't clip it. 3851 // Only propagate interior layout overflow if we don't clip it.
3880 LayoutRect rect = borderBoxRect(); 3852 LayoutRect rect = borderBoxRect();
3881 // We want to include the margin, but only when it adds height. Quirky margi ns don't contribute height 3853 // We want to include the margin, but only when it adds height. Quirky margi ns don't contribute height
3882 // nor do the margins of self-collapsing blocks. 3854 // nor do the margins of self-collapsing blocks.
3883 if (!style()->hasMarginAfterQuirk() && !isSelfCollapsingBlock()) 3855 if (!style()->hasMarginAfterQuirk() && !isSelfCollapsingBlock())
3884 rect.expand(isHorizontalWritingMode() ? LayoutSize(LayoutUnit(), marginA fter()) : LayoutSize(marginAfter(), LayoutUnit())); 3856 rect.expand(LayoutSize(LayoutUnit(), marginAfter()));
3885 3857
3886 if (!hasOverflowClip()) 3858 if (!hasOverflowClip())
3887 rect.unite(layoutOverflowRect()); 3859 rect.unite(layoutOverflowRect());
3888 3860
3889 bool hasTransform = hasLayer() && layer()->transform(); 3861 bool hasTransform = hasLayer() && layer()->transform();
3890 if (isRelPositioned() || hasTransform) { 3862 if (isRelPositioned() || hasTransform) {
3891 // If we are relatively positioned or if we have a transform, then we ha ve to convert 3863 // If we are relatively positioned or if we have a transform, then we ha ve to convert
3892 // this rectangle into physical coordinates, apply relative positioning and transforms 3864 // this rectangle into physical coordinates, apply relative positioning and transforms
3893 // to it, and then convert it back. 3865 // to it, and then convert it back.
3894 flipForWritingMode(rect); 3866 flipForWritingMode(rect);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3955 return adjustedPositionRelativeToOffsetParent(topLeftLocation()).x(); 3927 return adjustedPositionRelativeToOffsetParent(topLeftLocation()).x();
3956 } 3928 }
3957 3929
3958 LayoutUnit RenderBox::offsetTop() const 3930 LayoutUnit RenderBox::offsetTop() const
3959 { 3931 {
3960 return adjustedPositionRelativeToOffsetParent(topLeftLocation()).y(); 3932 return adjustedPositionRelativeToOffsetParent(topLeftLocation()).y();
3961 } 3933 }
3962 3934
3963 LayoutPoint RenderBox::flipForWritingModeForChild(const RenderBox* child, const LayoutPoint& point) const 3935 LayoutPoint RenderBox::flipForWritingModeForChild(const RenderBox* child, const LayoutPoint& point) const
3964 { 3936 {
3965 if (!style()->isFlippedBlocksWritingMode()) 3937 // FIXME(sky): Remove
3966 return point; 3938 return point;
3967
3968 // The child is going to add in its x() and y(), so we have to make sure it ends up in
3969 // the right place.
3970 if (isHorizontalWritingMode())
3971 return LayoutPoint(point.x(), point.y() + height() - child->height() - ( 2 * child->y()));
3972 return LayoutPoint(point.x() + width() - child->width() - (2 * child->x()), point.y());
3973 } 3939 }
3974 3940
3975 void RenderBox::flipForWritingMode(LayoutRect& rect) const 3941 void RenderBox::flipForWritingMode(LayoutRect& rect) const
3976 { 3942 {
3977 if (!style()->isFlippedBlocksWritingMode()) 3943 // FIXME(sky): Remove
3978 return;
3979
3980 if (isHorizontalWritingMode())
3981 rect.setY(height() - rect.maxY());
3982 else
3983 rect.setX(width() - rect.maxX());
3984 } 3944 }
3985 3945
3986 LayoutUnit RenderBox::flipForWritingMode(LayoutUnit position) const 3946 LayoutUnit RenderBox::flipForWritingMode(LayoutUnit position) const
3987 { 3947 {
3988 if (!style()->isFlippedBlocksWritingMode()) 3948 // FIXME(sky): Remove
3989 return position; 3949 return position;
3990 return logicalHeight() - position;
3991 } 3950 }
3992 3951
3993 LayoutPoint RenderBox::flipForWritingMode(const LayoutPoint& position) const 3952 LayoutPoint RenderBox::flipForWritingMode(const LayoutPoint& position) const
3994 { 3953 {
3995 if (!style()->isFlippedBlocksWritingMode()) 3954 // FIXME(sky): Remove
3996 return position; 3955 return position;
3997 return isHorizontalWritingMode() ? LayoutPoint(position.x(), height() - posi tion.y()) : LayoutPoint(width() - position.x(), position.y());
3998 } 3956 }
3999 3957
4000 LayoutPoint RenderBox::flipForWritingModeIncludingColumns(const LayoutPoint& poi nt) const 3958 LayoutPoint RenderBox::flipForWritingModeIncludingColumns(const LayoutPoint& poi nt) const
4001 { 3959 {
4002 return flipForWritingMode(point); 3960 // FIXME(sky): Remove
3961 return point;
4003 } 3962 }
4004 3963
4005 LayoutSize RenderBox::flipForWritingMode(const LayoutSize& offset) const 3964 LayoutSize RenderBox::flipForWritingMode(const LayoutSize& offset) const
4006 { 3965 {
4007 if (!style()->isFlippedBlocksWritingMode()) 3966 // FIXME(sky): Remove
4008 return offset; 3967 return offset;
4009 return isHorizontalWritingMode() ? LayoutSize(offset.width(), height() - off set.height()) : LayoutSize(width() - offset.width(), offset.height());
4010 } 3968 }
4011 3969
4012 FloatPoint RenderBox::flipForWritingMode(const FloatPoint& position) const 3970 FloatPoint RenderBox::flipForWritingMode(const FloatPoint& position) const
4013 { 3971 {
4014 if (!style()->isFlippedBlocksWritingMode()) 3972 // FIXME(sky): Remove
4015 return position; 3973 return position;
4016 return isHorizontalWritingMode() ? FloatPoint(position.x(), height() - posit ion.y()) : FloatPoint(width() - position.x(), position.y());
4017 } 3974 }
4018 3975
4019 void RenderBox::flipForWritingMode(FloatRect& rect) const 3976 void RenderBox::flipForWritingMode(FloatRect& rect) const
4020 { 3977 {
4021 if (!style()->isFlippedBlocksWritingMode()) 3978 // FIXME(sky): Remove
4022 return;
4023
4024 if (isHorizontalWritingMode())
4025 rect.setY(height() - rect.maxY());
4026 else
4027 rect.setX(width() - rect.maxX());
4028 } 3979 }
4029 3980
4030 LayoutPoint RenderBox::topLeftLocation() const 3981 LayoutPoint RenderBox::topLeftLocation() const
4031 { 3982 {
4032 RenderBlock* containerBlock = containingBlock(); 3983 RenderBlock* containerBlock = containingBlock();
4033 if (!containerBlock || containerBlock == this) 3984 if (!containerBlock || containerBlock == this)
4034 return location(); 3985 return location();
4035 return containerBlock->flipForWritingModeForChild(this, location()); 3986 return containerBlock->flipForWritingModeForChild(this, location());
4036 } 3987 }
4037 3988
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
4132 4083
4133 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) 4084 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style)
4134 { 4085 {
4135 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); 4086 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor);
4136 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); 4087 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage();
4137 ASSERT(hasBackground == style.hasBackground()); 4088 ASSERT(hasBackground == style.hasBackground());
4138 hasBorder = style.hasBorder(); 4089 hasBorder = style.hasBorder();
4139 } 4090 }
4140 4091
4141 } // namespace blink 4092 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBox.h ('k') | sky/engine/core/rendering/RenderBoxModelObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698