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

Unified Diff: third_party/WebKit/Source/core/input/ScrollManager.cpp

Issue 2769793002: Implement CSS: scroll-boundary-behavior (Closed)
Patch Set: Add documentation Created 3 years, 5 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/input/ScrollManager.cpp
diff --git a/third_party/WebKit/Source/core/input/ScrollManager.cpp b/third_party/WebKit/Source/core/input/ScrollManager.cpp
index 0d4a7cb180e276e187db3c6488917ace6589fea7..be52af5fff30e99680f1506e9651b0c6703a9ce1 100644
--- a/third_party/WebKit/Source/core/input/ScrollManager.cpp
+++ b/third_party/WebKit/Source/core/input/ScrollManager.cpp
@@ -6,6 +6,7 @@
#include <memory>
#include "core/dom/DOMNodeIds.h"
+#include "core/dom/NodeComputedStyle.h"
#include "core/events/GestureEvent.h"
#include "core/frame/BrowserControls.h"
#include "core/frame/LocalFrameView.h"
@@ -84,6 +85,23 @@ AutoscrollController* ScrollManager::GetAutoscrollController() const {
return nullptr;
}
+static bool CanPropagate(const ScrollState& scroll_state,
+ const Element& element) {
+ // ScrollBoundaryBehavior may have different values on x-axis and y-axis.
+ // We need to find out the dominant axis of user's intended scroll to decide
+ // which node's ScrollBoundaryBehavior should be applied, i.e. which the
+ // scroll should be propagated from this node given its relevant*
+ // ScrollBoundaryBehavior value. * relevant here depends on the dominant
+ // axis of scroll gesture.
+ bool x_dominant =
+ std::abs(scroll_state.deltaXHint()) > std::abs(scroll_state.deltaYHint());
+ return (x_dominant && element.GetComputedStyle()->ScrollBoundaryBehaviorX() ==
+ EScrollBoundaryBehavior::kAuto) ||
+ (!x_dominant &&
+ element.GetComputedStyle()->ScrollBoundaryBehaviorY() ==
+ EScrollBoundaryBehavior::kAuto);
+}
+
void ScrollManager::RecomputeScrollChain(const Node& start_node,
const ScrollState& scroll_state,
std::deque<int>& scroll_chain) {
@@ -117,6 +135,9 @@ void ScrollManager::RecomputeScrollChain(const Node& start_node,
if (IsViewportScrollingElement(*cur_element) ||
cur_element == document_element)
break;
+
+ if (!CanPropagate(scroll_state, *cur_element))
+ break;
}
cur_box = cur_box->ContainingBlock();

Powered by Google App Engine
This is Rietveld 408576698