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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 #include "core/loader/NavigationScheduler.h" | 187 #include "core/loader/NavigationScheduler.h" |
| 188 #include "core/loader/appcache/ApplicationCacheHost.h" | 188 #include "core/loader/appcache/ApplicationCacheHost.h" |
| 189 #include "core/page/ChromeClient.h" | 189 #include "core/page/ChromeClient.h" |
| 190 #include "core/page/EventWithHitTestResults.h" | 190 #include "core/page/EventWithHitTestResults.h" |
| 191 #include "core/page/FocusController.h" | 191 #include "core/page/FocusController.h" |
| 192 #include "core/page/FrameTree.h" | 192 #include "core/page/FrameTree.h" |
| 193 #include "core/page/Page.h" | 193 #include "core/page/Page.h" |
| 194 #include "core/page/PointerLockController.h" | 194 #include "core/page/PointerLockController.h" |
| 195 #include "core/page/scrolling/RootScroller.h" | 195 #include "core/page/scrolling/RootScroller.h" |
| 196 #include "core/page/scrolling/ScrollingCoordinator.h" | 196 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 197 #include "core/page/scrolling/ViewportScrollCallback.h" | |
| 197 #include "core/svg/SVGDocumentExtensions.h" | 198 #include "core/svg/SVGDocumentExtensions.h" |
| 198 #include "core/svg/SVGScriptElement.h" | 199 #include "core/svg/SVGScriptElement.h" |
| 199 #include "core/svg/SVGTitleElement.h" | 200 #include "core/svg/SVGTitleElement.h" |
| 200 #include "core/svg/SVGUseElement.h" | 201 #include "core/svg/SVGUseElement.h" |
| 201 #include "core/timing/DOMWindowPerformance.h" | 202 #include "core/timing/DOMWindowPerformance.h" |
| 202 #include "core/timing/Performance.h" | 203 #include "core/timing/Performance.h" |
| 203 #include "core/workers/SharedWorkerRepositoryClient.h" | 204 #include "core/workers/SharedWorkerRepositoryClient.h" |
| 204 #include "core/xml/parser/XMLDocumentParser.h" | 205 #include "core/xml/parser/XMLDocumentParser.h" |
| 205 #include "platform/DateComponents.h" | 206 #include "platform/DateComponents.h" |
| 206 #include "platform/EventDispatchForbiddenScope.h" | 207 #include "platform/EventDispatchForbiddenScope.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); | 467 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); |
| 467 | 468 |
| 468 m_fetcher = m_frame->loader().documentLoader()->fetcher(); | 469 m_fetcher = m_frame->loader().documentLoader()->fetcher(); |
| 469 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); | 470 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); |
| 470 } else if (m_importsController) { | 471 } else if (m_importsController) { |
| 471 m_fetcher = FrameFetchContext::createContextAndFetcher(nullptr, this); | 472 m_fetcher = FrameFetchContext::createContextAndFetcher(nullptr, this); |
| 472 } else { | 473 } else { |
| 473 m_fetcher = ResourceFetcher::create(nullptr); | 474 m_fetcher = ResourceFetcher::create(nullptr); |
| 474 } | 475 } |
| 475 | 476 |
| 477 ViewportScrollCallback* applyScroll = nullptr; | |
| 478 if (isInMainFrame()) { | |
| 479 applyScroll = RootScroller::createViewportApplyScroll( | |
| 480 frameHost()->topControls(), frameHost()->overscrollController()); | |
| 481 } | |
| 482 m_rootScroller = RootScroller::create(*this, applyScroll); | |
|
esprehn
2016/05/11 17:37:05
we should rename RootScroller to something like Ro
bokan
2016/06/02 15:49:55
Acknowledged.
| |
| 483 | |
| 476 // We depend on the url getting immediately set in subframes, but we | 484 // We depend on the url getting immediately set in subframes, but we |
| 477 // also depend on the url NOT getting immediately set in opened windows. | 485 // also depend on the url NOT getting immediately set in opened windows. |
| 478 // See fast/dom/early-frame-url.html | 486 // See fast/dom/early-frame-url.html |
| 479 // and fast/dom/location-new-window-no-crash.html, respectively. | 487 // and fast/dom/location-new-window-no-crash.html, respectively. |
| 480 // FIXME: Can/should we unify this behavior? | 488 // FIXME: Can/should we unify this behavior? |
| 481 if (initializer.shouldSetURL()) | 489 if (initializer.shouldSetURL()) |
| 482 setURL(initializer.url()); | 490 setURL(initializer.url()); |
| 483 | 491 |
| 484 initSecurityContext(initializer); | 492 initSecurityContext(initializer); |
| 485 initDNSPrefetch(); | 493 initDNSPrefetch(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 // so we resume as soon as we have a document element. Even for XHTML | 597 // so we resume as soon as we have a document element. Even for XHTML |
| 590 // documents there may never be a <body> (since the parser won't always | 598 // documents there may never be a <body> (since the parser won't always |
| 591 // insert one), so we resume here too. That does mean XHTML documents make | 599 // insert one), so we resume here too. That does mean XHTML documents make |
| 592 // frames when there's only a <head>, but such documents are pretty rare. | 600 // frames when there's only a <head>, but such documents are pretty rare. |
| 593 if (m_documentElement && !isHTMLDocument()) | 601 if (m_documentElement && !isHTMLDocument()) |
| 594 beginLifecycleUpdatesIfRenderingReady(); | 602 beginLifecycleUpdatesIfRenderingReady(); |
| 595 } | 603 } |
| 596 | 604 |
| 597 void Document::setRootScroller(Element* newScroller, ExceptionState& exceptionSt ate) | 605 void Document::setRootScroller(Element* newScroller, ExceptionState& exceptionSt ate) |
| 598 { | 606 { |
| 599 DCHECK(newScroller); | 607 m_rootScroller->set(newScroller); |
| 600 | |
| 601 if (!frame() || !frame()->isMainFrame()) { | |
| 602 exceptionState.throwDOMException( | |
| 603 WrongDocumentError, | |
| 604 "Root scroller can only be set on the top window's document."); | |
| 605 return; | |
| 606 } | |
| 607 | |
| 608 if (newScroller->document() != this) { | |
| 609 exceptionState.throwDOMException( | |
| 610 WrongDocumentError, | |
| 611 "Element isn't in this document."); | |
| 612 return; | |
| 613 } | |
| 614 | |
| 615 FrameHost* host = frameHost(); | |
| 616 if (!host) | |
| 617 return; | |
| 618 | |
| 619 RootScroller* rootScroller = host->rootScroller(); | |
| 620 DCHECK(rootScroller); | |
| 621 | |
| 622 if (!rootScroller->set(*newScroller)) { | |
| 623 exceptionState.throwDOMException( | |
| 624 InvalidStateError, | |
| 625 "Element cannot be set as root scroller. Must be block or iframe."); | |
| 626 } | |
| 627 } | 608 } |
| 628 | 609 |
| 629 Element* Document::rootScroller() | 610 Element* Document::rootScroller() const |
| 630 { | 611 { |
| 631 // TODO(bokan): Should child frames return the documentElement or nullptr? | 612 return m_rootScroller->get(); |
| 632 if (!isInMainFrame()) | 613 } |
| 633 return documentElement(); | |
| 634 | 614 |
| 635 FrameHost* host = frameHost(); | 615 bool Document::isEffectiveRootScroller(const Element* element) const |
| 636 if (!host) | 616 { |
| 637 return nullptr; | 617 if (!element) |
| 618 return false; | |
| 638 | 619 |
| 639 RootScroller* rootScroller = host->rootScroller(); | 620 return m_rootScroller->effectiveRootScroller() == element; |
| 640 DCHECK(rootScroller); | |
| 641 | |
| 642 updateLayoutIgnorePendingStylesheets(); | |
| 643 | |
| 644 return rootScroller->get(); | |
| 645 } | 621 } |
| 646 | 622 |
| 647 bool Document::isInMainFrame() const | 623 bool Document::isInMainFrame() const |
| 648 { | 624 { |
| 649 return frame() && frame()->isMainFrame(); | 625 return frame() && frame()->isMainFrame(); |
| 650 } | 626 } |
| 651 | 627 |
| 652 AtomicString Document::convertLocalName(const AtomicString& name) | 628 AtomicString Document::convertLocalName(const AtomicString& name) |
| 653 { | 629 { |
| 654 return isHTMLDocument() ? name.lower() : name; | 630 return isHTMLDocument() ? name.lower() : name; |
| (...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1923 // first real or 'paintable' layout. | 1899 // first real or 'paintable' layout. |
| 1924 // TODO(esprehn): This doesn't really make sense, why not track the first | 1900 // TODO(esprehn): This doesn't really make sense, why not track the first |
| 1925 // beginFrame? This will catch the first layout in a page that does lots | 1901 // beginFrame? This will catch the first layout in a page that does lots |
| 1926 // of layout thrashing even though that layout might not be followed by | 1902 // of layout thrashing even though that layout might not be followed by |
| 1927 // a paint for many seconds. | 1903 // a paint for many seconds. |
| 1928 if (isRenderingReady() && body() && !styleEngine().hasPendingSheets()) { | 1904 if (isRenderingReady() && body() && !styleEngine().hasPendingSheets()) { |
| 1929 if (!m_documentTiming.firstLayout()) | 1905 if (!m_documentTiming.firstLayout()) |
| 1930 m_documentTiming.markFirstLayout(); | 1906 m_documentTiming.markFirstLayout(); |
| 1931 } | 1907 } |
| 1932 | 1908 |
| 1933 if (isInMainFrame() && frameHost()) { | 1909 m_rootScroller->didUpdateLayout(); |
| 1934 DCHECK(frameHost()->rootScroller()); | |
| 1935 frameHost()->rootScroller()->didUpdateTopDocumentLayout(); | |
| 1936 } | |
| 1937 } | 1910 } |
| 1938 | 1911 |
| 1939 void Document::setNeedsFocusedElementCheck() | 1912 void Document::setNeedsFocusedElementCheck() |
| 1940 { | 1913 { |
| 1941 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::createWit hExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)); | 1914 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::createWit hExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)); |
| 1942 } | 1915 } |
| 1943 | 1916 |
| 1944 void Document::clearFocusedElementSoon() | 1917 void Document::clearFocusedElementSoon() |
| 1945 { | 1918 { |
| 1946 if (!m_clearFocusedElementTimer.isActive()) | 1919 if (!m_clearFocusedElementTimer.isActive()) |
| (...skipping 3961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5908 { | 5881 { |
| 5909 visitor->trace(m_importsController); | 5882 visitor->trace(m_importsController); |
| 5910 visitor->trace(m_docType); | 5883 visitor->trace(m_docType); |
| 5911 visitor->trace(m_implementation); | 5884 visitor->trace(m_implementation); |
| 5912 visitor->trace(m_autofocusElement); | 5885 visitor->trace(m_autofocusElement); |
| 5913 visitor->trace(m_focusedElement); | 5886 visitor->trace(m_focusedElement); |
| 5914 visitor->trace(m_sequentialFocusNavigationStartingPoint); | 5887 visitor->trace(m_sequentialFocusNavigationStartingPoint); |
| 5915 visitor->trace(m_hoverNode); | 5888 visitor->trace(m_hoverNode); |
| 5916 visitor->trace(m_activeHoverElement); | 5889 visitor->trace(m_activeHoverElement); |
| 5917 visitor->trace(m_documentElement); | 5890 visitor->trace(m_documentElement); |
| 5891 visitor->trace(m_rootScroller); | |
| 5918 visitor->trace(m_titleElement); | 5892 visitor->trace(m_titleElement); |
| 5919 visitor->trace(m_axObjectCache); | 5893 visitor->trace(m_axObjectCache); |
| 5920 visitor->trace(m_markers); | 5894 visitor->trace(m_markers); |
| 5921 visitor->trace(m_cssTarget); | 5895 visitor->trace(m_cssTarget); |
| 5922 visitor->trace(m_currentScriptStack); | 5896 visitor->trace(m_currentScriptStack); |
| 5923 visitor->trace(m_scriptRunner); | 5897 visitor->trace(m_scriptRunner); |
| 5924 visitor->trace(m_listsInvalidatedAtDocument); | 5898 visitor->trace(m_listsInvalidatedAtDocument); |
| 5925 for (int i = 0; i < numNodeListInvalidationTypes; ++i) | 5899 for (int i = 0; i < numNodeListInvalidationTypes; ++i) |
| 5926 visitor->trace(m_nodeLists[i]); | 5900 visitor->trace(m_nodeLists[i]); |
| 5927 visitor->trace(m_topLayerElements); | 5901 visitor->trace(m_topLayerElements); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5980 #ifndef NDEBUG | 5954 #ifndef NDEBUG |
| 5981 using namespace blink; | 5955 using namespace blink; |
| 5982 void showLiveDocumentInstances() | 5956 void showLiveDocumentInstances() |
| 5983 { | 5957 { |
| 5984 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5958 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
| 5985 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5959 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 5986 for (Document* document : set) | 5960 for (Document* document : set) |
| 5987 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); | 5961 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); |
| 5988 } | 5962 } |
| 5989 #endif | 5963 #endif |
| OLD | NEW |