Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 1840113005: Move viewport actions into an ApplyScroll callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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/origin_trials/DocumentOriginTrialContext.h" 189 #include "core/origin_trials/DocumentOriginTrialContext.h"
190 #include "core/page/ChromeClient.h" 190 #include "core/page/ChromeClient.h"
191 #include "core/page/EventWithHitTestResults.h" 191 #include "core/page/EventWithHitTestResults.h"
192 #include "core/page/FocusController.h" 192 #include "core/page/FocusController.h"
193 #include "core/page/FrameTree.h" 193 #include "core/page/FrameTree.h"
194 #include "core/page/Page.h" 194 #include "core/page/Page.h"
195 #include "core/page/PointerLockController.h" 195 #include "core/page/PointerLockController.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/SVGTitleElement.h" 199 #include "core/svg/SVGTitleElement.h"
199 #include "core/svg/SVGUseElement.h" 200 #include "core/svg/SVGUseElement.h"
200 #include "core/timing/DOMWindowPerformance.h" 201 #include "core/timing/DOMWindowPerformance.h"
201 #include "core/timing/Performance.h" 202 #include "core/timing/Performance.h"
202 #include "core/workers/SharedWorkerRepositoryClient.h" 203 #include "core/workers/SharedWorkerRepositoryClient.h"
203 #include "core/xml/parser/XMLDocumentParser.h" 204 #include "core/xml/parser/XMLDocumentParser.h"
204 #include "platform/DateComponents.h" 205 #include "platform/DateComponents.h"
205 #include "platform/EventDispatchForbiddenScope.h" 206 #include "platform/EventDispatchForbiddenScope.h"
206 #include "platform/Histogram.h" 207 #include "platform/Histogram.h"
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 695
695 return domWindow()->location(); 696 return domWindow()->location();
696 } 697 }
697 698
698 void Document::childrenChanged(const ChildrenChange& change) 699 void Document::childrenChanged(const ChildrenChange& change)
699 { 700 {
700 ContainerNode::childrenChanged(change); 701 ContainerNode::childrenChanged(change);
701 m_documentElement = ElementTraversal::firstWithin(*this); 702 m_documentElement = ElementTraversal::firstWithin(*this);
702 } 703 }
703 704
705 void Document::updateViewportApplyScroll()
706 {
707 if (!m_documentElement
708 || !m_documentElement->isHTMLElement()
709 || ownerElement())
710 return;
711
712 Element* newScrollingElement = scrollingElement();
713
714 // If there is no scrolling element (in QuirksMode and body is scrollable),
715 // install the viewport scroll callback on the <HTML> element.
716 if (!newScrollingElement)
717 newScrollingElement = m_documentElement;
718
719 if (newScrollingElement == m_oldScrollingElement)
720 return;
721
722 ScrollStateCallback* applyScroll = nullptr;
723
724 // If the scrolling element changed, remove the apply scroll from the
725 // old one and keep it to put on the new scrolling element.
726 if (m_oldScrollingElement) {
tdresser 2016/04/05 19:31:12 Ah, is this why we need m_oldScrollingElement to b
bokan 2016/04/06 15:21:01 Ah, TBH I did that out of habit and hadn't thought
bokan 2016/04/07 01:27:15 Ok, as far as I can tell there's no way to detach
727 applyScroll = m_oldScrollingElement->getApplyScroll();
728 m_oldScrollingElement->removeApplyScroll();
729 }
730
731 if (newScrollingElement) {
732 if (!applyScroll)
733 applyScroll = new ViewportScrollCallback(*this, *frameHost());
tdresser 2016/04/05 19:31:12 This is going to end up looking pretty different o
bokan 2016/04/06 15:21:01 Acknowledged.
734
735 newScrollingElement->setApplyScroll(
736 applyScroll,
737 "disable-native-scroll");
tdresser 2016/04/05 19:31:12 Add a comment indicating why we disable-native-scr
bokan 2016/04/06 15:21:01 Done.
738 }
739
740 m_oldScrollingElement = newScrollingElement;
741 }
742
704 AtomicString Document::convertLocalName(const AtomicString& name) 743 AtomicString Document::convertLocalName(const AtomicString& name)
705 { 744 {
706 return isHTMLDocument() ? name.lower() : name; 745 return isHTMLDocument() ? name.lower() : name;
707 } 746 }
708 747
709 RawPtr<Element> Document::createElement(const AtomicString& name, ExceptionState & exceptionState) 748 RawPtr<Element> Document::createElement(const AtomicString& name, ExceptionState & exceptionState)
710 { 749 {
711 if (!isValidName(name)) { 750 if (!isValidName(name)) {
712 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name."); 751 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name.");
713 return nullptr; 752 return nullptr;
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 2012
1974 if (frameView->needsLayout()) 2013 if (frameView->needsLayout())
1975 frameView->layout(); 2014 frameView->layout();
1976 2015
1977 if (lifecycle().state() < DocumentLifecycle::LayoutClean) 2016 if (lifecycle().state() < DocumentLifecycle::LayoutClean)
1978 lifecycle().advanceTo(DocumentLifecycle::LayoutClean); 2017 lifecycle().advanceTo(DocumentLifecycle::LayoutClean);
1979 } 2018 }
1980 2019
1981 void Document::layoutUpdated() 2020 void Document::layoutUpdated()
1982 { 2021 {
2022 updateViewportApplyScroll();
bokan 2016/04/04 21:44:38 This is the wrong place for this. Because scrollin
2023
1983 // Plugins can run script inside layout which can detach the page. 2024 // Plugins can run script inside layout which can detach the page.
1984 // TODO(esprehn): Can this still happen now that all plugins are out of 2025 // TODO(esprehn): Can this still happen now that all plugins are out of
1985 // process? 2026 // process?
1986 if (frame() && frame()->page()) 2027 if (frame() && frame()->page())
1987 frame()->page()->chromeClient().layoutUpdated(frame()); 2028 frame()->page()->chromeClient().layoutUpdated(frame());
1988 2029
1989 markers().updateRenderedRectsForMarkers(); 2030 markers().updateRenderedRectsForMarkers();
1990 2031
1991 // The layout system may perform layouts with pending stylesheets. When 2032 // The layout system may perform layouts with pending stylesheets. When
1992 // recording first layout time, we ignore these layouts, since painting is 2033 // recording first layout time, we ignore these layouts, since painting is
(...skipping 3992 matching lines...) Expand 10 before | Expand all | Expand 10 after
5985 visitor->trace(m_styleEngine); 6026 visitor->trace(m_styleEngine);
5986 visitor->trace(m_formController); 6027 visitor->trace(m_formController);
5987 visitor->trace(m_visitedLinkState); 6028 visitor->trace(m_visitedLinkState);
5988 visitor->trace(m_frame); 6029 visitor->trace(m_frame);
5989 visitor->trace(m_domWindow); 6030 visitor->trace(m_domWindow);
5990 visitor->trace(m_fetcher); 6031 visitor->trace(m_fetcher);
5991 visitor->trace(m_parser); 6032 visitor->trace(m_parser);
5992 visitor->trace(m_contextFeatures); 6033 visitor->trace(m_contextFeatures);
5993 visitor->trace(m_styleSheetList); 6034 visitor->trace(m_styleSheetList);
5994 visitor->trace(m_documentTiming); 6035 visitor->trace(m_documentTiming);
6036 visitor->trace(m_oldScrollingElement);
5995 visitor->trace(m_mediaQueryMatcher); 6037 visitor->trace(m_mediaQueryMatcher);
5996 visitor->trace(m_scriptedAnimationController); 6038 visitor->trace(m_scriptedAnimationController);
5997 visitor->trace(m_scriptedIdleTaskController); 6039 visitor->trace(m_scriptedIdleTaskController);
5998 visitor->trace(m_taskRunner); 6040 visitor->trace(m_taskRunner);
5999 visitor->trace(m_textAutosizer); 6041 visitor->trace(m_textAutosizer);
6000 visitor->trace(m_registrationContext); 6042 visitor->trace(m_registrationContext);
6001 visitor->trace(m_customElementMicrotaskRunQueue); 6043 visitor->trace(m_customElementMicrotaskRunQueue);
6002 visitor->trace(m_elementDataCache); 6044 visitor->trace(m_elementDataCache);
6003 visitor->trace(m_associatedFormControls); 6045 visitor->trace(m_associatedFormControls);
6004 visitor->trace(m_useElementsNeedingUpdate); 6046 visitor->trace(m_useElementsNeedingUpdate);
(...skipping 25 matching lines...) Expand all
6030 #ifndef NDEBUG 6072 #ifndef NDEBUG
6031 using namespace blink; 6073 using namespace blink;
6032 void showLiveDocumentInstances() 6074 void showLiveDocumentInstances()
6033 { 6075 {
6034 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 6076 Document::WeakDocumentSet& set = Document::liveDocumentSet();
6035 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6077 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6036 for (Document* document : set) 6078 for (Document* document : set)
6037 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6079 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6038 } 6080 }
6039 #endif 6081 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698