Remove live ranges from Editor.h and EditorClient.h
https://bugs.webkit.org/show_bug.cgi?id=214261

Reviewed by Sam Weinig.

Source/WebCore:

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::misspellingRange const): Update since
rangeForTextCheckingResult no longer returns a live range.
(WebCore::AccessibilityObject::rangeOfStringClosestToRangeInDirection const):
Update since rangeOfString no longer returns a live range.

* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(accessibilityTextOperationForParameterizedAttribute): Use makeSimpleRange.

* dom/Document.cpp:
(WebCore::acceptsEditingFocus): Use makeRangeSelectingNodeContents
since shouldBeginEditing no longer takes a live range.

* dom/Range.h: Exxported makeSimpleRange for use outside WebCore.

* dom/SimpleRange.cpp:
(WebCore::makeSimpleRange): Added. Takes two optional boundary points and
returns an optional range.
* dom/SimpleRange.h: Added the above.

* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::timerFired): Removed calls to
crateLiveRange since markAllMisspellingsAndBadGrammarInRanges no
longer takes live ranges.
(WebCore::AlternativeTextController::applyDictationAlternative):
Updates since shouldInsertText no longer takes a live range.

* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::mergeParagraphs): Updated since
shouldMoveRangeAfterDelete no longer takes live ranges.

* editing/Editor.cpp:
(WebCore::Editor::canDeleteRange const): Updated to not take a
live range.
(WebCore::Editor::deleteWithDirection): Updated since
addRangeToKillRing no longer takes a live range.
(WebCore::Editor::pasteAsPlainTextWithPasteboard): Updated since
shouldInsertText no longer takes a live range.
(WebCore::Editor::shouldInsertFragment): No longer take a live range.
(WebCore::Editor::replaceSelectionWithText): Updated since
selectedRange no longer returns a live range.
(WebCore::Editor::selectedRange): Do not return a live range.
(WebCore::Editor::shouldDeleteRange const): Do not take a live range.
(WebCore::Editor::shouldInsertText const): Ditto.
(WebCore::Editor::shouldApplyStyle): Ditto. Also take a const& to
the style instead of a non-const*.
(WebCore::Editor::applyStyleToSelection): Pass a style reference
and a non-live range.
(WebCore::Editor::applyParagraphStyleToSelection): Updated for
the change above.
(WebCore::Editor::insertTextWithoutSendingTextEvent): No need to
pass a live range any more.
(WebCore::Editor::insertLineBreak): Ditto.
(WebCore::Editor::insertParagraphSeparator): Ditto.
(WebCore::Editor::performCutOrCopy): Updated to not use live range.
(WebCore::Editor::performDelete): Ditto.
(WebCore::Editor::shouldEndEditing): Do not take a live range.
(WebCore::Editor::shouldBeginEditing): Ditto.
(WebCore::Editor::willWriteSelectionToPasteboard): Ditto.
(WebCore::Editor::selectComposition): Update since compositionRange
is not a live range.
(WebCore::Editor::markMisspellingsAfterTypingToWord): Update since
we don't need to pass live ranges to markAllMisspellingsAndBadGrammarInRanges.
(WebCore::Editor::markMisspellingsOrBadGrammar): Don't return a
live range in tthe out argument.
(WebCore::Editor::markMisspellings): Ditto.
(WebCore::Editor::markBadGrammar): Update for the above.
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): Do not
take live ranges for the arguments.
(WebCore::Editor::replaceRangeForSpellChecking): Do not take a live range.
(WebCore::Editor::markAndReplaceFor): Update since shouldInsertText does
not take a live range any more.
(WebCore::Editor::changeBackToReplacedString): Update to not use live
ranges as much.
(WebCore::Editor::markMisspellingsAndBadGrammar): Updae since
we don't need to pass live ranges to markAllMisspellingsAndBadGrammarInRanges.
(WebCore::Editor::rangeForPoint): Don't return a live range.
(WebCore::Editor::compositionRange const): Ditto.
(WebCore::Editor::transpose): Updated since we don't pass a live range.
(WebCore::Editor::firstRectForRange const): Don't take a live range.
(WebCore::Editor::shouldChangeSelection const): Updated since we don't
need to pass a live range.
(WebCore::Editor::findString): Ditto.
(WebCore::start): Added. Helper to make rangeOfString easier to read.
(WebCore::end): Ditto.
(WebCore::makeBoundaryPointAfterNodeContents): Ditto.
(WebCore::makeBoundaryPointAfterNode): Ditto.
(WebCore::collapseIfRootsDiffer): Ditto.
(WebCore::Editor::rangeOfString): Updated to not take or return a
live range and not use it internally either.
(WebCore::isFrameInRange): Don't take a live range.
(WebCore::Editor::countMatchesForText): Don't take or return live ranges.
(WebCore::Editor::contextRangeForCandidateRequest const): Don't return
a live range.
(WebCore::Editor::rangeForTextCheckingResult const): Ditto.
(WebCore::Editor::handleAcceptedCandidate): Update for the above.
(WebCore::Editor::adjustedSelectionRange): Don't return a live range.

