Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: Source/core/dom/FirstLetterPseudoElement.cpp

Issue 1033943002: Rename LayoutStyle to papayawhip (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ensureComputedStyle Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/FirstLetterPseudoElement.h ('k') | Source/core/dom/Fullscreen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 m_remainingTextRenderer->setTextFragment(textNode->dataImpl(), 0, te xtNode->dataImpl()->length()); 217 m_remainingTextRenderer->setTextFragment(textNode->dataImpl(), 0, te xtNode->dataImpl()->length());
218 } 218 }
219 m_remainingTextRenderer->setFirstLetterPseudoElement(nullptr); 219 m_remainingTextRenderer->setFirstLetterPseudoElement(nullptr);
220 m_remainingTextRenderer->setIsRemainingTextRenderer(false); 220 m_remainingTextRenderer->setIsRemainingTextRenderer(false);
221 } 221 }
222 m_remainingTextRenderer = nullptr; 222 m_remainingTextRenderer = nullptr;
223 223
224 PseudoElement::detach(context); 224 PseudoElement::detach(context);
225 } 225 }
226 226
227 LayoutStyle* FirstLetterPseudoElement::styleForFirstLetter(LayoutObject* rendere rContainer) 227 ComputedStyle* FirstLetterPseudoElement::styleForFirstLetter(LayoutObject* rende rerContainer)
228 { 228 {
229 ASSERT(rendererContainer); 229 ASSERT(rendererContainer);
230 230
231 LayoutObject* styleContainer = parentOrShadowHostElement()->layoutObject(); 231 LayoutObject* styleContainer = parentOrShadowHostElement()->layoutObject();
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->style()->removeCachedPseudoStyle(FIRST_LETTER);
238 238
239 LayoutStyle* pseudoStyle = styleContainer->getCachedPseudoStyle(FIRST_LETTER , rendererContainer->firstLineStyle()); 239 ComputedStyle* pseudoStyle = styleContainer->getCachedPseudoStyle(FIRST_LETT ER, 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);
248 ASSERT(nextRenderer); 248 ASSERT(nextRenderer);
249 ASSERT(nextRenderer->isText()); 249 ASSERT(nextRenderer->isText());
250 250
251 // The original string is going to be either a generated content string or a DOM node's 251 // The original string is going to be either a generated content string or a DOM node's
252 // string. We want the original string before it got transformed in case fir st-letter has 252 // string. We want the original string before it got transformed in case fir st-letter has
253 // no text-transform or a different text-transform applied to it. 253 // no text-transform or a different text-transform applied to it.
254 String oldText = toLayoutText(nextRenderer)->isTextFragment() ? toLayoutText Fragment(nextRenderer)->completeText() : toLayoutText(nextRenderer)->originalTex t(); 254 String oldText = toLayoutText(nextRenderer)->isTextFragment() ? toLayoutText Fragment(nextRenderer)->completeText() : toLayoutText(nextRenderer)->originalTex t();
255 ASSERT(oldText.impl()); 255 ASSERT(oldText.impl());
256 256
257 LayoutStyle* pseudoStyle = styleForFirstLetter(nextRenderer->parent()); 257 ComputedStyle* pseudoStyle = styleForFirstLetter(nextRenderer->parent());
258 layoutObject()->setStyle(pseudoStyle); 258 layoutObject()->setStyle(pseudoStyle);
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 LayoutTextFragment* remainingText = 265 LayoutTextFragment* remainingText =
266 new LayoutTextFragment(nextRenderer->node() ? nextRenderer->node() : &ne xtRenderer->document(), oldText.impl(), length, oldText.length() - length); 266 new LayoutTextFragment(nextRenderer->node() ? nextRenderer->node() : &ne xtRenderer->document(), oldText.impl(), length, oldText.length() - length);
267 remainingText->setFirstLetterPseudoElement(this); 267 remainingText->setFirstLetterPseudoElement(this);
(...skipping 22 matching lines...) Expand all
290 if (!layoutObject()) 290 if (!layoutObject())
291 return; 291 return;
292 292
293 // The renderers inside pseudo elements are anonymous so they don't get noti fied of recalcStyle and must have 293 // The renderers inside pseudo elements are anonymous so they don't get noti fied of recalcStyle and must have
294 // the style propagated downward manually similar to LayoutObject::propagate StyleToAnonymousChildren. 294 // the style propagated downward manually similar to LayoutObject::propagate StyleToAnonymousChildren.
295 LayoutObject* renderer = this->layoutObject(); 295 LayoutObject* renderer = this->layoutObject();
296 for (LayoutObject* child = renderer->nextInPreOrder(renderer); child; child = child->nextInPreOrder(renderer)) { 296 for (LayoutObject* child = renderer->nextInPreOrder(renderer); child; child = child->nextInPreOrder(renderer)) {
297 // We need to re-calculate the correct style for the first letter elemen t 297 // We need to re-calculate the correct style for the first letter elemen t
298 // and then apply that to the container and the text fragment inside. 298 // and then apply that to the container and the text fragment inside.
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 (ComputedStyle* pseudoStyle = styleForFirstLetter(m_remainingText Renderer->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->style());
310 } 310 }
311 } 311 }
312 312
313 } // namespace blink 313 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/FirstLetterPseudoElement.h ('k') | Source/core/dom/Fullscreen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698