Chromium Code Reviews| 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 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 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) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 return; | 360 return; |
| 361 if (document->childNeedsStyleRecalc()) | 361 if (document->childNeedsStyleRecalc()) |
| 362 return; | 362 return; |
| 363 if (document->focusedNode()->renderer() && document->focusedNode()->rend erer()->needsLayout()) | 363 if (document->focusedNode()->renderer() && document->focusedNode()->rend erer()->needsLayout()) |
| 364 return; | 364 return; |
| 365 if (!document->focusedNode()->isFocusable()) | 365 if (!document->focusedNode()->isFocusable()) |
| 366 document->setFocusedElement(0); | 366 document->setFocusedElement(0); |
| 367 } | 367 } |
| 368 }; | 368 }; |
| 369 | 369 |
| 370 Document::Document(Frame* frame, const KURL& url, DocumentClassFlags documentCla sses) | 370 Document::Document(const DocumentInitializer& initializer, DocumentClassFlags do cumentClasses) |
|
abarth-chromium
2013/07/12 23:32:53
DocumentInitializer -> DocumentInit ?
That name m
| |
| 371 : ContainerNode(0, CreateDocument) | 371 : ContainerNode(0, CreateDocument) |
| 372 , TreeScope(this) | 372 , TreeScope(this) |
| 373 , m_styleResolverThrowawayTimer(this, &Document::styleResolverThrowawayTimer Fired) | 373 , m_styleResolverThrowawayTimer(this, &Document::styleResolverThrowawayTimer Fired) |
| 374 , m_lastStyleResolverAccessTime(0) | 374 , m_lastStyleResolverAccessTime(0) |
| 375 , m_didCalculateStyleResolver(false) | 375 , m_didCalculateStyleResolver(false) |
| 376 , m_ignorePendingStylesheets(false) | 376 , m_ignorePendingStylesheets(false) |
| 377 , m_needsNotifyRemoveAllPendingStylesheet(false) | 377 , m_needsNotifyRemoveAllPendingStylesheet(false) |
| 378 , m_hasNodesWithPlaceholderStyle(false) | 378 , m_hasNodesWithPlaceholderStyle(false) |
| 379 , m_pendingSheetLayout(NoLayoutWithPendingSheets) | 379 , m_pendingSheetLayout(NoLayoutWithPendingSheets) |
| 380 , m_frame(frame) | 380 , m_frame(initializer.frame()) |
| 381 , m_domWindow(0) | 381 , m_domWindow(0) |
| 382 , m_import(initializer.import()) | |
| 382 , m_activeParserCount(0) | 383 , m_activeParserCount(0) |
| 383 , m_contextFeatures(ContextFeatures::defaultSwitch()) | 384 , m_contextFeatures(ContextFeatures::defaultSwitch()) |
| 384 , m_wellFormed(false) | 385 , m_wellFormed(false) |
| 385 , m_printing(false) | 386 , m_printing(false) |
| 386 , m_paginatedForScreen(false) | 387 , m_paginatedForScreen(false) |
| 387 , m_ignoreAutofocus(false) | 388 , m_ignoreAutofocus(false) |
| 388 , m_compatibilityMode(NoQuirksMode) | 389 , m_compatibilityMode(NoQuirksMode) |
| 389 , m_compatibilityModeLocked(false) | 390 , m_compatibilityModeLocked(false) |
| 390 , m_didPostCheckFocusedNodeTask(false) | 391 , m_didPostCheckFocusedNodeTask(false) |
| 391 , m_domTreeVersion(++s_globalTreeVersion) | 392 , m_domTreeVersion(++s_globalTreeVersion) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 , m_referrerPolicy(ReferrerPolicyDefault) | 435 , m_referrerPolicy(ReferrerPolicyDefault) |
| 435 , m_directionSetOnDocumentElement(false) | 436 , m_directionSetOnDocumentElement(false) |
| 436 , m_writingModeSetOnDocumentElement(false) | 437 , m_writingModeSetOnDocumentElement(false) |
| 437 , m_writeRecursionIsTooDeep(false) | 438 , m_writeRecursionIsTooDeep(false) |
| 438 , m_writeRecursionDepth(0) | 439 , m_writeRecursionDepth(0) |
| 439 , m_wheelEventHandlerCount(0) | 440 , m_wheelEventHandlerCount(0) |
| 440 , m_lastHandledUserGestureTimestamp(0) | 441 , m_lastHandledUserGestureTimestamp(0) |
| 441 , m_prerenderer(Prerenderer::create(this)) | 442 , m_prerenderer(Prerenderer::create(this)) |
| 442 , m_textAutosizer(TextAutosizer::create(this)) | 443 , m_textAutosizer(TextAutosizer::create(this)) |
| 443 , m_pendingTasksTimer(this, &Document::pendingTasksTimerFired) | 444 , m_pendingTasksTimer(this, &Document::pendingTasksTimerFired) |
| 444 , m_import(0) | |
| 445 , m_scheduledTasksAreSuspended(false) | 445 , m_scheduledTasksAreSuspended(false) |
| 446 , m_sharedObjectPoolClearTimer(this, &Document::sharedObjectPoolClearTimerFi red) | 446 , m_sharedObjectPoolClearTimer(this, &Document::sharedObjectPoolClearTimerFi red) |
| 447 #ifndef NDEBUG | 447 #ifndef NDEBUG |
| 448 , m_didDispatchViewportPropertiesChanged(false) | 448 , m_didDispatchViewportPropertiesChanged(false) |
| 449 #endif | 449 #endif |
| 450 , m_timeline(DocumentTimeline::create(this)) | 450 , m_timeline(DocumentTimeline::create(this)) |
| 451 , m_templateDocumentHost(0) | 451 , m_templateDocumentHost(0) |
| 452 , m_fontloader(0) | 452 , m_fontloader(0) |
| 453 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired) | 453 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired) |
| 454 { | 454 { |
| 455 ScriptWrappable::init(this); | 455 ScriptWrappable::init(this); |
| 456 | 456 |
| 457 if (m_frame) { | 457 if (m_frame) { |
| 458 provideContextFeaturesToDocumentFrom(this, m_frame->page()); | 458 provideContextFeaturesToDocumentFrom(this, m_frame->page()); |
| 459 | 459 |
| 460 m_cachedResourceLoader = m_frame->loader()->activeDocumentLoader()->cach edResourceLoader(); | 460 m_cachedResourceLoader = m_frame->loader()->activeDocumentLoader()->cach edResourceLoader(); |
| 461 } | 461 } |
| 462 | 462 |
| 463 if (!m_cachedResourceLoader) | 463 if (!m_cachedResourceLoader) |
| 464 m_cachedResourceLoader = CachedResourceLoader::create(0); | 464 m_cachedResourceLoader = CachedResourceLoader::create(0); |
| 465 m_cachedResourceLoader->setDocument(this); | 465 m_cachedResourceLoader->setDocument(this); |
| 466 | 466 |
| 467 // We depend on the url getting immediately set in subframes, but we | 467 // We depend on the url getting immediately set in subframes, but we |
| 468 // also depend on the url NOT getting immediately set in opened windows. | 468 // also depend on the url NOT getting immediately set in opened windows. |
| 469 // See fast/dom/early-frame-url.html | 469 // See fast/dom/early-frame-url.html |
| 470 // and fast/dom/location-new-window-no-crash.html, respectively. | 470 // and fast/dom/location-new-window-no-crash.html, respectively. |
| 471 // FIXME: Can/should we unify this behavior? | 471 // FIXME: Can/should we unify this behavior? |
| 472 if ((m_frame && m_frame->ownerElement()) || !url.isEmpty()) | 472 if (initializer.shouldSetURL()) |
| 473 setURL(url); | 473 setURL(initializer.url()); |
| 474 | 474 |
| 475 initSecurityContext(); | 475 initSecurityContext(initializer); |
| 476 initDNSPrefetch(); | 476 initDNSPrefetch(); |
| 477 | 477 |
| 478 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); i++) | 478 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); i++) |
| 479 m_nodeListCounts[i] = 0; | 479 m_nodeListCounts[i] = 0; |
| 480 | 480 |
| 481 InspectorCounters::incrementCounter(InspectorCounters::DocumentCounter); | 481 InspectorCounters::incrementCounter(InspectorCounters::DocumentCounter); |
| 482 | 482 |
| 483 bool shouldProcessCustomElements = | 483 bool shouldProcessCustomElements = |
| 484 (isHTMLDocument() || isXHTMLDocument()) | 484 (isHTMLDocument() || isXHTMLDocument()) |
| 485 && RuntimeEnabledFeatures::customDOMElementsEnabled(); | 485 && RuntimeEnabledFeatures::customDOMElementsEnabled(); |
| (...skipping 3691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4177 return false; | 4177 return false; |
| 4178 if (child->isSrcdocDocument()) | 4178 if (child->isSrcdocDocument()) |
| 4179 return true; | 4179 return true; |
| 4180 if (parent->securityOrigin()->canAccess(child->securityOrigin())) | 4180 if (parent->securityOrigin()->canAccess(child->securityOrigin())) |
| 4181 return true; | 4181 return true; |
| 4182 return parent->securityOrigin()->canRequest(child->url()); | 4182 return parent->securityOrigin()->canRequest(child->url()); |
| 4183 } | 4183 } |
| 4184 | 4184 |
| 4185 void Document::initSecurityContext() | 4185 void Document::initSecurityContext() |
| 4186 { | 4186 { |
| 4187 initSecurityContext(DocumentInitializer(m_url, m_frame, m_import)); | |
| 4188 } | |
| 4189 | |
| 4190 void Document::initSecurityContext(const DocumentInitializer& initializer) | |
| 4191 { | |
| 4187 if (haveInitializedSecurityOrigin()) { | 4192 if (haveInitializedSecurityOrigin()) { |
| 4188 ASSERT(securityOrigin()); | 4193 ASSERT(securityOrigin()); |
| 4189 return; | 4194 return; |
| 4190 } | 4195 } |
| 4191 | 4196 |
| 4192 if (!m_frame) { | 4197 if (!initializer.frame()) { |
| 4193 // No source for a security context. | 4198 // No source for a security context. |
| 4194 // This can occur via document.implementation.createDocument(). | 4199 // This can occur via document.implementation.createDocument(). |
| 4195 m_cookieURL = KURL(ParsedURLString, emptyString()); | 4200 m_cookieURL = KURL(ParsedURLString, emptyString()); |
| 4196 setSecurityOrigin(SecurityOrigin::createUnique()); | 4201 setSecurityOrigin(SecurityOrigin::createUnique()); |
| 4197 setContentSecurityPolicy(ContentSecurityPolicy::create(this)); | 4202 setContentSecurityPolicy(ContentSecurityPolicy::create(this)); |
| 4198 return; | 4203 return; |
| 4199 } | 4204 } |
| 4200 | 4205 |
| 4201 // In the common case, create the security context from the currently | 4206 // In the common case, create the security context from the currently |
| 4202 // loading URL with a fresh content security policy. | 4207 // loading URL with a fresh content security policy. |
| 4203 m_cookieURL = m_url; | 4208 m_cookieURL = m_url; |
| 4204 enforceSandboxFlags(m_frame->loader()->effectiveSandboxFlags()); | 4209 enforceSandboxFlags(initializer.sandboxFlags()); |
| 4205 setSecurityOrigin(isSandboxed(SandboxOrigin) ? SecurityOrigin::createUnique( ) : SecurityOrigin::create(m_url)); | 4210 setSecurityOrigin(isSandboxed(SandboxOrigin) ? SecurityOrigin::createUnique( ) : SecurityOrigin::create(m_url)); |
| 4206 setContentSecurityPolicy(ContentSecurityPolicy::create(this)); | 4211 setContentSecurityPolicy(ContentSecurityPolicy::create(this)); |
| 4207 | 4212 |
| 4208 if (Settings* settings = this->settings()) { | 4213 if (Settings* settings = initializer.settings()) { |
| 4209 if (!settings->webSecurityEnabled()) { | 4214 if (!settings->webSecurityEnabled()) { |
| 4210 // Web security is turned off. We should let this document access ev ery other document. This is used primary by testing | 4215 // Web security is turned off. We should let this document access ev ery other document. This is used primary by testing |
| 4211 // harnesses for web sites. | 4216 // harnesses for web sites. |
| 4212 securityOrigin()->grantUniversalAccess(); | 4217 securityOrigin()->grantUniversalAccess(); |
| 4213 } else if (securityOrigin()->isLocal()) { | 4218 } else if (securityOrigin()->isLocal()) { |
| 4214 if (settings->allowUniversalAccessFromFileURLs()) { | 4219 if (settings->allowUniversalAccessFromFileURLs()) { |
| 4215 // Some clients want local URLs to have universal access, but th at setting is dangerous for other clients. | 4220 // Some clients want local URLs to have universal access, but th at setting is dangerous for other clients. |
| 4216 securityOrigin()->grantUniversalAccess(); | 4221 securityOrigin()->grantUniversalAccess(); |
| 4217 } else if (!settings->allowFileAccessFromFileURLs()) { | 4222 } else if (!settings->allowFileAccessFromFileURLs()) { |
| 4218 // Some clients want local URLs to have even tighter restriction s by default, and not be able to access other local files. | 4223 // Some clients want local URLs to have even tighter restriction s by default, and not be able to access other local files. |
| 4219 // FIXME 81578: The naming of this is confusing. Files with rest ricted access to other local files | 4224 // FIXME 81578: The naming of this is confusing. Files with rest ricted access to other local files |
| 4220 // still can have other privileges that can be remembered, there by not making them unique origins. | 4225 // still can have other privileges that can be remembered, there by not making them unique origins. |
| 4221 securityOrigin()->enforceFilePathSeparation(); | 4226 securityOrigin()->enforceFilePathSeparation(); |
| 4222 } | 4227 } |
| 4223 } | 4228 } |
| 4224 } | 4229 } |
| 4225 | 4230 |
| 4226 Document* parentDocument = ownerElement() ? ownerElement()->document() : 0; | 4231 Document* parentDocument = ownerElement() ? ownerElement()->document() : 0; |
| 4227 if (parentDocument && m_frame->loader()->shouldTreatURLAsSrcdocDocument(url( ))) { | 4232 if (parentDocument && initializer.shouldTreatURLAsSrcdocDocument()) { |
| 4228 m_isSrcdocDocument = true; | 4233 m_isSrcdocDocument = true; |
| 4229 setBaseURLOverride(parentDocument->baseURL()); | 4234 setBaseURLOverride(parentDocument->baseURL()); |
| 4230 } | 4235 } |
| 4231 | 4236 |
| 4232 // FIXME: What happens if we inherit the security origin? This check may nee d to be later. | 4237 // FIXME: What happens if we inherit the security origin? This check may nee d to be later. |
| 4233 // <iframe seamless src="about:blank"> likely won't work as-is. | 4238 // <iframe seamless src="about:blank"> likely won't work as-is. |
| 4234 m_mayDisplaySeamlesslyWithParent = isEligibleForSeamless(parentDocument, thi s); | 4239 m_mayDisplaySeamlesslyWithParent = isEligibleForSeamless(parentDocument, thi s); |
| 4235 | 4240 |
| 4236 if (!shouldInheritSecurityOriginFromOwner(m_url)) | 4241 if (!shouldInheritSecurityOriginFromOwner(m_url)) |
| 4237 return; | 4242 return; |
| 4238 | 4243 |
| 4239 // If we do not obtain a meaningful origin from the URL, then we try to | 4244 // If we do not obtain a meaningful origin from the URL, then we try to |
| 4240 // find one via the frame hierarchy. | 4245 // find one via the frame hierarchy. |
| 4241 | 4246 |
| 4242 Frame* ownerFrame = m_frame->tree()->parent(); | 4247 Frame* ownerFrame = initializer.ownerFrame(); |
| 4243 if (!ownerFrame) | |
| 4244 ownerFrame = m_frame->loader()->opener(); | |
| 4245 | |
| 4246 if (!ownerFrame) { | 4248 if (!ownerFrame) { |
| 4247 didFailToInitializeSecurityOrigin(); | 4249 didFailToInitializeSecurityOrigin(); |
| 4248 return; | 4250 return; |
| 4249 } | 4251 } |
| 4250 | 4252 |
| 4251 if (isSandboxed(SandboxOrigin)) { | 4253 if (isSandboxed(SandboxOrigin)) { |
| 4252 // If we're supposed to inherit our security origin from our owner, | 4254 // If we're supposed to inherit our security origin from our owner, |
| 4253 // but we're also sandboxed, the only thing we inherit is the ability | 4255 // but we're also sandboxed, the only thing we inherit is the ability |
| 4254 // to load local resources. This lets about:blank iframes in file:// | 4256 // to load local resources. This lets about:blank iframes in file:// |
| 4255 // URL documents load images and other resources from the file system. | 4257 // URL documents load images and other resources from the file system. |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5111 result.iterator->value = Locale::create(localeKey); | 5113 result.iterator->value = Locale::create(localeKey); |
| 5112 return *(result.iterator->value); | 5114 return *(result.iterator->value); |
| 5113 } | 5115 } |
| 5114 | 5116 |
| 5115 Document* Document::ensureTemplateDocument() | 5117 Document* Document::ensureTemplateDocument() |
| 5116 { | 5118 { |
| 5117 if (const Document* document = templateDocument()) | 5119 if (const Document* document = templateDocument()) |
| 5118 return const_cast<Document*>(document); | 5120 return const_cast<Document*>(document); |
| 5119 | 5121 |
| 5120 if (isHTMLDocument()) | 5122 if (isHTMLDocument()) |
| 5121 m_templateDocument = HTMLDocument::create(0, blankURL()); | 5123 m_templateDocument = HTMLDocument::create(DocumentInitializer(blankURL() )); |
| 5122 else | 5124 else |
| 5123 m_templateDocument = Document::create(0, blankURL()); | 5125 m_templateDocument = Document::create(DocumentInitializer(blankURL())); |
| 5124 | 5126 |
| 5125 m_templateDocument->setTemplateDocumentHost(this); // balanced in dtor. | 5127 m_templateDocument->setTemplateDocumentHost(this); // balanced in dtor. |
| 5126 | 5128 |
| 5127 return m_templateDocument.get(); | 5129 return m_templateDocument.get(); |
| 5128 } | 5130 } |
| 5129 | 5131 |
| 5130 PassRefPtr<FontLoader> Document::fontloader() | 5132 PassRefPtr<FontLoader> Document::fontloader() |
| 5131 { | 5133 { |
| 5132 if (!m_fontloader) | 5134 if (!m_fontloader) |
| 5133 m_fontloader = FontLoader::create(this); | 5135 m_fontloader = FontLoader::create(this); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 5160 { | 5162 { |
| 5161 return DocumentLifecycleNotifier::create(this); | 5163 return DocumentLifecycleNotifier::create(this); |
| 5162 } | 5164 } |
| 5163 | 5165 |
| 5164 DocumentLifecycleNotifier* Document::lifecycleNotifier() | 5166 DocumentLifecycleNotifier* Document::lifecycleNotifier() |
| 5165 { | 5167 { |
| 5166 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); | 5168 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); |
| 5167 } | 5169 } |
| 5168 | 5170 |
| 5169 } // namespace WebCore | 5171 } // namespace WebCore |
| OLD | NEW |