Changeset 271459 in webkit
- Timestamp:
- Jan 13, 2021 2:50:25 PM (18 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 16 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item-expected.txt (added)
-
LayoutTests/editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item.html (added)
-
LayoutTests/platform/mac-wk1/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/editing/AlternativeTextController.cpp (modified) (2 diffs)
-
Source/WebCore/editing/AlternativeTextController.h (modified) (1 diff)
-
Source/WebCore/editing/Editor.cpp (modified) (1 diff)
-
Source/WebCore/editing/Editor.h (modified) (1 diff)
-
Source/WebCore/page/ContextMenuController.cpp (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Shared/EditorState.cpp (modified) (3 diffs)
-
Source/WebKit/Shared/EditorState.h (modified) (1 diff)
-
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (modified) (7 diffs)
-
Tools/TestWebKitAPI/Tests/mac/DisableAutomaticSpellingCorrection.mm (added)
-
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r271454 r271459 1 2021-01-13 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] "Correct Spelling Automatically" menu items are inconsistent when autocorrect="off" 4 https://bugs.webkit.org/show_bug.cgi?id=220598 5 <rdar://problem/71713611> 6 7 Reviewed by Tim Horton. 8 9 Add a new API test to verify that the context menu item to toggle "Correct Spelling Automatically" is disabled 10 when autocorrect="off". 11 12 * editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item-expected.txt: Added. 13 * editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item.html: Added. 14 * platform/mac-wk1/TestExpectations: 15 16 Disable the test in DumpRenderTree, due to lack of support for context menu testing in WebKit1. 17 1 18 2021-01-13 Truitt Savell <tsavell@apple.com> 2 19 -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r271324 r271459 290 290 # Fails with WebKit1 only. 291 291 editing/secure-input/reset-state-on-navigation.html [ Failure ] 292 293 # Context menu API is not exposed on DumpRenderTree. 294 editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item.html [ Skip ] 292 295 293 296 http/tests/plugins/nounsupported-plugin.html [ Skip ] -
trunk/Source/WebCore/ChangeLog
r271452 r271459 1 2021-01-13 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] "Correct Spelling Automatically" menu items are inconsistent when autocorrect="off" 4 https://bugs.webkit.org/show_bug.cgi?id=220598 5 <rdar://problem/71713611> 6 7 Reviewed by Tim Horton. 8 9 Disable the context menu item to toggle automatic spelling correction, as well as the menu bar item to toggle 10 automatic spelling correction, in the case where the autocorrect attribute is set to "off". See below for more 11 details. 12 13 Tests: editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item.html 14 DisableAutomaticSpellingCorrection.AutocorrectAttribute 15 16 * editing/AlternativeTextController.cpp: 17 (WebCore::AlternativeTextController::canEnableAutomaticSpellingCorrection const): 18 19 Factor out logic for checking the `autocorrect` attribute into a separate helper function; this is used to 20 determine whether or not we should enable both the context menu item and menu item in the menu bar. 21 22 (WebCore::AlternativeTextController::isAutomaticSpellingCorrectionEnabled): 23 * editing/AlternativeTextController.h: 24 (WebCore::AlternativeTextController::UNLESS_ENABLED): 25 * editing/Editor.cpp: 26 (WebCore::Editor::canEnableAutomaticSpellingCorrection const): 27 * editing/Editor.h: 28 * page/ContextMenuController.cpp: 29 (WebCore::ContextMenuController::checkOrEnableIfNeeded const): 30 1 31 2021-01-13 Fujii Hironori <Hironori.Fujii@sony.com> 2 32 -
trunk/Source/WebCore/editing/AlternativeTextController.cpp
r267363 r271459 336 336 } 337 337 338 bool AlternativeTextController::isAutomaticSpellingCorrectionEnabled() 339 { 340 if (!editorClient() || !editorClient()->isAutomaticSpellingCorrectionEnabled()) 341 return false; 342 338 bool AlternativeTextController::canEnableAutomaticSpellingCorrection() const 339 { 343 340 #if ENABLE(AUTOCORRECT) 344 341 auto position = m_document.selection().selection().start(); … … 355 352 356 353 return true; 354 } 355 356 bool AlternativeTextController::isAutomaticSpellingCorrectionEnabled() 357 { 358 if (!editorClient() || !editorClient()->isAutomaticSpellingCorrectionEnabled()) 359 return false; 360 361 return canEnableAutomaticSpellingCorrection(); 357 362 } 358 363 -
trunk/Source/WebCore/editing/AlternativeTextController.h
r264247 r271459 87 87 bool isSpellingMarkerAllowed(const SimpleRange& misspellingRange) const UNLESS_ENABLED({ UNUSED_PARAM(misspellingRange); return true; }) 88 88 bool isAutomaticSpellingCorrectionEnabled() UNLESS_ENABLED({ return false; }) 89 bool canEnableAutomaticSpellingCorrection() const UNLESS_ENABLED({ return false; }) 89 90 bool shouldRemoveMarkersUponEditing(); 90 91 -
trunk/Source/WebCore/editing/Editor.cpp
r269888 r271459 1766 1766 } 1767 1767 1768 bool Editor::canEnableAutomaticSpellingCorrection() const 1769 { 1770 return m_alternativeTextController->canEnableAutomaticSpellingCorrection(); 1771 } 1772 1768 1773 bool Editor::isAutomaticSpellingCorrectionEnabled() 1769 1774 { -
trunk/Source/WebCore/editing/Editor.h
r266557 r271459 512 512 WEBCORE_EXPORT bool isAutomaticSpellingCorrectionEnabled(); 513 513 WEBCORE_EXPORT void toggleAutomaticSpellingCorrection(); 514 WEBCORE_EXPORT bool canEnableAutomaticSpellingCorrection() const; 514 515 #endif 515 516 -
trunk/Source/WebCore/page/ContextMenuController.cpp
r270974 r271459 1325 1325 case ContextMenuItemTagCorrectSpellingAutomatically: 1326 1326 shouldCheck = frame->editor().isAutomaticSpellingCorrectionEnabled(); 1327 shouldEnable = frame->editor().canEnableAutomaticSpellingCorrection(); 1327 1328 break; 1328 1329 case ContextMenuItemTagSmartCopyPaste: -
trunk/Source/WebKit/ChangeLog
r271457 r271459 1 2021-01-13 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] "Correct Spelling Automatically" menu items are inconsistent when autocorrect="off" 4 https://bugs.webkit.org/show_bug.cgi?id=220598 5 <rdar://problem/71713611> 6 7 Reviewed by Tim Horton. 8 9 Plumb the new `canEnableAutomaticSpellingCorrection` flag through `EditorState` to the UI process, where we can 10 consult it when validating user interface items (namely, the "Correct Spelling Automatically" menu item, which 11 corresponds to the `-toggleAutomaticSpellingCorrection:` selector). 12 13 * Shared/EditorState.cpp: 14 (WebKit::EditorState::PostLayoutData::encode const): 15 (WebKit::EditorState::PostLayoutData::decode): 16 (WebKit::operator<<): 17 * Shared/EditorState.h: 18 * UIProcess/Cocoa/WebViewImpl.mm: 19 (WebKit::WebViewImpl::validateUserInterfaceItem): 20 * WebProcess/WebPage/mac/WebPageMac.mm: 21 (WebKit::WebPage::getPlatformEditorState const): 22 1 23 2021-01-13 Alex Christensen <achristensen@webkit.org> 2 24 -
trunk/Source/WebKit/Shared/EditorState.cpp
r266265 r271459 133 133 encoder << paragraphContextForCandidateRequest; 134 134 encoder << stringForCandidateRequest; 135 encoder << canEnableAutomaticSpellingCorrection; 135 136 #endif 136 137 #if PLATFORM(GTK) || PLATFORM(WPE) … … 224 225 225 226 if (!decoder.decode(result.stringForCandidateRequest)) 227 return false; 228 229 if (!decoder.decode(result.canEnableAutomaticSpellingCorrection)) 226 230 return false; 227 231 #endif … … 339 343 if (editorState.postLayoutData().stringForCandidateRequest.length()) 340 344 ts.dumpProperty("stringForCandidateRequest", editorState.postLayoutData().stringForCandidateRequest); 345 if (editorState.postLayoutData().canEnableAutomaticSpellingCorrection) 346 ts.dumpProperty("canEnableAutomaticSpellingCorrection", editorState.postLayoutData().canEnableAutomaticSpellingCorrection); 341 347 #endif 342 348 -
trunk/Source/WebKit/Shared/EditorState.h
r266265 r271459 124 124 String paragraphContextForCandidateRequest; 125 125 String stringForCandidateRequest; 126 bool canEnableAutomaticSpellingCorrection { true }; 126 127 #endif 127 128 #if PLATFORM(GTK) || PLATFORM(WPE) -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r271187 r271459 3064 3064 3065 3065 if (action == @selector(toggleAutomaticSpellingCorrection:)) { 3066 bool checked = TextChecker::state().isAutomaticSpellingCorrectionEnabled; 3067 [menuItem(item) setState:checked ? NSControlStateValueOn : NSControlStateValueOff]; 3068 return m_page->editorState().isContentEditable; 3066 auto& editorState = m_page->editorState(); 3067 bool enable = editorState.isContentEditable && (editorState.isMissingPostLayoutData || editorState.postLayoutData().canEnableAutomaticSpellingCorrection); 3068 menuItem(item).state = TextChecker::state().isAutomaticSpellingCorrectionEnabled && enable ? NSControlStateValueOn : NSControlStateValueOff; 3069 return enable; 3069 3070 } 3070 3071 -
trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
r271187 r271459 165 165 postLayoutData.paragraphContextForCandidateRequest = contextRangeForCandidateRequest ? plainText(*contextRangeForCandidateRequest) : String(); 166 166 postLayoutData.stringForCandidateRequest = frame.editor().stringForCandidateRequest(); 167 postLayoutData.canEnableAutomaticSpellingCorrection = frame.editor().canEnableAutomaticSpellingCorrection(); 167 168 168 169 auto quads = RenderObject::absoluteTextQuads(*selectedRange); -
trunk/Tools/ChangeLog
r271455 r271459 1 2021-01-13 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] "Correct Spelling Automatically" menu items are inconsistent when autocorrect="off" 4 https://bugs.webkit.org/show_bug.cgi?id=220598 5 <rdar://problem/71713611> 6 7 Reviewed by Tim Horton. 8 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/mac/DisableAutomaticSpellingCorrection.mm: Added. 11 12 Add a new API test to verify that the `NSMenuItem` for toggling automatic spelling correction is invalid when 13 editing inside a form control with autocorrect="off". 14 15 * WebKitTestRunner/InjectedBundle/EventSendingController.cpp: 16 (WTR::getMenuItemEnabledCallback): 17 18 Add the readonly `enabled` JS property on context menu items. See the new layout test, 19 editing/mac/spelling/disable-automatic-spelling-correction-context-menu-item.html, for more information. 20 1 21 2021-01-13 Jonathan Bedard <jbedard@apple.com> 2 22 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r271414 r271459 1198 1198 F4D4F3B61E4E2BCB00BB2767 /* DragAndDropSimulatorIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D4F3B41E4E2BCB00BB2767 /* DragAndDropSimulatorIOS.mm */; }; 1199 1199 F4D4F3B91E4E36E400BB2767 /* DragAndDropTestsIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D4F3B71E4E36E400BB2767 /* DragAndDropTestsIOS.mm */; }; 1200 F4D5D69525AF8BE400205280 /* DisableAutomaticSpellingCorrection.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D5D69425AF8BE400205280 /* DisableAutomaticSpellingCorrection.mm */; }; 1200 1201 F4D5E4E81F0C5D38008C1A49 /* dragstart-clear-selection.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4D5E4E71F0C5D27008C1A49 /* dragstart-clear-selection.html */; }; 1201 1202 F4D65DA81F5E4704009D8C27 /* selected-text-image-link-and-editable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4D65DA71F5E46C0009D8C27 /* selected-text-image-link-and-editable.html */; }; … … 2968 2969 F4D4F3B41E4E2BCB00BB2767 /* DragAndDropSimulatorIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropSimulatorIOS.mm; sourceTree = "<group>"; }; 2969 2970 F4D4F3B71E4E36E400BB2767 /* DragAndDropTestsIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropTestsIOS.mm; sourceTree = "<group>"; }; 2971 F4D5D69425AF8BE400205280 /* DisableAutomaticSpellingCorrection.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DisableAutomaticSpellingCorrection.mm; sourceTree = "<group>"; }; 2970 2972 F4D5E4E71F0C5D27008C1A49 /* dragstart-clear-selection.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "dragstart-clear-selection.html"; sourceTree = "<group>"; }; 2971 2973 F4D65DA71F5E46C0009D8C27 /* selected-text-image-link-and-editable.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "selected-text-image-link-and-editable.html"; sourceTree = "<group>"; }; … … 4506 4508 E5AA8D1C25151CC60051CC45 /* DateInputTests.mm */, 4507 4509 939BA91614103412001A01BD /* DeviceScaleFactorOnBack.mm */, 4510 F4D5D69425AF8BE400205280 /* DisableAutomaticSpellingCorrection.mm */, 4508 4511 37E1064A1697676400B78BD0 /* DOMHTMLTableCellCellAbove.mm */, 4509 4512 2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */, … … 5195 5198 7CCE7EEA1A411AE600447C4C /* DidNotHandleKeyDown.cpp in Sources */, 5196 5199 AD57AC211DA7465B00FF1BDE /* DidRemoveFrameFromHiearchyInPageCache.cpp in Sources */, 5200 F4D5D69525AF8BE400205280 /* DisableAutomaticSpellingCorrection.mm in Sources */, 5201 F4B0168325AE060F00E445C4 /* DisableSpellcheck.mm in Sources */, 5197 5202 FEC2A85424CE975F00ADBC35 /* DisallowVMEntry.cpp in Sources */, 5198 5203 F4094CC725545BD5003D73E3 /* DisplayListTests.cpp in Sources */, … … 5521 5526 7CCE7ED01A411A7E00447C4C /* StringByEvaluatingJavaScriptFromString.mm in Sources */, 5522 5527 7CCE7ED11A411A7E00447C4C /* StringTruncator.mm in Sources */, 5523 F4B0168325AE060F00E445C4 /* DisableSpellcheck.mm in Sources */,5524 5528 ECA680CE1E68CC0900731D20 /* StringUtilities.mm in Sources */, 5525 5529 CE4D5DE71F6743BA0072CFC6 /* StringWithDirection.cpp in Sources */, … … 5705 5709 374B7A611DF371CF00ACCB6C /* BundleEditingDelegatePlugIn.mm in Sources */, 5706 5710 7A89BB682331643A0042CB1E /* BundleFormDelegatePlugIn.mm in Sources */, 5707 F4B0168425AE08F800E445C4 /* DisableSpellcheckPlugIn.mm in Sources */,5708 5711 A13EBBB01B87436F00097110 /* BundleParametersPlugIn.mm in Sources */, 5709 5712 37A709AF1E3EA97E00CA5969 /* BundleRangeHandlePlugIn.mm in Sources */, … … 5714 5717 5C121E8D2410704900486F9B /* ContentWorldPlugIn.mm in Sources */, 5715 5718 CEA7F57D2089624B0078EF6E /* DidResignInputElementStrongPasswordAppearance.mm in Sources */, 5719 F4B0168425AE08F800E445C4 /* DisableSpellcheckPlugIn.mm in Sources */, 5716 5720 518EE51920A78CE500E024F3 /* DoubleDefersLoadingPlugin.mm in Sources */, 5717 5721 5CB5B3C21FFC55CF00C27BB0 /* FrameHandleSerialization.mm in Sources */, -
trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp
r270582 r271459 68 68 } 69 69 70 static JSValueRef getMenuItemEnabledCallback(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) 71 { 72 auto* privateData = static_cast<MenuItemPrivateData*>(JSObjectGetPrivate(object)); 73 return JSValueMakeBoolean(context, WKContextMenuItemGetEnabled(privateData->m_item.get())); 74 } 75 70 76 static JSClassRef getMenuItemClass(); 71 77 … … 91 97 { "title", getMenuItemTitleCallback, 0, kJSPropertyAttributeReadOnly }, 92 98 { "children", getMenuItemChildrenCallback, 0, kJSPropertyAttributeReadOnly }, 99 { "enabled", getMenuItemEnabledCallback, 0, kJSPropertyAttributeReadOnly }, 93 100 { 0, 0, 0, 0 } 94 101 };
Note: See TracChangeset
for help on using the changeset viewer.