haikuwebkit/Tools/TestWebKitAPI/EditingTestHarness.mm

233 lines
6.7 KiB
Plaintext
Raw Permalink Normal View History

[iOS WK2] WKWebView schedules nonstop layout after pressing cmb+b,i,u inside a contenteditable div https://bugs.webkit.org/show_bug.cgi?id=175116 <rdar://problem/28279301> Reviewed by Darin Adler and Ryosuke Niwa. Source/WebCore: WebCore support for WebPage::editorState refactoring. See WebKit ChangeLogs for more detail. Tests: EditorStateTests.TypingAttributesBold EditorStateTests.TypingAttributesItalic EditorStateTests.TypingAttributesUnderline EditorStateTests.TypingAttributesTextAlignmentAbsoluteAlignmentOptions EditorStateTests.TypingAttributesTextAlignmentStartEnd EditorStateTests.TypingAttributesTextAlignmentDirectionalText EditorStateTests.TypingAttributesTextColor EditorStateTests.TypingAttributesMixedStyles EditorStateTests.TypingAttributesLinkColor * css/StyleProperties.cpp: (WebCore::StyleProperties::propertyAsColor const): (WebCore::StyleProperties::propertyAsValueID const): Introduces some helper functions in StyleProperties to convert CSS property values to Color or a CSSValueID. * css/StyleProperties.h: * editing/EditingStyle.cpp: (WebCore::EditingStyle::hasStyle): Pull out logic in selectionStartHasStyle that asks for a style TriState into EditingStyle::hasStyle. This is because WebPage::editorState will now query for multiple styles at the selection start, but selectionStartHasStyle currently recomputes styleAtSelectionStart every time it is called. To prevent extra work from being done, we can just call selectionStartHasStyle once and use ask for EditingStyle::hasStyle on the computed EditingStyle at selection start. * editing/EditingStyle.h: * editing/Editor.cpp: (WebCore::Editor::selectionStartHasStyle const): Source/WebKit: Refactors WebPage::editorState to only use the StyleProperties derived from EditingStyle, instead of inserting and removing a temporary node to figure out the style. Also adds hooks to notify the UI delegate of EditorState changes. * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: * UIProcess/API/Cocoa/WKWebView.mm: (nsTextAlignment): (dictionaryRepresentationForEditorState): (-[WKWebView _didChangeEditorState]): Alerts the private UI delegate of UI-side EditorState updates. (-[WKWebView _web_editorStateDidChange]): (-[WKWebView _executeEditCommand:argument:completion:]): * UIProcess/API/Cocoa/WKWebViewInternal.h: * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/API/mac/WKView.mm: (-[WKView _web_editorStateDidChange]): * UIProcess/Cocoa/WebViewImpl.h: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::selectionDidChange): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::executeEditCommand): Change executeEditCommand(name, callback) to executeEditCommand(name, argument, callback) and lift out of iOS platform code and into WebPage.cpp. * UIProcess/WebPageProxy.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView executeEditCommandWithCallback:]): (-[WKContentView _selectionChanged]): * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::executeEditCommand): Deleted. Move the iOS-specific implementation of executeEditCommand that invokes a callback when the web process responds out of WebPageProxyIOS, and into cross-platform WebPageProxy code. Additionally, add a parameter for the edit command's argument. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::editorState const): Use EditingStyle::styleAtSelectionStart instead of Editor::styleForSelectionStart when computing an EditorState. Tweak bold, italic and underline to use EditingStyle TriStates. (WebKit::WebPage::executeEditCommandWithCallback): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::executeEditCommandWithCallback): Deleted. Tools: Introduces new testing infrastructure and API tests to test EditorState updates in the UI process. The new EditorStateTests run on both iOS and Mac. * TestWebKitAPI/EditingTestHarness.h: Added. * TestWebKitAPI/EditingTestHarness.mm: Added. EditingTestHarness is a helper object that API tests may use to apply editing commands and store EditorState history. This test harness adds sugaring around various editing commands, and simplifies the process of checking the state of the latest observed EditorState. (-[EditingTestHarness initWithWebView:]): (-[EditingTestHarness dealloc]): (-[EditingTestHarness webView]): (-[EditingTestHarness latestEditorState]): (-[EditingTestHarness editorStateHistory]): (-[EditingTestHarness insertText:andExpectEditorStateWith:]): (-[EditingTestHarness insertHTML:andExpectEditorStateWith:]): (-[EditingTestHarness selectAllAndExpectEditorStateWith:]): (-[EditingTestHarness moveBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness moveWordBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness toggleBold]): (-[EditingTestHarness toggleItalic]): (-[EditingTestHarness toggleUnderline]): (-[EditingTestHarness setForegroundColor:]): (-[EditingTestHarness alignJustifiedAndExpectEditorStateWith:]): (-[EditingTestHarness alignLeftAndExpectEditorStateWith:]): (-[EditingTestHarness alignCenterAndExpectEditorStateWith:]): (-[EditingTestHarness alignRightAndExpectEditorStateWith:]): (-[EditingTestHarness insertParagraphAndExpectEditorStateWith:]): (-[EditingTestHarness deleteBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness _execCommand:argument:expectEntries:]): Dispatches an editing command to the web process, and blocks until a response is received. If an expected entries dictionary is given, this will additionally verify that the latest EditorState contains all the expected keys and values. (-[EditingTestHarness latestEditorStateContains:]): (-[EditingTestHarness _webView:editorStateDidChange:]): * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit2Cocoa/EditorStateTests.mm: Added. (TestWebKitAPI::setUpEditorStateTestHarness): (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKit2Cocoa/editor-state-test-harness.html: Added. LayoutTests: * platform/ios-wk2/editing/style/unbold-in-bold-expected.txt: * platform/mac-wk2/editing/style/unbold-in-bold-expected.txt: Rebaseline a WK2 LayoutTest expectations. This test currently expects an empty anonymous RenderBlock to be inserted into the render tree, but this is only a result of us adding and removing a temporary <span> when computing a RenderStyle in WebPage::editorState -- this patch removes these empty RenderBlocks, making these expectations' RenderTrees consistent with WebKit1. Canonical link: https://commits.webkit.org/192520@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221065 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-23 03:16:55 +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.
*/
Use #import instead of #include in Objective-C and don't use #pragma once https://bugs.webkit.org/show_bug.cgi?id=210724 Reviewed by David Kilzer. Source/JavaScriptCore: * API/JSAPIWrapperObject.mm: * API/JSContext.h: * API/JSContext.mm: * API/JSScriptInternal.h: * API/JSValue.mm: * API/JSVirtualMachine.mm: * API/JSVirtualMachinePrivate.h: * API/JSWrapperMap.mm: * API/ObjCCallbackFunction.mm: * API/tests/CurrentThisInsideBlockGetterTest.mm: More #import, less #pragma once. Source/WebCore: * page/cocoa/SettingsBaseCocoa.mm: (WebCore::sansSerifTraditionalHanFontFamily): Deleted. (WebCore::sansSerifSimplifiedHanFontFamily): Deleted. (WebCore::SettingsBase::initializeDefaultFontFamilies): Just use font name strings directly since there are no conditionals any more. * Modules/applepay/PaymentRequestValidator.mm: * Modules/applepay/cocoa/PaymentContactCocoa.mm: * accessibility/ios/WebAccessibilityObjectWrapperIOS.h: * accessibility/mac/AXObjectCacheMac.mm: * accessibility/mac/WebAccessibilityObjectWrapperBase.h: * accessibility/mac/WebAccessibilityObjectWrapperMac.h: * bridge/objc/WebScriptObjectPrivate.h: * bridge/objc/objc_class.mm: * bridge/testbindings.mm: * crypto/mac/SerializedCryptoKeyWrapMac.mm: * editing/cocoa/WebArchiveResourceFromNSAttributedString.h: * editing/cocoa/WebArchiveResourceWebResourceHandler.h: * editing/cocoa/WebContentReaderCocoa.mm: * history/mac/HistoryItemMac.mm: * loader/cocoa/DiskCacheMonitorCocoa.mm: * loader/cocoa/SubresourceLoaderCocoa.mm: * loader/mac/ResourceLoaderMac.mm: * page/cocoa/MemoryReleaseCocoa.mm: * page/cocoa/ResourceUsageOverlayCocoa.mm: * page/cocoa/ResourceUsageThreadCocoa.mm: * page/ios/WebEventRegion.h: * page/mac/ChromeMac.mm: * page/mac/EventHandlerMac.mm: * page/mac/WheelEventDeltaFilterMac.mm: * page/scrolling/cocoa/ScrollingStateNode.mm: * page/scrolling/mac/ScrollingCoordinatorMac.mm: * page/scrolling/mac/ScrollingMomentumCalculatorMac.mm: * page/scrolling/mac/ScrollingStateScrollingNodeMac.mm: * page/scrolling/mac/ScrollingThreadMac.mm: * page/scrolling/mac/ScrollingTreeMac.mm: * platform/audio/cocoa/MediaSessionManagerCocoa.mm: * platform/audio/mac/AudioSampleDataSource.mm: * platform/cocoa/DataDetectorsCoreSoftLink.mm: * platform/cocoa/PasteboardCocoa.mm: * platform/cocoa/ScrollSnapAnimatorState.mm: * platform/cocoa/SystemVersion.mm: * platform/gamepad/cocoa/GameControllerGamepad.mm: * platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.mm: * platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm: * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm: * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm: * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm: * platform/graphics/ca/cocoa/WebSystemBackdropLayer.h: * platform/graphics/ca/cocoa/WebTiledBackingLayer.h: * platform/graphics/ca/cocoa/WebVideoContainerLayer.h: * platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm: * platform/graphics/cocoa/IOSurfacePoolCocoa.mm: * platform/graphics/cocoa/TextTrackRepresentationCocoa.mm: * platform/graphics/cocoa/WebGLLayer.h: * platform/graphics/cocoa/WebGLLayer.mm: * platform/graphics/cocoa/WebGPULayer.h: * platform/graphics/cocoa/WebGPULayer.mm: * platform/graphics/cv/ImageRotationSessionVT.mm: * platform/graphics/cv/ImageTransferSessionVT.mm: * platform/graphics/cv/TextureCacheCV.mm: * platform/graphics/gpu/cocoa/GPUBufferMetal.mm: * platform/graphics/gpu/cocoa/GPUComputePassEncoderMetal.mm: * platform/graphics/mac/ComplexTextControllerCoreText.mm: * platform/graphics/mac/FloatPointMac.mm: * platform/graphics/mac/FloatSizeMac.mm: * platform/graphics/mac/IntPointMac.mm: * platform/graphics/mac/IntSizeMac.mm: * platform/graphics/mac/WebLayer.h: * platform/graphics/mac/WebLayer.mm: * platform/ios/LegacyTileCache.mm: * platform/ios/LegacyTileGrid.mm: * platform/ios/LegacyTileGridTile.mm: * platform/ios/LegacyTileLayer.h: * platform/ios/LegacyTileLayer.mm: * platform/ios/LegacyTileLayerPool.mm: * platform/ios/LocalCurrentTraitCollection.mm: * platform/ios/LocalizedDeviceModel.mm: * platform/ios/ScrollbarThemeIOS.mm: * platform/ios/WebCoreMotionManager.h: * platform/ios/WebItemProviderPasteboard.mm: * platform/ios/WebVideoFullscreenControllerAVKit.h: * platform/mac/LocalCurrentGraphicsContext.mm: * platform/mac/LocalDefaultSystemAppearance.mm: * platform/mac/LoggingMac.mm: * platform/mac/PlatformEventFactoryMac.mm: * platform/mac/RemoteCommandListenerMac.mm: * platform/mac/ScrollAnimatorMac.mm: * platform/mac/SerializedPlatformDataCueMac.mm: * platform/mac/WebCoreFullScreenPlaceholderView.mm: * platform/mac/WebCoreFullScreenWarningView.h: * platform/mac/WebCoreFullScreenWarningView.mm: * platform/mac/WebCoreFullScreenWindow.h: * platform/mac/WebCoreObjCExtras.mm: * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm: * platform/mediasession/mac/MediaSessionInterruptionProviderMac.mm: * platform/mediastream/ios/AVAudioSessionCaptureDevice.mm: * platform/mediastream/ios/CoreAudioCaptureSourceIOS.mm: * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm: * platform/mediastream/mac/RealtimeMediaSourceCenterMac.mm: * platform/mediastream/mac/RealtimeVideoUtilities.mm: * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm: * platform/network/cocoa/CertificateInfoCocoa.mm: * platform/network/cocoa/WebCoreNSURLSession.h: * platform/network/mac/BlobDataFileReferenceMac.mm: * platform/network/mac/CredentialStorageMac.mm: * platform/network/mac/SynchronousLoaderClient.mm: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/text/cocoa/LocaleCocoa.mm: * testing/ServiceWorkerInternals.mm: * testing/cocoa/WebViewVisualIdentificationOverlay.h: More #import, less #pragma once. Source/WebCore/PAL: * pal/cocoa/AppSSOSoftLink.mm: * pal/cocoa/FileSizeFormatterCocoa.mm: * pal/cocoa/UsageTrackingSoftLink.mm: * pal/ios/ManagedConfigurationSoftLink.mm: * pal/ios/UIKitSoftLink.mm: * pal/mac/LookupSoftLink.mm: * pal/spi/cocoa/AVFoundationSPI.h: * pal/spi/cocoa/AccessibilitySupportSoftLink.cpp: * pal/spi/cocoa/AppSSOSPI.h: * pal/spi/cocoa/AuthKitSPI.h: * pal/spi/cocoa/DataDetectorsCoreSPI.h: * pal/spi/cocoa/LaunchServicesSPI.h: * pal/spi/cocoa/NSAccessibilitySPI.h: * pal/spi/cocoa/NSAttributedStringSPI.h: * pal/spi/cocoa/NSProgressSPI.h: * pal/spi/cocoa/NSURLDownloadSPI.h: * pal/spi/cocoa/NSUserDefaultsSPI.h: * pal/spi/cocoa/NSXPCConnectionSPI.h: * pal/spi/cocoa/PassKitSPI.h: * pal/spi/cocoa/SecKeyProxySPI.h: * pal/spi/ios/CelestialSPI.h: * pal/spi/mac/DataDetectorsSPI.h: * pal/spi/mac/NSColorWellSPI.h: * pal/spi/mac/NSGraphicsSPI.h: * pal/spi/mac/NSPopoverColorWellSPI.h: * pal/spi/mac/NSScrollerImpSPI.h: More #import, less #pragma once. Source/WebKit: * mac/MigrateHeadersFromWebKitLegacy.make: Delete stale MemoryMeasure.h forwarding header from incremental WebKit builds and ignore when generating new forwarding headers. * Platform/foundation/LoggingFoundation.mm: (WebKit::logLevelString): Use string directly instead of a named constant. * UIProcess/mac/WebColorPickerMac.h: Mark class final. * GPUProcess/webrtc/LibWebRTCCodecsProxy.mm: * NetworkProcess/WebStorage/ios/LocalStorageDatabaseTrackerIOS.mm: * NetworkProcess/cache/NetworkCacheDataCocoa.mm: * NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm: * NetworkProcess/cocoa/NetworkActivityTrackerCocoa.mm: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: * NetworkProcess/webrtc/NetworkRTCProvider.mm: * Platform/spi/Cocoa/DeviceManagementSPI.h: * Platform/spi/Cocoa/LocalAuthenticationSPI.h: * Platform/spi/Cocoa/NearFieldSPI.h: * Platform/spi/Cocoa/SafeBrowsingSPI.h: * Platform/spi/mac/AppKitSPI.h: * Shared/API/Cocoa/RemoteObjectInvocation.mm: * Shared/API/Cocoa/WKMain.mm: * Shared/APIWebArchive.mm: * Shared/APIWebArchiveResource.mm: * Shared/Authentication/cocoa/AuthenticationChallengeDispositionCocoa.mm: * Shared/Cocoa/LoadParametersCocoa.mm: * Shared/Cocoa/SandboxInitialiationParametersCocoa.mm: * Shared/Cocoa/WKNSData.mm: * Shared/DocumentEditingContext.mm: * Shared/Plugins/mac/PluginSandboxProfile.mm: * Shared/RemoteLayerTree/WKAnimationDelegate.h: * Shared/UserInterfaceIdiom.mm: * Shared/ios/WebIconUtilities.mm: * Shared/mac/CodeSigning.mm: * Shared/mac/ColorSpaceData.mm: * Shared/mac/HangDetectionDisablerMac.mm: * Shared/mac/PDFKitImports.mm: * UIProcess/API/Cocoa/APIContentRuleListStoreCocoa.mm: * UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm: * UIProcess/API/Cocoa/APISerializedScriptValueCocoa.mm: * UIProcess/API/Cocoa/WKContentRuleList.mm: * UIProcess/API/Cocoa/WKMenuItemIdentifiers.mm: * UIProcess/API/Cocoa/WKNavigationActionPrivate.h: * UIProcess/API/Cocoa/WKPreviewActionItemIdentifiers.mm: * UIProcess/API/Cocoa/WKWebViewInternal.h: * UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h: * UIProcess/API/Cocoa/_WKApplicationManifest.h: * UIProcess/API/Cocoa/_WKAttachment.h: * UIProcess/API/Cocoa/_WKResourceLoadInfoInternal.h: * UIProcess/API/Cocoa/_WKResourceLoadStatisticsFirstPartyInternal.h: * UIProcess/API/Cocoa/_WKResourceLoadStatisticsThirdPartyInternal.h: * UIProcess/API/Cocoa/_WKTextManipulationExclusionRule.mm: * UIProcess/API/Cocoa/_WKUserContentFilter.mm: * UIProcess/API/Cocoa/_WKWebAuthenticationAssertionResponseInternal.h: * UIProcess/API/Cocoa/_WKWebAuthenticationPanelInternal.h: * UIProcess/API/Cocoa/_WKWebsiteDataStoreDelegate.h: * UIProcess/Authentication/mac/WebCredentialMac.mm: * UIProcess/Automation/cocoa/WebAutomationSessionCocoa.mm: * UIProcess/Cocoa/IconLoadingDelegate.mm: * UIProcess/Cocoa/MediaUtilities.mm: * UIProcess/Cocoa/PreferenceObserver.h: * UIProcess/Cocoa/PreferenceObserver.mm: * UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm: * UIProcess/Cocoa/SOAuthorization/SOAuthorizationNSURLExtras.h: * UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.mm: * UIProcess/Cocoa/SOAuthorization/WKSOAuthorizationDelegate.h: * UIProcess/Cocoa/WKEditCommand.h: * UIProcess/Cocoa/WKFullKeyboardAccessWatcher.h: * UIProcess/Cocoa/WebPageProxyCocoa.mm: * UIProcess/Gamepad/cocoa/UIGamepadProviderCocoa.mm: * UIProcess/Inspector/mac/WKInspectorViewController.h: * UIProcess/Inspector/mac/WKInspectorWKWebView.h: * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.h: * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h: * UIProcess/RemoteLayerTree/mac/ScrollerMac.mm: * UIProcess/RemoteLayerTree/mac/ScrollerPairMac.mm: * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm: * UIProcess/WebAuthentication/Cocoa/WKNFReaderSessionDelegate.h: * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: * UIProcess/ios/WKDeferringGestureRecognizer.h: * UIProcess/ios/WKHighlightLongPressGestureRecognizer.h: * UIProcess/ios/WebDataListSuggestionsDropdownIOS.h: * UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm: * UIProcess/ios/forms/WKDatePickerViewController.h: * UIProcess/ios/forms/WKDatePickerViewController.mm: * UIProcess/ios/forms/WKFocusedFormControlView.h: * UIProcess/ios/forms/WKFocusedFormControlView.mm: * UIProcess/ios/forms/WKFormColorPicker.mm: * UIProcess/ios/forms/WKNumberPadViewController.h: * UIProcess/ios/forms/WKNumberPadViewController.mm: * UIProcess/ios/forms/WKQuickboardListViewController.h: * UIProcess/ios/forms/WKQuickboardListViewController.mm: * UIProcess/ios/forms/WKSelectMenuListViewController.h: * UIProcess/ios/forms/WKTimePickerViewController.h: * UIProcess/ios/forms/WKTimePickerViewController.mm: * UIProcess/ios/fullscreen/WKFullScreenViewController.h: * UIProcess/ios/fullscreen/WKFullscreenStackView.h: * UIProcess/ios/fullscreen/WKFullscreenStackView.mm: * UIProcess/mac/PageClientImplMac.mm: * UIProcess/mac/WKSharingServicePickerDelegate.h: * WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm: * WebProcess/GPU/media/cocoa/VideoLayerRemoteCocoa.h: * WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.mm: * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm: * WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm: * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp: * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteCustom.mm: * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteTiledBacking.cpp: * WebProcess/WebPage/WKAccessibilityWebPageObjectIOS.h: * WebProcess/WebPage/mac/PageBannerMac.mm: * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.h: * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.h: * WebProcess/cocoa/WebProcessCocoa.mm: More #import, less #pragma once. Source/WebKitLegacy: * WebKitLegacy.xcodeproj/project.pbxproj: Removed MemoryMeasure.h/mm. Source/WebKitLegacy/ios: * Misc/MemoryMeasure.h: Removed. * Misc/MemoryMeasure.mm: Removed. * WebKit.iOS.exp: Removed MemoryMeasure symbols. Source/WebKitLegacy/mac: * Configurations/WebKitLegacy.xcconfig: Removed MemoryMeasure.h from EXCLUDED_SOURCE_FILE_NAMES. * Misc/WebCache.mm: (+[WebCache emptyInMemoryResources]): Removed invocation of MemoryMeasure. This is no longer used for anything. * History/BackForwardList.mm: * Plugins/Hosted/ProxyRuntimeObject.mm: * Plugins/Hosted/WebHostedNetscapePluginView.mm: * WebCoreSupport/SearchPopupMenuMac.mm: * WebCoreSupport/WebAlternativeTextClient.mm: * WebCoreSupport/WebSecurityOriginInternal.h: * WebInspector/WebInspector.mm: * WebView/WebFramePrivate.h: * WebView/WebScriptWorld.h: * WebView/WebView.mm: More #import, less #pragma once. Source/WTF: * wtf/cocoa/Entitlements.mm: * wtf/cocoa/FileSystemCocoa.mm: * wtf/cocoa/MainThreadCocoa.mm: * wtf/cocoa/SystemTracingCocoa.cpp: * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: * wtf/mac/SchedulePairMac.mm: * wtf/text/cocoa/StringCocoa.mm: * wtf/text/cocoa/TextStreamCocoa.mm: More #import. Tools: * DumpRenderTree/TestNetscapePlugIn/PluginObjectMac.mm: * DumpRenderTree/ios/DumpRenderTreeAppMain.mm: * DumpRenderTree/mac/AccessibilityCommonMac.h: * DumpRenderTree/mac/DumpRenderTreeMain.mm: * TestRunnerShared/cocoa/ClassMethodSwizzler.mm: * TestRunnerShared/cocoa/InstanceMethodSwizzler.mm: * TestRunnerShared/cocoa/LayoutTestSpellChecker.h: * TestRunnerShared/mac/NSPasteboardAdditions.h: * TestRunnerShared/spi/AppKitTestSPI.h: * TestRunnerShared/spi/PencilKitTestSPI.h: * TestWebKitAPI/DataDetectorsCoreSPI.h: * TestWebKitAPI/EditingTestHarness.h: * TestWebKitAPI/EditingTestHarness.mm: * TestWebKitAPI/Tests/WTF/ns/RetainPtr.mm: * TestWebKitAPI/Tests/WebCore/LineBreaking.mm: * TestWebKitAPI/Tests/WebCore/cocoa/AVFoundationSoftLinkTest.mm: * TestWebKitAPI/Tests/WebCore/cocoa/DatabaseTrackerTest.mm: * TestWebKitAPI/Tests/WebKit/AGXCompilerService.mm: * TestWebKitAPI/Tests/WebKit/AccessibilityRemoteUIApp.mm: * TestWebKitAPI/Tests/WebKit/BacklightLevelNotification.mm: * TestWebKitAPI/Tests/WebKit/Battery.mm: * TestWebKitAPI/Tests/WebKit/DeferredViewInWindowStateChange.mm: * TestWebKitAPI/Tests/WebKit/EnableAccessibility.mm: * TestWebKitAPI/Tests/WebKit/FindMatches.mm: * TestWebKitAPI/Tests/WebKit/GrantAccessToMobileAssets.mm: * TestWebKitAPI/Tests/WebKit/GrantAccessToPreferencesService.mm: * TestWebKitAPI/Tests/WebKit/LocalizedDeviceModel.mm: * TestWebKitAPI/Tests/WebKit/MimeTypes.mm: * TestWebKitAPI/Tests/WebKit/NoHistoryItemScrollToFragment.mm: * TestWebKitAPI/Tests/WebKit/PasteboardNotifications.mm: * TestWebKitAPI/Tests/WebKit/PictureInPictureSupport.mm: * TestWebKitAPI/Tests/WebKit/PreferenceChanges.mm: * TestWebKitAPI/Tests/WebKit/SleepDisabler.mm: * TestWebKitAPI/Tests/WebKit/ViewportSizeForViewportUnits.mm: * TestWebKitAPI/Tests/WebKit/WKThumbnailView.mm: * TestWebKitAPI/Tests/WebKit/WebFilter.mm: * TestWebKitAPI/Tests/WebKit/mac/AttributedSubstringForProposedRangeWithImage.mm: * TestWebKitAPI/Tests/WebKit/mac/ContextMenuDownload.mm: * TestWebKitAPI/Tests/WebKit/mac/CustomBundleObject.h: * TestWebKitAPI/Tests/WebKit/mac/CustomBundleParameter.mm: * TestWebKitAPI/Tests/WebKit/mac/CustomBundleParameter_Bundle.mm: * TestWebKitAPI/Tests/WebKit/mac/EditorCommands.mm: * TestWebKitAPI/Tests/WebKit/mac/ForceLightAppearanceInBundle.mm: * TestWebKitAPI/Tests/WebKit/mac/ForceLightAppearanceInBundle_Bundle.mm: * TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm: * TestWebKitAPI/Tests/WebKitCocoa/AutoLayoutIntegration.mm: * TestWebKitAPI/Tests/WebKitCocoa/CloseWebViewAfterEnterFullscreen.mm: * TestWebKitAPI/Tests/WebKitCocoa/CloseWebViewDuringEnterFullscreen.mm: * TestWebKitAPI/Tests/WebKitCocoa/CookieAcceptPolicy.mm: * TestWebKitAPI/Tests/WebKitCocoa/CookiePrivateBrowsing.mm: * TestWebKitAPI/Tests/WebKitCocoa/CopyHTML.mm: * TestWebKitAPI/Tests/WebKitCocoa/CopyRTF.mm: * TestWebKitAPI/Tests/WebKitCocoa/CopyURL.mm: * TestWebKitAPI/Tests/WebKitCocoa/CustomUserAgent.mm: * TestWebKitAPI/Tests/WebKitCocoa/DataDetection.mm: * TestWebKitAPI/Tests/WebKitCocoa/DecidePolicyForNavigationAction.mm: * TestWebKitAPI/Tests/WebKitCocoa/DeviceManagementRestrictions.mm: * TestWebKitAPI/Tests/WebKitCocoa/DoAfterNextPresentationUpdateAfterCrash.mm: * TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm: * TestWebKitAPI/Tests/WebKitCocoa/ExitFullscreenOnEnterPiP.mm: * TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm: * TestWebKitAPI/Tests/WebKitCocoa/FindInPageAPI.mm: * TestWebKitAPI/Tests/WebKitCocoa/FirstVisuallyNonEmptyMilestone.mm: * TestWebKitAPI/Tests/WebKitCocoa/FixedLayoutSize.mm: * TestWebKitAPI/Tests/WebKitCocoa/FullscreenAlert.mm: * TestWebKitAPI/Tests/WebKitCocoa/FullscreenDelegate.mm: * TestWebKitAPI/Tests/WebKitCocoa/FullscreenLayoutConstraints.mm: * TestWebKitAPI/Tests/WebKitCocoa/InAppBrowserPrivacy.mm: * TestWebKitAPI/Tests/WebKitCocoa/InteractionDeadlockAfterCrash.mm: * TestWebKitAPI/Tests/WebKitCocoa/JavaScriptDuringNavigation.mm: * TestWebKitAPI/Tests/WebKitCocoa/LoadFileThenReload.mm: * TestWebKitAPI/Tests/WebKitCocoa/LoadFileURL.mm: * TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm: * TestWebKitAPI/Tests/WebKitCocoa/MediaBufferingPolicy.mm: * TestWebKitAPI/Tests/WebKitCocoa/MediaType.mm: * TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm: * TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm: * TestWebKitAPI/Tests/WebKitCocoa/NavigationAction.mm: * TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm: * TestWebKitAPI/Tests/WebKitCocoa/NetworkProcessCrashNonPersistentDataStore.mm: * TestWebKitAPI/Tests/WebKitCocoa/NoPauseWhenSwitchingTabs.mm: * TestWebKitAPI/Tests/WebKitCocoa/NowPlaying.mm: * TestWebKitAPI/Tests/WebKitCocoa/NowPlayingControlsTests.mm: * TestWebKitAPI/Tests/WebKitCocoa/ObservedRenderingProgressEventsAfterCrash.mm: * TestWebKitAPI/Tests/WebKitCocoa/OpenAndCloseWindow.mm: * TestWebKitAPI/Tests/WebKitCocoa/OverrideViewportArguments.mm: * TestWebKitAPI/Tests/WebKitCocoa/PageZoom.mm: * TestWebKitAPI/Tests/WebKitCocoa/ParserYieldTokenTests.mm: * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm: * TestWebKitAPI/Tests/WebKitCocoa/PasteImage.mm: * TestWebKitAPI/Tests/WebKitCocoa/PasteMixedContent.mm: * TestWebKitAPI/Tests/WebKitCocoa/PasteRTFD.mm: * TestWebKitAPI/Tests/WebKitCocoa/PasteWebArchive.mm: * TestWebKitAPI/Tests/WebKitCocoa/PictureInPictureDelegate.mm: * TestWebKitAPI/Tests/WebKitCocoa/PreferredAudioBufferSize.mm: * TestWebKitAPI/Tests/WebKitCocoa/ProcessSuspendMediaBuffering.mm: * TestWebKitAPI/Tests/WebKitCocoa/ReparentWebViewTimeout.mm: * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm: * TestWebKitAPI/Tests/WebKitCocoa/ResponsivenessTimer.mm: * TestWebKitAPI/Tests/WebKitCocoa/ResponsivenessTimerDoesntFireEarly.mm: * TestWebKitAPI/Tests/WebKitCocoa/RestoreSessionStateWithoutNavigation.mm: * TestWebKitAPI/Tests/WebKitCocoa/ShouldGoToBackForwardListItem.mm: * TestWebKitAPI/Tests/WebKitCocoa/ShouldOpenExternalURLsInNewWindowActions.mm: * TestWebKitAPI/Tests/WebKitCocoa/ShrinkToFit.mm: * TestWebKitAPI/Tests/WebKitCocoa/StopSuspendResumeAllMedia.mm: * TestWebKitAPI/Tests/WebKitCocoa/StorageQuota.mm: * TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm: * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm: * TestWebKitAPI/Tests/WebKitCocoa/TabOutOfWebView.mm: * TestWebKitAPI/Tests/WebKitCocoa/TestURLSchemeHandler.h: * TestWebKitAPI/Tests/WebKitCocoa/TestURLSchemeHandler.mm: * TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm: * TestWebKitAPI/Tests/WebKitCocoa/TextSize.mm: * TestWebKitAPI/Tests/WebKitCocoa/TextWidth.mm: * TestWebKitAPI/Tests/WebKitCocoa/TopContentInset.mm: * TestWebKitAPI/Tests/WebKitCocoa/UserInitiatedActionInNavigationAction.mm: * TestWebKitAPI/Tests/WebKitCocoa/VideoControlsManager.mm: * TestWebKitAPI/Tests/WebKitCocoa/VideoQualityDisplayCompositing.mm: * TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm: * TestWebKitAPI/Tests/WebKitCocoa/WKPDFView.mm: * TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm: * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewFindString.mm: * TestWebKitAPI/Tests/WebKitCocoa/WebContentProcessDidTerminate.mm: * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm: * TestWebKitAPI/Tests/WebKitCocoa/_WKInputDelegate.mm: * TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm: * TestWebKitAPI/Tests/WebKitLegacy/mac/AccessingPastedImage.mm: * TestWebKitAPI/Tests/ios/AccessibilityTestsIOS.mm: * TestWebKitAPI/Tests/ios/DataDetectorsTestIOS.mm: * TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm: * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm: * TestWebKitAPI/Tests/ios/OverflowScrollViewTests.mm: * TestWebKitAPI/Tests/ios/RenderingProgressTests.mm: * TestWebKitAPI/Tests/ios/ScrollViewInsetTests.mm: * TestWebKitAPI/Tests/ios/ScrollViewScrollabilityTests.mm: * TestWebKitAPI/Tests/ios/SelectionByWord.mm: * TestWebKitAPI/Tests/ios/SelectionModifyByParagraphBoundary.mm: * TestWebKitAPI/Tests/ios/TestInputDelegate.h: * TestWebKitAPI/Tests/ios/TestInputDelegate.mm: * TestWebKitAPI/Tests/ios/TextAutosizingBoost.mm: * TestWebKitAPI/Tests/ios/UIPasteboardTests.mm: * TestWebKitAPI/Tests/ios/WKScrollViewTests.mm: * TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm: * TestWebKitAPI/Tests/ios/WKWebViewPausePlayingAudioTests.mm: * TestWebKitAPI/Tests/mac/AcceptsFirstMouse.mm: * TestWebKitAPI/Tests/mac/AdditionalSupportedImageTypes.mm: * TestWebKitAPI/Tests/mac/BackForwardList.mm: * TestWebKitAPI/Tests/mac/BackgroundColor.mm: * TestWebKitAPI/Tests/mac/CandidateTests.mm: * TestWebKitAPI/Tests/mac/DOMHTMLTableCellCellAbove.mm: * TestWebKitAPI/Tests/mac/DeviceScaleFactorOnBack.mm: * TestWebKitAPI/Tests/mac/DynamicDeviceScaleFactor.mm: * TestWebKitAPI/Tests/mac/HTMLCollectionNamedItem.mm: * TestWebKitAPI/Tests/mac/HTMLFormCollectionNamedItem.mm: * TestWebKitAPI/Tests/mac/IsNavigationActionTrusted.mm: * TestWebKitAPI/Tests/mac/LegacyDragAndDropTests.mm: * TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.mm: * TestWebKitAPI/Tests/mac/SSLKeyGenerator.mm: * TestWebKitAPI/Tests/mac/SetAndUpdateCacheModel.mm: * TestWebKitAPI/Tests/mac/SetDocumentURI.mm: * TestWebKitAPI/Tests/mac/SimplifyMarkup.mm: * TestWebKitAPI/Tests/mac/SubresourceErrorCrash.mm: * TestWebKitAPI/Tests/mac/TypingStyleCrash.mm: * TestWebKitAPI/Tests/mac/WKWebViewMacEditingTests.mm: * TestWebKitAPI/Tests/mac/WebScriptObjectDescription.mm: * TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.mm: * TestWebKitAPI/cocoa/DragAndDropSimulator.h: * TestWebKitAPI/cocoa/NSItemProviderAdditions.h: * TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm: * TestWebKitAPI/cocoa/TestContextMenuDriver.h: * TestWebKitAPI/cocoa/TestNavigationDelegate.h: * TestWebKitAPI/cocoa/TestProtocol.mm: * TestWebKitAPI/cocoa/TestUIDelegate.h: * TestWebKitAPI/cocoa/UtilitiesCocoa.mm: * TestWebKitAPI/ios/PencilKitTestSPI.h: * TestWebKitAPI/mac/JavaScriptTestMac.mm: * TestWebKitAPI/mac/NSFontPanelTesting.h: * TestWebKitAPI/mac/NSFontPanelTesting.mm: * TestWebKitAPI/mac/OffscreenWindow.h: * TestWebKitAPI/mac/PlatformUtilitiesMac.mm: * TestWebKitAPI/mac/TestBrowsingContextLoadDelegate.mm: * TestWebKitAPI/mac/TestDraggingInfo.h: * TestWebKitAPI/mac/TestFilePromiseReceiver.h: * TestWebKitAPI/mac/TestFontOptions.h: * TestWebKitAPI/mac/TestInspectorBar.h: * TestWebKitAPI/mac/WebKitAgnosticTest.mm: * WebKitTestRunner/InjectedBundle/mac/AccessibilityCommonMac.h: * WebKitTestRunner/cocoa/TestWebsiteDataStoreDelegate.h: * WebKitTestRunner/mac/PoseAsClass.mm: More #import, less #pragma once. Canonical link: https://commits.webkit.org/223626@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260366 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-20 15:32:36 +00:00
#import "config.h"
#import "EditingTestHarness.h"
[iOS WK2] WKWebView schedules nonstop layout after pressing cmb+b,i,u inside a contenteditable div https://bugs.webkit.org/show_bug.cgi?id=175116 <rdar://problem/28279301> Reviewed by Darin Adler and Ryosuke Niwa. Source/WebCore: WebCore support for WebPage::editorState refactoring. See WebKit ChangeLogs for more detail. Tests: EditorStateTests.TypingAttributesBold EditorStateTests.TypingAttributesItalic EditorStateTests.TypingAttributesUnderline EditorStateTests.TypingAttributesTextAlignmentAbsoluteAlignmentOptions EditorStateTests.TypingAttributesTextAlignmentStartEnd EditorStateTests.TypingAttributesTextAlignmentDirectionalText EditorStateTests.TypingAttributesTextColor EditorStateTests.TypingAttributesMixedStyles EditorStateTests.TypingAttributesLinkColor * css/StyleProperties.cpp: (WebCore::StyleProperties::propertyAsColor const): (WebCore::StyleProperties::propertyAsValueID const): Introduces some helper functions in StyleProperties to convert CSS property values to Color or a CSSValueID. * css/StyleProperties.h: * editing/EditingStyle.cpp: (WebCore::EditingStyle::hasStyle): Pull out logic in selectionStartHasStyle that asks for a style TriState into EditingStyle::hasStyle. This is because WebPage::editorState will now query for multiple styles at the selection start, but selectionStartHasStyle currently recomputes styleAtSelectionStart every time it is called. To prevent extra work from being done, we can just call selectionStartHasStyle once and use ask for EditingStyle::hasStyle on the computed EditingStyle at selection start. * editing/EditingStyle.h: * editing/Editor.cpp: (WebCore::Editor::selectionStartHasStyle const): Source/WebKit: Refactors WebPage::editorState to only use the StyleProperties derived from EditingStyle, instead of inserting and removing a temporary node to figure out the style. Also adds hooks to notify the UI delegate of EditorState changes. * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: * UIProcess/API/Cocoa/WKWebView.mm: (nsTextAlignment): (dictionaryRepresentationForEditorState): (-[WKWebView _didChangeEditorState]): Alerts the private UI delegate of UI-side EditorState updates. (-[WKWebView _web_editorStateDidChange]): (-[WKWebView _executeEditCommand:argument:completion:]): * UIProcess/API/Cocoa/WKWebViewInternal.h: * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/API/mac/WKView.mm: (-[WKView _web_editorStateDidChange]): * UIProcess/Cocoa/WebViewImpl.h: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::selectionDidChange): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::executeEditCommand): Change executeEditCommand(name, callback) to executeEditCommand(name, argument, callback) and lift out of iOS platform code and into WebPage.cpp. * UIProcess/WebPageProxy.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView executeEditCommandWithCallback:]): (-[WKContentView _selectionChanged]): * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::executeEditCommand): Deleted. Move the iOS-specific implementation of executeEditCommand that invokes a callback when the web process responds out of WebPageProxyIOS, and into cross-platform WebPageProxy code. Additionally, add a parameter for the edit command's argument. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::editorState const): Use EditingStyle::styleAtSelectionStart instead of Editor::styleForSelectionStart when computing an EditorState. Tweak bold, italic and underline to use EditingStyle TriStates. (WebKit::WebPage::executeEditCommandWithCallback): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::executeEditCommandWithCallback): Deleted. Tools: Introduces new testing infrastructure and API tests to test EditorState updates in the UI process. The new EditorStateTests run on both iOS and Mac. * TestWebKitAPI/EditingTestHarness.h: Added. * TestWebKitAPI/EditingTestHarness.mm: Added. EditingTestHarness is a helper object that API tests may use to apply editing commands and store EditorState history. This test harness adds sugaring around various editing commands, and simplifies the process of checking the state of the latest observed EditorState. (-[EditingTestHarness initWithWebView:]): (-[EditingTestHarness dealloc]): (-[EditingTestHarness webView]): (-[EditingTestHarness latestEditorState]): (-[EditingTestHarness editorStateHistory]): (-[EditingTestHarness insertText:andExpectEditorStateWith:]): (-[EditingTestHarness insertHTML:andExpectEditorStateWith:]): (-[EditingTestHarness selectAllAndExpectEditorStateWith:]): (-[EditingTestHarness moveBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness moveWordBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness toggleBold]): (-[EditingTestHarness toggleItalic]): (-[EditingTestHarness toggleUnderline]): (-[EditingTestHarness setForegroundColor:]): (-[EditingTestHarness alignJustifiedAndExpectEditorStateWith:]): (-[EditingTestHarness alignLeftAndExpectEditorStateWith:]): (-[EditingTestHarness alignCenterAndExpectEditorStateWith:]): (-[EditingTestHarness alignRightAndExpectEditorStateWith:]): (-[EditingTestHarness insertParagraphAndExpectEditorStateWith:]): (-[EditingTestHarness deleteBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness _execCommand:argument:expectEntries:]): Dispatches an editing command to the web process, and blocks until a response is received. If an expected entries dictionary is given, this will additionally verify that the latest EditorState contains all the expected keys and values. (-[EditingTestHarness latestEditorStateContains:]): (-[EditingTestHarness _webView:editorStateDidChange:]): * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit2Cocoa/EditorStateTests.mm: Added. (TestWebKitAPI::setUpEditorStateTestHarness): (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKit2Cocoa/editor-state-test-harness.html: Added. LayoutTests: * platform/ios-wk2/editing/style/unbold-in-bold-expected.txt: * platform/mac-wk2/editing/style/unbold-in-bold-expected.txt: Rebaseline a WK2 LayoutTest expectations. This test currently expects an empty anonymous RenderBlock to be inserted into the render tree, but this is only a result of us adding and removing a temporary <span> when computing a RenderStyle in WebPage::editorState -- this patch removes these empty RenderBlocks, making these expectations' RenderTrees consistent with WebKit1. Canonical link: https://commits.webkit.org/192520@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221065 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-23 03:16:55 +00:00
#import "PlatformUtilities.h"
Move WKWebView code related to testing to new files, with new private "for testing" headers. https://bugs.webkit.org/show_bug.cgi?id=205021 Reviewed by Tim Horton. Source/WebKit: Move testing-only SPI to new private headers to discourage first parties from using them by mistake. Move test-only code to new files to reduce the size of WKWebView.mm. * SourcesCocoa.txt: * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _internalDoAfterNextPresentationUpdate:withoutWaitingForPainting:withoutWaitingForAnimatedResize:]): (-[WKWebView _prepareForImmediateActionAnimation]): (-[WKWebView _cancelImmediateActionAnimation]): (-[WKWebView _completeImmediateActionAnimation]): (-[WKWebView _useSystemAppearance]): (-[WKWebView _setUseSystemAppearance:]): (-[WKWebView _pageRefForTransitionToWKWebView]): (-[WKWebView _canChangeFrameLayout:]): (-[WKWebView _tryToSwipeWithEvent:ignoringPinnedState:]): (-[WKWebView _ignoresNonWheelEvents]): (-[WKWebView _setIgnoresNonWheelEvents:]): (-[WKWebView _hasActiveVideoForControlsManager]): (-[WKWebView _dismissContentRelativeChildWindows]): (-[WKWebView _gestureEventWasNotHandledByWebCore:]): (-[WKWebView _disableFrameSizeUpdates]): (-[WKWebView _enableFrameSizeUpdates]): (-[WKWebView _beginDeferringViewInWindowChanges]): (-[WKWebView _endDeferringViewInWindowChanges]): (-[WKWebView _endDeferringViewInWindowChangesSync]): (-[WKWebView _fullScreenPlaceholderView]): (-[WKWebView _fullScreenWindow]): (-[WKWebView _underlayColor]): (-[WKWebView _setUnderlayColor:]): (-[WKWebView _setCustomSwipeViews:]): (-[WKWebView _setCustomSwipeViewsTopContentInset:]): (-[WKWebView _setDidMoveSwipeSnapshotCallback:]): (-[WKWebView _setFrame:andScrollBy:]): (-[WKWebView _setTotalHeightOfBanners:]): (-[WKWebView _totalHeightOfBanners]): (-[WKWebView _setFont:sender:]): (-[WKWebView _setFontSize:sender:]): (-[WKWebView _setTextColor:sender:]): (-[WKWebView inputAccessoryView]): (-[WKWebView inputView]): (-[WKWebView _requestActivatedElementAtPosition:completionBlock:]): (-[WKWebView _contentVisibleRect]): (-[WKWebView _convertPointFromContentsToView:]): (-[WKWebView _convertPointFromViewToContents:]): (-[WKWebView didStartFormControlInteraction]): (-[WKWebView didEndFormControlInteraction]): (-[WKWebView _uiTextCaretRect]): (-[WKWebView _accessibilityRetrieveRectsAtSelectionOffset:withText:completionHandler:]): (-[WKWebView _accessibilityStoreSelection]): (-[WKWebView _accessibilityClearSelection]): (-[WKWebView _contentViewIsFirstResponder]): (-[WKWebView _inspector]): (-[WKWebView _mainFrame]): (-[WKWebView _isEditable]): (-[WKWebView _setEditable:]): (-[WKWebView _executeEditCommand:argument:completion:]): (-[WKWebView _textManipulationDelegate]): (-[WKWebView _setTextManipulationDelegate:]): (-[WKWebView _startTextManipulationsWithConfiguration:completion:]): (-[WKWebView _completeTextManipulation:completion:]): (-[WKWebView _takeFindStringFromSelection:]): (+[WKWebView _stringForFind]): (+[WKWebView _setStringForFind:]): (-[WKWebView _remoteObjectRegistry]): (-[WKWebView _handle]): (-[WKWebView _observedRenderingProgressEvents]): (-[WKWebView _historyDelegate]): (-[WKWebView _setHistoryDelegate:]): (-[WKWebView _updateMediaPlaybackControlsManager]): (-[WKWebView _canTogglePictureInPicture]): (-[WKWebView _isPictureInPictureActive]): (-[WKWebView _togglePictureInPicture]): (-[WKWebView _closeAllMediaPresentations]): (-[WKWebView _stopMediaCapture]): (-[WKWebView _stopAllMediaPlayback]): (-[WKWebView _suspendAllMediaPlayback]): (-[WKWebView _resumeAllMediaPlayback]): (-[WKWebView _unreachableURL]): (-[WKWebView _mainFrameURL]): (-[WKWebView _loadAlternateHTMLString:baseURL:forUnreachableURL:]): (-[WKWebView _loadData:MIMEType:characterEncodingName:baseURL:userData:]): (-[WKWebView _loadRequest:shouldOpenExternalURLs:]): (-[WKWebView _certificateChain]): (-[WKWebView _committedURL]): (-[WKWebView _MIMEType]): (-[WKWebView _userAgent]): (-[WKWebView _applicationNameForUserAgent]): (-[WKWebView _setApplicationNameForUserAgent:]): (-[WKWebView _customUserAgent]): (-[WKWebView _setCustomUserAgent:]): (-[WKWebView _setUserContentExtensionsEnabled:]): (-[WKWebView _userContentExtensionsEnabled]): (-[WKWebView _webProcessIdentifier]): (-[WKWebView _provisionalWebProcessIdentifier]): (-[WKWebView _killWebContentProcess]): (-[WKWebView _safeBrowsingWarning]): (-[WKWebView _reloadWithoutContentBlockers]): (-[WKWebView _reloadExpiredOnly]): (-[WKWebView _killWebContentProcessAndResetState]): (-[WKWebView _convertRectFromRootViewCoordinates:]): (-[WKWebView _convertRectToRootViewCoordinates:]): (-[WKWebView _requestTextInputContextsInRect:completionHandler:]): (-[WKWebView _focusTextInputContext:completionHandler:]): (-[WKWebView _takePDFSnapshotWithConfiguration:completionHandler:]): (-[WKWebView _setShouldSuppressFirstResponderChanges:]): (-[WKWebView _retainActiveFocusedState]): (-[WKWebView _becomeFirstResponderWithSelectionMovingForward:completionHandler:]): (-[WKWebView _snapshotLayerContentsForBackForwardListItem:]): (-[WKWebView _dataDetectionResults]): (-[WKWebView _accessibilityRetrieveSpeakSelectionContent]): (-[WKWebView _accessibilityDidGetSpeakSelectionContent:]): (-[WKWebView inputAssistantItem]): (-[WKWebView _sessionStateData]): (-[WKWebView _sessionState]): (-[WKWebView _sessionStateWithFilter:]): (-[WKWebView _restoreFromSessionStateData:]): (-[WKWebView _restoreSessionState:andNavigate:]): (-[WKWebView _close]): (-[WKWebView _insertAttachmentWithFilename:contentType:data:options:completion:]): (-[WKWebView _insertAttachmentWithFileWrapper:contentType:options:completion:]): (-[WKWebView _insertAttachmentWithFileWrapper:contentType:completion:]): (-[WKWebView _attachmentForIdentifier:]): (-[WKWebView _simulateDeviceOrientationChangeWithAlpha:beta:gamma:]): (+[WKWebView _handlesSafeBrowsing]): (-[WKWebView _showSafeBrowsingWarningWithTitle:warning:details:completionHandler:]): (-[WKWebView _showSafeBrowsingWarningWithURL:title:warning:details:completionHandler:]): (+[WKWebView _confirmMalwareSentinel]): (+[WKWebView _visitUnsafeWebsiteSentinel]): (-[WKWebView _isJITEnabled:]): (-[WKWebView _evaluateJavaScriptWithoutUserGesture:completionHandler:]): (-[WKWebView _updateWebsitePolicies:]): (-[WKWebView _allowsRemoteInspection]): (-[WKWebView _setAllowsRemoteInspection:]): (-[WKWebView _remoteInspectionNameOverride]): (-[WKWebView _setRemoteInspectionNameOverride:]): (-[WKWebView _addsVisitedLinks]): (-[WKWebView _setAddsVisitedLinks:]): (-[WKWebView _networkRequestsInProgress]): (layoutMilestones): (-[WKWebView _setObservedRenderingProgressEvents:]): (-[WKWebView _getMainResourceDataWithCompletionHandler:]): (-[WKWebView _getWebArchiveDataWithCompletionHandler:]): (-[WKWebView _getContentsAsStringWithCompletionHandler:]): (-[WKWebView _getContentsAsAttributedStringWithCompletionHandler:]): (-[WKWebView _getApplicationManifestWithCompletionHandler:]): (-[WKWebView _paginationMode]): (-[WKWebView _setPaginationMode:]): (-[WKWebView _paginationBehavesLikeColumns]): (-[WKWebView _setPaginationBehavesLikeColumns:]): (-[WKWebView _pageLength]): (-[WKWebView _setPageLength:]): (-[WKWebView _gapBetweenPages]): (-[WKWebView _setGapBetweenPages:]): (-[WKWebView _paginationLineGridEnabled]): (-[WKWebView _setPaginationLineGridEnabled:]): (-[WKWebView _pageCount]): (-[WKWebView _supportsTextZoom]): (-[WKWebView _textZoomFactor]): (-[WKWebView _setTextZoomFactor:]): (-[WKWebView setPageZoom:]): (-[WKWebView pageZoom]): (-[WKWebView _pageZoomFactor]): (-[WKWebView _setPageZoomFactor:]): (-[WKWebView _diagnosticLoggingDelegate]): (-[WKWebView _setDiagnosticLoggingDelegate:]): (-[WKWebView _findDelegate]): (-[WKWebView _setFindDelegate:]): (toFindOptions): (-[WKWebView _countStringMatches:options:maxCount:]): (-[WKWebView _findString:options:maxCount:]): (-[WKWebView _hideFindUI]): (-[WKWebView _saveBackForwardSnapshotForItem:]): (-[WKWebView _inputDelegate]): (-[WKWebView _setInputDelegate:]): (-[WKWebView _isDisplayingStandaloneImageDocument]): (-[WKWebView _isDisplayingStandaloneMediaDocument]): (-[WKWebView _isPlayingAudio]): (-[WKWebView _isShowingNavigationGestureSnapshot]): (-[WKWebView _layoutMode]): (-[WKWebView _setLayoutMode:]): (-[WKWebView _fixedLayoutSize]): (-[WKWebView _setFixedLayoutSize:]): (-[WKWebView _setBackgroundExtendsBeyondPage:]): (-[WKWebView _backgroundExtendsBeyondPage]): (-[WKWebView _viewScale]): (-[WKWebView _setViewScale:]): (-[WKWebView _setMinimumEffectiveDeviceWidth:]): (-[WKWebView _minimumEffectiveDeviceWidth]): (-[WKWebView _setScrollPerformanceDataCollectionEnabled:]): (-[WKWebView _scrollPerformanceDataCollectionEnabled]): (-[WKWebView _scrollPerformanceData]): (-[WKWebView _allowsMediaDocumentInlinePlayback]): (-[WKWebView _setAllowsMediaDocumentInlinePlayback:]): (-[WKWebView _webProcessIsResponsive]): (-[WKWebView _setFullscreenDelegate:]): (-[WKWebView _fullscreenDelegate]): (-[WKWebView _isInFullscreen]): (-[WKWebView _mediaCaptureState]): (-[WKWebView _setMediaCaptureEnabled:]): (-[WKWebView _mediaCaptureEnabled]): (-[WKWebView _setPageMuted:]): (-[WKWebView _removeDataDetectedLinks:]): (-[WKWebView _doAfterNextPresentationUpdate:]): (-[WKWebView _doAfterNextPresentationUpdateWithoutWaitingForPainting:]): (-[WKWebView _doAfterNextStablePresentationUpdate:]): (-[WKWebView _detectDataWithTypes:completionHandler:]): (-[WKWebView removeFromSuperview]): (-[WKWebView _minimumLayoutSizeOverride]): (-[WKWebView _setViewLayoutSizeOverride:]): (-[WKWebView _obscuredInsets]): (-[WKWebView _setObscuredInsets:]): (-[WKWebView _obscuredInsetEdgesAffectedBySafeArea]): (-[WKWebView _setObscuredInsetEdgesAffectedBySafeArea:]): (-[WKWebView _unobscuredSafeAreaInsets]): (-[WKWebView _setUnobscuredSafeAreaInsets:]): (-[WKWebView _safeAreaShouldAffectObscuredInsets]): (-[WKWebView _setInterfaceOrientationOverride:]): (-[WKWebView _interfaceOrientationOverride]): (-[WKWebView _clearInterfaceOrientationOverride]): (-[WKWebView _maximumUnobscuredSizeOverride]): (-[WKWebView _setMaximumUnobscuredSizeOverride:]): (-[WKWebView _setAllowsViewportShrinkToFit:]): (-[WKWebView _allowsViewportShrinkToFit]): (-[WKWebView _beginInteractiveObscuredInsetsChange]): (-[WKWebView _endInteractiveObscuredInsetsChange]): (-[WKWebView _hideContentUntilNextUpdate]): (-[WKWebView _beginAnimatedResizeWithUpdates:]): (-[WKWebView _endAnimatedResize]): (-[WKWebView _resizeWhileHidingContentWithUpdates:]): (-[WKWebView _setOverlaidAccessoryViewsInset:]): (-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]): (-[WKWebView _overrideLayoutParametersWithMinimumLayoutSize:maximumUnobscuredSizeOverride:]): (-[WKWebView _clearOverrideLayoutParameters]): (viewportArgumentsFromDictionary): (-[WKWebView _overrideViewportWithArguments:]): (-[WKWebView _viewForFindUI]): (-[WKWebView _isDisplayingPDF]): (-[WKWebView _dataForDisplayedPDF]): (-[WKWebView _suggestedFilenameForDisplayedPDF]): (-[WKWebView _webViewPrintFormatter]): (toUserInterfaceLayoutDirection): (-[WKWebView setSemanticContentAttribute:]): (-[WKWebView _drawsBackground]): (-[WKWebView _setDrawsBackground:]): (-[WKWebView _backgroundColor]): (-[WKWebView _setBackgroundColor:]): (-[WKWebView _setDrawsTransparentBackground:]): (-[WKWebView _inspectorAttachmentView]): (-[WKWebView _setInspectorAttachmentView:]): (-[WKWebView _setOverlayScrollbarStyle:]): (-[WKWebView _overlayScrollbarStyle]): (-[WKWebView _windowOcclusionDetectionEnabled]): (-[WKWebView _setWindowOcclusionDetectionEnabled:]): (-[WKWebView shareSheetDidDismiss:]): (-[WKWebView _setOverrideDeviceScaleFactor:]): (-[WKWebView _overrideDeviceScaleFactor]): (-[WKWebView _setTopContentInset:]): (-[WKWebView _topContentInset]): (-[WKWebView _pageExtendedBackgroundColor]): (-[WKWebView _pinnedState]): (-[WKWebView _rubberBandingEnabled]): (-[WKWebView _setRubberBandingEnabled:]): (-[WKWebView _immediateActionAnimationControllerForHitTestResult:withType:userData:]): (-[WKWebView _setAutomaticallyAdjustsContentInsets:]): (-[WKWebView _automaticallyAdjustsContentInsets]): (-[WKWebView _minimumLayoutWidth]): (-[WKWebView _setMinimumLayoutWidth:]): (-[WKWebView _shouldExpandContentToViewHeightForAutoLayout]): (-[WKWebView _setShouldExpandContentToViewHeightForAutoLayout:]): (-[WKWebView _alwaysShowsHorizontalScroller]): (-[WKWebView _setAlwaysShowsHorizontalScroller:]): (-[WKWebView _alwaysShowsVerticalScroller]): (-[WKWebView _setAlwaysShowsVerticalScroller:]): (-[WKWebView _printOperationWithPrintInfo:]): (-[WKWebView _printOperationWithPrintInfo:forFrame:]): (-[WKWebView setUserInterfaceLayoutDirection:]): (-[WKWebView _wantsMediaPlaybackControlsView]): (-[WKWebView _setWantsMediaPlaybackControlsView:]): (-[WKWebView _mediaPlaybackControlsView]): (-[WKWebView _addMediaPlaybackControlsView:]): (-[WKWebView _removeMediaPlaybackControlsView]): (-[WKWebView _prepareForMoveToWindow:completionHandler:]): (-[WKWebView _setThumbnailView:]): (-[WKWebView _thumbnailView]): (-[WKWebView _setIgnoresAllEvents:]): (-[WKWebView _ignoresAllEvents]): (-[WKWebView _spellCheckerDocumentTag]): (-[WKWebView _setContinuousSpellCheckingEnabledForTesting:]): Deleted. (-[WKWebView _contentsOfUserInterfaceItem:]): Deleted. (-[WKWebView _setDeviceOrientationUserPermissionHandlerForTesting:]): Deleted. (-[WKWebView keyboardAccessoryBarNext]): Deleted. (-[WKWebView keyboardAccessoryBarPrevious]): Deleted. (-[WKWebView applyAutocorrection:toString:withCompletionHandler:]): Deleted. (-[WKWebView dismissFormAccessoryView]): Deleted. (-[WKWebView _dismissFilePicker]): Deleted. (-[WKWebView setTimePickerValueToHour:minute:]): Deleted. (-[WKWebView selectFormAccessoryPickerRow:]): Deleted. (-[WKWebView selectFormPopoverTitle]): Deleted. (-[WKWebView textContentTypeForTesting]): Deleted. (-[WKWebView formInputLabel]): Deleted. (-[WKWebView _didShowContextMenu]): Deleted. (-[WKWebView _didDismissContextMenu]): Deleted. (-[WKWebView _inputViewBounds]): Deleted. (-[WKWebView _uiTextSelectionRects]): Deleted. (-[WKWebView _scrollingTreeAsText]): Deleted. (-[WKWebView _stableStateOverride]): Deleted. (-[WKWebView _propertiesOfLayerWithID:]): Deleted. (-[WKWebView _doAfterResettingSingleTapGesture:]): Deleted. (-[WKWebView _doAfterReceivingEditDragSnapshotForTesting:]): Deleted. (-[WKWebView _requestControlledElementID]): Deleted. (-[WKWebView _handleControlledElementIDResponse:]): Deleted. (-[WKWebView _handleAcceptedCandidate:]): Deleted. (-[WKWebView _didHandleAcceptedCandidate]): Deleted. (-[WKWebView _didUpdateCandidateListVisibility:]): Deleted. (-[WKWebView _forceRequestCandidates]): Deleted. (-[WKWebView _shouldRequestCandidates]): Deleted. (-[WKWebView _insertText:replacementRange:]): Deleted. (-[WKWebView _candidateRect]): Deleted. (-[WKWebView viewDidChangeEffectiveAppearance]): Deleted. (-[WKWebView _setHeaderBannerHeight:]): Deleted. (-[WKWebView _setFooterBannerHeight:]): Deleted. (-[WKWebView _doAfterProcessingAllPendingMouseEvents:]): Deleted. (-[WKWebView _activeMenu]): Deleted. (-[WKWebView _requestActiveNowPlayingSessionInfo:]): Deleted. (-[WKWebView _setPageScale:withOrigin:]): Deleted. (-[WKWebView _pageScale]): Deleted. (-[WKWebView _scrollingUpdatesDisabledForTesting]): Deleted. (-[WKWebView _setScrollingUpdatesDisabledForTesting:]): Deleted. (-[WKWebView _doAfterNextPresentationUpdateWithoutWaitingForAnimatedResizeForTesting:]): Deleted. (-[WKWebView _doAfterNextVisibleContentRectUpdate:]): Deleted. (-[WKWebView _disableBackForwardSnapshotVolatilityForTesting]): Deleted. (-[WKWebView _dragCaretRect]): Deleted. (-[WKWebView _simulateLongPressActionAtLocation:]): Deleted. (-[WKWebView _simulateTextEntered:]): Deleted. (-[WKWebView _dynamicUserInterfaceTraitDidChange]): Deleted. (-[WKWebView _beginBackSwipeForTesting]): Deleted. (-[WKWebView _completeBackSwipeForTesting]): Deleted. (-[WKWebView _setDefersLoadingForTesting:]): Deleted. (-[WKWebView _setShareSheetCompletesImmediatelyWithResolutionForTesting:]): Deleted. (-[WKWebView _hasInspectorFrontend]): Deleted. (-[WKWebView _processWillSuspendImminentlyForTesting]): Deleted. (-[WKWebView _processDidResumeForTesting]): Deleted. (-[WKWebView _setAssertionStateForTesting:]): Deleted. (-[WKWebView _hasServiceWorkerBackgroundActivityForTesting]): Deleted. (-[WKWebView _hasServiceWorkerForegroundActivityForTesting]): Deleted. (-[WKWebView _denyNextUserMediaRequest]): Deleted. (-[WKWebView _triggerSystemPreviewActionOnElement:document:page:]): Deleted. * UIProcess/API/Cocoa/WKWebViewInternal.h: * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h: Added. * UIProcess/API/Cocoa/WKWebViewTesting.mm: Added. (-[WKWebView _setPageScale:withOrigin:]): (-[WKWebView _pageScale]): (-[WKWebView _setContinuousSpellCheckingEnabledForTesting:]): (-[WKWebView _contentsOfUserInterfaceItem:]): (-[WKWebView _requestActiveNowPlayingSessionInfo:]): (-[WKWebView _scrollingUpdatesDisabledForTesting]): (-[WKWebView _setScrollingUpdatesDisabledForTesting:]): (-[WKWebView _doAfterNextPresentationUpdateWithoutWaitingForAnimatedResizeForTesting:]): (-[WKWebView _doAfterNextVisibleContentRectUpdate:]): (-[WKWebView _disableBackForwardSnapshotVolatilityForTesting]): (-[WKWebView _beginBackSwipeForTesting]): (-[WKWebView _completeBackSwipeForTesting]): (-[WKWebView _setDefersLoadingForTesting:]): (-[WKWebView _setShareSheetCompletesImmediatelyWithResolutionForTesting:]): (-[WKWebView _hasInspectorFrontend]): (-[WKWebView _processWillSuspendImminentlyForTesting]): (-[WKWebView _processDidResumeForTesting]): (-[WKWebView _setAssertionStateForTesting:]): (-[WKWebView _hasServiceWorkerBackgroundActivityForTesting]): (-[WKWebView _hasServiceWorkerForegroundActivityForTesting]): (-[WKWebView _denyNextUserMediaRequest]): * UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h: Added. * UIProcess/API/ios/WKWebViewTestingIOS.mm: Added. (-[WKWebView keyboardAccessoryBarNext]): (-[WKWebView keyboardAccessoryBarPrevious]): (-[WKWebView applyAutocorrection:toString:withCompletionHandler:]): (-[WKWebView dismissFormAccessoryView]): (-[WKWebView _dismissFilePicker]): (-[WKWebView setTimePickerValueToHour:minute:]): (-[WKWebView selectFormAccessoryPickerRow:]): (-[WKWebView selectFormPopoverTitle]): (-[WKWebView textContentTypeForTesting]): (-[WKWebView formInputLabel]): (-[WKWebView _didShowContextMenu]): (-[WKWebView _didDismissContextMenu]): (-[WKWebView _inputViewBounds]): (-[WKWebView _uiTextSelectionRects]): (-[WKWebView _scrollingTreeAsText]): (-[WKWebView _stableStateOverride]): (-[WKWebView _propertiesOfLayerWithID:]): (-[WKWebView _doAfterResettingSingleTapGesture:]): (-[WKWebView _doAfterReceivingEditDragSnapshotForTesting:]): (-[WKWebView _dragCaretRect]): (-[WKWebView _simulateLongPressActionAtLocation:]): (-[WKWebView _simulateTextEntered:]): (-[WKWebView _dynamicUserInterfaceTraitDidChange]): (-[WKWebView _triggerSystemPreviewActionOnElement:document:page:]): (-[WKWebView _setDeviceOrientationUserPermissionHandlerForTesting:]): * UIProcess/API/mac/WKWebViewPrivateForTestingMac.h: Copied from Tools/TestWebKitAPI/Tests/WebKitCocoa/InteractionDeadlockAfterCrash.mm. * UIProcess/API/mac/WKWebViewTestingMac.mm: Added. (-[WKWebView _requestControlledElementID]): (-[WKWebView _handleControlledElementIDResponse:]): (-[WKWebView _handleAcceptedCandidate:]): (-[WKWebView _didHandleAcceptedCandidate]): (-[WKWebView _didUpdateCandidateListVisibility:]): (-[WKWebView _forceRequestCandidates]): (-[WKWebView _shouldRequestCandidates]): (-[WKWebView _insertText:replacementRange:]): (-[WKWebView _candidateRect]): (-[WKWebView viewDidChangeEffectiveAppearance]): (-[WKWebView _setHeaderBannerHeight:]): (-[WKWebView _setFooterBannerHeight:]): (-[WKWebView _doAfterProcessingAllPendingMouseEvents:]): (-[WKWebView _activeMenu]): * UIProcess/Cocoa/PageClientImplCocoa.mm: * UIProcess/ios/PageClientImplIOS.mm: * UIProcess/ios/WKContentViewInteraction.mm: * UIProcess/ios/WKMouseGestureRecognizer.h: * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm: * UIProcess/mac/PageClientImplMac.mm: * UIProcess/mac/WKFullScreenWindowController.h: * WebKit.xcodeproj/project.pbxproj: Tools: Move testing-only SPI to new private headers to discourage first parties from using them by mistake. Move test-only code to new files to reduce the size of WKWebView.mm. * MiniBrowser/mac/WK2BrowserWindowController.m: * TestWebKitAPI/EditingTestHarness.mm: * TestWebKitAPI/Tests/WebKit/ResponsivenessTimerCrash.mm: * TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm: * TestWebKitAPI/Tests/WebKitCocoa/DeviceOrientation.mm: * TestWebKitAPI/Tests/WebKitCocoa/DoubleDefersLoading.mm: * TestWebKitAPI/Tests/WebKitCocoa/InteractionDeadlockAfterCrash.mm: * TestWebKitAPI/Tests/WebKitCocoa/MediaBufferingPolicy.mm: * TestWebKitAPI/Tests/WebKitCocoa/NowPlayingControlsTests.mm: * TestWebKitAPI/Tests/WebKitCocoa/PictureInPictureDelegate.mm: * TestWebKitAPI/Tests/WebKitCocoa/ProcessSuspendMediaBuffering.mm: * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: * TestWebKitAPI/Tests/WebKitCocoa/SnapshotStore.mm: * TestWebKitAPI/Tests/WebKitCocoa/SystemPreview.mm: * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm: * TestWebKitAPI/Tests/WebKitCocoa/UserMediaSimulateFailedSandbox.mm: * TestWebKitAPI/Tests/WebKitCocoa/VideoControlsManager.mm: * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm: * TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm: * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewCandidateTests.mm: * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEditActions.mm: * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewFirstResponderTests.mm: * TestWebKitAPI/Tests/ios/AccessibilityTestsIOS.mm: * TestWebKitAPI/Tests/ios/ActionSheetTests.mm: * TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm: * TestWebKitAPI/Tests/ios/FocusPreservationTests.mm: * TestWebKitAPI/cocoa/TestNavigationDelegate.mm: * TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm: * TestWebKitAPI/mac/DragAndDropSimulatorMac.mm: * WebKitTestRunner/cocoa/TestControllerCocoa.mm: * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm: * WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm: * WebKitTestRunner/ios/TestControllerIOS.mm: * WebKitTestRunner/ios/UIScriptControllerIOS.mm: * WebKitTestRunner/mac/UIScriptControllerMac.mm: Canonical link: https://commits.webkit.org/218389@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253465 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-13 06:06:08 +00:00
#import <WebKit/WKWebViewPrivateForTesting.h>
[iOS WK2] WKWebView schedules nonstop layout after pressing cmb+b,i,u inside a contenteditable div https://bugs.webkit.org/show_bug.cgi?id=175116 <rdar://problem/28279301> Reviewed by Darin Adler and Ryosuke Niwa. Source/WebCore: WebCore support for WebPage::editorState refactoring. See WebKit ChangeLogs for more detail. Tests: EditorStateTests.TypingAttributesBold EditorStateTests.TypingAttributesItalic EditorStateTests.TypingAttributesUnderline EditorStateTests.TypingAttributesTextAlignmentAbsoluteAlignmentOptions EditorStateTests.TypingAttributesTextAlignmentStartEnd EditorStateTests.TypingAttributesTextAlignmentDirectionalText EditorStateTests.TypingAttributesTextColor EditorStateTests.TypingAttributesMixedStyles EditorStateTests.TypingAttributesLinkColor * css/StyleProperties.cpp: (WebCore::StyleProperties::propertyAsColor const): (WebCore::StyleProperties::propertyAsValueID const): Introduces some helper functions in StyleProperties to convert CSS property values to Color or a CSSValueID. * css/StyleProperties.h: * editing/EditingStyle.cpp: (WebCore::EditingStyle::hasStyle): Pull out logic in selectionStartHasStyle that asks for a style TriState into EditingStyle::hasStyle. This is because WebPage::editorState will now query for multiple styles at the selection start, but selectionStartHasStyle currently recomputes styleAtSelectionStart every time it is called. To prevent extra work from being done, we can just call selectionStartHasStyle once and use ask for EditingStyle::hasStyle on the computed EditingStyle at selection start. * editing/EditingStyle.h: * editing/Editor.cpp: (WebCore::Editor::selectionStartHasStyle const): Source/WebKit: Refactors WebPage::editorState to only use the StyleProperties derived from EditingStyle, instead of inserting and removing a temporary node to figure out the style. Also adds hooks to notify the UI delegate of EditorState changes. * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: * UIProcess/API/Cocoa/WKWebView.mm: (nsTextAlignment): (dictionaryRepresentationForEditorState): (-[WKWebView _didChangeEditorState]): Alerts the private UI delegate of UI-side EditorState updates. (-[WKWebView _web_editorStateDidChange]): (-[WKWebView _executeEditCommand:argument:completion:]): * UIProcess/API/Cocoa/WKWebViewInternal.h: * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/API/mac/WKView.mm: (-[WKView _web_editorStateDidChange]): * UIProcess/Cocoa/WebViewImpl.h: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::selectionDidChange): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::executeEditCommand): Change executeEditCommand(name, callback) to executeEditCommand(name, argument, callback) and lift out of iOS platform code and into WebPage.cpp. * UIProcess/WebPageProxy.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView executeEditCommandWithCallback:]): (-[WKContentView _selectionChanged]): * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::executeEditCommand): Deleted. Move the iOS-specific implementation of executeEditCommand that invokes a callback when the web process responds out of WebPageProxyIOS, and into cross-platform WebPageProxy code. Additionally, add a parameter for the edit command's argument. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::editorState const): Use EditingStyle::styleAtSelectionStart instead of Editor::styleForSelectionStart when computing an EditorState. Tweak bold, italic and underline to use EditingStyle TriStates. (WebKit::WebPage::executeEditCommandWithCallback): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::executeEditCommandWithCallback): Deleted. Tools: Introduces new testing infrastructure and API tests to test EditorState updates in the UI process. The new EditorStateTests run on both iOS and Mac. * TestWebKitAPI/EditingTestHarness.h: Added. * TestWebKitAPI/EditingTestHarness.mm: Added. EditingTestHarness is a helper object that API tests may use to apply editing commands and store EditorState history. This test harness adds sugaring around various editing commands, and simplifies the process of checking the state of the latest observed EditorState. (-[EditingTestHarness initWithWebView:]): (-[EditingTestHarness dealloc]): (-[EditingTestHarness webView]): (-[EditingTestHarness latestEditorState]): (-[EditingTestHarness editorStateHistory]): (-[EditingTestHarness insertText:andExpectEditorStateWith:]): (-[EditingTestHarness insertHTML:andExpectEditorStateWith:]): (-[EditingTestHarness selectAllAndExpectEditorStateWith:]): (-[EditingTestHarness moveBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness moveWordBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness toggleBold]): (-[EditingTestHarness toggleItalic]): (-[EditingTestHarness toggleUnderline]): (-[EditingTestHarness setForegroundColor:]): (-[EditingTestHarness alignJustifiedAndExpectEditorStateWith:]): (-[EditingTestHarness alignLeftAndExpectEditorStateWith:]): (-[EditingTestHarness alignCenterAndExpectEditorStateWith:]): (-[EditingTestHarness alignRightAndExpectEditorStateWith:]): (-[EditingTestHarness insertParagraphAndExpectEditorStateWith:]): (-[EditingTestHarness deleteBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness _execCommand:argument:expectEntries:]): Dispatches an editing command to the web process, and blocks until a response is received. If an expected entries dictionary is given, this will additionally verify that the latest EditorState contains all the expected keys and values. (-[EditingTestHarness latestEditorStateContains:]): (-[EditingTestHarness _webView:editorStateDidChange:]): * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit2Cocoa/EditorStateTests.mm: Added. (TestWebKitAPI::setUpEditorStateTestHarness): (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKit2Cocoa/editor-state-test-harness.html: Added. LayoutTests: * platform/ios-wk2/editing/style/unbold-in-bold-expected.txt: * platform/mac-wk2/editing/style/unbold-in-bold-expected.txt: Rebaseline a WK2 LayoutTest expectations. This test currently expects an empty anonymous RenderBlock to be inserted into the render tree, but this is only a result of us adding and removing a temporary <span> when computing a RenderStyle in WebPage::editorState -- this patch removes these empty RenderBlocks, making these expectations' RenderTrees consistent with WebKit1. Canonical link: https://commits.webkit.org/192520@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221065 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-23 03:16:55 +00:00
@implementation EditingTestHarness
- (instancetype)initWithWebView:(TestWKWebView *)webView
{
if (self = [super init]) {
_webView = webView;
[_webView setUIDelegate:self];
_editorStateHistory = adoptNS([[NSMutableArray alloc] init]);
}
return self;
}
- (void)dealloc
{
if ([_webView UIDelegate] == self)
[_webView setUIDelegate:nil];
[super dealloc];
}
- (TestWKWebView *)webView
{
return _webView.get();
}
- (NSDictionary *)latestEditorState
{
return self.editorStateHistory.lastObject;
}
- (NSArray<NSDictionary *> *)editorStateHistory
{
return _editorStateHistory.get();
}
[iOS WK2] Implement -[WKContentView hasText] for compatibility with the UITextInput protocol https://bugs.webkit.org/show_bug.cgi?id=177662 <rdar://problem/33410373> Reviewed by Tim Horton. Source/WebCore: Adds a new TextIterator helper function to determine whether a Range has any plain text. Tests: EditorStateTests.ContentViewHasTextInContentEditableElement EditorStateTests.ContentViewHasTextInTextarea * editing/TextIterator.cpp: (WebCore::hasAnyPlainText): Add a new helper to determine whether a Range contains any plain text. While inspired by and very similar to the plainText() helper function, this variant does not create a new string buffer when invoked, and is therefore more efficient for the purposes of determining whether there is any plain text at all. * editing/TextIterator.h: Source/WebKit: Implements -[WKContentView hasText] by propagating a flag through post-layout editor state. * Shared/EditorState.cpp: (WebKit::EditorState::PostLayoutData::encode const): (WebKit::EditorState::PostLayoutData::decode): * Shared/EditorState.h: Add a new flag to EditorState indicating whether or not the current editable root containing the selection has any plain text. Add IPC support for this new flag. * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView hasText]): * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::computeEditableRootHasContentAndPlainText): Add a new helper to compute whether or not the editable root has any content, and any plain text. This is used as the last cached value for -hasText on WKContentView that we will deliver to UIKit. Some important things to note here: - If post layout data already indicates that we have selected some plain text, or that there is a plain text character near the selection, just set the flags to true and bail, since the editable root necessarily has content that is plain text. - If hasContent is false, don't even bother computing hasPlainText, because it must also be false. - Otherwise, use hasAnyPlainText to compute the value of hasPlainText, which is a faster variant of plainText. These optimizations help us avoid doing extra work at all when running Speedometer, apart from checking the values of a few PostLayoutData flags. This also fixes the value of hasContent, which was previously always false if we had a range selection rather than a caret selection even when the editable root has content, because the logic to compute the value of hasContent only existed in the branch where we have a caret selection. (WebKit::WebPage::platformEditorState const): Tools: Add EditorState API tests to check that the value of -[WKContentView hasText] is correct when editing both plain and rich text areas. * TestWebKitAPI/EditingTestHarness.h: * TestWebKitAPI/EditingTestHarness.mm: (-[EditingTestHarness insertParagraph]): (-[EditingTestHarness insertText:]): (-[EditingTestHarness insertHTML:]): (-[EditingTestHarness selectAll]): (-[EditingTestHarness deleteBackwards]): * TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm: Add versions of EditingTestHarness helpers that don't require us to expect any editor state after executing the edit command. (TestWebKitAPI::checkContentViewHasTextWithFailureDescription): (TestWebKitAPI::TEST): * TestWebKitAPI/cocoa/TestWKWebView.h: * TestWebKitAPI/cocoa/TestWKWebView.mm: (-[TestWKWebView textInputContentView]): Canonical link: https://commits.webkit.org/193938@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222654 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-09-29 18:33:32 +00:00
- (void)insertParagraph
{
[self insertParagraphAndExpectEditorStateWith:nil];
}
- (void)insertText:(NSString *)text
{
[self insertText:text andExpectEditorStateWith:nil];
}
- (void)insertHTML:(NSString *)html
{
[self insertHTML:html andExpectEditorStateWith:nil];
}
- (void)selectAll
{
[self selectAllAndExpectEditorStateWith:nil];
}
- (void)deleteBackwards
{
[self deleteBackwardAndExpectEditorStateWith:nil];
}
[iOS] Expose SPI to access the current sentence boundary and selection state https://bugs.webkit.org/show_bug.cgi?id=193398 <rdar://problem/45893108> Reviewed by Dean Jackson. Source/WebKit: Expose SPI on WKWebView for internal clients to grab information about attributes at the current selection; so far, this only includes whether the selection is a caret or a range, and whether or not the start of the selection is at the start of a new sentence. Test: EditorStateTests.ObserveSelectionAttributeChanges * Shared/EditorState.cpp: (WebKit::EditorState::PostLayoutData::encode const): (WebKit::EditorState::PostLayoutData::decode): * Shared/EditorState.h: Add a new bit in EditorState on iOS to compute whether or not the start of the selection is at the start of a new sentence. This is computed and set when sending post-layout data in `WebPageIOS.mm`. * UIProcess/API/Cocoa/WKWebView.mm: (selectionAttributes): (-[WKWebView _didChangeEditorState]): (-[WKWebView _selectionAttributes]): Make the new SPI property support KVO by invoking `-willChangeValueForKey:` and `-didChangeValueForKey:` whenever the selection attributes change. * UIProcess/API/Cocoa/WKWebViewPrivate.h: * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::platformEditorState const): Tools: Add an API test to verify that an SPI client can observe changes in the `@"_selectionAttributes"` key path on WKWebView, and that inserting text, deleting, and changing the selection cause selection attributes to change as expected. * TestWebKitAPI/EditingTestHarness.h: * TestWebKitAPI/EditingTestHarness.mm: (-[EditingTestHarness moveBackward]): (-[EditingTestHarness moveForward]): (-[EditingTestHarness moveForwardAndExpectEditorStateWith:]): Add a couple of new helper methods on EditingTestHarness. * TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm: (-[SelectionChangeObserver initWithWebView:]): (-[SelectionChangeObserver webView]): (-[SelectionChangeObserver observeValueForKeyPath:ofObject:change:context:]): (-[SelectionChangeObserver currentSelectionAttributes]): Canonical link: https://commits.webkit.org/207910@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239931 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-14 20:09:58 +00:00
- (void)moveBackward
{
[self moveBackwardAndExpectEditorStateWith:nil];
}
- (void)moveForward
{
[self moveForwardAndExpectEditorStateWith:nil];
}
[iOS WK2] WKWebView schedules nonstop layout after pressing cmb+b,i,u inside a contenteditable div https://bugs.webkit.org/show_bug.cgi?id=175116 <rdar://problem/28279301> Reviewed by Darin Adler and Ryosuke Niwa. Source/WebCore: WebCore support for WebPage::editorState refactoring. See WebKit ChangeLogs for more detail. Tests: EditorStateTests.TypingAttributesBold EditorStateTests.TypingAttributesItalic EditorStateTests.TypingAttributesUnderline EditorStateTests.TypingAttributesTextAlignmentAbsoluteAlignmentOptions EditorStateTests.TypingAttributesTextAlignmentStartEnd EditorStateTests.TypingAttributesTextAlignmentDirectionalText EditorStateTests.TypingAttributesTextColor EditorStateTests.TypingAttributesMixedStyles EditorStateTests.TypingAttributesLinkColor * css/StyleProperties.cpp: (WebCore::StyleProperties::propertyAsColor const): (WebCore::StyleProperties::propertyAsValueID const): Introduces some helper functions in StyleProperties to convert CSS property values to Color or a CSSValueID. * css/StyleProperties.h: * editing/EditingStyle.cpp: (WebCore::EditingStyle::hasStyle): Pull out logic in selectionStartHasStyle that asks for a style TriState into EditingStyle::hasStyle. This is because WebPage::editorState will now query for multiple styles at the selection start, but selectionStartHasStyle currently recomputes styleAtSelectionStart every time it is called. To prevent extra work from being done, we can just call selectionStartHasStyle once and use ask for EditingStyle::hasStyle on the computed EditingStyle at selection start. * editing/EditingStyle.h: * editing/Editor.cpp: (WebCore::Editor::selectionStartHasStyle const): Source/WebKit: Refactors WebPage::editorState to only use the StyleProperties derived from EditingStyle, instead of inserting and removing a temporary node to figure out the style. Also adds hooks to notify the UI delegate of EditorState changes. * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: * UIProcess/API/Cocoa/WKWebView.mm: (nsTextAlignment): (dictionaryRepresentationForEditorState): (-[WKWebView _didChangeEditorState]): Alerts the private UI delegate of UI-side EditorState updates. (-[WKWebView _web_editorStateDidChange]): (-[WKWebView _executeEditCommand:argument:completion:]): * UIProcess/API/Cocoa/WKWebViewInternal.h: * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/API/mac/WKView.mm: (-[WKView _web_editorStateDidChange]): * UIProcess/Cocoa/WebViewImpl.h: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::selectionDidChange): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::executeEditCommand): Change executeEditCommand(name, callback) to executeEditCommand(name, argument, callback) and lift out of iOS platform code and into WebPage.cpp. * UIProcess/WebPageProxy.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView executeEditCommandWithCallback:]): (-[WKContentView _selectionChanged]): * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::executeEditCommand): Deleted. Move the iOS-specific implementation of executeEditCommand that invokes a callback when the web process responds out of WebPageProxyIOS, and into cross-platform WebPageProxy code. Additionally, add a parameter for the edit command's argument. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::editorState const): Use EditingStyle::styleAtSelectionStart instead of Editor::styleForSelectionStart when computing an EditorState. Tweak bold, italic and underline to use EditingStyle TriStates. (WebKit::WebPage::executeEditCommandWithCallback): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::executeEditCommandWithCallback): Deleted. Tools: Introduces new testing infrastructure and API tests to test EditorState updates in the UI process. The new EditorStateTests run on both iOS and Mac. * TestWebKitAPI/EditingTestHarness.h: Added. * TestWebKitAPI/EditingTestHarness.mm: Added. EditingTestHarness is a helper object that API tests may use to apply editing commands and store EditorState history. This test harness adds sugaring around various editing commands, and simplifies the process of checking the state of the latest observed EditorState. (-[EditingTestHarness initWithWebView:]): (-[EditingTestHarness dealloc]): (-[EditingTestHarness webView]): (-[EditingTestHarness latestEditorState]): (-[EditingTestHarness editorStateHistory]): (-[EditingTestHarness insertText:andExpectEditorStateWith:]): (-[EditingTestHarness insertHTML:andExpectEditorStateWith:]): (-[EditingTestHarness selectAllAndExpectEditorStateWith:]): (-[EditingTestHarness moveBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness moveWordBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness toggleBold]): (-[EditingTestHarness toggleItalic]): (-[EditingTestHarness toggleUnderline]): (-[EditingTestHarness setForegroundColor:]): (-[EditingTestHarness alignJustifiedAndExpectEditorStateWith:]): (-[EditingTestHarness alignLeftAndExpectEditorStateWith:]): (-[EditingTestHarness alignCenterAndExpectEditorStateWith:]): (-[EditingTestHarness alignRightAndExpectEditorStateWith:]): (-[EditingTestHarness insertParagraphAndExpectEditorStateWith:]): (-[EditingTestHarness deleteBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness _execCommand:argument:expectEntries:]): Dispatches an editing command to the web process, and blocks until a response is received. If an expected entries dictionary is given, this will additionally verify that the latest EditorState contains all the expected keys and values. (-[EditingTestHarness latestEditorStateContains:]): (-[EditingTestHarness _webView:editorStateDidChange:]): * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit2Cocoa/EditorStateTests.mm: Added. (TestWebKitAPI::setUpEditorStateTestHarness): (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKit2Cocoa/editor-state-test-harness.html: Added. LayoutTests: * platform/ios-wk2/editing/style/unbold-in-bold-expected.txt: * platform/mac-wk2/editing/style/unbold-in-bold-expected.txt: Rebaseline a WK2 LayoutTest expectations. This test currently expects an empty anonymous RenderBlock to be inserted into the render tree, but this is only a result of us adding and removing a temporary <span> when computing a RenderStyle in WebPage::editorState -- this patch removes these empty RenderBlocks, making these expectations' RenderTrees consistent with WebKit1. Canonical link: https://commits.webkit.org/192520@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221065 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-23 03:16:55 +00:00
- (void)insertText:(NSString *)text andExpectEditorStateWith:(NSDictionary<NSString *, id> *)entries
{
[self _execCommand:@"InsertText" argument:text expectEntries:entries];
}
- (void)insertHTML:(NSString *)html andExpectEditorStateWith:(NSDictionary<NSString *, id> *)entries
{
[self _execCommand:@"InsertHTML" argument:html expectEntries:entries];
}
- (void)selectAllAndExpectEditorStateWith:(NSDictionary<NSString *, id> *)entries
{
[self _execCommand:@"SelectAll" argument:nil expectEntries:entries];
}
- (void)moveBackwardAndExpectEditorStateWith:(NSDictionary<NSString *, id> *)entries
{
[self _execCommand:@"MoveBackward" argument:nil expectEntries:entries];
}
- (void)moveWordBackwardAndExpectEditorStateWith:(NSDictionary<NSString *, id> *)entries
{
[self _execCommand:@"MoveWordBackward" argument:nil expectEntries:entries];
}
[iOS] Expose SPI to access the current sentence boundary and selection state https://bugs.webkit.org/show_bug.cgi?id=193398 <rdar://problem/45893108> Reviewed by Dean Jackson. Source/WebKit: Expose SPI on WKWebView for internal clients to grab information about attributes at the current selection; so far, this only includes whether the selection is a caret or a range, and whether or not the start of the selection is at the start of a new sentence. Test: EditorStateTests.ObserveSelectionAttributeChanges * Shared/EditorState.cpp: (WebKit::EditorState::PostLayoutData::encode const): (WebKit::EditorState::PostLayoutData::decode): * Shared/EditorState.h: Add a new bit in EditorState on iOS to compute whether or not the start of the selection is at the start of a new sentence. This is computed and set when sending post-layout data in `WebPageIOS.mm`. * UIProcess/API/Cocoa/WKWebView.mm: (selectionAttributes): (-[WKWebView _didChangeEditorState]): (-[WKWebView _selectionAttributes]): Make the new SPI property support KVO by invoking `-willChangeValueForKey:` and `-didChangeValueForKey:` whenever the selection attributes change. * UIProcess/API/Cocoa/WKWebViewPrivate.h: * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::platformEditorState const): Tools: Add an API test to verify that an SPI client can observe changes in the `@"_selectionAttributes"` key path on WKWebView, and that inserting text, deleting, and changing the selection cause selection attributes to change as expected. * TestWebKitAPI/EditingTestHarness.h: * TestWebKitAPI/EditingTestHarness.mm: (-[EditingTestHarness moveBackward]): (-[EditingTestHarness moveForward]): (-[EditingTestHarness moveForwardAndExpectEditorStateWith:]): Add a couple of new helper methods on EditingTestHarness. * TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm: (-[SelectionChangeObserver initWithWebView:]): (-[SelectionChangeObserver webView]): (-[SelectionChangeObserver observeValueForKeyPath:ofObject:change:context:]): (-[SelectionChangeObserver currentSelectionAttributes]): Canonical link: https://commits.webkit.org/207910@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239931 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-14 20:09:58 +00:00
- (void)moveForwardAndExpectEditorStateWith:(NSDictionary<NSString *, id> *)entries
{
[self _execCommand:@"MoveForward" argument:nil expectEntries:entries];
}
[iOS WK2] WKWebView schedules nonstop layout after pressing cmb+b,i,u inside a contenteditable div https://bugs.webkit.org/show_bug.cgi?id=175116 <rdar://problem/28279301> Reviewed by Darin Adler and Ryosuke Niwa. Source/WebCore: WebCore support for WebPage::editorState refactoring. See WebKit ChangeLogs for more detail. Tests: EditorStateTests.TypingAttributesBold EditorStateTests.TypingAttributesItalic EditorStateTests.TypingAttributesUnderline EditorStateTests.TypingAttributesTextAlignmentAbsoluteAlignmentOptions EditorStateTests.TypingAttributesTextAlignmentStartEnd EditorStateTests.TypingAttributesTextAlignmentDirectionalText EditorStateTests.TypingAttributesTextColor EditorStateTests.TypingAttributesMixedStyles EditorStateTests.TypingAttributesLinkColor * css/StyleProperties.cpp: (WebCore::StyleProperties::propertyAsColor const): (WebCore::StyleProperties::propertyAsValueID const): Introduces some helper functions in StyleProperties to convert CSS property values to Color or a CSSValueID. * css/StyleProperties.h: * editing/EditingStyle.cpp: (WebCore::EditingStyle::hasStyle): Pull out logic in selectionStartHasStyle that asks for a style TriState into EditingStyle::hasStyle. This is because WebPage::editorState will now query for multiple styles at the selection start, but selectionStartHasStyle currently recomputes styleAtSelectionStart every time it is called. To prevent extra work from being done, we can just call selectionStartHasStyle once and use ask for EditingStyle::hasStyle on the computed EditingStyle at selection start. * editing/EditingStyle.h: * editing/Editor.cpp: (WebCore::Editor::selectionStartHasStyle const): Source/WebKit: Refactors WebPage::editorState to only use the StyleProperties derived from EditingStyle, instead of inserting and removing a temporary node to figure out the style. Also adds hooks to notify the UI delegate of EditorState changes. * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: * UIProcess/API/Cocoa/WKWebView.mm: (nsTextAlignment): (dictionaryRepresentationForEditorState): (-[WKWebView _didChangeEditorState]): Alerts the private UI delegate of UI-side EditorState updates. (-[WKWebView _web_editorStateDidChange]): (-[WKWebView _executeEditCommand:argument:completion:]): * UIProcess/API/Cocoa/WKWebViewInternal.h: * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/API/mac/WKView.mm: (-[WKView _web_editorStateDidChange]): * UIProcess/Cocoa/WebViewImpl.h: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::selectionDidChange): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::executeEditCommand): Change executeEditCommand(name, callback) to executeEditCommand(name, argument, callback) and lift out of iOS platform code and into WebPage.cpp. * UIProcess/WebPageProxy.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView executeEditCommandWithCallback:]): (-[WKContentView _selectionChanged]): * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::executeEditCommand): Deleted. Move the iOS-specific implementation of executeEditCommand that invokes a callback when the web process responds out of WebPageProxyIOS, and into cross-platform WebPageProxy code. Additionally, add a parameter for the edit command's argument. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::editorState const): Use EditingStyle::styleAtSelectionStart instead of Editor::styleForSelectionStart when computing an EditorState. Tweak bold, italic and underline to use EditingStyle TriStates. (WebKit::WebPage::executeEditCommandWithCallback): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::executeEditCommandWithCallback): Deleted. Tools: Introduces new testing infrastructure and API tests to test EditorState updates in the UI process. The new EditorStateTests run on both iOS and Mac. * TestWebKitAPI/EditingTestHarness.h: Added. * TestWebKitAPI/EditingTestHarness.mm: Added. EditingTestHarness is a helper object that API tests may use to apply editing commands and store EditorState history. This test harness adds sugaring around various editing commands, and simplifies the process of checking the state of the latest observed EditorState. (-[EditingTestHarness initWithWebView:]): (-[EditingTestHarness dealloc]): (-[EditingTestHarness webView]): (-[EditingTestHarness latestEditorState]): (-[EditingTestHarness editorStateHistory]): (-[EditingTestHarness insertText:andExpectEditorStateWith:]): (-[EditingTestHarness insertHTML:andExpectEditorStateWith:]): (-[EditingTestHarness selectAllAndExpectEditorStateWith:]): (-[EditingTestHarness moveBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness moveWordBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness toggleBold]): (-[EditingTestHarness toggleItalic]): (-[EditingTestHarness toggleUnderline]): (-[EditingTestHarness setForegroundColor:]): (-[EditingTestHarness alignJustifiedAndExpectEditorStateWith:]): (-[EditingTestHarness alignLeftAndExpectEditorStateWith:]): (-[EditingTestHarness alignCenterAndExpectEditorStateWith:]): (-[EditingTestHarness alignRightAndExpectEditorStateWith:]): (-[EditingTestHarness insertParagraphAndExpectEditorStateWith:]): (-[EditingTestHarness deleteBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness _execCommand:argument:expectEntries:]): Dispatches an editing command to the web process, and blocks until a response is received. If an expected entries dictionary is given, this will additionally verify that the latest EditorState contains all the expected keys and values. (-[EditingTestHarness latestEditorStateContains:]): (-[EditingTestHarness _webView:editorStateDidChange:]): * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit2Cocoa/EditorStateTests.mm: Added. (TestWebKitAPI::setUpEditorStateTestHarness): (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKit2Cocoa/editor-state-test-harness.html: Added. LayoutTests: * platform/ios-wk2/editing/style/unbold-in-bold-expected.txt: * platform/mac-wk2/editing/style/unbold-in-bold-expected.txt: Rebaseline a WK2 LayoutTest expectations. This test currently expects an empty anonymous RenderBlock to be inserted into the render tree, but this is only a result of us adding and removing a temporary <span> when computing a RenderStyle in WebPage::editorState -- this patch removes these empty RenderBlocks, making these expectations' RenderTrees consistent with WebKit1. Canonical link: https://commits.webkit.org/192520@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221065 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-23 03:16:55 +00:00
- (void)toggleBold
{
[self _execCommand:@"ToggleBold" argument:nil expectEntries:nil];
}
- (void)toggleItalic
{
[self _execCommand:@"ToggleItalic" argument:nil expectEntries:nil];
}
- (void)toggleUnderline
{
[self _execCommand:@"ToggleUnderline" argument:nil expectEntries:nil];
}
- (void)setForegroundColor:(NSString *)colorAsString
{
[self _execCommand:@"ForeColor" argument:colorAsString expectEntries:nil];
}
- (void)alignJustifiedAndExpectEditorStateWith:(NSDictionary<NSString *, id> *)entries
{
[self _execCommand:@"AlignJustified" argument:nil expectEntries:entries];
}
- (void)alignLeftAndExpectEditorStateWith:(NSDictionary<NSString *, id> *)entries
{
[self _execCommand:@"AlignLeft" argument:nil expectEntries:entries];
}
- (void)alignCenterAndExpectEditorStateWith:(NSDictionary<NSString *, id> *)entries
{
[self _execCommand:@"AlignCenter" argument:nil expectEntries:entries];
}
- (void)alignRightAndExpectEditorStateWith:(NSDictionary<NSString *, id> *)entries
{
[self _execCommand:@"AlignRight" argument:nil expectEntries:entries];
}
- (void)insertParagraphAndExpectEditorStateWith:(NSDictionary<NSString *, id> *)entries
{
[self _execCommand:@"InsertParagraph" argument:nil expectEntries:entries];
}
- (void)deleteBackwardAndExpectEditorStateWith:(NSDictionary<NSString *, id> *)entries
{
[self _execCommand:@"DeleteBackward" argument:nil expectEntries:entries];
}
- (void)_execCommand:(NSString *)command argument:(NSString *)argument expectEntries:(NSDictionary<NSString *, id> *)entries
{
__block BOOL result = false;
__block bool done = false;
[_webView _executeEditCommand:command argument:argument completion:^(BOOL success) {
result = success;
done = true;
}];
TestWebKitAPI::Util::run(&done);
EXPECT_TRUE(result);
if (!result)
NSLog(@"Failed to execute editing command: ('%@', '%@')", command, argument ?: @"");
const NSTimeInterval loggingTimeout = 3;
auto startTime = retainPtr([NSDate date]);
BOOL hasLoggedWarning = NO;
BOOL containsEntries;
do {
[_webView waitForNextPresentationUpdate];
containsEntries = [self latestEditorStateContains:entries];
if (!hasLoggedWarning && [[NSDate date] timeIntervalSinceDate:startTime.get()] > loggingTimeout) {
NSLog(@"Expected %@ to contain %@", self.latestEditorState, entries);
hasLoggedWarning = YES;
}
} while (!containsEntries);
[iOS WK2] WKWebView schedules nonstop layout after pressing cmb+b,i,u inside a contenteditable div https://bugs.webkit.org/show_bug.cgi?id=175116 <rdar://problem/28279301> Reviewed by Darin Adler and Ryosuke Niwa. Source/WebCore: WebCore support for WebPage::editorState refactoring. See WebKit ChangeLogs for more detail. Tests: EditorStateTests.TypingAttributesBold EditorStateTests.TypingAttributesItalic EditorStateTests.TypingAttributesUnderline EditorStateTests.TypingAttributesTextAlignmentAbsoluteAlignmentOptions EditorStateTests.TypingAttributesTextAlignmentStartEnd EditorStateTests.TypingAttributesTextAlignmentDirectionalText EditorStateTests.TypingAttributesTextColor EditorStateTests.TypingAttributesMixedStyles EditorStateTests.TypingAttributesLinkColor * css/StyleProperties.cpp: (WebCore::StyleProperties::propertyAsColor const): (WebCore::StyleProperties::propertyAsValueID const): Introduces some helper functions in StyleProperties to convert CSS property values to Color or a CSSValueID. * css/StyleProperties.h: * editing/EditingStyle.cpp: (WebCore::EditingStyle::hasStyle): Pull out logic in selectionStartHasStyle that asks for a style TriState into EditingStyle::hasStyle. This is because WebPage::editorState will now query for multiple styles at the selection start, but selectionStartHasStyle currently recomputes styleAtSelectionStart every time it is called. To prevent extra work from being done, we can just call selectionStartHasStyle once and use ask for EditingStyle::hasStyle on the computed EditingStyle at selection start. * editing/EditingStyle.h: * editing/Editor.cpp: (WebCore::Editor::selectionStartHasStyle const): Source/WebKit: Refactors WebPage::editorState to only use the StyleProperties derived from EditingStyle, instead of inserting and removing a temporary node to figure out the style. Also adds hooks to notify the UI delegate of EditorState changes. * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: * UIProcess/API/Cocoa/WKWebView.mm: (nsTextAlignment): (dictionaryRepresentationForEditorState): (-[WKWebView _didChangeEditorState]): Alerts the private UI delegate of UI-side EditorState updates. (-[WKWebView _web_editorStateDidChange]): (-[WKWebView _executeEditCommand:argument:completion:]): * UIProcess/API/Cocoa/WKWebViewInternal.h: * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/API/mac/WKView.mm: (-[WKView _web_editorStateDidChange]): * UIProcess/Cocoa/WebViewImpl.h: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::selectionDidChange): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::executeEditCommand): Change executeEditCommand(name, callback) to executeEditCommand(name, argument, callback) and lift out of iOS platform code and into WebPage.cpp. * UIProcess/WebPageProxy.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView executeEditCommandWithCallback:]): (-[WKContentView _selectionChanged]): * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::executeEditCommand): Deleted. Move the iOS-specific implementation of executeEditCommand that invokes a callback when the web process responds out of WebPageProxyIOS, and into cross-platform WebPageProxy code. Additionally, add a parameter for the edit command's argument. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::editorState const): Use EditingStyle::styleAtSelectionStart instead of Editor::styleForSelectionStart when computing an EditorState. Tweak bold, italic and underline to use EditingStyle TriStates. (WebKit::WebPage::executeEditCommandWithCallback): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::executeEditCommandWithCallback): Deleted. Tools: Introduces new testing infrastructure and API tests to test EditorState updates in the UI process. The new EditorStateTests run on both iOS and Mac. * TestWebKitAPI/EditingTestHarness.h: Added. * TestWebKitAPI/EditingTestHarness.mm: Added. EditingTestHarness is a helper object that API tests may use to apply editing commands and store EditorState history. This test harness adds sugaring around various editing commands, and simplifies the process of checking the state of the latest observed EditorState. (-[EditingTestHarness initWithWebView:]): (-[EditingTestHarness dealloc]): (-[EditingTestHarness webView]): (-[EditingTestHarness latestEditorState]): (-[EditingTestHarness editorStateHistory]): (-[EditingTestHarness insertText:andExpectEditorStateWith:]): (-[EditingTestHarness insertHTML:andExpectEditorStateWith:]): (-[EditingTestHarness selectAllAndExpectEditorStateWith:]): (-[EditingTestHarness moveBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness moveWordBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness toggleBold]): (-[EditingTestHarness toggleItalic]): (-[EditingTestHarness toggleUnderline]): (-[EditingTestHarness setForegroundColor:]): (-[EditingTestHarness alignJustifiedAndExpectEditorStateWith:]): (-[EditingTestHarness alignLeftAndExpectEditorStateWith:]): (-[EditingTestHarness alignCenterAndExpectEditorStateWith:]): (-[EditingTestHarness alignRightAndExpectEditorStateWith:]): (-[EditingTestHarness insertParagraphAndExpectEditorStateWith:]): (-[EditingTestHarness deleteBackwardAndExpectEditorStateWith:]): (-[EditingTestHarness _execCommand:argument:expectEntries:]): Dispatches an editing command to the web process, and blocks until a response is received. If an expected entries dictionary is given, this will additionally verify that the latest EditorState contains all the expected keys and values. (-[EditingTestHarness latestEditorStateContains:]): (-[EditingTestHarness _webView:editorStateDidChange:]): * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit2Cocoa/EditorStateTests.mm: Added. (TestWebKitAPI::setUpEditorStateTestHarness): (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKit2Cocoa/editor-state-test-harness.html: Added. LayoutTests: * platform/ios-wk2/editing/style/unbold-in-bold-expected.txt: * platform/mac-wk2/editing/style/unbold-in-bold-expected.txt: Rebaseline a WK2 LayoutTest expectations. This test currently expects an empty anonymous RenderBlock to be inserted into the render tree, but this is only a result of us adding and removing a temporary <span> when computing a RenderStyle in WebPage::editorState -- this patch removes these empty RenderBlocks, making these expectations' RenderTrees consistent with WebKit1. Canonical link: https://commits.webkit.org/192520@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221065 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-23 03:16:55 +00:00
}
- (BOOL)latestEditorStateContains:(NSDictionary<NSString *, id> *)entries
{
NSDictionary *latestEditorState = self.latestEditorState;
for (NSString *key in entries) {
if (![latestEditorState[key] isEqual:entries[key]])
return NO;
}
return latestEditorState.count || !entries.count;
}
#pragma mark - WKUIDelegatePrivate
- (void)_webView:(WKWebView *)webView editorStateDidChange:(NSDictionary *)editorState
{
if (![editorState[@"post-layout-data"] boolValue])
return;
if (![self.latestEditorState isEqualToDictionary:editorState])
[_editorStateHistory addObject:editorState];
}
@end