Commit 6a2678df authored by Daniel Libby's avatar Daniel Libby Committed by Chromium LUCI CQ

Add support for painting layer selection for caret

crrev.com/c/2568694 added support for recording selection information
during paint in order to populate layer selection data in the
LayerTreeHost at commit time. This CL adds support for when the
selection is a caret. Note that this is not added directly to PaintCaret
since that is called both for a selection caret and a drag caret, and
we're only interested in recording for the former.

Bug: 1065049
Change-Id: Id22f656080b65c33f71f5caf1177149d0503d0e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2589355Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Commit-Queue: Daniel Libby <dlibby@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#836665}
parent 90a4f673
......@@ -694,7 +694,7 @@ IN_PROC_BROWSER_TEST_P(TouchSelectionControllerClientAuraSiteIsolationTest,
// Tests that tapping in a textfield brings up the insertion handle, but not the
// quick menu, initially. Then, successive taps on the insertion handle toggle
// the quick menu visibility.
IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest,
IN_PROC_BROWSER_TEST_P(TouchSelectionControllerClientAuraCAPFeatureTest,
BasicInsertionFollowedByTapsOnHandle) {
// Set the test page up.
ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html"));
......@@ -1017,8 +1017,9 @@ INSTANTIATE_TEST_SUITE_P(
testing::Bool());
// Tests that insertion handles are properly positioned at 2x DSF.
IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraScaleFactorTest,
InsertionHandleCoordinates) {
IN_PROC_BROWSER_TEST_P(
TouchSelectionControllerClientAuraScaleFactorCAPFeatureTest,
InsertionHandleCoordinates) {
// Set the test page up.
ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html"));
InitSelectionController();
......
......@@ -238,6 +238,23 @@ void CaretDisplayItemClient::PaintCaret(
DarkModeFilter::ElementRole::kText);
}
void CaretDisplayItemClient::RecordSelection(
GraphicsContext& context,
const PhysicalOffset& paint_offset) {
PhysicalRect drawing_rect = local_rect_;
drawing_rect.Move(paint_offset);
IntRect paint_rect = PixelSnappedIntRect(drawing_rect);
// For the caret, the start and selection selection bounds are recorded as
// the same edges, with the type marked as CENTER.
PaintedSelectionBound start = {gfx::SelectionBound::Type::CENTER,
paint_rect.MinXMinYCorner(),
paint_rect.MinXMaxYCorner(), false};
PaintedSelectionBound end = start;
context.GetPaintController().RecordSelection(start, end);
}
String CaretDisplayItemClient::DebugName() const {
return "Caret";
}
......
......@@ -66,6 +66,8 @@ class CORE_EXPORT CaretDisplayItemClient final : public DisplayItemClient {
const PhysicalOffset& paint_offset,
DisplayItem::Type) const;
void RecordSelection(GraphicsContext&, const PhysicalOffset& paint_offset);
// DisplayItemClient.
String DebugName() const final;
......
......@@ -173,6 +173,9 @@ bool FrameCaret::ShouldPaintCaret(const LayoutBlock& block) const {
void FrameCaret::PaintCaret(GraphicsContext& context,
const PhysicalOffset& paint_offset) const {
display_item_client_->PaintCaret(context, paint_offset, DisplayItem::kCaret);
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() &&
frame_->Selection().IsHandleVisible() && !frame_->Selection().IsHidden())
display_item_client_->RecordSelection(context, paint_offset);
}
bool FrameCaret::ShouldShowCaret() const {
......
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