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

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

Issue 1653673002: Even more explicit LayoutUnit conversion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@moarConstructors
Patch Set: address comments Created 4 years, 10 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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 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) 581 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 { 582 {
583 bool isRootBox = isRootInlineBox(); 583 bool isRootBox = isRootInlineBox();
584 if (isRootBox) { 584 if (isRootBox) {
585 const FontMetrics& fontMetrics = lineLayoutItem().style(isFirstLineStyle ())->fontMetrics(); 585 const FontMetrics& fontMetrics = lineLayoutItem().style(isFirstLineStyle ())->fontMetrics();
586 // RootInlineBoxes are always placed at pixel boundaries in their logica l y direction. Not doing 586 // RootInlineBoxes are always placed at pixel boundaries in their logica l y direction. Not doing
587 // so results in incorrect layout of text decorations, most notably unde rlines. 587 // so results in incorrect layout of text decorations, most notably unde rlines.
588 setLogicalTop(roundToInt(top + maxAscent - fontMetrics.ascent(baselineTy pe))); 588 setLogicalTop(roundToInt(top + maxAscent - fontMetrics.ascent(baselineTy pe)));
589 } 589 }
590 590
591 LayoutUnit adjustmentForChildrenWithSameLineHeightAndBaseline = 0; 591 LayoutUnit adjustmentForChildrenWithSameLineHeightAndBaseline;
592 if (descendantsHaveSameLineHeightAndBaseline()) { 592 if (descendantsHaveSameLineHeightAndBaseline()) {
593 adjustmentForChildrenWithSameLineHeightAndBaseline = logicalTop(); 593 adjustmentForChildrenWithSameLineHeightAndBaseline = logicalTop();
594 if (parent()) 594 if (parent())
595 adjustmentForChildrenWithSameLineHeightAndBaseline += boxModelObject ().borderAndPaddingOver(); 595 adjustmentForChildrenWithSameLineHeightAndBaseline += boxModelObject ().borderAndPaddingOver();
596 } 596 }
597 597
598 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 598 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
599 if (curr->lineLayoutItem().isOutOfFlowPositioned()) 599 if (curr->lineLayoutItem().isOutOfFlowPositioned())
600 continue; // Positioned placeholders don't affect calculations. 600 continue; // Positioned placeholders don't affect calculations.
601 601
(...skipping 13 matching lines...) Expand all
615 && !(inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() & & inlineFlowBox->hasTextDescendants())) 615 && !(inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() & & inlineFlowBox->hasTextDescendants()))
616 childAffectsTopBottomPos = false; 616 childAffectsTopBottomPos = false;
617 LayoutUnit posAdjust = maxAscent - curr->baselinePosition(baselineTy pe); 617 LayoutUnit posAdjust = maxAscent - curr->baselinePosition(baselineTy pe);
618 curr->setLogicalTop(curr->logicalTop() + top + posAdjust); 618 curr->setLogicalTop(curr->logicalTop() + top + posAdjust);
619 } 619 }
620 620
621 LayoutUnit newLogicalTop = curr->logicalTop(); 621 LayoutUnit newLogicalTop = curr->logicalTop();
622 LayoutUnit newLogicalTopIncludingMargins = newLogicalTop; 622 LayoutUnit newLogicalTopIncludingMargins = newLogicalTop;
623 LayoutUnit boxHeight = curr->logicalHeight(); 623 LayoutUnit boxHeight = curr->logicalHeight();
624 LayoutUnit boxHeightIncludingMargins = boxHeight; 624 LayoutUnit boxHeightIncludingMargins = boxHeight;
625 LayoutUnit borderPaddingHeight = 0; 625 LayoutUnit borderPaddingHeight;
626 if (curr->isText() || curr->isInlineFlowBox()) { 626 if (curr->isText() || curr->isInlineFlowBox()) {
627 const FontMetrics& fontMetrics = curr->lineLayoutItem().style(isFirs tLineStyle())->fontMetrics(); 627 const FontMetrics& fontMetrics = curr->lineLayoutItem().style(isFirs tLineStyle())->fontMetrics();
628 newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics. ascent(baselineType); 628 newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics. ascent(baselineType);
629 if (curr->isInlineFlowBox()) { 629 if (curr->isInlineFlowBox()) {
630 LineLayoutBoxModel boxObject = LineLayoutBoxModel(curr->lineLayo utItem()); 630 LineLayoutBoxModel boxObject = LineLayoutBoxModel(curr->lineLayo utItem());
631 newLogicalTop -= boxObject.borderAndPaddingOver(); 631 newLogicalTop -= boxObject.borderAndPaddingOver();
632 borderPaddingHeight = boxObject.borderAndPaddingLogicalHeight(); 632 borderPaddingHeight = boxObject.borderAndPaddingLogicalHeight();
633 } 633 }
634 newLogicalTopIncludingMargins = newLogicalTop; 634 newLogicalTopIncludingMargins = newLogicalTop;
635 } else if (!curr->lineLayoutItem().isBR()) { 635 } else if (!curr->lineLayoutItem().isBR()) {
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 } 1131 }
1132 1132
1133 void InlineFlowBox::clearTruncation() 1133 void InlineFlowBox::clearTruncation()
1134 { 1134 {
1135 for (InlineBox* box = firstChild(); box; box = box->nextOnLine()) 1135 for (InlineBox* box = firstChild(); box; box = box->nextOnLine())
1136 box->clearTruncation(); 1136 box->clearTruncation();
1137 } 1137 }
1138 1138
1139 LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi tion) const 1139 LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi tion) const
1140 { 1140 {
1141 LayoutUnit result = 0; 1141 LayoutUnit result;
1142 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 1142 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
1143 if (curr->lineLayoutItem().isOutOfFlowPositioned()) 1143 if (curr->lineLayoutItem().isOutOfFlowPositioned())
1144 continue; // Positioned placeholders don't affect calculations. 1144 continue; // Positioned placeholders don't affect calculations.
1145 1145
1146 if (curr->isInlineFlowBox()) 1146 if (curr->isInlineFlowBox())
1147 result = std::max(result, toInlineFlowBox(curr)->computeOverAnnotati onAdjustment(allowedPosition)); 1147 result = std::max(result, toInlineFlowBox(curr)->computeOverAnnotati onAdjustment(allowedPosition));
1148 1148
1149 if (curr->lineLayoutItem().isAtomicInlineLevel() && curr->lineLayoutItem ().isRubyRun() && curr->lineLayoutItem().style()->rubyPosition() == RubyPosition Before) { 1149 if (curr->lineLayoutItem().isAtomicInlineLevel() && curr->lineLayoutItem ().isRubyRun() && curr->lineLayoutItem().style()->rubyPosition() == RubyPosition Before) {
1150 LineLayoutRubyRun rubyRun = LineLayoutRubyRun(curr->lineLayoutItem() ); 1150 LineLayoutRubyRun rubyRun = LineLayoutRubyRun(curr->lineLayoutItem() );
1151 LayoutRubyText* rubyText = rubyRun.rubyText(); 1151 LayoutRubyText* rubyText = rubyRun.rubyText();
(...skipping 27 matching lines...) Expand all
1179 result = std::max(result, bottomOfEmphasisMark - allowedPosi tion); 1179 result = std::max(result, bottomOfEmphasisMark - allowedPosi tion);
1180 } 1180 }
1181 } 1181 }
1182 } 1182 }
1183 } 1183 }
1184 return result; 1184 return result;
1185 } 1185 }
1186 1186
1187 LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPos ition) const 1187 LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPos ition) const
1188 { 1188 {
1189 LayoutUnit result = 0; 1189 LayoutUnit result;
1190 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 1190 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
1191 if (curr->lineLayoutItem().isOutOfFlowPositioned()) 1191 if (curr->lineLayoutItem().isOutOfFlowPositioned())
1192 continue; // Positioned placeholders don't affect calculations. 1192 continue; // Positioned placeholders don't affect calculations.
1193 1193
1194 if (curr->isInlineFlowBox()) 1194 if (curr->isInlineFlowBox())
1195 result = std::max(result, toInlineFlowBox(curr)->computeUnderAnnotat ionAdjustment(allowedPosition)); 1195 result = std::max(result, toInlineFlowBox(curr)->computeUnderAnnotat ionAdjustment(allowedPosition));
1196 1196
1197 if (curr->lineLayoutItem().isAtomicInlineLevel() && curr->lineLayoutItem ().isRubyRun() && curr->lineLayoutItem().style()->rubyPosition() == RubyPosition After) { 1197 if (curr->lineLayoutItem().isAtomicInlineLevel() && curr->lineLayoutItem ().isRubyRun() && curr->lineLayoutItem().style()->rubyPosition() == RubyPosition After) {
1198 LineLayoutRubyRun rubyRun = LineLayoutRubyRun(curr->lineLayoutItem() ); 1198 LineLayoutRubyRun rubyRun = LineLayoutRubyRun(curr->lineLayoutItem() );
1199 LayoutRubyText* rubyText = rubyRun.rubyText(); 1199 LayoutRubyText* rubyText = rubyRun.rubyText();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 ASSERT(child->prevOnLine() == prev); 1312 ASSERT(child->prevOnLine() == prev);
1313 prev = child; 1313 prev = child;
1314 } 1314 }
1315 ASSERT(prev == m_lastChild); 1315 ASSERT(prev == m_lastChild);
1316 #endif 1316 #endif
1317 } 1317 }
1318 1318
1319 #endif 1319 #endif
1320 1320
1321 } // namespace blink 1321 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698