Changeset 238440 in webkit
- Timestamp:
- Nov 21, 2018 10:39:15 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r238438 r238440 1 2018-11-21 Ryosuke Niwa <rniwa@webkit.org> 2 3 Phantom focus/blur events fire on clicking between text input fields when listening with addEventListener 4 https://bugs.webkit.org/show_bug.cgi?id=179990 5 6 Reviewed by Tim Horton. 7 8 The bug was caused by TemporarySelectionChange which is used by TextIndicator::createWithRange 9 to set and restore the selection putting the focus on the newly mouse-down'ed input element 10 and restoring the focus back to the input element which originally had the focus immediately. 11 12 Fixed the bug by avoiding to set the focus since only selection highlights need to be updated here. 13 Also made TemporarySelectionOption an enum class. 14 15 Unfortunately, no new tests since force click testing is broken :( See <rdar://problem/31301721>. 16 17 * editing/Editor.cpp: 18 (WebCore::TemporarySelectionChange::TemporarySelectionChange): 19 (WebCore::TemporarySelectionChange::~TemporarySelectionChange): 20 (WebCore::TemporarySelectionChange::setSelection): Extracted. Fixed the bug by adding 21 FrameSelection::DoNotSetFocus to the option when TemporarySelectionOption::DoNotSetFocus is set. 22 * editing/Editor.h: 23 * page/DragController.cpp: 24 (WebCore::DragController::performDragOperation): 25 * page/TextIndicator.cpp: 26 (WebCore::TextIndicator::createWithRange): Set TemporarySelectionOption::DoNotSetFocus. 27 1 28 2018-11-21 Wenson Hsieh <wenson_hsieh@apple.com> 2 29 -
trunk/Source/WebCore/editing/Editor.cpp
r238359 r238440 207 207 { 208 208 #if PLATFORM(IOS_FAMILY) 209 if (options & TemporarySelectionOption EnableAppearanceUpdates)209 if (options & TemporarySelectionOption::EnableAppearanceUpdates) 210 210 frame.selection().setUpdateAppearanceEnabled(true); 211 211 #endif 212 212 213 if (options & TemporarySelectionOption IgnoreSelectionChanges)213 if (options & TemporarySelectionOption::IgnoreSelectionChanges) 214 214 frame.editor().setIgnoreSelectionChanges(true); 215 215 216 216 if (temporarySelection) { 217 217 m_selectionToRestore = frame.selection().selection(); 218 frame.selection().setSelection(temporarySelection.value());218 setSelection(temporarySelection.value()); 219 219 } 220 220 } … … 223 223 { 224 224 if (m_selectionToRestore) 225 m_frame->selection().setSelection(m_selectionToRestore.value());226 227 if (m_options & TemporarySelectionOption IgnoreSelectionChanges) {228 auto revealSelection = m_options & TemporarySelectionOption RevealSelection ? Editor::RevealSelection::Yes : Editor::RevealSelection::No;225 setSelection(m_selectionToRestore.value()); 226 227 if (m_options & TemporarySelectionOption::IgnoreSelectionChanges) { 228 auto revealSelection = m_options & TemporarySelectionOption::RevealSelection ? Editor::RevealSelection::Yes : Editor::RevealSelection::No; 229 229 m_frame->editor().setIgnoreSelectionChanges(m_wasIgnoringSelectionChanges, revealSelection); 230 230 } 231 231 232 232 #if PLATFORM(IOS_FAMILY) 233 if (m_options & TemporarySelectionOption EnableAppearanceUpdates)233 if (m_options & TemporarySelectionOption::EnableAppearanceUpdates) 234 234 m_frame->selection().setUpdateAppearanceEnabled(m_appearanceUpdatesWereEnabled); 235 235 #endif 236 } 237 238 void TemporarySelectionChange::setSelection(const VisibleSelection& selection) 239 { 240 auto options = FrameSelection::defaultSetSelectionOptions(); 241 if (m_options & TemporarySelectionOption::DoNotSetFocus) 242 options.add(FrameSelection::DoNotSetFocus); 243 m_frame->selection().setSelection(selection, options); 236 244 } 237 245 -
trunk/Source/WebCore/editing/Editor.h
r238080 r238440 103 103 #endif 104 104 105 enum TemporarySelectionOption : uint8_t {106 // Scroll to reveal the selection.107 TemporarySelectionOptionRevealSelection = 1 << 0,105 enum class TemporarySelectionOption : uint8_t { 106 RevealSelection = 1 << 0, 107 DoNotSetFocus = 1 << 1, 108 108 109 109 // Don't propagate selection changes to the client layer. 110 TemporarySelectionOptionIgnoreSelectionChanges = 1 << 1,110 IgnoreSelectionChanges = 1 << 2, 111 111 112 112 // Force the render tree to update selection state. Only respected on iOS. 113 TemporarySelectionOptionEnableAppearanceUpdates = 1 << 2113 EnableAppearanceUpdates = 1 << 3, 114 114 }; 115 115 … … 120 120 121 121 private: 122 void setSelection(const VisibleSelection&); 123 122 124 Ref<Frame> m_frame; 123 125 OptionSet<TemporarySelectionOption> m_options; -
trunk/Source/WebCore/page/DragController.cpp
r238375 r238440 252 252 { 253 253 SetForScope<bool> isPerformingDrop(m_isPerformingDrop, true); 254 TemporarySelectionChange ignoreSelectionChanges(m_page.focusController().focusedOrMainFrame(), std::nullopt, TemporarySelectionOption IgnoreSelectionChanges);254 TemporarySelectionChange ignoreSelectionChanges(m_page.focusController().focusedOrMainFrame(), std::nullopt, TemporarySelectionOption::IgnoreSelectionChanges); 255 255 256 256 m_documentUnderMouse = m_page.mainFrame().documentAtPoint(dragData.clientPosition()); -
trunk/Source/WebCore/page/TextIndicator.cpp
r237266 r238440 78 78 VisibleSelection oldSelection = frame->selection().selection(); 79 79 OptionSet<TemporarySelectionOption> temporarySelectionOptions; 80 #if PLATFORM(IOS_FAMILY) 81 temporarySelectionOptions.add(TemporarySelectionOptionIgnoreSelectionChanges); 82 temporarySelectionOptions.add(TemporarySelectionOptionEnableAppearanceUpdates); 80 temporarySelectionOptions.add(TemporarySelectionOption::DoNotSetFocus); 81 #if PLATFORM(IOS_FAMILY) 82 temporarySelectionOptions.add(TemporarySelectionOption::IgnoreSelectionChanges); 83 temporarySelectionOptions.add(TemporarySelectionOption::EnableAppearanceUpdates); 83 84 #endif 84 85 TemporarySelectionChange selectionChange(*frame, { range }, temporarySelectionOptions);
Note: See TracChangeset
for help on using the changeset viewer.