OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 void InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, Inline
Box* lastChild, | 382 void InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, Inline
Box* lastChild, |
383 LayoutUnit& logicalLeft, LayoutUnit& minLogicalLeft, LayoutUnit& maxLogicalR
ight, bool& needsWordSpacing) | 383 LayoutUnit& logicalLeft, LayoutUnit& minLogicalLeft, LayoutUnit& maxLogicalR
ight, bool& needsWordSpacing) |
384 { | 384 { |
385 for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->n
extOnLine()) { | 385 for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->n
extOnLine()) { |
386 if (curr->lineLayoutItem().isText()) { | 386 if (curr->lineLayoutItem().isText()) { |
387 InlineTextBox* text = toInlineTextBox(curr); | 387 InlineTextBox* text = toInlineTextBox(curr); |
388 LineLayoutText rt = text->lineLayoutItem(); | 388 LineLayoutText rt = text->lineLayoutItem(); |
389 LayoutUnit space; | 389 LayoutUnit space; |
390 if (rt.textLength()) { | 390 if (rt.textLength()) { |
391 if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->st
art()))) | 391 if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->st
art()))) |
392 space = rt.style(isFirstLineStyle())->font().fontDescription
().wordSpacing(); | 392 space = LayoutUnit(rt.style(isFirstLineStyle())->font().font
Description().wordSpacing()); |
393 needsWordSpacing = !isSpaceOrNewline(rt.characterAt(text->end())
); | 393 needsWordSpacing = !isSpaceOrNewline(rt.characterAt(text->end())
); |
394 } | 394 } |
395 if (isLeftToRightDirection()) { | 395 if (isLeftToRightDirection()) { |
396 logicalLeft += space; | 396 logicalLeft += space; |
397 text->setLogicalLeft(logicalLeft); | 397 text->setLogicalLeft(logicalLeft); |
398 } else { | 398 } else { |
399 text->setLogicalLeft(logicalLeft); | 399 text->setLogicalLeft(logicalLeft); |
400 logicalLeft += space; | 400 logicalLeft += space; |
401 } | 401 } |
402 if (knownToHaveNoOverflow()) | 402 if (knownToHaveNoOverflow()) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 540 |
541 // The verticalPositionForBox function returns the distance between the
child box's baseline | 541 // The verticalPositionForBox function returns the distance between the
child box's baseline |
542 // and the root box's baseline. The value is negative if the child box'
s baseline is above the | 542 // and the root box's baseline. The value is negative if the child box'
s baseline is above the |
543 // root box's baseline, and it is positive if the child box's baseline i
s below the root box's baseline. | 543 // root box's baseline, and it is positive if the child box's baseline i
s below the root box's baseline. |
544 curr->setLogicalTop(rootBox->verticalPositionForBox(curr, verticalPositi
onCache)); | 544 curr->setLogicalTop(rootBox->verticalPositionForBox(curr, verticalPositi
onCache)); |
545 | 545 |
546 int ascent = 0; | 546 int ascent = 0; |
547 int descent = 0; | 547 int descent = 0; |
548 rootBox->ascentAndDescentForBox(curr, textBoxDataMap, ascent, descent, a
ffectsAscent, affectsDescent); | 548 rootBox->ascentAndDescentForBox(curr, textBoxDataMap, ascent, descent, a
ffectsAscent, affectsDescent); |
549 | 549 |
550 LayoutUnit boxHeight = ascent + descent; | 550 LayoutUnit boxHeight(ascent + descent); |
551 if (curr->verticalAlign() == TOP) { | 551 if (curr->verticalAlign() == TOP) { |
552 if (maxPositionTop < boxHeight) | 552 if (maxPositionTop < boxHeight) |
553 maxPositionTop = boxHeight; | 553 maxPositionTop = boxHeight; |
554 } else if (curr->verticalAlign() == BOTTOM) { | 554 } else if (curr->verticalAlign() == BOTTOM) { |
555 if (maxPositionBottom < boxHeight) | 555 if (maxPositionBottom < boxHeight) |
556 maxPositionBottom = boxHeight; | 556 maxPositionBottom = boxHeight; |
557 } else if (!inlineFlowBox || noQuirksMode || inlineFlowBox->hasTextChild
ren() || (inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() && inlineFlo
wBox->hasTextDescendants()) || inlineFlowBox->boxModelObject().hasInlineDirectio
nBordersOrPadding()) { | 557 } else if (!inlineFlowBox || noQuirksMode || inlineFlowBox->hasTextChild
ren() || (inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() && inlineFlo
wBox->hasTextDescendants()) || inlineFlowBox->boxModelObject().hasInlineDirectio
nBordersOrPadding()) { |
558 // Note that these values can be negative. Even though we only affe
ct the maxAscent and maxDescent values | 558 // Note that these values can be negative. Even though we only affe
ct the maxAscent and maxDescent values |
559 // if our box (excluding line-height) was above (for ascent) or belo
w (for descent) the root baseline, once you factor in line-height | 559 // if our box (excluding line-height) was above (for ascent) or belo
w (for descent) the root baseline, once you factor in line-height |
560 // the final box can end up being fully above or fully below the roo
t box's baseline! This is ok, but what it | 560 // the final box can end up being fully above or fully below the roo
t box's baseline! This is ok, but what it |
(...skipping 18 matching lines...) Expand all Loading... |
579 } | 579 } |
580 } | 580 } |
581 | 581 |
582 void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
ght, int maxAscent, bool noQuirksMode, LayoutUnit& lineTop, LayoutUnit& lineBott
om, LayoutUnit& selectionBottom, bool& setLineTop, LayoutUnit& lineTopIncludingM
argins, LayoutUnit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool
& hasAnnotationsAfter, FontBaseline baselineType) | 582 void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
ght, int maxAscent, bool noQuirksMode, LayoutUnit& lineTop, LayoutUnit& lineBott
om, LayoutUnit& selectionBottom, bool& setLineTop, LayoutUnit& lineTopIncludingM
argins, LayoutUnit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool
& hasAnnotationsAfter, FontBaseline baselineType) |
583 { | 583 { |
584 bool isRootBox = isRootInlineBox(); | 584 bool isRootBox = isRootInlineBox(); |
585 if (isRootBox) { | 585 if (isRootBox) { |
586 const FontMetrics& fontMetrics = lineLayoutItem().style(isFirstLineStyle
())->fontMetrics(); | 586 const FontMetrics& fontMetrics = lineLayoutItem().style(isFirstLineStyle
())->fontMetrics(); |
587 // RootInlineBoxes are always placed at pixel boundaries in their logica
l y direction. Not doing | 587 // RootInlineBoxes are always placed at pixel boundaries in their logica
l y direction. Not doing |
588 // so results in incorrect layout of text decorations, most notably unde
rlines. | 588 // so results in incorrect layout of text decorations, most notably unde
rlines. |
589 setLogicalTop(roundToInt(top + maxAscent - fontMetrics.ascent(baselineTy
pe))); | 589 setLogicalTop(LayoutUnit(roundToInt(top + maxAscent - fontMetrics.ascent
(baselineType)))); |
590 } | 590 } |
591 | 591 |
592 LayoutUnit adjustmentForChildrenWithSameLineHeightAndBaseline; | 592 LayoutUnit adjustmentForChildrenWithSameLineHeightAndBaseline; |
593 if (descendantsHaveSameLineHeightAndBaseline()) { | 593 if (descendantsHaveSameLineHeightAndBaseline()) { |
594 adjustmentForChildrenWithSameLineHeightAndBaseline = logicalTop(); | 594 adjustmentForChildrenWithSameLineHeightAndBaseline = logicalTop(); |
595 if (parent()) | 595 if (parent()) |
596 adjustmentForChildrenWithSameLineHeightAndBaseline += boxModelObject
().borderAndPaddingOver(); | 596 adjustmentForChildrenWithSameLineHeightAndBaseline += boxModelObject
().borderAndPaddingOver(); |
597 } | 597 } |
598 | 598 |
599 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { | 599 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { |
600 if (curr->lineLayoutItem().isOutOfFlowPositioned()) | 600 if (curr->lineLayoutItem().isOutOfFlowPositioned()) |
601 continue; // Positioned placeholders don't affect calculations. | 601 continue; // Positioned placeholders don't affect calculations. |
602 | 602 |
603 if (descendantsHaveSameLineHeightAndBaseline()) { | 603 if (descendantsHaveSameLineHeightAndBaseline()) { |
604 curr->moveInBlockDirection(adjustmentForChildrenWithSameLineHeightAn
dBaseline); | 604 curr->moveInBlockDirection(adjustmentForChildrenWithSameLineHeightAn
dBaseline); |
605 continue; | 605 continue; |
606 } | 606 } |
607 | 607 |
608 InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox
(curr) : nullptr; | 608 InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox
(curr) : nullptr; |
609 bool childAffectsTopBottomPos = true; | 609 bool childAffectsTopBottomPos = true; |
610 if (curr->verticalAlign() == TOP) { | 610 if (curr->verticalAlign() == TOP) { |
611 curr->setLogicalTop(top); | 611 curr->setLogicalTop(top); |
612 } else if (curr->verticalAlign() == BOTTOM) { | 612 } else if (curr->verticalAlign() == BOTTOM) { |
613 curr->setLogicalTop((top + maxHeight - curr->lineHeight())); | 613 curr->setLogicalTop((top + maxHeight - curr->lineHeight())); |
614 } else { | 614 } else { |
615 if (!noQuirksMode && inlineFlowBox && !inlineFlowBox->hasTextChildre
n() && !curr->boxModelObject().hasInlineDirectionBordersOrPadding() | 615 if (!noQuirksMode && inlineFlowBox && !inlineFlowBox->hasTextChildre
n() && !curr->boxModelObject().hasInlineDirectionBordersOrPadding() |
616 && !(inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() &
& inlineFlowBox->hasTextDescendants())) | 616 && !(inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() &
& inlineFlowBox->hasTextDescendants())) |
617 childAffectsTopBottomPos = false; | 617 childAffectsTopBottomPos = false; |
618 LayoutUnit posAdjust = maxAscent - curr->baselinePosition(baselineTy
pe); | 618 int posAdjust = maxAscent - curr->baselinePosition(baselineType); |
619 curr->setLogicalTop(curr->logicalTop() + top + posAdjust); | 619 curr->setLogicalTop(curr->logicalTop() + top + posAdjust); |
620 } | 620 } |
621 | 621 |
622 LayoutUnit newLogicalTop = curr->logicalTop(); | 622 LayoutUnit newLogicalTop = curr->logicalTop(); |
623 LayoutUnit newLogicalTopIncludingMargins = newLogicalTop; | 623 LayoutUnit newLogicalTopIncludingMargins = newLogicalTop; |
624 LayoutUnit boxHeight = curr->logicalHeight(); | 624 LayoutUnit boxHeight = curr->logicalHeight(); |
625 LayoutUnit boxHeightIncludingMargins = boxHeight; | 625 LayoutUnit boxHeightIncludingMargins = boxHeight; |
626 LayoutUnit borderPaddingHeight; | 626 LayoutUnit borderPaddingHeight; |
627 if (curr->isText() || curr->isInlineFlowBox()) { | 627 if (curr->isText() || curr->isInlineFlowBox()) { |
628 const FontMetrics& fontMetrics = curr->lineLayoutItem().style(isFirs
tLineStyle())->fontMetrics(); | 628 const FontMetrics& fontMetrics = curr->lineLayoutItem().style(isFirs
tLineStyle())->fontMetrics(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 // Adjust boxes to use their real box y/height and not the logical heigh
t (as dictated by | 691 // Adjust boxes to use their real box y/height and not the logical heigh
t (as dictated by |
692 // line-height). | 692 // line-height). |
693 if (inlineFlowBox) | 693 if (inlineFlowBox) |
694 inlineFlowBox->placeBoxesInBlockDirection(top, maxHeight, maxAscent,
noQuirksMode, lineTop, lineBottom, selectionBottom, setLineTop, lineTopIncludin
gMargins, lineBottomIncludingMargins, hasAnnotationsBefore, hasAnnotationsAfter,
baselineType); | 694 inlineFlowBox->placeBoxesInBlockDirection(top, maxHeight, maxAscent,
noQuirksMode, lineTop, lineBottom, selectionBottom, setLineTop, lineTopIncludin
gMargins, lineBottomIncludingMargins, hasAnnotationsBefore, hasAnnotationsAfter,
baselineType); |
695 } | 695 } |
696 | 696 |
697 if (isRootBox) { | 697 if (isRootBox) { |
698 if (noQuirksMode || hasTextChildren() || (descendantsHaveSameLineHeightA
ndBaseline() && hasTextDescendants())) { | 698 if (noQuirksMode || hasTextChildren() || (descendantsHaveSameLineHeightA
ndBaseline() && hasTextDescendants())) { |
699 if (!setLineTop) { | 699 if (!setLineTop) { |
700 setLineTop = true; | 700 setLineTop = true; |
701 lineTop = pixelSnappedLogicalTop(); | 701 lineTop = LayoutUnit(pixelSnappedLogicalTop()); |
702 lineTopIncludingMargins = lineTop; | 702 lineTopIncludingMargins = lineTop; |
703 } else { | 703 } else { |
704 lineTop = std::min<LayoutUnit>(lineTop, pixelSnappedLogicalTop()
); | 704 lineTop = std::min(lineTop, LayoutUnit(pixelSnappedLogicalTop())
); |
705 lineTopIncludingMargins = std::min(lineTop, lineTopIncludingMarg
ins); | 705 lineTopIncludingMargins = std::min(lineTop, lineTopIncludingMarg
ins); |
706 } | 706 } |
707 selectionBottom = std::max<LayoutUnit>(selectionBottom, pixelSnapped
LogicalBottom()); | 707 selectionBottom = std::max(selectionBottom, LayoutUnit(pixelSnappedL
ogicalBottom())); |
708 lineBottom = std::max<LayoutUnit>(lineBottom, pixelSnappedLogicalBot
tom()); | 708 lineBottom = std::max(lineBottom, LayoutUnit(pixelSnappedLogicalBott
om())); |
709 lineBottomIncludingMargins = std::max(lineBottom, lineBottomIncludin
gMargins); | 709 lineBottomIncludingMargins = std::max(lineBottom, lineBottomIncludin
gMargins); |
710 } | 710 } |
711 | 711 |
712 if (lineLayoutItem().style()->isFlippedLinesWritingMode()) | 712 if (lineLayoutItem().style()->isFlippedLinesWritingMode()) |
713 flipLinesInBlockDirection(lineTopIncludingMargins, lineBottomIncludi
ngMargins); | 713 flipLinesInBlockDirection(lineTopIncludingMargins, lineBottomIncludi
ngMargins); |
714 } | 714 } |
715 } | 715 } |
716 | 716 |
717 void InlineFlowBox::computeMaxLogicalTop(LayoutUnit& maxLogicalTop) const | 717 void InlineFlowBox::computeMaxLogicalTop(LayoutUnit& maxLogicalTop) const |
718 { | 718 { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 if (ShadowList* textShadow = style.textShadow()) | 849 if (ShadowList* textShadow = style.textShadow()) |
850 textShadowLogicalOutsets = LayoutRectOutsets(textShadow->rectOutsetsIncl
udingOriginal()).logicalOutsets(style.writingMode()); | 850 textShadowLogicalOutsets = LayoutRectOutsets(textShadow->rectOutsetsIncl
udingOriginal()).logicalOutsets(style.writingMode()); |
851 | 851 |
852 // FIXME: This code currently uses negative values for expansion of the top | 852 // FIXME: This code currently uses negative values for expansion of the top |
853 // and left edges. This should be cleaned up. | 853 // and left edges. This should be cleaned up. |
854 LayoutUnit textShadowLogicalTop = -textShadowLogicalOutsets.top(); | 854 LayoutUnit textShadowLogicalTop = -textShadowLogicalOutsets.top(); |
855 LayoutUnit textShadowLogicalBottom = textShadowLogicalOutsets.bottom(); | 855 LayoutUnit textShadowLogicalBottom = textShadowLogicalOutsets.bottom(); |
856 LayoutUnit textShadowLogicalLeft = -textShadowLogicalOutsets.left(); | 856 LayoutUnit textShadowLogicalLeft = -textShadowLogicalOutsets.left(); |
857 LayoutUnit textShadowLogicalRight = textShadowLogicalOutsets.right(); | 857 LayoutUnit textShadowLogicalRight = textShadowLogicalOutsets.right(); |
858 | 858 |
859 LayoutUnit childOverflowLogicalTop = std::min<LayoutUnit>(textShadowLogicalT
op + topGlyphOverflow, topGlyphOverflow); | 859 LayoutUnit childOverflowLogicalTop(std::min(textShadowLogicalTop + topGlyphO
verflow, topGlyphOverflow)); |
860 LayoutUnit childOverflowLogicalBottom = std::max<LayoutUnit>(textShadowLogic
alBottom + bottomGlyphOverflow, bottomGlyphOverflow); | 860 LayoutUnit childOverflowLogicalBottom(std::max(textShadowLogicalBottom + bot
tomGlyphOverflow, bottomGlyphOverflow)); |
861 LayoutUnit childOverflowLogicalLeft = std::min<LayoutUnit>(textShadowLogical
Left + leftGlyphOverflow, leftGlyphOverflow); | 861 LayoutUnit childOverflowLogicalLeft(std::min(textShadowLogicalLeft + leftGly
phOverflow, leftGlyphOverflow)); |
862 LayoutUnit childOverflowLogicalRight = std::max<LayoutUnit>(textShadowLogica
lRight + rightGlyphOverflow, rightGlyphOverflow); | 862 LayoutUnit childOverflowLogicalRight(std::max(textShadowLogicalRight + right
GlyphOverflow, rightGlyphOverflow)); |
863 | 863 |
864 int enclosingLogicalTopWithOverflow = (textBox->logicalTop() + childOverflow
LogicalTop).floor(); | 864 int enclosingLogicalTopWithOverflow = (textBox->logicalTop() + childOverflow
LogicalTop).floor(); |
865 int enclosingLogicalBottomWithOverflow = (textBox->logicalBottom() + childOv
erflowLogicalBottom).ceil(); | 865 int enclosingLogicalBottomWithOverflow = (textBox->logicalBottom() + childOv
erflowLogicalBottom).ceil(); |
866 int enclosingLogicalLeftWithOverflow = (textBox->logicalLeft() + childOverfl
owLogicalLeft).floor(); | 866 int enclosingLogicalLeftWithOverflow = (textBox->logicalLeft() + childOverfl
owLogicalLeft).floor(); |
867 int enclosingLogicalRightWithOverflow = (textBox->logicalRight() + childOver
flowLogicalRight).ceil(); | 867 int enclosingLogicalRightWithOverflow = (textBox->logicalRight() + childOver
flowLogicalRight).ceil(); |
868 | 868 |
869 LayoutUnit logicalTopVisualOverflow = std::min<LayoutUnit>(enclosingLogicalT
opWithOverflow, logicalVisualOverflow.y()); | 869 LayoutUnit logicalTopVisualOverflow = std::min(LayoutUnit(enclosingLogicalTo
pWithOverflow), logicalVisualOverflow.y()); |
870 LayoutUnit logicalBottomVisualOverflow = std::max<LayoutUnit>(enclosingLogic
alBottomWithOverflow, logicalVisualOverflow.maxY()); | 870 LayoutUnit logicalBottomVisualOverflow = std::max(LayoutUnit(enclosingLogica
lBottomWithOverflow), logicalVisualOverflow.maxY()); |
871 LayoutUnit logicalLeftVisualOverflow = std::min<LayoutUnit>(enclosingLogical
LeftWithOverflow, logicalVisualOverflow.x()); | 871 LayoutUnit logicalLeftVisualOverflow = std::min(LayoutUnit(enclosingLogicalL
eftWithOverflow), logicalVisualOverflow.x()); |
872 LayoutUnit logicalRightVisualOverflow = std::max<LayoutUnit>(enclosingLogica
lRightWithOverflow, logicalVisualOverflow.maxX()); | 872 LayoutUnit logicalRightVisualOverflow = std::max(LayoutUnit(enclosingLogical
RightWithOverflow), logicalVisualOverflow.maxX()); |
873 | 873 |
874 logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisu
alOverflow, logicalRightVisualOverflow - logicalLeftVisualOverflow, logicalBotto
mVisualOverflow - logicalTopVisualOverflow); | 874 logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisu
alOverflow, logicalRightVisualOverflow - logicalLeftVisualOverflow, logicalBotto
mVisualOverflow - logicalTopVisualOverflow); |
875 | 875 |
876 textBox->setLogicalOverflowRect(logicalVisualOverflow); | 876 textBox->setLogicalOverflowRect(logicalVisualOverflow); |
877 } | 877 } |
878 | 878 |
879 inline void InlineFlowBox::addReplacedChildOverflow(const InlineBox* inlineBox,
LayoutRect& logicalLayoutOverflow, LayoutRect& logicalVisualOverflow) | 879 inline void InlineFlowBox::addReplacedChildOverflow(const InlineBox* inlineBox,
LayoutRect& logicalLayoutOverflow, LayoutRect& logicalVisualOverflow) |
880 { | 880 { |
881 LineLayoutBox box = LineLayoutBox(inlineBox->lineLayoutItem()); | 881 LineLayoutBox box = LineLayoutBox(inlineBox->lineLayoutItem()); |
882 | 882 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 { | 1097 { |
1098 for (InlineBox* box = firstChild(); box; box = box->nextOnLine()) { | 1098 for (InlineBox* box = firstChild(); box; box = box->nextOnLine()) { |
1099 if (!box->canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth)) | 1099 if (!box->canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth)) |
1100 return false; | 1100 return false; |
1101 } | 1101 } |
1102 return true; | 1102 return true; |
1103 } | 1103 } |
1104 | 1104 |
1105 LayoutUnit InlineFlowBox::placeEllipsisBox(bool ltr, LayoutUnit blockLeftEdge, L
ayoutUnit blockRightEdge, LayoutUnit ellipsisWidth, LayoutUnit &truncatedWidth,
bool& foundBox) | 1105 LayoutUnit InlineFlowBox::placeEllipsisBox(bool ltr, LayoutUnit blockLeftEdge, L
ayoutUnit blockRightEdge, LayoutUnit ellipsisWidth, LayoutUnit &truncatedWidth,
bool& foundBox) |
1106 { | 1106 { |
1107 LayoutUnit result = -1; | 1107 LayoutUnit result(-1); |
1108 // We iterate over all children, the foundBox variable tells us when we've f
ound the | 1108 // We iterate over all children, the foundBox variable tells us when we've f
ound the |
1109 // box containing the ellipsis. All boxes after that one in the flow are hi
dden. | 1109 // box containing the ellipsis. All boxes after that one in the flow are hi
dden. |
1110 // If our flow is ltr then iterate over the boxes from left to right, otherw
ise iterate | 1110 // If our flow is ltr then iterate over the boxes from left to right, otherw
ise iterate |
1111 // from right to left. Varying the order allows us to correctly hide the box
es following the ellipsis. | 1111 // from right to left. Varying the order allows us to correctly hide the box
es following the ellipsis. |
1112 InlineBox* box = ltr ? firstChild() : lastChild(); | 1112 InlineBox* box = ltr ? firstChild() : lastChild(); |
1113 | 1113 |
1114 // NOTE: these will cross after foundBox = true. | 1114 // NOTE: these will cross after foundBox = true. |
1115 int visibleLeftEdge = blockLeftEdge; | 1115 int visibleLeftEdge = blockLeftEdge; |
1116 int visibleRightEdge = blockRightEdge; | 1116 int visibleRightEdge = blockRightEdge; |
1117 | 1117 |
1118 while (box) { | 1118 while (box) { |
1119 int currResult = box->placeEllipsisBox(ltr, visibleLeftEdge, visibleRigh
tEdge, ellipsisWidth, truncatedWidth, foundBox); | 1119 int currResult = box->placeEllipsisBox(ltr, LayoutUnit(visibleLeftEdge),
LayoutUnit(visibleRightEdge), |
| 1120 ellipsisWidth, truncatedWidth, foundBox); |
1120 if (currResult != -1 && result == -1) | 1121 if (currResult != -1 && result == -1) |
1121 result = currResult; | 1122 result = LayoutUnit(currResult); |
1122 | 1123 |
1123 if (ltr) { | 1124 if (ltr) { |
1124 visibleLeftEdge += box->logicalWidth().round(); | 1125 visibleLeftEdge += box->logicalWidth().round(); |
1125 box = box->nextOnLine(); | 1126 box = box->nextOnLine(); |
1126 } else { | 1127 } else { |
1127 visibleRightEdge -= box->logicalWidth().round(); | 1128 visibleRightEdge -= box->logicalWidth().round(); |
1128 box = box->prevOnLine(); | 1129 box = box->prevOnLine(); |
1129 } | 1130 } |
1130 } | 1131 } |
1131 return result; | 1132 return result; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 ASSERT(child->prevOnLine() == prev); | 1314 ASSERT(child->prevOnLine() == prev); |
1314 prev = child; | 1315 prev = child; |
1315 } | 1316 } |
1316 ASSERT(prev == m_lastChild); | 1317 ASSERT(prev == m_lastChild); |
1317 #endif | 1318 #endif |
1318 } | 1319 } |
1319 | 1320 |
1320 #endif | 1321 #endif |
1321 | 1322 |
1322 } // namespace blink | 1323 } // namespace blink |
OLD | NEW |