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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Element.cpp
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp
index 68af23e2104623ab7161b1d3d3d92e123197ecf8..c8b85eeb4d8e3f748d80c68fb86af57391c9a677 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -116,6 +116,7 @@
#include "core/page/scrolling/ScrollCustomizationCallbacks.h"
#include "core/page/scrolling/ScrollState.h"
#include "core/page/scrolling/ScrollStateCallback.h"
+#include "core/page/scrolling/SnapCoordinator.h"
#include "core/paint/PaintLayer.h"
#include "core/svg/SVGDocumentExtensions.h"
#include "core/svg/SVGElement.h"
@@ -1530,7 +1531,9 @@ void Element::attach(const AttachContext& context)
if (!isActiveInsertionPoint(*this))
LayoutTreeBuilderForElement(*this, context.resolvedStyle).createLayoutObjectIfNeeded();
- addCallbackSelectors();
+ const ComputedStyle* style = computedStyle();
+ addCallbackSelectors(style);
+ addScrollSnapMapping(style);
if (hasRareData() && !layoutObject()) {
if (ElementAnimations* elementAnimations = elementRareData()->elementAnimations()) {
@@ -1562,7 +1565,11 @@ void Element::detach(const AttachContext& context)
{
HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
cancelFocusAppearanceUpdate();
- removeCallbackSelectors();
+
+ const ComputedStyle* style = computedStyle();
+ removeCallbackSelectors(style);
+ removeScrollSnapMapping(style);
+
if (hasRareData()) {
ElementRareData* data = elementRareData();
data->clearPseudoElements();
@@ -1772,8 +1779,10 @@ StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change)
ASSERT(oldStyle);
- if (localChange != NoChange)
+ if (localChange != NoChange) {
updateCallbackSelectors(oldStyle.get(), newStyle.get());
+ updateScrollSnapMapping(oldStyle.get(), newStyle.get());
+ }
if (LayoutObject* layoutObject = this->layoutObject()) {
if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()) || svgFilterNeedsLayerUpdate()) {
@@ -1817,16 +1826,45 @@ void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, const Compu
CSSSelectorWatch::from(document()).updateSelectorMatches(oldCallbackSelectors, newCallbackSelectors);
}
-void Element::addCallbackSelectors()
+void Element::addCallbackSelectors(const ComputedStyle* style)
+{
+ updateCallbackSelectors(0, style);
+}
+
+void Element::removeCallbackSelectors(const ComputedStyle* style)
+{
+ updateCallbackSelectors(style, 0);
+}
+
+void Element::updateScrollSnapMapping(const ComputedStyle* oldStyle, const ComputedStyle* newStyle)
{
- updateCallbackSelectors(0, computedStyle());
+ SnapCoordinator* snapCoordinator = document().snapCoordinator();
+ if (!snapCoordinator)
+ return;
+
+ ScrollSnapType oldSnapType = oldStyle ? oldStyle->scrollSnapType() : ScrollSnapTypeNone;
+ ScrollSnapType newSnapType = newStyle ? newStyle->scrollSnapType() : ScrollSnapTypeNone;
+ if (oldSnapType != newSnapType)
+ snapCoordinator->snapContainerDidChange(*this, newSnapType);
+
+ Vector<LengthPoint> emptyVector;
+ Vector<LengthPoint> oldSnapCoordinate = oldStyle ? oldStyle->scrollSnapCoordinate() : emptyVector;
+ Vector<LengthPoint> newSnapCoordinate = newStyle ? newStyle->scrollSnapCoordinate() : emptyVector;
esprehn 2015/10/20 21:03:35 This means making copies all the time, I think you
+ if (oldSnapCoordinate != newSnapCoordinate)
+ snapCoordinator->snapElementDidChange(*this, newSnapCoordinate);
}
-void Element::removeCallbackSelectors()
+void Element::addScrollSnapMapping(const ComputedStyle* style)
{
- updateCallbackSelectors(computedStyle(), 0);
+ updateScrollSnapMapping(0, style);
}
+void Element::removeScrollSnapMapping(const ComputedStyle* style)
+{
+ updateScrollSnapMapping(style, 0);
+}
+
+
ElementShadow* Element::shadow() const
{
return hasRareData() ? elementRareData()->shadow() : nullptr;

Powered by Google App Engine
This is Rietveld 408576698