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

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

Issue 1188563005: Compute snap offsets (both repeat and element based) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use client and scroll size to handle overlay scrollbars 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 #include "core/loader/NavigationScheduler.h" 188 #include "core/loader/NavigationScheduler.h"
189 #include "core/loader/appcache/ApplicationCacheHost.h" 189 #include "core/loader/appcache/ApplicationCacheHost.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/RootScroller.h" 196 #include "core/page/scrolling/RootScroller.h"
197 #include "core/page/scrolling/ScrollingCoordinator.h" 197 #include "core/page/scrolling/ScrollingCoordinator.h"
198 #include "core/page/scrolling/SnapCoordinator.h"
198 #include "core/svg/SVGDocumentExtensions.h" 199 #include "core/svg/SVGDocumentExtensions.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"
207 #include "platform/Histogram.h" 208 #include "platform/Histogram.h"
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 // Visible overflow on the viewport is meaningless, and the spec says to treat it as 'auto': 1629 // Visible overflow on the viewport is meaningless, and the spec says to treat it as 'auto':
1629 if (overflowX == OverflowVisible) 1630 if (overflowX == OverflowVisible)
1630 overflowX = OverflowAuto; 1631 overflowX = OverflowAuto;
1631 if (overflowY == OverflowVisible) 1632 if (overflowY == OverflowVisible)
1632 overflowY = OverflowAuto; 1633 overflowY = OverflowAuto;
1633 // Column-gap is (ab)used by the current paged overflow implementation ( in lack of other 1634 // Column-gap is (ab)used by the current paged overflow implementation ( in lack of other
1634 // ways to specify gaps between pages), so we have to propagate it too. 1635 // ways to specify gaps between pages), so we have to propagate it too.
1635 columnGap = overflowStyle->columnGap(); 1636 columnGap = overflowStyle->columnGap();
1636 } 1637 }
1637 1638
1639 ScrollSnapType snapType = overflowStyle->getScrollSnapType();
1640 const LengthPoint& snapDestination = overflowStyle->scrollSnapDestination();
1641
1638 RefPtr<ComputedStyle> documentStyle = layoutView()->mutableStyle(); 1642 RefPtr<ComputedStyle> documentStyle = layoutView()->mutableStyle();
1639 if (documentStyle->getWritingMode() != rootWritingMode 1643 if (documentStyle->getWritingMode() != rootWritingMode
1640 || documentStyle->direction() != rootDirection 1644 || documentStyle->direction() != rootDirection
1641 || documentStyle->visitedDependentColor(CSSPropertyBackgroundColor) != b ackgroundColor 1645 || documentStyle->visitedDependentColor(CSSPropertyBackgroundColor) != b ackgroundColor
1642 || documentStyle->backgroundLayers() != backgroundLayers 1646 || documentStyle->backgroundLayers() != backgroundLayers
1643 || documentStyle->imageRendering() != imageRendering 1647 || documentStyle->imageRendering() != imageRendering
1644 || documentStyle->overflowX() != overflowX 1648 || documentStyle->overflowX() != overflowX
1645 || documentStyle->overflowY() != overflowY 1649 || documentStyle->overflowY() != overflowY
1646 || documentStyle->columnGap() != columnGap) { 1650 || documentStyle->columnGap() != columnGap
1651 || documentStyle->getScrollSnapType() != snapType
1652 || documentStyle->scrollSnapDestination() != snapDestination) {
1647 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*documentStyle); 1653 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*documentStyle);
1648 newStyle->setWritingMode(rootWritingMode); 1654 newStyle->setWritingMode(rootWritingMode);
1649 newStyle->setDirection(rootDirection); 1655 newStyle->setDirection(rootDirection);
1650 newStyle->setBackgroundColor(backgroundColor); 1656 newStyle->setBackgroundColor(backgroundColor);
1651 newStyle->accessBackgroundLayers() = backgroundLayers; 1657 newStyle->accessBackgroundLayers() = backgroundLayers;
1652 newStyle->setImageRendering(imageRendering); 1658 newStyle->setImageRendering(imageRendering);
1653 newStyle->setOverflowX(overflowX); 1659 newStyle->setOverflowX(overflowX);
1654 newStyle->setOverflowY(overflowY); 1660 newStyle->setOverflowY(overflowY);
1655 newStyle->setColumnGap(columnGap); 1661 newStyle->setColumnGap(columnGap);
1662 newStyle->setScrollSnapType(snapType);
1663 newStyle->setScrollSnapDestination(snapDestination);
1656 layoutView()->setStyle(newStyle); 1664 layoutView()->setStyle(newStyle);
1657 setupFontBuilder(*newStyle); 1665 setupFontBuilder(*newStyle);
1658 } 1666 }
1659 1667
1660 if (body) { 1668 if (body) {
1661 if (const ComputedStyle* style = body->computedStyle()) { 1669 if (const ComputedStyle* style = body->computedStyle()) {
1662 if (style->direction() != rootDirection || style->getWritingMode() ! = rootWritingMode) 1670 if (style->direction() != rootDirection || style->getWritingMode() ! = rootWritingMode)
1663 body->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonF orTracing::create(StyleChangeReason::WritingModeChange)); 1671 body->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonF orTracing::create(StyleChangeReason::WritingModeChange));
1664 } 1672 }
1665 } 1673 }
(...skipping 3845 matching lines...) Expand 10 before | Expand all | Expand 10 after
5511 void Document::setThreadedParsingEnabledForTesting(bool enabled) 5519 void Document::setThreadedParsingEnabledForTesting(bool enabled)
5512 { 5520 {
5513 s_threadedParsingEnabledForTesting = enabled; 5521 s_threadedParsingEnabledForTesting = enabled;
5514 } 5522 }
5515 5523
5516 bool Document::threadedParsingEnabledForTesting() 5524 bool Document::threadedParsingEnabledForTesting()
5517 { 5525 {
5518 return s_threadedParsingEnabledForTesting; 5526 return s_threadedParsingEnabledForTesting;
5519 } 5527 }
5520 5528
5529 SnapCoordinator* Document::snapCoordinator()
5530 {
5531 if (RuntimeEnabledFeatures::cssScrollSnapPointsEnabled() && !m_snapCoordinat or)
5532 m_snapCoordinator = SnapCoordinator::create();
5533
5534 return m_snapCoordinator.get();
5535 }
5536
5521 void Document::setContextFeatures(ContextFeatures& features) 5537 void Document::setContextFeatures(ContextFeatures& features)
5522 { 5538 {
5523 m_contextFeatures = &features; 5539 m_contextFeatures = &features;
5524 } 5540 }
5525 5541
5526 static LayoutObject* nearestCommonHoverAncestor(LayoutObject* obj1, LayoutObject * obj2) 5542 static LayoutObject* nearestCommonHoverAncestor(LayoutObject* obj1, LayoutObject * obj2)
5527 { 5543 {
5528 if (!obj1 || !obj2) 5544 if (!obj1 || !obj2)
5529 return 0; 5545 return 0;
5530 5546
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
5952 visitor->trace(m_templateDocumentHost); 5968 visitor->trace(m_templateDocumentHost);
5953 visitor->trace(m_visibilityObservers); 5969 visitor->trace(m_visibilityObservers);
5954 visitor->trace(m_userActionElements); 5970 visitor->trace(m_userActionElements);
5955 visitor->trace(m_svgExtensions); 5971 visitor->trace(m_svgExtensions);
5956 visitor->trace(m_timeline); 5972 visitor->trace(m_timeline);
5957 visitor->trace(m_compositorPendingAnimations); 5973 visitor->trace(m_compositorPendingAnimations);
5958 visitor->trace(m_contextDocument); 5974 visitor->trace(m_contextDocument);
5959 visitor->trace(m_canvasFontCache); 5975 visitor->trace(m_canvasFontCache);
5960 visitor->trace(m_intersectionObserverController); 5976 visitor->trace(m_intersectionObserverController);
5961 visitor->trace(m_intersectionObserverData); 5977 visitor->trace(m_intersectionObserverData);
5978 visitor->trace(m_snapCoordinator);
5962 Supplementable<Document>::trace(visitor); 5979 Supplementable<Document>::trace(visitor);
5963 TreeScope::trace(visitor); 5980 TreeScope::trace(visitor);
5964 ContainerNode::trace(visitor); 5981 ContainerNode::trace(visitor);
5965 ExecutionContext::trace(visitor); 5982 ExecutionContext::trace(visitor);
5966 DocumentLifecycleNotifier::trace(visitor); 5983 DocumentLifecycleNotifier::trace(visitor);
5967 SecurityContext::trace(visitor); 5984 SecurityContext::trace(visitor);
5968 } 5985 }
5969 5986
5970 template class CORE_TEMPLATE_EXPORT Supplement<Document>; 5987 template class CORE_TEMPLATE_EXPORT Supplement<Document>;
5971 5988
5972 } // namespace blink 5989 } // namespace blink
5973 5990
5974 #ifndef NDEBUG 5991 #ifndef NDEBUG
5975 using namespace blink; 5992 using namespace blink;
5976 void showLiveDocumentInstances() 5993 void showLiveDocumentInstances()
5977 { 5994 {
5978 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 5995 Document::WeakDocumentSet& set = Document::liveDocumentSet();
5979 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5996 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5980 for (Document* document : set) 5997 for (Document* document : set)
5981 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 5998 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
5982 } 5999 }
5983 #endif 6000 #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