Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp

Issue 1774943003: blink: Rename platform/ methods to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-platform: rebase-yayyyyyyyy Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 117
118 if (descendantsHaveSameLineHeightAndBaseline() && !child->getLineLayoutItem( ).isOutOfFlowPositioned()) { 118 if (descendantsHaveSameLineHeightAndBaseline() && !child->getLineLayoutItem( ).isOutOfFlowPositioned()) {
119 const ComputedStyle& parentStyle = getLineLayoutItem().styleRef(isFirstL ineStyle()); 119 const ComputedStyle& parentStyle = getLineLayoutItem().styleRef(isFirstL ineStyle());
120 const ComputedStyle& childStyle = child->getLineLayoutItem().styleRef(is FirstLineStyle()); 120 const ComputedStyle& childStyle = child->getLineLayoutItem().styleRef(is FirstLineStyle());
121 bool shouldClearDescendantsHaveSameLineHeightAndBaseline = false; 121 bool shouldClearDescendantsHaveSameLineHeightAndBaseline = false;
122 if (child->getLineLayoutItem().isAtomicInlineLevel()) { 122 if (child->getLineLayoutItem().isAtomicInlineLevel()) {
123 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; 123 shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
124 } else if (child->isText()) { 124 } else if (child->isText()) {
125 if (child->getLineLayoutItem().isBR() || (child->getLineLayoutItem() .parent() != getLineLayoutItem())) { 125 if (child->getLineLayoutItem().isBR() || (child->getLineLayoutItem() .parent() != getLineLayoutItem())) {
126 if (!parentStyle.font().fontMetrics().hasIdenticalAscentDescentA ndLineGap(childStyle.font().fontMetrics()) 126 if (!parentStyle.font().getFontMetrics().hasIdenticalAscentDesce ntAndLineGap(childStyle.font().getFontMetrics())
127 || parentStyle.lineHeight() != childStyle.lineHeight() 127 || parentStyle.lineHeight() != childStyle.lineHeight()
128 || (parentStyle.verticalAlign() != VerticalAlignBaseline && !isRootInlineBox()) || childStyle.verticalAlign() != VerticalAlignBaseline) 128 || (parentStyle.verticalAlign() != VerticalAlignBaseline && !isRootInlineBox()) || childStyle.verticalAlign() != VerticalAlignBaseline)
129 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; 129 shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
130 } 130 }
131 if (childStyle.hasTextCombine() || childStyle.getTextEmphasisMark() != TextEmphasisMarkNone) 131 if (childStyle.hasTextCombine() || childStyle.getTextEmphasisMark() != TextEmphasisMarkNone)
132 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; 132 shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
133 } else { 133 } else {
134 if (child->getLineLayoutItem().isBR()) { 134 if (child->getLineLayoutItem().isBR()) {
135 // FIXME: This is dumb. We only turn off because current layout test results expect the <br> to be 0-height on the baseline. 135 // FIXME: This is dumb. We only turn off because current layout test results expect the <br> to be 0-height on the baseline.
136 // Other than making a zillion tests have to regenerate results, there's no reason to ditch the optimization here. 136 // Other than making a zillion tests have to regenerate results, there's no reason to ditch the optimization here.
137 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; 137 shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
138 } else { 138 } else {
139 ASSERT(isInlineFlowBox()); 139 ASSERT(isInlineFlowBox());
140 InlineFlowBox* childFlowBox = toInlineFlowBox(child); 140 InlineFlowBox* childFlowBox = toInlineFlowBox(child);
141 // Check the child's bit, and then also check for differences in font, line-height, vertical-align 141 // Check the child's bit, and then also check for differences in font, line-height, vertical-align
142 if (!childFlowBox->descendantsHaveSameLineHeightAndBaseline() 142 if (!childFlowBox->descendantsHaveSameLineHeightAndBaseline()
143 || !parentStyle.font().fontMetrics().hasIdenticalAscentDesce ntAndLineGap(childStyle.font().fontMetrics()) 143 || !parentStyle.font().getFontMetrics().hasIdenticalAscentDe scentAndLineGap(childStyle.font().getFontMetrics())
144 || parentStyle.lineHeight() != childStyle.lineHeight() 144 || parentStyle.lineHeight() != childStyle.lineHeight()
145 || (parentStyle.verticalAlign() != VerticalAlignBaseline && !isRootInlineBox()) || childStyle.verticalAlign() != VerticalAlignBaseline 145 || (parentStyle.verticalAlign() != VerticalAlignBaseline && !isRootInlineBox()) || childStyle.verticalAlign() != VerticalAlignBaseline
146 || childStyle.hasBorder() || childStyle.hasPadding() || chil dStyle.hasTextCombine()) 146 || childStyle.hasBorder() || childStyle.hasPadding() || chil dStyle.hasTextCombine())
147 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; 147 shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
148 } 148 }
149 } 149 }
150 150
151 if (shouldClearDescendantsHaveSameLineHeightAndBaseline) 151 if (shouldClearDescendantsHaveSameLineHeightAndBaseline)
152 clearDescendantsHaveSameLineHeightAndBaseline(); 152 clearDescendantsHaveSameLineHeightAndBaseline();
153 } 153 }
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
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->getLineLayoutItem().isText()) { 386 if (curr->getLineLayoutItem().isText()) {
387 InlineTextBox* text = toInlineTextBox(curr); 387 InlineTextBox* text = toInlineTextBox(curr);
388 LineLayoutText rt = text->getLineLayoutItem(); 388 LineLayoutText rt = text->getLineLayoutItem();
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 = LayoutUnit(rt.style(isFirstLineStyle())->font().font Description().wordSpacing()); 392 space = LayoutUnit(rt.style(isFirstLineStyle())->font().getF ontDescription().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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 needsWordSpacing = true; 451 needsWordSpacing = true;
452 } 452 }
453 } 453 }
454 } 454 }
455 } 455 }
456 456
457 FontBaseline InlineFlowBox::dominantBaseline() const 457 FontBaseline InlineFlowBox::dominantBaseline() const
458 { 458 {
459 // Use "central" (Ideographic) baseline if writing-mode is vertical-* and te xt-orientation is not sideways-*. 459 // Use "central" (Ideographic) baseline if writing-mode is vertical-* and te xt-orientation is not sideways-*.
460 // http://dev.w3.org/csswg/css-writing-modes-3/#text-baselines 460 // http://dev.w3.org/csswg/css-writing-modes-3/#text-baselines
461 if (!isHorizontal() && getLineLayoutItem().style(isFirstLineStyle())->fontDe scription().isVerticalAnyUpright()) 461 if (!isHorizontal() && getLineLayoutItem().style(isFirstLineStyle())->getFon tDescription().isVerticalAnyUpright())
462 return IdeographicBaseline; 462 return IdeographicBaseline;
463 return AlphabeticBaseline; 463 return AlphabeticBaseline;
464 } 464 }
465 465
466 void InlineFlowBox::adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, i nt maxPositionTop, int maxPositionBottom) 466 void InlineFlowBox::adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, i nt maxPositionTop, int maxPositionBottom)
467 { 467 {
468 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 468 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
469 // The computed lineheight needs to be extended for the 469 // The computed lineheight needs to be extended for the
470 // positioned elements 470 // positioned elements
471 if (curr->getLineLayoutItem().isOutOfFlowPositioned()) 471 if (curr->getLineLayoutItem().isOutOfFlowPositioned())
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 576
577 if (inlineFlowBox) 577 if (inlineFlowBox)
578 inlineFlowBox->computeLogicalBoxHeights(rootBox, maxPositionTop, max PositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, noQuirksMode , textBoxDataMap, baselineType, verticalPositionCache); 578 inlineFlowBox->computeLogicalBoxHeights(rootBox, maxPositionTop, max PositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, noQuirksMode , textBoxDataMap, baselineType, verticalPositionCache);
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 = getLineLayoutItem().style(isFirstLineSt yle())->fontMetrics(); 586 const FontMetrics& fontMetrics = getLineLayoutItem().style(isFirstLineSt yle())->getFontMetrics();
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(LayoutUnit(roundToInt(top + maxAscent - fontMetrics.ascent (baselineType)))); 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();
(...skipping 21 matching lines...) Expand all
618 int posAdjust = maxAscent - curr->baselinePosition(baselineType); 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->getLineLayoutItem().style(isF irstLineStyle())->fontMetrics(); 628 const FontMetrics& fontMetrics = curr->getLineLayoutItem().style(isF irstLineStyle())->getFontMetrics();
629 newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics. ascent(baselineType); 629 newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics. ascent(baselineType);
630 if (curr->isInlineFlowBox()) { 630 if (curr->isInlineFlowBox()) {
631 LineLayoutBoxModel boxObject = LineLayoutBoxModel(curr->getLineL ayoutItem()); 631 LineLayoutBoxModel boxObject = LineLayoutBoxModel(curr->getLineL ayoutItem());
632 newLogicalTop -= boxObject.borderAndPaddingOver(); 632 newLogicalTop -= boxObject.borderAndPaddingOver();
633 borderPaddingHeight = boxObject.borderAndPaddingLogicalHeight(); 633 borderPaddingHeight = boxObject.borderAndPaddingLogicalHeight();
634 } 634 }
635 newLogicalTopIncludingMargins = newLogicalTop; 635 newLogicalTopIncludingMargins = newLogicalTop;
636 } else if (!curr->getLineLayoutItem().isBR()) { 636 } else if (!curr->getLineLayoutItem().isBR()) {
637 LineLayoutBox box = LineLayoutBox(curr->getLineLayoutItem()); 637 LineLayoutBox box = LineLayoutBox(curr->getLineLayoutItem());
638 newLogicalTopIncludingMargins = newLogicalTop; 638 newLogicalTopIncludingMargins = newLogicalTop;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 if (style.getTextEmphasisMark() != TextEmphasisMarkNone && textBox->getEmpha sisMarkPosition(style, emphasisMarkPosition)) { 836 if (style.getTextEmphasisMark() != TextEmphasisMarkNone && textBox->getEmpha sisMarkPosition(style, emphasisMarkPosition)) {
837 float emphasisMarkHeight = style.font().emphasisMarkHeight(style.textEmp hasisMarkString()); 837 float emphasisMarkHeight = style.font().emphasisMarkHeight(style.textEmp hasisMarkString());
838 if ((emphasisMarkPosition == TextEmphasisPositionOver) == (!style.isFlip pedLinesWritingMode())) 838 if ((emphasisMarkPosition == TextEmphasisPositionOver) == (!style.isFlip pedLinesWritingMode()))
839 topGlyphOverflow = std::min(topGlyphOverflow, -emphasisMarkHeight); 839 topGlyphOverflow = std::min(topGlyphOverflow, -emphasisMarkHeight);
840 else 840 else
841 bottomGlyphOverflow = std::max(bottomGlyphOverflow, emphasisMarkHeig ht); 841 bottomGlyphOverflow = std::max(bottomGlyphOverflow, emphasisMarkHeig ht);
842 } 842 }
843 843
844 // If letter-spacing is negative, we should factor that into right layout ov erflow. Even in RTL, letter-spacing is 844 // If letter-spacing is negative, we should factor that into right layout ov erflow. Even in RTL, letter-spacing is
845 // applied to the right, so this is not an issue with left overflow. 845 // applied to the right, so this is not an issue with left overflow.
846 rightGlyphOverflow -= std::min(0.0f, style.font().fontDescription().letterSp acing()); 846 rightGlyphOverflow -= std::min(0.0f, style.font().getFontDescription().lette rSpacing());
847 847
848 LayoutRectOutsets textShadowLogicalOutsets; 848 LayoutRectOutsets textShadowLogicalOutsets;
849 if (ShadowList* textShadow = style.textShadow()) 849 if (ShadowList* textShadow = style.textShadow())
850 textShadowLogicalOutsets = LayoutRectOutsets(textShadow->rectOutsetsIncl udingOriginal()).logicalOutsets(style.getWritingMode()); 850 textShadowLogicalOutsets = LayoutRectOutsets(textShadow->rectOutsetsIncl udingOriginal()).logicalOutsets(style.getWritingMode());
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();
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 ASSERT(child->prevOnLine() == prev); 1314 ASSERT(child->prevOnLine() == prev);
1315 prev = child; 1315 prev = child;
1316 } 1316 }
1317 ASSERT(prev == m_lastChild); 1317 ASSERT(prev == m_lastChild);
1318 #endif 1318 #endif
1319 } 1319 }
1320 1320
1321 #endif 1321 #endif
1322 1322
1323 } // namespace blink 1323 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/line/InlineBox.cpp ('k') | third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698