Commit 6c138885 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Always paint a caret when it's active

When a caret is active, now we always paint it in either the desired
color or the transparent color according to the blinking state.

This prepares for composited caret which will use an opacity effect
node to control the visibility during blinking.

The always painted display item for the active caret won't cause
performance issue because the paint opearation is trivial. It may
actually make PaintController and RasterInvalidator more efficient when
matching display items sequentially (without appearing/disappearing
display items).

Bug: 1123630
Change-Id: I507e1f5014040e8aecceb83346e5f28973f16c4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391002Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804064}
parent 7b62b986
...@@ -169,6 +169,13 @@ void CaretDisplayItemClient::UpdateStyleAndLayoutIfNeeded( ...@@ -169,6 +169,13 @@ void CaretDisplayItemClient::UpdateStyleAndLayoutIfNeeded(
new_layout_block->SetShouldCheckForPaintInvalidation(); new_layout_block->SetShouldCheckForPaintInvalidation();
} }
void CaretDisplayItemClient::SetVisibleIfActive(bool visible) {
if (visible == is_visible_if_active_)
return;
is_visible_if_active_ = visible;
needs_paint_invalidation_ = true;
}
void CaretDisplayItemClient::InvalidatePaint( void CaretDisplayItemClient::InvalidatePaint(
const LayoutBlock& block, const LayoutBlock& block,
const PaintInvalidatorContext& context) { const PaintInvalidatorContext& context) {
...@@ -227,7 +234,8 @@ void CaretDisplayItemClient::PaintCaret( ...@@ -227,7 +234,8 @@ void CaretDisplayItemClient::PaintCaret(
DrawingRecorder recorder(context, *this, display_item_type, DrawingRecorder recorder(context, *this, display_item_type,
EnclosingIntRect(drawing_rect)); EnclosingIntRect(drawing_rect));
IntRect paint_rect = PixelSnappedIntRect(drawing_rect); IntRect paint_rect = PixelSnappedIntRect(drawing_rect);
context.FillRect(paint_rect, color_, DarkModeFilter::ElementRole::kText); context.FillRect(paint_rect, is_visible_if_active_ ? color_ : Color(),
DarkModeFilter::ElementRole::kText);
} }
String CaretDisplayItemClient::DebugName() const { String CaretDisplayItemClient::DebugName() const {
......
...@@ -52,12 +52,16 @@ class CORE_EXPORT CaretDisplayItemClient final : public DisplayItemClient { ...@@ -52,12 +52,16 @@ class CORE_EXPORT CaretDisplayItemClient final : public DisplayItemClient {
// caret for paint invalidation and painting. // caret for paint invalidation and painting.
void UpdateStyleAndLayoutIfNeeded(const PositionWithAffinity& caret_position); void UpdateStyleAndLayoutIfNeeded(const PositionWithAffinity& caret_position);
bool IsVisibleIfActive() const { return is_visible_if_active_; }
void SetVisibleIfActive(bool visible);
// Called during LayoutBlock paint invalidation. // Called during LayoutBlock paint invalidation.
void InvalidatePaint(const LayoutBlock&, const PaintInvalidatorContext&); void InvalidatePaint(const LayoutBlock&, const PaintInvalidatorContext&);
bool ShouldPaintCaret(const LayoutBlock& block) const { bool ShouldPaintCaret(const LayoutBlock& block) const {
return &block == layout_block_; return &block == layout_block_;
} }
void PaintCaret(GraphicsContext&, void PaintCaret(GraphicsContext&,
const PhysicalOffset& paint_offset, const PhysicalOffset& paint_offset,
DisplayItem::Type) const; DisplayItem::Type) const;
...@@ -97,6 +101,7 @@ class CORE_EXPORT CaretDisplayItemClient final : public DisplayItemClient { ...@@ -97,6 +101,7 @@ class CORE_EXPORT CaretDisplayItemClient final : public DisplayItemClient {
const LayoutBlock* previous_layout_block_ = nullptr; const LayoutBlock* previous_layout_block_ = nullptr;
bool needs_paint_invalidation_ = false; bool needs_paint_invalidation_ = false;
bool is_visible_if_active_ = true;
DISALLOW_COPY_AND_ASSIGN(CaretDisplayItemClient); DISALLOW_COPY_AND_ASSIGN(CaretDisplayItemClient);
}; };
......
...@@ -317,12 +317,12 @@ TEST_P(CaretDisplayItemClientTest, CaretHideMoveAndShow) { ...@@ -317,12 +317,12 @@ TEST_P(CaretDisplayItemClientTest, CaretHideMoveAndShow) {
GetDocument().View()->SetTracksRasterInvalidations(true); GetDocument().View()->SetTracksRasterInvalidations(true);
// Simulate that the blinking cursor becomes invisible. // Simulate that the blinking cursor becomes invisible.
Selection().SetCaretVisible(false); Selection().SetCaretEnabled(false);
// Move the caret to the end of the text. // Move the caret to the end of the text.
Selection().SetSelectionAndEndTyping( Selection().SetSelectionAndEndTyping(
SelectionInDOMTree::Builder().Collapse(Position(text, 5)).Build()); SelectionInDOMTree::Builder().Collapse(Position(text, 5)).Build());
// Simulate that the cursor blinking is restarted. // Simulate that the cursor blinking is restarted.
Selection().SetCaretVisible(true); Selection().SetCaretEnabled(true);
EXPECT_TRUE(GetCaretDisplayItemClient().IsValid()); EXPECT_TRUE(GetCaretDisplayItemClient().IsValid());
GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint( GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint(
......
...@@ -50,14 +50,10 @@ FrameCaret::FrameCaret(LocalFrame& frame, ...@@ -50,14 +50,10 @@ FrameCaret::FrameCaret(LocalFrame& frame,
: selection_editor_(&selection_editor), : selection_editor_(&selection_editor),
frame_(frame), frame_(frame),
display_item_client_(new CaretDisplayItemClient()), display_item_client_(new CaretDisplayItemClient()),
caret_visibility_(CaretVisibility::kHidden),
caret_blink_timer_(new TaskRunnerTimer<FrameCaret>( caret_blink_timer_(new TaskRunnerTimer<FrameCaret>(
frame.GetTaskRunner(TaskType::kInternalDefault), frame.GetTaskRunner(TaskType::kInternalDefault),
this, this,
&FrameCaret::CaretBlinkTimerFired)), &FrameCaret::CaretBlinkTimerFired)) {}
should_paint_caret_(true),
is_caret_blinking_suspended_(false),
should_show_block_cursor_(false) {}
FrameCaret::~FrameCaret() = default; FrameCaret::~FrameCaret() = default;
...@@ -89,7 +85,13 @@ void FrameCaret::UpdateAppearance() { ...@@ -89,7 +85,13 @@ void FrameCaret::UpdateAppearance() {
should_show_block_cursor_ && IsActive() && should_show_block_cursor_ && IsActive() &&
!IsLogicalEndOfLine(CreateVisiblePosition(CaretPosition())); !IsLogicalEndOfLine(CreateVisiblePosition(CaretPosition()));
bool should_blink = !paint_block_cursor && ShouldBlinkCaret(); bool new_should_show_caret = ShouldShowCaret();
if (new_should_show_caret != should_show_caret_) {
should_show_caret_ = new_should_show_caret;
ScheduleVisualUpdateForPaintInvalidationIfNeeded();
}
bool should_blink = !paint_block_cursor && should_show_caret_;
if (!should_blink) { if (!should_blink) {
StopCaretBlinkTimer(); StopCaretBlinkTimer();
return; return;
...@@ -100,9 +102,10 @@ void FrameCaret::UpdateAppearance() { ...@@ -100,9 +102,10 @@ void FrameCaret::UpdateAppearance() {
} }
void FrameCaret::StopCaretBlinkTimer() { void FrameCaret::StopCaretBlinkTimer() {
if (caret_blink_timer_->IsActive() || should_paint_caret_) if (caret_blink_timer_->IsActive() ||
display_item_client_->IsVisibleIfActive())
ScheduleVisualUpdateForPaintInvalidationIfNeeded(); ScheduleVisualUpdateForPaintInvalidationIfNeeded();
should_paint_caret_ = false; display_item_client_->SetVisibleIfActive(false);
caret_blink_timer_->Stop(); caret_blink_timer_->Stop();
} }
...@@ -116,17 +119,17 @@ void FrameCaret::StartBlinkCaret() { ...@@ -116,17 +119,17 @@ void FrameCaret::StartBlinkCaret() {
if (!blink_interval.is_zero()) if (!blink_interval.is_zero())
caret_blink_timer_->StartRepeating(blink_interval, FROM_HERE); caret_blink_timer_->StartRepeating(blink_interval, FROM_HERE);
should_paint_caret_ = true; display_item_client_->SetVisibleIfActive(true);
ScheduleVisualUpdateForPaintInvalidationIfNeeded(); ScheduleVisualUpdateForPaintInvalidationIfNeeded();
} }
void FrameCaret::SetCaretVisibility(CaretVisibility visibility) { void FrameCaret::SetCaretEnabled(bool enabled) {
if (caret_visibility_ == visibility) if (is_caret_enabled_ == enabled)
return; return;
caret_visibility_ = visibility; is_caret_enabled_ = enabled;
if (visibility == CaretVisibility::kHidden) if (!is_caret_enabled_)
StopCaretBlinkTimer(); StopCaretBlinkTimer();
ScheduleVisualUpdateForPaintInvalidationIfNeeded(); ScheduleVisualUpdateForPaintInvalidationIfNeeded();
} }
...@@ -139,15 +142,8 @@ void FrameCaret::UpdateStyleAndLayoutIfNeeded() { ...@@ -139,15 +142,8 @@ void FrameCaret::UpdateStyleAndLayoutIfNeeded() {
DCHECK_GE(frame_->GetDocument()->Lifecycle().GetState(), DCHECK_GE(frame_->GetDocument()->Lifecycle().GetState(),
DocumentLifecycle::kLayoutClean); DocumentLifecycle::kLayoutClean);
UpdateAppearance(); UpdateAppearance();
bool should_paint_caret =
should_paint_caret_ && IsActive() &&
caret_visibility_ == CaretVisibility::kVisible &&
(IsEditablePosition(
selection_editor_->ComputeVisibleSelectionInDOMTree().Start()) ||
frame_->IsCaretBrowsingEnabled());
display_item_client_->UpdateStyleAndLayoutIfNeeded( display_item_client_->UpdateStyleAndLayoutIfNeeded(
should_paint_caret ? CaretPosition() : PositionWithAffinity()); should_show_caret_ ? CaretPosition() : PositionWithAffinity());
} }
void FrameCaret::InvalidatePaint(const LayoutBlock& block, void FrameCaret::InvalidatePaint(const LayoutBlock& block,
...@@ -179,34 +175,40 @@ void FrameCaret::PaintCaret(GraphicsContext& context, ...@@ -179,34 +175,40 @@ void FrameCaret::PaintCaret(GraphicsContext& context,
display_item_client_->PaintCaret(context, paint_offset, DisplayItem::kCaret); display_item_client_->PaintCaret(context, paint_offset, DisplayItem::kCaret);
} }
bool FrameCaret::ShouldBlinkCaret() const { bool FrameCaret::ShouldShowCaret() const {
// Don't blink the caret if it isn't visible or positioned. // Don't show the caret if it isn't visible or positioned.
if (caret_visibility_ != CaretVisibility::kVisible || !IsActive()) if (!is_caret_enabled_ || !IsActive())
return false; return false;
Element* root = RootEditableElementOf(CaretPosition().GetPosition()); Element* root = RootEditableElementOf(CaretPosition().GetPosition());
if (root) { if (root) {
// Caret is contained in editable content. If there is no focused element, // Caret is contained in editable content. If there is no focused element,
// don't blink the caret. // don't show the caret.
Element* focused_element = root->GetDocument().FocusedElement(); Element* focused_element = root->GetDocument().FocusedElement();
if (!focused_element) if (!focused_element)
return false; return false;
} else { } else {
// Caret is not contained in editable content--see if caret browsing is // Caret is not contained in editable content--see if caret browsing is
// enabled. If it isn't, don't blink the caret. // enabled. If it isn't, don't show the caret.
if (!frame_->IsCaretBrowsingEnabled()) if (!frame_->IsCaretBrowsingEnabled())
return false; return false;
} }
// Only blink the caret if the selection has focus. if (!IsEditablePosition(
selection_editor_->ComputeVisibleSelectionInDOMTree().Start()) &&
!frame_->IsCaretBrowsingEnabled())
return false;
// Only show the caret if the selection has focus.
return frame_->Selection().SelectionHasFocus(); return frame_->Selection().SelectionHasFocus();
} }
void FrameCaret::CaretBlinkTimerFired(TimerBase*) { void FrameCaret::CaretBlinkTimerFired(TimerBase*) {
DCHECK_EQ(caret_visibility_, CaretVisibility::kVisible); DCHECK(is_caret_enabled_);
if (IsCaretBlinkingSuspended() && should_paint_caret_) if (IsCaretBlinkingSuspended() && display_item_client_->IsVisibleIfActive())
return; return;
should_paint_caret_ = !should_paint_caret_; display_item_client_->SetVisibleIfActive(
!display_item_client_->IsVisibleIfActive());
ScheduleVisualUpdateForPaintInvalidationIfNeeded(); ScheduleVisualUpdateForPaintInvalidationIfNeeded();
} }
...@@ -221,4 +223,8 @@ void FrameCaret::RecreateCaretBlinkTimerForTesting( ...@@ -221,4 +223,8 @@ void FrameCaret::RecreateCaretBlinkTimerForTesting(
std::move(task_runner), this, &FrameCaret::CaretBlinkTimerFired)); std::move(task_runner), this, &FrameCaret::CaretBlinkTimerFired));
} }
bool FrameCaret::IsVisibleIfActiveForTesting() const {
return display_item_client_->IsVisibleIfActive();
}
} // namespace blink } // namespace blink
...@@ -47,8 +47,6 @@ class SelectionEditor; ...@@ -47,8 +47,6 @@ class SelectionEditor;
struct PaintInvalidatorContext; struct PaintInvalidatorContext;
struct PhysicalOffset; struct PhysicalOffset;
enum class CaretVisibility { kVisible, kHidden };
class CORE_EXPORT FrameCaret final : public GarbageCollected<FrameCaret> { class CORE_EXPORT FrameCaret final : public GarbageCollected<FrameCaret> {
public: public:
FrameCaret(LocalFrame&, const SelectionEditor&); FrameCaret(LocalFrame&, const SelectionEditor&);
...@@ -65,7 +63,7 @@ class CORE_EXPORT FrameCaret final : public GarbageCollected<FrameCaret> { ...@@ -65,7 +63,7 @@ class CORE_EXPORT FrameCaret final : public GarbageCollected<FrameCaret> {
bool IsCaretBlinkingSuspended() const { return is_caret_blinking_suspended_; } bool IsCaretBlinkingSuspended() const { return is_caret_blinking_suspended_; }
void StopCaretBlinkTimer(); void StopCaretBlinkTimer();
void StartBlinkCaret(); void StartBlinkCaret();
void SetCaretVisibility(CaretVisibility); void SetCaretEnabled(bool);
IntRect AbsoluteCaretBounds() const; IntRect AbsoluteCaretBounds() const;
bool ShouldShowBlockCursor() const { return should_show_block_cursor_; } bool ShouldShowBlockCursor() const { return should_show_block_cursor_; }
...@@ -83,7 +81,7 @@ class CORE_EXPORT FrameCaret final : public GarbageCollected<FrameCaret> { ...@@ -83,7 +81,7 @@ class CORE_EXPORT FrameCaret final : public GarbageCollected<FrameCaret> {
const CaretDisplayItemClient& CaretDisplayItemClientForTesting() const { const CaretDisplayItemClient& CaretDisplayItemClientForTesting() const {
return *display_item_client_; return *display_item_client_;
} }
bool ShouldPaintCaretForTesting() const { return should_paint_caret_; } bool IsVisibleIfActiveForTesting() const;
void RecreateCaretBlinkTimerForTesting( void RecreateCaretBlinkTimerForTesting(
scoped_refptr<base::SingleThreadTaskRunner>); scoped_refptr<base::SingleThreadTaskRunner>);
...@@ -95,19 +93,19 @@ class CORE_EXPORT FrameCaret final : public GarbageCollected<FrameCaret> { ...@@ -95,19 +93,19 @@ class CORE_EXPORT FrameCaret final : public GarbageCollected<FrameCaret> {
const PositionWithAffinity CaretPosition() const; const PositionWithAffinity CaretPosition() const;
bool ShouldBlinkCaret() const; bool ShouldShowCaret() const;
void CaretBlinkTimerFired(TimerBase*); void CaretBlinkTimerFired(TimerBase*);
void UpdateAppearance(); void UpdateAppearance();
const Member<const SelectionEditor> selection_editor_; const Member<const SelectionEditor> selection_editor_;
const Member<LocalFrame> frame_; const Member<LocalFrame> frame_;
const std::unique_ptr<CaretDisplayItemClient> display_item_client_; const std::unique_ptr<CaretDisplayItemClient> display_item_client_;
CaretVisibility caret_visibility_;
// TODO(https://crbug.com/668758): Consider using BeginFrame update for this. // TODO(https://crbug.com/668758): Consider using BeginFrame update for this.
std::unique_ptr<TaskRunnerTimer<FrameCaret>> caret_blink_timer_; std::unique_ptr<TaskRunnerTimer<FrameCaret>> caret_blink_timer_;
bool should_paint_caret_ : 1; bool is_caret_enabled_ = false;
bool is_caret_blinking_suspended_ : 1; bool should_show_caret_ = false;
bool should_show_block_cursor_ : 1; bool is_caret_blinking_suspended_ = false;
bool should_show_block_cursor_ = false;
DISALLOW_COPY_AND_ASSIGN(FrameCaret); DISALLOW_COPY_AND_ASSIGN(FrameCaret);
}; };
......
...@@ -29,8 +29,8 @@ class FrameCaretTest : public EditingTestBase { ...@@ -29,8 +29,8 @@ class FrameCaretTest : public EditingTestBase {
WebTestSupport::SetIsRunningWebTest(was_running_web_test_); WebTestSupport::SetIsRunningWebTest(was_running_web_test_);
} }
static bool ShouldBlinkCaret(const FrameCaret& caret) { static bool ShouldShowCaret(const FrameCaret& caret) {
return caret.ShouldBlinkCaret(); return caret.ShouldShowCaret();
} }
private: private:
...@@ -55,26 +55,26 @@ TEST_F(FrameCaretTest, BlinkAfterTyping) { ...@@ -55,26 +55,26 @@ TEST_F(FrameCaretTest, BlinkAfterTyping) {
EXPECT_TRUE(caret.IsActive()); EXPECT_TRUE(caret.IsActive());
EXPECT_FALSE(caret.ShouldShowBlockCursor()); EXPECT_FALSE(caret.ShouldShowBlockCursor());
EXPECT_TRUE(caret.ShouldPaintCaretForTesting()) EXPECT_TRUE(caret.IsVisibleIfActiveForTesting())
<< "Initially a caret should be in visible cycle."; << "Initially a caret should be in visible cycle.";
task_runner->AdvanceTimeAndRun(kInterval); task_runner->AdvanceTimeAndRun(kInterval);
EXPECT_FALSE(caret.ShouldPaintCaretForTesting()) EXPECT_FALSE(caret.IsVisibleIfActiveForTesting())
<< "The caret blinks normally."; << "The caret blinks normally.";
TypingCommand::InsertLineBreak(GetDocument()); TypingCommand::InsertLineBreak(GetDocument());
UpdateAllLifecyclePhasesForTest(); UpdateAllLifecyclePhasesForTest();
EXPECT_TRUE(caret.ShouldPaintCaretForTesting()) EXPECT_TRUE(caret.IsVisibleIfActiveForTesting())
<< "The caret should be in visible cycle just after a typing command."; << "The caret should be in visible cycle just after a typing command.";
task_runner->AdvanceTimeAndRun(kInterval - 1); task_runner->AdvanceTimeAndRun(kInterval - 1);
UpdateAllLifecyclePhasesForTest(); UpdateAllLifecyclePhasesForTest();
EXPECT_TRUE(caret.ShouldPaintCaretForTesting()) EXPECT_TRUE(caret.IsVisibleIfActiveForTesting())
<< "The typing command reset the timer. The caret is still visible."; << "The typing command reset the timer. The caret is still visible.";
task_runner->AdvanceTimeAndRun(1); task_runner->AdvanceTimeAndRun(1);
UpdateAllLifecyclePhasesForTest(); UpdateAllLifecyclePhasesForTest();
EXPECT_FALSE(caret.ShouldPaintCaretForTesting()) EXPECT_FALSE(caret.IsVisibleIfActiveForTesting())
<< "The caret should blink after the typing command."; << "The caret should blink after the typing command.";
} }
...@@ -94,18 +94,18 @@ TEST_F(FrameCaretTest, ShouldNotBlinkWhenSelectionLooseFocus) { ...@@ -94,18 +94,18 @@ TEST_F(FrameCaretTest, ShouldNotBlinkWhenSelectionLooseFocus) {
const SelectionInDOMTree& selection = Selection().GetSelectionInDOMTree(); const SelectionInDOMTree& selection = Selection().GetSelectionInDOMTree();
EXPECT_EQ(selection.Base(), EXPECT_EQ(selection.Base(),
Position(input, PositionAnchorType::kBeforeChildren)); Position(input, PositionAnchorType::kBeforeChildren));
EXPECT_FALSE(ShouldBlinkCaret(caret)); EXPECT_FALSE(ShouldShowCaret(caret));
} }
TEST_F(FrameCaretTest, ShouldBlinkCaretWhileCaretBrowsing) { TEST_F(FrameCaretTest, ShouldBlinkCaretWhileCaretBrowsing) {
FrameCaret& caret = Selection().FrameCaretForTesting(); FrameCaret& caret = Selection().FrameCaretForTesting();
Selection().SetSelection(SetSelectionTextToBody("<div>a|b</div>"), Selection().SetSelection(SetSelectionTextToBody("<div>a|b</div>"),
SetSelectionOptions()); SetSelectionOptions());
Selection().SetCaretVisible(true); Selection().SetCaretEnabled(true);
EXPECT_FALSE(ShouldBlinkCaret(caret)); EXPECT_FALSE(ShouldShowCaret(caret));
GetDocument().GetFrame()->GetSettings()->SetCaretBrowsingEnabled(true); GetDocument().GetFrame()->GetSettings()->SetCaretBrowsingEnabled(true);
UpdateAllLifecyclePhasesForTest(); UpdateAllLifecyclePhasesForTest();
EXPECT_TRUE(ShouldBlinkCaret(caret)); EXPECT_TRUE(ShouldShowCaret(caret));
} }
} // namespace blink } // namespace blink
...@@ -874,9 +874,7 @@ void FrameSelection::FocusedOrActiveStateChanged() { ...@@ -874,9 +874,7 @@ void FrameSelection::FocusedOrActiveStateChanged() {
// Caret appears in the active frame. // Caret appears in the active frame.
if (active_and_focused) if (active_and_focused)
SetSelectionFromNone(); SetSelectionFromNone();
frame_caret_->SetCaretVisibility(active_and_focused frame_caret_->SetCaretEnabled(active_and_focused);
? CaretVisibility::kVisible
: CaretVisibility::kHidden);
// Update for caps lock state // Update for caps lock state
frame_->GetEventHandler().CapsLockStateMayHaveChanged(); frame_->GetEventHandler().CapsLockStateMayHaveChanged();
...@@ -1268,9 +1266,8 @@ void FrameSelection::MoveRangeSelectionInternal( ...@@ -1268,9 +1266,8 @@ void FrameSelection::MoveRangeSelectionInternal(
.Build()); .Build());
} }
void FrameSelection::SetCaretVisible(bool caret_is_visible) { void FrameSelection::SetCaretEnabled(bool enabled) {
frame_caret_->SetCaretVisibility(caret_is_visible ? CaretVisibility::kVisible frame_caret_->SetCaretEnabled(enabled);
: CaretVisibility::kHidden);
} }
void FrameSelection::SetCaretBlinkingSuspended(bool suspended) { void FrameSelection::SetCaretBlinkingSuspended(bool suspended) {
......
...@@ -216,7 +216,7 @@ class CORE_EXPORT FrameSelection final ...@@ -216,7 +216,7 @@ class CORE_EXPORT FrameSelection final
void DidLayout(); void DidLayout();
void CommitAppearanceIfNeeded(); void CommitAppearanceIfNeeded();
void SetCaretVisible(bool caret_is_visible); void SetCaretEnabled(bool caret_is_visible);
void ScheduleVisualUpdate() const; void ScheduleVisualUpdate() const;
void ScheduleVisualUpdateForPaintInvalidationIfNeeded() const; void ScheduleVisualUpdateForPaintInvalidationIfNeeded() const;
......
...@@ -126,7 +126,7 @@ TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) { ...@@ -126,7 +126,7 @@ TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) {
GetDocument().body()->focus(); GetDocument().body()->focus();
EXPECT_TRUE(GetDocument().body()->IsFocused()); EXPECT_TRUE(GetDocument().body()->IsFocused());
Selection().SetCaretVisible(true); Selection().SetCaretEnabled(true);
Selection().SetSelectionAndEndTyping( Selection().SetSelectionAndEndTyping(
SelectionInDOMTree::Builder().Collapse(Position(text, 0)).Build()); SelectionInDOMTree::Builder().Collapse(Position(text, 0)).Build());
UpdateAllLifecyclePhasesForTest(); UpdateAllLifecyclePhasesForTest();
......
...@@ -370,7 +370,7 @@ void TextSuggestionController::OnSuggestionMenuClosed() { ...@@ -370,7 +370,7 @@ void TextSuggestionController::OnSuggestionMenuClosed() {
GetDocument().Markers().RemoveMarkersOfTypes( GetDocument().Markers().RemoveMarkersOfTypes(
DocumentMarker::MarkerTypes::ActiveSuggestion()); DocumentMarker::MarkerTypes::ActiveSuggestion());
GetFrame().Selection().SetCaretVisible(true); GetFrame().Selection().SetCaretEnabled(true);
is_suggestion_menu_open_ = false; is_suggestion_menu_open_ = false;
} }
...@@ -425,7 +425,7 @@ void TextSuggestionController::ShowSpellCheckMenu( ...@@ -425,7 +425,7 @@ void TextSuggestionController::ShowSpellCheckMenu(
const String& description = marker->Description(); const String& description = marker->Description();
is_suggestion_menu_open_ = true; is_suggestion_menu_open_ = true;
GetFrame().Selection().SetCaretVisible(false); GetFrame().Selection().SetCaretEnabled(false);
GetDocument().Markers().AddActiveSuggestionMarker( GetDocument().Markers().AddActiveSuggestionMarker(
active_suggestion_range, SK_ColorTRANSPARENT, active_suggestion_range, SK_ColorTRANSPARENT,
ui::mojom::ImeTextSpanThickness::kNone, ui::mojom::ImeTextSpanThickness::kNone,
...@@ -499,7 +499,7 @@ void TextSuggestionController::ShowSuggestionMenu( ...@@ -499,7 +499,7 @@ void TextSuggestionController::ShowSuggestionMenu(
suggestion_infos_with_node_and_highlight_color.highlight_color); suggestion_infos_with_node_and_highlight_color.highlight_color);
is_suggestion_menu_open_ = true; is_suggestion_menu_open_ = true;
GetFrame().Selection().SetCaretVisible(false); GetFrame().Selection().SetCaretEnabled(false);
const String& misspelled_word = PlainText(marker_range); const String& misspelled_word = PlainText(marker_range);
CallMojoShowTextSuggestionMenu( CallMojoShowTextSuggestionMenu(
......
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