| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 | 165 |
| 166 FirstLetterPseudoElement::FirstLetterPseudoElement(Element* parent) | 166 FirstLetterPseudoElement::FirstLetterPseudoElement(Element* parent) |
| 167 : PseudoElement(parent, PseudoIdFirstLetter) | 167 : PseudoElement(parent, PseudoIdFirstLetter) |
| 168 , m_remainingTextLayoutObject(nullptr) | 168 , m_remainingTextLayoutObject(nullptr) |
| 169 { | 169 { |
| 170 } | 170 } |
| 171 | 171 |
| 172 FirstLetterPseudoElement::~FirstLetterPseudoElement() | 172 FirstLetterPseudoElement::~FirstLetterPseudoElement() |
| 173 { | 173 { |
| 174 ASSERT(!m_remainingTextLayoutObject); | 174 DCHECK(!m_remainingTextLayoutObject); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void FirstLetterPseudoElement::updateTextFragments() | 177 void FirstLetterPseudoElement::updateTextFragments() |
| 178 { | 178 { |
| 179 String oldText = m_remainingTextLayoutObject->completeText(); | 179 String oldText = m_remainingTextLayoutObject->completeText(); |
| 180 ASSERT(oldText.impl()); | 180 DCHECK(oldText.impl()); |
| 181 | 181 |
| 182 unsigned length = FirstLetterPseudoElement::firstLetterLength(oldText); | 182 unsigned length = FirstLetterPseudoElement::firstLetterLength(oldText); |
| 183 m_remainingTextLayoutObject->setTextFragment(oldText.impl()->substring(lengt
h, oldText.length()), length, oldText.length() - length); | 183 m_remainingTextLayoutObject->setTextFragment(oldText.impl()->substring(lengt
h, oldText.length()), length, oldText.length() - length); |
| 184 m_remainingTextLayoutObject->dirtyLineBoxes(); | 184 m_remainingTextLayoutObject->dirtyLineBoxes(); |
| 185 | 185 |
| 186 for (auto child = layoutObject()->slowFirstChild(); child; child = child->ne
xtSibling()) { | 186 for (auto child = layoutObject()->slowFirstChild(); child; child = child->ne
xtSibling()) { |
| 187 if (!child->isText() || !toLayoutText(child)->isTextFragment()) | 187 if (!child->isText() || !toLayoutText(child)->isTextFragment()) |
| 188 continue; | 188 continue; |
| 189 LayoutTextFragmentItem childFragment = LayoutTextFragmentItem(toLayoutTe
xtFragment(child)); | 189 LayoutTextFragmentItem childFragment = LayoutTextFragmentItem(toLayoutTe
xtFragment(child)); |
| 190 if (childFragment.firstLetterPseudoElement() != this) | 190 if (childFragment.firstLetterPseudoElement() != this) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 m_remainingTextLayoutObject->setFirstLetterPseudoElement(nullptr); | 228 m_remainingTextLayoutObject->setFirstLetterPseudoElement(nullptr); |
| 229 m_remainingTextLayoutObject->setIsRemainingTextLayoutObject(false); | 229 m_remainingTextLayoutObject->setIsRemainingTextLayoutObject(false); |
| 230 } | 230 } |
| 231 m_remainingTextLayoutObject = nullptr; | 231 m_remainingTextLayoutObject = nullptr; |
| 232 | 232 |
| 233 PseudoElement::detach(context); | 233 PseudoElement::detach(context); |
| 234 } | 234 } |
| 235 | 235 |
| 236 ComputedStyle* FirstLetterPseudoElement::styleForFirstLetter(LayoutObject* layou
tObjectContainer) | 236 ComputedStyle* FirstLetterPseudoElement::styleForFirstLetter(LayoutObject* layou
tObjectContainer) |
| 237 { | 237 { |
| 238 ASSERT(layoutObjectContainer); | 238 DCHECK(layoutObjectContainer); |
| 239 | 239 |
| 240 LayoutObject* styleContainer = parentOrShadowHostElement()->layoutObject(); | 240 LayoutObject* styleContainer = parentOrShadowHostElement()->layoutObject(); |
| 241 ASSERT(styleContainer); | 241 DCHECK(styleContainer); |
| 242 | 242 |
| 243 // We always force the pseudo style to recompute as the first-letter style | 243 // We always force the pseudo style to recompute as the first-letter style |
| 244 // computed by the style container may not have taken the layoutObjects styl
es | 244 // computed by the style container may not have taken the layoutObjects styl
es |
| 245 // into account. | 245 // into account. |
| 246 styleContainer->mutableStyle()->removeCachedPseudoStyle(PseudoIdFirstLetter)
; | 246 styleContainer->mutableStyle()->removeCachedPseudoStyle(PseudoIdFirstLetter)
; |
| 247 | 247 |
| 248 ComputedStyle* pseudoStyle = styleContainer->getCachedPseudoStyle(PseudoIdFi
rstLetter, layoutObjectContainer->firstLineStyle()); | 248 ComputedStyle* pseudoStyle = styleContainer->getCachedPseudoStyle(PseudoIdFi
rstLetter, layoutObjectContainer->firstLineStyle()); |
| 249 ASSERT(pseudoStyle); | 249 DCHECK(pseudoStyle); |
| 250 | 250 |
| 251 return pseudoStyle; | 251 return pseudoStyle; |
| 252 } | 252 } |
| 253 | 253 |
| 254 void FirstLetterPseudoElement::attachFirstLetterTextLayoutObjects() | 254 void FirstLetterPseudoElement::attachFirstLetterTextLayoutObjects() |
| 255 { | 255 { |
| 256 LayoutObject* nextLayoutObject = FirstLetterPseudoElement::firstLetterTextLa
youtObject(*this); | 256 LayoutObject* nextLayoutObject = FirstLetterPseudoElement::firstLetterTextLa
youtObject(*this); |
| 257 ASSERT(nextLayoutObject); | 257 DCHECK(nextLayoutObject); |
| 258 ASSERT(nextLayoutObject->isText()); | 258 DCHECK(nextLayoutObject->isText()); |
| 259 | 259 |
| 260 // The original string is going to be either a generated content string or a
DOM node's | 260 // The original string is going to be either a generated content string or a
DOM node's |
| 261 // string. We want the original string before it got transformed in case fir
st-letter has | 261 // string. We want the original string before it got transformed in case fir
st-letter has |
| 262 // no text-transform or a different text-transform applied to it. | 262 // no text-transform or a different text-transform applied to it. |
| 263 String oldText = toLayoutText(nextLayoutObject)->isTextFragment() ? toLayout
TextFragment(nextLayoutObject)->completeText() : toLayoutText(nextLayoutObject)-
>originalText(); | 263 String oldText = toLayoutText(nextLayoutObject)->isTextFragment() ? toLayout
TextFragment(nextLayoutObject)->completeText() : toLayoutText(nextLayoutObject)-
>originalText(); |
| 264 ASSERT(oldText.impl()); | 264 DCHECK(oldText.impl()); |
| 265 | 265 |
| 266 ComputedStyle* pseudoStyle = styleForFirstLetter(nextLayoutObject->parent())
; | 266 ComputedStyle* pseudoStyle = styleForFirstLetter(nextLayoutObject->parent())
; |
| 267 layoutObject()->setStyle(pseudoStyle); | 267 layoutObject()->setStyle(pseudoStyle); |
| 268 | 268 |
| 269 // FIXME: This would already have been calculated in firstLetterLayoutObject
. Can we pass the length through? | 269 // FIXME: This would already have been calculated in firstLetterLayoutObject
. Can we pass the length through? |
| 270 unsigned length = FirstLetterPseudoElement::firstLetterLength(oldText); | 270 unsigned length = FirstLetterPseudoElement::firstLetterLength(oldText); |
| 271 | 271 |
| 272 // Construct a text fragment for the text after the first letter. | 272 // Construct a text fragment for the text after the first letter. |
| 273 // This text fragment might be empty. | 273 // This text fragment might be empty. |
| 274 LayoutTextFragment* remainingText = | 274 LayoutTextFragment* remainingText = |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 313 |
| 314 // We only manage the style for the generated content items. | 314 // We only manage the style for the generated content items. |
| 315 if (!child->isText() && !child->isQuote() && !child->isImage()) | 315 if (!child->isText() && !child->isQuote() && !child->isImage()) |
| 316 continue; | 316 continue; |
| 317 | 317 |
| 318 child->setPseudoStyle(layoutObject->mutableStyle()); | 318 child->setPseudoStyle(layoutObject->mutableStyle()); |
| 319 } | 319 } |
| 320 } | 320 } |
| 321 | 321 |
| 322 } // namespace blink | 322 } // namespace blink |
| OLD | NEW |