| 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) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 8 * Copyright (C) 2011 Google Inc. All rights reserved. | 8 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 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 19 matching lines...) Expand all Loading... |
| 30 #include "sky/engine/core/dom/NodeTraversal.h" | 30 #include "sky/engine/core/dom/NodeTraversal.h" |
| 31 #include "sky/engine/core/dom/shadow/ElementShadow.h" | 31 #include "sky/engine/core/dom/shadow/ElementShadow.h" |
| 32 #include "sky/engine/core/dom/shadow/ShadowRoot.h" | 32 #include "sky/engine/core/dom/shadow/ShadowRoot.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 void TreeScopeAdopter::moveTreeToNewScope(Node& root) const | 36 void TreeScopeAdopter::moveTreeToNewScope(Node& root) const |
| 37 { | 37 { |
| 38 ASSERT(needsScopeChange()); | 38 ASSERT(needsScopeChange()); |
| 39 | 39 |
| 40 #if !ENABLE(OILPAN) | |
| 41 oldScope().guardRef(); | 40 oldScope().guardRef(); |
| 42 #endif | |
| 43 | 41 |
| 44 Document& oldDocument = oldScope().document(); | 42 Document& oldDocument = oldScope().document(); |
| 45 Document& newDocument = newScope().document(); | 43 Document& newDocument = newScope().document(); |
| 46 bool willMoveToNewDocument = oldDocument != newDocument; | 44 bool willMoveToNewDocument = oldDocument != newDocument; |
| 47 | 45 |
| 48 for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) { | 46 for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) { |
| 49 updateTreeScope(*node); | 47 updateTreeScope(*node); |
| 50 | 48 |
| 51 if (willMoveToNewDocument) | 49 if (willMoveToNewDocument) |
| 52 moveNodeToNewDocument(*node, oldDocument, newDocument); | 50 moveNodeToNewDocument(*node, oldDocument, newDocument); |
| 53 | 51 |
| 54 if (!node->isElementNode()) | 52 if (!node->isElementNode()) |
| 55 continue; | 53 continue; |
| 56 | 54 |
| 57 for (ShadowRoot* shadow = node->youngestShadowRoot(); shadow; shadow = s
hadow->olderShadowRoot()) { | 55 if (ShadowRoot* shadow = node->shadowRoot()) { |
| 58 shadow->setParentTreeScope(newScope()); | 56 shadow->setParentTreeScope(newScope()); |
| 59 if (willMoveToNewDocument) | 57 if (willMoveToNewDocument) |
| 60 moveTreeToNewDocument(*shadow, oldDocument, newDocument); | 58 moveTreeToNewDocument(*shadow, oldDocument, newDocument); |
| 61 } | 59 } |
| 62 } | 60 } |
| 63 | 61 |
| 64 #if !ENABLE(OILPAN) | |
| 65 oldScope().guardDeref(); | 62 oldScope().guardDeref(); |
| 66 #endif | |
| 67 } | 63 } |
| 68 | 64 |
| 69 void TreeScopeAdopter::moveTreeToNewDocument(Node& root, Document& oldDocument,
Document& newDocument) const | 65 void TreeScopeAdopter::moveTreeToNewDocument(Node& root, Document& oldDocument,
Document& newDocument) const |
| 70 { | 66 { |
| 71 ASSERT(oldDocument != newDocument); | 67 ASSERT(oldDocument != newDocument); |
| 72 for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) { | 68 for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) { |
| 73 moveNodeToNewDocument(*node, oldDocument, newDocument); | 69 moveNodeToNewDocument(*node, oldDocument, newDocument); |
| 74 | 70 |
| 75 for (ShadowRoot* shadow = node->youngestShadowRoot(); shadow; shadow = s
hadow->olderShadowRoot()) | 71 if (ShadowRoot* shadow = node->shadowRoot()) |
| 76 moveTreeToNewDocument(*shadow, oldDocument, newDocument); | 72 moveTreeToNewDocument(*shadow, oldDocument, newDocument); |
| 77 } | 73 } |
| 78 } | 74 } |
| 79 | 75 |
| 80 #if ENABLE(ASSERT) | 76 #if ENABLE(ASSERT) |
| 81 static bool didMoveToNewDocumentWasCalled = false; | 77 static bool didMoveToNewDocumentWasCalled = false; |
| 82 static Document* oldDocumentDidMoveToNewDocumentWasCalledWith = 0; | 78 static Document* oldDocumentDidMoveToNewDocumentWasCalledWith = 0; |
| 83 | 79 |
| 84 void TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(Document& oldDocument
) | 80 void TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(Document& oldDocument
) |
| 85 { | 81 { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 110 #if ENABLE(ASSERT) | 106 #if ENABLE(ASSERT) |
| 111 didMoveToNewDocumentWasCalled = false; | 107 didMoveToNewDocumentWasCalled = false; |
| 112 oldDocumentDidMoveToNewDocumentWasCalledWith = &oldDocument; | 108 oldDocumentDidMoveToNewDocumentWasCalledWith = &oldDocument; |
| 113 #endif | 109 #endif |
| 114 | 110 |
| 115 node.didMoveToNewDocument(oldDocument); | 111 node.didMoveToNewDocument(oldDocument); |
| 116 ASSERT(didMoveToNewDocumentWasCalled); | 112 ASSERT(didMoveToNewDocumentWasCalled); |
| 117 } | 113 } |
| 118 | 114 |
| 119 } | 115 } |
| OLD | NEW |