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

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

Issue 1895323002: Viewport apply scroll should be on the document element not scrollingElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved attaching applyScroll to childrenChanged 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 if (!frame()) 577 if (!frame())
578 return 0; 578 return 0;
579 579
580 return domWindow()->location(); 580 return domWindow()->location();
581 } 581 }
582 582
583 void Document::childrenChanged(const ChildrenChange& change) 583 void Document::childrenChanged(const ChildrenChange& change)
584 { 584 {
585 ContainerNode::childrenChanged(change); 585 ContainerNode::childrenChanged(change);
586 m_documentElement = ElementTraversal::firstWithin(*this); 586 m_documentElement = ElementTraversal::firstWithin(*this);
587
588 updateViewportApplyScroll();
587 } 589 }
588 590
589 void Document::updateViewportApplyScroll() 591 void Document::updateViewportApplyScroll()
tdresser 2016/04/19 17:48:42 We could put this in an anonymous namespace, and h
bokan 2016/04/19 18:36:27 Done.
590 { 592 {
591 if (!m_documentElement 593 if (!m_documentElement
592 || !m_documentElement->isHTMLElement() 594 || !m_documentElement->isHTMLElement()
593 || ownerElement()) 595 || ownerElement())
594 return; 596 return;
595 597
596 Element* newScrollingElement = scrollingElement(); 598 if (m_documentElement->getApplyScroll())
597
598 // If there is no scrolling element (in QuirksMode and body is scrollable),
599 // install the viewport scroll callback on the <HTML> element.
600 if (!newScrollingElement)
601 newScrollingElement = m_documentElement;
602
603 if (newScrollingElement == m_oldScrollingElement)
604 return; 599 return;
605 600
606 ScrollStateCallback* applyScroll = nullptr; 601 ScrollStateCallback* applyScroll =
602 new ViewportScrollCallback(*this, *frameHost());
607 603
608 // If the scrolling element changed, remove the apply scroll from the 604 // Use disable-native-scroll since the ViewportScrollCallback needs to
609 // old one and keep it to put on the new scrolling element. 605 // apply scroll actions before (TopControls) and after (overscroll)
610 if (m_oldScrollingElement) { 606 // scrolling the element so it applies scroll to the element itself.
611 applyScroll = m_oldScrollingElement->getApplyScroll(); 607 m_documentElement->setApplyScroll(
612 m_oldScrollingElement->removeApplyScroll(); 608 applyScroll,
613 } 609 "disable-native-scroll");
614
615 if (newScrollingElement) {
616 if (!applyScroll)
617 applyScroll = new ViewportScrollCallback(*this, *frameHost());
618
619 // Use disable-native-scroll since the ViewportScrollCallback needs to
620 // apply scroll actions before (TopControls) and after (overscroll)
621 // scrolling the element so it applies scroll to the element itself.
622 newScrollingElement->setApplyScroll(
623 applyScroll,
624 "disable-native-scroll");
625 }
626
627 m_oldScrollingElement = newScrollingElement;
628 } 610 }
629 611
630 AtomicString Document::convertLocalName(const AtomicString& name) 612 AtomicString Document::convertLocalName(const AtomicString& name)
631 { 613 {
632 return isHTMLDocument() ? name.lower() : name; 614 return isHTMLDocument() ? name.lower() : name;
633 } 615 }
634 616
635 Element* Document::createElement(const AtomicString& name, ExceptionState& excep tionState) 617 Element* Document::createElement(const AtomicString& name, ExceptionState& excep tionState)
636 { 618 {
637 if (!isValidName(name)) { 619 if (!isValidName(name)) {
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 1880
1899 if (frameView->needsLayout()) 1881 if (frameView->needsLayout())
1900 frameView->layout(); 1882 frameView->layout();
1901 1883
1902 if (lifecycle().state() < DocumentLifecycle::LayoutClean) 1884 if (lifecycle().state() < DocumentLifecycle::LayoutClean)
1903 lifecycle().advanceTo(DocumentLifecycle::LayoutClean); 1885 lifecycle().advanceTo(DocumentLifecycle::LayoutClean);
1904 } 1886 }
1905 1887
1906 void Document::layoutUpdated() 1888 void Document::layoutUpdated()
1907 { 1889 {
1908 updateViewportApplyScroll();
1909
1910 // Plugins can run script inside layout which can detach the page. 1890 // Plugins can run script inside layout which can detach the page.
1911 // TODO(esprehn): Can this still happen now that all plugins are out of 1891 // TODO(esprehn): Can this still happen now that all plugins are out of
1912 // process? 1892 // process?
1913 if (frame() && frame()->page()) 1893 if (frame() && frame()->page())
1914 frame()->page()->chromeClient().layoutUpdated(frame()); 1894 frame()->page()->chromeClient().layoutUpdated(frame());
1915 1895
1916 markers().updateRenderedRectsForMarkers(); 1896 markers().updateRenderedRectsForMarkers();
1917 1897
1918 // The layout system may perform layouts with pending stylesheets. When 1898 // The layout system may perform layouts with pending stylesheets. When
1919 // recording first layout time, we ignore these layouts, since painting is 1899 // recording first layout time, we ignore these layouts, since painting is
(...skipping 3948 matching lines...) Expand 10 before | Expand all | Expand 10 after
5868 visitor->trace(m_styleEngine); 5848 visitor->trace(m_styleEngine);
5869 visitor->trace(m_formController); 5849 visitor->trace(m_formController);
5870 visitor->trace(m_visitedLinkState); 5850 visitor->trace(m_visitedLinkState);
5871 visitor->trace(m_frame); 5851 visitor->trace(m_frame);
5872 visitor->trace(m_domWindow); 5852 visitor->trace(m_domWindow);
5873 visitor->trace(m_fetcher); 5853 visitor->trace(m_fetcher);
5874 visitor->trace(m_parser); 5854 visitor->trace(m_parser);
5875 visitor->trace(m_contextFeatures); 5855 visitor->trace(m_contextFeatures);
5876 visitor->trace(m_styleSheetList); 5856 visitor->trace(m_styleSheetList);
5877 visitor->trace(m_documentTiming); 5857 visitor->trace(m_documentTiming);
5878 visitor->trace(m_oldScrollingElement);
5879 visitor->trace(m_mediaQueryMatcher); 5858 visitor->trace(m_mediaQueryMatcher);
5880 visitor->trace(m_scriptedAnimationController); 5859 visitor->trace(m_scriptedAnimationController);
5881 visitor->trace(m_scriptedIdleTaskController); 5860 visitor->trace(m_scriptedIdleTaskController);
5882 visitor->trace(m_taskRunner); 5861 visitor->trace(m_taskRunner);
5883 visitor->trace(m_textAutosizer); 5862 visitor->trace(m_textAutosizer);
5884 visitor->trace(m_registrationContext); 5863 visitor->trace(m_registrationContext);
5885 visitor->trace(m_customElementMicrotaskRunQueue); 5864 visitor->trace(m_customElementMicrotaskRunQueue);
5886 visitor->trace(m_elementDataCache); 5865 visitor->trace(m_elementDataCache);
5887 visitor->trace(m_associatedFormControls); 5866 visitor->trace(m_associatedFormControls);
5888 visitor->trace(m_useElementsNeedingUpdate); 5867 visitor->trace(m_useElementsNeedingUpdate);
(...skipping 25 matching lines...) Expand all
5914 #ifndef NDEBUG 5893 #ifndef NDEBUG
5915 using namespace blink; 5894 using namespace blink;
5916 void showLiveDocumentInstances() 5895 void showLiveDocumentInstances()
5917 { 5896 {
5918 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 5897 Document::WeakDocumentSet& set = Document::liveDocumentSet();
5919 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5898 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5920 for (Document* document : set) 5899 for (Document* document : set)
5921 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 5900 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
5922 } 5901 }
5923 #endif 5902 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/input/EventHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698