| 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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 } | 591 } |
| 592 } | 592 } |
| 593 | 593 |
| 594 if (inlineFlowBox) | 594 if (inlineFlowBox) |
| 595 inlineFlowBox->computeLogicalBoxHeights(rootBox, maxPositionTop, max
PositionBottom, maxAscent, maxDescent, | 595 inlineFlowBox->computeLogicalBoxHeights(rootBox, maxPositionTop, max
PositionBottom, maxAscent, maxDescent, |
| 596 setMaxAscent, setMaxDescent,
strictMode, textBoxDataMap, | 596 setMaxAscent, setMaxDescent,
strictMode, textBoxDataMap, |
| 597 baselineType, verticalPositi
onCache); | 597 baselineType, verticalPositi
onCache); |
| 598 } | 598 } |
| 599 } | 599 } |
| 600 | 600 |
| 601 void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
ght, int maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom
, bool& setLineTop, | 601 void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
ght, int maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom
, LayoutUnit& selectionBottom, bool& setLineTop, |
| 602 LayoutUnit& lineTopIncludingMargi
ns, LayoutUnit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& ha
sAnnotationsAfter, FontBaseline baselineType) | 602 LayoutUnit& lineTopIncludingMargi
ns, LayoutUnit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& ha
sAnnotationsAfter, FontBaseline baselineType) |
| 603 { | 603 { |
| 604 bool isRootBox = isRootInlineBox(); | 604 bool isRootBox = isRootInlineBox(); |
| 605 if (isRootBox) { | 605 if (isRootBox) { |
| 606 const FontMetrics& fontMetrics = renderer().style(isFirstLineStyle())->f
ontMetrics(); | 606 const FontMetrics& fontMetrics = renderer().style(isFirstLineStyle())->f
ontMetrics(); |
| 607 // RootInlineBoxes are always placed on at pixel boundaries in their log
ical y direction. Not doing | 607 // RootInlineBoxes are always placed on at pixel boundaries in their log
ical y direction. Not doing |
| 608 // so results in incorrect rendering of text decorations, most notably u
nderlines. | 608 // so results in incorrect rendering of text decorations, most notably u
nderlines. |
| 609 setLogicalTop(roundToInt(top + maxAscent - fontMetrics.ascent(baselineTy
pe))); | 609 setLogicalTop(roundToInt(top + maxAscent - fontMetrics.ascent(baselineTy
pe))); |
| 610 } | 610 } |
| 611 | 611 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 636 && !(inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() &
& inlineFlowBox->hasTextDescendants())) | 636 && !(inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() &
& inlineFlowBox->hasTextDescendants())) |
| 637 childAffectsTopBottomPos = false; | 637 childAffectsTopBottomPos = false; |
| 638 LayoutUnit posAdjust = maxAscent - curr->baselinePosition(baselineTy
pe); | 638 LayoutUnit posAdjust = maxAscent - curr->baselinePosition(baselineTy
pe); |
| 639 curr->setLogicalTop(curr->logicalTop() + top + posAdjust); | 639 curr->setLogicalTop(curr->logicalTop() + top + posAdjust); |
| 640 } | 640 } |
| 641 | 641 |
| 642 LayoutUnit newLogicalTop = curr->logicalTop(); | 642 LayoutUnit newLogicalTop = curr->logicalTop(); |
| 643 LayoutUnit newLogicalTopIncludingMargins = newLogicalTop; | 643 LayoutUnit newLogicalTopIncludingMargins = newLogicalTop; |
| 644 LayoutUnit boxHeight = curr->logicalHeight(); | 644 LayoutUnit boxHeight = curr->logicalHeight(); |
| 645 LayoutUnit boxHeightIncludingMargins = boxHeight; | 645 LayoutUnit boxHeightIncludingMargins = boxHeight; |
| 646 | 646 LayoutUnit borderPaddingHeight = 0; |
| 647 if (curr->isText() || curr->isInlineFlowBox()) { | 647 if (curr->isText() || curr->isInlineFlowBox()) { |
| 648 const FontMetrics& fontMetrics = curr->renderer().style(isFirstLineS
tyle())->fontMetrics(); | 648 const FontMetrics& fontMetrics = curr->renderer().style(isFirstLineS
tyle())->fontMetrics(); |
| 649 newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.
ascent(baselineType); | 649 newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.
ascent(baselineType); |
| 650 if (curr->isInlineFlowBox()) { | 650 if (curr->isInlineFlowBox()) { |
| 651 RenderBoxModelObject& boxObject = toRenderBoxModelObject(curr->r
enderer()); | 651 RenderBoxModelObject& boxObject = toRenderBoxModelObject(curr->r
enderer()); |
| 652 newLogicalTop -= boxObject.style(isFirstLineStyle())->isHorizont
alWritingMode() ? boxObject.borderTop() + boxObject.paddingTop() : | 652 newLogicalTop -= boxObject.style(isFirstLineStyle())->isHorizont
alWritingMode() ? boxObject.borderTop() + boxObject.paddingTop() : |
| 653 boxObject.borderRight() + boxObject.paddingRight(); | 653 boxObject.borderRight() + boxObject.paddingRight(); |
| 654 borderPaddingHeight = boxObject.borderAndPaddingLogicalHeight(); |
| 654 } | 655 } |
| 655 newLogicalTopIncludingMargins = newLogicalTop; | 656 newLogicalTopIncludingMargins = newLogicalTop; |
| 656 } else if (!curr->renderer().isBR()) { | 657 } else if (!curr->renderer().isBR()) { |
| 657 RenderBox& box = toRenderBox(curr->renderer()); | 658 RenderBox& box = toRenderBox(curr->renderer()); |
| 658 newLogicalTopIncludingMargins = newLogicalTop; | 659 newLogicalTopIncludingMargins = newLogicalTop; |
| 659 LayoutUnit overSideMargin = curr->isHorizontal() ? box.marginTop() :
box.marginRight(); | 660 LayoutUnit overSideMargin = curr->isHorizontal() ? box.marginTop() :
box.marginRight(); |
| 660 LayoutUnit underSideMargin = curr->isHorizontal() ? box.marginBottom
() : box.marginLeft(); | 661 LayoutUnit underSideMargin = curr->isHorizontal() ? box.marginBottom
() : box.marginLeft(); |
| 661 newLogicalTop += overSideMargin; | 662 newLogicalTop += overSideMargin; |
| 662 boxHeightIncludingMargins += overSideMargin + underSideMargin; | 663 boxHeightIncludingMargins += overSideMargin + underSideMargin; |
| 663 } | 664 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 694 } | 695 } |
| 695 | 696 |
| 696 if (!setLineTop) { | 697 if (!setLineTop) { |
| 697 setLineTop = true; | 698 setLineTop = true; |
| 698 lineTop = newLogicalTop; | 699 lineTop = newLogicalTop; |
| 699 lineTopIncludingMargins = min(lineTop, newLogicalTopIncludingMar
gins); | 700 lineTopIncludingMargins = min(lineTop, newLogicalTopIncludingMar
gins); |
| 700 } else { | 701 } else { |
| 701 lineTop = min(lineTop, newLogicalTop); | 702 lineTop = min(lineTop, newLogicalTop); |
| 702 lineTopIncludingMargins = min(lineTop, min(lineTopIncludingMargi
ns, newLogicalTopIncludingMargins)); | 703 lineTopIncludingMargins = min(lineTop, min(lineTopIncludingMargi
ns, newLogicalTopIncludingMargins)); |
| 703 } | 704 } |
| 705 selectionBottom = max(selectionBottom, newLogicalTop + boxHeight - b
orderPaddingHeight); |
| 704 lineBottom = max(lineBottom, newLogicalTop + boxHeight); | 706 lineBottom = max(lineBottom, newLogicalTop + boxHeight); |
| 705 lineBottomIncludingMargins = max(lineBottom, max(lineBottomIncluding
Margins, newLogicalTopIncludingMargins + boxHeightIncludingMargins)); | 707 lineBottomIncludingMargins = max(lineBottom, max(lineBottomIncluding
Margins, newLogicalTopIncludingMargins + boxHeightIncludingMargins)); |
| 706 } | 708 } |
| 707 | 709 |
| 708 // Adjust boxes to use their real box y/height and not the logical heigh
t (as dictated by | 710 // Adjust boxes to use their real box y/height and not the logical heigh
t (as dictated by |
| 709 // line-height). | 711 // line-height). |
| 710 if (inlineFlowBox) | 712 if (inlineFlowBox) |
| 711 inlineFlowBox->placeBoxesInBlockDirection(top, maxHeight, maxAscent,
strictMode, lineTop, lineBottom, setLineTop, | 713 inlineFlowBox->placeBoxesInBlockDirection(top, maxHeight, maxAscent,
strictMode, lineTop, lineBottom, selectionBottom, setLineTop, |
| 712 lineTopIncludingMargins, l
ineBottomIncludingMargins, hasAnnotationsBefore, hasAnnotationsAfter, baselineTy
pe); | 714 lineTopIncludingMargins, l
ineBottomIncludingMargins, hasAnnotationsBefore, hasAnnotationsAfter, baselineTy
pe); |
| 713 } | 715 } |
| 714 | 716 |
| 715 if (isRootBox) { | 717 if (isRootBox) { |
| 716 if (strictMode || hasTextChildren() || (descendantsHaveSameLineHeightAnd
Baseline() && hasTextDescendants())) { | 718 if (strictMode || hasTextChildren() || (descendantsHaveSameLineHeightAnd
Baseline() && hasTextDescendants())) { |
| 717 if (!setLineTop) { | 719 if (!setLineTop) { |
| 718 setLineTop = true; | 720 setLineTop = true; |
| 719 lineTop = pixelSnappedLogicalTop(); | 721 lineTop = pixelSnappedLogicalTop(); |
| 720 lineTopIncludingMargins = lineTop; | 722 lineTopIncludingMargins = lineTop; |
| 721 } else { | 723 } else { |
| 722 lineTop = min<LayoutUnit>(lineTop, pixelSnappedLogicalTop()); | 724 lineTop = min<LayoutUnit>(lineTop, pixelSnappedLogicalTop()); |
| 723 lineTopIncludingMargins = min(lineTop, lineTopIncludingMargins); | 725 lineTopIncludingMargins = min(lineTop, lineTopIncludingMargins); |
| 724 } | 726 } |
| 727 selectionBottom = max<LayoutUnit>(selectionBottom, pixelSnappedLogic
alBottom()); |
| 725 lineBottom = max<LayoutUnit>(lineBottom, pixelSnappedLogicalBottom()
); | 728 lineBottom = max<LayoutUnit>(lineBottom, pixelSnappedLogicalBottom()
); |
| 726 lineBottomIncludingMargins = max(lineBottom, lineBottomIncludingMarg
ins); | 729 lineBottomIncludingMargins = max(lineBottom, lineBottomIncludingMarg
ins); |
| 727 } | 730 } |
| 728 | 731 |
| 729 if (renderer().style()->isFlippedLinesWritingMode()) | 732 if (renderer().style()->isFlippedLinesWritingMode()) |
| 730 flipLinesInBlockDirection(lineTopIncludingMargins, lineBottomIncludi
ngMargins); | 733 flipLinesInBlockDirection(lineTopIncludingMargins, lineBottomIncludi
ngMargins); |
| 731 } | 734 } |
| 732 } | 735 } |
| 733 | 736 |
| 734 void InlineFlowBox::computeMaxLogicalTop(float& maxLogicalTop) const | 737 void InlineFlowBox::computeMaxLogicalTop(float& maxLogicalTop) const |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1656 ASSERT(child->prevOnLine() == prev); | 1659 ASSERT(child->prevOnLine() == prev); |
| 1657 prev = child; | 1660 prev = child; |
| 1658 } | 1661 } |
| 1659 ASSERT(prev == m_lastChild); | 1662 ASSERT(prev == m_lastChild); |
| 1660 #endif | 1663 #endif |
| 1661 } | 1664 } |
| 1662 | 1665 |
| 1663 #endif | 1666 #endif |
| 1664 | 1667 |
| 1665 } // namespace WebCore | 1668 } // namespace WebCore |
| OLD | NEW |