* editing/Editor.h: Updated for all the chagnes above.

* editing/EditorCommand.cpp:
(WebCore::expandSelectionToGranularity): Updated to reduce the use of
live ranges.
(WebCore::unionRanges): Updated to no longer take or return a live
range. Still uses live ranges in the algorithm for now.
(WebCore::executeDeleteToMark): Updated since selectedRange no longer
returns a live range.
(WebCore::executeSelectToMark): Update to use the new unionRanges.

* editing/FrameSelection.cpp:
(WebCore::FrameSelection::shouldDeleteSelection const): Updated
since shouldDeleteRange no longer requires a live range.

* editing/cocoa/EditorCocoa.mm:
(WebCore::Editor::getPasteboardTypesAndDataForAttachment): Updated
for changes to use fewer live ranges.
(WebCore::Editor::writeSelectionToPasteboard): Ditto.
(WebCore::Editor::writeSelection): Ditto.
(WebCore::Editor::replaceSelectionWithAttributedString): Ditto.
* editing/gtk/EditorGtk.cpp:
(WebCore::Editor::pasteWithPasteboard): Ditto.
* editing/ios/EditorIOS.mm:
(WebCore::Editor::writeImageToPasteboard): Ditto.
(WebCore::Editor::pasteWithPasteboard): Ditto.
* editing/libwpe/EditorLibWPE.cpp:
(WebCore::createFragmentFromPasteboardData): Ditto.
(WebCore::Editor::pasteWithPasteboard): Ditto.
* editing/mac/EditorMac.mm:
(WebCore::Editor::pasteWithPasteboard): Ditto.
(WebCore::Editor::replaceNodeFromPasteboard): Ditto.
(WebCore::Editor::dataSelectionForPasteboard): Ditto.
* editing/win/EditorWin.cpp:
(WebCore::Editor::pasteWithPasteboard): Ditto.

* html/FTPDirectoryDocument.cpp:
(WebCore::FTPDirectoryDocumentParser::createTDForFilename):
Removed a WTFMove that messes up the return value optimization.
Noticed while fixing errors caused by live range changes.

* loader/EmptyClients.cpp: Updated for changes to EditorClient.

* page/ContextMenuController.cpp:
(WebCore::insertUnicodeCharacter): Updated to use fewer live ranges.
(WebCore::ContextMenuController::contextMenuItemSelected): DItto.
* page/DragController.cpp:
(WebCore::DragController::concludeEditDrag): Ditto.
(WebCore::DragController::startDrag): Ditto.

* page/EditorClient.h: Don't take or return live ranges.

* page/EventHandler.cpp:
(WebCore::EventHandler::sendContextMenuEventForKey): Simplified
since we don't need to use a live range.

* page/FocusController.cpp:
(WebCore::relinquishesEditingFocus): Changed argument type to be
more specific, and changed to not use a live range.
(WebCore::FocusController::setFocusedElement): Updated for the above.

* page/Frame.cpp:
(WebCore::Frame::rangeForPoint): Updated to not use live ranges.

* page/Page.cpp:
(WebCore::Page::findStringMatchingRanges): Updated to not use
live ranges as much.
(WebCore::Page::rangeOfString): Ditto.
(WebCore::Page::findMatchesForText): Ditto.

* testing/Internals.cpp:
(WebCore::Internals::rangeOfString): Updated since return value
of the Editor member function is no longer a live range.
(WebCore::Internals::countMatchesForText): Ditto.

Source/WebKit:

* UIProcess/mac/WKPrintingView.mm:
(-[WKPrintingView rectForPage:]): Use NSZeroRect.

* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::shouldDeleteRange): Updated for live
range changes and also removed gratuitous call to notImplemented
since the function is implemented.
(WebKit::WebEditorClient::shouldBeginEditing): Ditto.
(WebKit::WebEditorClient::shouldEndEditing): Ditto.
(WebKit::WebEditorClient::shouldInsertNode): Ditto.
(WebKit::WebEditorClient::shouldInsertText): Ditto.
(WebKit::WebEditorClient::shouldChangeSelectedRange): Ditto.
(WebKit::WebEditorClient::shouldApplyStyle): Ditto.
(WebKit::WebEditorClient::shouldMoveRangeAfterDelete): Ditto.
(WebKit::WebEditorClient::didBeginEditing): Ditto.
(WebKit::WebEditorClient::didEndEditing): Ditto.
(WebKit::WebEditorClient::willWriteSelectionToPasteboard): Ditto.
(WebKit::WebEditorClient::getClientPasteboardData): Ditto.
(WebKit::WebEditorClient::performTwoStepDrop): Ditto.
(WebKit::WebEditorClient::overflowScrollPositionChanged): Ditto.
(WebKit::WebEditorClient::subFrameScrollPositionChanged): Ditto.
(WebKit::WebEditorClient::setInputMethodState): Ditto.

* WebProcess/WebCoreSupport/WebEditorClient.h: Updated
for changes to EditorClient.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::getMarkedRangeAsync): Updated to reduce
the use of local values and live ranges.
(WebKit::WebPage::getSelectedRangeAsync): Ditto.
(WebKit::WebPage::characterIndexForPointAsync): Ditto.
(WebKit::WebPage::firstRectForCharacterRangeAsync): Ditto.
(WebKit::WebPage::setCompositionAsync): Ditto.
* WebProcess/WebPage/glib/WebPageGLib.cpp:
(WebKit::WebPage::getPlatformEditorState const): Ditto.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getPlatformEditorState const): Ditto.
(WebKit::WebPage::selectWithGesture): Ditto.
(WebKit::WebPage::autocorrectionContext): Ditto.
(WebKit::focusedElementPositionInformation): Ditto.
(WebKit::WebPage::requestDocumentEditingContext): Ditto.

Source/WebKitLegacy/ios:

* WebCoreSupport/WebFrameIOS.mm:
(-[WebFrame closestCaretRectInMarkedTextRangeForPoint:]):
Updated since compositionRange is no longer a live range.

Source/WebKitLegacy/mac:

* DOM/DOMRange.mm:
(kit): Added an overload to convert to a live range so we don't have
to touch every call site.
* DOM/DOMRangeInternal.h: Added the above.

* WebCoreSupport/WebEditorClient.h: Updated for changes to EditorClient.

* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::shouldDeleteRange): Changed types to not use live ranges.
(WebEditorClient::shouldApplyStyle): Ditto.
(WebEditorClient::shouldMoveRangeAfterDelete): Ditto.
(WebEditorClient::shouldBeginEditing): Ditto.
(WebEditorClient::shouldEndEditing): Ditto.
(WebEditorClient::shouldInsertText): Ditto.
(WebEditorClient::shouldChangeSelectedRange): Ditto.
(WebEditorClient::willWriteSelectionToPasteboard): Ditto.
(WebEditorClient::getClientPasteboardData): Ditto.
(WebEditorClient::shouldInsertNode): Ditto.
(WebEditorClient::performTwoStepDrop): Ditto.

* WebView/WebFrame.mm:
(-[WebFrame _firstRectForDOMRange:]): Update to not use live range.
(-[WebFrame _scrollDOMRangeToVisible:]): Ditto.
(-[WebFrame _rangeByAlteringCurrentSelection:direction:granularity:]): Ditto.
(-[WebFrame _markDOMRange]): Ditto.
(-[WebFrame _selectionRangeForFirstPoint:secondPoint:]): Ditto.
(-[WebFrame _selectionRangeForPoint:]): Ditto.
(-[WebFrame selectedDOMRange]): Ditto.
(-[WebFrame elementRangeContainingCaretSelection]): Ditto.
(-[WebFrame wordRangeContainingCaretSelection]): Ditto.
(-[WebFrame rangeByMovingCurrentSelection:]): Ditto.
(-[WebFrame rangeByExtendingCurrentSelection:]): Ditto.
(-[WebFrame markedTextDOMRange]): Ditto.

* WebView/WebHTMLView.mm:
(-[WebHTMLView _selectedRange]): Update to not use live range.
(-[WebHTMLView firstRectForCharacterRange:]): Use NSZeroRect.
(-[WebHTMLView countMatchesForText:inDOMRange:options:limit:markMatches:]):
Update to not use live range.
* WebView/WebTextCompletionController.mm:
(-[WebTextCompletionController doCompletion]): Ditto.
* WebView/WebTextIterator.mm:
(-[WebTextIterator currentRange]): Ditto.
* WebView/WebView.mm:
(-[WebView textIteratorForRect:]): Ditto.
(-[WebView editableDOMRangeForPoint:]): Ditto.
(-[WebView selectedDOMRange]): Ditto.

