void LayoutQuote::updateText() { String text = computeText(); if (m_text == text) return; m_text = text; LayoutTextFragment* fragment = findFragmentChild(); if (fragment) { fragment->setStyle(mutableStyle()); fragment->setContentString(m_text.impl()); } else { fragment = new LayoutTextFragment(&document(), m_text.impl()); fragment->setStyle(mutableStyle()); addChild(fragment); } }
void FirstLetterPseudoElement::attachFirstLetterTextLayoutObjects() { LayoutObject* nextLayoutObject = FirstLetterPseudoElement::firstLetterTextLayoutObject(*this); ASSERT(nextLayoutObject); ASSERT(nextLayoutObject->isText()); // The original string is going to be either a generated content string or a DOM node's // string. We want the original string before it got transformed in case first-letter has // no text-transform or a different text-transform applied to it. String oldText = toLayoutText(nextLayoutObject)->isTextFragment() ? toLayoutTextFragment(nextLayoutObject)->completeText() : toLayoutText(nextLayoutObject)->originalText(); ASSERT(oldText.impl()); ComputedStyle* pseudoStyle = styleForFirstLetter(nextLayoutObject->parent()); layoutObject()->setStyle(pseudoStyle); // FIXME: This would already have been calculated in firstLetterLayoutObject. Can we pass the length through? unsigned length = FirstLetterPseudoElement::firstLetterLength(oldText); // Construct a text fragment for the text after the first letter. // This text fragment might be empty. LayoutTextFragment* remainingText = new LayoutTextFragment(nextLayoutObject->node() ? nextLayoutObject->node() : &nextLayoutObject->document(), oldText.impl(), length, oldText.length() - length); remainingText->setFirstLetterPseudoElement(this); remainingText->setIsRemainingTextLayoutObject(true); remainingText->setStyle(nextLayoutObject->mutableStyle()); if (remainingText->node()) remainingText->node()->setLayoutObject(remainingText); m_remainingTextLayoutObject = remainingText; LayoutObject* nextSibling = layoutObject()->nextSibling(); layoutObject()->parent()->addChild(remainingText, nextSibling); // Construct text fragment for the first letter. LayoutTextFragment* letter = new LayoutTextFragment(&nextLayoutObject->document(), oldText.impl(), 0, length); letter->setFirstLetterPseudoElement(this); letter->setStyle(pseudoStyle); layoutObject()->addChild(letter); nextLayoutObject->destroy(); }