Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Unified Diff: third_party/WebKit/Source/core/editing/FrameSelection.cpp

Issue 2201853002: Blink handle selection handle visibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed contextual search test function Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/FrameSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/FrameSelection.cpp b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
index 2be9d69c92ebe14b0913e955d5c78b0c61572464..e0dda9dd080960891a2fccb7dd6c3088e197c89a 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
@@ -101,6 +101,7 @@ FrameSelection::FrameSelection(LocalFrame* frame)
m_xPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation()),
m_focused(frame->page() &&
frame->page()->focusController().focusedFrame() == frame),
+ m_isHandleVisible(false),
m_frameCaret(new FrameCaret(frame, *m_selectionEditor)) {
DCHECK(frame);
}
@@ -158,8 +159,9 @@ void FrameSelection::moveTo(const VisiblePosition& pos,
EUserTriggered userTriggered,
CursorAlignOnScroll align) {
SetSelectionOptions options = CloseTyping | ClearTypingStyle | userTriggered;
+ bool isHandleVisible = userTriggered == UserTriggered;
setSelection(createVisibleSelection(pos, pos, selection().isDirectional()),
- options, align);
+ options, align, CharacterGranularity, isHandleVisible);
}
void FrameSelection::moveTo(const Position& pos, TextAffinity affinity) {
@@ -225,7 +227,8 @@ static void adjustEndpointsAtBidiBoundary(
void FrameSelection::setNonDirectionalSelectionIfNeeded(
const VisibleSelectionInFlatTree& passedNewSelection,
TextGranularity granularity,
- EndPointsAdjustmentMode endpointsAdjustmentMode) {
+ EndPointsAdjustmentMode endpointsAdjustmentMode,
+ bool isHandleVisible) {
VisibleSelectionInFlatTree newSelection = passedNewSelection;
bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) ||
newSelection.isDirectional();
@@ -263,12 +266,13 @@ void FrameSelection::setNonDirectionalSelectionIfNeeded(
// Adjusting base and extent will make newSelection always directional
newSelection.setIsDirectional(isDirectional);
- if (visibleSelection<EditingInFlatTreeStrategy>() == newSelection)
+ if (visibleSelection<EditingInFlatTreeStrategy>() == newSelection &&
+ m_isHandleVisible == isHandleVisible)
return;
const SetSelectionOptions options = CloseTyping | ClearTypingStyle;
setSelection(newSelection, options, CursorAlignOnScroll::IfNeeded,
- granularity);
+ granularity, isHandleVisible);
}
template <typename Strategy>
@@ -276,7 +280,8 @@ void FrameSelection::setSelectionAlgorithm(
const VisibleSelectionTemplate<Strategy>& newSelection,
SetSelectionOptions options,
CursorAlignOnScroll align,
- TextGranularity granularity) {
+ TextGranularity granularity,
+ bool isHandleVisible) {
DCHECK(isAvailable());
DCHECK(newSelection.isValidFor(document()));
const Document& currentDocument = document();
@@ -301,7 +306,8 @@ void FrameSelection::setSelectionAlgorithm(
if (shouldClearTypingStyle)
clearTypingStyle();
- if (m_selectionEditor->visibleSelection<Strategy>() == s) {
+ if (m_selectionEditor->visibleSelection<Strategy>() == s &&
+ m_isHandleVisible == isHandleVisible) {
// Even if selection was not changed, selection offsets may have been
// changed.
m_frame->inputMethodController().cancelCompositionIfSelectionIsInvalid();
@@ -313,6 +319,7 @@ void FrameSelection::setSelectionAlgorithm(
visibleSelection<Strategy>();
const VisibleSelection oldSelectionInDOMTree = selection();
+ m_isHandleVisible = isHandleVisible;
m_selectionEditor->setVisibleSelection(s, options);
m_frameCaret->setCaretRectNeedsUpdate();
@@ -387,18 +394,20 @@ void FrameSelection::setSelectionAlgorithm(
void FrameSelection::setSelection(const VisibleSelection& newSelection,
SetSelectionOptions options,
CursorAlignOnScroll align,
- TextGranularity granularity) {
+ TextGranularity granularity,
+ bool isHandleVisible) {
setSelectionAlgorithm<EditingStrategy>(newSelection, options, align,
- granularity);
+ granularity, isHandleVisible);
}
void FrameSelection::setSelection(
const VisibleSelectionInFlatTree& newSelection,
SetSelectionOptions options,
CursorAlignOnScroll align,
- TextGranularity granularity) {
- setSelectionAlgorithm<EditingInFlatTreeStrategy>(newSelection, options, align,
- granularity);
+ TextGranularity granularity,
+ bool isHandleVisible) {
+ setSelectionAlgorithm<EditingInFlatTreeStrategy>(
+ newSelection, options, align, granularity, isHandleVisible);
}
static bool removingNodeRemovesPosition(Node& node, const Position& position) {
@@ -815,19 +824,13 @@ void FrameSelection::paintCaret(GraphicsContext& context,
m_frameCaret->paintCaret(context, paintOffset);
}
-bool FrameSelection::contains(const LayoutPoint& point) {
- if (document().layoutViewItem().isNull())
- return false;
-
+bool FrameSelection::contains(const HitTestResult& result) {
// Treat a collapsed selection like no selection.
const VisibleSelectionInFlatTree& visibleSelection =
this->visibleSelection<EditingInFlatTreeStrategy>();
if (!visibleSelection.isRange())
return false;
- HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
- HitTestResult result(request, point);
- document().layoutViewItem().hitTest(result);
Node* innerNode = result.innerNode();
if (!innerNode || !innerNode->layoutObject())
return false;
@@ -850,6 +853,17 @@ bool FrameSelection::contains(const LayoutPoint& point) {
return start.compareTo(pos) <= 0 && pos.compareTo(end) <= 0;
}
+bool FrameSelection::contains(const LayoutPoint& point) {
+ if (document().layoutViewItem().isNull())
+ return false;
+
+ HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
+ HitTestResult result(request, point);
+ document().layoutViewItem().hitTest(result);
+
+ return contains(result);
+}
+
// Workaround for the fact that it's hard to delete a frame.
// Call this after doing user-triggered selections to make it easy to delete the
// frame you entirely selected. Can't do this implicitly as part of every
@@ -1422,7 +1436,8 @@ void FrameSelection::moveRangeSelectionExtent(const IntPoint& contentsPoint) {
setSelection(newSelection,
FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle |
FrameSelection::DoNotClearStrategy | UserTriggered,
- CursorAlignOnScroll::IfNeeded, CharacterGranularity);
+ CursorAlignOnScroll::IfNeeded, CharacterGranularity,
+ m_isHandleVisible);
}
void FrameSelection::moveRangeSelection(const VisiblePosition& basePosition,
@@ -1435,7 +1450,7 @@ void FrameSelection::moveRangeSelection(const VisiblePosition& basePosition,
if (newSelection.isNone())
return;
- setSelection(newSelection, granularity);
+ setSelection(newSelection, granularity, m_isHandleVisible);
}
void FrameSelection::updateIfNeeded() {

Powered by Google App Engine
This is Rietveld 408576698