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

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

Issue 938193004: Remove dead position:relative code. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 } 1108 }
1109 1109
1110 mode &= ~ApplyContainerFlip; 1110 mode &= ~ApplyContainerFlip;
1111 1111
1112 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode); 1112 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode);
1113 } 1113 }
1114 1114
1115 LayoutSize RenderBox::offsetFromContainer(const RenderObject* o, const LayoutPoi nt& point, bool* offsetDependsOnPoint) const 1115 LayoutSize RenderBox::offsetFromContainer(const RenderObject* o, const LayoutPoi nt& point, bool* offsetDependsOnPoint) const
1116 { 1116 {
1117 ASSERT(o == container()); 1117 ASSERT(o == container());
1118
1119 LayoutSize offset;
1120 if (isRelPositioned())
1121 offset += offsetForInFlowPosition();
1122
1123 if (!isInline() || isReplaced()) 1118 if (!isInline() || isReplaced())
1124 offset += locationOffset(); 1119 return locationOffset();
1125 1120 return LayoutSize();
1126 if (style()->position() == AbsolutePosition && o->isRelPositioned() && o->is RenderInline())
1127 offset += toRenderInline(o)->offsetForInFlowPositionedInline(*this);
1128
1129 return offset;
1130 } 1121 }
1131 1122
1132 InlineBox* RenderBox::createInlineBox() 1123 InlineBox* RenderBox::createInlineBox()
1133 { 1124 {
1134 return new InlineBox(*this); 1125 return new InlineBox(*this);
1135 } 1126 }
1136 1127
1137 void RenderBox::dirtyLineBoxes(bool fullLayout) 1128 void RenderBox::dirtyLineBoxes(bool fullLayout)
1138 { 1129 {
1139 if (inlineBoxWrapper()) { 1130 if (inlineBoxWrapper()) {
(...skipping 23 matching lines...) Expand all
1163 } else { 1154 } else {
1164 // Our object was a block originally, so we make our normal flow pos ition be 1155 // Our object was a block originally, so we make our normal flow pos ition be
1165 // just below the line box (as though all the inlines that came befo re us got 1156 // just below the line box (as though all the inlines that came befo re us got
1166 // wrapped in an anonymous block, which is what would have happened had we been 1157 // wrapped in an anonymous block, which is what would have happened had we been
1167 // in flow). This value was cached in the y() of the box. 1158 // in flow). This value was cached in the y() of the box.
1168 layer()->setStaticBlockPosition(box->logicalTop()); 1159 layer()->setStaticBlockPosition(box->logicalTop());
1169 if (style()->hasStaticBlockPosition()) 1160 if (style()->hasStaticBlockPosition())
1170 setChildNeedsLayout(MarkOnlyThis); // Just go ahead and mark the positioned object as needing layout, so it will update its position properly. 1161 setChildNeedsLayout(MarkOnlyThis); // Just go ahead and mark the positioned object as needing layout, so it will update its position properly.
1171 } 1162 }
1172 1163
1173 if (container()->isRenderInline())
1174 moveWithEdgeOfInlineContainerIfNecessary();
1175
1176 // Nuke the box. 1164 // Nuke the box.
1177 box->remove(DontMarkLineBoxes); 1165 box->remove(DontMarkLineBoxes);
1178 box->destroy(); 1166 box->destroy();
1179 } else if (isReplaced()) { 1167 } else if (isReplaced()) {
1180 setLocation(roundedLayoutPoint(box->topLeft())); 1168 setLocation(roundedLayoutPoint(box->topLeft()));
1181 setInlineBoxWrapper(box); 1169 setInlineBoxWrapper(box);
1182 } 1170 }
1183 } 1171 }
1184 1172
1185 void RenderBox::moveWithEdgeOfInlineContainerIfNecessary()
1186 {
1187 ASSERT(isOutOfFlowPositioned() && container()->isRenderInline() && container ()->isRelPositioned());
1188 // If this object is inside a relative positioned inline and its inline posi tion is an explicit offset from the edge of its container
1189 // then it will need to move if its inline container has changed width. We d o not track if the width has changed
1190 // 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
1191 // move to the new offset created by the new width.
1192 if (!normalChildNeedsLayout() && !style()->hasStaticInlinePosition())
1193 setChildNeedsLayout(MarkOnlyThis);
1194 }
1195
1196 void RenderBox::deleteLineBoxWrapper() 1173 void RenderBox::deleteLineBoxWrapper()
1197 { 1174 {
1198 if (inlineBoxWrapper()) { 1175 if (inlineBoxWrapper()) {
1199 if (!documentBeingDestroyed()) 1176 if (!documentBeingDestroyed())
1200 inlineBoxWrapper()->remove(); 1177 inlineBoxWrapper()->remove();
1201 inlineBoxWrapper()->destroy(); 1178 inlineBoxWrapper()->destroy();
1202 ASSERT(m_rareData); 1179 ASSERT(m_rareData);
1203 m_rareData->m_inlineBoxWrapper = 0; 1180 m_rareData->m_inlineBoxWrapper = 0;
1204 } 1181 }
1205 } 1182 }
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 style()->marginBeforeUsing(containingBlock->style()), 1777 style()->marginBeforeUsing(containingBlock->style()),
1801 style()->marginAfterUsing(containingBlock->style())); 1778 style()->marginAfterUsing(containingBlock->style()));
1802 // 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. 1779 // 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.
1803 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthogonal -flows 1780 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthogonal -flows
1804 containingBlock->setMarginBeforeForChild(this, marginBefore); 1781 containingBlock->setMarginBeforeForChild(this, marginBefore);
1805 containingBlock->setMarginAfterForChild(this, marginAfter); 1782 containingBlock->setMarginAfterForChild(this, marginAfter);
1806 } 1783 }
1807 1784
1808 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo delObject* containingBlock) const 1785 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo delObject* containingBlock) const
1809 { 1786 {
1810 if (containingBlock->isBox()) 1787 ASSERT(containingBlock->isBox());
1811 return toRenderBox(containingBlock)->clientLogicalWidth(); 1788 return toRenderBox(containingBlock)->clientLogicalWidth();
1812
1813 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ());
1814
1815 const RenderInline* flow = toRenderInline(containingBlock);
1816 InlineFlowBox* first = flow->firstLineBox();
1817 InlineFlowBox* last = flow->lastLineBox();
1818
1819 // If the containing block is empty, return a width of 0.
1820 if (!first || !last)
1821 return 0;
1822
1823 LayoutUnit fromLeft;
1824 LayoutUnit fromRight;
1825 if (containingBlock->style()->isLeftToRightDirection()) {
1826 fromLeft = first->logicalLeft() + first->borderLogicalLeft();
1827 fromRight = last->logicalLeft() + last->logicalWidth() - last->borderLog icalRight();
1828 } else {
1829 fromRight = first->logicalLeft() + first->logicalWidth() - first->border LogicalRight();
1830 fromLeft = last->logicalLeft() + last->borderLogicalLeft();
1831 }
1832
1833 return std::max<LayoutUnit>(0, fromRight - fromLeft);
1834 } 1789 }
1835 1790
1836 LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM odelObject* containingBlock) const 1791 LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM odelObject* containingBlock) const
1837 { 1792 {
1838 if (containingBlock->isBox()) { 1793 ASSERT(containingBlock->isBox());
1839 const RenderBlock* cb = containingBlock->isRenderBlock() ? 1794 const RenderBlock* cb = containingBlock->isRenderBlock() ?
1840 toRenderBlock(containingBlock) : containingBlock->containingBlock(); 1795 toRenderBlock(containingBlock) : containingBlock->containingBlock();
1841 return cb->clientLogicalHeight(); 1796 return cb->clientLogicalHeight();
1842 }
1843
1844 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ());
1845
1846 const RenderInline* flow = toRenderInline(containingBlock);
1847 InlineFlowBox* first = flow->firstLineBox();
1848 InlineFlowBox* last = flow->lastLineBox();
1849
1850 // If the containing block is empty, return a height of 0.
1851 if (!first || !last)
1852 return 0;
1853
1854 LayoutRect boundingBox = flow->linesBoundingBox();
1855 LayoutUnit heightResult = boundingBox.height();
1856 heightResult -= (containingBlock->borderBefore() + containingBlock->borderAf ter());
1857 return heightResult;
1858 } 1797 }
1859 1798
1860 static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh t, const RenderBox* child, const RenderBoxModelObject* containerBlock, LayoutUni t containerLogicalWidth) 1799 static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh t, const RenderBox* child, const RenderBoxModelObject* containerBlock, LayoutUni t containerLogicalWidth)
1861 { 1800 {
1862 if (!logicalLeft.isAuto() || !logicalRight.isAuto()) 1801 if (!logicalLeft.isAuto() || !logicalRight.isAuto())
1863 return; 1802 return;
1864 1803
1865 // FIXME: The static distance computation has not been patched for mixed wri ting modes yet. 1804 // FIXME: The static distance computation has not been patched for mixed wri ting modes yet.
1866 if (child->parent()->style()->direction() == LTR) { 1805 if (child->parent()->style()->direction() == LTR) {
1867 LayoutUnit staticPosition = child->layer()->staticInlinePosition() - con tainerBlock->borderLogicalLeft(); 1806 LayoutUnit staticPosition = child->layer()->staticInlinePosition() - con tainerBlock->borderLogicalLeft();
1868 for (RenderObject* curr = child->parent(); curr && curr != containerBloc k; curr = curr->container()) { 1807 for (RenderObject* curr = child->parent(); curr && curr != containerBloc k; curr = curr->container()) {
1869 if (curr->isBox()) { 1808 if (curr->isBox())
1870 staticPosition += toRenderBox(curr)->logicalLeft(); 1809 staticPosition += toRenderBox(curr)->logicalLeft();
1871 if (toRenderBox(curr)->isRelPositioned())
1872 staticPosition += toRenderBox(curr)->relativePositionOffset( ).width();
1873 } else if (curr->isInline()) {
1874 if (curr->isRelPositioned()) {
1875 if (!curr->style()->logicalLeft().isAuto())
1876 staticPosition += curr->style()->logicalLeft().value();
1877 else
1878 staticPosition -= curr->style()->logicalRight().value();
1879 }
1880 }
1881 } 1810 }
1882 logicalLeft.setValue(Fixed, staticPosition); 1811 logicalLeft.setValue(Fixed, staticPosition);
1883 } else { 1812 } else {
1884 RenderBox* enclosingBox = child->parent()->enclosingBox(); 1813 RenderBox* enclosingBox = child->parent()->enclosingBox();
1885 LayoutUnit staticPosition = child->layer()->staticInlinePosition() + con tainerLogicalWidth + containerBlock->borderLogicalLeft(); 1814 LayoutUnit staticPosition = child->layer()->staticInlinePosition() + con tainerLogicalWidth + containerBlock->borderLogicalLeft();
1886 for (RenderObject* curr = child->parent(); curr; curr = curr->container( )) { 1815 for (RenderObject* curr = child->parent(); curr; curr = curr->container( )) {
1887 if (curr->isBox()) { 1816 if (curr->isBox()) {
1888 if (curr != containerBlock) { 1817 if (curr != containerBlock)
1889 staticPosition -= toRenderBox(curr)->logicalLeft(); 1818 staticPosition -= toRenderBox(curr)->logicalLeft();
1890 if (toRenderBox(curr)->isRelPositioned())
1891 staticPosition -= toRenderBox(curr)->relativePositionOff set().width();
1892 }
1893 if (curr == enclosingBox) 1819 if (curr == enclosingBox)
1894 staticPosition -= enclosingBox->logicalWidth(); 1820 staticPosition -= enclosingBox->logicalWidth();
1895 } else if (curr->isInline()) {
1896 if (curr->isRelPositioned()) {
1897 if (!curr->style()->logicalLeft().isAuto())
1898 staticPosition -= curr->style()->logicalLeft().value();
1899 else
1900 staticPosition += curr->style()->logicalRight().value();
1901 }
1902 } 1821 }
1903 if (curr == containerBlock) 1822 if (curr == containerBlock)
1904 break; 1823 break;
1905 } 1824 }
1906 logicalRight.setValue(Fixed, staticPosition); 1825 logicalRight.setValue(Fixed, staticPosition);
1907 } 1826 }
1908 } 1827 }
1909 1828
1910 void RenderBox::computePositionedLogicalWidth(LogicalExtentComputedValues& compu tedValues) const 1829 void RenderBox::computePositionedLogicalWidth(LogicalExtentComputedValues& compu tedValues) const
1911 { 1830 {
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
3085 3004
3086 LayoutRect RenderBox::layoutOverflowRectForPropagation() const 3005 LayoutRect RenderBox::layoutOverflowRectForPropagation() const
3087 { 3006 {
3088 // Only propagate interior layout overflow if we don't clip it. 3007 // Only propagate interior layout overflow if we don't clip it.
3089 LayoutRect rect = borderBoxRect(); 3008 LayoutRect rect = borderBoxRect();
3090 rect.expand(LayoutSize(LayoutUnit(), marginAfter())); 3009 rect.expand(LayoutSize(LayoutUnit(), marginAfter()));
3091 3010
3092 if (!hasOverflowClip()) 3011 if (!hasOverflowClip())
3093 rect.unite(layoutOverflowRect()); 3012 rect.unite(layoutOverflowRect());
3094 3013
3095 bool hasTransform = hasLayer() && layer()->transform(); 3014 if (hasLayer() && layer()->transform())
3096 if (isRelPositioned() || hasTransform) { 3015 rect = layer()->currentTransform().mapRect(rect);
3097 if (hasTransform)
3098 rect = layer()->currentTransform().mapRect(rect);
3099
3100 if (isRelPositioned())
3101 rect.move(offsetForInFlowPosition());
3102 }
3103 3016
3104 return rect; 3017 return rect;
3105 } 3018 }
3106 3019
3107 LayoutUnit RenderBox::offsetLeft() const 3020 LayoutUnit RenderBox::offsetLeft() const
3108 { 3021 {
3109 return adjustedPositionRelativeToOffsetParent(location()).x(); 3022 return adjustedPositionRelativeToOffsetParent(location()).x();
3110 } 3023 }
3111 3024
3112 LayoutUnit RenderBox::offsetTop() const 3025 LayoutUnit RenderBox::offsetTop() const
(...skipping 10 matching lines...) Expand all
3123 3036
3124 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) 3037 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style)
3125 { 3038 {
3126 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); 3039 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor);
3127 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); 3040 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage();
3128 ASSERT(hasBackground == style.hasBackground()); 3041 ASSERT(hasBackground == style.hasBackground());
3129 hasBorder = style.hasBorder(); 3042 hasBorder = style.hasBorder();
3130 } 3043 }
3131 3044
3132 } // namespace blink 3045 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698