OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 box = box->parent(); | 81 box = box->parent(); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 static inline bool hasIdenticalLineHeightProperties( | 85 static inline bool hasIdenticalLineHeightProperties( |
86 const ComputedStyle& parentStyle, | 86 const ComputedStyle& parentStyle, |
87 const ComputedStyle& childStyle, | 87 const ComputedStyle& childStyle, |
88 bool isRoot) { | 88 bool isRoot) { |
89 return parentStyle.hasIdenticalAscentDescentAndLineGap(childStyle) && | 89 return parentStyle.hasIdenticalAscentDescentAndLineGap(childStyle) && |
90 parentStyle.lineHeight() == childStyle.lineHeight() && | 90 parentStyle.lineHeight() == childStyle.lineHeight() && |
91 (parentStyle.verticalAlign() == VerticalAlignBaseline || isRoot) && | 91 (parentStyle.verticalAlign() == EVerticalAlign::Baseline || isRoot) && |
92 childStyle.verticalAlign() == VerticalAlignBaseline; | 92 childStyle.verticalAlign() == EVerticalAlign::Baseline; |
93 } | 93 } |
94 | 94 |
95 void InlineFlowBox::addToLine(InlineBox* child) { | 95 void InlineFlowBox::addToLine(InlineBox* child) { |
96 ASSERT(!child->parent()); | 96 ASSERT(!child->parent()); |
97 ASSERT(!child->nextOnLine()); | 97 ASSERT(!child->nextOnLine()); |
98 ASSERT(!child->prevOnLine()); | 98 ASSERT(!child->prevOnLine()); |
99 checkConsistency(); | 99 checkConsistency(); |
100 | 100 |
101 child->setParent(this); | 101 child->setParent(this); |
102 if (!m_firstChild) { | 102 if (!m_firstChild) { |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 int& maxDescent, | 524 int& maxDescent, |
525 int maxPositionTop, | 525 int maxPositionTop, |
526 int maxPositionBottom) { | 526 int maxPositionBottom) { |
527 int originalMaxAscent = maxAscent; | 527 int originalMaxAscent = maxAscent; |
528 int originalMaxDescent = maxDescent; | 528 int originalMaxDescent = maxDescent; |
529 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { | 529 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { |
530 // The computed lineheight needs to be extended for the | 530 // The computed lineheight needs to be extended for the |
531 // positioned elements | 531 // positioned elements |
532 if (curr->getLineLayoutItem().isOutOfFlowPositioned()) | 532 if (curr->getLineLayoutItem().isOutOfFlowPositioned()) |
533 continue; // Positioned placeholders don't affect calculations. | 533 continue; // Positioned placeholders don't affect calculations. |
534 if (curr->verticalAlign() == VerticalAlignTop || | 534 if (curr->verticalAlign() == EVerticalAlign::Top || |
535 curr->verticalAlign() == VerticalAlignBottom) { | 535 curr->verticalAlign() == EVerticalAlign::Bottom) { |
536 int lineHeight = curr->lineHeight().round(); | 536 int lineHeight = curr->lineHeight().round(); |
537 if (curr->verticalAlign() == VerticalAlignTop) { | 537 if (curr->verticalAlign() == EVerticalAlign::Top) { |
538 if (maxAscent + maxDescent < lineHeight) | 538 if (maxAscent + maxDescent < lineHeight) |
539 maxDescent = lineHeight - maxAscent; | 539 maxDescent = lineHeight - maxAscent; |
540 } else { | 540 } else { |
541 if (maxAscent + maxDescent < lineHeight) | 541 if (maxAscent + maxDescent < lineHeight) |
542 maxAscent = lineHeight - maxDescent; | 542 maxAscent = lineHeight - maxDescent; |
543 } | 543 } |
544 | 544 |
545 if (maxAscent + maxDescent >= std::max(maxPositionTop, maxPositionBottom)) | 545 if (maxAscent + maxDescent >= std::max(maxPositionTop, maxPositionBottom)) |
546 break; | 546 break; |
547 maxAscent = originalMaxAscent; | 547 maxAscent = originalMaxAscent; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 // positive if the child box's baseline is below the root box's baseline. | 630 // positive if the child box's baseline is below the root box's baseline. |
631 curr->setLogicalTop( | 631 curr->setLogicalTop( |
632 rootBox->verticalPositionForBox(curr, verticalPositionCache)); | 632 rootBox->verticalPositionForBox(curr, verticalPositionCache)); |
633 | 633 |
634 int ascent = 0; | 634 int ascent = 0; |
635 int descent = 0; | 635 int descent = 0; |
636 rootBox->ascentAndDescentForBox(curr, textBoxDataMap, ascent, descent, | 636 rootBox->ascentAndDescentForBox(curr, textBoxDataMap, ascent, descent, |
637 affectsAscent, affectsDescent); | 637 affectsAscent, affectsDescent); |
638 | 638 |
639 LayoutUnit boxHeight(ascent + descent); | 639 LayoutUnit boxHeight(ascent + descent); |
640 if (curr->verticalAlign() == VerticalAlignTop) { | 640 if (curr->verticalAlign() == EVerticalAlign::Top) { |
641 if (maxPositionTop < boxHeight) | 641 if (maxPositionTop < boxHeight) |
642 maxPositionTop = boxHeight; | 642 maxPositionTop = boxHeight; |
643 } else if (curr->verticalAlign() == VerticalAlignBottom) { | 643 } else if (curr->verticalAlign() == EVerticalAlign::Bottom) { |
644 if (maxPositionBottom < boxHeight) | 644 if (maxPositionBottom < boxHeight) |
645 maxPositionBottom = boxHeight; | 645 maxPositionBottom = boxHeight; |
646 } else if (!inlineFlowBox || noQuirksMode || | 646 } else if (!inlineFlowBox || noQuirksMode || |
647 inlineFlowBox->hasTextChildren() || | 647 inlineFlowBox->hasTextChildren() || |
648 (inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() && | 648 (inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() && |
649 inlineFlowBox->hasTextDescendants()) || | 649 inlineFlowBox->hasTextDescendants()) || |
650 inlineFlowBox->boxModelObject() | 650 inlineFlowBox->boxModelObject() |
651 .hasInlineDirectionBordersOrPadding()) { | 651 .hasInlineDirectionBordersOrPadding()) { |
652 // Note that these values can be negative. Even though we only affect the | 652 // Note that these values can be negative. Even though we only affect the |
653 // maxAscent and maxDescent values if our box (excluding line-height) was | 653 // maxAscent and maxDescent values if our box (excluding line-height) was |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 | 721 |
722 if (descendantsHaveSameLineHeightAndBaseline()) { | 722 if (descendantsHaveSameLineHeightAndBaseline()) { |
723 curr->moveInBlockDirection( | 723 curr->moveInBlockDirection( |
724 adjustmentForChildrenWithSameLineHeightAndBaseline); | 724 adjustmentForChildrenWithSameLineHeightAndBaseline); |
725 continue; | 725 continue; |
726 } | 726 } |
727 | 727 |
728 InlineFlowBox* inlineFlowBox = | 728 InlineFlowBox* inlineFlowBox = |
729 curr->isInlineFlowBox() ? toInlineFlowBox(curr) : nullptr; | 729 curr->isInlineFlowBox() ? toInlineFlowBox(curr) : nullptr; |
730 bool childAffectsTopBottomPos = true; | 730 bool childAffectsTopBottomPos = true; |
731 if (curr->verticalAlign() == VerticalAlignTop) { | 731 if (curr->verticalAlign() == EVerticalAlign::Top) { |
732 curr->setLogicalTop(top); | 732 curr->setLogicalTop(top); |
733 } else if (curr->verticalAlign() == VerticalAlignBottom) { | 733 } else if (curr->verticalAlign() == EVerticalAlign::Bottom) { |
734 curr->setLogicalTop((top + maxHeight - curr->lineHeight())); | 734 curr->setLogicalTop((top + maxHeight - curr->lineHeight())); |
735 } else { | 735 } else { |
736 if (!noQuirksMode && inlineFlowBox && !inlineFlowBox->hasTextChildren() && | 736 if (!noQuirksMode && inlineFlowBox && !inlineFlowBox->hasTextChildren() && |
737 !curr->boxModelObject().hasInlineDirectionBordersOrPadding() && | 737 !curr->boxModelObject().hasInlineDirectionBordersOrPadding() && |
738 !(inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() && | 738 !(inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() && |
739 inlineFlowBox->hasTextDescendants())) | 739 inlineFlowBox->hasTextDescendants())) |
740 childAffectsTopBottomPos = false; | 740 childAffectsTopBottomPos = false; |
741 int posAdjust = maxAscent - curr->baselinePosition(baselineType); | 741 int posAdjust = maxAscent - curr->baselinePosition(baselineType); |
742 curr->setLogicalTop(curr->logicalTop() + top + posAdjust); | 742 curr->setLogicalTop(curr->logicalTop() + top + posAdjust); |
743 } | 743 } |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1648 ASSERT(child->prevOnLine() == prev); | 1648 ASSERT(child->prevOnLine() == prev); |
1649 prev = child; | 1649 prev = child; |
1650 } | 1650 } |
1651 ASSERT(prev == m_lastChild); | 1651 ASSERT(prev == m_lastChild); |
1652 #endif | 1652 #endif |
1653 } | 1653 } |
1654 | 1654 |
1655 #endif | 1655 #endif |
1656 | 1656 |
1657 } // namespace blink | 1657 } // namespace blink |
OLD | NEW |