Commit f498307f authored by Hugo Holgersson's avatar Hugo Holgersson Committed by Commit Bot

Snav: Remove the redundant CanBeScrolledIntoView()

This simplifies spatnav's inner loop, the evaluation of
DOM nodes when looking for candidates, a tiny bit.

Now that CanBeScrolledIntoView lost its call site
we can remove it completely to reduce spatnav's
code footprint.

Bug: 770147
Test: snav-div-overflow-scroll-hidden.html
Change-Id: Icbf4cb4d0274d63658dbeab1cdae1ce63557576f
Reviewed-on: https://chromium-review.googlesource.com/c/1319678
Commit-Queue: Hugo Holgersson <hugoh@vewd.com>
Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#606480}
parent c830d52e
......@@ -1226,7 +1226,6 @@ bool FocusController::SetFocusedElement(Element* element,
new_document->FocusedElement() == element)
return true;
if (old_document && old_document != new_document)
old_document->ClearFocusedElement();
......@@ -1285,18 +1284,15 @@ static void UpdateFocusCandidateIfNeeded(WebFocusType direction,
candidate.rect_in_root_frame.IsEmpty()))
return;
// Ignore off screen child nodes of containers that do not scroll
// (overflow:hidden)
if (candidate.is_offscreen && !CanBeScrolledIntoView(direction, candidate))
// Ignore off-screen focusables that are not exposed after one "scroll step"
// in the direction.
if (candidate.is_offscreen && candidate.is_offscreen_after_scrolling)
return;
DistanceDataForNode(direction, current, candidate);
if (candidate.distance == MaxDistance())
return;
if (candidate.is_offscreen_after_scrolling)
return;
if (closest.IsNull()) {
closest = candidate;
return;
......
......@@ -667,37 +667,6 @@ void DistanceDataForNode(WebFocusType direction,
weighted_orthogonal_axis_distance - sqrt(overlap);
}
bool CanBeScrolledIntoView(WebFocusType direction,
const FocusCandidate& candidate) {
DCHECK(candidate.visible_node);
DCHECK(candidate.is_offscreen);
LayoutRect candidate_rect = candidate.rect_in_root_frame;
// TODO(ecobos@igalia.com): Investigate interaction with Shadow DOM.
for (Node& parent_node :
NodeTraversal::AncestorsOf(*candidate.visible_node)) {
if (UNLIKELY(!parent_node.GetLayoutObject())) {
DCHECK(parent_node.IsElementNode() &&
ToElement(parent_node).HasDisplayContentsStyle());
continue;
}
LayoutRect parent_rect = NodeRectInRootFrame(&parent_node);
if (!candidate_rect.Intersects(parent_rect)) {
if (((direction == kWebFocusTypeLeft ||
direction == kWebFocusTypeRight) &&
parent_node.GetLayoutObject()->Style()->OverflowX() ==
EOverflow::kHidden) ||
((direction == kWebFocusTypeUp || direction == kWebFocusTypeDown) &&
parent_node.GetLayoutObject()->Style()->OverflowY() ==
EOverflow::kHidden))
return false;
}
if (parent_node == candidate.enclosing_scrollable_box)
return CanScrollInDirection(&parent_node, direction);
}
return true;
}
// Returns a thin rectangle that represents one of box's sides.
LayoutRect OppositeEdge(WebFocusType side,
const LayoutRect& box,
......
......@@ -93,7 +93,6 @@ CORE_EXPORT bool IsScrollableAreaOrDocument(const Node*);
CORE_EXPORT Node* ScrollableAreaOrDocumentOf(Node*);
bool CanScrollInDirection(const Node* container, WebFocusType);
bool CanScrollInDirection(const LocalFrame*, WebFocusType);
bool CanBeScrolledIntoView(WebFocusType, const FocusCandidate&);
bool AreElementsOnSameLine(const FocusCandidate& first_candidate,
const FocusCandidate& second_candidate);
void DistanceDataForNode(WebFocusType,
......
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