OLD | NEW |
---|---|
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 3909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3920 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); | 3920 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); |
3921 return fontMetrics.ascent() | 3921 return fontMetrics.ascent() |
3922 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2 | 3922 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2 |
3923 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight()); | 3923 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight()); |
3924 } | 3924 } |
3925 } | 3925 } |
3926 | 3926 |
3927 return -1; | 3927 return -1; |
3928 } | 3928 } |
3929 | 3929 |
3930 static inline bool isRenderBlockFlowOrRenderButton(RenderObject* renderObject) | |
3931 { | |
3932 // We include isRenderButton in this check because buttons are implemented | |
3933 // using flex box but should still support first-line|first-letter. | |
3934 // The flex box and grid specs requires that flex box and grid do not | |
3935 // support first-line|first-letter, though. | |
3936 // FIXME: Remove when buttons are implemented with align-items instead | |
3937 // of flexbox. | |
3938 return renderObject->isRenderBlockFlow() || renderObject->isRenderButton(); | |
3939 } | |
3940 | |
3930 RenderBlock* RenderBlock::firstLineBlock() const | 3941 RenderBlock* RenderBlock::firstLineBlock() const |
3931 { | 3942 { |
3932 RenderBlock* firstLineBlock = const_cast<RenderBlock*>(this); | 3943 RenderBlock* firstLineBlock = const_cast<RenderBlock*>(this); |
3933 bool hasPseudo = false; | 3944 bool hasPseudo = false; |
3934 while (true) { | 3945 while (true) { |
3935 hasPseudo = firstLineBlock->style()->hasPseudoStyle(FIRST_LINE); | 3946 hasPseudo = firstLineBlock->style()->hasPseudoStyle(FIRST_LINE); |
3936 if (hasPseudo) | 3947 if (hasPseudo) |
3937 break; | 3948 break; |
3938 RenderObject* parentBlock = firstLineBlock->parent(); | 3949 RenderObject* parentBlock = firstLineBlock->parent(); |
3939 // We include isRenderButton in this check because buttons are | |
3940 // implemented using flex box but should still support first-line. The | |
3941 // flex box spec requires that flex box does not support first-line, | |
3942 // though. | |
3943 // FIXME: Remove when buttons are implemented with align-items instead | |
3944 // of flexbox. | |
3945 if (firstLineBlock->isReplaced() || firstLineBlock->isFloating() | 3950 if (firstLineBlock->isReplaced() || firstLineBlock->isFloating() |
3946 || !parentBlock | 3951 || !parentBlock |
3947 || (!parentBlock->isRenderBlockFlow() && !parentBlock->isRenderButto n())) | 3952 || !isRenderBlockFlowOrRenderButton(parentBlock)) |
3948 break; | 3953 break; |
3949 ASSERT_WITH_SECURITY_IMPLICATION(parentBlock->isRenderBlock()); | 3954 ASSERT_WITH_SECURITY_IMPLICATION(parentBlock->isRenderBlock()); |
3950 if (toRenderBlock(parentBlock)->firstChild() != firstLineBlock) | 3955 if (toRenderBlock(parentBlock)->firstChild() != firstLineBlock) |
3951 break; | 3956 break; |
3952 firstLineBlock = toRenderBlock(parentBlock); | 3957 firstLineBlock = toRenderBlock(parentBlock); |
3953 } | 3958 } |
3954 | 3959 |
3955 if (!hasPseudo) | 3960 if (!hasPseudo) |
3956 return 0; | 3961 return 0; |
3957 | 3962 |
(...skipping 25 matching lines...) Expand all Loading... | |
3983 | 3988 |
3984 static inline bool isSpaceForFirstLetter(UChar c) | 3989 static inline bool isSpaceForFirstLetter(UChar c) |
3985 { | 3990 { |
3986 return isSpaceOrNewline(c) || c == noBreakSpace; | 3991 return isSpaceOrNewline(c) || c == noBreakSpace; |
3987 } | 3992 } |
3988 | 3993 |
3989 static inline RenderObject* findFirstLetterBlock(RenderBlock* start) | 3994 static inline RenderObject* findFirstLetterBlock(RenderBlock* start) |
3990 { | 3995 { |
3991 RenderObject* firstLetterBlock = start; | 3996 RenderObject* firstLetterBlock = start; |
3992 while (true) { | 3997 while (true) { |
3993 // We include isRenderButton in these two checks because buttons are | |
3994 // implemented using flex box but should still support first-letter. | |
3995 // The flex box spec requires that flex box does not support | |
3996 // first-letter, though. | |
3997 // FIXME: Remove when buttons are implemented with align-items instead | |
3998 // of flexbox. | |
3999 bool canHaveFirstLetterRenderer = firstLetterBlock->style()->hasPseudoSt yle(FIRST_LETTER) | 3998 bool canHaveFirstLetterRenderer = firstLetterBlock->style()->hasPseudoSt yle(FIRST_LETTER) |
4000 && firstLetterBlock->canHaveGeneratedChildren() | 3999 && firstLetterBlock->canHaveGeneratedChildren() |
4001 && (!firstLetterBlock->isFlexibleBox() || firstLetterBlock->isRender Button()); | 4000 && isRenderBlockFlowOrRenderButton(firstLetterBlock); |
4002 if (canHaveFirstLetterRenderer) | 4001 if (canHaveFirstLetterRenderer) |
4003 return firstLetterBlock; | 4002 return firstLetterBlock; |
4004 | 4003 |
4005 RenderObject* parentBlock = firstLetterBlock->parent(); | 4004 RenderObject* parentBlock = firstLetterBlock->parent(); |
4006 if (firstLetterBlock->isReplaced() || !parentBlock | 4005 if (firstLetterBlock->isReplaced() || !parentBlock |
4007 || (!parentBlock->isRenderBlockFlow() && !parentBlock->isRenderButto n())) { | 4006 || !isRenderBlockFlowOrRenderButton(parentBlock)) { |
4008 return 0; | 4007 return 0; |
4009 } | 4008 } |
4010 ASSERT(parentBlock->isRenderBlock()); | 4009 ASSERT(parentBlock->isRenderBlock()); |
4011 if (toRenderBlock(parentBlock)->firstChild() != firstLetterBlock) | 4010 if (toRenderBlock(parentBlock)->firstChild() != firstLetterBlock) |
4012 return 0; | 4011 return 0; |
4013 firstLetterBlock = parentBlock; | 4012 firstLetterBlock = parentBlock; |
4014 } | 4013 } |
4015 | 4014 |
4016 return 0; | 4015 return 0; |
4017 } | 4016 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4169 break; | 4168 break; |
4170 currChild = currChild->nextSibling(); | 4169 currChild = currChild->nextSibling(); |
4171 } else if (currChild->isListMarker()) { | 4170 } else if (currChild->isListMarker()) { |
4172 currChild = currChild->nextSibling(); | 4171 currChild = currChild->nextSibling(); |
4173 } else if (currChild->isFloatingOrOutOfFlowPositioned()) { | 4172 } else if (currChild->isFloatingOrOutOfFlowPositioned()) { |
4174 if (currChild->style()->styleType() == FIRST_LETTER) { | 4173 if (currChild->style()->styleType() == FIRST_LETTER) { |
4175 currChild = currChild->slowFirstChild(); | 4174 currChild = currChild->slowFirstChild(); |
4176 break; | 4175 break; |
4177 } | 4176 } |
4178 currChild = currChild->nextSibling(); | 4177 currChild = currChild->nextSibling(); |
4179 } else if (currChild->isReplaced() || currChild->isRenderButton() || cur rChild->isMenuList()) { | 4178 } else if (currChild->isReplaced() || currChild->isRenderButton() || cur rChild->isMenuList() || !isRenderBlockFlowOrRenderButton(firstLetterBlock)) { |
cbiesinger
2014/08/08 03:28:12
I'm confused, why do we want a break here if the f
Manuel Rego
2014/08/08 12:55:27
Yeah, I agree that it's confusing to add this in t
| |
4180 break; | 4179 break; |
4181 } else if (currChild->style()->hasPseudoStyle(FIRST_LETTER) && currChild ->canHaveGeneratedChildren()) { | 4180 } else if (currChild->style()->hasPseudoStyle(FIRST_LETTER) && currChild ->canHaveGeneratedChildren()) { |
4182 // We found a lower-level node with first-letter, which supersedes t he higher-level style | 4181 // We found a lower-level node with first-letter, which supersedes t he higher-level style |
4183 firstLetterBlock = currChild; | 4182 firstLetterBlock = currChild; |
4184 currChild = currChild->slowFirstChild(); | 4183 currChild = currChild->slowFirstChild(); |
4185 } else { | 4184 } else { |
4186 currChild = currChild->slowFirstChild(); | 4185 currChild = currChild->slowFirstChild(); |
4187 } | 4186 } |
4188 } | 4187 } |
4189 | 4188 |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4835 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const | 4834 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const |
4836 { | 4835 { |
4837 showRenderObject(); | 4836 showRenderObject(); |
4838 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) | 4837 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) |
4839 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); | 4838 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); |
4840 } | 4839 } |
4841 | 4840 |
4842 #endif | 4841 #endif |
4843 | 4842 |
4844 } // namespace blink | 4843 } // namespace blink |
OLD | NEW |