| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 LayoutUnit startPosition = borderStart() + paddingStart(); | 468 LayoutUnit startPosition = borderStart() + paddingStart(); |
| 469 LayoutUnit initialStartPosition = startPosition; | 469 LayoutUnit initialStartPosition = startPosition; |
| 470 if (shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 470 if (shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 471 startPosition -= verticalScrollbarWidth(); | 471 startPosition -= verticalScrollbarWidth(); |
| 472 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava
ilableLogicalWidth(); | 472 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava
ilableLogicalWidth(); |
| 473 | 473 |
| 474 LayoutUnit childMarginStart = marginStartForChild(child); | 474 LayoutUnit childMarginStart = marginStartForChild(child); |
| 475 LayoutUnit newPosition = startPosition + childMarginStart; | 475 LayoutUnit newPosition = startPosition + childMarginStart; |
| 476 | 476 |
| 477 if (child.avoidsFloats() && containsFloats()) { | 477 if (child.avoidsFloats() && containsFloats()) { |
| 478 LayoutUnit positionToAvoidFloats = startOffsetForLine(logicalTopForChild
(child), false, logicalHeightForChild(child)); | 478 LayoutUnit positionToAvoidFloats = startOffsetForLine(logicalTopForChild
(child), DoNotIndentText, logicalHeightForChild(child)); |
| 479 | 479 |
| 480 // If the child has an offset from the content edge to avoid floats then
use that, otherwise let any negative | 480 // If the child has an offset from the content edge to avoid floats then
use that, otherwise let any negative |
| 481 // margin pull it back over the content edge or any positive margin push
it out. | 481 // margin pull it back over the content edge or any positive margin push
it out. |
| 482 // If the child is being centred then the margin calculated to do that h
as factored in any offset required to | 482 // If the child is being centred then the margin calculated to do that h
as factored in any offset required to |
| 483 // avoid floats, so use it if necessary. | 483 // avoid floats, so use it if necessary. |
| 484 if (style()->textAlign() == WEBKIT_CENTER || child.style()->marginStartU
sing(style()).isAuto()) | 484 if (style()->textAlign() == WEBKIT_CENTER || child.style()->marginStartU
sing(style()).isAuto()) |
| 485 newPosition = std::max(newPosition, positionToAvoidFloats + childMar
ginStart); | 485 newPosition = std::max(newPosition, positionToAvoidFloats + childMar
ginStart); |
| 486 else if (positionToAvoidFloats > initialStartPosition) | 486 else if (positionToAvoidFloats > initialStartPosition) |
| 487 newPosition = std::max(newPosition, positionToAvoidFloats); | 487 newPosition = std::max(newPosition, positionToAvoidFloats); |
| 488 } | 488 } |
| (...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1845 break; | 1845 break; |
| 1846 } | 1846 } |
| 1847 | 1847 |
| 1848 // We also clear floats if we are too big to sit on the same line as a float
(and wish to avoid floats by default). | 1848 // We also clear floats if we are too big to sit on the same line as a float
(and wish to avoid floats by default). |
| 1849 LayoutUnit result = clearSet ? std::max<LayoutUnit>(0, logicalBottom - logic
alTop) : LayoutUnit(); | 1849 LayoutUnit result = clearSet ? std::max<LayoutUnit>(0, logicalBottom - logic
alTop) : LayoutUnit(); |
| 1850 if (!result && child->avoidsFloats()) { | 1850 if (!result && child->avoidsFloats()) { |
| 1851 LayoutUnit newLogicalTop = logicalTop; | 1851 LayoutUnit newLogicalTop = logicalTop; |
| 1852 LayoutRect borderBox = child->borderBoxRect(); | 1852 LayoutRect borderBox = child->borderBoxRect(); |
| 1853 LayoutUnit childLogicalWidthAtOldLogicalTopOffset = isHorizontalWritingM
ode() ? borderBox.width() : borderBox.height(); | 1853 LayoutUnit childLogicalWidthAtOldLogicalTopOffset = isHorizontalWritingM
ode() ? borderBox.width() : borderBox.height(); |
| 1854 while (true) { | 1854 while (true) { |
| 1855 LayoutUnit availableLogicalWidthAtNewLogicalTopOffset = availableLog
icalWidthForLine(newLogicalTop, false, logicalHeightForChild(*child)); | 1855 LayoutUnit availableLogicalWidthAtNewLogicalTopOffset = availableLog
icalWidthForLine(newLogicalTop, DoNotIndentText, logicalHeightForChild(*child)); |
| 1856 if (availableLogicalWidthAtNewLogicalTopOffset == availableLogicalWi
dthForContent()) | 1856 if (availableLogicalWidthAtNewLogicalTopOffset == availableLogicalWi
dthForContent()) |
| 1857 return newLogicalTop - logicalTop; | 1857 return newLogicalTop - logicalTop; |
| 1858 | 1858 |
| 1859 LogicalExtentComputedValues computedValues; | 1859 LogicalExtentComputedValues computedValues; |
| 1860 child->logicalExtentAfterUpdatingLogicalWidth(newLogicalTop, compute
dValues); | 1860 child->logicalExtentAfterUpdatingLogicalWidth(newLogicalTop, compute
dValues); |
| 1861 LayoutUnit childLogicalWidthAtNewLogicalTopOffset = computedValues.m
_extent; | 1861 LayoutUnit childLogicalWidthAtNewLogicalTopOffset = computedValues.m
_extent; |
| 1862 | 1862 |
| 1863 if (childLogicalWidthAtNewLogicalTopOffset <= availableLogicalWidthA
tNewLogicalTopOffset) { | 1863 if (childLogicalWidthAtNewLogicalTopOffset <= availableLogicalWidthA
tNewLogicalTopOffset) { |
| 1864 // Even though we may not be moving, if the logical width did sh
rink because of the presence of new floats, then | 1864 // Even though we may not be moving, if the logical width did sh
rink because of the presence of new floats, then |
| 1865 // we need to force a relayout as though we shifted. This happen
s because of the dynamic addition of overhanging floats | 1865 // we need to force a relayout as though we shifted. This happen
s because of the dynamic addition of overhanging floats |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1957 } | 1957 } |
| 1958 } | 1958 } |
| 1959 | 1959 |
| 1960 void LayoutBlockFlow::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildre
n, LayoutBox& child) | 1960 void LayoutBlockFlow::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildre
n, LayoutBox& child) |
| 1961 { | 1961 { |
| 1962 if (child.isLayoutMultiColumnSpannerPlaceholder()) | 1962 if (child.isLayoutMultiColumnSpannerPlaceholder()) |
| 1963 toLayoutMultiColumnSpannerPlaceholder(child).markForLayoutIfObjectInFlow
ThreadNeedsLayout(); | 1963 toLayoutMultiColumnSpannerPlaceholder(child).markForLayoutIfObjectInFlow
ThreadNeedsLayout(); |
| 1964 LayoutBlock::updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, child); | 1964 LayoutBlock::updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, child); |
| 1965 } | 1965 } |
| 1966 | 1966 |
| 1967 void LayoutBlockFlow::updateStaticInlinePositionForChild(LayoutBox& child, Layou
tUnit logicalTop, bool shouldIndentText) | 1967 void LayoutBlockFlow::updateStaticInlinePositionForChild(LayoutBox& child, Layou
tUnit logicalTop, IndentTextOrNot indentText) |
| 1968 { | 1968 { |
| 1969 if (child.style()->isOriginalDisplayInlineType()) | 1969 if (child.style()->isOriginalDisplayInlineType()) |
| 1970 setStaticInlinePositionForChild(child, startAlignedOffsetForLine(logical
Top, shouldIndentText)); | 1970 setStaticInlinePositionForChild(child, startAlignedOffsetForLine(logical
Top, indentText)); |
| 1971 else | 1971 else |
| 1972 setStaticInlinePositionForChild(child, startOffsetForContent()); | 1972 setStaticInlinePositionForChild(child, startOffsetForContent()); |
| 1973 } | 1973 } |
| 1974 | 1974 |
| 1975 void LayoutBlockFlow::setStaticInlinePositionForChild(LayoutBox& child, LayoutUn
it inlinePosition) | 1975 void LayoutBlockFlow::setStaticInlinePositionForChild(LayoutBox& child, LayoutUn
it inlinePosition) |
| 1976 { | 1976 { |
| 1977 child.layer()->setStaticInlinePosition(inlinePosition); | 1977 child.layer()->setStaticInlinePosition(inlinePosition); |
| 1978 } | 1978 } |
| 1979 | 1979 |
| 1980 void LayoutBlockFlow::addChild(LayoutObject* newChild, LayoutObject* beforeChild
) | 1980 void LayoutBlockFlow::addChild(LayoutObject* newChild, LayoutObject* beforeChild
) |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2174 if (isHorizontalWritingMode()) | 2174 if (isHorizontalWritingMode()) |
| 2175 return LayoutPoint(point.x(), point.y() + size().height() - child.layout
Object()->size().height() - 2 * yPositionForFloatIncludingMargin(child)); | 2175 return LayoutPoint(point.x(), point.y() + size().height() - child.layout
Object()->size().height() - 2 * yPositionForFloatIncludingMargin(child)); |
| 2176 return LayoutPoint(point.x() + size().width() - child.layoutObject()->size()
.width() - 2 * xPositionForFloatIncludingMargin(child), point.y()); | 2176 return LayoutPoint(point.x() + size().width() - child.layoutObject()->size()
.width() - 2 * xPositionForFloatIncludingMargin(child), point.y()); |
| 2177 } | 2177 } |
| 2178 | 2178 |
| 2179 LayoutUnit LayoutBlockFlow::logicalLeftOffsetForPositioningFloat(LayoutUnit logi
calTop, LayoutUnit fixedOffset, LayoutUnit* heightRemaining) const | 2179 LayoutUnit LayoutBlockFlow::logicalLeftOffsetForPositioningFloat(LayoutUnit logi
calTop, LayoutUnit fixedOffset, LayoutUnit* heightRemaining) const |
| 2180 { | 2180 { |
| 2181 LayoutUnit offset = fixedOffset; | 2181 LayoutUnit offset = fixedOffset; |
| 2182 if (m_floatingObjects && m_floatingObjects->hasLeftObjects()) | 2182 if (m_floatingObjects && m_floatingObjects->hasLeftObjects()) |
| 2183 offset = m_floatingObjects->logicalLeftOffsetForPositioningFloat(fixedOf
fset, logicalTop, heightRemaining); | 2183 offset = m_floatingObjects->logicalLeftOffsetForPositioningFloat(fixedOf
fset, logicalTop, heightRemaining); |
| 2184 return adjustLogicalLeftOffsetForLine(offset, false); | 2184 return adjustLogicalLeftOffsetForLine(offset, DoNotIndentText); |
| 2185 } | 2185 } |
| 2186 | 2186 |
| 2187 LayoutUnit LayoutBlockFlow::logicalRightOffsetForPositioningFloat(LayoutUnit log
icalTop, LayoutUnit fixedOffset, LayoutUnit* heightRemaining) const | 2187 LayoutUnit LayoutBlockFlow::logicalRightOffsetForPositioningFloat(LayoutUnit log
icalTop, LayoutUnit fixedOffset, LayoutUnit* heightRemaining) const |
| 2188 { | 2188 { |
| 2189 LayoutUnit offset = fixedOffset; | 2189 LayoutUnit offset = fixedOffset; |
| 2190 if (m_floatingObjects && m_floatingObjects->hasRightObjects()) | 2190 if (m_floatingObjects && m_floatingObjects->hasRightObjects()) |
| 2191 offset = m_floatingObjects->logicalRightOffsetForPositioningFloat(fixedO
ffset, logicalTop, heightRemaining); | 2191 offset = m_floatingObjects->logicalRightOffsetForPositioningFloat(fixedO
ffset, logicalTop, heightRemaining); |
| 2192 return adjustLogicalRightOffsetForLine(offset, false); | 2192 return adjustLogicalRightOffsetForLine(offset, DoNotIndentText); |
| 2193 } | 2193 } |
| 2194 | 2194 |
| 2195 LayoutUnit LayoutBlockFlow::adjustLogicalLeftOffsetForLine(LayoutUnit offsetFrom
Floats, bool applyTextIndent) const | 2195 LayoutUnit LayoutBlockFlow::adjustLogicalLeftOffsetForLine(LayoutUnit offsetFrom
Floats, IndentTextOrNot applyTextIndent) const |
| 2196 { | 2196 { |
| 2197 LayoutUnit left = offsetFromFloats; | 2197 LayoutUnit left = offsetFromFloats; |
| 2198 | 2198 |
| 2199 if (applyTextIndent && style()->isLeftToRightDirection()) | 2199 if (applyTextIndent == IndentText && style()->isLeftToRightDirection()) |
| 2200 left += textIndentOffset(); | 2200 left += textIndentOffset(); |
| 2201 | 2201 |
| 2202 return left; | 2202 return left; |
| 2203 } | 2203 } |
| 2204 | 2204 |
| 2205 LayoutUnit LayoutBlockFlow::adjustLogicalRightOffsetForLine(LayoutUnit offsetFro
mFloats, bool applyTextIndent) const | 2205 LayoutUnit LayoutBlockFlow::adjustLogicalRightOffsetForLine(LayoutUnit offsetFro
mFloats, IndentTextOrNot applyTextIndent) const |
| 2206 { | 2206 { |
| 2207 LayoutUnit right = offsetFromFloats; | 2207 LayoutUnit right = offsetFromFloats; |
| 2208 | 2208 |
| 2209 if (applyTextIndent && !style()->isLeftToRightDirection()) | 2209 if (applyTextIndent == IndentText && !style()->isLeftToRightDirection()) |
| 2210 right -= textIndentOffset(); | 2210 right -= textIndentOffset(); |
| 2211 | 2211 |
| 2212 return right; | 2212 return right; |
| 2213 } | 2213 } |
| 2214 | 2214 |
| 2215 LayoutPoint LayoutBlockFlow::computeLogicalLocationForFloat(const FloatingObject
& floatingObject, LayoutUnit logicalTopOffset) const | 2215 LayoutPoint LayoutBlockFlow::computeLogicalLocationForFloat(const FloatingObject
& floatingObject, LayoutUnit logicalTopOffset) const |
| 2216 { | 2216 { |
| 2217 LayoutBox* childBox = floatingObject.layoutObject(); | 2217 LayoutBox* childBox = floatingObject.layoutObject(); |
| 2218 LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent(); // Constant pa
rt of left offset. | 2218 LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent(); // Constant pa
rt of left offset. |
| 2219 LayoutUnit logicalRightOffset; // Constant part of right offset. | 2219 LayoutUnit logicalRightOffset; // Constant part of right offset. |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2977 | 2977 |
| 2978 void LayoutBlockFlow::moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, Lay
outObject* startChild, LayoutObject* endChild, LayoutObject* beforeChild, bool f
ullRemoveInsert) | 2978 void LayoutBlockFlow::moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, Lay
outObject* startChild, LayoutObject* endChild, LayoutObject* beforeChild, bool f
ullRemoveInsert) |
| 2979 { | 2979 { |
| 2980 if (childrenInline()) | 2980 if (childrenInline()) |
| 2981 deleteLineBoxTree(); | 2981 deleteLineBoxTree(); |
| 2982 LayoutBoxModelObject::moveChildrenTo(toBoxModelObject, startChild, endChild,
beforeChild, fullRemoveInsert); | 2982 LayoutBoxModelObject::moveChildrenTo(toBoxModelObject, startChild, endChild,
beforeChild, fullRemoveInsert); |
| 2983 } | 2983 } |
| 2984 | 2984 |
| 2985 LayoutUnit LayoutBlockFlow::logicalLeftSelectionOffset(const LayoutBlock* rootBl
ock, LayoutUnit position) const | 2985 LayoutUnit LayoutBlockFlow::logicalLeftSelectionOffset(const LayoutBlock* rootBl
ock, LayoutUnit position) const |
| 2986 { | 2986 { |
| 2987 LayoutUnit logicalLeft = logicalLeftOffsetForLine(position, false); | 2987 LayoutUnit logicalLeft = logicalLeftOffsetForLine(position, DoNotIndentText)
; |
| 2988 if (logicalLeft == logicalLeftOffsetForContent()) | 2988 if (logicalLeft == logicalLeftOffsetForContent()) |
| 2989 return LayoutBlock::logicalLeftSelectionOffset(rootBlock, position); | 2989 return LayoutBlock::logicalLeftSelectionOffset(rootBlock, position); |
| 2990 | 2990 |
| 2991 const LayoutBlock* cb = this; | 2991 const LayoutBlock* cb = this; |
| 2992 while (cb != rootBlock) { | 2992 while (cb != rootBlock) { |
| 2993 logicalLeft += cb->logicalLeft(); | 2993 logicalLeft += cb->logicalLeft(); |
| 2994 cb = cb->containingBlock(); | 2994 cb = cb->containingBlock(); |
| 2995 } | 2995 } |
| 2996 return logicalLeft; | 2996 return logicalLeft; |
| 2997 } | 2997 } |
| 2998 | 2998 |
| 2999 LayoutUnit LayoutBlockFlow::logicalRightSelectionOffset(const LayoutBlock* rootB
lock, LayoutUnit position) const | 2999 LayoutUnit LayoutBlockFlow::logicalRightSelectionOffset(const LayoutBlock* rootB
lock, LayoutUnit position) const |
| 3000 { | 3000 { |
| 3001 LayoutUnit logicalRight = logicalRightOffsetForLine(position, false); | 3001 LayoutUnit logicalRight = logicalRightOffsetForLine(position, DoNotIndentTex
t); |
| 3002 if (logicalRight == logicalRightOffsetForContent()) | 3002 if (logicalRight == logicalRightOffsetForContent()) |
| 3003 return LayoutBlock::logicalRightSelectionOffset(rootBlock, position); | 3003 return LayoutBlock::logicalRightSelectionOffset(rootBlock, position); |
| 3004 | 3004 |
| 3005 const LayoutBlock* cb = this; | 3005 const LayoutBlock* cb = this; |
| 3006 while (cb != rootBlock) { | 3006 while (cb != rootBlock) { |
| 3007 logicalRight += cb->logicalLeft(); | 3007 logicalRight += cb->logicalLeft(); |
| 3008 cb = cb->containingBlock(); | 3008 cb = cb->containingBlock(); |
| 3009 } | 3009 } |
| 3010 return logicalRight; | 3010 return logicalRight; |
| 3011 } | 3011 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3124 FrameView* frameView = document().view(); | 3124 FrameView* frameView = document().view(); |
| 3125 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 3125 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
| 3126 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 3126 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
| 3127 if (size().height() < visibleHeight) | 3127 if (size().height() < visibleHeight) |
| 3128 top += (visibleHeight - size().height()) / 2; | 3128 top += (visibleHeight - size().height()) / 2; |
| 3129 setY(top); | 3129 setY(top); |
| 3130 dialog->setCentered(top); | 3130 dialog->setCentered(top); |
| 3131 } | 3131 } |
| 3132 | 3132 |
| 3133 } // namespace blink | 3133 } // namespace blink |
| OLD | NEW |