| 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 3905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3916 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); | 3916 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); |
| 3917 return fontMetrics.ascent() | 3917 return fontMetrics.ascent() |
| 3918 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes)
- fontMetrics.height()) / 2 | 3918 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes)
- fontMetrics.height()) / 2 |
| 3919 + (lineDirection == HorizontalLine ? borderTop() + paddingTop()
: borderRight() + paddingRight()); | 3919 + (lineDirection == HorizontalLine ? borderTop() + paddingTop()
: borderRight() + paddingRight()); |
| 3920 } | 3920 } |
| 3921 } | 3921 } |
| 3922 | 3922 |
| 3923 return -1; | 3923 return -1; |
| 3924 } | 3924 } |
| 3925 | 3925 |
| 3926 static inline bool isRenderBlockFlowOrRenderButton(RenderObject* renderObject) |
| 3927 { |
| 3928 // We include isRenderButton in this check because buttons are implemented |
| 3929 // using flex box but should still support first-line|first-letter. |
| 3930 // The flex box and grid specs require that flex box and grid do not |
| 3931 // support first-line|first-letter, though. |
| 3932 // FIXME: Remove when buttons are implemented with align-items instead |
| 3933 // of flex box. |
| 3934 return renderObject->isRenderBlockFlow() || renderObject->isRenderButton(); |
| 3935 } |
| 3936 |
| 3926 RenderBlock* RenderBlock::firstLineBlock() const | 3937 RenderBlock* RenderBlock::firstLineBlock() const |
| 3927 { | 3938 { |
| 3928 RenderBlock* firstLineBlock = const_cast<RenderBlock*>(this); | 3939 RenderBlock* firstLineBlock = const_cast<RenderBlock*>(this); |
| 3929 bool hasPseudo = false; | 3940 bool hasPseudo = false; |
| 3930 while (true) { | 3941 while (true) { |
| 3931 hasPseudo = firstLineBlock->style()->hasPseudoStyle(FIRST_LINE); | 3942 hasPseudo = firstLineBlock->style()->hasPseudoStyle(FIRST_LINE); |
| 3932 if (hasPseudo) | 3943 if (hasPseudo) |
| 3933 break; | 3944 break; |
| 3934 RenderObject* parentBlock = firstLineBlock->parent(); | 3945 RenderObject* parentBlock = firstLineBlock->parent(); |
| 3935 // We include isRenderButton in this check because buttons are | |
| 3936 // implemented using flex box but should still support first-line. The | |
| 3937 // flex box spec requires that flex box does not support first-line, | |
| 3938 // though. | |
| 3939 // FIXME: Remove when buttons are implemented with align-items instead | |
| 3940 // of flexbox. | |
| 3941 if (firstLineBlock->isReplaced() || firstLineBlock->isFloating() | 3946 if (firstLineBlock->isReplaced() || firstLineBlock->isFloating() |
| 3942 || !parentBlock | 3947 || !parentBlock |
| 3943 || (!parentBlock->isRenderBlockFlow() && !parentBlock->isRenderButto
n())) | 3948 || !isRenderBlockFlowOrRenderButton(parentBlock)) |
| 3944 break; | 3949 break; |
| 3945 ASSERT_WITH_SECURITY_IMPLICATION(parentBlock->isRenderBlock()); | 3950 ASSERT_WITH_SECURITY_IMPLICATION(parentBlock->isRenderBlock()); |
| 3946 if (toRenderBlock(parentBlock)->firstChild() != firstLineBlock) | 3951 if (toRenderBlock(parentBlock)->firstChild() != firstLineBlock) |
| 3947 break; | 3952 break; |
| 3948 firstLineBlock = toRenderBlock(parentBlock); | 3953 firstLineBlock = toRenderBlock(parentBlock); |
| 3949 } | 3954 } |
| 3950 | 3955 |
| 3951 if (!hasPseudo) | 3956 if (!hasPseudo) |
| 3952 return 0; | 3957 return 0; |
| 3953 | 3958 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3979 | 3984 |
| 3980 static inline bool isSpaceForFirstLetter(UChar c) | 3985 static inline bool isSpaceForFirstLetter(UChar c) |
| 3981 { | 3986 { |
| 3982 return isSpaceOrNewline(c) || c == noBreakSpace; | 3987 return isSpaceOrNewline(c) || c == noBreakSpace; |
| 3983 } | 3988 } |
| 3984 | 3989 |
| 3985 static inline RenderObject* findFirstLetterBlock(RenderBlock* start) | 3990 static inline RenderObject* findFirstLetterBlock(RenderBlock* start) |
| 3986 { | 3991 { |
| 3987 RenderObject* firstLetterBlock = start; | 3992 RenderObject* firstLetterBlock = start; |
| 3988 while (true) { | 3993 while (true) { |
| 3989 // We include isRenderButton in these two checks because buttons are | |
| 3990 // implemented using flex box but should still support first-letter. | |
| 3991 // The flex box spec requires that flex box does not support | |
| 3992 // first-letter, though. | |
| 3993 // FIXME: Remove when buttons are implemented with align-items instead | |
| 3994 // of flexbox. | |
| 3995 bool canHaveFirstLetterRenderer = firstLetterBlock->style()->hasPseudoSt
yle(FIRST_LETTER) | 3994 bool canHaveFirstLetterRenderer = firstLetterBlock->style()->hasPseudoSt
yle(FIRST_LETTER) |
| 3996 && firstLetterBlock->canHaveGeneratedChildren() | 3995 && firstLetterBlock->canHaveGeneratedChildren() |
| 3997 && (!firstLetterBlock->isFlexibleBox() || firstLetterBlock->isRender
Button()); | 3996 && isRenderBlockFlowOrRenderButton(firstLetterBlock); |
| 3998 if (canHaveFirstLetterRenderer) | 3997 if (canHaveFirstLetterRenderer) |
| 3999 return firstLetterBlock; | 3998 return firstLetterBlock; |
| 4000 | 3999 |
| 4001 RenderObject* parentBlock = firstLetterBlock->parent(); | 4000 RenderObject* parentBlock = firstLetterBlock->parent(); |
| 4002 if (firstLetterBlock->isReplaced() || !parentBlock | 4001 if (firstLetterBlock->isReplaced() || !parentBlock |
| 4003 || (!parentBlock->isRenderBlockFlow() && !parentBlock->isRenderButto
n())) { | 4002 || !isRenderBlockFlowOrRenderButton(parentBlock)) { |
| 4004 return 0; | 4003 return 0; |
| 4005 } | 4004 } |
| 4006 ASSERT(parentBlock->isRenderBlock()); | 4005 ASSERT(parentBlock->isRenderBlock()); |
| 4007 if (toRenderBlock(parentBlock)->firstChild() != firstLetterBlock) | 4006 if (toRenderBlock(parentBlock)->firstChild() != firstLetterBlock) |
| 4008 return 0; | 4007 return 0; |
| 4009 firstLetterBlock = parentBlock; | 4008 firstLetterBlock = parentBlock; |
| 4010 } | 4009 } |
| 4011 | 4010 |
| 4012 return 0; | 4011 return 0; |
| 4013 } | 4012 } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4176 break; | 4175 break; |
| 4177 } else if (currChild->style()->hasPseudoStyle(FIRST_LETTER) && currChild
->canHaveGeneratedChildren()) { | 4176 } else if (currChild->style()->hasPseudoStyle(FIRST_LETTER) && currChild
->canHaveGeneratedChildren()) { |
| 4178 // We found a lower-level node with first-letter, which supersedes t
he higher-level style | 4177 // We found a lower-level node with first-letter, which supersedes t
he higher-level style |
| 4179 firstLetterBlock = currChild; | 4178 firstLetterBlock = currChild; |
| 4180 currChild = currChild->slowFirstChild(); | 4179 currChild = currChild->slowFirstChild(); |
| 4181 } else { | 4180 } else { |
| 4182 currChild = currChild->slowFirstChild(); | 4181 currChild = currChild->slowFirstChild(); |
| 4183 } | 4182 } |
| 4184 } | 4183 } |
| 4185 | 4184 |
| 4186 if (!currChild) | 4185 if (!currChild || !isRenderBlockFlowOrRenderButton(firstLetterBlock)) |
| 4187 return; | 4186 return; |
| 4188 | 4187 |
| 4189 // If the child already has style, then it has already been created, so we j
ust want | 4188 // If the child already has style, then it has already been created, so we j
ust want |
| 4190 // to update it. | 4189 // to update it. |
| 4191 if (currChild->parent()->style()->styleType() == FIRST_LETTER) { | 4190 if (currChild->parent()->style()->styleType() == FIRST_LETTER) { |
| 4192 updateFirstLetterStyle(firstLetterBlock, currChild); | 4191 updateFirstLetterStyle(firstLetterBlock, currChild); |
| 4193 return; | 4192 return; |
| 4194 } | 4193 } |
| 4195 | 4194 |
| 4196 // FIXME: This black-list of disallowed RenderText subclasses is fragile. | 4195 // FIXME: This black-list of disallowed RenderText subclasses is fragile. |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4810 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const | 4809 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const |
| 4811 { | 4810 { |
| 4812 showRenderObject(); | 4811 showRenderObject(); |
| 4813 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 4812 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
| 4814 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 4813 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
| 4815 } | 4814 } |
| 4816 | 4815 |
| 4817 #endif | 4816 #endif |
| 4818 | 4817 |
| 4819 } // namespace blink | 4818 } // namespace blink |
| OLD | NEW |