haikuwebkit/Tools/TestRunnerShared/spi/AppKitTestSPI.h

44 lines
1.7 KiB
C
Raw Permalink Normal View History

Picking an emoji via the emoji dialog (Ctrl+Cmd+Space) fires inconsistent beforeinput events. https://bugs.webkit.org/show_bug.cgi?id=170955 <rdar://problem/31697653> Reviewed by Ryosuke Niwa. Source/WebKit: Currently, we insert text with TextEventInputAutocompletion as the text event input type if any text range to replace was specified by the platform. Instead, limit this only to when the text replacement range is not empty. This more closely matches the intention of the spec, which states that the "insertReplacementText" inputType should be used when "[replacing] existing text by means of a spell checker, auto-correct or similar". * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::insertTextAsync): Source/WebKitLegacy/mac: Tweak -insertText: to pass TextEventInputAutocompletion to Editor::insertText when inserting text, if existing text is being replaced. * WebView/WebHTMLView.mm: (-[WebHTMLView insertText:]): Tools: Replace UIScriptController.insertText with UIScriptController.replaceTextAtRange, and implement replaceTextAtRange in WebKit1. See corresponding layout tests (input-event-insert-replacement.html and before-input-prevent-insert-replacement.html) for more detail. * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj: * DumpRenderTree/mac/AppKitTestSPI.h: Added. Introduce an SPI header for private AppKit headers needed to support DumpRenderTree. * DumpRenderTree/mac/UIScriptControllerMac.mm: (WTR::UIScriptController::replaceTextAtRange): (WTR::UIScriptController::insertText): Deleted. * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: * TestRunnerShared/UIScriptContext/UIScriptController.cpp: (WTR::UIScriptController::replaceTextAtRange): (WTR::UIScriptController::insertText): Deleted. * TestRunnerShared/UIScriptContext/UIScriptController.h: * WebKitTestRunner/mac/UIScriptControllerMac.mm: (WTR::UIScriptController::replaceTextAtRange): (WTR::UIScriptController::insertText): Deleted. Replace UIScriptController.insertText with UIScriptController.replaceTextAtRange, which better describes the behavior of this function. LayoutTests: Augments two existing layout tests to check for additional cases of inserting text with replacement ranges. Also enables this test for WebKit1 on Mac. Both these tests are currently enabled only for WebKit2, and also only check the case where we're replacing an existing non-empty range of text. * fast/events/before-input-prevent-insert-replacement-expected.txt: * fast/events/before-input-prevent-insert-replacement.html: * fast/events/input-event-insert-replacement-expected.txt: * fast/events/input-event-insert-replacement.html: Tests for cases of replacing existing text ranges, and inserting text at a position. * platform/mac-wk1/TestExpectations: * resources/ui-helper.js: Add a new UIHelper function to insert text at a given replacement range. This codepath is taken when selecting an emoji using the emoji picker menu on Mac, and also when selecting a dead key option after holding down on a vowel key. (window.UIHelper.replaceTextAtRange): Canonical link: https://commits.webkit.org/192681@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221234 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-28 05:12:56 +00:00
/*
* Copyright (C) 2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if PLATFORM(MAC)
Remove USE(INSERTION_UNDO_GROUPING) checks in macOS platform code https://bugs.webkit.org/show_bug.cgi?id=211525 Reviewed by Anders Carlsson. Source/WebCore: * editing/mac/TextUndoInsertionMarkupMac.h: Remove NSTextInputContext_Private.h usage. Moving to NSTextInputContextSPI.h instead. Also remove #pragma once since this is an Objective-C-only header, not for cross-platform use. * editing/mac/TextUndoInsertionMarkupMac.mm: Above, plus move NSUndoManager_Private.h to NSUndoManagerSPI.h. Source/WebCore/PAL: * PAL.xcodeproj/project.pbxproj: Added NSTextInputContextSPI.h and NSUndoManagerSPI.h. * pal/PlatformMac.cmake: Ditto. * pal/spi/mac/NSTextInputContextSPI.h: Added. * pal/spi/mac/NSUndoManagerSPI.h: Added. Source/WebKit: * UIProcess/Cocoa/WebViewImpl.mm: Use NSTextInputContextSPI.h. (WebKit::WebViewImpl::validAttributesForMarkedText): Removed USE(INSERTION_UNDO_GROUPING) from the macOS-specific code here. (WebKit::WebViewImpl::insertText): Ditto. * UIProcess/PageClient.h: Ditto. * UIProcess/ios/PageClientImplIOS.mm: (WebKit::PageClientImpl::registerInsertionUndoGrouping): Deleted. This function is not needed at all on iOS. * UIProcess/mac/PageClientImplMac.h: Removed USE(INSERTION_UNDO_GROUPING). * UIProcess/mac/PageClientImplMac.mm: (WebKit::PageClientImpl::registerInsertionUndoGrouping): Ditto. Source/WebKitLegacy/mac: * WebView/WebHTMLView.mm: Use NSTextInputContextSPI.h. (-[WebHTMLView validAttributesForMarkedText]): Removed USE(INSERTION_UNDO_GROUPING). (-[WebHTMLView insertText:]): Ditto. Tools: * DumpRenderTree/mac/TextInputControllerMac.m: Use NSTextInputContextSPI.h. (-[TextInputController stringWithUndoGroupingInsertion:]): Removed SUPPORT_INSERTION_UNDO_GROUPING. * DumpRenderTree/mac/UIScriptControllerMac.mm: Use NSTextInputContextSPI.h. * TestRunnerShared/spi/AppKitTestSPI.h: Removed NSTextInputContext_Private.h, clients can use NSTextInputContextSPI.h. * TestWebKitAPI/Tests/TestWebKitAPI/mac/AppKitSPI.h: Ditto. * TestWebKitAPI/Tests/mac/CandidateTests.mm: Use NSTextInputContextSPI.h. * TestWebKitAPI/Tests/mac/WKWebViewMacEditingTests.mm: Ditto. Canonical link: https://commits.webkit.org/224486@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261320 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-07 18:37:33 +00:00
#import <AppKit/NSDraggingItem.h>
Picking an emoji via the emoji dialog (Ctrl+Cmd+Space) fires inconsistent beforeinput events. https://bugs.webkit.org/show_bug.cgi?id=170955 <rdar://problem/31697653> Reviewed by Ryosuke Niwa. Source/WebKit: Currently, we insert text with TextEventInputAutocompletion as the text event input type if any text range to replace was specified by the platform. Instead, limit this only to when the text replacement range is not empty. This more closely matches the intention of the spec, which states that the "insertReplacementText" inputType should be used when "[replacing] existing text by means of a spell checker, auto-correct or similar". * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::insertTextAsync): Source/WebKitLegacy/mac: Tweak -insertText: to pass TextEventInputAutocompletion to Editor::insertText when inserting text, if existing text is being replaced. * WebView/WebHTMLView.mm: (-[WebHTMLView insertText:]): Tools: Replace UIScriptController.insertText with UIScriptController.replaceTextAtRange, and implement replaceTextAtRange in WebKit1. See corresponding layout tests (input-event-insert-replacement.html and before-input-prevent-insert-replacement.html) for more detail. * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj: * DumpRenderTree/mac/AppKitTestSPI.h: Added. Introduce an SPI header for private AppKit headers needed to support DumpRenderTree. * DumpRenderTree/mac/UIScriptControllerMac.mm: (WTR::UIScriptController::replaceTextAtRange): (WTR::UIScriptController::insertText): Deleted. * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: * TestRunnerShared/UIScriptContext/UIScriptController.cpp: (WTR::UIScriptController::replaceTextAtRange): (WTR::UIScriptController::insertText): Deleted. * TestRunnerShared/UIScriptContext/UIScriptController.h: * WebKitTestRunner/mac/UIScriptControllerMac.mm: (WTR::UIScriptController::replaceTextAtRange): (WTR::UIScriptController::insertText): Deleted. Replace UIScriptController.insertText with UIScriptController.replaceTextAtRange, which better describes the behavior of this function. LayoutTests: Augments two existing layout tests to check for additional cases of inserting text with replacement ranges. Also enables this test for WebKit1 on Mac. Both these tests are currently enabled only for WebKit2, and also only check the case where we're replacing an existing non-empty range of text. * fast/events/before-input-prevent-insert-replacement-expected.txt: * fast/events/before-input-prevent-insert-replacement.html: * fast/events/input-event-insert-replacement-expected.txt: * fast/events/input-event-insert-replacement.html: Tests for cases of replacing existing text ranges, and inserting text at a position. * platform/mac-wk1/TestExpectations: * resources/ui-helper.js: Add a new UIHelper function to insert text at a given replacement range. This codepath is taken when selecting an emoji using the emoji picker menu on Mac, and also when selecting a dead key option after holding down on a vowel key. (window.UIHelper.replaceTextAtRange): Canonical link: https://commits.webkit.org/192681@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221234 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-28 05:12:56 +00:00
Remove USE(INSERTION_UNDO_GROUPING) checks in macOS platform code https://bugs.webkit.org/show_bug.cgi?id=211525 Reviewed by Anders Carlsson. Source/WebCore: * editing/mac/TextUndoInsertionMarkupMac.h: Remove NSTextInputContext_Private.h usage. Moving to NSTextInputContextSPI.h instead. Also remove #pragma once since this is an Objective-C-only header, not for cross-platform use. * editing/mac/TextUndoInsertionMarkupMac.mm: Above, plus move NSUndoManager_Private.h to NSUndoManagerSPI.h. Source/WebCore/PAL: * PAL.xcodeproj/project.pbxproj: Added NSTextInputContextSPI.h and NSUndoManagerSPI.h. * pal/PlatformMac.cmake: Ditto. * pal/spi/mac/NSTextInputContextSPI.h: Added. * pal/spi/mac/NSUndoManagerSPI.h: Added. Source/WebKit: * UIProcess/Cocoa/WebViewImpl.mm: Use NSTextInputContextSPI.h. (WebKit::WebViewImpl::validAttributesForMarkedText): Removed USE(INSERTION_UNDO_GROUPING) from the macOS-specific code here. (WebKit::WebViewImpl::insertText): Ditto. * UIProcess/PageClient.h: Ditto. * UIProcess/ios/PageClientImplIOS.mm: (WebKit::PageClientImpl::registerInsertionUndoGrouping): Deleted. This function is not needed at all on iOS. * UIProcess/mac/PageClientImplMac.h: Removed USE(INSERTION_UNDO_GROUPING). * UIProcess/mac/PageClientImplMac.mm: (WebKit::PageClientImpl::registerInsertionUndoGrouping): Ditto. Source/WebKitLegacy/mac: * WebView/WebHTMLView.mm: Use NSTextInputContextSPI.h. (-[WebHTMLView validAttributesForMarkedText]): Removed USE(INSERTION_UNDO_GROUPING). (-[WebHTMLView insertText:]): Ditto. Tools: * DumpRenderTree/mac/TextInputControllerMac.m: Use NSTextInputContextSPI.h. (-[TextInputController stringWithUndoGroupingInsertion:]): Removed SUPPORT_INSERTION_UNDO_GROUPING. * DumpRenderTree/mac/UIScriptControllerMac.mm: Use NSTextInputContextSPI.h. * TestRunnerShared/spi/AppKitTestSPI.h: Removed NSTextInputContext_Private.h, clients can use NSTextInputContextSPI.h. * TestWebKitAPI/Tests/TestWebKitAPI/mac/AppKitSPI.h: Ditto. * TestWebKitAPI/Tests/mac/CandidateTests.mm: Use NSTextInputContextSPI.h. * TestWebKitAPI/Tests/mac/WKWebViewMacEditingTests.mm: Ditto. Canonical link: https://commits.webkit.org/224486@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261320 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-07 18:37:33 +00:00
// FIXME: Move this to PlatformHave.h.
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
#define HAVE_NSDRAGGINGITEM_INITWITHITEM 1
#endif
@interface NSDraggingItem ()
#if HAVE(NSDRAGGINGITEM_INITWITHITEM)
- (instancetype)_initWithItem:(id)item;
#else
- (void)setItem:(id)item;
#endif
@end
Picking an emoji via the emoji dialog (Ctrl+Cmd+Space) fires inconsistent beforeinput events. https://bugs.webkit.org/show_bug.cgi?id=170955 <rdar://problem/31697653> Reviewed by Ryosuke Niwa. Source/WebKit: Currently, we insert text with TextEventInputAutocompletion as the text event input type if any text range to replace was specified by the platform. Instead, limit this only to when the text replacement range is not empty. This more closely matches the intention of the spec, which states that the "insertReplacementText" inputType should be used when "[replacing] existing text by means of a spell checker, auto-correct or similar". * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::insertTextAsync): Source/WebKitLegacy/mac: Tweak -insertText: to pass TextEventInputAutocompletion to Editor::insertText when inserting text, if existing text is being replaced. * WebView/WebHTMLView.mm: (-[WebHTMLView insertText:]): Tools: Replace UIScriptController.insertText with UIScriptController.replaceTextAtRange, and implement replaceTextAtRange in WebKit1. See corresponding layout tests (input-event-insert-replacement.html and before-input-prevent-insert-replacement.html) for more detail. * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj: * DumpRenderTree/mac/AppKitTestSPI.h: Added. Introduce an SPI header for private AppKit headers needed to support DumpRenderTree. * DumpRenderTree/mac/UIScriptControllerMac.mm: (WTR::UIScriptController::replaceTextAtRange): (WTR::UIScriptController::insertText): Deleted. * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: * TestRunnerShared/UIScriptContext/UIScriptController.cpp: (WTR::UIScriptController::replaceTextAtRange): (WTR::UIScriptController::insertText): Deleted. * TestRunnerShared/UIScriptContext/UIScriptController.h: * WebKitTestRunner/mac/UIScriptControllerMac.mm: (WTR::UIScriptController::replaceTextAtRange): (WTR::UIScriptController::insertText): Deleted. Replace UIScriptController.insertText with UIScriptController.replaceTextAtRange, which better describes the behavior of this function. LayoutTests: Augments two existing layout tests to check for additional cases of inserting text with replacement ranges. Also enables this test for WebKit1 on Mac. Both these tests are currently enabled only for WebKit2, and also only check the case where we're replacing an existing non-empty range of text. * fast/events/before-input-prevent-insert-replacement-expected.txt: * fast/events/before-input-prevent-insert-replacement.html: * fast/events/input-event-insert-replacement-expected.txt: * fast/events/input-event-insert-replacement.html: Tests for cases of replacing existing text ranges, and inserting text at a position. * platform/mac-wk1/TestExpectations: * resources/ui-helper.js: Add a new UIHelper function to insert text at a given replacement range. This codepath is taken when selecting an emoji using the emoji picker menu on Mac, and also when selecting a dead key option after holding down on a vowel key. (window.UIHelper.replaceTextAtRange): Canonical link: https://commits.webkit.org/192681@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221234 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-28 05:12:56 +00:00
#endif // PLATFORM(MAC)