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

Unified Diff: Source/core/rendering/RootInlineBox.cpp

Issue 351213002: Change RenderObject::style(bool) to accept an enum instead (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Renamed enum to OwnOrFirstLineStyle, rebased and got rid of duplicate state on the stack in RootInl… Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/RootInlineBox.cpp
diff --git a/Source/core/rendering/RootInlineBox.cpp b/Source/core/rendering/RootInlineBox.cpp
index 088f725676fa2654eccb25b4bbe2f1ea3fa4a19e..b8c1b2422ea9a45164133f10a415fd576aece4ea 100644
--- a/Source/core/rendering/RootInlineBox.cpp
+++ b/Source/core/rendering/RootInlineBox.cpp
@@ -727,13 +727,13 @@ LayoutUnit RootInlineBox::verticalPositionForBox(InlineBox* box, VerticalPositio
return 0;
// This method determines the vertical position for inline elements.
- bool firstLine = isFirstLineStyle();
- if (firstLine && !renderer->document().styleEngine()->usesFirstLineRules())
- firstLine = false;
+ OwnOrFirstLineStyle ownOrFirstLineStyle = isFirstLineStyle();
+ if (ownOrFirstLineStyle == FirstLineStyle && !renderer->document().styleEngine()->usesFirstLineRules())
+ ownOrFirstLineStyle = OwnStyle;
// Check the cache.
bool isRenderInline = renderer->isRenderInline();
- if (isRenderInline && !firstLine) {
+ if (isRenderInline && ownOrFirstLineStyle == OwnStyle) {
LayoutUnit verticalPosition = verticalPositionCache.get(renderer, baselineType());
if (verticalPosition != PositionUndefined)
return verticalPosition;
@@ -749,7 +749,7 @@ LayoutUnit RootInlineBox::verticalPositionForBox(InlineBox* box, VerticalPositio
verticalPosition = box->parent()->logicalTop();
if (verticalAlign != BASELINE) {
- const Font& font = parent->style(firstLine)->font();
+ const Font& font = parent->style(ownOrFirstLineStyle)->font();
const FontMetrics& fontMetrics = font.fontMetrics();
int fontSize = font.fontDescription().computedPixelSize();
@@ -760,29 +760,29 @@ LayoutUnit RootInlineBox::verticalPositionForBox(InlineBox* box, VerticalPositio
else if (verticalAlign == SUPER)
verticalPosition -= fontSize / 3 + 1;
else if (verticalAlign == TEXT_TOP)
- verticalPosition += renderer->baselinePosition(baselineType(), firstLine, lineDirection) - fontMetrics.ascent(baselineType());
+ verticalPosition += renderer->baselinePosition(baselineType(), ownOrFirstLineStyle, lineDirection) - fontMetrics.ascent(baselineType());
else if (verticalAlign == MIDDLE)
- verticalPosition = (verticalPosition - static_cast<LayoutUnit>(fontMetrics.xHeight() / 2) - renderer->lineHeight(firstLine, lineDirection) / 2 + renderer->baselinePosition(baselineType(), firstLine, lineDirection)).round();
+ verticalPosition = (verticalPosition - static_cast<LayoutUnit>(fontMetrics.xHeight() / 2) - renderer->lineHeight(ownOrFirstLineStyle, lineDirection) / 2 + renderer->baselinePosition(baselineType(), ownOrFirstLineStyle, lineDirection)).round();
else if (verticalAlign == TEXT_BOTTOM) {
verticalPosition += fontMetrics.descent(baselineType());
// lineHeight - baselinePosition is always 0 for replaced elements (except inline blocks), so don't bother wasting time in that case.
if (!renderer->isReplaced() || renderer->isInlineBlockOrInlineTable())
- verticalPosition -= (renderer->lineHeight(firstLine, lineDirection) - renderer->baselinePosition(baselineType(), firstLine, lineDirection));
+ verticalPosition -= (renderer->lineHeight(ownOrFirstLineStyle, lineDirection) - renderer->baselinePosition(baselineType(), ownOrFirstLineStyle, lineDirection));
} else if (verticalAlign == BASELINE_MIDDLE)
- verticalPosition += -renderer->lineHeight(firstLine, lineDirection) / 2 + renderer->baselinePosition(baselineType(), firstLine, lineDirection);
+ verticalPosition += -renderer->lineHeight(ownOrFirstLineStyle, lineDirection) / 2 + renderer->baselinePosition(baselineType(), ownOrFirstLineStyle, lineDirection);
else if (verticalAlign == LENGTH) {
LayoutUnit lineHeight;
//Per http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align: 'Percentages: refer to the 'line-height' of the element itself'.
if (renderer->style()->verticalAlignLength().isPercent())
lineHeight = renderer->style()->computedLineHeight();
else
- lineHeight = renderer->lineHeight(firstLine, lineDirection);
+ lineHeight = renderer->lineHeight(ownOrFirstLineStyle, lineDirection);
verticalPosition -= valueForLength(renderer->style()->verticalAlignLength(), lineHeight);
}
}
// Store the cached value.
- if (isRenderInline && !firstLine)
+ if (isRenderInline && ownOrFirstLineStyle == OwnStyle)
verticalPositionCache.set(renderer, baselineType(), verticalPosition);
return verticalPosition;
« no previous file with comments | « Source/core/rendering/RenderTextControlSingleLine.cpp ('k') | Source/core/rendering/line/BreakingContextInlineHeaders.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698