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

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

Issue 2769793002: Implement CSS: scroll-boundary-behavior (Closed)
Patch Set: Update promises tests and Scroll Manager 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..3b6b4d17f7d69f53eeabe430f7ba4687fb50fa6e 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"
@@ -117,6 +118,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();
@@ -152,6 +156,22 @@ bool ScrollManager::CanScroll(const ScrollState& scroll_state,
return clamped_offset != current_offset;
}
+bool ScrollManager::CanPropagate(const ScrollState& scroll_state,
+ const Element& current_element) {
majidvp 2017/07/14 14:29:44 ditto. This function does not need to be a member
sunyunjia 2017/07/14 22:07:24 Done.
+ // 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 ScrollBoundaryBehavior should be applied, i.e. which node should
+ // be scrolled.
majidvp 2017/07/14 14:29:44 ditto. the last sentence of the comment is not acc
sunyunjia 2017/07/14 22:07:24 Done.
+ bool x_dominant =
+ std::abs(scroll_state.deltaXHint()) > std::abs(scroll_state.deltaYHint());
+ return (x_dominant &&
+ current_element.GetComputedStyle()->ScrollBoundaryBehaviorX() ==
+ EScrollBoundaryBehavior::kAuto) ||
+ (!x_dominant &&
+ current_element.GetComputedStyle()->ScrollBoundaryBehaviorY() ==
+ EScrollBoundaryBehavior::kAuto);
+}
+
bool ScrollManager::LogicalScroll(ScrollDirection direction,
ScrollGranularity granularity,
Node* start_node,

Powered by Google App Engine
This is Rietveld 408576698