Chromium Code Reviews| Index: Source/core/dom/Document.cpp |
| diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
| index b175d3a412944ee45a21556dfd200977daf19a22..8399a4055a1ca3b109b206d9317e81b8be64a502 100644 |
| --- a/Source/core/dom/Document.cpp |
| +++ b/Source/core/dom/Document.cpp |
| @@ -367,7 +367,7 @@ private: |
| } |
| }; |
| -Document::Document(Frame* frame, const KURL& url, DocumentClassFlags documentClasses) |
| +Document::Document(const DocumentInitializer& initializer, DocumentClassFlags documentClasses) |
|
abarth-chromium
2013/07/12 23:32:53
DocumentInitializer -> DocumentInit ?
That name m
|
| : ContainerNode(0, CreateDocument) |
| , TreeScope(this) |
| , m_styleResolverThrowawayTimer(this, &Document::styleResolverThrowawayTimerFired) |
| @@ -377,8 +377,9 @@ Document::Document(Frame* frame, const KURL& url, DocumentClassFlags documentCla |
| , m_needsNotifyRemoveAllPendingStylesheet(false) |
| , m_hasNodesWithPlaceholderStyle(false) |
| , m_pendingSheetLayout(NoLayoutWithPendingSheets) |
| - , m_frame(frame) |
| + , m_frame(initializer.frame()) |
| , m_domWindow(0) |
| + , m_import(initializer.import()) |
| , m_activeParserCount(0) |
| , m_contextFeatures(ContextFeatures::defaultSwitch()) |
| , m_wellFormed(false) |
| @@ -441,7 +442,6 @@ Document::Document(Frame* frame, const KURL& url, DocumentClassFlags documentCla |
| , m_prerenderer(Prerenderer::create(this)) |
| , m_textAutosizer(TextAutosizer::create(this)) |
| , m_pendingTasksTimer(this, &Document::pendingTasksTimerFired) |
| - , m_import(0) |
| , m_scheduledTasksAreSuspended(false) |
| , m_sharedObjectPoolClearTimer(this, &Document::sharedObjectPoolClearTimerFired) |
| #ifndef NDEBUG |
| @@ -469,10 +469,10 @@ Document::Document(Frame* frame, const KURL& url, DocumentClassFlags documentCla |
| // See fast/dom/early-frame-url.html |
| // and fast/dom/location-new-window-no-crash.html, respectively. |
| // FIXME: Can/should we unify this behavior? |
| - if ((m_frame && m_frame->ownerElement()) || !url.isEmpty()) |
| - setURL(url); |
| + if (initializer.shouldSetURL()) |
| + setURL(initializer.url()); |
| - initSecurityContext(); |
| + initSecurityContext(initializer); |
| initDNSPrefetch(); |
| for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); i++) |
| @@ -4184,12 +4184,17 @@ static bool isEligibleForSeamless(Document* parent, Document* child) |
| void Document::initSecurityContext() |
| { |
| + initSecurityContext(DocumentInitializer(m_url, m_frame, m_import)); |
| +} |
| + |
| +void Document::initSecurityContext(const DocumentInitializer& initializer) |
| +{ |
| if (haveInitializedSecurityOrigin()) { |
| ASSERT(securityOrigin()); |
| return; |
| } |
| - if (!m_frame) { |
| + if (!initializer.frame()) { |
| // No source for a security context. |
| // This can occur via document.implementation.createDocument(). |
| m_cookieURL = KURL(ParsedURLString, emptyString()); |
| @@ -4201,11 +4206,11 @@ void Document::initSecurityContext() |
| // In the common case, create the security context from the currently |
| // loading URL with a fresh content security policy. |
| m_cookieURL = m_url; |
| - enforceSandboxFlags(m_frame->loader()->effectiveSandboxFlags()); |
| + enforceSandboxFlags(initializer.sandboxFlags()); |
| setSecurityOrigin(isSandboxed(SandboxOrigin) ? SecurityOrigin::createUnique() : SecurityOrigin::create(m_url)); |
| setContentSecurityPolicy(ContentSecurityPolicy::create(this)); |
| - if (Settings* settings = this->settings()) { |
| + if (Settings* settings = initializer.settings()) { |
| if (!settings->webSecurityEnabled()) { |
| // Web security is turned off. We should let this document access every other document. This is used primary by testing |
| // harnesses for web sites. |
| @@ -4224,7 +4229,7 @@ void Document::initSecurityContext() |
| } |
| Document* parentDocument = ownerElement() ? ownerElement()->document() : 0; |
| - if (parentDocument && m_frame->loader()->shouldTreatURLAsSrcdocDocument(url())) { |
| + if (parentDocument && initializer.shouldTreatURLAsSrcdocDocument()) { |
| m_isSrcdocDocument = true; |
| setBaseURLOverride(parentDocument->baseURL()); |
| } |
| @@ -4239,10 +4244,7 @@ void Document::initSecurityContext() |
| // If we do not obtain a meaningful origin from the URL, then we try to |
| // find one via the frame hierarchy. |
| - Frame* ownerFrame = m_frame->tree()->parent(); |
| - if (!ownerFrame) |
| - ownerFrame = m_frame->loader()->opener(); |
| - |
| + Frame* ownerFrame = initializer.ownerFrame(); |
| if (!ownerFrame) { |
| didFailToInitializeSecurityOrigin(); |
| return; |
| @@ -5118,9 +5120,9 @@ Document* Document::ensureTemplateDocument() |
| return const_cast<Document*>(document); |
| if (isHTMLDocument()) |
| - m_templateDocument = HTMLDocument::create(0, blankURL()); |
| + m_templateDocument = HTMLDocument::create(DocumentInitializer(blankURL())); |
| else |
| - m_templateDocument = Document::create(0, blankURL()); |
| + m_templateDocument = Document::create(DocumentInitializer(blankURL())); |
| m_templateDocument->setTemplateDocumentHost(this); // balanced in dtor. |