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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlow.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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 2012 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 return count; 2023 return count;
2024 } 2024 }
2025 2025
2026 int LayoutBlockFlow::firstLineBoxBaseline() const 2026 int LayoutBlockFlow::firstLineBoxBaseline() const
2027 { 2027 {
2028 if (isWritingModeRoot() && !isRubyRun()) 2028 if (isWritingModeRoot() && !isRubyRun())
2029 return -1; 2029 return -1;
2030 if (!childrenInline()) 2030 if (!childrenInline())
2031 return LayoutBlock::firstLineBoxBaseline(); 2031 return LayoutBlock::firstLineBoxBaseline();
2032 if (firstLineBox()) 2032 if (firstLineBox())
2033 return firstLineBox()->logicalTop() + style(true)->getFontMetrics().asce nt(firstRootBox()->baselineType()); 2033 return (firstLineBox()->logicalTop() + style(true)->getFontMetrics().asc ent(firstRootBox()->baselineType())).toInt();
2034 return -1; 2034 return -1;
2035 } 2035 }
2036 2036
2037 int LayoutBlockFlow::inlineBlockBaseline(LineDirectionMode lineDirection) const 2037 int LayoutBlockFlow::inlineBlockBaseline(LineDirectionMode lineDirection) const
2038 { 2038 {
2039 // CSS2.1 states that the baseline of an 'inline-block' is: 2039 // CSS2.1 states that the baseline of an 'inline-block' is:
2040 // the baseline of the last line box in the normal flow, unless it has 2040 // the baseline of the last line box in the normal flow, unless it has
2041 // either no in-flow line boxes or if its 'overflow' property has a computed 2041 // either no in-flow line boxes or if its 'overflow' property has a computed
2042 // value other than 'visible', in which case the baseline is the bottom 2042 // value other than 'visible', in which case the baseline is the bottom
2043 // margin edge. 2043 // margin edge.
2044 // We likewise avoid using the last line box in the case of size containment , 2044 // We likewise avoid using the last line box in the case of size containment ,
2045 // where the block's contents shouldn't be considered when laying out its 2045 // where the block's contents shouldn't be considered when laying out its
2046 // ancestors or siblings. 2046 // ancestors or siblings.
2047 2047
2048 if ((!style()->isOverflowVisible() && !shouldIgnoreOverflowPropertyForInline BlockBaseline()) || style()->containsSize()) { 2048 if ((!style()->isOverflowVisible() && !shouldIgnoreOverflowPropertyForInline BlockBaseline()) || style()->containsSize()) {
2049 // We are not calling baselinePosition here because the caller should ad d the margin-top/margin-right, not us. 2049 // We are not calling baselinePosition here because the caller should ad d the margin-top/margin-right, not us.
2050 return lineDirection == HorizontalLine ? size().height() + marginBottom( ) : size().width() + marginLeft(); 2050 return (lineDirection == HorizontalLine ? size().height() + marginBottom () : size().width() + marginLeft()).toInt();
2051 } 2051 }
2052 if (isWritingModeRoot() && !isRubyRun()) 2052 if (isWritingModeRoot() && !isRubyRun())
2053 return -1; 2053 return -1;
2054 if (!childrenInline()) 2054 if (!childrenInline())
2055 return LayoutBlock::inlineBlockBaseline(lineDirection); 2055 return LayoutBlock::inlineBlockBaseline(lineDirection);
2056 if (lastLineBox()) 2056 if (lastLineBox())
2057 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLineBox ())->getFontMetrics().ascent(lastRootBox()->baselineType()); 2057 return (lastLineBox()->logicalTop() + style(lastLineBox() == firstLineBo x())->getFontMetrics().ascent(lastRootBox()->baselineType())).toInt();
2058 if (!hasLineIfEmpty()) 2058 if (!hasLineIfEmpty())
2059 return -1; 2059 return -1;
2060 const FontMetrics& fontMetrics = firstLineStyle()->getFontMetrics(); 2060 const FontMetrics& fontMetrics = firstLineStyle()->getFontMetrics();
2061 return fontMetrics.ascent() 2061 return (fontMetrics.ascent()
2062 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMe trics.height()) / 2 2062 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMe trics.height()) / 2
2063 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : border Right() + paddingRight()); 2063 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : border Right() + paddingRight())).toInt();
2064 } 2064 }
2065 2065
2066 void LayoutBlockFlow::removeFloatingObjectsFromDescendants() 2066 void LayoutBlockFlow::removeFloatingObjectsFromDescendants()
2067 { 2067 {
2068 if (!containsFloats()) 2068 if (!containsFloats())
2069 return; 2069 return;
2070 removeFloatingObjects(); 2070 removeFloatingObjects();
2071 setChildNeedsLayout(MarkOnlyThis); 2071 setChildNeedsLayout(MarkOnlyThis);
2072 2072
2073 // If our children are inline, then the only boxes which could contain float s are atomic inlines (e.g. inline-block, float etc.) 2073 // If our children are inline, then the only boxes which could contain float s are atomic inlines (e.g. inline-block, float etc.)
(...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after
3793 if (inlineElementContinuation) 3793 if (inlineElementContinuation)
3794 inlineElementContinuation->addOutlineRects(rects, additionalOffset + (in lineElementContinuation->containingBlock()->location() - location()), includeBlo ckOverflows); 3794 inlineElementContinuation->addOutlineRects(rects, additionalOffset + (in lineElementContinuation->containingBlock()->location() - location()), includeBlo ckOverflows);
3795 } 3795 }
3796 3796
3797 PaintInvalidationReason LayoutBlockFlow::invalidatePaintIfNeeded(const PaintInva lidatorContext& context) const 3797 PaintInvalidationReason LayoutBlockFlow::invalidatePaintIfNeeded(const PaintInva lidatorContext& context) const
3798 { 3798 {
3799 return BlockFlowPaintInvalidator(*this, context).invalidatePaintIfNeeded(); 3799 return BlockFlowPaintInvalidator(*this, context).invalidatePaintIfNeeded();
3800 } 3800 }
3801 3801
3802 } // namespace blink 3802 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698