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 * 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 if (isSVGText(this)) | 339 if (isSVGText(this)) |
340 return new LayoutSVGInlineText(this, dataImpl()); | 340 return new LayoutSVGInlineText(this, dataImpl()); |
341 | 341 |
342 if (style.hasTextCombine()) | 342 if (style.hasTextCombine()) |
343 return new LayoutTextCombine(this, dataImpl()); | 343 return new LayoutTextCombine(this, dataImpl()); |
344 | 344 |
345 return new LayoutText(this, dataImpl()); | 345 return new LayoutText(this, dataImpl()); |
346 } | 346 } |
347 | 347 |
348 void Text::attachLayoutTree(const AttachContext& context) { | 348 void Text::attachLayoutTree(const AttachContext& context) { |
349 if (ContainerNode* layoutParent = LayoutTreeBuilderTraversal::parent(*this)) { | 349 ContainerNode* styleParent = LayoutTreeBuilderTraversal::parent(*this); |
350 if (LayoutObject* parentLayoutObject = layoutParent->layoutObject()) { | 350 LayoutObject* parentLayoutObject = |
351 if (textLayoutObjectIsNeeded(*parentLayoutObject->style(), | 351 LayoutTreeBuilderTraversal::parentLayoutObject(*this); |
352 *parentLayoutObject)) | 352 |
353 LayoutTreeBuilderForText(*this, parentLayoutObject) | 353 if (styleParent && parentLayoutObject) { |
354 .createLayoutObject(); | 354 DCHECK(styleParent->computedStyle()); |
| 355 if (textLayoutObjectIsNeeded(*styleParent->computedStyle(), |
| 356 *parentLayoutObject)) { |
| 357 LayoutTreeBuilderForText(*this, parentLayoutObject, |
| 358 styleParent->mutableComputedStyle()) |
| 359 .createLayoutObject(); |
355 } | 360 } |
356 } | 361 } |
357 CharacterData::attachLayoutTree(context); | 362 CharacterData::attachLayoutTree(context); |
358 } | 363 } |
359 | 364 |
360 void Text::reattachLayoutTreeIfNeeded(const AttachContext& context) { | 365 void Text::reattachLayoutTreeIfNeeded(const AttachContext& context) { |
361 bool layoutObjectIsNeeded = false; | 366 bool layoutObjectIsNeeded = false; |
362 ContainerNode* layoutParent = LayoutTreeBuilderTraversal::parent(*this); | 367 ContainerNode* styleParent = LayoutTreeBuilderTraversal::parent(*this); |
363 if (layoutParent) { | 368 LayoutObject* parentLayoutObject = |
364 if (LayoutObject* parentLayoutObject = layoutParent->layoutObject()) { | 369 LayoutTreeBuilderTraversal::parentLayoutObject(*this); |
365 if (textLayoutObjectIsNeeded(*parentLayoutObject->style(), | 370 if (styleParent && parentLayoutObject) { |
366 *parentLayoutObject)) | 371 DCHECK(styleParent->computedStyle()); |
367 layoutObjectIsNeeded = true; | 372 layoutObjectIsNeeded = textLayoutObjectIsNeeded( |
368 } | 373 *styleParent->computedStyle(), *parentLayoutObject); |
369 } | 374 } |
370 | 375 |
371 if (layoutObjectIsNeeded == !!layoutObject()) | 376 if (layoutObjectIsNeeded == !!layoutObject()) |
372 return; | 377 return; |
373 | 378 |
374 // The following is almost the same as Node::reattachLayoutTree() except that | 379 // The following is almost the same as Node::reattachLayoutTree() except that |
375 // we create a layoutObject only if needed. Not calling reattachLayoutTree() | 380 // we create a layoutObject only if needed. Not calling reattachLayoutTree() |
376 // to avoid repeated calls to Text::textLayoutObjectIsNeeded(). | 381 // to avoid repeated calls to Text::textLayoutObjectIsNeeded(). |
377 AttachContext reattachContext(context); | 382 AttachContext reattachContext(context); |
378 reattachContext.performingReattach = true; | 383 reattachContext.performingReattach = true; |
379 | 384 |
380 if (getStyleChangeType() < NeedsReattachStyleChange) | 385 if (getStyleChangeType() < NeedsReattachStyleChange) |
381 detachLayoutTree(reattachContext); | 386 detachLayoutTree(reattachContext); |
382 if (layoutObjectIsNeeded) | 387 if (layoutObjectIsNeeded) { |
383 LayoutTreeBuilderForText(*this, layoutParent->layoutObject()) | 388 LayoutTreeBuilderForText(*this, parentLayoutObject, |
| 389 styleParent->mutableComputedStyle()) |
384 .createLayoutObject(); | 390 .createLayoutObject(); |
| 391 } |
385 CharacterData::attachLayoutTree(reattachContext); | 392 CharacterData::attachLayoutTree(reattachContext); |
386 } | 393 } |
387 | 394 |
388 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) { | 395 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) { |
389 if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) { | 396 if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) { |
390 if (change != NoChange || needsStyleRecalc()) | 397 if (change != NoChange || needsStyleRecalc()) |
391 layoutItem.setStyle(document().ensureStyleResolver().styleForText(this)); | 398 layoutItem.setStyle(document().ensureStyleResolver().styleForText(this)); |
392 if (needsStyleRecalc()) | 399 if (needsStyleRecalc()) |
393 layoutItem.setText(dataImpl()); | 400 layoutItem.setText(dataImpl()); |
394 clearNeedsStyleRecalc(); | 401 clearNeedsStyleRecalc(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 458 |
452 Text* Text::cloneWithData(const String& data) { | 459 Text* Text::cloneWithData(const String& data) { |
453 return create(document(), data); | 460 return create(document(), data); |
454 } | 461 } |
455 | 462 |
456 DEFINE_TRACE(Text) { | 463 DEFINE_TRACE(Text) { |
457 CharacterData::trace(visitor); | 464 CharacterData::trace(visitor); |
458 } | 465 } |
459 | 466 |
460 } // namespace blink | 467 } // namespace blink |
OLD | NEW |