Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: third_party/WebKit/Source/core/dom/custom/CustomElementCreationScope.h

Issue 2279703002: Add a scoped context object for synchronous CE creation (Closed)
Patch Set: Clean up Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/custom/CustomElementCreationScope.h
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementCreationScope.h b/third_party/WebKit/Source/core/dom/custom/CustomElementCreationScope.h
new file mode 100644
index 0000000000000000000000000000000000000000..d8f2dbd120ef60530bc7804f55c7054b7d073412
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementCreationScope.h
@@ -0,0 +1,40 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CustomElementCreationScope_h
+#define CustomElementCreationScope_h
+
+#include "core/frame/LocalDOMWindow.h"
+#include "platform/heap/Handle.h"
+
+namespace blink {
+
+class Document;
+
+class CustomElementCreationScope {
+ STACK_ALLOCATED();
+public:
+ explicit CustomElementCreationScope(Document* document)
+ : m_document(document)
+ {
+ if (LocalDOMWindow* window = m_document->executingWindow()) {
+ m_prev = window->customElementCreationContext();
+ window->setCustomElementCreationContext(m_document);
+ }
+ }
+
+ ~CustomElementCreationScope()
+ {
+ if (LocalDOMWindow* window = m_document->executingWindow())
+ window->setCustomElementCreationContext(m_prev);
+ }
+
+private:
+ Member<Document> m_document;
+ Member<Document> m_prev = nullptr;
+};
+
+} // namespace blink
+
+#endif // CustomElementCreationScope_h
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/frame/LocalDOMWindow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698