| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 #include "core/loader/FrameLoader.h" | 198 #include "core/loader/FrameLoader.h" |
| 199 #include "core/loader/FrameLoaderClient.h" | 199 #include "core/loader/FrameLoaderClient.h" |
| 200 #include "core/loader/ImageLoader.h" | 200 #include "core/loader/ImageLoader.h" |
| 201 #include "core/loader/NavigationScheduler.h" | 201 #include "core/loader/NavigationScheduler.h" |
| 202 #include "core/loader/PrerendererClient.h" | 202 #include "core/loader/PrerendererClient.h" |
| 203 #include "core/loader/appcache/ApplicationCacheHost.h" | 203 #include "core/loader/appcache/ApplicationCacheHost.h" |
| 204 #include "core/page/ChromeClient.h" | 204 #include "core/page/ChromeClient.h" |
| 205 #include "core/page/EventWithHitTestResults.h" | 205 #include "core/page/EventWithHitTestResults.h" |
| 206 #include "core/page/FocusController.h" | 206 #include "core/page/FocusController.h" |
| 207 #include "core/page/FrameTree.h" | 207 #include "core/page/FrameTree.h" |
| 208 #include "core/page/NetworkStateNotifier.h" |
| 208 #include "core/page/Page.h" | 209 #include "core/page/Page.h" |
| 209 #include "core/page/PointerLockController.h" | 210 #include "core/page/PointerLockController.h" |
| 210 #include "core/page/scrolling/RootScrollerController.h" | 211 #include "core/page/scrolling/RootScrollerController.h" |
| 211 #include "core/page/scrolling/ScrollStateCallback.h" | 212 #include "core/page/scrolling/ScrollStateCallback.h" |
| 212 #include "core/page/scrolling/ScrollingCoordinator.h" | 213 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 213 #include "core/page/scrolling/SnapCoordinator.h" | 214 #include "core/page/scrolling/SnapCoordinator.h" |
| 214 #include "core/page/scrolling/TopDocumentRootScrollerController.h" | 215 #include "core/page/scrolling/TopDocumentRootScrollerController.h" |
| 215 #include "core/svg/SVGDocumentExtensions.h" | 216 #include "core/svg/SVGDocumentExtensions.h" |
| 216 #include "core/svg/SVGScriptElement.h" | 217 #include "core/svg/SVGScriptElement.h" |
| 217 #include "core/svg/SVGTitleElement.h" | 218 #include "core/svg/SVGTitleElement.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 } | 398 } |
| 398 } | 399 } |
| 399 | 400 |
| 400 static void recordLoadReasonToHistogram(WouldLoadReason reason) { | 401 static void recordLoadReasonToHistogram(WouldLoadReason reason) { |
| 401 DEFINE_STATIC_LOCAL( | 402 DEFINE_STATIC_LOCAL( |
| 402 EnumerationHistogram, unseenFrameHistogram, | 403 EnumerationHistogram, unseenFrameHistogram, |
| 403 ("Navigation.DeferredDocumentLoading.StatesV3", WouldLoadReasonEnd)); | 404 ("Navigation.DeferredDocumentLoading.StatesV3", WouldLoadReasonEnd)); |
| 404 unseenFrameHistogram.count(reason); | 405 unseenFrameHistogram.count(reason); |
| 405 } | 406 } |
| 406 | 407 |
| 408 class Document::NetworkStateObserver final |
| 409 : public GarbageCollected<Document::NetworkStateObserver>, |
| 410 public NetworkStateNotifier::NetworkStateObserver, |
| 411 public ContextLifecycleObserver { |
| 412 USING_GARBAGE_COLLECTED_MIXIN(Document::NetworkStateObserver); |
| 413 |
| 414 public: |
| 415 explicit NetworkStateObserver(Document& document) |
| 416 : ContextLifecycleObserver(&document) { |
| 417 networkStateNotifier().addOnLineObserver( |
| 418 this, |
| 419 TaskRunnerHelper::get(TaskType::Networking, getExecutionContext())); |
| 420 } |
| 421 |
| 422 void onLineStateChange(bool onLine) override { |
| 423 AtomicString eventName = |
| 424 onLine ? EventTypeNames::online : EventTypeNames::offline; |
| 425 Document* document = toDocument(getExecutionContext()); |
| 426 if (!document->domWindow()) |
| 427 return; |
| 428 document->domWindow()->dispatchEvent(Event::create(eventName)); |
| 429 InspectorInstrumentation::networkStateChanged(document->frame(), onLine); |
| 430 } |
| 431 |
| 432 void contextDestroyed(ExecutionContext* context) override { |
| 433 networkStateNotifier().removeOnLineObserver( |
| 434 this, TaskRunnerHelper::get(TaskType::Networking, context)); |
| 435 } |
| 436 |
| 437 DEFINE_INLINE_VIRTUAL_TRACE() { ContextLifecycleObserver::trace(visitor); } |
| 438 }; |
| 439 |
| 407 Document::Document(const DocumentInit& initializer, | 440 Document::Document(const DocumentInit& initializer, |
| 408 DocumentClassFlags documentClasses) | 441 DocumentClassFlags documentClasses) |
| 409 : ContainerNode(0, CreateDocument), | 442 : ContainerNode(0, CreateDocument), |
| 410 TreeScope(*this), | 443 TreeScope(*this), |
| 411 m_hasNodesWithPlaceholderStyle(false), | 444 m_hasNodesWithPlaceholderStyle(false), |
| 412 m_evaluateMediaQueriesOnStyleRecalc(false), | 445 m_evaluateMediaQueriesOnStyleRecalc(false), |
| 413 m_pendingSheetLayout(NoLayoutWithPendingSheets), | 446 m_pendingSheetLayout(NoLayoutWithPendingSheets), |
| 414 m_frame(initializer.frame()), | 447 m_frame(initializer.frame()), |
| 415 // TODO(dcheng): Why does this need both a LocalFrame and LocalDOMWindow | 448 // TODO(dcheng): Why does this need both a LocalFrame and LocalDOMWindow |
| 416 // pointer? | 449 // pointer? |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 m_didAssociateFormControlsTimer( | 522 m_didAssociateFormControlsTimer( |
| 490 TaskRunnerHelper::get(TaskType::UnspecedLoading, this), | 523 TaskRunnerHelper::get(TaskType::UnspecedLoading, this), |
| 491 this, | 524 this, |
| 492 &Document::didAssociateFormControlsTimerFired), | 525 &Document::didAssociateFormControlsTimerFired), |
| 493 m_timers(TaskRunnerHelper::get(TaskType::Timer, this)), | 526 m_timers(TaskRunnerHelper::get(TaskType::Timer, this)), |
| 494 m_hasViewportUnits(false), | 527 m_hasViewportUnits(false), |
| 495 m_parserSyncPolicy(AllowAsynchronousParsing), | 528 m_parserSyncPolicy(AllowAsynchronousParsing), |
| 496 m_nodeCount(0), | 529 m_nodeCount(0), |
| 497 m_wouldLoadReason(Created), | 530 m_wouldLoadReason(Created), |
| 498 m_passwordCount(0), | 531 m_passwordCount(0), |
| 499 m_engagementLevel(mojom::blink::EngagementLevel::NONE) { | 532 m_engagementLevel(mojom::blink::EngagementLevel::NONE), |
| 533 m_networkStateObserver(new NetworkStateObserver(*this)) { |
| 500 if (m_frame) { | 534 if (m_frame) { |
| 501 DCHECK(m_frame->page()); | 535 DCHECK(m_frame->page()); |
| 502 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); | 536 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); |
| 503 | 537 |
| 504 m_fetcher = m_frame->loader().documentLoader()->fetcher(); | 538 m_fetcher = m_frame->loader().documentLoader()->fetcher(); |
| 505 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); | 539 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); |
| 506 | 540 |
| 507 // TODO(dcheng): Why does this need to check that DOMWindow is non-null? | 541 // TODO(dcheng): Why does this need to check that DOMWindow is non-null? |
| 508 CustomElementRegistry* registry = | 542 CustomElementRegistry* registry = |
| 509 m_frame->domWindow() ? m_frame->domWindow()->maybeCustomElements() | 543 m_frame->domWindow() ? m_frame->domWindow()->maybeCustomElements() |
| (...skipping 6046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6556 visitor->trace(m_svgExtensions); | 6590 visitor->trace(m_svgExtensions); |
| 6557 visitor->trace(m_timeline); | 6591 visitor->trace(m_timeline); |
| 6558 visitor->trace(m_compositorPendingAnimations); | 6592 visitor->trace(m_compositorPendingAnimations); |
| 6559 visitor->trace(m_contextDocument); | 6593 visitor->trace(m_contextDocument); |
| 6560 visitor->trace(m_canvasFontCache); | 6594 visitor->trace(m_canvasFontCache); |
| 6561 visitor->trace(m_intersectionObserverController); | 6595 visitor->trace(m_intersectionObserverController); |
| 6562 visitor->trace(m_snapCoordinator); | 6596 visitor->trace(m_snapCoordinator); |
| 6563 visitor->trace(m_resizeObserverController); | 6597 visitor->trace(m_resizeObserverController); |
| 6564 visitor->trace(m_propertyRegistry); | 6598 visitor->trace(m_propertyRegistry); |
| 6565 visitor->trace(m_styleReattachDataMap); | 6599 visitor->trace(m_styleReattachDataMap); |
| 6600 visitor->trace(m_networkStateObserver); |
| 6566 Supplementable<Document>::trace(visitor); | 6601 Supplementable<Document>::trace(visitor); |
| 6567 TreeScope::trace(visitor); | 6602 TreeScope::trace(visitor); |
| 6568 ContainerNode::trace(visitor); | 6603 ContainerNode::trace(visitor); |
| 6569 ExecutionContext::trace(visitor); | 6604 ExecutionContext::trace(visitor); |
| 6570 SecurityContext::trace(visitor); | 6605 SecurityContext::trace(visitor); |
| 6571 SynchronousMutationNotifier::trace(visitor); | 6606 SynchronousMutationNotifier::trace(visitor); |
| 6572 } | 6607 } |
| 6573 | 6608 |
| 6574 void Document::maybeRecordLoadReason(WouldLoadReason reason) { | 6609 void Document::maybeRecordLoadReason(WouldLoadReason reason) { |
| 6575 DCHECK(m_wouldLoadReason == Created || reason != Created); | 6610 DCHECK(m_wouldLoadReason == Created || reason != Created); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6616 } | 6651 } |
| 6617 | 6652 |
| 6618 void showLiveDocumentInstances() { | 6653 void showLiveDocumentInstances() { |
| 6619 WeakDocumentSet& set = liveDocumentSet(); | 6654 WeakDocumentSet& set = liveDocumentSet(); |
| 6620 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6655 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6621 for (blink::Document* document : set) | 6656 for (blink::Document* document : set) |
| 6622 fprintf(stderr, "- Document %p URL: %s\n", document, | 6657 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6623 document->url().getString().utf8().data()); | 6658 document->url().getString().utf8().data()); |
| 6624 } | 6659 } |
| 6625 #endif | 6660 #endif |
| OLD | NEW |