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

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

Issue 2261663002: Disallow cast/implicit conversion from LayoutUnit to int/unsigned (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 4 years, 3 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, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2008 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 // Next iterate over all the line boxes on the line. If we find a replaced element that intersects 104 // Next iterate over all the line boxes on the line. If we find a replaced element that intersects
105 // then we refuse to accommodate the ellipsis. Otherwise we're ok. 105 // then we refuse to accommodate the ellipsis. Otherwise we're ok.
106 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth); 106 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth);
107 } 107 }
108 108
109 LayoutUnit RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, bool l tr, LayoutUnit blockLeftEdge, LayoutUnit blockRightEdge, LayoutUnit ellipsisWidt h) 109 LayoutUnit RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, bool l tr, LayoutUnit blockLeftEdge, LayoutUnit blockRightEdge, LayoutUnit ellipsisWidt h)
110 { 110 {
111 // Create an ellipsis box. 111 // Create an ellipsis box.
112 EllipsisBox* ellipsisBox = new EllipsisBox(getLineLayoutItem(), ellipsisStr, this, 112 EllipsisBox* ellipsisBox = new EllipsisBox(getLineLayoutItem(), ellipsisStr, this,
113 ellipsisWidth, logicalHeight().toFloat(), x(), y(), !prevRootBox(), isHo rizontal()); 113 ellipsisWidth, logicalHeight().toFloat(), x().toInt(), y().toInt(), !pre vRootBox(), isHorizontal());
114 114
115 if (!gEllipsisBoxMap) 115 if (!gEllipsisBoxMap)
116 gEllipsisBoxMap = new EllipsisBoxMap(); 116 gEllipsisBoxMap = new EllipsisBoxMap();
117 gEllipsisBoxMap->add(this, ellipsisBox); 117 gEllipsisBoxMap->add(this, ellipsisBox);
118 setHasEllipsisBox(true); 118 setHasEllipsisBox(true);
119 119
120 // FIXME: Do we need an RTL version of this? 120 // FIXME: Do we need an RTL version of this?
121 if (ltr && (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdg e) { 121 if (ltr && (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdg e) {
122 ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth()); 122 ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth());
123 return logicalWidth() + ellipsisWidth; 123 return logicalWidth() + ellipsisWidth;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 bool setMaxDescent = false; 224 bool setMaxDescent = false;
225 225
226 // Figure out if we're in no-quirks mode. 226 // Figure out if we're in no-quirks mode.
227 bool noQuirksMode = getLineLayoutItem().document().inNoQuirksMode(); 227 bool noQuirksMode = getLineLayoutItem().document().inNoQuirksMode();
228 228
229 m_baselineType = dominantBaseline(); 229 m_baselineType = dominantBaseline();
230 230
231 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, noQuirksMode, textBoxDataMap, baseline Type(), verticalPositionCache); 231 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, noQuirksMode, textBoxDataMap, baseline Type(), verticalPositionCache);
232 232
233 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom)) 233 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom))
234 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPosi tionBottom); 234 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop.toInt(), maxPositionBottom.toInt());
235 235
236 if (getLineLayoutItem().styleRef().snapHeightUnit()) 236 if (getLineLayoutItem().styleRef().snapHeightUnit())
237 snapHeight(maxAscent, maxDescent, getLineLayoutItem().styleRef()); 237 snapHeight(maxAscent, maxDescent, getLineLayoutItem().styleRef());
238 238
239 LayoutUnit maxHeight = LayoutUnit(maxAscent + maxDescent); 239 LayoutUnit maxHeight = LayoutUnit(maxAscent + maxDescent);
240 LayoutUnit lineTop = heightOfBlock; 240 LayoutUnit lineTop = heightOfBlock;
241 LayoutUnit lineBottom = heightOfBlock; 241 LayoutUnit lineBottom = heightOfBlock;
242 LayoutUnit lineTopIncludingMargins = heightOfBlock; 242 LayoutUnit lineTopIncludingMargins = heightOfBlock;
243 LayoutUnit lineBottomIncludingMargins = heightOfBlock; 243 LayoutUnit lineBottomIncludingMargins = heightOfBlock;
244 LayoutUnit selectionBottom = heightOfBlock; 244 LayoutUnit selectionBottom = heightOfBlock;
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 if (!affectsAscent) 578 if (!affectsAscent)
579 affectsAscent = usedFontAscent - box->logicalTop() > 0; 579 affectsAscent = usedFontAscent - box->logicalTop() > 0;
580 if (!affectsDescent) 580 if (!affectsDescent)
581 affectsDescent = usedFontDescent + box->logicalTop() > 0; 581 affectsDescent = usedFontDescent + box->logicalTop() > 0;
582 } 582 }
583 } 583 }
584 584
585 // If leading is included for the box, then we compute that box. 585 // If leading is included for the box, then we compute that box.
586 if (includeLeading && !setUsedFontWithLeading) { 586 if (includeLeading && !setUsedFontWithLeading) {
587 int ascentWithLeading = box->baselinePosition(baselineType()); 587 int ascentWithLeading = box->baselinePosition(baselineType());
588 int descentWithLeading = box->lineHeight() - ascentWithLeading; 588 int descentWithLeading = (box->lineHeight() - ascentWithLeading).toInt() ;
589 setAscentAndDescent(ascent, descent, ascentWithLeading, descentWithLeadi ng, ascentDescentSet); 589 setAscentAndDescent(ascent, descent, ascentWithLeading, descentWithLeadi ng, ascentDescentSet);
590 590
591 // Examine the font box for inline flows and text boxes to see if any pa rt of it is above the baseline. 591 // Examine the font box for inline flows and text boxes to see if any pa rt of it is above the baseline.
592 // If the top of our font box relative to the root box baseline is above the root box baseline, then 592 // If the top of our font box relative to the root box baseline is above the root box baseline, then
593 // we are contributing to the maxAscent value. Descent is similar. If an y part of our font box is below 593 // we are contributing to the maxAscent value. Descent is similar. If an y part of our font box is below
594 // the root box's baseline, then we contribute to the maxDescent value. 594 // the root box's baseline, then we contribute to the maxDescent value.
595 affectsAscent = ascentWithLeading - box->logicalTop() > 0; 595 affectsAscent = ascentWithLeading - box->logicalTop() > 0;
596 affectsDescent = descentWithLeading + box->logicalTop() > 0; 596 affectsDescent = descentWithLeading + box->logicalTop() > 0;
597 } 597 }
598 } 598 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 if (boxModel.style()->getVerticalAlignLength().hasPercent()) 659 if (boxModel.style()->getVerticalAlignLength().hasPercent())
660 lineHeight = LayoutUnit(boxModel.style()->computedLineHeight()); 660 lineHeight = LayoutUnit(boxModel.style()->computedLineHeight());
661 else 661 else
662 lineHeight = boxModel.lineHeight(firstLine, lineDirection); 662 lineHeight = boxModel.lineHeight(firstLine, lineDirection);
663 verticalPosition -= valueForLength(boxModel.style()->getVerticalAlig nLength(), lineHeight); 663 verticalPosition -= valueForLength(boxModel.style()->getVerticalAlig nLength(), lineHeight);
664 } 664 }
665 } 665 }
666 666
667 // Store the cached value. 667 // Store the cached value.
668 if (isLayoutInline && !firstLine) 668 if (isLayoutInline && !firstLine)
669 verticalPositionCache.set(boxModel, baselineType(), verticalPosition); 669 verticalPositionCache.set(boxModel, baselineType(), verticalPosition.toI nt());
670 670
671 return verticalPosition; 671 return verticalPosition;
672 } 672 }
673 673
674 bool RootInlineBox::includeLeadingForBox(InlineBox* box) const 674 bool RootInlineBox::includeLeadingForBox(InlineBox* box) const
675 { 675 {
676 return !(box->getLineLayoutItem().isAtomicInlineLevel() || (box->getLineLayo utItem().isText() && !box->isText())); 676 return !(box->getLineLayoutItem().isAtomicInlineLevel() || (box->getLineLayo utItem().isText() && !box->isText()));
677 } 677 }
678 678
679 Node* RootInlineBox::getLogicalStartBoxWithNode(InlineBox*& startBox) const 679 Node* RootInlineBox::getLogicalStartBoxWithNode(InlineBox*& startBox) const
(...skipping 23 matching lines...) Expand all
703 endBox = nullptr; 703 endBox = nullptr;
704 return nullptr; 704 return nullptr;
705 } 705 }
706 706
707 const char* RootInlineBox::boxName() const 707 const char* RootInlineBox::boxName() const
708 { 708 {
709 return "RootInlineBox"; 709 return "RootInlineBox";
710 } 710 }
711 711
712 } // namespace blink 712 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698