|
Lines 250-282
void FrameSelection::setSelectionByMouse
Source/WebCore/editing/FrameSelection.cpp_sec1
|
| 250 |
setSelection(newSelection, UserTriggered | DoNotRevealSelection | CloseTyping | ClearTypingStyle, AlignCursorOnScrollIfNeeded, granularity); |
250 |
setSelection(newSelection, UserTriggered | DoNotRevealSelection | CloseTyping | ClearTypingStyle, AlignCursorOnScrollIfNeeded, granularity); |
| 251 |
} |
251 |
} |
| 252 |
|
252 |
|
| 253 |
bool FrameSelection::setSelectionWithoutUpdatingAppearance(const VisibleSelection& newSelection, SetSelectionOptions options, CursorAlignOnScroll align, TextGranularity granularity, EUserTriggered userTriggered) |
253 |
bool FrameSelection::setSelectionWithoutUpdatingAppearance(const VisibleSelection& newSelectionPossiblyWithoutDirection, SetSelectionOptions options, CursorAlignOnScroll align, TextGranularity granularity, EUserTriggered userTriggered) |
| 254 |
{ |
254 |
{ |
| 255 |
bool closeTyping = options & CloseTyping; |
255 |
bool closeTyping = options & CloseTyping; |
| 256 |
bool shouldClearTypingStyle = options & ClearTypingStyle; |
256 |
bool shouldClearTypingStyle = options & ClearTypingStyle; |
| 257 |
|
257 |
|
| 258 |
VisibleSelection s = newSelection; |
258 |
VisibleSelection newSelection = newSelectionPossiblyWithoutDirection; |
| 259 |
if (shouldAlwaysUseDirectionalSelection(m_frame)) |
259 |
if (shouldAlwaysUseDirectionalSelection(m_frame)) |
| 260 |
s.setIsDirectional(true); |
260 |
newSelection.setIsDirectional(true); |
| 261 |
|
261 |
|
| 262 |
if (!m_frame) { |
262 |
if (!m_frame) { |
| 263 |
m_selection = s; |
263 |
m_selection = newSelection; |
| 264 |
return false; |
264 |
return false; |
| 265 |
} |
265 |
} |
| 266 |
|
266 |
|
| 267 |
// <http://bugs.webkit.org/show_bug.cgi?id=23464>: Infinite recursion at FrameSelection::setSelection |
267 |
// <http://bugs.webkit.org/show_bug.cgi?id=23464>: Infinite recursion at FrameSelection::setSelection |
| 268 |
// if document->frame() == m_frame we can get into an infinite loop |
268 |
// if document->frame() == m_frame we can get into an infinite loop |
| 269 |
if (s.base().anchorNode()) { |
269 |
if (Document* newSelectionDocument = newSelection.base().document()) { |
| 270 |
Document& document = s.base().anchorNode()->document(); |
270 |
if (RefPtr<Frame> newSelectionFrame = newSelectionDocument->frame()) { |
| 271 |
if (document.frame() && document.frame() != m_frame && &document != m_frame->document()) { |
271 |
if (newSelectionFrame != m_frame && newSelectionDocument != m_frame->document()) { |
| 272 |
RefPtr<Frame> guard = document.frame(); |
272 |
newSelectionFrame->selection().setSelection(newSelection, options, align, granularity); |
| 273 |
document.frame()->selection().setSelection(s, options, align, granularity); |
273 |
// It's possible that during the above set selection, this FrameSelection has been modified by |
| 274 |
// It's possible that during the above set selection, this FrameSelection has been modified by |
274 |
// selectFrameElementInParentIfFullySelected, but that the selection is no longer valid since |
| 275 |
// selectFrameElementInParentIfFullySelected, but that the selection is no longer valid since |
275 |
// the frame is about to be destroyed. If this is the case, clear our selection. |
| 276 |
// the frame is about to be destroyed. If this is the case, clear our selection. |
276 |
if (newSelectionFrame->hasOneRef() && !m_selection.isNonOrphanedCaretOrRange()) |
| 277 |
if (guard->hasOneRef() && !m_selection.isNonOrphanedCaretOrRange()) |
277 |
clear(); |
| 278 |
clear(); |
278 |
return false; |
| 279 |
return false; |
279 |
} |
| 280 |
} |
280 |
} |
| 281 |
} |
281 |
} |
| 282 |
|
282 |
|
|
Lines 292-316
bool FrameSelection::setSelectionWithout
Source/WebCore/editing/FrameSelection.cpp_sec2
|
| 292 |
if (shouldClearTypingStyle) |
292 |
if (shouldClearTypingStyle) |
| 293 |
clearTypingStyle(); |
293 |
clearTypingStyle(); |
| 294 |
|
294 |
|
| 295 |
if (m_selection == s) { |
|
|
| 296 |
// Even if selection was not changed, selection offsets may have been changed. |
| 297 |
updateSelectionCachesIfSelectionIsInsideTextFormControl(userTriggered); |
| 298 |
return false; |
| 299 |
} |
| 300 |
|
| 301 |
VisibleSelection oldSelection = m_selection; |
295 |
VisibleSelection oldSelection = m_selection; |
|
|
296 |
m_selection = newSelection; |
| 297 |
|
| 298 |
// Selection offsets should increase when LF is inserted before the caret in InsertLineBreakCommand. See <https://webkit.org/b/56061>. |
| 299 |
if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(newSelection.start())) |
| 300 |
textControl->selectionChanged(userTriggered == UserTriggered); |
| 301 |
|
| 302 |
if (oldSelection == newSelection) |
| 303 |
return false; |
| 302 |
|
304 |
|
| 303 |
m_selection = s; |
|
|
| 304 |
setCaretRectNeedsUpdate(); |
305 |
setCaretRectNeedsUpdate(); |
| 305 |
|
306 |
|
| 306 |
if (!s.isNone() && !(options & DoNotSetFocus)) |
307 |
if (!newSelection.isNone() && !(options & DoNotSetFocus)) |
| 307 |
setFocusedElementIfNeeded(); |
308 |
setFocusedElementIfNeeded(); |
| 308 |
|
309 |
|
| 309 |
// Always clear the x position used for vertical arrow navigation. |
310 |
// Always clear the x position used for vertical arrow navigation. |
| 310 |
// It will be restored by the vertical arrow navigation code if necessary. |
311 |
// It will be restored by the vertical arrow navigation code if necessary. |
| 311 |
m_xPosForVerticalArrowNavigation = NoXPosForVerticalArrowNavigation(); |
312 |
m_xPosForVerticalArrowNavigation = NoXPosForVerticalArrowNavigation(); |
| 312 |
selectFrameElementInParentIfFullySelected(); |
313 |
selectFrameElementInParentIfFullySelected(); |
| 313 |
updateSelectionCachesIfSelectionIsInsideTextFormControl(userTriggered); |
|
|
| 314 |
m_frame->editor().respondToChangedSelection(oldSelection, options); |
314 |
m_frame->editor().respondToChangedSelection(oldSelection, options); |
| 315 |
m_frame->document()->enqueueDocumentEvent(Event::create(eventNames().selectionchangeEvent, false, false)); |
315 |
m_frame->document()->enqueueDocumentEvent(Event::create(eventNames().selectionchangeEvent, false, false)); |
| 316 |
|
316 |
|
|
Lines 1706-1715
void FrameSelection::selectAll()
Source/WebCore/editing/FrameSelection.cpp_sec3
|
| 1706 |
VisibleSelection newSelection(VisibleSelection::selectionFromContentsOfNode(root.get())); |
1706 |
VisibleSelection newSelection(VisibleSelection::selectionFromContentsOfNode(root.get())); |
| 1707 |
|
1707 |
|
| 1708 |
if (shouldChangeSelection(newSelection)) |
1708 |
if (shouldChangeSelection(newSelection)) |
| 1709 |
setSelection(newSelection); |
1709 |
setSelection(newSelection, UserTriggered | CloseTyping | ClearTypingStyle | DoNotRevealSelection); |
| 1710 |
|
|
|
| 1711 |
selectFrameElementInParentIfFullySelected(); |
| 1712 |
updateSelectionCachesIfSelectionIsInsideTextFormControl(UserTriggered); |
| 1713 |
} |
1710 |
} |
| 1714 |
|
1711 |
|
| 1715 |
bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, bool closeTyping) |
1712 |
bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, bool closeTyping) |
|
Lines 1912-1923
void FrameSelection::caretBlinkTimerFire
Source/WebCore/editing/FrameSelection.cpp_sec4
|
| 1912 |
#endif |
1909 |
#endif |
| 1913 |
} |
1910 |
} |
| 1914 |
|
1911 |
|
| 1915 |
void FrameSelection::updateSelectionCachesIfSelectionIsInsideTextFormControl(EUserTriggered userTriggered) |
|
|
| 1916 |
{ |
| 1917 |
if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(m_selection.start())) |
| 1918 |
textControl->selectionChanged(userTriggered == UserTriggered); |
| 1919 |
} |
| 1920 |
|
| 1921 |
// Helper function that tells whether a particular node is an element that has an entire |
1912 |
// Helper function that tells whether a particular node is an element that has an entire |
| 1922 |
// Frame and FrameView, a <frame>, <iframe>, or <object>. |
1913 |
// Frame and FrameView, a <frame>, <iframe>, or <object>. |
| 1923 |
static bool isFrameElement(const Node* n) |
1914 |
static bool isFrameElement(const Node* n) |