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

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

Issue 1188563005: Compute snap offsets (both repeat and element based) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: remove m_frame Created 5 years, 2 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 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 #include "core/layout/LayoutView.h" 109 #include "core/layout/LayoutView.h"
110 #include "core/loader/DocumentLoader.h" 110 #include "core/loader/DocumentLoader.h"
111 #include "core/page/ChromeClient.h" 111 #include "core/page/ChromeClient.h"
112 #include "core/page/FocusController.h" 112 #include "core/page/FocusController.h"
113 #include "core/page/Page.h" 113 #include "core/page/Page.h"
114 #include "core/page/PointerLockController.h" 114 #include "core/page/PointerLockController.h"
115 #include "core/page/SpatialNavigation.h" 115 #include "core/page/SpatialNavigation.h"
116 #include "core/page/scrolling/ScrollCustomizationCallbacks.h" 116 #include "core/page/scrolling/ScrollCustomizationCallbacks.h"
117 #include "core/page/scrolling/ScrollState.h" 117 #include "core/page/scrolling/ScrollState.h"
118 #include "core/page/scrolling/ScrollStateCallback.h" 118 #include "core/page/scrolling/ScrollStateCallback.h"
119 #include "core/page/scrolling/SnapCoordinator.h"
119 #include "core/paint/PaintLayer.h" 120 #include "core/paint/PaintLayer.h"
120 #include "core/svg/SVGDocumentExtensions.h" 121 #include "core/svg/SVGDocumentExtensions.h"
121 #include "core/svg/SVGElement.h" 122 #include "core/svg/SVGElement.h"
122 #include "platform/EventDispatchForbiddenScope.h" 123 #include "platform/EventDispatchForbiddenScope.h"
123 #include "platform/RuntimeEnabledFeatures.h" 124 #include "platform/RuntimeEnabledFeatures.h"
124 #include "platform/UserGestureIndicator.h" 125 #include "platform/UserGestureIndicator.h"
125 #include "platform/scroll/ScrollableArea.h" 126 #include "platform/scroll/ScrollableArea.h"
126 #include "wtf/BitVector.h" 127 #include "wtf/BitVector.h"
127 #include "wtf/HashFunctions.h" 128 #include "wtf/HashFunctions.h"
128 #include "wtf/text/CString.h" 129 #include "wtf/text/CString.h"
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 // We've already been through detach when doing an attach, but we might 1524 // We've already been through detach when doing an attach, but we might
1524 // need to clear any state that's been added since then. 1525 // need to clear any state that's been added since then.
1525 if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) { 1526 if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) {
1526 ElementRareData* data = elementRareData(); 1527 ElementRareData* data = elementRareData();
1527 data->clearComputedStyle(); 1528 data->clearComputedStyle();
1528 } 1529 }
1529 1530
1530 if (!isActiveInsertionPoint(*this)) 1531 if (!isActiveInsertionPoint(*this))
1531 LayoutTreeBuilderForElement(*this, context.resolvedStyle).createLayoutOb jectIfNeeded(); 1532 LayoutTreeBuilderForElement(*this, context.resolvedStyle).createLayoutOb jectIfNeeded();
1532 1533
1533 addCallbackSelectors(); 1534 const ComputedStyle* style = computedStyle();
1535 addCallbackSelectors(style);
1536 addScrollSnapMapping(style);
1534 1537
1535 if (hasRareData() && !layoutObject()) { 1538 if (hasRareData() && !layoutObject()) {
1536 if (ElementAnimations* elementAnimations = elementRareData()->elementAni mations()) { 1539 if (ElementAnimations* elementAnimations = elementRareData()->elementAni mations()) {
1537 elementAnimations->cssAnimations().cancel(); 1540 elementAnimations->cssAnimations().cancel();
1538 elementAnimations->setAnimationStyleChange(false); 1541 elementAnimations->setAnimationStyleChange(false);
1539 } 1542 }
1540 } 1543 }
1541 1544
1542 StyleResolverParentScope parentScope(*this); 1545 StyleResolverParentScope parentScope(*this);
1543 1546
(...skipping 11 matching lines...) Expand all
1555 // We create the first-letter element after the :before, :after and 1558 // We create the first-letter element after the :before, :after and
1556 // children are attached because the first letter text could come 1559 // children are attached because the first letter text could come
1557 // from any of them. 1560 // from any of them.
1558 createPseudoElementIfNeeded(FIRST_LETTER); 1561 createPseudoElementIfNeeded(FIRST_LETTER);
1559 } 1562 }
1560 1563
1561 void Element::detach(const AttachContext& context) 1564 void Element::detach(const AttachContext& context)
1562 { 1565 {
1563 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; 1566 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
1564 cancelFocusAppearanceUpdate(); 1567 cancelFocusAppearanceUpdate();
1565 removeCallbackSelectors(); 1568
1569 const ComputedStyle* style = computedStyle();
1570 removeCallbackSelectors(style);
1571 removeScrollSnapMapping(style);
1572
1566 if (hasRareData()) { 1573 if (hasRareData()) {
1567 ElementRareData* data = elementRareData(); 1574 ElementRareData* data = elementRareData();
1568 data->clearPseudoElements(); 1575 data->clearPseudoElements();
1569 1576
1570 // attach() will clear the computed style for us when inside recalcStyle . 1577 // attach() will clear the computed style for us when inside recalcStyle .
1571 if (!document().inStyleRecalc()) 1578 if (!document().inStyleRecalc())
1572 data->clearComputedStyle(); 1579 data->clearComputedStyle();
1573 1580
1574 if (ElementAnimations* elementAnimations = data->elementAnimations()) { 1581 if (ElementAnimations* elementAnimations = data->elementAnimations()) {
1575 if (context.performingReattach) { 1582 if (context.performingReattach) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 reattachContext.resolvedStyle = newStyle.get(); 1772 reattachContext.resolvedStyle = newStyle.get();
1766 bool layoutObjectWillChange = needsAttach() || layoutObject(); 1773 bool layoutObjectWillChange = needsAttach() || layoutObject();
1767 reattach(reattachContext); 1774 reattach(reattachContext);
1768 if (layoutObjectWillChange || layoutObject()) 1775 if (layoutObjectWillChange || layoutObject())
1769 return Reattach; 1776 return Reattach;
1770 return ReattachNoLayoutObject; 1777 return ReattachNoLayoutObject;
1771 } 1778 }
1772 1779
1773 ASSERT(oldStyle); 1780 ASSERT(oldStyle);
1774 1781
1775 if (localChange != NoChange) 1782 if (localChange != NoChange) {
1776 updateCallbackSelectors(oldStyle.get(), newStyle.get()); 1783 updateCallbackSelectors(oldStyle.get(), newStyle.get());
1784 updateScrollSnapMapping(oldStyle.get(), newStyle.get());
1785 }
1777 1786
1778 if (LayoutObject* layoutObject = this->layoutObject()) { 1787 if (LayoutObject* layoutObject = this->layoutObject()) {
1779 if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()) || svgFilterNeedsLayerUpdate()) { 1788 if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()) || svgFilterNeedsLayerUpdate()) {
1780 layoutObject->setStyle(newStyle.get()); 1789 layoutObject->setStyle(newStyle.get());
1781 } else { 1790 } else {
1782 // Although no change occurred, we use the new style so that the cou sin style sharing code won't get 1791 // Although no change occurred, we use the new style so that the cou sin style sharing code won't get
1783 // fooled into believing this style is the same. 1792 // fooled into believing this style is the same.
1784 // FIXME: We may be able to remove this hack, see discussion in 1793 // FIXME: We may be able to remove this hack, see discussion in
1785 // https://codereview.chromium.org/30453002/ 1794 // https://codereview.chromium.org/30453002/
1786 layoutObject->setStyleInternal(newStyle.get()); 1795 layoutObject->setStyleInternal(newStyle.get());
(...skipping 23 matching lines...) Expand all
1810 { 1819 {
1811 Vector<String> emptyVector; 1820 Vector<String> emptyVector;
1812 const Vector<String>& oldCallbackSelectors = oldStyle ? oldStyle->callbackSe lectors() : emptyVector; 1821 const Vector<String>& oldCallbackSelectors = oldStyle ? oldStyle->callbackSe lectors() : emptyVector;
1813 const Vector<String>& newCallbackSelectors = newStyle ? newStyle->callbackSe lectors() : emptyVector; 1822 const Vector<String>& newCallbackSelectors = newStyle ? newStyle->callbackSe lectors() : emptyVector;
1814 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty()) 1823 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty())
1815 return; 1824 return;
1816 if (oldCallbackSelectors != newCallbackSelectors) 1825 if (oldCallbackSelectors != newCallbackSelectors)
1817 CSSSelectorWatch::from(document()).updateSelectorMatches(oldCallbackSele ctors, newCallbackSelectors); 1826 CSSSelectorWatch::from(document()).updateSelectorMatches(oldCallbackSele ctors, newCallbackSelectors);
1818 } 1827 }
1819 1828
1820 void Element::addCallbackSelectors() 1829 void Element::addCallbackSelectors(const ComputedStyle* style)
1821 { 1830 {
1822 updateCallbackSelectors(0, computedStyle()); 1831 updateCallbackSelectors(0, style);
1823 } 1832 }
1824 1833
1825 void Element::removeCallbackSelectors() 1834 void Element::removeCallbackSelectors(const ComputedStyle* style)
1826 { 1835 {
1827 updateCallbackSelectors(computedStyle(), 0); 1836 updateCallbackSelectors(style, 0);
1828 } 1837 }
1829 1838
1839 void Element::updateScrollSnapMapping(const ComputedStyle* oldStyle, const Compu tedStyle* newStyle)
1840 {
1841 SnapCoordinator* snapCoordinator = document().snapCoordinator();
1842 if (!snapCoordinator)
1843 return;
1844
1845 ScrollSnapType oldSnapType = oldStyle ? oldStyle->scrollSnapType() : Scroll SnapTypeNone;
1846 ScrollSnapType newSnapType = newStyle ? newStyle->scrollSnapType() : Scroll SnapTypeNone;
1847 if (oldSnapType != newSnapType)
1848 snapCoordinator->snapContainerDidChange(*this, newSnapType);
1849
1850 Vector<LengthPoint> emptyVector;
1851 Vector<LengthPoint> oldSnapCoordinate = oldStyle ? oldStyle->scrollSnapCoord inate() : emptyVector;
1852 Vector<LengthPoint> newSnapCoordinate = newStyle ? newStyle->scrollSnapCoord inate() : emptyVector;
esprehn 2015/10/20 21:03:35 This means making copies all the time, I think you
1853 if (oldSnapCoordinate != newSnapCoordinate)
1854 snapCoordinator->snapElementDidChange(*this, newSnapCoordinate);
1855 }
1856
1857 void Element::addScrollSnapMapping(const ComputedStyle* style)
1858 {
1859 updateScrollSnapMapping(0, style);
1860 }
1861
1862 void Element::removeScrollSnapMapping(const ComputedStyle* style)
1863 {
1864 updateScrollSnapMapping(style, 0);
1865 }
1866
1867
1830 ElementShadow* Element::shadow() const 1868 ElementShadow* Element::shadow() const
1831 { 1869 {
1832 return hasRareData() ? elementRareData()->shadow() : nullptr; 1870 return hasRareData() ? elementRareData()->shadow() : nullptr;
1833 } 1871 }
1834 1872
1835 ElementShadow& Element::ensureShadow() 1873 ElementShadow& Element::ensureShadow()
1836 { 1874 {
1837 return ensureElementRareData().ensureShadow(); 1875 return ensureElementRareData().ensureShadow();
1838 } 1876 }
1839 1877
(...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after
3564 { 3602 {
3565 #if ENABLE(OILPAN) 3603 #if ENABLE(OILPAN)
3566 if (hasRareData()) 3604 if (hasRareData())
3567 visitor->trace(elementRareData()); 3605 visitor->trace(elementRareData());
3568 visitor->trace(m_elementData); 3606 visitor->trace(m_elementData);
3569 #endif 3607 #endif
3570 ContainerNode::trace(visitor); 3608 ContainerNode::trace(visitor);
3571 } 3609 }
3572 3610
3573 } // namespace blink 3611 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698