Source/WebKitLegacy/win:

* DOMCoreClasses.cpp:
(DOMWindow::DOMWindow): Added ref for underlying WebCore::DOMWindow.
(DOMWindow::~DOMWindow): Added deref for underlying WebCore::DOMWindow.
(DOMRange::DOMRange): Added ref for underlying live range.
(DOMRange::~DOMRange): Added deref for underlying live range.
(DOMRange::createInstance): Added overload for creating a DOMRange from
a SimpleRange that creates the live range.
(DOMNamedNodeMap::DOMNamedNodeMap): Added ref for underlying live range.
(DOMNamedNodeMap::~DOMNamedNodeMap): Added deref for underlying live range.

* DOMCoreClasses.h: Added createInstance overload as described above.

* WebCoreSupport/WebEditorClient.cpp:
(WebEditorClient::shouldBeginEditing): Updated for changes to not use
live ranges. Also removed unnecessary notImplemented calls.
(WebEditorClient::shouldEndEditing): Ditto.
(WebEditorClient::discardedComposition): Ditto.
(WebEditorClient::canceledComposition): Ditto.
(WebEditorClient::didWriteSelectionToPasteboard): Ditto.
(WebEditorClient::willWriteSelectionToPasteboard): Ditto.
(WebEditorClient::getClientPasteboardData): Ditto.
(WebEditorClient::shouldDeleteRange): Ditto.
(WebEditorClient::shouldInsertNode): Ditto.
(WebEditorClient::shouldInsertText): Ditto.
(WebEditorClient::shouldChangeSelectedRange): Ditto.
(WebEditorClient::shouldApplyStyle): Ditto.
(WebEditorClient::didApplyStyle): Ditto.
(WebEditorClient::shouldMoveRangeAfterDelete): Ditto.

* WebCoreSupport/WebEditorClient.h: Updated for changes to
EditorClient.

* WebView.cpp:
(WebView::prepareCandidateWindow): Updated to not use live ranges.
(WebView::onIMERequestCharPosition): Ditto.
(WebView::compositionRangeForTesting): Ditto.
(WebView::firstRectForCharacterRangeForTesting): Ditto.
(WebView::selectedRangeForTesting): Ditto.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
Removed duplicate install of Ahem.ttf that was leading new versions
of Xcode to fail when trying to build this.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@264692 268f45cc-cd09-0410-ab3c-d52691b4dbfc
56 files changed
tree: 562cca687847dc7e9d719fee192e3c102aa6235f
  1. JSTests/
  2. LayoutTests/
  3. ManualTests/
  4. PerformanceTests/
  5. Source/
  6. Tools/
  7. WebDriverTests/
  8. WebKit.xcworkspace/
  9. WebKitLibraries/
  10. Websites/
  11. .clang-format
  12. .dir-locals.el
  13. .editorconfig
  14. .gitattributes
  15. .gitignore
  16. ChangeLog
  17. ChangeLog-2012-05-22
  18. ChangeLog-2018-01-01
  19. CMakeLists.txt
  20. Makefile
  21. Makefile.shared
  22. ReadMe.md
ReadMe.md

WebKit

WebKit is a cross-platform web browser engine. On iOS and macOS, it powers Safari, Mail, iBooks, and many other applications.

Feature Status

Visit WebKit Feature Status page to see which Web API has been implemented, in development, or under consideration.

Trying the Latest

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.

Reporting Bugs

  1. Search WebKit Bugzilla to see if there is an existing report for the bug you've encountered.
  2. Create a Bugzilla account to to report bugs (and to comment on them) if you haven't done so already.
  3. File a bug in accordance with our guidelines.

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.

Getting the Code

On Windows, follow the instructions on our website.

Cloning the Git SVN Repository

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.

Checking out the Subversion Repository

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

Building WebKit

Building macOS Port

Install Xcode and its command line tools if you haven't done so already:

  1. Install Xcode Get Xcode from https://developer.apple.com/downloads. To build WebKit for OS X, Xcode 5.1.1 or later is required. To build WebKit for iOS Simulator, Xcode 7 or later is required.
  2. Install the Xcode Command Line Tools In Terminal, run the command: 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.

Using Xcode

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.

Building iOS Port

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

Building the GTK+ Port

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.

Building the WPE Port

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

Building Windows Port

For building WebKit on Windows, see the wiki page.

Running WebKit

With Safari and Other macOS Applications

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>

iOS Simulator

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.

Linux Ports

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.

Contribute

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.