diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/paint/selection_bounds_recorder.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/paint/selection_bounds_recorder.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/chromium/third_party/blink/renderer/core/paint/selection_bounds_recorder.cc b/chromium/third_party/blink/renderer/core/paint/selection_bounds_recorder.cc index 58c5409858b..f9266ca880b 100644 --- a/chromium/third_party/blink/renderer/core/paint/selection_bounds_recorder.cc +++ b/chromium/third_party/blink/renderer/core/paint/selection_bounds_recorder.cc @@ -3,12 +3,15 @@ // found in the LICENSE file. #include "third_party/blink/renderer/core/paint/selection_bounds_recorder.h" + #include "third_party/blink/renderer/core/editing/frame_selection.h" +#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/html/forms/text_control_element.h" #include "third_party/blink/renderer/core/layout/api/selection_state.h" #include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" #include "third_party/blink/renderer/core/layout/layout_box.h" -#include "third_party/blink/renderer/core/layout/layout_view.h" +#include "third_party/blink/renderer/core/page/focus_controller.h" +#include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_controller.h" namespace blink { @@ -164,6 +167,16 @@ bool SelectionBoundsRecorder::ShouldRecordSelection( if (!frame_selection.IsHandleVisible() || frame_selection.IsHidden()) return false; + // If the currently focused frame is not the one in which selection + // lives, don't paint the selection bounds. Note this is subtly different + // from whether the frame has focus (i.e. `FrameSelection::SelectionHasFocus`) + // which is false if the hosting window is not focused. + LocalFrame* local_frame = frame_selection.GetFrame(); + LocalFrame* focused_frame = + local_frame->GetPage()->GetFocusController().FocusedFrame(); + if (local_frame != focused_frame) + return false; + if (state == SelectionState::kInside || state == SelectionState::kNone) return false; @@ -189,7 +202,7 @@ bool SelectionBoundsRecorder::IsVisible(const LayoutObject& rect_layout_object, return true; const PhysicalOffset sample_point = GetSamplePointForVisibility( - edge_start, edge_end, rect_layout_object.View()->ZoomFactor()); + edge_start, edge_end, rect_layout_object.GetFrame()->PageZoomFactor()); auto* const text_control_object = To<LayoutBox>(layout_object); const PhysicalOffset position_in_input = |