Commit 47aba8bb authored by Yoichi Osato's avatar Yoichi Osato Committed by Commit Bot

[LayoutNG] Refactor RenderedPosition::IsVisible not to use boolean argument.

Since the argument |selection_start| is used to compute two LayoutPoints,
this patch salvages them from IsVibisile to the caller CompositedSelectionBound
which already has the LayoutPoints.

Bug: 789870
Change-Id: I43e751d35268466e910ac826820010a719a8298e
Reviewed-on: https://chromium-review.googlesource.com/888338Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Yoichi Osato <yoichio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532098}
parent 06b09b44
...@@ -341,12 +341,10 @@ static LayoutPoint GetSamplePointForVisibility( ...@@ -341,12 +341,10 @@ static LayoutPoint GetSamplePointForVisibility(
// Returns whether this position is not visible on the screen (because // Returns whether this position is not visible on the screen (because
// clipped out). // clipped out).
static bool IsVisible(bool selection_start, static bool IsVisible(const LayoutObject& rect_layout_object,
const LocalCaretRect& local_caret_rect) { const LayoutPoint& edge_top_in_layer,
if (!local_caret_rect.layout_object) const LayoutPoint& edge_bottom_in_layer) {
return false; Node* const node = rect_layout_object.GetNode();
Node* const node = local_caret_rect.layout_object->GetNode();
if (!node) if (!node)
return true; return true;
TextControlElement* text_control = EnclosingTextControl(node); TextControlElement* text_control = EnclosingTextControl(node);
...@@ -359,21 +357,14 @@ static bool IsVisible(bool selection_start, ...@@ -359,21 +357,14 @@ static bool IsVisible(bool selection_start,
if (!layout_object || !layout_object->IsBox()) if (!layout_object || !layout_object->IsBox())
return true; return true;
LayoutPoint edge_top_in_layer, edge_bottom_in_layer; const LayoutPoint sample_point =
std::tie(edge_top_in_layer, edge_bottom_in_layer) =
GetLocalSelectionEndpoints(selection_start, local_caret_rect);
LayoutPoint sample_point =
GetSamplePointForVisibility(edge_top_in_layer, edge_bottom_in_layer); GetSamplePointForVisibility(edge_top_in_layer, edge_bottom_in_layer);
LayoutBox* text_control_object = ToLayoutBox(layout_object); LayoutBox* const text_control_object = ToLayoutBox(layout_object);
LayoutPoint position_in_input( const LayoutPoint position_in_input(rect_layout_object.LocalToAncestorPoint(
local_caret_rect.layout_object->LocalToAncestorPoint(
FloatPoint(sample_point), text_control_object, FloatPoint(sample_point), text_control_object,
kTraverseDocumentBoundaries)); kTraverseDocumentBoundaries));
if (!text_control_object->BorderBoxRect().Contains(position_in_input)) return text_control_object->BorderBoxRect().Contains(position_in_input);
return false;
return true;
} }
static CompositedSelectionBound PositionInGraphicsLayerBacking( static CompositedSelectionBound PositionInGraphicsLayerBacking(
...@@ -397,7 +388,8 @@ static CompositedSelectionBound PositionInGraphicsLayerBacking( ...@@ -397,7 +388,8 @@ static CompositedSelectionBound PositionInGraphicsLayerBacking(
bound.edge_bottom_in_layer = bound.edge_bottom_in_layer =
LocalToInvalidationBackingPoint(edge_bottom_in_layer, *layout_object); LocalToInvalidationBackingPoint(edge_bottom_in_layer, *layout_object);
bound.layer = GetGraphicsLayerBacking(*layout_object); bound.layer = GetGraphicsLayerBacking(*layout_object);
bound.hidden = !IsVisible(selection_start, local_caret_rect); bound.hidden =
!IsVisible(*layout_object, edge_top_in_layer, edge_bottom_in_layer);
return bound; return bound;
} }
......
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