Changeset 54212 in webkit
- Timestamp:
- Feb 2, 2010 12:25:30 AM (14 years ago)
- Location:
- trunk/WebKit/chromium
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/chromium/ChangeLog
r54195 r54212 1 2010-02-02 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Darin Fisher. 4 5 [Chromium] Should not select a word on right-click. 6 https://bugs.webkit.org/show_bug.cgi?id=33364 7 8 For non-Mac platforms, do not select a word around the caret when 9 a context menu is opening. This behavior is not common in non-Mac 10 platforms, and it prevents pasting with a context menu. 11 12 In order that the spell checker works without the selection, we 13 introduce WebFrame::selectWordAroundCaret(). We can replace a word 14 around the caret with selectWordAroundCaret() + replaceSelection(). 15 16 * public/WebFrame.h: Add pure selectWordAroundCaret() declaration. 17 * src/ContextMenuClientImpl.cpp: 18 (WebKit::selectMisspelledWord): Move word-selection code to 19 WebFrameImpl::selectWordAroundPosition(), and clear the selection 20 on non-Mac. 21 * src/WebFrameImpl.cpp: 22 (WebKit::WebFrameImpl::selectWordAroundPosition): 23 (WebKit::WebFrameImpl::selectWordAroundCaret): 24 * src/WebFrameImpl.h: Add selectWordAroundCaret() declaration. 25 1 26 2010-02-01 Shinichiro Hamaji <hamaji@chromium.org> 2 27 -
trunk/WebKit/chromium/public/WebFrame.h
r52851 r54212 358 358 virtual WebString selectionAsMarkup() const = 0; 359 359 360 // Expands the selection to a word around the caret and returns 361 // true. Does nothing and returns false if there is no caret or 362 // there is ranged selection. 363 virtual bool selectWordAroundCaret() = 0; 364 360 365 361 366 // Printing ------------------------------------------------------------ -
trunk/WebKit/chromium/src/ContextMenuClientImpl.cpp
r54119 r54212 90 90 // is to be evolked. This function also sets the word on which context menu 91 91 // has been evoked to be the selected word, as required. This function changes 92 // the selection only when there were no selected characters .92 // the selection only when there were no selected characters on OS X. 93 93 static String selectMisspelledWord(const ContextMenu* defaultMenu, Frame* selectedFrame) 94 94 { … … 111 111 hitTestResult.localPoint())); 112 112 113 VisibleSelection selection; 114 if (pos.isNotNull()) { 115 selection = VisibleSelection(pos); 116 selection.expandUsingGranularity(WordGranularity); 117 } 118 119 if (selection.isRange()) 120 selectedFrame->setSelectionGranularity(WordGranularity); 121 122 if (selectedFrame->shouldChangeSelection(selection)) 123 selectedFrame->selection()->setSelection(selection); 124 113 if (pos.isNull()) 114 return misspelledWord; // It is empty. 115 116 WebFrameImpl::selectWordAroundPosition(selectedFrame, pos); 125 117 misspelledWord = selectedFrame->selectedText().stripWhiteSpace(); 126 118 119 #if OS(DARWIN) 127 120 // If misspelled word is still empty, then that portion should not be 128 121 // selected. Set the selection to that position only, and do not expand. 129 if (misspelledWord.isEmpty()) { 130 selection = VisibleSelection(pos); 131 selectedFrame->selection()->setSelection(selection); 132 } 133 122 if (misspelledWord.isEmpty()) 123 selectedFrame->selection()->setSelection(VisibleSelection(pos)); 124 #else 125 // On non-Mac, right-click should not make a range selection in any case. 126 selectedFrame->selection()->setSelection(VisibleSelection(pos)); 127 #endif 134 128 return misspelledWord; 135 129 } -
trunk/WebKit/chromium/src/WebFrameImpl.cpp
r53527 r54212 1078 1078 } 1079 1079 1080 void WebFrameImpl::selectWordAroundPosition(Frame* frame, VisiblePosition pos) 1081 { 1082 VisibleSelection selection(pos); 1083 selection.expandUsingGranularity(WordGranularity); 1084 1085 if (selection.isRange()) 1086 frame->setSelectionGranularity(WordGranularity); 1087 1088 if (frame->shouldChangeSelection(selection)) 1089 frame->selection()->setSelection(selection); 1090 } 1091 1092 bool WebFrameImpl::selectWordAroundCaret() 1093 { 1094 SelectionController* controller = frame()->selection(); 1095 ASSERT(!controller->isNone()); 1096 if (controller->isNone() || controller->isRange()) 1097 return false; 1098 selectWordAroundPosition(frame(), controller->selection().visibleStart()); 1099 return true; 1100 } 1101 1080 1102 int WebFrameImpl::printBegin(const WebSize& pageSize) 1081 1103 { -
trunk/WebKit/chromium/src/WebFrameImpl.h
r52851 r54212 142 142 virtual WebString selectionAsText() const; 143 143 virtual WebString selectionAsMarkup() const; 144 virtual bool selectWordAroundCaret(); 144 145 virtual int printBegin(const WebSize& pageSize); 145 146 virtual float printPage(int pageToPrint, WebCanvas*); … … 220 221 void dropClient() { m_client = 0; } 221 222 223 static void selectWordAroundPosition(WebCore::Frame*, WebCore::VisiblePosition); 224 222 225 private: 223 226 class DeferredScopeStringMatches;
Note: See TracChangeset
for help on using the changeset viewer.