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 | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All |
| 7 * rights reserved. | 7 * rights reserved. |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 | 391 |
| 392 // This doesn't work with non-Document ExecutionContext. | 392 // This doesn't work with non-Document ExecutionContext. |
| 393 static void runAutofocusTask(ExecutionContext* context) { | 393 static void runAutofocusTask(ExecutionContext* context) { |
| 394 Document* document = toDocument(context); | 394 Document* document = toDocument(context); |
| 395 if (Element* element = document->autofocusElement()) { | 395 if (Element* element = document->autofocusElement()) { |
| 396 document->setAutofocusElement(0); | 396 document->setAutofocusElement(0); |
| 397 element->focus(); | 397 element->focus(); |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 // These are logged to UMA, so don't re-arrange them without creating a new | 401 static void recordReasonToHistogram(WouldLoadReason reason) { |
|
dcheng
2016/10/08 00:46:22
Nit: recordLoadReasonToHistogram
dgrogan
2016/10/13 01:06:21
Done.
| |
| 402 // histogram. | 402 DEFINE_STATIC_LOCAL( |
| 403 enum DocumentVisibilityForDeferredLoading { | 403 EnumerationHistogram, unseenFrameHistogram, |
| 404 Created, | 404 ("Navigation.DeferredDocumentLoading.StatesV2", WouldLoadReasonEnd)); |
| 405 WouldLoadBecauseVisible, | 405 unseenFrameHistogram.count(reason); |
| 406 // TODO(dgrogan): Add WouldLoadBecauseTopOrLeft, WouldLoadBecauseDisplayNone, | |
| 407 // etc | |
| 408 | |
| 409 DocumentVisibilityForDeferredLoadingEnd | |
| 410 }; | |
| 411 | |
| 412 static void RecordStateToHistogram(DocumentVisibilityForDeferredLoading state) { | |
| 413 DEFINE_STATIC_LOCAL(EnumerationHistogram, unseenFrameHistogram, | |
| 414 ("Navigation.DeferredDocumentLoading.StatesV1", | |
| 415 DocumentVisibilityForDeferredLoadingEnd)); | |
| 416 unseenFrameHistogram.count(state); | |
| 417 } | 406 } |
| 418 | 407 |
| 419 Document::Document(const DocumentInit& initializer, | 408 Document::Document(const DocumentInit& initializer, |
| 420 DocumentClassFlags documentClasses) | 409 DocumentClassFlags documentClasses) |
| 421 : ContainerNode(0, CreateDocument), | 410 : ContainerNode(0, CreateDocument), |
| 422 TreeScope(*this), | 411 TreeScope(*this), |
| 423 m_hasNodesWithPlaceholderStyle(false), | 412 m_hasNodesWithPlaceholderStyle(false), |
| 424 m_evaluateMediaQueriesOnStyleRecalc(false), | 413 m_evaluateMediaQueriesOnStyleRecalc(false), |
| 425 m_pendingSheetLayout(NoLayoutWithPendingSheets), | 414 m_pendingSheetLayout(NoLayoutWithPendingSheets), |
| 426 m_frame(initializer.frame()), | 415 m_frame(initializer.frame()), |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 m_timeline(DocumentTimeline::create(this)), | 478 m_timeline(DocumentTimeline::create(this)), |
| 490 m_compositorPendingAnimations(new CompositorPendingAnimations()), | 479 m_compositorPendingAnimations(new CompositorPendingAnimations()), |
| 491 m_templateDocumentHost(nullptr), | 480 m_templateDocumentHost(nullptr), |
| 492 m_didAssociateFormControlsTimer( | 481 m_didAssociateFormControlsTimer( |
| 493 this, | 482 this, |
| 494 &Document::didAssociateFormControlsTimerFired), | 483 &Document::didAssociateFormControlsTimerFired), |
| 495 m_timers(TaskRunnerHelper::get(TaskType::Timer, this)->clone()), | 484 m_timers(TaskRunnerHelper::get(TaskType::Timer, this)->clone()), |
| 496 m_hasViewportUnits(false), | 485 m_hasViewportUnits(false), |
| 497 m_parserSyncPolicy(AllowAsynchronousParsing), | 486 m_parserSyncPolicy(AllowAsynchronousParsing), |
| 498 m_nodeCount(0), | 487 m_nodeCount(0), |
| 499 m_visibilityWasLogged(false) { | 488 m_wouldLoadReason(Created) { |
| 500 if (m_frame) { | 489 if (m_frame) { |
| 501 DCHECK(m_frame->page()); | 490 DCHECK(m_frame->page()); |
| 502 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); | 491 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); |
| 503 | 492 |
| 504 m_fetcher = m_frame->loader().documentLoader()->fetcher(); | 493 m_fetcher = m_frame->loader().documentLoader()->fetcher(); |
| 505 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); | 494 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); |
| 506 | 495 |
| 507 CustomElementRegistry* registry = | 496 CustomElementRegistry* registry = |
| 508 m_frame->localDOMWindow() | 497 m_frame->localDOMWindow() |
| 509 ? m_frame->localDOMWindow()->maybeCustomElements() | 498 ? m_frame->localDOMWindow()->maybeCustomElements() |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 521 // We depend on the url getting immediately set in subframes, but we | 510 // We depend on the url getting immediately set in subframes, but we |
| 522 // also depend on the url NOT getting immediately set in opened windows. | 511 // also depend on the url NOT getting immediately set in opened windows. |
| 523 // See fast/dom/early-frame-url.html | 512 // See fast/dom/early-frame-url.html |
| 524 // and fast/dom/location-new-window-no-crash.html, respectively. | 513 // and fast/dom/location-new-window-no-crash.html, respectively. |
| 525 // FIXME: Can/should we unify this behavior? | 514 // FIXME: Can/should we unify this behavior? |
| 526 if (initializer.shouldSetURL()) | 515 if (initializer.shouldSetURL()) |
| 527 setURL(initializer.url()); | 516 setURL(initializer.url()); |
| 528 | 517 |
| 529 initSecurityContext(initializer); | 518 initSecurityContext(initializer); |
| 530 DCHECK(getSecurityOrigin()); | 519 DCHECK(getSecurityOrigin()); |
| 531 if (frame() && frame()->tree().top()->securityContext() && | 520 if (frame() && frame()->tree().top()->securityContext() && |
|
dcheng
2016/10/08 00:46:22
Nit: Not introduced by this CL, but can this be fr
dgrogan
2016/10/13 01:06:21
That would be nice but unfortunately not; LocalFra
dcheng
2016/10/13 23:00:43
Let's just update isCrossOriginSubframe() to handl
dgrogan
2016/10/14 21:45:08
Same stacktrace :( But thanks for looking into thi
dcheng
2016/10/14 23:40:30
Ah OK. So I patched this in and I understand the p
| |
| 532 !getSecurityOrigin()->canAccess( | 521 !getSecurityOrigin()->canAccess( |
| 533 frame()->tree().top()->securityContext()->getSecurityOrigin())) | 522 frame()->tree().top()->securityContext()->getSecurityOrigin()) && |
| 534 RecordStateToHistogram(Created); | 523 frame()->loader().stateMachine()->committedFirstRealDocumentLoad()) { |
| 524 recordReasonToHistogram(Created); | |
| 525 } | |
| 535 | 526 |
| 536 initDNSPrefetch(); | 527 initDNSPrefetch(); |
| 537 | 528 |
| 538 InstanceCounters::incrementCounter(InstanceCounters::DocumentCounter); | 529 InstanceCounters::incrementCounter(InstanceCounters::DocumentCounter); |
| 539 | 530 |
| 540 m_lifecycle.advanceTo(DocumentLifecycle::Inactive); | 531 m_lifecycle.advanceTo(DocumentLifecycle::Inactive); |
| 541 | 532 |
| 542 // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns | 533 // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns |
| 543 // CSSFontSelector, need to initialize m_styleEngine after initializing | 534 // CSSFontSelector, need to initialize m_styleEngine after initializing |
| 544 // m_fetcher. | 535 // m_fetcher. |
| (...skipping 5814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6359 visitor->trace(m_resizeObserverController); | 6350 visitor->trace(m_resizeObserverController); |
| 6360 visitor->trace(m_propertyRegistry); | 6351 visitor->trace(m_propertyRegistry); |
| 6361 visitor->trace(m_nonAttachedStyle); | 6352 visitor->trace(m_nonAttachedStyle); |
| 6362 Supplementable<Document>::trace(visitor); | 6353 Supplementable<Document>::trace(visitor); |
| 6363 TreeScope::trace(visitor); | 6354 TreeScope::trace(visitor); |
| 6364 ContainerNode::trace(visitor); | 6355 ContainerNode::trace(visitor); |
| 6365 ExecutionContext::trace(visitor); | 6356 ExecutionContext::trace(visitor); |
| 6366 SecurityContext::trace(visitor); | 6357 SecurityContext::trace(visitor); |
| 6367 } | 6358 } |
| 6368 | 6359 |
| 6369 void Document::onVisibilityMaybeChanged(bool visible) { | 6360 void Document::wouldLoadBecause(WouldLoadReason reason) { |
| 6361 DCHECK(reason != Created); | |
| 6370 DCHECK(frame()); | 6362 DCHECK(frame()); |
| 6371 if (visible && !m_visibilityWasLogged && frame()->isCrossOriginSubframe()) { | 6363 if (m_wouldLoadReason == Created && frame()->isCrossOriginSubframe() && |
| 6372 m_visibilityWasLogged = true; | 6364 frame()->loader().stateMachine()->committedFirstRealDocumentLoad()) { |
| 6373 RecordStateToHistogram(WouldLoadBecauseVisible); | 6365 recordReasonToHistogram(reason); |
| 6374 } | 6366 } |
| 6367 m_wouldLoadReason = reason; | |
| 6375 } | 6368 } |
| 6376 | 6369 |
| 6377 DEFINE_TRACE_WRAPPERS(Document) { | 6370 DEFINE_TRACE_WRAPPERS(Document) { |
| 6378 visitor->traceWrappers(m_importsController); | 6371 visitor->traceWrappers(m_importsController); |
| 6379 visitor->traceWrappers(m_implementation); | 6372 visitor->traceWrappers(m_implementation); |
| 6380 visitor->traceWrappers(m_styleSheetList); | 6373 visitor->traceWrappers(m_styleSheetList); |
| 6381 visitor->traceWrappers(m_styleEngine); | 6374 visitor->traceWrappers(m_styleEngine); |
| 6382 visitor->traceWrappers(Supplementable<Document>::m_supplements.get( | 6375 visitor->traceWrappers(Supplementable<Document>::m_supplements.get( |
| 6383 FontFaceSet::supplementName())); | 6376 FontFaceSet::supplementName())); |
| 6384 for (int i = 0; i < numNodeListInvalidationTypes; ++i) { | 6377 for (int i = 0; i < numNodeListInvalidationTypes; ++i) { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 6402 } | 6395 } |
| 6403 | 6396 |
| 6404 void showLiveDocumentInstances() { | 6397 void showLiveDocumentInstances() { |
| 6405 WeakDocumentSet& set = liveDocumentSet(); | 6398 WeakDocumentSet& set = liveDocumentSet(); |
| 6406 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6399 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6407 for (Document* document : set) | 6400 for (Document* document : set) |
| 6408 fprintf(stderr, "- Document %p URL: %s\n", document, | 6401 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6409 document->url().getString().utf8().data()); | 6402 document->url().getString().utf8().data()); |
| 6410 } | 6403 } |
| 6411 #endif | 6404 #endif |
| OLD | NEW |