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

Side by Side Diff: Source/core/dom/DocumentInit.cpp

Issue 132203012: Make Custom Element registration context creation explicit. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Nicer. Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/DocumentInit.h ('k') | Source/core/loader/DocumentLoader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9 * Copyright (C) 2013 Google Inc. All rights reserved. 9 * Copyright (C) 2013 Google Inc. All rights reserved.
10 * 10 *
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 return ownerFrame->document(); 61 return ownerFrame->document();
62 } 62 }
63 63
64 DocumentInit::DocumentInit(const KURL& url, Frame* frame, WeakPtr<Document> cont extDocument, HTMLImport* import) 64 DocumentInit::DocumentInit(const KURL& url, Frame* frame, WeakPtr<Document> cont extDocument, HTMLImport* import)
65 : m_url(url) 65 : m_url(url)
66 , m_frame(frame) 66 , m_frame(frame)
67 , m_parent(parentDocument(frame)) 67 , m_parent(parentDocument(frame))
68 , m_owner(ownerDocument(frame)) 68 , m_owner(ownerDocument(frame))
69 , m_contextDocument(contextDocument) 69 , m_contextDocument(contextDocument)
70 , m_import(import) 70 , m_import(import)
71 , m_createNewRegistrationContext(false)
71 { 72 {
72 } 73 }
73 74
74 DocumentInit::DocumentInit(const DocumentInit& other) 75 DocumentInit::DocumentInit(const DocumentInit& other)
75 : m_url(other.m_url) 76 : m_url(other.m_url)
76 , m_frame(other.m_frame) 77 , m_frame(other.m_frame)
77 , m_parent(other.m_parent) 78 , m_parent(other.m_parent)
78 , m_owner(other.m_owner) 79 , m_owner(other.m_owner)
79 , m_contextDocument(other.m_contextDocument) 80 , m_contextDocument(other.m_contextDocument)
80 , m_import(other.m_import) 81 , m_import(other.m_import)
81 , m_registrationContext(other.m_registrationContext) 82 , m_registrationContext(other.m_registrationContext)
83 , m_createNewRegistrationContext(other.m_createNewRegistrationContext)
82 { 84 {
83 } 85 }
84 86
85 DocumentInit::~DocumentInit() 87 DocumentInit::~DocumentInit()
86 { 88 {
87 } 89 }
88 90
89 bool DocumentInit::shouldSetURL() const 91 bool DocumentInit::shouldSetURL() const
90 { 92 {
91 Frame* frame = frameForSecurityContext(); 93 Frame* frame = frameForSecurityContext();
(...skipping 26 matching lines...) Expand all
118 return frameForSecurityContext()->settings(); 120 return frameForSecurityContext()->settings();
119 } 121 }
120 122
121 KURL DocumentInit::parentBaseURL() const 123 KURL DocumentInit::parentBaseURL() const
122 { 124 {
123 return m_parent->baseURL(); 125 return m_parent->baseURL();
124 } 126 }
125 127
126 DocumentInit& DocumentInit::withRegistrationContext(CustomElementRegistrationCon text* registrationContext) 128 DocumentInit& DocumentInit::withRegistrationContext(CustomElementRegistrationCon text* registrationContext)
127 { 129 {
128 ASSERT(!m_registrationContext); 130 ASSERT(!m_createNewRegistrationContext && !m_registrationContext);
129 m_registrationContext = registrationContext; 131 m_registrationContext = registrationContext;
130 return *this; 132 return *this;
131 } 133 }
132 134
135 DocumentInit& DocumentInit::withNewRegistrationContext()
136 {
137 ASSERT(!m_createNewRegistrationContext && !m_registrationContext);
138 m_createNewRegistrationContext = true;
139 return *this;
140 }
141
133 PassRefPtr<CustomElementRegistrationContext> DocumentInit::registrationContext(D ocument* document) const 142 PassRefPtr<CustomElementRegistrationContext> DocumentInit::registrationContext(D ocument* document) const
134 { 143 {
135 if (!RuntimeEnabledFeatures::customElementsEnabled() && !RuntimeEnabledFeatu res::embedderCustomElementsEnabled()) 144 if (!RuntimeEnabledFeatures::customElementsEnabled() && !RuntimeEnabledFeatu res::embedderCustomElementsEnabled())
136 return 0; 145 return 0;
137 146
138 if (!document->isHTMLDocument() && !document->isXHTMLDocument()) 147 if (!document->isHTMLDocument() && !document->isXHTMLDocument())
139 return 0; 148 return 0;
140 149
141 if (m_registrationContext) 150 if (m_createNewRegistrationContext)
142 return m_registrationContext.get(); 151 return CustomElementRegistrationContext::create();
143 152
144 return CustomElementRegistrationContext::create(); 153 return m_registrationContext.get();
145 } 154 }
146 155
147 WeakPtr<Document> DocumentInit::contextDocument() const 156 WeakPtr<Document> DocumentInit::contextDocument() const
148 { 157 {
149 return m_contextDocument; 158 return m_contextDocument;
150 } 159 }
151 160
152 DocumentInit DocumentInit::fromContext(WeakPtr<Document> contextDocument, const KURL& url) 161 DocumentInit DocumentInit::fromContext(WeakPtr<Document> contextDocument, const KURL& url)
153 { 162 {
154 return DocumentInit(url, 0, contextDocument, 0); 163 return DocumentInit(url, 0, contextDocument, 0);
155 } 164 }
156 165
157 } // namespace WebCore 166 } // namespace WebCore
158 167
OLDNEW
« no previous file with comments | « Source/core/dom/DocumentInit.h ('k') | Source/core/loader/DocumentLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698