| 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) { |
| 402 // histogram. | 402 LOG(ERROR) << "UMAing " << reason; |
| 403 enum DocumentVisibilityForDeferredLoading { | 403 DEFINE_STATIC_LOCAL( |
| 404 Created, | 404 EnumerationHistogram, unseenFrameHistogram, |
| 405 WouldLoadBecauseVisible, | 405 ("Navigation.DeferredDocumentLoading.StatesV2", WouldLoadReasonEnd)); |
| 406 // TODO(dgrogan): Add WouldLoadBecauseTopOrLeft, WouldLoadBecauseDisplayNone, | 406 unseenFrameHistogram.count(reason); |
| 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 } | 407 } |
| 418 | 408 |
| 419 Document::Document(const DocumentInit& initializer, | 409 Document::Document(const DocumentInit& initializer, |
| 420 DocumentClassFlags documentClasses) | 410 DocumentClassFlags documentClasses) |
| 421 : ContainerNode(0, CreateDocument), | 411 : ContainerNode(0, CreateDocument), |
| 422 TreeScope(*this), | 412 TreeScope(*this), |
| 423 m_hasNodesWithPlaceholderStyle(false), | 413 m_hasNodesWithPlaceholderStyle(false), |
| 424 m_evaluateMediaQueriesOnStyleRecalc(false), | 414 m_evaluateMediaQueriesOnStyleRecalc(false), |
| 425 m_pendingSheetLayout(NoLayoutWithPendingSheets), | 415 m_pendingSheetLayout(NoLayoutWithPendingSheets), |
| 426 m_frame(initializer.frame()), | 416 m_frame(initializer.frame()), |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 m_timeline(DocumentTimeline::create(this)), | 479 m_timeline(DocumentTimeline::create(this)), |
| 490 m_compositorPendingAnimations(new CompositorPendingAnimations()), | 480 m_compositorPendingAnimations(new CompositorPendingAnimations()), |
| 491 m_templateDocumentHost(nullptr), | 481 m_templateDocumentHost(nullptr), |
| 492 m_didAssociateFormControlsTimer( | 482 m_didAssociateFormControlsTimer( |
| 493 this, | 483 this, |
| 494 &Document::didAssociateFormControlsTimerFired), | 484 &Document::didAssociateFormControlsTimerFired), |
| 495 m_timers(TaskRunnerHelper::get(TaskType::Timer, this)->clone()), | 485 m_timers(TaskRunnerHelper::get(TaskType::Timer, this)->clone()), |
| 496 m_hasViewportUnits(false), | 486 m_hasViewportUnits(false), |
| 497 m_parserSyncPolicy(AllowAsynchronousParsing), | 487 m_parserSyncPolicy(AllowAsynchronousParsing), |
| 498 m_nodeCount(0), | 488 m_nodeCount(0), |
| 499 m_visibilityWasLogged(false) { | 489 m_wouldLoadReason(Created) { |
| 500 if (m_frame) { | 490 if (m_frame) { |
| 501 DCHECK(m_frame->page()); | 491 DCHECK(m_frame->page()); |
| 502 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); | 492 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); |
| 503 | 493 |
| 504 m_fetcher = m_frame->loader().documentLoader()->fetcher(); | 494 m_fetcher = m_frame->loader().documentLoader()->fetcher(); |
| 505 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); | 495 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); |
| 506 | 496 |
| 507 CustomElementRegistry* registry = | 497 CustomElementRegistry* registry = |
| 508 m_frame->localDOMWindow() | 498 m_frame->localDOMWindow() |
| 509 ? m_frame->localDOMWindow()->maybeCustomElements() | 499 ? m_frame->localDOMWindow()->maybeCustomElements() |
| (...skipping 13 matching lines...) Expand all Loading... |
| 523 // See fast/dom/early-frame-url.html | 513 // See fast/dom/early-frame-url.html |
| 524 // and fast/dom/location-new-window-no-crash.html, respectively. | 514 // and fast/dom/location-new-window-no-crash.html, respectively. |
| 525 // FIXME: Can/should we unify this behavior? | 515 // FIXME: Can/should we unify this behavior? |
| 526 if (initializer.shouldSetURL()) | 516 if (initializer.shouldSetURL()) |
| 527 setURL(initializer.url()); | 517 setURL(initializer.url()); |
| 528 | 518 |
| 529 initSecurityContext(initializer); | 519 initSecurityContext(initializer); |
| 530 DCHECK(getSecurityOrigin()); | 520 DCHECK(getSecurityOrigin()); |
| 531 if (frame() && frame()->tree().top()->securityContext() && | 521 if (frame() && frame()->tree().top()->securityContext() && |
| 532 !getSecurityOrigin()->canAccess( | 522 !getSecurityOrigin()->canAccess( |
| 533 frame()->tree().top()->securityContext()->getSecurityOrigin())) | 523 frame()->tree().top()->securityContext()->getSecurityOrigin()) && |
| 534 RecordStateToHistogram(Created); | 524 frame()->loader().stateMachine()->committedFirstRealDocumentLoad()) { |
| 525 recordReasonToHistogram(Created); |
| 526 } |
| 535 | 527 |
| 536 initDNSPrefetch(); | 528 initDNSPrefetch(); |
| 537 | 529 |
| 538 InstanceCounters::incrementCounter(InstanceCounters::DocumentCounter); | 530 InstanceCounters::incrementCounter(InstanceCounters::DocumentCounter); |
| 539 | 531 |
| 540 m_lifecycle.advanceTo(DocumentLifecycle::Inactive); | 532 m_lifecycle.advanceTo(DocumentLifecycle::Inactive); |
| 541 | 533 |
| 542 // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns | 534 // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns |
| 543 // CSSFontSelector, need to initialize m_styleEngine after initializing | 535 // CSSFontSelector, need to initialize m_styleEngine after initializing |
| 544 // m_fetcher. | 536 // m_fetcher. |
| (...skipping 5781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6326 visitor->trace(m_snapCoordinator); | 6318 visitor->trace(m_snapCoordinator); |
| 6327 visitor->trace(m_resizeObserverController); | 6319 visitor->trace(m_resizeObserverController); |
| 6328 visitor->trace(m_propertyRegistry); | 6320 visitor->trace(m_propertyRegistry); |
| 6329 Supplementable<Document>::trace(visitor); | 6321 Supplementable<Document>::trace(visitor); |
| 6330 TreeScope::trace(visitor); | 6322 TreeScope::trace(visitor); |
| 6331 ContainerNode::trace(visitor); | 6323 ContainerNode::trace(visitor); |
| 6332 ExecutionContext::trace(visitor); | 6324 ExecutionContext::trace(visitor); |
| 6333 SecurityContext::trace(visitor); | 6325 SecurityContext::trace(visitor); |
| 6334 } | 6326 } |
| 6335 | 6327 |
| 6336 void Document::onVisibilityMaybeChanged(bool visible) { | 6328 void Document::wouldLoadBecause(WouldLoadReason reason) { |
| 6329 DCHECK(reason != Created); |
| 6337 DCHECK(frame()); | 6330 DCHECK(frame()); |
| 6338 if (visible && !m_visibilityWasLogged && frame()->isCrossOriginSubframe()) { | 6331 if (m_wouldLoadReason == Created && frame()->isCrossOriginSubframe() && |
| 6339 m_visibilityWasLogged = true; | 6332 frame()->loader().stateMachine()->committedFirstRealDocumentLoad()) { |
| 6340 RecordStateToHistogram(WouldLoadBecauseVisible); | 6333 recordReasonToHistogram(reason); |
| 6341 } | 6334 } |
| 6335 m_wouldLoadReason = reason; |
| 6342 } | 6336 } |
| 6343 | 6337 |
| 6344 DEFINE_TRACE_WRAPPERS(Document) { | 6338 DEFINE_TRACE_WRAPPERS(Document) { |
| 6345 visitor->traceWrappers(m_importsController); | 6339 visitor->traceWrappers(m_importsController); |
| 6346 visitor->traceWrappers(m_implementation); | 6340 visitor->traceWrappers(m_implementation); |
| 6347 visitor->traceWrappers(m_styleSheetList); | 6341 visitor->traceWrappers(m_styleSheetList); |
| 6348 visitor->traceWrappers(m_styleEngine); | 6342 visitor->traceWrappers(m_styleEngine); |
| 6349 visitor->traceWrappers(Supplementable<Document>::m_supplements.get( | 6343 visitor->traceWrappers(Supplementable<Document>::m_supplements.get( |
| 6350 FontFaceSet::supplementName())); | 6344 FontFaceSet::supplementName())); |
| 6351 for (int i = 0; i < numNodeListInvalidationTypes; ++i) { | 6345 for (int i = 0; i < numNodeListInvalidationTypes; ++i) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 6369 } | 6363 } |
| 6370 | 6364 |
| 6371 void showLiveDocumentInstances() { | 6365 void showLiveDocumentInstances() { |
| 6372 WeakDocumentSet& set = liveDocumentSet(); | 6366 WeakDocumentSet& set = liveDocumentSet(); |
| 6373 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6367 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6374 for (Document* document : set) | 6368 for (Document* document : set) |
| 6375 fprintf(stderr, "- Document %p URL: %s\n", document, | 6369 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6376 document->url().getString().utf8().data()); | 6370 document->url().getString().utf8().data()); |
| 6377 } | 6371 } |
| 6378 #endif | 6372 #endif |
| OLD | NEW |