Commit 43723445 authored by Yoichi Osato's avatar Yoichi Osato Committed by Commit Bot

[LayoutNG] Refactor RenderedPosition::GetLocalSelectionEndpoints

GetLocalSelectionEndpoints uses a boolean argument |selection_start| to compute
a selection bound.
This patch refactors the function by removing the argument and splitting
the function into GetLocalSelectionStartpoints and
GetLocalSelectionEndpoints for code health.

Bug: 789870
Change-Id: I7a2f3e7ab9f086c286c0f60bd1e8ce8a1d1c94a8
Reviewed-on: https://chromium-review.googlesource.com/890695Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Yoichi Osato <yoichio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532370}
parent 794ac52d
...@@ -305,27 +305,25 @@ static GraphicsLayer* GetGraphicsLayerBacking( ...@@ -305,27 +305,25 @@ static GraphicsLayer* GetGraphicsLayerBacking(
&paint_invalidation_container); &paint_invalidation_container);
} }
std::pair<LayoutPoint, LayoutPoint> static GetLocalSelectionEndpoints( std::pair<LayoutPoint, LayoutPoint> static GetLocalSelectionStartpoints(
bool selection_start,
const LocalCaretRect& local_caret_rect) { const LocalCaretRect& local_caret_rect) {
const LayoutRect rect = local_caret_rect.rect; const LayoutRect rect = local_caret_rect.rect;
if (local_caret_rect.layout_object->Style()->IsHorizontalWritingMode()) { if (local_caret_rect.layout_object->Style()->IsHorizontalWritingMode())
const LayoutPoint edge_top_in_layer = rect.MinXMinYCorner(); return {rect.MinXMinYCorner(), rect.MinXMaxYCorner()};
const LayoutPoint edge_bottom_in_layer = rect.MinXMaxYCorner();
return {edge_top_in_layer, edge_bottom_in_layer};
}
LayoutPoint edge_top_in_layer = rect.MinXMinYCorner();
LayoutPoint edge_bottom_in_layer = rect.MaxXMinYCorner();
// When text is vertical, it looks better for the start handle baseline to // When text is vertical, it looks better for the start handle baseline to
// be at the starting edge, to enclose the selection fully between the // be at the starting edge, to enclose the selection fully between the
// handles. // handles.
if (selection_start) { return {rect.MaxXMinYCorner(), rect.MinXMinYCorner()};
LayoutUnit x_swap = edge_bottom_in_layer.X(); }
edge_bottom_in_layer.SetX(edge_top_in_layer.X());
edge_top_in_layer.SetX(x_swap); std::pair<LayoutPoint, LayoutPoint> static GetLocalSelectionEndpoints(
} const LocalCaretRect& local_caret_rect) {
return {edge_top_in_layer, edge_bottom_in_layer}; const LayoutRect rect = local_caret_rect.rect;
if (local_caret_rect.layout_object->Style()->IsHorizontalWritingMode())
return {rect.MinXMinYCorner(), rect.MinXMaxYCorner()};
return {rect.MinXMinYCorner(), rect.MaxXMinYCorner()};
} }
static LayoutPoint GetSamplePointForVisibility( static LayoutPoint GetSamplePointForVisibility(
...@@ -383,7 +381,8 @@ static CompositedSelectionBound PositionInGraphicsLayerBacking( ...@@ -383,7 +381,8 @@ static CompositedSelectionBound PositionInGraphicsLayerBacking(
LayoutPoint edge_top_in_layer, edge_bottom_in_layer; LayoutPoint edge_top_in_layer, edge_bottom_in_layer;
std::tie(edge_top_in_layer, edge_bottom_in_layer) = std::tie(edge_top_in_layer, edge_bottom_in_layer) =
GetLocalSelectionEndpoints(selection_start, local_caret_rect); selection_start ? GetLocalSelectionStartpoints(local_caret_rect)
: GetLocalSelectionEndpoints(local_caret_rect);
bound.edge_top_in_layer = bound.edge_top_in_layer =
LocalToInvalidationBackingPoint(edge_top_in_layer, *layout_object); LocalToInvalidationBackingPoint(edge_top_in_layer, *layout_object);
bound.edge_bottom_in_layer = bound.edge_bottom_in_layer =
......
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