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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 #include "core/loader/appcache/ApplicationCacheHost.h" | 190 #include "core/loader/appcache/ApplicationCacheHost.h" |
191 #include "core/page/ChromeClient.h" | 191 #include "core/page/ChromeClient.h" |
192 #include "core/page/EventWithHitTestResults.h" | 192 #include "core/page/EventWithHitTestResults.h" |
193 #include "core/page/FocusController.h" | 193 #include "core/page/FocusController.h" |
194 #include "core/page/FrameTree.h" | 194 #include "core/page/FrameTree.h" |
195 #include "core/page/Page.h" | 195 #include "core/page/Page.h" |
196 #include "core/page/PointerLockController.h" | 196 #include "core/page/PointerLockController.h" |
197 #include "core/page/scrolling/RootScroller.h" | 197 #include "core/page/scrolling/RootScroller.h" |
198 #include "core/page/scrolling/ScrollingCoordinator.h" | 198 #include "core/page/scrolling/ScrollingCoordinator.h" |
199 #include "core/page/scrolling/SnapCoordinator.h" | 199 #include "core/page/scrolling/SnapCoordinator.h" |
| 200 #include "core/page/scrolling/ViewportScrollCallback.h" |
200 #include "core/svg/SVGDocumentExtensions.h" | 201 #include "core/svg/SVGDocumentExtensions.h" |
201 #include "core/svg/SVGScriptElement.h" | 202 #include "core/svg/SVGScriptElement.h" |
202 #include "core/svg/SVGTitleElement.h" | 203 #include "core/svg/SVGTitleElement.h" |
203 #include "core/svg/SVGUseElement.h" | 204 #include "core/svg/SVGUseElement.h" |
204 #include "core/timing/DOMWindowPerformance.h" | 205 #include "core/timing/DOMWindowPerformance.h" |
205 #include "core/timing/Performance.h" | 206 #include "core/timing/Performance.h" |
206 #include "core/workers/SharedWorkerRepositoryClient.h" | 207 #include "core/workers/SharedWorkerRepositoryClient.h" |
207 #include "core/xml/parser/XMLDocumentParser.h" | 208 #include "core/xml/parser/XMLDocumentParser.h" |
208 #include "platform/DateComponents.h" | 209 #include "platform/DateComponents.h" |
209 #include "platform/EventDispatchForbiddenScope.h" | 210 #include "platform/EventDispatchForbiddenScope.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); | 473 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); |
473 | 474 |
474 m_fetcher = m_frame->loader().documentLoader()->fetcher(); | 475 m_fetcher = m_frame->loader().documentLoader()->fetcher(); |
475 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); | 476 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); |
476 } else if (m_importsController) { | 477 } else if (m_importsController) { |
477 m_fetcher = FrameFetchContext::createContextAndFetcher(nullptr, this); | 478 m_fetcher = FrameFetchContext::createContextAndFetcher(nullptr, this); |
478 } else { | 479 } else { |
479 m_fetcher = ResourceFetcher::create(nullptr); | 480 m_fetcher = ResourceFetcher::create(nullptr); |
480 } | 481 } |
481 | 482 |
| 483 ViewportScrollCallback* applyScroll = nullptr; |
| 484 if (isInMainFrame()) { |
| 485 applyScroll = RootScroller::createViewportApplyScroll( |
| 486 frameHost()->topControls(), frameHost()->overscrollController()); |
| 487 } |
| 488 m_rootScroller = RootScroller::create(*this, applyScroll); |
| 489 |
482 // We depend on the url getting immediately set in subframes, but we | 490 // We depend on the url getting immediately set in subframes, but we |
483 // also depend on the url NOT getting immediately set in opened windows. | 491 // also depend on the url NOT getting immediately set in opened windows. |
484 // See fast/dom/early-frame-url.html | 492 // See fast/dom/early-frame-url.html |
485 // and fast/dom/location-new-window-no-crash.html, respectively. | 493 // and fast/dom/location-new-window-no-crash.html, respectively. |
486 // FIXME: Can/should we unify this behavior? | 494 // FIXME: Can/should we unify this behavior? |
487 if (initializer.shouldSetURL()) | 495 if (initializer.shouldSetURL()) |
488 setURL(initializer.url()); | 496 setURL(initializer.url()); |
489 | 497 |
490 initSecurityContext(initializer); | 498 initSecurityContext(initializer); |
491 initDNSPrefetch(); | 499 initDNSPrefetch(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 // so we resume as soon as we have a document element. Even for XHTML | 603 // so we resume as soon as we have a document element. Even for XHTML |
596 // documents there may never be a <body> (since the parser won't always | 604 // documents there may never be a <body> (since the parser won't always |
597 // insert one), so we resume here too. That does mean XHTML documents make | 605 // insert one), so we resume here too. That does mean XHTML documents make |
598 // frames when there's only a <head>, but such documents are pretty rare. | 606 // frames when there's only a <head>, but such documents are pretty rare. |
599 if (m_documentElement && !isHTMLDocument()) | 607 if (m_documentElement && !isHTMLDocument()) |
600 beginLifecycleUpdatesIfRenderingReady(); | 608 beginLifecycleUpdatesIfRenderingReady(); |
601 } | 609 } |
602 | 610 |
603 void Document::setRootScroller(Element* newScroller, ExceptionState& exceptionSt
ate) | 611 void Document::setRootScroller(Element* newScroller, ExceptionState& exceptionSt
ate) |
604 { | 612 { |
605 DCHECK(newScroller); | 613 m_rootScroller->set(newScroller); |
606 | |
607 if (!frame() || !frame()->isMainFrame()) { | |
608 exceptionState.throwDOMException( | |
609 WrongDocumentError, | |
610 "Root scroller can only be set on the top window's document."); | |
611 return; | |
612 } | |
613 | |
614 if (newScroller->document() != this) { | |
615 exceptionState.throwDOMException( | |
616 WrongDocumentError, | |
617 "Element isn't in this document."); | |
618 return; | |
619 } | |
620 | |
621 FrameHost* host = frameHost(); | |
622 if (!host) | |
623 return; | |
624 | |
625 RootScroller* rootScroller = host->rootScroller(); | |
626 DCHECK(rootScroller); | |
627 | |
628 if (!rootScroller->set(*newScroller)) { | |
629 exceptionState.throwDOMException( | |
630 InvalidStateError, | |
631 "Element cannot be set as root scroller. Must be block or iframe."); | |
632 } | |
633 } | 614 } |
634 | 615 |
635 Element* Document::rootScroller() | 616 Element* Document::rootScroller() const |
636 { | 617 { |
637 // TODO(bokan): Should child frames return the documentElement or nullptr? | 618 return m_rootScroller->get(); |
638 if (!isInMainFrame()) | 619 } |
639 return documentElement(); | |
640 | 620 |
641 FrameHost* host = frameHost(); | 621 bool Document::isEffectiveRootScroller(const Element& element) const |
642 if (!host) | 622 { |
643 return nullptr; | 623 return m_rootScroller->effectiveRootScroller() == element; |
644 | |
645 RootScroller* rootScroller = host->rootScroller(); | |
646 DCHECK(rootScroller); | |
647 | |
648 updateStyleAndLayoutIgnorePendingStylesheets(); | |
649 | |
650 return rootScroller->get(); | |
651 } | 624 } |
652 | 625 |
653 bool Document::isInMainFrame() const | 626 bool Document::isInMainFrame() const |
654 { | 627 { |
655 return frame() && frame()->isMainFrame(); | 628 return frame() && frame()->isMainFrame(); |
656 } | 629 } |
657 | 630 |
658 AtomicString Document::convertLocalName(const AtomicString& name) | 631 AtomicString Document::convertLocalName(const AtomicString& name) |
659 { | 632 { |
660 return isHTMLDocument() ? name.lower() : name; | 633 return isHTMLDocument() ? name.lower() : name; |
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1940 // first real or 'paintable' layout. | 1913 // first real or 'paintable' layout. |
1941 // TODO(esprehn): This doesn't really make sense, why not track the first | 1914 // TODO(esprehn): This doesn't really make sense, why not track the first |
1942 // beginFrame? This will catch the first layout in a page that does lots | 1915 // beginFrame? This will catch the first layout in a page that does lots |
1943 // of layout thrashing even though that layout might not be followed by | 1916 // of layout thrashing even though that layout might not be followed by |
1944 // a paint for many seconds. | 1917 // a paint for many seconds. |
1945 if (isRenderingReady() && body() && !styleEngine().hasPendingScriptBlockingS
heets()) { | 1918 if (isRenderingReady() && body() && !styleEngine().hasPendingScriptBlockingS
heets()) { |
1946 if (!m_documentTiming.firstLayout()) | 1919 if (!m_documentTiming.firstLayout()) |
1947 m_documentTiming.markFirstLayout(); | 1920 m_documentTiming.markFirstLayout(); |
1948 } | 1921 } |
1949 | 1922 |
1950 // TODO(bokan): Not sure how rootScroller can be null here if we're in the | 1923 m_rootScroller->didUpdateLayout(); |
1951 // main frame. In any case, I'm moving rootScroller to be owned by Document | |
1952 // soon so this will go away: https://codereview.chromium.org/1970763002/ | |
1953 if (isInMainFrame() && frameHost() && frameHost()->rootScroller()) | |
1954 frameHost()->rootScroller()->didUpdateTopDocumentLayout(); | |
1955 } | 1924 } |
1956 | 1925 |
1957 void Document::setNeedsFocusedElementCheck() | 1926 void Document::setNeedsFocusedElementCheck() |
1958 { | 1927 { |
1959 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::createWit
hExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)); | 1928 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::createWit
hExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)); |
1960 } | 1929 } |
1961 | 1930 |
1962 void Document::clearFocusedElementSoon() | 1931 void Document::clearFocusedElementSoon() |
1963 { | 1932 { |
1964 if (!m_clearFocusedElementTimer.isActive()) | 1933 if (!m_clearFocusedElementTimer.isActive()) |
(...skipping 3988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5953 { | 5922 { |
5954 visitor->trace(m_importsController); | 5923 visitor->trace(m_importsController); |
5955 visitor->trace(m_docType); | 5924 visitor->trace(m_docType); |
5956 visitor->trace(m_implementation); | 5925 visitor->trace(m_implementation); |
5957 visitor->trace(m_autofocusElement); | 5926 visitor->trace(m_autofocusElement); |
5958 visitor->trace(m_focusedElement); | 5927 visitor->trace(m_focusedElement); |
5959 visitor->trace(m_sequentialFocusNavigationStartingPoint); | 5928 visitor->trace(m_sequentialFocusNavigationStartingPoint); |
5960 visitor->trace(m_hoverNode); | 5929 visitor->trace(m_hoverNode); |
5961 visitor->trace(m_activeHoverElement); | 5930 visitor->trace(m_activeHoverElement); |
5962 visitor->trace(m_documentElement); | 5931 visitor->trace(m_documentElement); |
| 5932 visitor->trace(m_rootScroller); |
5963 visitor->trace(m_titleElement); | 5933 visitor->trace(m_titleElement); |
5964 visitor->trace(m_axObjectCache); | 5934 visitor->trace(m_axObjectCache); |
5965 visitor->trace(m_markers); | 5935 visitor->trace(m_markers); |
5966 visitor->trace(m_cssTarget); | 5936 visitor->trace(m_cssTarget); |
5967 visitor->trace(m_currentScriptStack); | 5937 visitor->trace(m_currentScriptStack); |
5968 visitor->trace(m_scriptRunner); | 5938 visitor->trace(m_scriptRunner); |
5969 visitor->trace(m_listsInvalidatedAtDocument); | 5939 visitor->trace(m_listsInvalidatedAtDocument); |
5970 for (int i = 0; i < numNodeListInvalidationTypes; ++i) | 5940 for (int i = 0; i < numNodeListInvalidationTypes; ++i) |
5971 visitor->trace(m_nodeLists[i]); | 5941 visitor->trace(m_nodeLists[i]); |
5972 visitor->trace(m_topLayerElements); | 5942 visitor->trace(m_topLayerElements); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6036 #ifndef NDEBUG | 6006 #ifndef NDEBUG |
6037 using namespace blink; | 6007 using namespace blink; |
6038 void showLiveDocumentInstances() | 6008 void showLiveDocumentInstances() |
6039 { | 6009 { |
6040 WeakDocumentSet& set = liveDocumentSet(); | 6010 WeakDocumentSet& set = liveDocumentSet(); |
6041 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6011 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
6042 for (Document* document : set) | 6012 for (Document* document : set) |
6043 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); | 6013 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); |
6044 } | 6014 } |
6045 #endif | 6015 #endif |
OLD | NEW |