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 df3a10d601da448046f48b3ae3b1b655a928d5b2..e182a132ddbe2c00f3e39abd7b53d1d8cd7a50e6 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_handleVisibility(HandleVisibility::NotVisible), |
yosin_UTC9
2016/10/19 06:33:05
nit: Let's initialize in class declaration instead
amaralp
2016/10/21 03:47:18
Done.
|
m_frameCaret(new FrameCaret(frame, *m_selectionEditor)) { |
DCHECK(frame); |
} |
@@ -158,6 +159,9 @@ void FrameSelection::moveTo(const VisiblePosition& pos, |
EUserTriggered userTriggered, |
CursorAlignOnScroll align) { |
SetSelectionOptions options = CloseTyping | ClearTypingStyle | userTriggered; |
+ bool isHandleVisible = userTriggered == UserTriggered; |
yosin_UTC9
2016/10/19 06:33:05
nit: This variable name makes me confusing, should
amaralp
2016/10/21 03:47:18
Done.
|
+ if (isHandleVisible) |
+ options |= HandleVisible; |
setSelection(createVisibleSelection(pos, pos, selection().isDirectional()), |
options, align); |
} |
@@ -218,7 +222,8 @@ static void adjustEndpointsAtBidiBoundary( |
void FrameSelection::setNonDirectionalSelectionIfNeeded( |
const VisibleSelectionInFlatTree& passedNewSelection, |
TextGranularity granularity, |
- EndPointsAdjustmentMode endpointsAdjustmentMode) { |
+ EndPointsAdjustmentMode endpointsAdjustmentMode, |
+ const HandleVisibility& handleVisibility) { |
yosin_UTC9
2016/10/19 06:33:05
Since |HandleVisibility| is |enum|, we don't need
amaralp
2016/10/21 03:47:18
Done.
|
VisibleSelectionInFlatTree newSelection = passedNewSelection; |
bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) || |
newSelection.isDirectional(); |
@@ -256,10 +261,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_handleVisibility == handleVisibility) |
return; |
- const SetSelectionOptions options = CloseTyping | ClearTypingStyle; |
+ SetSelectionOptions options = CloseTyping | ClearTypingStyle; |
+ if (handleVisibility == HandleVisibility::Visible) |
+ options |= HandleVisible; |
setSelection(newSelection, options, CursorAlignOnScroll::IfNeeded, |
granularity); |
} |
@@ -278,6 +286,9 @@ void FrameSelection::setSelectionAlgorithm( |
m_granularityStrategy->Clear(); |
bool closeTyping = options & CloseTyping; |
bool shouldClearTypingStyle = options & ClearTypingStyle; |
+ HandleVisibility handleVisibility = options & HandleVisible |
yosin_UTC9
2016/10/19 06:33:05
nit: s/HandleVisibility/const HandleVisibility/
amaralp
2016/10/21 03:47:18
Done.
|
+ ? HandleVisibility::Visible |
+ : HandleVisibility::NotVisible; |
EUserTriggered userTriggered = selectionOptionsToUserTriggered(options); |
VisibleSelectionTemplate<Strategy> s = validateSelection(newSelection); |
@@ -294,7 +305,8 @@ void FrameSelection::setSelectionAlgorithm( |
if (shouldClearTypingStyle) |
clearTypingStyle(); |
- if (m_selectionEditor->visibleSelection<Strategy>() == s) { |
+ if (m_selectionEditor->visibleSelection<Strategy>() == s && |
+ m_handleVisibility == handleVisibility) { |
// Even if selection was not changed, selection offsets may have been |
// changed. |
m_frame->inputMethodController().cancelCompositionIfSelectionIsInvalid(); |
@@ -306,6 +318,7 @@ void FrameSelection::setSelectionAlgorithm( |
visibleSelection<Strategy>(); |
const VisibleSelection oldSelectionInDOMTree = selection(); |
+ m_handleVisibility = handleVisibility; |
m_selectionEditor->setVisibleSelection(s, options); |
m_frameCaret->setCaretRectNeedsUpdate(); |
@@ -840,19 +853,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; |
@@ -875,6 +882,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 |
@@ -1441,7 +1459,8 @@ void FrameSelection::moveRangeSelectionExtent(const IntPoint& contentsPoint) { |
granularityStrategy()->updateExtent(contentsPoint, m_frame); |
setSelection(newSelection, |
FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | |
- FrameSelection::DoNotClearStrategy | UserTriggered, |
+ FrameSelection::DoNotClearStrategy | UserTriggered | |
+ FrameSelection::HandleVisible, |
CursorAlignOnScroll::IfNeeded, CharacterGranularity); |
} |
@@ -1454,8 +1473,11 @@ void FrameSelection::moveRangeSelection(const VisiblePosition& basePosition, |
if (newSelection.isNone()) |
return; |
- |
- setSelection(newSelection, granularity); |
+ SetSelectionOptions options = CloseTyping | ClearTypingStyle; |
+ if (isHandleVisible()) |
+ options |= HandleVisible; |
+ setSelection(newSelection, options, CursorAlignOnScroll::IfNeeded, |
+ granularity); |
} |
void FrameSelection::updateIfNeeded() { |