commit | 2e2bfd72277728992ca12449c1ee83280e977bdd | [log] [tgz] |
---|---|---|
author | darin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Wed Jul 29 16:36:40 2020 +0000 |
committer | darin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Wed Jul 29 16:36:40 2020 +0000 |
tree | b96c65bfa0fb56dbf710c079577e8ef6bf844c28 | |
parent | 8cbe197c381318198653028d0153d7e3fff1352c [diff] |
Improve range idioms and other changes to prepare the way for more reduction in live range use https://bugs.webkit.org/show_bug.cgi?id=214882 Reviewed by Sam Weinig. Source/WebCore: * accessibility/AXObjectCache.cpp: (WebCore::AccessibilityReplacedText::AccessibilityReplacedText): Call the VisiblePosition versions of start and end instead of converting to Position and then back to VisiblePosition. (WebCore::AXObjectCache::rangeMatchesTextNearRange): Simplify with makeSimpleRange. (WebCore::AXObjectCache::characterOffsetForPoint): Ditto. * accessibility/AccessibilityObject.cpp: (WebCore::AccessibilityObject::visiblePositionRangeForUnorderedPositions const): Update idiom for creating VisiblePositionRange since it's just a struct now without explicit constructors. (WebCore::AccessibilityObject::positionOfLeftWord const): Ditto. (WebCore::AccessibilityObject::positionOfRightWord const): Ditto. (WebCore::AccessibilityObject::leftLineVisiblePositionRange const): Ditto. (WebCore::AccessibilityObject::rightLineVisiblePositionRange const): Ditto. (WebCore::AccessibilityObject::sentenceForPosition const): Ditto. (WebCore::AccessibilityObject::paragraphForPosition const): Ditto. (WebCore::AccessibilityObject::styleRangeForPosition const): Ditto. (WebCore::AccessibilityObject::visiblePositionRangeForRange const): Ditto. (WebCore::AccessibilityObject::lineRangeForPosition const): Ditto. (WebCore::AccessibilityObject::stringForVisiblePositionRange): Ditto. (WebCore::AccessibilityObject::lengthForVisiblePositionRange const): Ditto. (WebCore::AccessibilityObject::nextSentenceEndPosition const): Ditto. (WebCore::AccessibilityObject::previousSentenceStartPosition const): Ditto. * accessibility/AccessibilityObjectInterface.h: Moved VisiblePositionRange to VisiblePosition.h for wider use. Also removed constructors. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::textUnderElement const): Simplify with makeSimpleRange. (WebCore::AccessibilityRenderObject::linkClickPoint): Ditto. (WebCore::AccessibilityRenderObject::clickPoint): Ditto. (WebCore::AccessibilityRenderObject::visiblePositionRange const): Updated for removal of VisiblePositionRange constructor. (WebCore::AccessibilityRenderObject::visiblePositionRangeForLine const): Remove unnecessary explicit conversion to VisiblePositionRange. * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: (visiblePositionRangeForTextMarkerRange): Added, replacing separate functions for start and end. (-[WebAccessibilityObjectWrapper visiblePositionRangeForTextMarkerRange:]): Simplify using visiblePositionRangeForTextMarkerRange. * dom/Document.cpp: Added include of "Range.h", may not be needed right now, but highly likely to be needed after future live range work. * dom/Node.cpp: Removed include of "Range.h". * dom/Position.h: Added PositionRange. This will be a more efficient alternative to SimpleRange that can avoid computing node offets for positions before and after anchor nodes in some cases. Not used yet. * dom/RadioButtonGroups.cpp: Removed include of "Range.h". * dom/Range.h: Export makeSimpleRange overload now used outside WebCore. * dom/SimpleRange.cpp: (WebCore::makeSimpleRange): Added overloads for ranges that consist of just a single boundary point, so the argument does not have to be passed twice. (WebCore::commonInclusiveAncestor): Added overload so caller can just pass a simple range rather than passing two boundary point container nodes. * dom/SimpleRange.h: Added makeSimpleRange overloads that take one or more argument that can be passed to makeBoundaryPoint or actual boundary points. * dom/StaticRange.cpp: Removed include of "Range.h". * editing/AlternativeTextController.cpp: (WebCore::AlternativeTextController::markPrecedingWhitespaceForDeletedAutocorrectionAfterCommand): Simplify with makeSimpleRange. (WebCore::AlternativeTextController::processMarkersOnTextToBeReplacedByResult): Ditto. * editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::applyBlockStyle): Ditto. * editing/CompositeEditCommand.cpp: (WebCore::stringForVisiblePositionIndexRange): Updated for removal of VisiblePositionRange constructor; also use move to reduce reference count churn a tiny bit. (WebCore::CompositeEditCommand::moveParagraphs): Simplify with makeSimpleRange. * editing/DeleteSelectionCommand.cpp: Added include of "Range.h", may not be needed now, but highly likely to be needed after future live range work. * editing/Editing.cpp: (WebCore::indexForVisiblePosition): Simplify using makeSimpleRange and makeBoundaryPointBeforeNodeContents. * editing/Editor.cpp: (WebCore::Editor::selectedText const): Simplify using VisibleSelection::firstRange. (WebCore::extendSelection): Simplify using makeSimpleRange. (WebCore::Editor::contextRangeForCandidateRequest const): Ditto. (WebCore::Editor::adjustedSelectionRange): Simplify with the new overload of commonInclusiveAncestor. * editing/FrameSelection.cpp: (WebCore::FrameSelection::wordOffsetInRange const): Deleted. Moved the code into the iOS-specific part of WebKitLegacy WebFrame. (WebCore::FrameSelection::spaceFollowsWordInRange const): Deleted. Moved the code into the iOS-specific part of WebKitLegacy WebFrame. (WebCore::FrameSelection::selectionAtSentenceStart const): Merged in with actualSelectionAtSentenceStart. (WebCore::FrameSelection::actualSelectionAtSentenceStart const): Deleted. * editing/FrameSelection.h: Updated for the above deletion. * editing/TextCheckingHelper.cpp: (WebCore::TextCheckingParagraph::offsetTo const): Simplify with makeSimpleRange. * editing/TextManipulationController.cpp: (WebCore::ParagraphContentIterator::ParagraphContentIterator): Simplify with makeSimpleRange. * editing/TypingCommand.cpp: (WebCore::TypingCommand::postTextStateChangeNotificationForDeletion): Pass visibleStart/End instead of converting to Position and back to VisiblePosition. * editing/VisiblePosition.cpp: (WebCore::makeSimpleRange): Added. Converts a VisiblePositionRange into a SimpleRange. * editing/VisiblePosition.h: Moved VisiblePositionRange here. * editing/VisibleSelection.cpp: (WebCore::VisibleSelection::firstRange const): Simplify using makeSimpleRange. (WebCore::VisibleSelection::toNormalizedRange const): Ditto. (WebCore::makeSearchRange): Deleted. This was confusingly named given that it was only used in appendTrailingWhitespace. (WebCore::VisibleSelection::appendTrailingWhitespace): Merged makeSearchRange in here and simplified using makeSimpleRange. * editing/VisibleSelection.h: Added conversion to VisiblePositionRange. Previously this was implemented as a constructor for VisiblePositionRange, but that was a layering inversion since this is built on top of VisiblePosition. * editing/VisibleUnits.cpp: (WebCore::distanceBetweenPositions): Simplified using makeSimpleRange. (WebCore::charactersAroundPosition): Ditto. (WebCore::wordRangeFromPosition): Removed an unhelpful comment. (WebCore::closestWordBoundaryForPosition): Ditto. * editing/cocoa/DataDetection.mm: (WebCore::detectItem): Simplify using makeSimpleRange. (WebCore::searchForLinkRemovingExistingDDLinks): Removed out argument about modifying the DOM. This was used to work around a problem caused by using live ranges. The problem no longer exists because the code does not use live ranges any more. (WebCore::DataDetection::detectContentInRange): Removed the workaround. * editing/cocoa/DictionaryLookup.mm: (WebCore::DictionaryLookup::rangeForSelection): Simplify using makeSimpleRange. (WebCore::DictionaryLookup::rangeAtHitTestResult): Ditto. * editing/cocoa/WebContentReaderCocoa.mm: Added include of "Range.h", may not be needed now, but highly likely to be needed after future live range work. * editing/ios/DictationCommandIOS.cpp: Removed include of "Range.h". * editing/mac/DictionaryLookupLegacy.mm: (WebCore::DictionaryLookup::rangeForSelection): Simplify using makeSimpleRange. (WebCore::DictionaryLookup::rangeAtHitTestResult): Ditto. * editing/mac/EditorMac.mm: Removed include of "Range.h". * editing/markup.cpp: (WebCore::StyledMarkupAccumulator::renderedTextRespectingRange): Simplify using makeSimpleRange. * editing/win/EditorWin.cpp: Added include of "Range.h", may not be needed now, but highly likely to be needed after future live range work. * html/shadow/mac/ImageControlsButtonElementMac.cpp: Removed include of "Range.h". * page/DOMSelection.cpp: (WebCore::DOMSelection::addRange): Call setSelection instead of moveTo. No need to have two functions that do the same thing. * page/EventHandler.cpp: (WebCore::textDistance): Simplify using makeSimpleRange. * page/Frame.cpp: (WebCore::Frame::rangeForPoint): Simplify using makeSimpleRange. * page/TextIndicator.cpp: (WebCore::estimatedBackgroundColorForRange): Simplify using the commonInclusiveAncestor overload that takes a range. (WebCore::initializeIndicator): Ditto. Source/WebKit: * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp: (WKBundleNodeHandleGetRenderRect): Emptied out this unused function and added ASSERT_NOT_REACHED. Later, we can delete this once we deal with any link-time dependencies. I believe Safari may link with this but never calls it. (WKBundleNodeHandleCopyVisibleRange): Ditto. (WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled): Ditto. (WKBundleNodeHandleGetHTMLInputElementAutoFilled): Ditto. (WKBundleNodeHandleGetHTMLInputElementAutoFillButtonEnabled): Ditto. (WKBundleNodeHandleGetHTMLInputElementAutoFillAvailable): Ditto. (WKBundleNodeHandleGetHTMLInputElementAutoFillButtonBounds): Ditto. (WKBundleNodeHandleCopyHTMLTableCellElementCellAbove): Ditto. (WKBundleNodeHandleCopyHTMLFrameElementContentFrame): Ditto. (WKBundleNodeHandleGetHTMLInputElementAutofilled): Ditto. (WKBundleNodeHandleSetHTMLInputElementAutofilled): Ditto. (WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabled): Ditto. * WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm: (WebKit::TextCheckingControllerProxy::annotatedSubstringBetweenPositions): Simplify with makeSimpleRange. * WebProcess/WebPage/glib/WebPageGLib.cpp: Added include of "Range.h", may not be needed right now, but highly likely to be needed after future live range work. * WebProcess/WebPage/ios/WebPageIOS.mm: Ditto. (WebKit::WebPage::selectWithGesture): Simplify with makeSimpleRange. (WebKit::WebPage::requestDocumentEditingContext): Ditto. * WebProcess/WebPage/mac/WebPageMac.mm: (WebKit::WebPage::attributedSubstringForCharacterRangeAsync): Use auto for range to prepare for possible change of type from live range to SimpleRange. Source/WebKitLegacy: * WebKitLegacy.xcodeproj/project.pbxproj: Removed singly-building DOMUIKitExtensions.mm, which also is built in a unified source file. We don't need to build it twice. Source/WebKitLegacy/mac: * WebCoreSupport/WebEditorClient.mm: (insertionPointFromCurrentSelection): Simplify with makeSimpleRange. (WebEditorClient::requestCandidatesForSelection): Ditto. * WebView/WebFrame.mm: (-[WebFrame _convertToDOMRange:rangeIsRelativeTo:]): Get rid of unnecessary construction of a range just to get an end point. (-[WebFrame wordOffsetInRange:]): Moved logic here from VisibleSelection. (-[WebFrame spaceFollowsWordInRange:]): Ditto. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@265044 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
or
git clone https://git.webkit.org/git/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.