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 4084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4095 if (!isPunctuationForFirstLetter(c)) | 4095 if (!isPunctuationForFirstLetter(c)) |
4096 break; | 4096 break; |
4097 | 4097 |
4098 length = scanLength + 1; | 4098 length = scanLength + 1; |
4099 } | 4099 } |
4100 | 4100 |
4101 // FIXME: If textLength is 0, length may still be 1! | 4101 // FIXME: If textLength is 0, length may still be 1! |
4102 return length; | 4102 return length; |
4103 } | 4103 } |
4104 | 4104 |
4105 void RenderBlock::createFirstLetterRenderer(RenderObject* firstLetterBlock, Rend
erObject* currentChild, unsigned length) | 4105 void RenderBlock::createFirstLetterRenderer(RenderObject* firstLetterBlock, Rend
erText& currentChild, unsigned length) |
4106 { | 4106 { |
4107 ASSERT(length && currentChild->isText()); | 4107 ASSERT(length); |
4108 | 4108 |
4109 RenderObject* firstLetterContainer = currentChild->parent(); | 4109 RenderObject* firstLetterContainer = currentChild.parent(); |
4110 RenderStyle* pseudoStyle = styleForFirstLetter(firstLetterBlock, firstLetter
Container); | 4110 RenderStyle* pseudoStyle = styleForFirstLetter(firstLetterBlock, firstLetter
Container); |
4111 RenderBoxModelObject* firstLetter = 0; | 4111 RenderBoxModelObject* firstLetter = 0; |
4112 if (pseudoStyle->display() == INLINE) | 4112 if (pseudoStyle->display() == INLINE) |
4113 firstLetter = RenderInline::createAnonymous(&document()); | 4113 firstLetter = RenderInline::createAnonymous(&document()); |
4114 else | 4114 else |
4115 firstLetter = RenderBlockFlow::createAnonymous(&document()); | 4115 firstLetter = RenderBlockFlow::createAnonymous(&document()); |
4116 firstLetter->setStyle(pseudoStyle); | 4116 firstLetter->setStyle(pseudoStyle); |
4117 | 4117 |
4118 // FIXME: The first letter code should not modify the render tree during | 4118 // FIXME: The first letter code should not modify the render tree during |
4119 // layout. crbug.com/370458 | 4119 // layout. crbug.com/370458 |
4120 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; | 4120 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; |
4121 | 4121 |
4122 firstLetterContainer->addChild(firstLetter, currentChild); | 4122 firstLetterContainer->addChild(firstLetter, ¤tChild); |
4123 RenderText* textObj = toRenderText(currentChild); | |
4124 | 4123 |
4125 // The original string is going to be either a generated content string or a
DOM node's | 4124 // The original string is going to be either a generated content string or a
DOM node's |
4126 // string. We want the original string before it got transformed in case fi
rst-letter has | 4125 // string. We want the original string before it got transformed in case fi
rst-letter has |
4127 // no text-transform or a different text-transform applied to it. | 4126 // no text-transform or a different text-transform applied to it. |
4128 String oldText = textObj->originalText(); | 4127 String oldText = currentChild.originalText(); |
4129 ASSERT(oldText.impl()); | 4128 ASSERT(oldText.impl()); |
4130 | 4129 |
4131 // Construct a text fragment for the text after the first letter. | 4130 // Construct a text fragment for the text after the first letter. |
4132 // This text fragment might be empty. | 4131 // This text fragment might be empty. |
4133 RenderTextFragment* remainingText = | 4132 RenderTextFragment* remainingText = |
4134 new RenderTextFragment(textObj->node() ? textObj->node() : &textObj->doc
ument(), oldText.impl(), length, oldText.length() - length); | 4133 new RenderTextFragment(currentChild.node() ? currentChild.node() : &curr
entChild.document(), oldText.impl(), length, oldText.length() - length); |
4135 remainingText->setStyle(textObj->style()); | 4134 remainingText->setStyle(currentChild.style()); |
4136 if (remainingText->node()) | 4135 if (remainingText->node()) |
4137 remainingText->node()->setRenderer(remainingText); | 4136 remainingText->node()->setRenderer(remainingText); |
4138 | 4137 |
4139 firstLetterContainer->addChild(remainingText, textObj); | 4138 firstLetterContainer->addChild(remainingText, ¤tChild); |
4140 firstLetterContainer->removeChild(textObj); | 4139 firstLetterContainer->removeChild(¤tChild); |
4141 remainingText->setFirstLetter(firstLetter); | 4140 remainingText->setFirstLetter(firstLetter); |
4142 firstLetter->setFirstLetterRemainingText(remainingText); | 4141 firstLetter->setFirstLetterRemainingText(remainingText); |
4143 | 4142 |
4144 // construct text fragment for the first letter | 4143 // construct text fragment for the first letter |
4145 RenderTextFragment* letter = | 4144 RenderTextFragment* letter = |
4146 new RenderTextFragment(remainingText->node() ? remainingText->node() : &
remainingText->document(), oldText.impl(), 0, length); | 4145 new RenderTextFragment(remainingText->node() ? remainingText->node() : &
remainingText->document(), oldText.impl(), 0, length); |
4147 letter->setStyle(pseudoStyle); | 4146 letter->setStyle(pseudoStyle); |
4148 firstLetter->addChild(letter); | 4147 firstLetter->addChild(letter); |
4149 | 4148 |
4150 textObj->destroy(); | 4149 currentChild.destroy(); |
4151 } | 4150 } |
4152 | 4151 |
4153 void RenderBlock::updateFirstLetter() | 4152 void RenderBlock::updateFirstLetter() |
4154 { | 4153 { |
4155 if (!document().styleEngine()->usesFirstLetterRules()) | 4154 if (!document().styleEngine()->usesFirstLetterRules()) |
4156 return; | 4155 return; |
4157 // Don't recur | 4156 // Don't recur |
4158 if (style()->styleType() == FIRST_LETTER) | 4157 if (style()->styleType() == FIRST_LETTER) |
4159 return; | 4158 return; |
4160 | 4159 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4202 if (currChild->parent()->style()->styleType() == FIRST_LETTER) { | 4201 if (currChild->parent()->style()->styleType() == FIRST_LETTER) { |
4203 updateFirstLetterStyle(firstLetterBlock, currChild); | 4202 updateFirstLetterStyle(firstLetterBlock, currChild); |
4204 return; | 4203 return; |
4205 } | 4204 } |
4206 | 4205 |
4207 // FIXME: This black-list of disallowed RenderText subclasses is fragile. | 4206 // FIXME: This black-list of disallowed RenderText subclasses is fragile. |
4208 // Should counter be on this list? What about RenderTextFragment? | 4207 // Should counter be on this list? What about RenderTextFragment? |
4209 if (!currChild->isText() || currChild->isBR() || toRenderText(currChild)->is
WordBreak()) | 4208 if (!currChild->isText() || currChild->isBR() || toRenderText(currChild)->is
WordBreak()) |
4210 return; | 4209 return; |
4211 | 4210 |
4212 createFirstLetterRenderer(firstLetterBlock, currChild, length); | 4211 createFirstLetterRenderer(firstLetterBlock, toRenderText(*currChild), length
); |
4213 } | 4212 } |
4214 | 4213 |
4215 // Helper methods for obtaining the last line, computing line counts and heights
for line counts | 4214 // Helper methods for obtaining the last line, computing line counts and heights
for line counts |
4216 // (crawling into blocks). | 4215 // (crawling into blocks). |
4217 static bool shouldCheckLines(RenderObject* obj) | 4216 static bool shouldCheckLines(RenderObject* obj) |
4218 { | 4217 { |
4219 return !obj->isFloatingOrOutOfFlowPositioned() | 4218 return !obj->isFloatingOrOutOfFlowPositioned() |
4220 && obj->isRenderBlock() && obj->style()->height().isAuto() | 4219 && obj->isRenderBlock() && obj->style()->height().isAuto() |
4221 && (!obj->isDeprecatedFlexibleBox() || obj->style()->boxOrient() == VERT
ICAL); | 4220 && (!obj->isDeprecatedFlexibleBox() || obj->style()->boxOrient() == VERT
ICAL); |
4222 } | 4221 } |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4842 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const | 4841 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const |
4843 { | 4842 { |
4844 showRenderObject(); | 4843 showRenderObject(); |
4845 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 4844 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
4846 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 4845 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
4847 } | 4846 } |
4848 | 4847 |
4849 #endif | 4848 #endif |
4850 | 4849 |
4851 } // namespace blink | 4850 } // namespace blink |
OLD | NEW |