commit | 674311db4098da7e06f9469451a7f7fbbfdfce8a | [log] [tgz] |
---|---|---|
author | wenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Tue Oct 02 10:39:40 2018 +0000 |
committer | wenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Tue Oct 02 10:39:40 2018 +0000 |
tree | 2179b1a5b7da5e19b04751bf3c364dfa1cb58728 | |
parent | 5dc0f5eeb9084c4027f39331c4e8a2a369a093ec [diff] |
[macOS] Implement a way for the UI process to request typing attributes at the current selection https://bugs.webkit.org/show_bug.cgi?id=189983 <rdar://problem/44648705> Reviewed by Ryosuke Niwa. Source/WebKit: Implements `-[WKWebView typingAttributesWithCompletionHandler:]`, which asynchronously retrieves an NSDictionary containing the typing attributes at the start of the current selection. This is a new asynchronous text input client hook on macOS that is needed in order to support NSInspectorBar on WKWebView. At a high level, this patch builds on top of refactoring done in r236445 to make it possible to send typing attributes from the web process to the UI process, and then adds plumbing in the WebKit2 client layer to surface typing attributes to WKWebView on macOS. Tests: FontManagerTests.TypingAttributesAfterSubscriptAndSuperscript FontManagerTests.ChangeTypingAttributesWithInspectorBar FontManagerTests.ChangeAttributesWithFontEffectsBox * Platform/spi/mac/AppKitSPI.h: * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<FontAttributes>::encode): (IPC::ArgumentCoder<FontAttributes>::decode): Implement IPC coding support for FontAttributes. * Shared/WebCoreArgumentCoders.h: * Shared/mac/ArgumentCodersMac.h: * Shared/mac/ArgumentCodersMac.mm: (IPC::encode): (IPC::decode): Add the ability to encode and decode UIFont. This allows Cocoa platforms to send `FontAttributes.font` over IPC with a single call to IPC::encode/IPC::decode. * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView typingAttributesWithCompletionHandler:]): Add plumbing to WebViewImpl. * UIProcess/Cocoa/WebViewImpl.h: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::selectionDidChange): Update the NSInspectorBar on selection change, but only if it is present and visible, and WKWebView is currently first responder. (WebKit::WebViewImpl::typingAttributesWithCompletionHandler): Call into WebPageProxy to retrieve FontAttributes from the web process, and invoke the callback with an NSDictionary constructed from the retrieved FontAttributes. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::requestFontAttributesAtSelectionStart): (WebKit::WebPageProxy::fontAttributesCallback): Add plumbing to retrieve FontAttributes from the web process at the current selection. Additionally, cache the font attributes to avoid doing extra work during subsequent requests. (WebKit::WebPageProxy::resetStateAfterProcessExited): * UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::cachedFontAttributesAtSelectionStart const): * UIProcess/WebPageProxy.messages.in: * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::editorStateChanged): * UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::editorStateChanged): Invalidate cached font attributes. * WebKit.xcodeproj/project.pbxproj: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::requestFontAttributesAtSelectionStart): Use the currently focused frame's Editor to compute FontAttributes at the current selection, and send the computed FontAttributes back to the UI process. * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: Tools: Adds new FontManagerTests that exercise -typingAttributesWithCompletionHandler:. See below for more detail. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/TestWebKitAPI/mac/AppKitSPI.h: * TestWebKitAPI/Tests/mac/FontManagerTests.mm: Add a new test that exercises font attribute modification via inspector bar. Also, add a new test that checks typing attributes when using subscript/superscript/unscript. Lastly, augment an existing NSFontPanel test to additionally check that shadowed text and strike-through are reflected in typing attributes. (-[FontManagerTestWKWebView inspectorBarItemIdentifiers]): (-[TestWKWebView typingAttributes]): Add a synchronous wrapper around `-typingAttributesWithCompletionHandler:` by spinning the runloop. (-[TestWKWebView collapseToStart]): (webViewForFontManagerTesting): (TestWebKitAPI::TEST): * TestWebKitAPI/cocoa/TestWKWebView.h: * TestWebKitAPI/mac/TestInspectorBar.h: Copied from Tools/TestWebKitAPI/Tests/TestWebKitAPI/mac/AppKitSPI.h. * TestWebKitAPI/mac/TestInspectorBar.mm: Added. Introduce subclasses of `__InspectorBarItemController` and `NSInspectorBar` for testing inspector bar interaction. (-[TestInspectorBarItemController initWithInspectorBar:]): (-[TestInspectorBarItemController inspectorBar]): (-[TestInspectorBarItemController updateSelectedAttributes]): (-[TestInspectorBar initWithWebView:]): (+[TestInspectorBar standardItemControllerClass]): (+[TestInspectorBar standardTextItemIdentifiers]): (-[TestInspectorBar _setStyleControlSelected:atIndex:]): (-[TestInspectorBar chooseFontSize:]): (-[TestInspectorBar chooseFontFamily:]): (-[TestInspectorBar _chooseColor:inColorWell:]): (-[TestInspectorBar chooseForegroundColor:]): (-[TestInspectorBar chooseBackgroundColor:]): (-[TestInspectorBar formatBold:]): (-[TestInspectorBar formatItalic:]): (-[TestInspectorBar formatUnderline:]): Add helper methods to TestInspectorBar to simulate interacting with various controls (e.g. color wells and font styling controls). (-[TestInspectorBar itemController]): (-[TestInspectorBar setItemController:]): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@236724 268f45cc-cd09-0410-ab3c-d52691b4dbfc
WebKit is a cross-platform web browser engine. On iOS and macOS, it powers Safari, Mail, iBooks, and many other applications.
Visit WebKit Feature Status page to see which Web API has been implemented, in development, or under consideration.
On macOS, download Safari Technology Preview to test the latest version of WebKit. On Linux, download Epiphany Technology Preview. On Windows, you'll have to build it yourself.
Once your bug is filed, you will receive email when it is updated at each stage in the bug life cycle. After the bug is considered fixed, you may be asked to download the latest nightly and confirm that the fix works for you.
On Windows, follow the instructions on our website.
Run the following command to clone WebKit's Git SVN repository:
git clone git://git.webkit.org/WebKit.git WebKit
If you want to be able to commit changes to the repository, or just want to check out branches that aren’t contained in WebKit.git, you will need track WebKit's Subversion repository. You can run the following command to configure this and other options of the new Git clone for WebKit development.
Tools/Scripts/webkit-patch setup-git-clone
For information about this, and other aspects of using Git with WebKit, read the wiki page.
If you don‘t want to use Git, run the following command to check out WebKit’s Subversion repository:
svn checkout https://svn.webkit.org/repository/webkit/trunk WebKit
Install Xcode and its command line tools if you haven't done so already:
xcode-select --install
Run the following command to build a debug build with debugging symbols and assertions:
Tools/Scripts/build-webkit --debug
For performance testing, and other purposes, use --release
instead.
You can open WebKit.xcworkspace
to build and debug WebKit within Xcode.
If you don't use a custom build location in Xcode preferences, you have to update the workspace settings to use WebKitBuild
directory. In menu bar, choose File > Workspace Settings, then click the Advanced button, select “Custom”, “Relative to Workspace”, and enter WebKitBuild
for both Products and Intermediates.
The first time after you install a new Xcode, you will need to run the following command to enable Xcode to build command line tools for iOS Simulator:
sudo Tools/Scripts/configure-xcode-for-ios-development
Without this step, you will see the error message: “target specifies product type ‘com.apple.product-type.tool’, but there’s no such product type for the ‘iphonesimulator’ platform.
” when building target JSCLLIntOffsetsExtractor
of project JavaScriptCore
.
Run the following command to build a debug build with debugging symbols and assertions for iOS:
Tools/Scripts/build-webkit --debug --ios-simulator.
For production builds:
cmake -DPORT=GTK -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ninja sudo ninja install
For development builds:
Tools/gtk/install-dependencies Tools/Scripts/update-webkitgtk-libs Tools/Scripts/build-webkit --gtk --debug
For more information on building WebKitGTK+, see the wiki page.
For production builds:
cmake -DPORT=WPE -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ninja sudo ninja install
For development builds:
Tools/wpe/install-dependencies Tools/Scripts/update-webkitwpe-libs Tools/Scripts/build-webkit --wpe --debug
For building WebKit on Windows, see the wiki page.
Run the following command to launch Safari with your local build of WebKit:
Tools/Scripts/run-safari --debug
The run-safari
script sets the DYLD_FRAMEWORK_PATH
environment variable to point to your build products, and then launches /Applications/Safari.app
. DYLD_FRAMEWORK_PATH
tells the system loader to prefer your build products over the frameworks installed in /System/Library/Frameworks
.
To run other applications with your local build of WebKit, run the following command:
Tools/Scripts/run-webkit-app <application-path>
Run the following command to launch iOS simulator with your local build of WebKit:
run-safari --debug --ios-simulator
In both cases, if you have built release builds instead, use --release
instead of --debug
.
If you have a development build, you can use the run-minibrowser script, e.g.:
run-minibrowser --debug --wpe
Pass one of --gtk
, --jsc-only
, or --wpe
to indicate the port to use.
Congratulations! You’re up and running. Now you can begin coding in WebKit and contribute your fixes and new features to the project. For details on submitting your code to the project, read Contributing Code.