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

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: Allow text as child of the LayoutView, since it can happen with display: contents Created 4 years 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 DCHECK(styleParent->computedStyle());
371 layoutObjectIsNeeded = true; 376 layoutObjectIsNeeded = textLayoutObjectIsNeeded(
372 } 377 *styleParent->computedStyle(), *parentLayoutObject);
373 } 378 }
374 379
375 if (layoutObjectIsNeeded == !!layoutObject()) 380 if (layoutObjectIsNeeded == !!layoutObject())
376 return; 381 return;
377 382
378 // The following is almost the same as Node::reattachLayoutTree() except that 383 // The following is almost the same as Node::reattachLayoutTree() except that
379 // we create a layoutObject only if needed. Not calling reattachLayoutTree() 384 // we create a layoutObject only if needed. Not calling reattachLayoutTree()
380 // to avoid repeated calls to Text::textLayoutObjectIsNeeded(). 385 // to avoid repeated calls to Text::textLayoutObjectIsNeeded().
381 AttachContext reattachContext(context); 386 AttachContext reattachContext(context);
382 reattachContext.performingReattach = true; 387 reattachContext.performingReattach = true;
383 388
384 if (getStyleChangeType() < NeedsReattachStyleChange) 389 if (getStyleChangeType() < NeedsReattachStyleChange)
385 detachLayoutTree(reattachContext); 390 detachLayoutTree(reattachContext);
386 if (layoutObjectIsNeeded) 391 if (layoutObjectIsNeeded) {
387 LayoutTreeBuilderForText(*this, layoutParent->layoutObject()) 392 LayoutTreeBuilderForText(*this, parentLayoutObject,
393 styleParent->mutableComputedStyle())
388 .createLayoutObject(); 394 .createLayoutObject();
395 }
389 CharacterData::attachLayoutTree(reattachContext); 396 CharacterData::attachLayoutTree(reattachContext);
390 } 397 }
391 398
392 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) { 399 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) {
393 if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) { 400 if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) {
394 if (change != NoChange || needsStyleRecalc()) 401 if (change != NoChange || needsStyleRecalc())
395 layoutItem.setStyle(document().ensureStyleResolver().styleForText(this)); 402 layoutItem.setStyle(document().ensureStyleResolver().styleForText(this));
396 if (needsStyleRecalc()) 403 if (needsStyleRecalc())
397 layoutItem.setText(dataImpl()); 404 layoutItem.setText(dataImpl());
398 clearNeedsStyleRecalc(); 405 clearNeedsStyleRecalc();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 457
451 Text* Text::cloneWithData(const String& data) { 458 Text* Text::cloneWithData(const String& data) {
452 return create(document(), data); 459 return create(document(), data);
453 } 460 }
454 461
455 DEFINE_TRACE(Text) { 462 DEFINE_TRACE(Text) {
456 CharacterData::trace(visitor); 463 CharacterData::trace(visitor);
457 } 464 }
458 465
459 } // namespace blink 466 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698