Commit 0dcd705c authored by Hugo Holgersson's avatar Hugo Holgersson Committed by Commit Bot

Snav: Remove some irrelevant "overlap" logic

DeflateIfOverlapped() was introduced in SpatNav's
very first WebKit commit [1], seemingly, to get some
support for certain overlapping elements. It seems
like we no longer need it...

Since crrev.com/c/1605696, SpatNav better supports
generic overlapping rects.

The spec [2] that formalizes Chromium's SpatNav
implementation never included it either.

[1] https://trac.webkit.org/browser/webkit/trunk/
      WebCore/page/SpatialNavigation.cpp?rev=55543
[2] https://drafts.csswg.org/css-nav-1/

Bug: 770147, 1000578
Change-Id: I498ccdb5032d97c89a5c015c893a2e5f08edd1f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1949785
Commit-Queue: Hugo Holgersson <hholgersson@fb.com>
Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#721485}
parent a284b88d
...@@ -56,8 +56,6 @@ constexpr double kMinDistance = std::numeric_limits<int>::lowest(); ...@@ -56,8 +56,6 @@ constexpr double kMinDistance = std::numeric_limits<int>::lowest();
constexpr int kFudgeFactor = 2; constexpr int kFudgeFactor = 2;
static void DeflateIfOverlapped(PhysicalRect&, PhysicalRect&);
FocusCandidate::FocusCandidate(Node* node, SpatialNavigationDirection direction) FocusCandidate::FocusCandidate(Node* node, SpatialNavigationDirection direction)
: visible_node(nullptr), focusable_node(nullptr), is_offscreen(true) { : visible_node(nullptr), focusable_node(nullptr), is_offscreen(true) {
DCHECK(node); DCHECK(node);
...@@ -313,22 +311,6 @@ bool ScrollInDirection(Node* container, SpatialNavigationDirection direction) { ...@@ -313,22 +311,6 @@ bool ScrollInDirection(Node* container, SpatialNavigationDirection direction) {
return true; return true;
} }
static void DeflateIfOverlapped(PhysicalRect& a, PhysicalRect& b) {
if (!a.Intersects(b) || a.Contains(b) || b.Contains(a))
return;
LayoutUnit deflate_factor = LayoutUnit(-kFudgeFactor);
// Avoid negative width or height values.
if ((a.Width() + 2 * deflate_factor > 0) &&
(a.Height() + 2 * deflate_factor > 0))
a.Inflate(deflate_factor);
if ((b.Width() + 2 * deflate_factor > 0) &&
(b.Height() + 2 * deflate_factor > 0))
b.Inflate(deflate_factor);
}
bool IsScrollableNode(const Node* node) { bool IsScrollableNode(const Node* node) {
if (!node) if (!node)
return false; return false;
...@@ -630,7 +612,6 @@ double ComputeDistanceDataForNode(SpatialNavigationDirection direction, ...@@ -630,7 +612,6 @@ double ComputeDistanceDataForNode(SpatialNavigationDirection direction,
} else if (!IsRectInDirection(direction, current_rect, node_rect)) { } else if (!IsRectInDirection(direction, current_rect, node_rect)) {
return kMaxDistance; return kMaxDistance;
} else { } else {
DeflateIfOverlapped(current_rect, node_rect);
PhysicalRect intersection_rect = Intersection(current_rect, node_rect); PhysicalRect intersection_rect = Intersection(current_rect, node_rect);
overlap = overlap =
(intersection_rect.Width() * intersection_rect.Height()).ToDouble(); (intersection_rect.Width() * intersection_rect.Height()).ToDouble();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment