Chromium Code Reviews| 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) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. |
| 7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 #include "wtf/text/WTFString.h" | 89 #include "wtf/text/WTFString.h" |
| 90 #include <algorithm> | 90 #include <algorithm> |
| 91 #ifndef NDEBUG | 91 #ifndef NDEBUG |
| 92 #include <stdio.h> | 92 #include <stdio.h> |
| 93 #endif | 93 #endif |
| 94 | 94 |
| 95 using namespace std; | 95 using namespace std; |
| 96 | 96 |
| 97 namespace WebCore { | 97 namespace WebCore { |
| 98 | 98 |
| 99 namespace { | |
| 100 | |
| 101 static RenderObjectLifecycleMode gRenderObjectLifecycleMode = RenderObjectLifecy cleUpdatesOnlyInRecalcStyle; | |
| 102 | |
| 103 } // namespace | |
| 104 | |
| 99 using namespace HTMLNames; | 105 using namespace HTMLNames; |
| 100 | 106 |
| 101 #ifndef NDEBUG | 107 #ifndef NDEBUG |
| 102 | 108 |
| 103 RenderObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(Rende rObject& renderObject) | 109 RenderObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(Rende rObject& renderObject) |
| 104 : m_renderObject(renderObject) | 110 : m_renderObject(renderObject) |
| 105 , m_preexistingForbidden(m_renderObject.isSetNeedsLayoutForbidden()) | 111 , m_preexistingForbidden(m_renderObject.isSetNeedsLayoutForbidden()) |
| 106 { | 112 { |
| 107 m_renderObject.setNeedsLayoutIsForbidden(true); | 113 m_renderObject.setNeedsLayoutIsForbidden(true); |
| 108 } | 114 } |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 136 } | 142 } |
| 137 | 143 |
| 138 void RenderObject::operator delete(void* ptr) | 144 void RenderObject::operator delete(void* ptr) |
| 139 { | 145 { |
| 140 ASSERT(isMainThread()); | 146 ASSERT(isMainThread()); |
| 141 partitionFree(ptr); | 147 partitionFree(ptr); |
| 142 } | 148 } |
| 143 | 149 |
| 144 RenderObject* RenderObject::createObject(Element* element, RenderStyle* style) | 150 RenderObject* RenderObject::createObject(Element* element, RenderStyle* style) |
| 145 { | 151 { |
| 152 ASSERT(isAllowedToAccessLifecycle(element->document())); | |
| 153 | |
| 146 // Minimal support for content properties replacing an entire element. | 154 // Minimal support for content properties replacing an entire element. |
| 147 // Works only if we have exactly one piece of content and it's a URL. | 155 // Works only if we have exactly one piece of content and it's a URL. |
| 148 // Otherwise acts as if we didn't support this feature. | 156 // Otherwise acts as if we didn't support this feature. |
| 149 const ContentData* contentData = style->contentData(); | 157 const ContentData* contentData = style->contentData(); |
| 150 if (contentData && !contentData->next() && contentData->isImage() && !elemen t->isPseudoElement()) { | 158 if (contentData && !contentData->next() && contentData->isImage() && !elemen t->isPseudoElement()) { |
| 151 RenderImage* image = new RenderImage(element); | 159 RenderImage* image = new RenderImage(element); |
| 152 // RenderImageResourceStyleImage requires a style being present on the i mage but we don't want to | 160 // RenderImageResourceStyleImage requires a style being present on the i mage but we don't want to |
| 153 // trigger a style change now as the node is not fully attached. Moving this code to style change | 161 // trigger a style change now as the node is not fully attached. Moving this code to style change |
| 154 // doesn't make sense as it should be run once at renderer creation. | 162 // doesn't make sense as it should be run once at renderer creation. |
| 155 image->setStyleInternal(style); | 163 image->setStyleInternal(style); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 return !isTable(); | 297 return !isTable(); |
| 290 else if (newChild->isTableRow()) | 298 else if (newChild->isTableRow()) |
| 291 return !isTableSection(); | 299 return !isTableSection(); |
| 292 else if (newChild->isTableCell()) | 300 else if (newChild->isTableCell()) |
| 293 return !isTableRow(); | 301 return !isTableRow(); |
| 294 return false; | 302 return false; |
| 295 } | 303 } |
| 296 | 304 |
| 297 void RenderObject::addChild(RenderObject* newChild, RenderObject* beforeChild) | 305 void RenderObject::addChild(RenderObject* newChild, RenderObject* beforeChild) |
| 298 { | 306 { |
| 307 ASSERT(isAllowedToAccessLifecycle(document())); | |
| 308 | |
| 299 RenderObjectChildList* children = virtualChildren(); | 309 RenderObjectChildList* children = virtualChildren(); |
| 300 ASSERT(children); | 310 ASSERT(children); |
| 301 if (!children) | 311 if (!children) |
| 302 return; | 312 return; |
| 303 | 313 |
| 304 if (requiresAnonymousTableWrappers(newChild)) { | 314 if (requiresAnonymousTableWrappers(newChild)) { |
| 305 // Generate an anonymous table or reuse existing one from previous child | 315 // Generate an anonymous table or reuse existing one from previous child |
| 306 // Per: 17.2.1 Anonymous table objects 3. Generate missing parents | 316 // Per: 17.2.1 Anonymous table objects 3. Generate missing parents |
| 307 // http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes | 317 // http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes |
| 308 RenderTable* table; | 318 RenderTable* table; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 327 // - when the document is painted, both layers are painted. The <body> layer doesn't | 337 // - when the document is painted, both layers are painted. The <body> layer doesn't |
| 328 // know that it's inside a "hidden SVG subtree", and thus paints, even if it shouldn't. | 338 // know that it's inside a "hidden SVG subtree", and thus paints, even if it shouldn't. |
| 329 // To avoid the problem alltogether, detect early if we're inside a hidden S VG subtree | 339 // To avoid the problem alltogether, detect early if we're inside a hidden S VG subtree |
| 330 // and stop creating layers at all for these cases - they're not used anyway s. | 340 // and stop creating layers at all for these cases - they're not used anyway s. |
| 331 if (newChild->hasLayer() && !layerCreationAllowedForSubtree()) | 341 if (newChild->hasLayer() && !layerCreationAllowedForSubtree()) |
| 332 toRenderLayerModelObject(newChild)->layer()->removeOnlyThisLayer(); | 342 toRenderLayerModelObject(newChild)->layer()->removeOnlyThisLayer(); |
| 333 } | 343 } |
| 334 | 344 |
| 335 void RenderObject::removeChild(RenderObject* oldChild) | 345 void RenderObject::removeChild(RenderObject* oldChild) |
| 336 { | 346 { |
| 347 ASSERT(isAllowedToAccessLifecycle(document()) || document().lifecycle().stat e() >= DocumentLifecycle::Stopping); | |
|
ojan
2014/05/06 05:51:10
I think in the end we want to remove the >= Stoppi
dsinclair
2014/05/06 15:55:49
Done.
This ended up being covered by the disabler
| |
| 348 | |
| 337 RenderObjectChildList* children = virtualChildren(); | 349 RenderObjectChildList* children = virtualChildren(); |
| 338 ASSERT(children); | 350 ASSERT(children); |
| 339 if (!children) | 351 if (!children) |
| 340 return; | 352 return; |
| 341 | 353 |
| 342 children->removeChildNode(this, oldChild); | 354 children->removeChildNode(this, oldChild); |
| 343 } | 355 } |
| 344 | 356 |
| 345 RenderObject* RenderObject::nextInPreOrder() const | 357 RenderObject* RenderObject::nextInPreOrder() const |
| 346 { | 358 { |
| (...skipping 2409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2756 if (const RenderObjectChildList* children = virtualChildren()) { | 2768 if (const RenderObjectChildList* children = virtualChildren()) { |
| 2757 for (RenderObject* child = children->firstChild(); child; child = child- >nextSibling()) | 2769 for (RenderObject* child = children->firstChild(); child; child = child- >nextSibling()) |
| 2758 child->removeFromRenderFlowThreadRecursive(renderFlowThread); | 2770 child->removeFromRenderFlowThreadRecursive(renderFlowThread); |
| 2759 } | 2771 } |
| 2760 | 2772 |
| 2761 setFlowThreadState(NotInsideFlowThread); | 2773 setFlowThreadState(NotInsideFlowThread); |
| 2762 } | 2774 } |
| 2763 | 2775 |
| 2764 void RenderObject::destroyAndCleanupAnonymousWrappers() | 2776 void RenderObject::destroyAndCleanupAnonymousWrappers() |
| 2765 { | 2777 { |
| 2778 DisableRenderObjectLifecycleAsserts disabler; | |
| 2779 | |
| 2766 // If the tree is destroyed, there is no need for a clean-up phase. | 2780 // If the tree is destroyed, there is no need for a clean-up phase. |
| 2767 if (documentBeingDestroyed()) { | 2781 if (documentBeingDestroyed()) { |
| 2768 destroy(); | 2782 destroy(); |
| 2769 return; | 2783 return; |
| 2770 } | 2784 } |
| 2771 | 2785 |
| 2772 RenderObject* destroyRoot = this; | 2786 RenderObject* destroyRoot = this; |
| 2773 for (RenderObject* destroyRootParent = destroyRoot->parent(); destroyRootPar ent && destroyRootParent->isAnonymous(); destroyRoot = destroyRootParent, destro yRootParent = destroyRootParent->parent()) { | 2787 for (RenderObject* destroyRootParent = destroyRoot->parent(); destroyRootPar ent && destroyRootParent->isAnonymous(); destroyRoot = destroyRootParent, destro yRootParent = destroyRootParent->parent()) { |
| 2774 // Anonymous block continuations are tracked and destroyed elsewhere (se e the bottom of RenderBlock::removeChild) | 2788 // Anonymous block continuations are tracked and destroyed elsewhere (se e the bottom of RenderBlock::removeChild) |
| 2775 if (destroyRootParent->isRenderBlock() && toRenderBlock(destroyRootParen t)->isAnonymousBlockContinuation()) | 2789 if (destroyRootParent->isRenderBlock() && toRenderBlock(destroyRootParen t)->isAnonymousBlockContinuation()) |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3403 | 3417 |
| 3404 void RenderObject::clearRepaintState() | 3418 void RenderObject::clearRepaintState() |
| 3405 { | 3419 { |
| 3406 setShouldDoFullRepaintAfterLayout(false); | 3420 setShouldDoFullRepaintAfterLayout(false); |
| 3407 setShouldDoFullRepaintIfSelfPaintingLayer(false); | 3421 setShouldDoFullRepaintIfSelfPaintingLayer(false); |
| 3408 setShouldRepaintOverflow(false); | 3422 setShouldRepaintOverflow(false); |
| 3409 setLayoutDidGetCalled(false); | 3423 setLayoutDidGetCalled(false); |
| 3410 setMayNeedInvalidation(false); | 3424 setMayNeedInvalidation(false); |
| 3411 } | 3425 } |
| 3412 | 3426 |
| 3427 bool RenderObject::isAllowedToAccessLifecycle(Document& document) | |
|
ojan
2014/05/06 05:48:17
This name is a bit funny. I might call it somethin
dsinclair
2014/05/06 15:55:49
Done.
Thanks, I couldn't think of anything good.
| |
| 3428 { | |
| 3429 if (gRenderObjectLifecycleMode == RenderObjectLifecycleUpdatesAnyState) | |
| 3430 return true; | |
| 3431 return document.lifecycle().state() == DocumentLifecycle::InStyleRecalc; | |
| 3432 } | |
| 3433 | |
| 3434 DisableRenderObjectLifecycleAsserts::DisableRenderObjectLifecycleAsserts() | |
| 3435 : m_disabler(gRenderObjectLifecycleMode, RenderObjectLifecycleUpdatesAnyStat e) { } | |
| 3436 | |
| 3413 } // namespace WebCore | 3437 } // namespace WebCore |
| 3414 | 3438 |
| 3415 #ifndef NDEBUG | 3439 #ifndef NDEBUG |
| 3416 | 3440 |
| 3417 void showTree(const WebCore::RenderObject* object) | 3441 void showTree(const WebCore::RenderObject* object) |
| 3418 { | 3442 { |
| 3419 if (object) | 3443 if (object) |
| 3420 object->showTreeForThis(); | 3444 object->showTreeForThis(); |
| 3421 } | 3445 } |
| 3422 | 3446 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 3435 { | 3459 { |
| 3436 if (object1) { | 3460 if (object1) { |
| 3437 const WebCore::RenderObject* root = object1; | 3461 const WebCore::RenderObject* root = object1; |
| 3438 while (root->parent()) | 3462 while (root->parent()) |
| 3439 root = root->parent(); | 3463 root = root->parent(); |
| 3440 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3464 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
| 3441 } | 3465 } |
| 3442 } | 3466 } |
| 3443 | 3467 |
| 3444 #endif | 3468 #endif |
| OLD | NEW |