diff --git a/layout/base/TouchCaret.cpp b/layout/base/TouchCaret.cpp index 1a907d161d30..5efef5ad40fa 100644 --- a/layout/base/TouchCaret.cpp +++ b/layout/base/TouchCaret.cpp @@ -351,11 +351,15 @@ void TouchCaret::SyncVisibilityWithCaret() { TOUCHCARET_LOG("SyncVisibilityWithCaret"); - if (IsDisplayable()) { - SetVisibility(true); - UpdatePosition(); - } else { + + if (!IsDisplayable()) { SetVisibility(false); + return; + } + + SetVisibility(true); + if (mVisible) { + UpdatePosition(); } } @@ -363,12 +367,15 @@ void TouchCaret::UpdatePositionIfNeeded() { TOUCHCARET_LOG("UpdatePositionIfNeeded"); - if (IsDisplayable()) { - if (mVisible) { - UpdatePosition(); - } - } else { + + if (!IsDisplayable()) { SetVisibility(false); + return; + + } + + if (mVisible) { + UpdatePosition(); } }