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

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

Issue 1970563002: Compute snap offsets according to CSS Scroll Snap Spec Level 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/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/SnapCoordinator.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 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 // Visible overflow on the viewport is meaningless, and the spec says to treat it as 'auto': 1619 // Visible overflow on the viewport is meaningless, and the spec says to treat it as 'auto':
1619 if (overflowX == OverflowVisible) 1620 if (overflowX == OverflowVisible)
1620 overflowX = OverflowAuto; 1621 overflowX = OverflowAuto;
1621 if (overflowY == OverflowVisible) 1622 if (overflowY == OverflowVisible)
1622 overflowY = OverflowAuto; 1623 overflowY = OverflowAuto;
1623 // Column-gap is (ab)used by the current paged overflow implementation ( in lack of other 1624 // Column-gap is (ab)used by the current paged overflow implementation ( in lack of other
1624 // ways to specify gaps between pages), so we have to propagate it too. 1625 // ways to specify gaps between pages), so we have to propagate it too.
1625 columnGap = overflowStyle->columnGap(); 1626 columnGap = overflowStyle->columnGap();
1626 } 1627 }
1627 1628
1629 ScrollSnapType snapType = overflowStyle->getScrollSnapType();
1630 const LengthPoint& snapDestination = overflowStyle->scrollSnapDestination();
1631
1628 RefPtr<ComputedStyle> documentStyle = layoutView()->mutableStyle(); 1632 RefPtr<ComputedStyle> documentStyle = layoutView()->mutableStyle();
1629 if (documentStyle->getWritingMode() != rootWritingMode 1633 if (documentStyle->getWritingMode() != rootWritingMode
1630 || documentStyle->direction() != rootDirection 1634 || documentStyle->direction() != rootDirection
1631 || documentStyle->visitedDependentColor(CSSPropertyBackgroundColor) != b ackgroundColor 1635 || documentStyle->visitedDependentColor(CSSPropertyBackgroundColor) != b ackgroundColor
1632 || documentStyle->backgroundLayers() != backgroundLayers 1636 || documentStyle->backgroundLayers() != backgroundLayers
1633 || documentStyle->imageRendering() != imageRendering 1637 || documentStyle->imageRendering() != imageRendering
1634 || documentStyle->overflowX() != overflowX 1638 || documentStyle->overflowX() != overflowX
1635 || documentStyle->overflowY() != overflowY 1639 || documentStyle->overflowY() != overflowY
1636 || documentStyle->columnGap() != columnGap) { 1640 || documentStyle->columnGap() != columnGap
1641 || documentStyle->getScrollSnapType() != snapType
1642 || documentStyle->scrollSnapDestination() != snapDestination) {
1637 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*documentStyle); 1643 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*documentStyle);
1638 newStyle->setWritingMode(rootWritingMode); 1644 newStyle->setWritingMode(rootWritingMode);
1639 newStyle->setDirection(rootDirection); 1645 newStyle->setDirection(rootDirection);
1640 newStyle->setBackgroundColor(backgroundColor); 1646 newStyle->setBackgroundColor(backgroundColor);
1641 newStyle->accessBackgroundLayers() = backgroundLayers; 1647 newStyle->accessBackgroundLayers() = backgroundLayers;
1642 newStyle->setImageRendering(imageRendering); 1648 newStyle->setImageRendering(imageRendering);
1643 newStyle->setOverflowX(overflowX); 1649 newStyle->setOverflowX(overflowX);
1644 newStyle->setOverflowY(overflowY); 1650 newStyle->setOverflowY(overflowY);
1645 newStyle->setColumnGap(columnGap); 1651 newStyle->setColumnGap(columnGap);
1652 newStyle->setScrollSnapType(snapType);
1653 newStyle->setScrollSnapDestination(snapDestination);
1646 layoutView()->setStyle(newStyle); 1654 layoutView()->setStyle(newStyle);
1647 setupFontBuilder(*newStyle); 1655 setupFontBuilder(*newStyle);
1648 } 1656 }
1649 1657
1650 if (body) { 1658 if (body) {
1651 if (const ComputedStyle* style = body->computedStyle()) { 1659 if (const ComputedStyle* style = body->computedStyle()) {
1652 if (style->direction() != rootDirection || style->getWritingMode() ! = rootWritingMode) 1660 if (style->direction() != rootDirection || style->getWritingMode() ! = rootWritingMode)
1653 body->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonF orTracing::create(StyleChangeReason::WritingModeChange)); 1661 body->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonF orTracing::create(StyleChangeReason::WritingModeChange));
1654 } 1662 }
1655 } 1663 }
(...skipping 3857 matching lines...) Expand 10 before | Expand all | Expand 10 after
5513 void Document::setThreadedParsingEnabledForTesting(bool enabled) 5521 void Document::setThreadedParsingEnabledForTesting(bool enabled)
5514 { 5522 {
5515 s_threadedParsingEnabledForTesting = enabled; 5523 s_threadedParsingEnabledForTesting = enabled;
5516 } 5524 }
5517 5525
5518 bool Document::threadedParsingEnabledForTesting() 5526 bool Document::threadedParsingEnabledForTesting()
5519 { 5527 {
5520 return s_threadedParsingEnabledForTesting; 5528 return s_threadedParsingEnabledForTesting;
5521 } 5529 }
5522 5530
5531 SnapCoordinator* Document::snapCoordinator()
5532 {
5533 if (RuntimeEnabledFeatures::cssScrollSnapPointsEnabled() && !m_snapCoordinat or)
5534 m_snapCoordinator = SnapCoordinator::create();
5535
5536 return m_snapCoordinator.get();
5537 }
5538
5523 void Document::setContextFeatures(ContextFeatures& features) 5539 void Document::setContextFeatures(ContextFeatures& features)
5524 { 5540 {
5525 m_contextFeatures = &features; 5541 m_contextFeatures = &features;
5526 } 5542 }
5527 5543
5528 static LayoutObject* nearestCommonHoverAncestor(LayoutObject* obj1, LayoutObject * obj2) 5544 static LayoutObject* nearestCommonHoverAncestor(LayoutObject* obj1, LayoutObject * obj2)
5529 { 5545 {
5530 if (!obj1 || !obj2) 5546 if (!obj1 || !obj2)
5531 return 0; 5547 return 0;
5532 5548
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
5953 visitor->trace(m_templateDocument); 5969 visitor->trace(m_templateDocument);
5954 visitor->trace(m_templateDocumentHost); 5970 visitor->trace(m_templateDocumentHost);
5955 visitor->trace(m_userActionElements); 5971 visitor->trace(m_userActionElements);
5956 visitor->trace(m_svgExtensions); 5972 visitor->trace(m_svgExtensions);
5957 visitor->trace(m_timeline); 5973 visitor->trace(m_timeline);
5958 visitor->trace(m_compositorPendingAnimations); 5974 visitor->trace(m_compositorPendingAnimations);
5959 visitor->trace(m_contextDocument); 5975 visitor->trace(m_contextDocument);
5960 visitor->trace(m_canvasFontCache); 5976 visitor->trace(m_canvasFontCache);
5961 visitor->trace(m_intersectionObserverController); 5977 visitor->trace(m_intersectionObserverController);
5962 visitor->trace(m_intersectionObserverData); 5978 visitor->trace(m_intersectionObserverData);
5979 visitor->trace(m_snapCoordinator);
5963 Supplementable<Document>::trace(visitor); 5980 Supplementable<Document>::trace(visitor);
5964 TreeScope::trace(visitor); 5981 TreeScope::trace(visitor);
5965 ContainerNode::trace(visitor); 5982 ContainerNode::trace(visitor);
5966 ExecutionContext::trace(visitor); 5983 ExecutionContext::trace(visitor);
5967 SecurityContext::trace(visitor); 5984 SecurityContext::trace(visitor);
5968 } 5985 }
5969 5986
5970 DEFINE_TRACE_WRAPPERS(Document) 5987 DEFINE_TRACE_WRAPPERS(Document)
5971 { 5988 {
5972 visitor->traceWrappers(m_importsController); 5989 visitor->traceWrappers(m_importsController);
5973 ContainerNode::traceWrappers(visitor); 5990 ContainerNode::traceWrappers(visitor);
5974 } 5991 }
5975 5992
5976 template class CORE_TEMPLATE_EXPORT Supplement<Document>; 5993 template class CORE_TEMPLATE_EXPORT Supplement<Document>;
5977 5994
5978 } // namespace blink 5995 } // namespace blink
5979 5996
5980 #ifndef NDEBUG 5997 #ifndef NDEBUG
5981 using namespace blink; 5998 using namespace blink;
5982 void showLiveDocumentInstances() 5999 void showLiveDocumentInstances()
5983 { 6000 {
5984 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 6001 Document::WeakDocumentSet& set = Document::liveDocumentSet();
5985 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6002 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5986 for (Document* document : set) 6003 for (Document* document : set)
5987 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6004 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
5988 } 6005 }
5989 #endif 6006 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/frame/LocalFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698