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

Side by Side Diff: Source/core/rendering/RenderBlock.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 unified diff | Download patch
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | Source/core/rendering/RenderBlockLineLayout.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 3742 matching lines...) Expand 10 before | Expand all | Expand 10 after
3753 3753
3754 if (node()->isRootEditableElement()) 3754 if (node()->isRootEditableElement())
3755 return true; 3755 return true;
3756 3756
3757 if (node()->isShadowRoot() && isHTMLInputElement(*toShadowRoot(node())->host ())) 3757 if (node()->isShadowRoot() && isHTMLInputElement(*toShadowRoot(node())->host ()))
3758 return true; 3758 return true;
3759 3759
3760 return false; 3760 return false;
3761 } 3761 }
3762 3762
3763 LayoutUnit RenderBlock::lineHeight(bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const 3763 LayoutUnit RenderBlock::lineHeight(OwnOrFirstLineStyle firstLine, LineDirectionM ode direction, LinePositionMode linePositionMode) const
3764 { 3764 {
3765 // Inline blocks are replaced elements. Otherwise, just pass off to 3765 // Inline blocks are replaced elements. Otherwise, just pass off to
3766 // the base class. If we're being queried as though we're the root line 3766 // the base class. If we're being queried as though we're the root line
3767 // box, then the fact that we're an inline-block is irrelevant, and we behav e 3767 // box, then the fact that we're an inline-block is irrelevant, and we behav e
3768 // just like a block. 3768 // just like a block.
3769 if (isReplaced() && linePositionMode == PositionOnContainingLine) 3769 if (isReplaced() && linePositionMode == PositionOnContainingLine)
3770 return RenderBox::lineHeight(firstLine, direction, linePositionMode); 3770 return RenderBox::lineHeight(firstLine, direction, linePositionMode);
3771 3771
3772 RenderStyle* s = style(firstLine && document().styleEngine()->usesFirstLineR ules()); 3772 return style(firstLine)->computedLineHeight();
3773 return s->computedLineHeight();
3774 } 3773 }
3775 3774
3776 int RenderBlock::beforeMarginInLineDirection(LineDirectionMode direction) const 3775 int RenderBlock::beforeMarginInLineDirection(LineDirectionMode direction) const
3777 { 3776 {
3778 return direction == HorizontalLine ? marginTop() : marginRight(); 3777 return direction == HorizontalLine ? marginTop() : marginRight();
3779 } 3778 }
3780 3779
3781 int RenderBlock::baselinePosition(FontBaseline baselineType, bool firstLine, Lin eDirectionMode direction, LinePositionMode linePositionMode) const 3780 int RenderBlock::baselinePosition(FontBaseline baselineType, OwnOrFirstLineStyle firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) cons t
3782 { 3781 {
3783 // Inline blocks are replaced elements. Otherwise, just pass off to 3782 // Inline blocks are replaced elements. Otherwise, just pass off to
3784 // the base class. If we're being queried as though we're the root line 3783 // the base class. If we're being queried as though we're the root line
3785 // box, then the fact that we're an inline-block is irrelevant, and we behav e 3784 // box, then the fact that we're an inline-block is irrelevant, and we behav e
3786 // just like a block. 3785 // just like a block.
3787 if (isInline() && linePositionMode == PositionOnContainingLine) { 3786 if (isInline() && linePositionMode == PositionOnContainingLine) {
3788 // For "leaf" theme objects, let the theme decide what the baseline posi tion is. 3787 // For "leaf" theme objects, let the theme decide what the baseline posi tion is.
3789 // FIXME: Might be better to have a custom CSS property instead, so that if the theme 3788 // FIXME: Might be better to have a custom CSS property instead, so that if the theme
3790 // is turned off, checkboxes/radios will still have decent baselines. 3789 // is turned off, checkboxes/radios will still have decent baselines.
3791 // FIXME: Need to patch form controls to deal with vertical lines. 3790 // FIXME: Need to patch form controls to deal with vertical lines.
(...skipping 27 matching lines...) Expand all
3819 } 3818 }
3820 3819
3821 // If we're not replaced, we'll only get called with PositionOfInteriorLineB oxes. 3820 // If we're not replaced, we'll only get called with PositionOfInteriorLineB oxes.
3822 // Note that inline-block counts as replaced here. 3821 // Note that inline-block counts as replaced here.
3823 ASSERT(linePositionMode == PositionOfInteriorLineBoxes); 3822 ASSERT(linePositionMode == PositionOfInteriorLineBoxes);
3824 3823
3825 const FontMetrics& fontMetrics = style(firstLine)->fontMetrics(); 3824 const FontMetrics& fontMetrics = style(firstLine)->fontMetrics();
3826 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2; 3825 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2;
3827 } 3826 }
3828 3827
3829 LayoutUnit RenderBlock::minLineHeightForReplacedRenderer(bool isFirstLine, Layou tUnit replacedHeight) const 3828 LayoutUnit RenderBlock::minLineHeightForReplacedRenderer(OwnOrFirstLineStyle isF irstLine, LayoutUnit replacedHeight) const
3830 { 3829 {
3831 if (!document().inNoQuirksMode() && replacedHeight) 3830 if (!document().inNoQuirksMode() && replacedHeight)
3832 return replacedHeight; 3831 return replacedHeight;
3833 3832
3834 if (!(style(isFirstLine)->lineBoxContain() & LineBoxContainBlock)) 3833 if (!(style(isFirstLine)->lineBoxContain() & LineBoxContainBlock))
3835 return 0; 3834 return 0;
3836 3835
3837 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, isHorizo ntalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes)) ; 3836 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, isHorizo ntalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes)) ;
3838 } 3837 }
3839 3838
3840 int RenderBlock::firstLineBoxBaseline() const 3839 int RenderBlock::firstLineBoxBaseline() const
3841 { 3840 {
3842 if (isWritingModeRoot() && !isRubyRun()) 3841 if (isWritingModeRoot() && !isRubyRun())
3843 return -1; 3842 return -1;
3844 3843
3845 if (childrenInline()) { 3844 if (childrenInline()) {
3846 if (firstLineBox()) 3845 if (firstLineBox())
3847 return firstLineBox()->logicalTop() + style(true)->fontMetrics().asc ent(firstRootBox()->baselineType()); 3846 return firstLineBox()->logicalTop() + style(FirstLineStyle)->fontMet rics().ascent(firstRootBox()->baselineType());
3848 else 3847 else
3849 return -1; 3848 return -1;
3850 } 3849 }
3851 else { 3850 else {
3852 for (RenderBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBo x()) { 3851 for (RenderBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBo x()) {
3853 if (!curr->isFloatingOrOutOfFlowPositioned()) { 3852 if (!curr->isFloatingOrOutOfFlowPositioned()) {
3854 int result = curr->firstLineBoxBaseline(); 3853 int result = curr->firstLineBoxBaseline();
3855 if (result != -1) 3854 if (result != -1)
3856 return curr->logicalTop() + result; // Translate to our coor dinate space. 3855 return curr->logicalTop() + result; // Translate to our coor dinate space.
3857 } 3856 }
(...skipping 15 matching lines...) Expand all
3873 3872
3874 int RenderBlock::lastLineBoxBaseline(LineDirectionMode lineDirection) const 3873 int RenderBlock::lastLineBoxBaseline(LineDirectionMode lineDirection) const
3875 { 3874 {
3876 if (isWritingModeRoot() && !isRubyRun()) 3875 if (isWritingModeRoot() && !isRubyRun())
3877 return -1; 3876 return -1;
3878 3877
3879 if (childrenInline()) { 3878 if (childrenInline()) {
3880 if (!firstLineBox() && hasLineIfEmpty()) { 3879 if (!firstLineBox() && hasLineIfEmpty()) {
3881 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); 3880 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics();
3882 return fontMetrics.ascent() 3881 return fontMetrics.ascent()
3883 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2 3882 + (lineHeight(FirstLineStyle, lineDirection, PositionOfInteriorL ineBoxes) - fontMetrics.height()) / 2
3884 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight()); 3883 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight());
3885 } 3884 }
3886 if (lastLineBox()) 3885 if (lastLineBox())
3887 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLin eBox())->fontMetrics().ascent(lastRootBox()->baselineType()); 3886 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLin eBox() ? FirstLineStyle : OwnStyle)->fontMetrics().ascent(lastRootBox()->baselin eType());
3888 return -1; 3887 return -1;
3889 } else { 3888 } else {
3890 bool haveNormalFlowChild = false; 3889 bool haveNormalFlowChild = false;
3891 for (RenderBox* curr = lastChildBox(); curr; curr = curr->previousSiblin gBox()) { 3890 for (RenderBox* curr = lastChildBox(); curr; curr = curr->previousSiblin gBox()) {
3892 if (!curr->isFloatingOrOutOfFlowPositioned()) { 3891 if (!curr->isFloatingOrOutOfFlowPositioned()) {
3893 haveNormalFlowChild = true; 3892 haveNormalFlowChild = true;
3894 int result = curr->inlineBlockBaseline(lineDirection); 3893 int result = curr->inlineBlockBaseline(lineDirection);
3895 if (result != -1) 3894 if (result != -1)
3896 return curr->logicalTop() + result; // Translate to our coor dinate space. 3895 return curr->logicalTop() + result; // Translate to our coor dinate space.
3897 } 3896 }
3898 } 3897 }
3899 if (!haveNormalFlowChild && hasLineIfEmpty()) { 3898 if (!haveNormalFlowChild && hasLineIfEmpty()) {
3900 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); 3899 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics();
3901 return fontMetrics.ascent() 3900 return fontMetrics.ascent()
3902 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2 3901 + (lineHeight(FirstLineStyle, lineDirection, PositionOfInteriorL ineBoxes) - fontMetrics.height()) / 2
3903 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight()); 3902 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight());
3904 } 3903 }
3905 } 3904 }
3906 3905
3907 return -1; 3906 return -1;
3908 } 3907 }
3909 3908
3910 RenderBlock* RenderBlock::firstLineBlock() const 3909 RenderBlock* RenderBlock::firstLineBlock() const
3911 { 3910 {
3912 RenderBlock* firstLineBlock = const_cast<RenderBlock*>(this); 3911 RenderBlock* firstLineBlock = const_cast<RenderBlock*>(this);
3913 bool hasPseudo = false; 3912 bool hasPseudo = false;
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
5039 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 5038 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
5040 { 5039 {
5041 showRenderObject(); 5040 showRenderObject();
5042 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 5041 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
5043 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 5042 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
5044 } 5043 }
5045 5044
5046 #endif 5045 #endif
5047 5046
5048 } // namespace WebCore 5047 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | Source/core/rendering/RenderBlockLineLayout.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698