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 3057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3404 void RenderObject::clearRepaintState() | 3416 void RenderObject::clearRepaintState() |
3405 { | 3417 { |
3406 setShouldDoFullRepaintAfterLayout(false); | 3418 setShouldDoFullRepaintAfterLayout(false); |
3407 setShouldDoFullRepaintIfSelfPaintingLayer(false); | 3419 setShouldDoFullRepaintIfSelfPaintingLayer(false); |
3408 setOnlyNeededPositionedMovementLayout(false); | 3420 setOnlyNeededPositionedMovementLayout(false); |
3409 setShouldRepaintOverflow(false); | 3421 setShouldRepaintOverflow(false); |
3410 setLayoutDidGetCalled(false); | 3422 setLayoutDidGetCalled(false); |
3411 setMayNeedInvalidation(false); | 3423 setMayNeedInvalidation(false); |
3412 } | 3424 } |
3413 | 3425 |
3426 bool RenderObject::isAllowedToModifyRenderTreeStructure(Document& document) | |
3427 { | |
3428 return DeprecatedDisableModifyRenderTreeStructureAsserts::canModifyRenderTre eStateInAnyState() | |
3429 || document.lifecycle().stateAllowsRenderTreeMutations(); | |
3430 } | |
3431 | |
3432 DeprecatedDisableModifyRenderTreeStructureAsserts::DeprecatedDisableModifyRender TreeStructureAsserts() | |
3433 : m_disabler(gModifyRenderTreeStructureAnyState, true) { } | |
esprehn
2014/05/08 05:41:25
These braces are placed wrong.
dsinclair
2014/05/08 19:32:11
Done.
| |
3434 | |
3435 bool DeprecatedDisableModifyRenderTreeStructureAsserts::canModifyRenderTreeState InAnyState() | |
3436 { | |
3437 return gModifyRenderTreeStructureAnyState; | |
3438 } | |
3439 | |
3414 } // namespace WebCore | 3440 } // namespace WebCore |
3415 | 3441 |
3416 #ifndef NDEBUG | 3442 #ifndef NDEBUG |
3417 | 3443 |
3418 void showTree(const WebCore::RenderObject* object) | 3444 void showTree(const WebCore::RenderObject* object) |
3419 { | 3445 { |
3420 if (object) | 3446 if (object) |
3421 object->showTreeForThis(); | 3447 object->showTreeForThis(); |
3422 } | 3448 } |
3423 | 3449 |
(...skipping 12 matching lines...) Expand all Loading... | |
3436 { | 3462 { |
3437 if (object1) { | 3463 if (object1) { |
3438 const WebCore::RenderObject* root = object1; | 3464 const WebCore::RenderObject* root = object1; |
3439 while (root->parent()) | 3465 while (root->parent()) |
3440 root = root->parent(); | 3466 root = root->parent(); |
3441 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3467 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
3442 } | 3468 } |
3443 } | 3469 } |
3444 | 3470 |
3445 #endif | 3471 #endif |
OLD | NEW |