| 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. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
| 6 * All rights reserved. | 6 * All rights reserved. |
| 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 ? toLayoutTextFragment(nextLayoutObject)->completeText() | 283 ? toLayoutTextFragment(nextLayoutObject)->completeText() |
| 284 : toLayoutText(nextLayoutObject)->originalText(); | 284 : toLayoutText(nextLayoutObject)->originalText(); |
| 285 DCHECK(oldText.impl()); | 285 DCHECK(oldText.impl()); |
| 286 | 286 |
| 287 ComputedStyle* pseudoStyle = styleForFirstLetter(nextLayoutObject->parent()); | 287 ComputedStyle* pseudoStyle = styleForFirstLetter(nextLayoutObject->parent()); |
| 288 layoutObject()->setStyle(pseudoStyle); | 288 layoutObject()->setStyle(pseudoStyle); |
| 289 | 289 |
| 290 // FIXME: This would already have been calculated in firstLetterLayoutObject. | 290 // FIXME: This would already have been calculated in firstLetterLayoutObject. |
| 291 // Can we pass the length through? | 291 // Can we pass the length through? |
| 292 unsigned length = FirstLetterPseudoElement::firstLetterLength(oldText); | 292 unsigned length = FirstLetterPseudoElement::firstLetterLength(oldText); |
| 293 unsigned remainingLength = oldText.length() - length; |
| 293 | 294 |
| 294 // Construct a text fragment for the text after the first letter. | 295 // Construct a text fragment for the text after the first letter. |
| 295 // This text fragment might be empty. | 296 // This text fragment might be empty. |
| 296 LayoutTextFragment* remainingText = new LayoutTextFragment( | 297 LayoutTextFragment* remainingText; |
| 297 nextLayoutObject->node() ? nextLayoutObject->node() | 298 |
| 298 : &nextLayoutObject->document(), | 299 if (nextLayoutObject->node()) { |
| 299 oldText.impl(), length, oldText.length() - length); | 300 remainingText = new LayoutTextFragment( |
| 301 nextLayoutObject->node(), oldText.impl(), length, remainingLength); |
| 302 } else { |
| 303 remainingText = LayoutTextFragment::createAnonymous( |
| 304 *this, oldText.impl(), length, remainingLength); |
| 305 } |
| 306 |
| 300 remainingText->setFirstLetterPseudoElement(this); | 307 remainingText->setFirstLetterPseudoElement(this); |
| 301 remainingText->setIsRemainingTextLayoutObject(true); | 308 remainingText->setIsRemainingTextLayoutObject(true); |
| 302 remainingText->setStyle(nextLayoutObject->mutableStyle()); | 309 remainingText->setStyle(nextLayoutObject->mutableStyle()); |
| 303 | 310 |
| 304 if (remainingText->node()) | 311 if (remainingText->node()) |
| 305 remainingText->node()->setLayoutObject(remainingText); | 312 remainingText->node()->setLayoutObject(remainingText); |
| 306 | 313 |
| 307 m_remainingTextLayoutObject = remainingText; | 314 m_remainingTextLayoutObject = remainingText; |
| 308 | 315 |
| 309 LayoutObject* nextSibling = layoutObject()->nextSibling(); | 316 LayoutObject* nextSibling = layoutObject()->nextSibling(); |
| 310 layoutObject()->parent()->addChild(remainingText, nextSibling); | 317 layoutObject()->parent()->addChild(remainingText, nextSibling); |
| 311 | 318 |
| 312 // Construct text fragment for the first letter. | 319 // Construct text fragment for the first letter. |
| 313 LayoutTextFragment* letter = new LayoutTextFragment( | 320 LayoutTextFragment* letter = |
| 314 &nextLayoutObject->document(), oldText.impl(), 0, length); | 321 LayoutTextFragment::createAnonymous(*this, oldText.impl(), 0, length); |
| 315 letter->setFirstLetterPseudoElement(this); | 322 letter->setFirstLetterPseudoElement(this); |
| 316 letter->setStyle(pseudoStyle); | 323 letter->setStyle(pseudoStyle); |
| 317 layoutObject()->addChild(letter); | 324 layoutObject()->addChild(letter); |
| 318 | 325 |
| 319 nextLayoutObject->destroy(); | 326 nextLayoutObject->destroy(); |
| 320 } | 327 } |
| 321 | 328 |
| 322 void FirstLetterPseudoElement::didRecalcStyle() { | 329 void FirstLetterPseudoElement::didRecalcStyle() { |
| 323 if (!layoutObject()) | 330 if (!layoutObject()) |
| 324 return; | 331 return; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 342 | 349 |
| 343 // We only manage the style for the generated content items. | 350 // We only manage the style for the generated content items. |
| 344 if (!child->isText() && !child->isQuote() && !child->isImage()) | 351 if (!child->isText() && !child->isQuote() && !child->isImage()) |
| 345 continue; | 352 continue; |
| 346 | 353 |
| 347 child->setPseudoStyle(layoutObject->mutableStyle()); | 354 child->setPseudoStyle(layoutObject->mutableStyle()); |
| 348 } | 355 } |
| 349 } | 356 } |
| 350 | 357 |
| 351 } // namespace blink | 358 } // namespace blink |
| OLD | NEW |