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

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

Issue 1766723004: style: Remame values in EOverflow and EVerticalAlign to CamelCase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enum-clash-EOverflowEVerticalAlign: rebase 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
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().fontMetrics().hasIdenticalAscentDescentA ndLineGap(childStyle.font().fontMetrics())
127 || parentStyle.lineHeight() != childStyle.lineHeight() 127 || parentStyle.lineHeight() != childStyle.lineHeight()
128 || (parentStyle.verticalAlign() != BASELINE && !isRootInline Box()) || childStyle.verticalAlign() != BASELINE) 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().fontMetrics().hasIdenticalAscentDesce ntAndLineGap(childStyle.font().fontMetrics())
144 || parentStyle.lineHeight() != childStyle.lineHeight() 144 || parentStyle.lineHeight() != childStyle.lineHeight()
145 || (parentStyle.verticalAlign() != BASELINE && !isRootInline Box()) || childStyle.verticalAlign() != BASELINE 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 }
154 154
155 if (!child->getLineLayoutItem().isOutOfFlowPositioned()) { 155 if (!child->getLineLayoutItem().isOutOfFlowPositioned()) {
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
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())
472 continue; // Positioned placeholders don't affect calculations. 472 continue; // Positioned placeholders don't affect calculations.
473 if (curr->verticalAlign() == TOP || curr->verticalAlign() == BOTTOM) { 473 if (curr->verticalAlign() == VerticalAlignTop || curr->verticalAlign() = = VerticalAlignBottom) {
474 int lineHeight = curr->lineHeight(); 474 int lineHeight = curr->lineHeight();
475 if (curr->verticalAlign() == TOP) { 475 if (curr->verticalAlign() == VerticalAlignTop) {
476 if (maxAscent + maxDescent < lineHeight) 476 if (maxAscent + maxDescent < lineHeight)
477 maxDescent = lineHeight - maxAscent; 477 maxDescent = lineHeight - maxAscent;
478 } else { 478 } else {
479 if (maxAscent + maxDescent < lineHeight) 479 if (maxAscent + maxDescent < lineHeight)
480 maxAscent = lineHeight - maxDescent; 480 maxAscent = lineHeight - maxDescent;
481 } 481 }
482 482
483 if (maxAscent + maxDescent >= std::max(maxPositionTop, maxPositionBo ttom)) 483 if (maxAscent + maxDescent >= std::max(maxPositionTop, maxPositionBo ttom))
484 break; 484 break;
485 } 485 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() == VerticalAlignTop) {
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() == VerticalAlignBottom) {
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
561 // means is that ascent and descent (including leading), can end up being negative. The setMaxAscent and 561 // means is that ascent and descent (including leading), can end up being negative. The setMaxAscent and
562 // setMaxDescent booleans are used to ensure that we're willing to i nitially set maxAscent/Descent to negative 562 // setMaxDescent booleans are used to ensure that we're willing to i nitially set maxAscent/Descent to negative
563 // values. 563 // values.
564 ascent -= curr->logicalTop().round(); 564 ascent -= curr->logicalTop().round();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 if (curr->getLineLayoutItem().isOutOfFlowPositioned()) 600 if (curr->getLineLayoutItem().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() == VerticalAlignTop) {
611 curr->setLogicalTop(top); 611 curr->setLogicalTop(top);
612 } else if (curr->verticalAlign() == BOTTOM) { 612 } else if (curr->verticalAlign() == VerticalAlignBottom) {
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 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();
(...skipping 691 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/TextAutosizer.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