| OLD | NEW |
| 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) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 if (cb->isRenderBlock()) | 252 if (cb->isRenderBlock()) |
| 253 toRenderBlock(cb)->removePositionedObjects(this, NewContainingBl
ock); | 253 toRenderBlock(cb)->removePositionedObjects(this, NewContainingBl
ock); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 | 256 |
| 257 RenderBox::styleWillChange(diff, newStyle); | 257 RenderBox::styleWillChange(diff, newStyle); |
| 258 } | 258 } |
| 259 | 259 |
| 260 static bool borderOrPaddingLogicalWidthChanged(const RenderStyle* oldStyle, cons
t RenderStyle* newStyle) | 260 static bool borderOrPaddingLogicalWidthChanged(const RenderStyle* oldStyle, cons
t RenderStyle* newStyle) |
| 261 { | 261 { |
| 262 if (newStyle->isHorizontalWritingMode()) | 262 return oldStyle->borderLeftWidth() != newStyle->borderLeftWidth() |
| 263 return oldStyle->borderLeftWidth() != newStyle->borderLeftWidth() | 263 || oldStyle->borderRightWidth() != newStyle->borderRightWidth() |
| 264 || oldStyle->borderRightWidth() != newStyle->borderRightWidth() | 264 || oldStyle->paddingLeft() != newStyle->paddingLeft() |
| 265 || oldStyle->paddingLeft() != newStyle->paddingLeft() | 265 || oldStyle->paddingRight() != newStyle->paddingRight(); |
| 266 || oldStyle->paddingRight() != newStyle->paddingRight(); | |
| 267 | |
| 268 return oldStyle->borderTopWidth() != newStyle->borderTopWidth() | |
| 269 || oldStyle->borderBottomWidth() != newStyle->borderBottomWidth() | |
| 270 || oldStyle->paddingTop() != newStyle->paddingTop() | |
| 271 || oldStyle->paddingBottom() != newStyle->paddingBottom(); | |
| 272 } | 266 } |
| 273 | 267 |
| 274 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty
le) | 268 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty
le) |
| 275 { | 269 { |
| 276 RenderBox::styleDidChange(diff, oldStyle); | 270 RenderBox::styleDidChange(diff, oldStyle); |
| 277 | 271 |
| 278 RenderStyle* newStyle = style(); | 272 RenderStyle* newStyle = style(); |
| 279 | 273 |
| 280 if (!isAnonymousBlock()) { | 274 if (!isAnonymousBlock()) { |
| 281 // Ensure that all of our continuation blocks pick up the new style. | 275 // Ensure that all of our continuation blocks pick up the new style. |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 | 1053 |
| 1060 // Add in the overflow from positioned objects. | 1054 // Add in the overflow from positioned objects. |
| 1061 addOverflowFromPositionedObjects(); | 1055 addOverflowFromPositionedObjects(); |
| 1062 | 1056 |
| 1063 if (hasOverflowClip()) { | 1057 if (hasOverflowClip()) { |
| 1064 // When we have overflow clip, propagate the original spillout since it
will include collapsed bottom margins | 1058 // When we have overflow clip, propagate the original spillout since it
will include collapsed bottom margins |
| 1065 // and bottom padding. Set the axis we don't care about to be 1, since
we want this overflow to always | 1059 // and bottom padding. Set the axis we don't care about to be 1, since
we want this overflow to always |
| 1066 // be considered reachable. | 1060 // be considered reachable. |
| 1067 LayoutRect clientRect(noOverflowRect()); | 1061 LayoutRect clientRect(noOverflowRect()); |
| 1068 LayoutRect rectToApply; | 1062 LayoutRect rectToApply; |
| 1069 if (isHorizontalWritingMode()) | 1063 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), 1, std::max<Lay
outUnit>(0, oldClientAfterEdge - clientRect.y())); |
| 1070 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), 1, std::max
<LayoutUnit>(0, oldClientAfterEdge - clientRect.y())); | |
| 1071 else | |
| 1072 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), std::max<La
youtUnit>(0, oldClientAfterEdge - clientRect.x()), 1); | |
| 1073 addLayoutOverflow(rectToApply); | 1064 addLayoutOverflow(rectToApply); |
| 1074 if (hasRenderOverflow()) | 1065 if (hasRenderOverflow()) |
| 1075 m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge); | 1066 m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge); |
| 1076 } | 1067 } |
| 1077 | 1068 |
| 1078 addVisualEffectOverflow(); | 1069 addVisualEffectOverflow(); |
| 1079 } | 1070 } |
| 1080 | 1071 |
| 1081 void RenderBlock::addOverflowFromBlockChildren() | 1072 void RenderBlock::addOverflowFromBlockChildren() |
| 1082 { | 1073 { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 | 1212 |
| 1222 // FIXME: this should only be set from clearNeedsLayout crbug.com/361250 | 1213 // FIXME: this should only be set from clearNeedsLayout crbug.com/361250 |
| 1223 r->setLayoutDidGetCalled(true); | 1214 r->setLayoutDidGetCalled(true); |
| 1224 | 1215 |
| 1225 SubtreeLayoutScope layoutScope(*r); | 1216 SubtreeLayoutScope layoutScope(*r); |
| 1226 | 1217 |
| 1227 // When a non-positioned block element moves, it may have positioned chi
ldren that are implicitly positioned relative to the | 1218 // When a non-positioned block element moves, it may have positioned chi
ldren that are implicitly positioned relative to the |
| 1228 // non-positioned block. Rather than trying to detect all of these move
ment cases, we just always lay out positioned | 1219 // non-positioned block. Rather than trying to detect all of these move
ment cases, we just always lay out positioned |
| 1229 // objects that are positioned implicitly like this. Such objects are r
are, and so in typical DHTML menu usage (where everything is | 1220 // objects that are positioned implicitly like this. Such objects are r
are, and so in typical DHTML menu usage (where everything is |
| 1230 // positioned explicitly) this should not incur a performance penalty. | 1221 // positioned explicitly) this should not incur a performance penalty. |
| 1231 if (relayoutChildren || (r->style()->hasStaticBlockPosition(isHorizontal
WritingMode()) && r->parent() != this)) | 1222 if (relayoutChildren || (r->style()->hasStaticBlockPosition() && r->pare
nt() != this)) |
| 1232 layoutScope.setChildNeedsLayout(r); | 1223 layoutScope.setChildNeedsLayout(r); |
| 1233 | 1224 |
| 1234 // If relayoutChildren is set and the child has percentage padding or an
embedded content box, we also need to invalidate the childs pref widths. | 1225 // If relayoutChildren is set and the child has percentage padding or an
embedded content box, we also need to invalidate the childs pref widths. |
| 1235 if (relayoutChildren && r->needsPreferredWidthsRecalculation()) | 1226 if (relayoutChildren && r->needsPreferredWidthsRecalculation()) |
| 1236 r->setPreferredLogicalWidthsDirty(MarkOnlyThis); | 1227 r->setPreferredLogicalWidthsDirty(MarkOnlyThis); |
| 1237 | 1228 |
| 1238 if (info == ForcedLayoutAfterContainingBlockMoved) | 1229 if (info == ForcedLayoutAfterContainingBlockMoved) |
| 1239 r->setNeedsPositionedMovementLayout(); | 1230 r->setNeedsPositionedMovementLayout(); |
| 1240 | 1231 |
| 1241 r->layoutIfNeeded(); | 1232 r->layoutIfNeeded(); |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1629 | 1620 |
| 1630 TrackedRendererListHashSet::const_iterator end = positionedObjects->end(); | 1621 TrackedRendererListHashSet::const_iterator end = positionedObjects->end(); |
| 1631 for (TrackedRendererListHashSet::const_iterator it = positionedObjects->begi
n(); it != end; ++it) { | 1622 for (TrackedRendererListHashSet::const_iterator it = positionedObjects->begi
n(); it != end; ++it) { |
| 1632 RenderBox* r = *it; | 1623 RenderBox* r = *it; |
| 1633 paintInfo->context->clipOut(IntRect(offset.x() + r->x(), offset.y() + r-
>y(), r->width(), r->height())); | 1624 paintInfo->context->clipOut(IntRect(offset.x() + r->x(), offset.y() + r-
>y(), r->width(), r->height())); |
| 1634 } | 1625 } |
| 1635 } | 1626 } |
| 1636 | 1627 |
| 1637 LayoutUnit RenderBlock::blockDirectionOffset(const LayoutSize& offsetFromBlock)
const | 1628 LayoutUnit RenderBlock::blockDirectionOffset(const LayoutSize& offsetFromBlock)
const |
| 1638 { | 1629 { |
| 1639 return isHorizontalWritingMode() ? offsetFromBlock.height() : offsetFromBloc
k.width(); | 1630 // FIXME(sky): Remove |
| 1631 return offsetFromBlock.height(); |
| 1640 } | 1632 } |
| 1641 | 1633 |
| 1642 LayoutUnit RenderBlock::inlineDirectionOffset(const LayoutSize& offsetFromBlock)
const | 1634 LayoutUnit RenderBlock::inlineDirectionOffset(const LayoutSize& offsetFromBlock)
const |
| 1643 { | 1635 { |
| 1644 return isHorizontalWritingMode() ? offsetFromBlock.width() : offsetFromBlock
.height(); | 1636 // FIXME(sky): Remove |
| 1637 return offsetFromBlock.width(); |
| 1645 } | 1638 } |
| 1646 | 1639 |
| 1647 LayoutRect RenderBlock::logicalRectToPhysicalRect(const LayoutPoint& rootBlockPh
ysicalPosition, const LayoutRect& logicalRect) | 1640 LayoutRect RenderBlock::logicalRectToPhysicalRect(const LayoutPoint& rootBlockPh
ysicalPosition, const LayoutRect& logicalRect) |
| 1648 { | 1641 { |
| 1649 LayoutRect result; | 1642 LayoutRect result = logicalRect; |
| 1650 if (isHorizontalWritingMode()) | |
| 1651 result = logicalRect; | |
| 1652 else | |
| 1653 result = LayoutRect(logicalRect.y(), logicalRect.x(), logicalRect.height
(), logicalRect.width()); | |
| 1654 flipForWritingMode(result); | |
| 1655 result.moveBy(rootBlockPhysicalPosition); | 1643 result.moveBy(rootBlockPhysicalPosition); |
| 1656 return result; | 1644 return result; |
| 1657 } | 1645 } |
| 1658 | 1646 |
| 1659 GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const LayoutPoint& r
ootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, | 1647 GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const LayoutPoint& r
ootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, |
| 1660 LayoutUnit& lastLogicalTop, LayoutUnit& last
LogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo) | 1648 LayoutUnit& lastLogicalTop, LayoutUnit& last
LogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo) |
| 1661 { | 1649 { |
| 1662 // IMPORTANT: Callers of this method that intend for painting to happen need
to do a save/restore. | 1650 // IMPORTANT: Callers of this method that intend for painting to happen need
to do a save/restore. |
| 1663 // Clip out floating and positioned objects when painting selection gaps. | 1651 // Clip out floating and positioned objects when painting selection gaps. |
| 1664 if (paintInfo) { | 1652 if (paintInfo) { |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2277 RenderObject* ancestor = parent; | 2265 RenderObject* ancestor = parent; |
| 2278 while (ancestor && !ancestor->nonPseudoNode()) | 2266 while (ancestor && !ancestor->nonPseudoNode()) |
| 2279 ancestor = ancestor->parent(); | 2267 ancestor = ancestor->parent(); |
| 2280 | 2268 |
| 2281 // If we can't find an ancestor to check editability on, or editability is u
nchanged, we recur like normal | 2269 // If we can't find an ancestor to check editability on, or editability is u
nchanged, we recur like normal |
| 2282 if (isEditingBoundary(ancestor, child)) | 2270 if (isEditingBoundary(ancestor, child)) |
| 2283 return child->positionForPoint(pointInChildCoordinates); | 2271 return child->positionForPoint(pointInChildCoordinates); |
| 2284 | 2272 |
| 2285 // Otherwise return before or after the child, depending on if the click was
to the logical left or logical right of the child | 2273 // Otherwise return before or after the child, depending on if the click was
to the logical left or logical right of the child |
| 2286 LayoutUnit childMiddle = parent->logicalWidthForChild(child) / 2; | 2274 LayoutUnit childMiddle = parent->logicalWidthForChild(child) / 2; |
| 2287 LayoutUnit logicalLeft = parent->isHorizontalWritingMode() ? pointInChildCoo
rdinates.x() : pointInChildCoordinates.y(); | 2275 LayoutUnit logicalLeft = pointInChildCoordinates.x(); |
| 2288 if (logicalLeft < childMiddle) | 2276 if (logicalLeft < childMiddle) |
| 2289 return ancestor->createPositionWithAffinity(childNode->nodeIndex(), DOWN
STREAM); | 2277 return ancestor->createPositionWithAffinity(childNode->nodeIndex(), DOWN
STREAM); |
| 2290 return ancestor->createPositionWithAffinity(childNode->nodeIndex() + 1, UPST
REAM); | 2278 return ancestor->createPositionWithAffinity(childNode->nodeIndex() + 1, UPST
REAM); |
| 2291 } | 2279 } |
| 2292 | 2280 |
| 2293 PositionWithAffinity RenderBlock::positionForPointWithInlineChildren(const Layou
tPoint& pointInLogicalContents) | 2281 PositionWithAffinity RenderBlock::positionForPointWithInlineChildren(const Layou
tPoint& pointInLogicalContents) |
| 2294 { | 2282 { |
| 2295 ASSERT(childrenInline()); | 2283 ASSERT(childrenInline()); |
| 2296 | 2284 |
| 2297 if (!firstRootBox()) | 2285 if (!firstRootBox()) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2350 if (InlineBox* newBox = box->nextLeafChildIgnoringLineBreak(
)) | 2338 if (InlineBox* newBox = box->nextLeafChildIgnoringLineBreak(
)) |
| 2351 box = newBox; | 2339 box = newBox; |
| 2352 } | 2340 } |
| 2353 // y coordinate is above first root line box, so return the star
t of the first | 2341 // y coordinate is above first root line box, so return the star
t of the first |
| 2354 return PositionWithAffinity(positionForBox(box, true), DOWNSTREA
M); | 2342 return PositionWithAffinity(positionForBox(box, true), DOWNSTREA
M); |
| 2355 } | 2343 } |
| 2356 } | 2344 } |
| 2357 | 2345 |
| 2358 // pass the box a top position that is inside it | 2346 // pass the box a top position that is inside it |
| 2359 LayoutPoint point(pointInLogicalContents.x(), closestBox->root().blockDi
rectionPointInLine()); | 2347 LayoutPoint point(pointInLogicalContents.x(), closestBox->root().blockDi
rectionPointInLine()); |
| 2360 if (!isHorizontalWritingMode()) | |
| 2361 point = point.transposedPoint(); | |
| 2362 if (closestBox->renderer().isReplaced()) | 2348 if (closestBox->renderer().isReplaced()) |
| 2363 return positionForPointRespectingEditingBoundaries(this, &toRenderBo
x(closestBox->renderer()), point); | 2349 return positionForPointRespectingEditingBoundaries(this, &toRenderBo
x(closestBox->renderer()), point); |
| 2364 return closestBox->renderer().positionForPoint(point); | 2350 return closestBox->renderer().positionForPoint(point); |
| 2365 } | 2351 } |
| 2366 | 2352 |
| 2367 if (lastRootBoxWithChildren) { | 2353 if (lastRootBoxWithChildren) { |
| 2368 // We hit this case for Mac behavior when the Y coordinate is below the
last box. | 2354 // We hit this case for Mac behavior when the Y coordinate is below the
last box. |
| 2369 ASSERT(moveCaretToBoundary); | 2355 ASSERT(moveCaretToBoundary); |
| 2370 InlineBox* logicallyLastBox; | 2356 InlineBox* logicallyLastBox; |
| 2371 if (lastRootBoxWithChildren->getLogicalEndBoxWithNode(logicallyLastBox)) | 2357 if (lastRootBoxWithChildren->getLogicalEndBoxWithNode(logicallyLastBox)) |
| 2372 return PositionWithAffinity(positionForBox(logicallyLastBox, false),
DOWNSTREAM); | 2358 return PositionWithAffinity(positionForBox(logicallyLastBox, false),
DOWNSTREAM); |
| 2373 } | 2359 } |
| 2374 | 2360 |
| 2375 // Can't reach this. We have a root line box, but it has no kids. | 2361 // Can't reach this. We have a root line box, but it has no kids. |
| 2376 // FIXME: This should ASSERT_NOT_REACHED(), but clicking on placeholder text | 2362 // FIXME: This should ASSERT_NOT_REACHED(), but clicking on placeholder text |
| 2377 // seems to hit this code path. | 2363 // seems to hit this code path. |
| 2378 return createPositionWithAffinity(0, DOWNSTREAM); | 2364 return createPositionWithAffinity(0, DOWNSTREAM); |
| 2379 } | 2365 } |
| 2380 | 2366 |
| 2381 static inline bool isChildHitTestCandidate(RenderBox* box) | 2367 static inline bool isChildHitTestCandidate(RenderBox* box) |
| 2382 { | 2368 { |
| 2383 return box->height() && !box->isFloatingOrOutOfFlowPositioned(); | 2369 return box->height() && !box->isFloatingOrOutOfFlowPositioned(); |
| 2384 } | 2370 } |
| 2385 | 2371 |
| 2386 PositionWithAffinity RenderBlock::positionForPoint(const LayoutPoint& point) | 2372 PositionWithAffinity RenderBlock::positionForPoint(const LayoutPoint& point) |
| 2387 { | 2373 { |
| 2388 if (isReplaced()) { | 2374 if (isReplaced()) { |
| 2389 // FIXME: This seems wrong when the object's writing-mode doesn't match
the line's writing-mode. | 2375 // FIXME: This seems wrong when the object's writing-mode doesn't match
the line's writing-mode. |
| 2390 LayoutUnit pointLogicalLeft = isHorizontalWritingMode() ? point.x() : po
int.y(); | 2376 LayoutUnit pointLogicalLeft = point.x(); |
| 2391 LayoutUnit pointLogicalTop = isHorizontalWritingMode() ? point.y() : poi
nt.x(); | 2377 LayoutUnit pointLogicalTop = point.y(); |
| 2392 | 2378 |
| 2393 if (pointLogicalLeft < 0) | 2379 if (pointLogicalLeft < 0) |
| 2394 return createPositionWithAffinity(caretMinOffset(), DOWNSTREAM); | 2380 return createPositionWithAffinity(caretMinOffset(), DOWNSTREAM); |
| 2395 if (pointLogicalLeft >= logicalWidth()) | 2381 if (pointLogicalLeft >= logicalWidth()) |
| 2396 return createPositionWithAffinity(caretMaxOffset(), DOWNSTREAM); | 2382 return createPositionWithAffinity(caretMaxOffset(), DOWNSTREAM); |
| 2397 if (pointLogicalTop < 0) | 2383 if (pointLogicalTop < 0) |
| 2398 return createPositionWithAffinity(caretMinOffset(), DOWNSTREAM); | 2384 return createPositionWithAffinity(caretMinOffset(), DOWNSTREAM); |
| 2399 if (pointLogicalTop >= logicalHeight()) | 2385 if (pointLogicalTop >= logicalHeight()) |
| 2400 return createPositionWithAffinity(caretMaxOffset(), DOWNSTREAM); | 2386 return createPositionWithAffinity(caretMaxOffset(), DOWNSTREAM); |
| 2401 } | 2387 } |
| 2402 | 2388 |
| 2403 LayoutPoint pointInContents = point; | 2389 LayoutPoint pointInContents = point; |
| 2404 offsetForContents(pointInContents); | 2390 offsetForContents(pointInContents); |
| 2405 LayoutPoint pointInLogicalContents(pointInContents); | 2391 LayoutPoint pointInLogicalContents(pointInContents); |
| 2406 if (!isHorizontalWritingMode()) | |
| 2407 pointInLogicalContents = pointInLogicalContents.transposedPoint(); | |
| 2408 | 2392 |
| 2409 if (childrenInline()) | 2393 if (childrenInline()) |
| 2410 return positionForPointWithInlineChildren(pointInLogicalContents); | 2394 return positionForPointWithInlineChildren(pointInLogicalContents); |
| 2411 | 2395 |
| 2412 RenderBox* lastCandidateBox = lastChildBox(); | 2396 RenderBox* lastCandidateBox = lastChildBox(); |
| 2413 while (lastCandidateBox && !isChildHitTestCandidate(lastCandidateBox)) | 2397 while (lastCandidateBox && !isChildHitTestCandidate(lastCandidateBox)) |
| 2414 lastCandidateBox = lastCandidateBox->previousSiblingBox(); | 2398 lastCandidateBox = lastCandidateBox->previousSiblingBox(); |
| 2415 | 2399 |
| 2416 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); | 2400 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); |
| 2417 if (lastCandidateBox) { | 2401 if (lastCandidateBox) { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2532 Length endMarginLength = childStyle->marginEndUsing(styleToUse); | 2516 Length endMarginLength = childStyle->marginEndUsing(styleToUse); |
| 2533 LayoutUnit margin = 0; | 2517 LayoutUnit margin = 0; |
| 2534 LayoutUnit marginStart = 0; | 2518 LayoutUnit marginStart = 0; |
| 2535 LayoutUnit marginEnd = 0; | 2519 LayoutUnit marginEnd = 0; |
| 2536 if (startMarginLength.isFixed()) | 2520 if (startMarginLength.isFixed()) |
| 2537 marginStart += startMarginLength.value(); | 2521 marginStart += startMarginLength.value(); |
| 2538 if (endMarginLength.isFixed()) | 2522 if (endMarginLength.isFixed()) |
| 2539 marginEnd += endMarginLength.value(); | 2523 marginEnd += endMarginLength.value(); |
| 2540 margin = marginStart + marginEnd; | 2524 margin = marginStart + marginEnd; |
| 2541 | 2525 |
| 2542 LayoutUnit childMinPreferredLogicalWidth, childMaxPreferredLogicalWidth; | 2526 LayoutUnit childMinPreferredLogicalWidth = child->minPreferredLogicalWid
th(); |
| 2543 if (child->isBox() && child->isHorizontalWritingMode() != isHorizontalWr
itingMode()) { | 2527 LayoutUnit childMaxPreferredLogicalWidth = child->maxPreferredLogicalWid
th(); |
| 2544 RenderBox* childBox = toRenderBox(child); | |
| 2545 LogicalExtentComputedValues computedValues; | |
| 2546 childBox->computeLogicalHeight(childBox->borderAndPaddingLogicalHeig
ht(), 0, computedValues); | |
| 2547 childMinPreferredLogicalWidth = childMaxPreferredLogicalWidth = comp
utedValues.m_extent; | |
| 2548 } else { | |
| 2549 childMinPreferredLogicalWidth = child->minPreferredLogicalWidth(); | |
| 2550 childMaxPreferredLogicalWidth = child->maxPreferredLogicalWidth(); | |
| 2551 } | |
| 2552 | 2528 |
| 2553 LayoutUnit w = childMinPreferredLogicalWidth + margin; | 2529 LayoutUnit w = childMinPreferredLogicalWidth + margin; |
| 2554 minLogicalWidth = std::max(w, minLogicalWidth); | 2530 minLogicalWidth = std::max(w, minLogicalWidth); |
| 2555 | 2531 |
| 2556 // IE ignores tables for calculation of nowrap. Makes some sense. | 2532 // IE ignores tables for calculation of nowrap. Makes some sense. |
| 2557 if (nowrap) | 2533 if (nowrap) |
| 2558 maxLogicalWidth = std::max(w, maxLogicalWidth); | 2534 maxLogicalWidth = std::max(w, maxLogicalWidth); |
| 2559 | 2535 |
| 2560 w = childMaxPreferredLogicalWidth + margin; | 2536 w = childMaxPreferredLogicalWidth + margin; |
| 2561 | 2537 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2648 | 2624 |
| 2649 const FontMetrics& fontMetrics = style(firstLine)->fontMetrics(); | 2625 const FontMetrics& fontMetrics = style(firstLine)->fontMetrics(); |
| 2650 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction,
linePositionMode) - fontMetrics.height()) / 2; | 2626 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction,
linePositionMode) - fontMetrics.height()) / 2; |
| 2651 } | 2627 } |
| 2652 | 2628 |
| 2653 LayoutUnit RenderBlock::minLineHeightForReplacedRenderer(bool isFirstLine, Layou
tUnit replacedHeight) const | 2629 LayoutUnit RenderBlock::minLineHeightForReplacedRenderer(bool isFirstLine, Layou
tUnit replacedHeight) const |
| 2654 { | 2630 { |
| 2655 if (!(style(isFirstLine)->lineBoxContain() & LineBoxContainBlock)) | 2631 if (!(style(isFirstLine)->lineBoxContain() & LineBoxContainBlock)) |
| 2656 return 0; | 2632 return 0; |
| 2657 | 2633 |
| 2658 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, isHorizo
ntalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes))
; | 2634 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, Horizont
alLine, PositionOfInteriorLineBoxes)); |
| 2659 } | 2635 } |
| 2660 | 2636 |
| 2661 int RenderBlock::firstLineBoxBaseline() const | 2637 int RenderBlock::firstLineBoxBaseline() const |
| 2662 { | 2638 { |
| 2663 if (isWritingModeRoot()) | 2639 if (isWritingModeRoot()) |
| 2664 return -1; | 2640 return -1; |
| 2665 | 2641 |
| 2666 if (childrenInline()) { | 2642 if (childrenInline()) { |
| 2667 if (firstLineBox()) | 2643 if (firstLineBox()) |
| 2668 return firstLineBox()->logicalTop() + style(true)->fontMetrics().asc
ent(firstRootBox()->baselineType()); | 2644 return firstLineBox()->logicalTop() + style(true)->fontMetrics().asc
ent(firstRootBox()->baselineType()); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2992 { | 2968 { |
| 2993 return createAnonymousWithParentRendererAndDisplay(parent, style()->display(
)); | 2969 return createAnonymousWithParentRendererAndDisplay(parent, style()->display(
)); |
| 2994 } | 2970 } |
| 2995 | 2971 |
| 2996 LayoutUnit RenderBlock::collapsedMarginBeforeForChild(const RenderBox* child) co
nst | 2972 LayoutUnit RenderBlock::collapsedMarginBeforeForChild(const RenderBox* child) co
nst |
| 2997 { | 2973 { |
| 2998 // If the child has the same directionality as we do, then we can just retur
n its | 2974 // If the child has the same directionality as we do, then we can just retur
n its |
| 2999 // collapsed margin. | 2975 // collapsed margin. |
| 3000 if (!child->isWritingModeRoot()) | 2976 if (!child->isWritingModeRoot()) |
| 3001 return child->collapsedMarginBefore(); | 2977 return child->collapsedMarginBefore(); |
| 3002 | 2978 return child->collapsedMarginAfter(); |
| 3003 // The child has a different directionality. If the child is parallel, then
it's just | |
| 3004 // flipped relative to us. We can use the collapsed margin for the opposite
edge. | |
| 3005 if (child->isHorizontalWritingMode() == isHorizontalWritingMode()) | |
| 3006 return child->collapsedMarginAfter(); | |
| 3007 | |
| 3008 // The child is perpendicular to us, which means its margins don't collapse
but are on the | |
| 3009 // "logical left/right" sides of the child box. We can just return the raw
margin in this case. | |
| 3010 return marginBeforeForChild(child); | |
| 3011 } | 2979 } |
| 3012 | 2980 |
| 3013 LayoutUnit RenderBlock::collapsedMarginAfterForChild(const RenderBox* child) co
nst | 2981 LayoutUnit RenderBlock::collapsedMarginAfterForChild(const RenderBox* child) co
nst |
| 3014 { | 2982 { |
| 3015 // If the child has the same directionality as we do, then we can just retur
n its | 2983 // If the child has the same directionality as we do, then we can just retur
n its |
| 3016 // collapsed margin. | 2984 // collapsed margin. |
| 3017 if (!child->isWritingModeRoot()) | 2985 if (!child->isWritingModeRoot()) |
| 3018 return child->collapsedMarginAfter(); | 2986 return child->collapsedMarginAfter(); |
| 3019 | 2987 return child->collapsedMarginBefore(); |
| 3020 // The child has a different directionality. If the child is parallel, then
it's just | |
| 3021 // flipped relative to us. We can use the collapsed margin for the opposite
edge. | |
| 3022 if (child->isHorizontalWritingMode() == isHorizontalWritingMode()) | |
| 3023 return child->collapsedMarginBefore(); | |
| 3024 | |
| 3025 // The child is perpendicular to us, which means its margins don't collapse
but are on the | |
| 3026 // "logical left/right" side of the child box. We can just return the raw m
argin in this case. | |
| 3027 return marginAfterForChild(child); | |
| 3028 } | 2988 } |
| 3029 | 2989 |
| 3030 bool RenderBlock::hasMarginBeforeQuirk(const RenderBox* child) const | 2990 bool RenderBlock::hasMarginBeforeQuirk(const RenderBox* child) const |
| 3031 { | 2991 { |
| 3032 // If the child has the same directionality as we do, then we can just retur
n its | 2992 // If the child has the same directionality as we do, then we can just retur
n its |
| 3033 // margin quirk. | 2993 // margin quirk. |
| 3034 if (!child->isWritingModeRoot()) | 2994 if (!child->isWritingModeRoot()) |
| 3035 return child->isRenderBlock() ? toRenderBlock(child)->hasMarginBeforeQui
rk() : child->style()->hasMarginBeforeQuirk(); | 2995 return child->isRenderBlock() ? toRenderBlock(child)->hasMarginBeforeQui
rk() : child->style()->hasMarginBeforeQuirk(); |
| 3036 | 2996 |
| 3037 // The child has a different directionality. If the child is parallel, then
it's just | 2997 return child->isRenderBlock() ? toRenderBlock(child)->hasMarginAfterQuirk()
: child->style()->hasMarginAfterQuirk(); |
| 3038 // flipped relative to us. We can use the opposite edge. | |
| 3039 if (child->isHorizontalWritingMode() == isHorizontalWritingMode()) | |
| 3040 return child->isRenderBlock() ? toRenderBlock(child)->hasMarginAfterQuir
k() : child->style()->hasMarginAfterQuirk(); | |
| 3041 | |
| 3042 // The child is perpendicular to us and box sides are never quirky in html.c
ss, and we don't really care about | |
| 3043 // whether or not authors specified quirky ems, since they're an implementat
ion detail. | |
| 3044 return false; | |
| 3045 } | 2998 } |
| 3046 | 2999 |
| 3047 bool RenderBlock::hasMarginAfterQuirk(const RenderBox* child) const | 3000 bool RenderBlock::hasMarginAfterQuirk(const RenderBox* child) const |
| 3048 { | 3001 { |
| 3049 // If the child has the same directionality as we do, then we can just retur
n its | 3002 // If the child has the same directionality as we do, then we can just retur
n its |
| 3050 // margin quirk. | 3003 // margin quirk. |
| 3051 if (!child->isWritingModeRoot()) | 3004 if (!child->isWritingModeRoot()) |
| 3052 return child->isRenderBlock() ? toRenderBlock(child)->hasMarginAfterQuir
k() : child->style()->hasMarginAfterQuirk(); | 3005 return child->isRenderBlock() ? toRenderBlock(child)->hasMarginAfterQuir
k() : child->style()->hasMarginAfterQuirk(); |
| 3053 | 3006 |
| 3054 // The child has a different directionality. If the child is parallel, then
it's just | 3007 return child->isRenderBlock() ? toRenderBlock(child)->hasMarginBeforeQuirk()
: child->style()->hasMarginBeforeQuirk(); |
| 3055 // flipped relative to us. We can use the opposite edge. | |
| 3056 if (child->isHorizontalWritingMode() == isHorizontalWritingMode()) | |
| 3057 return child->isRenderBlock() ? toRenderBlock(child)->hasMarginBeforeQui
rk() : child->style()->hasMarginBeforeQuirk(); | |
| 3058 | |
| 3059 // The child is perpendicular to us and box sides are never quirky in html.c
ss, and we don't really care about | |
| 3060 // whether or not authors specified quirky ems, since they're an implementat
ion detail. | |
| 3061 return false; | |
| 3062 } | 3008 } |
| 3063 | 3009 |
| 3064 const char* RenderBlock::renderName() const | 3010 const char* RenderBlock::renderName() const |
| 3065 { | 3011 { |
| 3066 if (isFloating()) | 3012 if (isFloating()) |
| 3067 return "RenderBlock (floating)"; | 3013 return "RenderBlock (floating)"; |
| 3068 if (isOutOfFlowPositioned()) | 3014 if (isOutOfFlowPositioned()) |
| 3069 return "RenderBlock (positioned)"; | 3015 return "RenderBlock (positioned)"; |
| 3070 if (isAnonymousBlock()) | 3016 if (isAnonymousBlock()) |
| 3071 return "RenderBlock (anonymous)"; | 3017 return "RenderBlock (anonymous)"; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3202 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const | 3148 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const |
| 3203 { | 3149 { |
| 3204 showRenderObject(); | 3150 showRenderObject(); |
| 3205 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 3151 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
| 3206 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 3152 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
| 3207 } | 3153 } |
| 3208 | 3154 |
| 3209 #endif | 3155 #endif |
| 3210 | 3156 |
| 3211 } // namespace blink | 3157 } // namespace blink |
| OLD | NEW |