| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 LayoutStyle* FirstLetterPseudoElement::styleForFirstLetter(LayoutObject* rendere
rContainer) | 227 LayoutStyle* FirstLetterPseudoElement::styleForFirstLetter(LayoutObject* rendere
rContainer) |
| 228 { | 228 { |
| 229 ASSERT(rendererContainer); | 229 ASSERT(rendererContainer); |
| 230 | 230 |
| 231 LayoutObject* styleContainer = parentOrShadowHostElement()->renderer(); | 231 LayoutObject* styleContainer = parentOrShadowHostElement()->renderer(); |
| 232 ASSERT(styleContainer); | 232 ASSERT(styleContainer); |
| 233 | 233 |
| 234 // We always force the pseudo style to recompute as the first-letter style | 234 // We always force the pseudo style to recompute as the first-letter style |
| 235 // computed by the style container may not have taken the renderers styles | 235 // computed by the style container may not have taken the renderers styles |
| 236 // into account. | 236 // into account. |
| 237 styleContainer->style()->removeCachedPseudoStyle(FIRST_LETTER); | 237 styleContainer->mutableStyleRef().removeCachedPseudoStyle(FIRST_LETTER); |
| 238 | 238 |
| 239 LayoutStyle* pseudoStyle = styleContainer->getCachedPseudoStyle(FIRST_LETTER
, rendererContainer->firstLineStyle()); | 239 LayoutStyle* pseudoStyle = styleContainer->getCachedPseudoStyle(FIRST_LETTER
, rendererContainer->firstLineStyle()); |
| 240 ASSERT(pseudoStyle); | 240 ASSERT(pseudoStyle); |
| 241 | 241 |
| 242 return pseudoStyle; | 242 return pseudoStyle; |
| 243 } | 243 } |
| 244 | 244 |
| 245 void FirstLetterPseudoElement::attachFirstLetterTextRenderers() | 245 void FirstLetterPseudoElement::attachFirstLetterTextRenderers() |
| 246 { | 246 { |
| 247 LayoutObject* nextRenderer = FirstLetterPseudoElement::firstLetterTextRender
er(*this); | 247 LayoutObject* nextRenderer = FirstLetterPseudoElement::firstLetterTextRender
er(*this); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 259 | 259 |
| 260 // FIXME: This would already have been calculated in firstLetterRenderer. Ca
n we pass the length through? | 260 // FIXME: This would already have been calculated in firstLetterRenderer. Ca
n we pass the length through? |
| 261 unsigned length = FirstLetterPseudoElement::firstLetterLength(oldText); | 261 unsigned length = FirstLetterPseudoElement::firstLetterLength(oldText); |
| 262 | 262 |
| 263 // Construct a text fragment for the text after the first letter. | 263 // Construct a text fragment for the text after the first letter. |
| 264 // This text fragment might be empty. | 264 // This text fragment might be empty. |
| 265 RenderTextFragment* remainingText = | 265 RenderTextFragment* remainingText = |
| 266 new RenderTextFragment(nextRenderer->node() ? nextRenderer->node() : &ne
xtRenderer->document(), oldText.impl(), length, oldText.length() - length); | 266 new RenderTextFragment(nextRenderer->node() ? nextRenderer->node() : &ne
xtRenderer->document(), oldText.impl(), length, oldText.length() - length); |
| 267 remainingText->setFirstLetterPseudoElement(this); | 267 remainingText->setFirstLetterPseudoElement(this); |
| 268 remainingText->setIsRemainingTextRenderer(true); | 268 remainingText->setIsRemainingTextRenderer(true); |
| 269 remainingText->setStyle(nextRenderer->style()); | 269 remainingText->setStyle(nextRenderer->mutableStyle()); |
| 270 | 270 |
| 271 if (remainingText->node()) | 271 if (remainingText->node()) |
| 272 remainingText->node()->setRenderer(remainingText); | 272 remainingText->node()->setRenderer(remainingText); |
| 273 | 273 |
| 274 m_remainingTextRenderer = remainingText; | 274 m_remainingTextRenderer = remainingText; |
| 275 | 275 |
| 276 LayoutObject* nextSibling = renderer()->nextSibling(); | 276 LayoutObject* nextSibling = renderer()->nextSibling(); |
| 277 renderer()->parent()->addChild(remainingText, nextSibling); | 277 renderer()->parent()->addChild(remainingText, nextSibling); |
| 278 | 278 |
| 279 // Construct text fragment for the first letter. | 279 // Construct text fragment for the first letter. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 299 if (child->style()->styleType() == FIRST_LETTER && m_remainingTextRender
er) { | 299 if (child->style()->styleType() == FIRST_LETTER && m_remainingTextRender
er) { |
| 300 if (LayoutStyle* pseudoStyle = styleForFirstLetter(m_remainingTextRe
nderer->parent())) | 300 if (LayoutStyle* pseudoStyle = styleForFirstLetter(m_remainingTextRe
nderer->parent())) |
| 301 child->setPseudoStyle(pseudoStyle); | 301 child->setPseudoStyle(pseudoStyle); |
| 302 continue; | 302 continue; |
| 303 } | 303 } |
| 304 | 304 |
| 305 // We only manage the style for the generated content items. | 305 // We only manage the style for the generated content items. |
| 306 if (!child->isText() && !child->isQuote() && !child->isImage()) | 306 if (!child->isText() && !child->isQuote() && !child->isImage()) |
| 307 continue; | 307 continue; |
| 308 | 308 |
| 309 child->setPseudoStyle(renderer->style()); | 309 child->setPseudoStyle(renderer->mutableStyle()); |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 | 312 |
| 313 } // namespace blink | 313 } // namespace blink |
| OLD | NEW |