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 bool gModifyRenderTreeStructureAnyState = false; | |
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(isAllowedToModifyRenderTreeStructure(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(isAllowedToModifyRenderTreeStructure(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(isAllowedToModifyRenderTreeStructure(document())); | |
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 // FIXME: We should not modify the structure of the render tree during | |
2779 // layout. crbug.com/370463 | |
2780 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; | |
eseidel
2014/05/07 16:48:22
It seems like the bug talked about moving this up
dsinclair
2014/05/07 20:32:34
Done.
I kept the fixme over the move as it sounds
| |
2781 | |
2766 // If the tree is destroyed, there is no need for a clean-up phase. | 2782 // If the tree is destroyed, there is no need for a clean-up phase. |
2767 if (documentBeingDestroyed()) { | 2783 if (documentBeingDestroyed()) { |
2768 destroy(); | 2784 destroy(); |
2769 return; | 2785 return; |
2770 } | 2786 } |
2771 | 2787 |
2772 RenderObject* destroyRoot = this; | 2788 RenderObject* destroyRoot = this; |
2773 for (RenderObject* destroyRootParent = destroyRoot->parent(); destroyRootPar ent && destroyRootParent->isAnonymous(); destroyRoot = destroyRootParent, destro yRootParent = destroyRootParent->parent()) { | 2789 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) | 2790 // Anonymous block continuations are tracked and destroyed elsewhere (se e the bottom of RenderBlock::removeChild) |
2775 if (destroyRootParent->isRenderBlock() && toRenderBlock(destroyRootParen t)->isAnonymousBlockContinuation()) | 2791 if (destroyRootParent->isRenderBlock() && toRenderBlock(destroyRootParen t)->isAnonymousBlockContinuation()) |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3404 void RenderObject::clearRepaintState() | 3420 void RenderObject::clearRepaintState() |
3405 { | 3421 { |
3406 setShouldDoFullRepaintAfterLayout(false); | 3422 setShouldDoFullRepaintAfterLayout(false); |
3407 setShouldDoFullRepaintIfSelfPaintingLayer(false); | 3423 setShouldDoFullRepaintIfSelfPaintingLayer(false); |
3408 setOnlyNeededPositionedMovementLayout(false); | 3424 setOnlyNeededPositionedMovementLayout(false); |
3409 setShouldRepaintOverflow(false); | 3425 setShouldRepaintOverflow(false); |
3410 setLayoutDidGetCalled(false); | 3426 setLayoutDidGetCalled(false); |
3411 setMayNeedInvalidation(false); | 3427 setMayNeedInvalidation(false); |
3412 } | 3428 } |
3413 | 3429 |
3430 bool RenderObject::isAllowedToModifyRenderTreeStructure(Document& document) | |
3431 { | |
3432 return DeprecatedDisableModifyRenderTreeStructureAsserts::canModifyRenderTre eStateInAnyState() | |
3433 || document.lifecycle().stateAllowsRenderTreeMutations(); | |
3434 } | |
3435 | |
3436 DeprecatedDisableModifyRenderTreeStructureAsserts::DeprecatedDisableModifyRender TreeStructureAsserts() | |
3437 : m_disabler(gModifyRenderTreeStructureAnyState, true) { } | |
3438 | |
3439 bool DeprecatedDisableModifyRenderTreeStructureAsserts::canModifyRenderTreeState InAnyState() | |
3440 { | |
3441 return gModifyRenderTreeStructureAnyState; | |
3442 } | |
3443 | |
3414 } // namespace WebCore | 3444 } // namespace WebCore |
3415 | 3445 |
3416 #ifndef NDEBUG | 3446 #ifndef NDEBUG |
3417 | 3447 |
3418 void showTree(const WebCore::RenderObject* object) | 3448 void showTree(const WebCore::RenderObject* object) |
3419 { | 3449 { |
3420 if (object) | 3450 if (object) |
3421 object->showTreeForThis(); | 3451 object->showTreeForThis(); |
3422 } | 3452 } |
3423 | 3453 |
(...skipping 12 matching lines...) Expand all Loading... | |
3436 { | 3466 { |
3437 if (object1) { | 3467 if (object1) { |
3438 const WebCore::RenderObject* root = object1; | 3468 const WebCore::RenderObject* root = object1; |
3439 while (root->parent()) | 3469 while (root->parent()) |
3440 root = root->parent(); | 3470 root = root->parent(); |
3441 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3471 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
3442 } | 3472 } |
3443 } | 3473 } |
3444 | 3474 |
3445 #endif | 3475 #endif |
OLD | NEW |