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

Side by Side Diff: third_party/WebKit/Source/core/dom/Text.cpp

Issue 2450093005: Support display: contents for elements, first-line and first-letter pseudos. (Closed)
Patch Set: Support display: contents for elements, first-line and first-letter pseudos. Created 4 years, 1 month 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
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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
5 * reserved. 5 * reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 if (isSVGText(this)) 343 if (isSVGText(this))
344 return new LayoutSVGInlineText(this, dataImpl()); 344 return new LayoutSVGInlineText(this, dataImpl());
345 345
346 if (style.hasTextCombine()) 346 if (style.hasTextCombine())
347 return new LayoutTextCombine(this, dataImpl()); 347 return new LayoutTextCombine(this, dataImpl());
348 348
349 return new LayoutText(this, dataImpl()); 349 return new LayoutText(this, dataImpl());
350 } 350 }
351 351
352 void Text::attachLayoutTree(const AttachContext& context) { 352 void Text::attachLayoutTree(const AttachContext& context) {
353 if (ContainerNode* layoutParent = LayoutTreeBuilderTraversal::parent(*this)) { 353 ContainerNode* styleParent = LayoutTreeBuilderTraversal::parent(*this);
354 if (LayoutObject* parentLayoutObject = layoutParent->layoutObject()) { 354 LayoutObject* parentLayoutObject =
355 if (textLayoutObjectIsNeeded(*parentLayoutObject->style(), 355 LayoutTreeBuilderTraversal::parentLayoutObject(*this);
356 *parentLayoutObject)) 356
357 LayoutTreeBuilderForText(*this, parentLayoutObject) 357 if (styleParent && parentLayoutObject) {
358 .createLayoutObject(); 358 DCHECK(styleParent->computedStyle());
359 if (textLayoutObjectIsNeeded(*styleParent->computedStyle(),
360 *parentLayoutObject)) {
361 LayoutTreeBuilderForText(*this, parentLayoutObject,
362 styleParent->mutableComputedStyle())
363 .createLayoutObject();
359 } 364 }
360 } 365 }
361 CharacterData::attachLayoutTree(context); 366 CharacterData::attachLayoutTree(context);
362 } 367 }
363 368
364 void Text::reattachLayoutTreeIfNeeded(const AttachContext& context) { 369 void Text::reattachLayoutTreeIfNeeded(const AttachContext& context) {
365 bool layoutObjectIsNeeded = false; 370 bool layoutObjectIsNeeded = false;
366 ContainerNode* layoutParent = LayoutTreeBuilderTraversal::parent(*this); 371 ContainerNode* styleParent = LayoutTreeBuilderTraversal::parent(*this);
367 if (layoutParent) { 372 LayoutObject* parentLayoutObject =
368 if (LayoutObject* parentLayoutObject = layoutParent->layoutObject()) { 373 LayoutTreeBuilderTraversal::parentLayoutObject(*this);
369 if (textLayoutObjectIsNeeded(*parentLayoutObject->style(), 374 if (styleParent && parentLayoutObject) {
370 *parentLayoutObject)) 375 layoutObjectIsNeeded = textLayoutObjectIsNeeded(
371 layoutObjectIsNeeded = true; 376 *styleParent->computedStyle(), *parentLayoutObject);
372 }
373 } 377 }
374 378
375 if (layoutObjectIsNeeded == !!layoutObject()) 379 if (layoutObjectIsNeeded == !!layoutObject())
376 return; 380 return;
377 381
378 // The following is almost the same as Node::reattachLayoutTree() except that 382 // The following is almost the same as Node::reattachLayoutTree() except that
379 // we create a layoutObject only if needed. Not calling reattachLayoutTree() 383 // we create a layoutObject only if needed. Not calling reattachLayoutTree()
380 // to avoid repeated calls to Text::textLayoutObjectIsNeeded(). 384 // to avoid repeated calls to Text::textLayoutObjectIsNeeded().
381 AttachContext reattachContext(context); 385 AttachContext reattachContext(context);
382 reattachContext.performingReattach = true; 386 reattachContext.performingReattach = true;
383 387
384 if (getStyleChangeType() < NeedsReattachStyleChange) 388 if (getStyleChangeType() < NeedsReattachStyleChange)
385 detachLayoutTree(reattachContext); 389 detachLayoutTree(reattachContext);
386 if (layoutObjectIsNeeded) 390 if (layoutObjectIsNeeded) {
387 LayoutTreeBuilderForText(*this, layoutParent->layoutObject()) 391 LayoutTreeBuilderForText(*this, parentLayoutObject,
392 styleParent->mutableComputedStyle())
388 .createLayoutObject(); 393 .createLayoutObject();
394 }
389 CharacterData::attachLayoutTree(reattachContext); 395 CharacterData::attachLayoutTree(reattachContext);
390 } 396 }
391 397
392 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) { 398 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) {
393 if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) { 399 if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) {
394 if (change != NoChange || needsStyleRecalc()) 400 if (change != NoChange || needsStyleRecalc())
395 layoutItem.setStyle(document().ensureStyleResolver().styleForText(this)); 401 layoutItem.setStyle(document().ensureStyleResolver().styleForText(this));
396 if (needsStyleRecalc()) 402 if (needsStyleRecalc())
397 layoutItem.setText(dataImpl()); 403 layoutItem.setText(dataImpl());
398 clearNeedsStyleRecalc(); 404 clearNeedsStyleRecalc();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 452
447 Text* Text::cloneWithData(const String& data) { 453 Text* Text::cloneWithData(const String& data) {
448 return create(document(), data); 454 return create(document(), data);
449 } 455 }
450 456
451 DEFINE_TRACE(Text) { 457 DEFINE_TRACE(Text) {
452 CharacterData::trace(visitor); 458 CharacterData::trace(visitor);
453 } 459 }
454 460
455 } // namespace blink 461 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698