OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CustomElementCreationScope_h |
| 6 #define CustomElementCreationScope_h |
| 7 |
| 8 #include "core/frame/LocalDOMWindow.h" |
| 9 #include "platform/heap/Handle.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 class Document; |
| 14 |
| 15 class CustomElementCreationScope { |
| 16 STACK_ALLOCATED(); |
| 17 public: |
| 18 explicit CustomElementCreationScope(Document* document) |
| 19 : m_document(document) |
| 20 { |
| 21 if (LocalDOMWindow* window = m_document->executingWindow()) { |
| 22 m_prev = window->customElementCreationContext(); |
| 23 window->setCustomElementCreationContext(m_document); |
| 24 } |
| 25 } |
| 26 |
| 27 ~CustomElementCreationScope() |
| 28 { |
| 29 if (LocalDOMWindow* window = m_document->executingWindow()) |
| 30 window->setCustomElementCreationContext(m_prev); |
| 31 } |
| 32 |
| 33 private: |
| 34 Member<Document> m_document; |
| 35 Member<Document> m_prev = nullptr; |
| 36 }; |
| 37 |
| 38 } // namespace blink |
| 39 |
| 40 #endif // CustomElementCreationScope_h |
OLD | NEW |