Use enum serialization instead of casting to/from uint32_t
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 May 2020 03:45:59 +0000 (03:45 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 May 2020 03:45:59 +0000 (03:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=211885
Source/WebCore:

<rdar://problem/60106629> and <rdar://problem/60107663>

Patch by Alex Christensen <achristensen@webkit.org> on 2020-05-15
Reviewed by Geoffrey Garen.

This doesn't change anything except make stricter checks at IPC boundaries.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::visiblePositionRangeForLine const):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper accessibilityModifySelection:increase:]):
* editing/EditingBehavior.h:
* editing/Editor.cpp:
(WebCore::Editor::shouldSmartDelete):
(WebCore::Editor::deleteWithDirection):
(WebCore::Editor::misspelledWordAtCaretOrRange const):
(WebCore::Editor::guessesForMisspelledOrUngrammatical):
(WebCore::Editor::markMisspellingsAfterTypingToWord):
(WebCore::Editor::markAndReplaceFor):
(WebCore::Editor::handleAcceptedCandidate):
* editing/EditorCommand.cpp:
(WebCore::executeDeleteBackward):
(WebCore::executeDeleteBackwardByDecomposingPreviousCharacter):
(WebCore::executeDeleteForward):
(WebCore::executeDeleteToBeginningOfLine):
(WebCore::executeDeleteToBeginningOfParagraph):
(WebCore::executeDeleteToEndOfLine):
(WebCore::executeDeleteToEndOfParagraph):
(WebCore::executeDeleteWordBackward):
(WebCore::executeDeleteWordForward):
(WebCore::executeForwardDelete):
(WebCore::executeMoveBackward):
(WebCore::executeMoveBackwardAndModifySelection):
(WebCore::executeMoveDown):
(WebCore::executeMoveDownAndModifySelection):
(WebCore::executeMoveForward):
(WebCore::executeMoveForwardAndModifySelection):
(WebCore::executeMoveLeft):
(WebCore::executeMoveLeftAndModifySelection):
(WebCore::executeMoveRight):
(WebCore::executeMoveRightAndModifySelection):
(WebCore::executeMoveToBeginningOfDocument):
(WebCore::executeMoveToBeginningOfDocumentAndModifySelection):
(WebCore::executeMoveToBeginningOfLine):
(WebCore::executeMoveToBeginningOfLineAndModifySelection):
(WebCore::executeMoveToBeginningOfParagraph):
(WebCore::executeMoveToBeginningOfParagraphAndModifySelection):
(WebCore::executeMoveToBeginningOfSentence):
(WebCore::executeMoveToBeginningOfSentenceAndModifySelection):
(WebCore::executeMoveToEndOfDocument):
(WebCore::executeMoveToEndOfDocumentAndModifySelection):
(WebCore::executeMoveToEndOfSentence):
(WebCore::executeMoveToEndOfSentenceAndModifySelection):
(WebCore::executeMoveToEndOfLine):
(WebCore::executeMoveToEndOfLineAndModifySelection):
(WebCore::executeMoveToEndOfParagraph):
(WebCore::executeMoveToEndOfParagraphAndModifySelection):
(WebCore::executeMoveParagraphBackwardAndModifySelection):
(WebCore::executeMoveParagraphForwardAndModifySelection):
(WebCore::executeMoveUp):
(WebCore::executeMoveUpAndModifySelection):
(WebCore::executeMoveWordBackward):
(WebCore::executeMoveWordBackwardAndModifySelection):
(WebCore::executeMoveWordForward):
(WebCore::executeMoveWordForwardAndModifySelection):
(WebCore::executeMoveWordLeft):
(WebCore::executeMoveWordLeftAndModifySelection):
(WebCore::executeMoveWordRight):
(WebCore::executeMoveWordRightAndModifySelection):
(WebCore::executeMoveToLeftEndOfLine):
(WebCore::executeMoveToLeftEndOfLineAndModifySelection):
(WebCore::executeMoveToRightEndOfLine):
(WebCore::executeMoveToRightEndOfLineAndModifySelection):
(WebCore::executeSelectLine):
(WebCore::executeSelectParagraph):
(WebCore::executeSelectSentence):
(WebCore::executeSelectWord):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::FrameSelection):
(WebCore::FrameSelection::willBeModified):
(WebCore::FrameSelection::modifyExtendingRight):
(WebCore::FrameSelection::modifyExtendingForward):
(WebCore::FrameSelection::modifyMovingRight):
(WebCore::FrameSelection::modifyMovingForward):
(WebCore::FrameSelection::modifyExtendingLeft):
(WebCore::FrameSelection::modifyExtendingBackward):
(WebCore::FrameSelection::modifyMovingLeft):
(WebCore::FrameSelection::modifyMovingBackward):
(WebCore::isBoundary):
(WebCore::FrameSelection::textSelectionIntent):
(WebCore::textSelectionWithDirectionAndGranularity):
(WebCore::FrameSelection::modify):
(WebCore::FrameSelection::clear):
(WebCore::FrameSelection::willBeRemovedFromFrame):
(WebCore::FrameSelection::updateAppearance):
(WebCore::FrameSelection::wordSelectionContainingCaretSelection):
(WebCore::FrameSelection::rangeByAlteringCurrentSelection const):
* editing/FrameSelection.h:
* editing/TextGranularity.h:
(): Deleted.
* editing/TypingCommand.cpp:
(WebCore::editActionForTypingCommand):
(WebCore::TypingCommand::deleteKeyPressed):
(WebCore::TypingCommand::forwardDeleteKeyPressed):
(WebCore::TypingCommand::insertTextRunWithoutNewlines):
(WebCore::TypingCommand::insertLineBreak):
(WebCore::TypingCommand::insertParagraphSeparator):
(WebCore::TypingCommand::insertParagraphSeparatorInQuotedContent):
(WebCore::TypingCommand::deleteSelection):
* editing/TypingCommand.h:
* editing/VisibleSelection.cpp:
(WebCore::VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity):
* editing/VisibleSelection.h:
* editing/VisibleUnits.cpp:
(WebCore::directionIsDownstream):
(WebCore::atBoundaryOfGranularity):
(WebCore::withinTextUnitOfGranularity):
(WebCore::nextWordBoundaryInDirection):
(WebCore::nextSentenceBoundaryInDirection):
(WebCore::nextParagraphBoundaryInDirection):
(WebCore::positionOfNextBoundaryOfGranularity):
(WebCore::enclosingTextUnitOfGranularity):
(WebCore::charactersAroundPosition):
(WebCore::wordRangeFromPosition):
(WebCore::closestWordBoundaryForPosition):
(WebCore::rangeExpandedByCharactersInDirectionAtWordBoundary):
(WebCore::wordBoundaryForPositionWithoutCrossingLine):
* editing/cocoa/DataDetection.mm:
(WebCore::DataDetection::detectItemAroundHitTestResult):
* editing/cocoa/DictionaryLookup.mm:
* editing/mac/DictionaryLookupLegacy.mm:
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::create):
* loader/FrameLoaderClient.h:
(WebCore::FrameLoaderClient::webGLPolicyForURL const):
(WebCore::FrameLoaderClient::resolveWebGLPolicyForURL const):
(): Deleted.
* loader/FrameLoaderTypes.h:
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected):
* page/DOMSelection.cpp:
(WebCore::DOMSelection::modify):
* page/DragController.cpp:
(WebCore::DragController::concludeEditDrag):
* page/EventHandler.cpp:
(WebCore::EventHandler::updateSelectionForMouseDownDispatchingSelectStart):
(WebCore::EventHandler::selectClosestWordFromHitTestResult):
(WebCore::EventHandler::selectClosestContextualWordFromMouseEvent):
(WebCore::EventHandler::selectClosestContextualWordOrLinkFromMouseEvent):
(WebCore::EventHandler::handleMousePressEventTripleClick):
(WebCore::EventHandler::handleMousePressEventSingleClick):
(WebCore::EventHandler::updateSelectionForMouseDrag):
(WebCore::setInitialKeyboardSelection):
(WebCore::handleKeyboardSelectionMovement):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::isOverTextInsideFormControlElement const):

Source/WebKit:

Patch by Alex Christensen <achristensen@webkit.org> on 2020-05-15
Reviewed by Geoffrey Garen.

* Scripts/webkit/messages.py:
* Shared/DocumentEditingContext.h:
* Shared/ios/GestureTypes.h:
* UIProcess/API/C/WKAPICast.h:
(WebKit::toWebGLLoadPolicy):
(WebKit::toAPI):
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::toWebCoreWebGLLoadPolicy):
(WebKit::NavigationState::NavigationClient::webGLLoadPolicy const):
(WebKit::NavigationState::NavigationClient::resolveWebGLLoadPolicy const):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::webGLPolicyForURL):
(WebKit::WebPageProxy::resolveWebGLPolicyForURL):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView selectForWebView:]):
(toUIWKSelectionFlags):
(toSelectionFlags):
(toWKTextGranularity):
(toWKSelectionDirection):
(selectionChangedWithGesture):
(selectionChangedWithTouch):
(-[WKContentView changeSelectionWithGestureAt:withGesture:withState:withFlags:]):
(-[WKContentView changeSelectionWithTouchAt:withSelectionTouch:baseIsStart:withFlags:]):
(-[WKContentView changeSelectionWithTouchesFrom:to:withGesture:withState:]):
(-[WKContentView selectWordForReplacement]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::gestureCallback):
(WebKit::WebPageProxy::touchesCallback):
(WebKit::WebPageProxy::selectWithGesture):
(WebKit::WebPageProxy::updateSelectionWithTouches):
(WebKit::WebPageProxy::selectTextWithGranularityAtPoint):
(WebKit::WebPageProxy::selectPositionAtBoundaryWithDirection):
(WebKit::WebPageProxy::moveSelectionAtBoundaryWithDirection):
(WebKit::WebPageProxy::selectWithTwoTouches):
(WebKit::WebPageProxy::extendSelection):
(WebKit::WebPageProxy::requestRectsForGranularityWithSelectionOffset):
* WebProcess/InjectedBundle/API/mac/WKDOMRange.mm:
(-[WKDOMRange rangeByExpandingToWordBoundaryByCharacters:inDirection:]):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::webGLPolicyForURL const):
(WebKit::WebFrameLoaderClient::resolveWebGLPolicyForURL const):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::webGLPolicyForURL):
(WebKit::WebPage::resolveWebGLPolicyForURL):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getPlatformEditorState const):
(WebKit::WebPage::getSelectionContext):
(WebKit::WebPage::selectWithGesture):
(WebKit::rangeAtWordBoundaryForPosition):
(WebKit::WebPage::updateSelectionWithTouches):
(WebKit::WebPage::selectWithTwoTouches):
(WebKit::WebPage::extendSelection):
(WebKit::WebPage::selectWordBackward):
(WebKit::WebPage::moveSelectionByOffset):
(WebKit::WebPage::getRectsForGranularityWithSelectionOffset):
(WebKit::WebPage::selectPositionAtBoundaryWithDirection):
(WebKit::WebPage::moveSelectionAtBoundaryWithDirection):
(WebKit::WebPage::rangeForGranularityAtPoint):
(WebKit::WebPage::selectTextWithGranularityAtPoint):
(WebKit::WebPage::beginSelectionInDirection):
(WebKit::WebPage::updateSelectionWithExtentPointAndBoundary):
(WebKit::WebPage::requestDictationContext):
(WebKit::WebPage::applyAutocorrectionInternal):
(WebKit::WebPage::autocorrectionContext):
(WebKit::dataDetectorLinkPositionInformation):
(WebKit::moveByGranularityRespectingWordBoundary):
(WebKit::WebPage::requestDocumentEditingContext):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::webGLPolicyForURL):
(WebKit::WebPage::resolveWebGLPolicyForURL):

Source/WebKitLegacy/ios:

Patch by Alex Christensen <achristensen@webkit.org> on 2020-05-15
Reviewed by Geoffrey Garen.

* WebCoreSupport/WebFrameIOS.mm:
(-[WebFrame aggressivelyExpandSelectionToWordContainingCaretSelection]):
(-[WebFrame setSelectionGranularity:]):
* WebCoreSupport/WebVisiblePosition.mm:
(toTextGranularity):
(toSelectionDirection):

Source/WebKitLegacy/mac:

Patch by Alex Christensen <achristensen@webkit.org> on 2020-05-15
Reviewed by Geoffrey Garen.

* DOM/DOMUIKitExtensions.mm:
(-[DOMRange move:inDirection:]):
(-[DOMRange extend:inDirection:]):
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::webGLPolicyForURL const):
(WebFrameLoaderClient::resolveWebGLPolicyForURL const):
* WebView/WebHTMLView.mm:
(-[WebHTMLView _canSmartCopyOrDelete]):
* WebView/WebTextCompletionController.mm:
(-[WebTextCompletionController doCompletion]):

Tools:

Patch by Alex Christensen <achristensen@webkit.org> on 2020-05-15
Reviewed by Geoffrey Garen.

* DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
(AccessibilityUIElement::increaseTextSelection):
(AccessibilityUIElement::decreaseTextSelection):
* WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
(WTR::AccessibilityUIElement::increaseTextSelection):
(WTR::AccessibilityUIElement::decreaseTextSelection):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261776 268f45cc-cd09-0410-ab3c-d52691b4dbfc

57 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/editing/EditingBehavior.h
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/EditorCommand.cpp
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/editing/FrameSelection.h
Source/WebCore/editing/TextGranularity.h
Source/WebCore/editing/TypingCommand.cpp
Source/WebCore/editing/TypingCommand.h
Source/WebCore/editing/VisibleSelection.cpp
Source/WebCore/editing/VisibleSelection.h
Source/WebCore/editing/VisibleUnits.cpp
Source/WebCore/editing/cocoa/DataDetection.mm
Source/WebCore/editing/cocoa/DictionaryLookup.mm
Source/WebCore/editing/mac/DictionaryLookupLegacy.mm
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/loader/FrameLoaderClient.h
Source/WebCore/loader/FrameLoaderTypes.h
Source/WebCore/page/ContextMenuController.cpp
Source/WebCore/page/DOMSelection.cpp
Source/WebCore/page/DragController.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/rendering/HitTestResult.cpp
Source/WebKit/ChangeLog
Source/WebKit/Scripts/testMessageReceiver.cpp
Source/WebKit/Scripts/testMessages.h
Source/WebKit/Scripts/webkit/messages.py
Source/WebKit/Scripts/webkit/test.messages.in
Source/WebKit/Shared/DocumentEditingContext.h
Source/WebKit/Shared/ios/GestureTypes.h
Source/WebKit/UIProcess/API/C/WKAPICast.h
Source/WebKit/UIProcess/Cocoa/NavigationState.mm
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
Source/WebKitLegacy/ios/ChangeLog
Source/WebKitLegacy/ios/WebCoreSupport/WebFrameIOS.mm
Source/WebKitLegacy/ios/WebCoreSupport/WebVisiblePosition.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/DOM/DOMUIKitExtensions.mm
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
Source/WebKitLegacy/mac/WebView/WebTextCompletionController.mm
Tools/ChangeLog
Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm
Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm

index 3815979..d16c9f5 100644 (file)
@@ -1,3 +1,163 @@
+2020-05-15  Alex Christensen  <achristensen@webkit.org>
+
+        Use enum serialization instead of casting to/from uint32_t
+        https://bugs.webkit.org/show_bug.cgi?id=211885
+        <rdar://problem/60106629> and <rdar://problem/60107663>
+
+        Reviewed by Geoffrey Garen.
+
+        This doesn't change anything except make stricter checks at IPC boundaries.
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::visiblePositionRangeForLine const):
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityModifySelection:increase:]):
+        * editing/EditingBehavior.h:
+        * editing/Editor.cpp:
+        (WebCore::Editor::shouldSmartDelete):
+        (WebCore::Editor::deleteWithDirection):
+        (WebCore::Editor::misspelledWordAtCaretOrRange const):
+        (WebCore::Editor::guessesForMisspelledOrUngrammatical):
+        (WebCore::Editor::markMisspellingsAfterTypingToWord):
+        (WebCore::Editor::markAndReplaceFor):
+        (WebCore::Editor::handleAcceptedCandidate):
+        * editing/EditorCommand.cpp:
+        (WebCore::executeDeleteBackward):
+        (WebCore::executeDeleteBackwardByDecomposingPreviousCharacter):
+        (WebCore::executeDeleteForward):
+        (WebCore::executeDeleteToBeginningOfLine):
+        (WebCore::executeDeleteToBeginningOfParagraph):
+        (WebCore::executeDeleteToEndOfLine):
+        (WebCore::executeDeleteToEndOfParagraph):
+        (WebCore::executeDeleteWordBackward):
+        (WebCore::executeDeleteWordForward):
+        (WebCore::executeForwardDelete):
+        (WebCore::executeMoveBackward):
+        (WebCore::executeMoveBackwardAndModifySelection):
+        (WebCore::executeMoveDown):
+        (WebCore::executeMoveDownAndModifySelection):
+        (WebCore::executeMoveForward):
+        (WebCore::executeMoveForwardAndModifySelection):
+        (WebCore::executeMoveLeft):
+        (WebCore::executeMoveLeftAndModifySelection):
+        (WebCore::executeMoveRight):
+        (WebCore::executeMoveRightAndModifySelection):
+        (WebCore::executeMoveToBeginningOfDocument):
+        (WebCore::executeMoveToBeginningOfDocumentAndModifySelection):
+        (WebCore::executeMoveToBeginningOfLine):
+        (WebCore::executeMoveToBeginningOfLineAndModifySelection):
+        (WebCore::executeMoveToBeginningOfParagraph):
+        (WebCore::executeMoveToBeginningOfParagraphAndModifySelection):
+        (WebCore::executeMoveToBeginningOfSentence):
+        (WebCore::executeMoveToBeginningOfSentenceAndModifySelection):
+        (WebCore::executeMoveToEndOfDocument):
+        (WebCore::executeMoveToEndOfDocumentAndModifySelection):
+        (WebCore::executeMoveToEndOfSentence):
+        (WebCore::executeMoveToEndOfSentenceAndModifySelection):
+        (WebCore::executeMoveToEndOfLine):
+        (WebCore::executeMoveToEndOfLineAndModifySelection):
+        (WebCore::executeMoveToEndOfParagraph):
+        (WebCore::executeMoveToEndOfParagraphAndModifySelection):
+        (WebCore::executeMoveParagraphBackwardAndModifySelection):
+        (WebCore::executeMoveParagraphForwardAndModifySelection):
+        (WebCore::executeMoveUp):
+        (WebCore::executeMoveUpAndModifySelection):
+        (WebCore::executeMoveWordBackward):
+        (WebCore::executeMoveWordBackwardAndModifySelection):
+        (WebCore::executeMoveWordForward):
+        (WebCore::executeMoveWordForwardAndModifySelection):
+        (WebCore::executeMoveWordLeft):
+        (WebCore::executeMoveWordLeftAndModifySelection):
+        (WebCore::executeMoveWordRight):
+        (WebCore::executeMoveWordRightAndModifySelection):
+        (WebCore::executeMoveToLeftEndOfLine):
+        (WebCore::executeMoveToLeftEndOfLineAndModifySelection):
+        (WebCore::executeMoveToRightEndOfLine):
+        (WebCore::executeMoveToRightEndOfLineAndModifySelection):
+        (WebCore::executeSelectLine):
+        (WebCore::executeSelectParagraph):
+        (WebCore::executeSelectSentence):
+        (WebCore::executeSelectWord):
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::FrameSelection):
+        (WebCore::FrameSelection::willBeModified):
+        (WebCore::FrameSelection::modifyExtendingRight):
+        (WebCore::FrameSelection::modifyExtendingForward):
+        (WebCore::FrameSelection::modifyMovingRight):
+        (WebCore::FrameSelection::modifyMovingForward):
+        (WebCore::FrameSelection::modifyExtendingLeft):
+        (WebCore::FrameSelection::modifyExtendingBackward):
+        (WebCore::FrameSelection::modifyMovingLeft):
+        (WebCore::FrameSelection::modifyMovingBackward):
+        (WebCore::isBoundary):
+        (WebCore::FrameSelection::textSelectionIntent):
+        (WebCore::textSelectionWithDirectionAndGranularity):
+        (WebCore::FrameSelection::modify):
+        (WebCore::FrameSelection::clear):
+        (WebCore::FrameSelection::willBeRemovedFromFrame):
+        (WebCore::FrameSelection::updateAppearance):
+        (WebCore::FrameSelection::wordSelectionContainingCaretSelection):
+        (WebCore::FrameSelection::rangeByAlteringCurrentSelection const):
+        * editing/FrameSelection.h:
+        * editing/TextGranularity.h:
+        (): Deleted.
+        * editing/TypingCommand.cpp:
+        (WebCore::editActionForTypingCommand):
+        (WebCore::TypingCommand::deleteKeyPressed):
+        (WebCore::TypingCommand::forwardDeleteKeyPressed):
+        (WebCore::TypingCommand::insertTextRunWithoutNewlines):
+        (WebCore::TypingCommand::insertLineBreak):
+        (WebCore::TypingCommand::insertParagraphSeparator):
+        (WebCore::TypingCommand::insertParagraphSeparatorInQuotedContent):
+        (WebCore::TypingCommand::deleteSelection):
+        * editing/TypingCommand.h:
+        * editing/VisibleSelection.cpp:
+        (WebCore::VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity):
+        * editing/VisibleSelection.h:
+        * editing/VisibleUnits.cpp:
+        (WebCore::directionIsDownstream):
+        (WebCore::atBoundaryOfGranularity):
+        (WebCore::withinTextUnitOfGranularity):
+        (WebCore::nextWordBoundaryInDirection):
+        (WebCore::nextSentenceBoundaryInDirection):
+        (WebCore::nextParagraphBoundaryInDirection):
+        (WebCore::positionOfNextBoundaryOfGranularity):
+        (WebCore::enclosingTextUnitOfGranularity):
+        (WebCore::charactersAroundPosition):
+        (WebCore::wordRangeFromPosition):
+        (WebCore::closestWordBoundaryForPosition):
+        (WebCore::rangeExpandedByCharactersInDirectionAtWordBoundary):
+        (WebCore::wordBoundaryForPositionWithoutCrossingLine):
+        * editing/cocoa/DataDetection.mm:
+        (WebCore::DataDetection::detectItemAroundHitTestResult):
+        * editing/cocoa/DictionaryLookup.mm:
+        * editing/mac/DictionaryLookupLegacy.mm:
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::create):
+        * loader/FrameLoaderClient.h:
+        (WebCore::FrameLoaderClient::webGLPolicyForURL const):
+        (WebCore::FrameLoaderClient::resolveWebGLPolicyForURL const):
+        (): Deleted.
+        * loader/FrameLoaderTypes.h:
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::contextMenuItemSelected):
+        * page/DOMSelection.cpp:
+        (WebCore::DOMSelection::modify):
+        * page/DragController.cpp:
+        (WebCore::DragController::concludeEditDrag):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::updateSelectionForMouseDownDispatchingSelectStart):
+        (WebCore::EventHandler::selectClosestWordFromHitTestResult):
+        (WebCore::EventHandler::selectClosestContextualWordFromMouseEvent):
+        (WebCore::EventHandler::selectClosestContextualWordOrLinkFromMouseEvent):
+        (WebCore::EventHandler::handleMousePressEventTripleClick):
+        (WebCore::EventHandler::handleMousePressEventSingleClick):
+        (WebCore::EventHandler::updateSelectionForMouseDrag):
+        (WebCore::setInitialKeyboardSelection):
+        (WebCore::handleKeyboardSelectionMovement):
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::isOverTextInsideFormControlElement const):
+
 2020-05-15  Simon Fraser  <simon.fraser@apple.com>
 
         Rename the mapLocalToContainer() container argument, since it's not just used for repaint
index dac6c17..8b3d93e 100644 (file)
@@ -2012,7 +2012,7 @@ VisiblePositionRange AccessibilityRenderObject::visiblePositionRangeForLine(unsi
     // will be a caret at visiblePos.
     FrameSelection selection;
     selection.setSelection(VisibleSelection(visiblePos));
-    selection.modify(FrameSelection::AlterationExtend, DirectionRight, LineBoundary);
+    selection.modify(FrameSelection::AlterationExtend, SelectionDirection::Right, TextGranularity::LineBoundary);
     
     return VisiblePositionRange(selection.selection().visibleStart(), selection.selection().visibleEnd());
 }
index 1d96590..b77425c 100644 (file)
@@ -2010,7 +2010,7 @@ static RenderObject* rendererForView(WAKView* view)
     if (frameSelection.isNone() && (selection.visibleStart() < range.start || selection.visibleEnd() > range.end))
         frameSelection.moveTo(range.start, UserTriggered);
     
-    frameSelection.modify(FrameSelection::AlterationExtend, (increase) ? DirectionRight : DirectionLeft, granularity, UserTriggered);
+    frameSelection.modify(FrameSelection::AlterationExtend, (increase) ? SelectionDirection::Right : SelectionDirection::Left, granularity, UserTriggered);
 }
 
 - (void)accessibilityIncreaseSelection:(TextGranularity)granularity
index 7b9d342..4447607 100644 (file)
@@ -96,7 +96,7 @@ public:
     // On iOS, we don't want to select all the text when focusing a field. Instead, match platform behavior by going to the end of the line.
     bool shouldMoveSelectionToEndWhenFocusingTextInput() const { return m_type == EditingIOSBehavior; }
     
-    // On iOS, when smart delete is on, it is always on, and should do not additional checks (i.e. WordGranularity).
+    // On iOS, when smart delete is on, it is always on, and should do not additional checks (i.e. TextGranularity::WordGranularity).
     bool shouldAlwaysSmartDelete() const { return m_type == EditingIOSBehavior; }
     
     // On iOS, we should turn on smart insert and delete and newlines around paragraphs to match UIKit behaviour.
index 1028173..c251010 100644 (file)
@@ -528,7 +528,7 @@ bool Editor::shouldSmartDelete()
 {
     if (behavior().shouldAlwaysSmartDelete())
         return true;
-    return m_document.selection().granularity() == WordGranularity;
+    return m_document.selection().granularity() == TextGranularity::WordGranularity;
 }
 
 bool Editor::smartInsertDeleteEnabled()
@@ -568,12 +568,12 @@ bool Editor::deleteWithDirection(SelectionDirection direction, TextGranularity g
         if (shouldAddToKillRing)
             options |= TypingCommand::AddsToKillRing;
         switch (direction) {
-        case DirectionForward:
-        case DirectionRight:
+        case SelectionDirection::Forward:
+        case SelectionDirection::Right:
             TypingCommand::forwardDeleteKeyPressed(document(), options, granularity);
             break;
-        case DirectionBackward:
-        case DirectionLeft:
+        case SelectionDirection::Backward:
+        case SelectionDirection::Left:
             TypingCommand::deleteKeyPressed(document(), options, granularity);
             break;
         }
@@ -2331,7 +2331,7 @@ String Editor::misspelledWordAtCaretOrRange(Node* clickedNode) const
         return String();
 
     VisibleSelection wordSelection(selection.base());
-    wordSelection.expandUsingGranularity(WordGranularity);
+    wordSelection.expandUsingGranularity(TextGranularity::WordGranularity);
     auto wordRange = wordSelection.toNormalizedRange();
     if (!wordRange)
         return String();
@@ -2402,7 +2402,7 @@ Vector<String> Editor::guessesForMisspelledOrUngrammatical(bool& misspelled, boo
         VisibleSelection selection = m_document.selection().selection();
         if (selection.isCaret() && behavior().shouldAllowSpellingSuggestionsWithoutSelection()) {
             VisibleSelection wordSelection = VisibleSelection(selection.base());
-            wordSelection.expandUsingGranularity(WordGranularity);
+            wordSelection.expandUsingGranularity(TextGranularity::WordGranularity);
             range = wordSelection.toNormalizedRange();
         } else
             range = selection.toNormalizedRange();
@@ -2593,7 +2593,7 @@ void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart,
 
         // Reset the charet one character further.
         m_document.selection().moveTo(m_document.selection().selection().end());
-        m_document.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
+        m_document.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Forward, TextGranularity::CharacterGranularity);
     }
 
     if (!isGrammarCheckingEnabled())
@@ -2919,11 +2919,11 @@ void Editor::markAndReplaceFor(const SpellCheckRequest& request, const Vector<Te
             auto selectionRange = extendedParagraph.subrange({ 0, selectionOffset });
             m_document.selection().moveTo(selectionRange->endPosition(), DOWNSTREAM);
             if (adjustSelectionForParagraphBoundaries)
-                m_document.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
+                m_document.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Forward, TextGranularity::CharacterGranularity);
         } else {
             // If this fails for any reason, the fallback is to go one position beyond the last replacement
             m_document.selection().moveTo(m_document.selection().selection().end());
-            m_document.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
+            m_document.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Forward, TextGranularity::CharacterGranularity);
         }
     }
 }
@@ -4215,7 +4215,7 @@ void Editor::handleAcceptedCandidate(TextCheckingResult acceptedCandidate)
     } else
         insertText(acceptedCandidate.replacement, nullptr);
 
-    RefPtr<Range> insertedCandidateRange = rangeExpandedByCharactersInDirectionAtWordBoundary(selection.visibleStart(), acceptedCandidate.replacement.length(), DirectionBackward);
+    RefPtr<Range> insertedCandidateRange = rangeExpandedByCharactersInDirectionAtWordBoundary(selection.visibleStart(), acceptedCandidate.replacement.length(), SelectionDirection::Backward);
     if (insertedCandidateRange)
         insertedCandidateRange->startContainer().document().markers().addMarker(*insertedCandidateRange, DocumentMarker::AcceptedCandidate, acceptedCandidate.replacement);
 
index dcf3dce..747f955 100644 (file)
@@ -304,32 +304,32 @@ static bool executeDelete(Frame& frame, Event*, EditorCommandSource source, cons
 
 static bool executeDeleteBackward(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.editor().deleteWithDirection(DirectionBackward, CharacterGranularity, false, true);
+    frame.editor().deleteWithDirection(SelectionDirection::Backward, TextGranularity::CharacterGranularity, false, true);
     return true;
 }
 
 static bool executeDeleteBackwardByDecomposingPreviousCharacter(Frame& frame, Event*, EditorCommandSource, const String&)
 {
     LOG_ERROR("DeleteBackwardByDecomposingPreviousCharacter is not implemented, doing DeleteBackward instead");
-    frame.editor().deleteWithDirection(DirectionBackward, CharacterGranularity, false, true);
+    frame.editor().deleteWithDirection(SelectionDirection::Backward, TextGranularity::CharacterGranularity, false, true);
     return true;
 }
 
 static bool executeDeleteForward(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.editor().deleteWithDirection(DirectionForward, CharacterGranularity, false, true);
+    frame.editor().deleteWithDirection(SelectionDirection::Forward, TextGranularity::CharacterGranularity, false, true);
     return true;
 }
 
 static bool executeDeleteToBeginningOfLine(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.editor().deleteWithDirection(DirectionBackward, LineBoundary, true, false);
+    frame.editor().deleteWithDirection(SelectionDirection::Backward, TextGranularity::LineBoundary, true, false);
     return true;
 }
 
 static bool executeDeleteToBeginningOfParagraph(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.editor().deleteWithDirection(DirectionBackward, ParagraphBoundary, true, false);
+    frame.editor().deleteWithDirection(SelectionDirection::Backward, TextGranularity::ParagraphBoundary, true, false);
     return true;
 }
 
@@ -337,7 +337,7 @@ static bool executeDeleteToEndOfLine(Frame& frame, Event*, EditorCommandSource,
 {
     // Despite its name, this command should delete the newline at the end of
     // a paragraph if you are at the end of a paragraph (like DeleteToEndOfParagraph).
-    frame.editor().deleteWithDirection(DirectionForward, LineBoundary, true, false);
+    frame.editor().deleteWithDirection(SelectionDirection::Forward, TextGranularity::LineBoundary, true, false);
     return true;
 }
 
@@ -345,7 +345,7 @@ static bool executeDeleteToEndOfParagraph(Frame& frame, Event*, EditorCommandSou
 {
     // Despite its name, this command should delete the newline at the end of
     // a paragraph if you are at the end of a paragraph.
-    frame.editor().deleteWithDirection(DirectionForward, ParagraphBoundary, true, false);
+    frame.editor().deleteWithDirection(SelectionDirection::Forward, TextGranularity::ParagraphBoundary, true, false);
     return true;
 }
 
@@ -366,13 +366,13 @@ static bool executeDeleteToMark(Frame& frame, Event*, EditorCommandSource, const
 
 static bool executeDeleteWordBackward(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.editor().deleteWithDirection(DirectionBackward, WordGranularity, true, false);
+    frame.editor().deleteWithDirection(SelectionDirection::Backward, TextGranularity::WordGranularity, true, false);
     return true;
 }
 
 static bool executeDeleteWordForward(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.editor().deleteWithDirection(DirectionForward, WordGranularity, true, false);
+    frame.editor().deleteWithDirection(SelectionDirection::Forward, TextGranularity::WordGranularity, true, false);
     return true;
 }
 
@@ -424,7 +424,7 @@ static bool executeForwardDelete(Frame& frame, Event*, EditorCommandSource sourc
 {
     switch (source) {
     case CommandFromMenuOrKeyBinding:
-        frame.editor().deleteWithDirection(DirectionForward, CharacterGranularity, false, true);
+        frame.editor().deleteWithDirection(SelectionDirection::Forward, TextGranularity::CharacterGranularity, false, true);
         return true;
     case CommandFromDOM:
     case CommandFromDOMWithUserInterface:
@@ -606,47 +606,47 @@ static bool executeMakeTextWritingDirectionRightToLeft(Frame& frame, Event*, Edi
 
 static bool executeMoveBackward(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionBackward, CharacterGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Backward, TextGranularity::CharacterGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveBackwardAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, CharacterGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Backward, TextGranularity::CharacterGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveDown(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    return frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, LineGranularity, UserTriggered);
+    return frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Forward, TextGranularity::LineGranularity, UserTriggered);
 }
 
 static bool executeMoveDownAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, LineGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Forward, TextGranularity::LineGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveForward(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Forward, TextGranularity::CharacterGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveForwardAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, CharacterGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Forward, TextGranularity::CharacterGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveLeft(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    return frame.selection().modify(FrameSelection::AlterationMove, DirectionLeft, CharacterGranularity, UserTriggered);
+    return frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Left, TextGranularity::CharacterGranularity, UserTriggered);
 }
 
 static bool executeMoveLeftAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionLeft, CharacterGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Left, TextGranularity::CharacterGranularity, UserTriggered);
     return true;
 }
 
@@ -688,203 +688,203 @@ static bool executeMovePageUpAndModifySelection(Frame& frame, Event*, EditorComm
 
 static bool executeMoveRight(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    return frame.selection().modify(FrameSelection::AlterationMove, DirectionRight, CharacterGranularity, UserTriggered);
+    return frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Right, TextGranularity::CharacterGranularity, UserTriggered);
 }
 
 static bool executeMoveRightAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionRight, CharacterGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Right, TextGranularity::CharacterGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfDocument(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionBackward, DocumentBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Backward, TextGranularity::DocumentBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfDocumentAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, DocumentBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Backward, TextGranularity::DocumentBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfLine(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionBackward, LineBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Backward, TextGranularity::LineBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfLineAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, LineBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Backward, TextGranularity::LineBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfParagraph(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionBackward, ParagraphBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Backward, TextGranularity::ParagraphBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfParagraphAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, ParagraphBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Backward, TextGranularity::ParagraphBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfSentence(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionBackward, SentenceBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Backward, TextGranularity::SentenceBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfSentenceAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, SentenceBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Backward, TextGranularity::SentenceBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfDocument(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, DocumentBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Forward, TextGranularity::DocumentBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfDocumentAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, DocumentBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Forward, TextGranularity::DocumentBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfSentence(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, SentenceBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Forward, TextGranularity::SentenceBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfSentenceAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, SentenceBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Forward, TextGranularity::SentenceBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfLine(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, LineBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Forward, TextGranularity::LineBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfLineAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, LineBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Forward, TextGranularity::LineBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfParagraph(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, ParagraphBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Forward, TextGranularity::ParagraphBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfParagraphAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, ParagraphBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Forward, TextGranularity::ParagraphBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveParagraphBackwardAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, ParagraphGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Backward, TextGranularity::ParagraphGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveParagraphForwardAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, ParagraphGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Forward, TextGranularity::ParagraphGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveUp(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    return frame.selection().modify(FrameSelection::AlterationMove, DirectionBackward, LineGranularity, UserTriggered);
+    return frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Backward, TextGranularity::LineGranularity, UserTriggered);
 }
 
 static bool executeMoveUpAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, LineGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Backward, TextGranularity::LineGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordBackward(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionBackward, WordGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Backward, TextGranularity::WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordBackwardAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionBackward, WordGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Backward, TextGranularity::WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordForward(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, WordGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Forward, TextGranularity::WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordForwardAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionForward, WordGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Forward, TextGranularity::WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordLeft(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionLeft, WordGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Left, TextGranularity::WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordLeftAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionLeft, WordGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Left, TextGranularity::WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordRight(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionRight, WordGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Right, TextGranularity::WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordRightAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionRight, WordGranularity, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Right, TextGranularity::WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveToLeftEndOfLine(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionLeft, LineBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Left, TextGranularity::LineBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToLeftEndOfLineAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionLeft, LineBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Left, TextGranularity::LineBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToRightEndOfLine(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationMove, DirectionRight, LineBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationMove, SelectionDirection::Right, TextGranularity::LineBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToRightEndOfLineAndModifySelection(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    frame.selection().modify(FrameSelection::AlterationExtend, DirectionRight, LineBoundary, UserTriggered);
+    frame.selection().modify(FrameSelection::AlterationExtend, SelectionDirection::Right, TextGranularity::LineBoundary, UserTriggered);
     return true;
 }
 
@@ -1035,17 +1035,17 @@ static bool executeSelectAll(Frame& frame, Event*, EditorCommandSource, const St
 
 static bool executeSelectLine(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    return expandSelectionToGranularity(frame, LineGranularity);
+    return expandSelectionToGranularity(frame, TextGranularity::LineGranularity);
 }
 
 static bool executeSelectParagraph(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    return expandSelectionToGranularity(frame, ParagraphGranularity);
+    return expandSelectionToGranularity(frame, TextGranularity::ParagraphGranularity);
 }
 
 static bool executeSelectSentence(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    return expandSelectionToGranularity(frame, SentenceGranularity);
+    return expandSelectionToGranularity(frame, TextGranularity::SentenceGranularity);
 }
 
 static bool executeSelectToMark(Frame& frame, Event*, EditorCommandSource, const String&)
@@ -1062,7 +1062,7 @@ static bool executeSelectToMark(Frame& frame, Event*, EditorCommandSource, const
 
 static bool executeSelectWord(Frame& frame, Event*, EditorCommandSource, const String&)
 {
-    return expandSelectionToGranularity(frame, WordGranularity);
+    return expandSelectionToGranularity(frame, TextGranularity::WordGranularity);
 }
 
 static bool executeSetMark(Frame& frame, Event*, EditorCommandSource, const String&)
index dc862f7..ee2890c 100644 (file)
@@ -147,7 +147,7 @@ static inline bool shouldAlwaysUseDirectionalSelection(Document* document)
 FrameSelection::FrameSelection(Document* document)
     : m_document(document)
     , m_xPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation())
-    , m_granularity(CharacterGranularity)
+    , m_granularity(TextGranularity::CharacterGranularity)
 #if ENABLE(TEXT_CARET)
     , m_caretBlinkTimer(*this, &FrameSelection::caretBlinkTimerFired)
 #endif
@@ -676,22 +676,22 @@ void FrameSelection::willBeModified(EAlteration alter, SelectionDirection direct
             baseIsStart = false;
     } else {
         switch (direction) {
-        case DirectionRight:
+        case SelectionDirection::Right:
             if (directionOfSelection() == TextDirection::LTR)
                 baseIsStart = true;
             else
                 baseIsStart = false;
             break;
-        case DirectionForward:
+        case SelectionDirection::Forward:
             baseIsStart = true;
             break;
-        case DirectionLeft:
+        case SelectionDirection::Left:
             if (directionOfSelection() == TextDirection::LTR)
                 baseIsStart = false;
             else
                 baseIsStart = true;
             break;
-        case DirectionBackward:
+        case SelectionDirection::Backward:
             baseIsStart = false;
             break;
         }
@@ -765,34 +765,34 @@ VisiblePosition FrameSelection::modifyExtendingRight(TextGranularity granularity
     // it extends forward logically if the enclosing block is TextDirection::LTR,
     // but it extends backward logically if the enclosing block is TextDirection::RTL.
     switch (granularity) {
-    case CharacterGranularity:
+    case TextGranularity::CharacterGranularity:
         if (directionOfEnclosingBlock() == TextDirection::LTR)
             pos = pos.next(CannotCrossEditingBoundary);
         else
             pos = pos.previous(CannotCrossEditingBoundary);
         break;
-    case WordGranularity:
+    case TextGranularity::WordGranularity:
         if (directionOfEnclosingBlock() == TextDirection::LTR)
             pos = nextWordPositionForPlatform(pos);
         else
             pos = previousWordPosition(pos);
         break;
-    case LineBoundary:
+    case TextGranularity::LineBoundary:
         if (directionOfEnclosingBlock() == TextDirection::LTR)
             pos = modifyExtendingForward(granularity);
         else
             pos = modifyExtendingBackward(granularity);
         break;
-    case SentenceGranularity:
-    case LineGranularity:
-    case ParagraphGranularity:
-    case SentenceBoundary:
-    case ParagraphBoundary:
-    case DocumentBoundary:
+    case TextGranularity::SentenceGranularity:
+    case TextGranularity::LineGranularity:
+    case TextGranularity::ParagraphGranularity:
+    case TextGranularity::SentenceBoundary:
+    case TextGranularity::ParagraphBoundary:
+    case TextGranularity::DocumentBoundary:
         // FIXME: implement all of the above?
         pos = modifyExtendingForward(granularity);
         break;
-    case DocumentGranularity:
+    case TextGranularity::DocumentGranularity:
         ASSERT_NOT_REACHED();
         break;
     }
@@ -806,34 +806,34 @@ VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari
 {
     VisiblePosition pos(m_selection.extent(), m_selection.affinity());
     switch (granularity) {
-    case CharacterGranularity:
+    case TextGranularity::CharacterGranularity:
         pos = pos.next(CannotCrossEditingBoundary);
         break;
-    case WordGranularity:
+    case TextGranularity::WordGranularity:
         pos = nextWordPositionForPlatform(pos);
         break;
-    case SentenceGranularity:
+    case TextGranularity::SentenceGranularity:
         pos = nextSentencePosition(pos);
         break;
-    case LineGranularity:
+    case TextGranularity::LineGranularity:
         pos = nextLinePosition(pos, lineDirectionPointForBlockDirectionNavigation(EXTENT));
         break;
-    case ParagraphGranularity:
+    case TextGranularity::ParagraphGranularity:
         pos = nextParagraphPosition(pos, lineDirectionPointForBlockDirectionNavigation(EXTENT));
         break;
-    case DocumentGranularity:
+    case TextGranularity::DocumentGranularity:
         ASSERT_NOT_REACHED();
         break;
-    case SentenceBoundary:
+    case TextGranularity::SentenceBoundary:
         pos = endOfSentence(endForPlatform());
         break;
-    case LineBoundary:
+    case TextGranularity::LineBoundary:
         pos = logicalEndOfLine(endForPlatform());
         break;
-    case ParagraphBoundary:
+    case TextGranularity::ParagraphBoundary:
         pos = endOfParagraph(endForPlatform());
         break;
-    case DocumentBoundary:
+    case TextGranularity::DocumentBoundary:
         pos = endForPlatform();
         if (isEditablePosition(pos.deepEquivalent()))
             pos = endOfEditableContent(pos);
@@ -853,7 +853,7 @@ VisiblePosition FrameSelection::modifyMovingRight(TextGranularity granularity, b
         *reachedBoundary = false;
     VisiblePosition pos;
     switch (granularity) {
-    case CharacterGranularity:
+    case TextGranularity::CharacterGranularity:
         if (isRange()) {
             if (directionOfSelection() == TextDirection::LTR)
                 pos = VisiblePosition(m_selection.end(), m_selection.affinity());
@@ -862,7 +862,7 @@ VisiblePosition FrameSelection::modifyMovingRight(TextGranularity granularity, b
         } else
             pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).right(true, reachedBoundary);
         break;
-    case WordGranularity: {
+    case TextGranularity::WordGranularity: {
         bool skipsSpaceWhenMovingRight = m_document && m_document->editor().behavior().shouldSkipSpaceWhenMovingRight();
         VisiblePosition currentPosition(m_selection.extent(), m_selection.affinity());
         pos = rightWordPosition(currentPosition, skipsSpaceWhenMovingRight);
@@ -870,19 +870,19 @@ VisiblePosition FrameSelection::modifyMovingRight(TextGranularity granularity, b
             *reachedBoundary = pos == currentPosition;
         break;
     }
-    case SentenceGranularity:
-    case LineGranularity:
-    case ParagraphGranularity:
-    case SentenceBoundary:
-    case ParagraphBoundary:
-    case DocumentBoundary:
+    case TextGranularity::SentenceGranularity:
+    case TextGranularity::LineGranularity:
+    case TextGranularity::ParagraphGranularity:
+    case TextGranularity::SentenceBoundary:
+    case TextGranularity::ParagraphBoundary:
+    case TextGranularity::DocumentBoundary:
         // FIXME: Implement all of the above.
         pos = modifyMovingForward(granularity, reachedBoundary);
         break;
-    case LineBoundary:
+    case TextGranularity::LineBoundary:
         pos = rightBoundaryOfLine(startForPlatform(), directionOfEnclosingBlock(), reachedBoundary);
         break;
-    case DocumentGranularity:
+    case TextGranularity::DocumentGranularity:
         ASSERT_NOT_REACHED();
         break;
     }
@@ -895,15 +895,15 @@ VisiblePosition FrameSelection::modifyMovingForward(TextGranularity granularity,
         *reachedBoundary = false;
     VisiblePosition currentPosition;
     switch (granularity) {
-    case WordGranularity:
-    case SentenceGranularity:
+    case TextGranularity::WordGranularity:
+    case TextGranularity::SentenceGranularity:
         currentPosition = VisiblePosition(m_selection.extent(), m_selection.affinity());
         break;
-    case LineGranularity:
-    case ParagraphGranularity:
-    case SentenceBoundary:
-    case ParagraphBoundary:
-    case DocumentBoundary:
+    case TextGranularity::LineGranularity:
+    case TextGranularity::ParagraphGranularity:
+    case TextGranularity::SentenceBoundary:
+    case TextGranularity::ParagraphBoundary:
+    case TextGranularity::DocumentBoundary:
         currentPosition = endForPlatform();
         break;
     default:
@@ -912,19 +912,19 @@ VisiblePosition FrameSelection::modifyMovingForward(TextGranularity granularity,
     VisiblePosition pos;
     // FIXME: Stay in editable content for the less common granularities.
     switch (granularity) {
-    case CharacterGranularity:
+    case TextGranularity::CharacterGranularity:
         if (isRange())
             pos = VisiblePosition(m_selection.end(), m_selection.affinity());
         else
             pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).next(CannotCrossEditingBoundary, reachedBoundary);
         break;
-    case WordGranularity:
+    case TextGranularity::WordGranularity:
         pos = nextWordPositionForPlatform(currentPosition);
         break;
-    case SentenceGranularity:
+    case TextGranularity::SentenceGranularity:
         pos = nextSentencePosition(currentPosition);
         break;
-    case LineGranularity: {
+    case TextGranularity::LineGranularity: {
         // down-arrowing from a range selection that ends at the start of a line needs
         // to leave the selection at that line start (no need to call nextLinePosition!)
         pos = currentPosition;
@@ -932,22 +932,22 @@ VisiblePosition FrameSelection::modifyMovingForward(TextGranularity granularity,
             pos = nextLinePosition(pos, lineDirectionPointForBlockDirectionNavigation(START));
         break;
     }
-    case ParagraphGranularity:
+    case TextGranularity::ParagraphGranularity:
         pos = nextParagraphPosition(currentPosition, lineDirectionPointForBlockDirectionNavigation(START));
         break;
-    case DocumentGranularity:
+    case TextGranularity::DocumentGranularity:
         ASSERT_NOT_REACHED();
         break;
-    case SentenceBoundary:
+    case TextGranularity::SentenceBoundary:
         pos = endOfSentence(currentPosition);
         break;
-    case LineBoundary:
+    case TextGranularity::LineBoundary:
         pos = logicalEndOfLine(endForPlatform(), reachedBoundary);
         break;
-    case ParagraphBoundary:
+    case TextGranularity::ParagraphBoundary:
         pos = endOfParagraph(currentPosition);
         break;
-    case DocumentBoundary:
+    case TextGranularity::DocumentBoundary:
         pos = currentPosition;
         if (isEditablePosition(pos.deepEquivalent()))
             pos = endOfEditableContent(pos);
@@ -956,13 +956,13 @@ VisiblePosition FrameSelection::modifyMovingForward(TextGranularity granularity,
         break;
     }
     switch (granularity) {
-    case WordGranularity:
-    case SentenceGranularity:
-    case LineGranularity:
-    case ParagraphGranularity:
-    case SentenceBoundary:
-    case ParagraphBoundary:
-    case DocumentBoundary:
+    case TextGranularity::WordGranularity:
+    case TextGranularity::SentenceGranularity:
+    case TextGranularity::LineGranularity:
+    case TextGranularity::ParagraphGranularity:
+    case TextGranularity::SentenceBoundary:
+    case TextGranularity::ParagraphBoundary:
+    case TextGranularity::DocumentBoundary:
         if (reachedBoundary)
             *reachedBoundary = pos == currentPosition;
         break;
@@ -982,33 +982,33 @@ VisiblePosition FrameSelection::modifyExtendingLeft(TextGranularity granularity)
     // it extends backward logically if the enclosing block is TextDirection::LTR,
     // but it extends forward logically if the enclosing block is TextDirection::RTL.
     switch (granularity) {
-    case CharacterGranularity:
+    case TextGranularity::CharacterGranularity:
         if (directionOfEnclosingBlock() == TextDirection::LTR)
             pos = pos.previous(CannotCrossEditingBoundary);
         else
             pos = pos.next(CannotCrossEditingBoundary);
         break;
-    case WordGranularity:
+    case TextGranularity::WordGranularity:
         if (directionOfEnclosingBlock() == TextDirection::LTR)
             pos = previousWordPosition(pos);
         else
             pos = nextWordPositionForPlatform(pos);
         break;
-    case LineBoundary:
+    case TextGranularity::LineBoundary:
         if (directionOfEnclosingBlock() == TextDirection::LTR)
             pos = modifyExtendingBackward(granularity);
         else
             pos = modifyExtendingForward(granularity);
         break;
-    case SentenceGranularity:
-    case LineGranularity:
-    case ParagraphGranularity:
-    case SentenceBoundary:
-    case ParagraphBoundary:
-    case DocumentBoundary:
+    case TextGranularity::SentenceGranularity:
+    case TextGranularity::LineGranularity:
+    case TextGranularity::ParagraphGranularity:
+    case TextGranularity::SentenceBoundary:
+    case TextGranularity::ParagraphBoundary:
+    case TextGranularity::DocumentBoundary:
         pos = modifyExtendingBackward(granularity);
         break;
-    case DocumentGranularity:
+    case TextGranularity::DocumentGranularity:
         ASSERT_NOT_REACHED();
         break;
     }
@@ -1027,38 +1027,38 @@ VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular
     // It was done here instead of in VisiblePosition because we want VPs to iterate
     // over everything.
     switch (granularity) {
-    case CharacterGranularity:
+    case TextGranularity::CharacterGranularity:
         pos = pos.previous(CannotCrossEditingBoundary);
         break;
-    case WordGranularity:
+    case TextGranularity::WordGranularity:
         pos = previousWordPosition(pos);
         break;
-    case SentenceGranularity:
+    case TextGranularity::SentenceGranularity:
         pos = previousSentencePosition(pos);
         break;
-    case LineGranularity:
+    case TextGranularity::LineGranularity:
         pos = previousLinePosition(pos, lineDirectionPointForBlockDirectionNavigation(EXTENT));
         break;
-    case ParagraphGranularity:
+    case TextGranularity::ParagraphGranularity:
         pos = previousParagraphPosition(pos, lineDirectionPointForBlockDirectionNavigation(EXTENT));
         break;
-    case SentenceBoundary:
+    case TextGranularity::SentenceBoundary:
         pos = startOfSentence(startForPlatform());
         break;
-    case LineBoundary:
+    case TextGranularity::LineBoundary:
         pos = logicalStartOfLine(startForPlatform());
         break;
-    case ParagraphBoundary:
+    case TextGranularity::ParagraphBoundary:
         pos = startOfParagraph(startForPlatform());
         break;
-    case DocumentBoundary:
+    case TextGranularity::DocumentBoundary:
         pos = startForPlatform();
         if (isEditablePosition(pos.deepEquivalent()))
             pos = startOfEditableContent(pos);
         else
             pos = startOfDocument(pos);
         break;
-    case DocumentGranularity:
+    case TextGranularity::DocumentGranularity:
         ASSERT_NOT_REACHED();
         break;
     }
@@ -1074,7 +1074,7 @@ VisiblePosition FrameSelection::modifyMovingLeft(TextGranularity granularity, bo
         *reachedBoundary = false;
     VisiblePosition pos;
     switch (granularity) {
-    case CharacterGranularity:
+    case TextGranularity::CharacterGranularity:
         if (isRange())
             if (directionOfSelection() == TextDirection::LTR)
                 pos = VisiblePosition(m_selection.start(), m_selection.affinity());
@@ -1083,7 +1083,7 @@ VisiblePosition FrameSelection::modifyMovingLeft(TextGranularity granularity, bo
         else
             pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).left(true, reachedBoundary);
         break;
-    case WordGranularity: {
+    case TextGranularity::WordGranularity: {
         bool skipsSpaceWhenMovingRight = m_document && m_document->editor().behavior().shouldSkipSpaceWhenMovingRight();
         VisiblePosition currentPosition(m_selection.extent(), m_selection.affinity());
         pos = leftWordPosition(currentPosition, skipsSpaceWhenMovingRight);
@@ -1091,19 +1091,19 @@ VisiblePosition FrameSelection::modifyMovingLeft(TextGranularity granularity, bo
             *reachedBoundary = pos == currentPosition;
         break;
     }
-    case SentenceGranularity:
-    case LineGranularity:
-    case ParagraphGranularity:
-    case SentenceBoundary:
-    case ParagraphBoundary:
-    case DocumentBoundary:
+    case TextGranularity::SentenceGranularity:
+    case TextGranularity::LineGranularity:
+    case TextGranularity::ParagraphGranularity:
+    case TextGranularity::SentenceBoundary:
+    case TextGranularity::ParagraphBoundary:
+    case TextGranularity::DocumentBoundary:
         // FIXME: Implement all of the above.
         pos = modifyMovingBackward(granularity, reachedBoundary);
         break;
-    case LineBoundary:
+    case TextGranularity::LineBoundary:
         pos = leftBoundaryOfLine(startForPlatform(), directionOfEnclosingBlock(), reachedBoundary);
         break;
-    case DocumentGranularity:
+    case TextGranularity::DocumentGranularity:
         ASSERT_NOT_REACHED();
         break;
     }
@@ -1116,15 +1116,15 @@ VisiblePosition FrameSelection::modifyMovingBackward(TextGranularity granularity
         *reachedBoundary = false;
     VisiblePosition currentPosition;
     switch (granularity) {
-    case WordGranularity:
-    case SentenceGranularity:
+    case TextGranularity::WordGranularity:
+    case TextGranularity::SentenceGranularity:
         currentPosition = VisiblePosition(m_selection.extent(), m_selection.affinity());
         break;
-    case LineGranularity:
-    case ParagraphGranularity:
-    case SentenceBoundary:
-    case ParagraphBoundary:
-    case DocumentBoundary:
+    case TextGranularity::LineGranularity:
+    case TextGranularity::ParagraphGranularity:
+    case TextGranularity::SentenceBoundary:
+    case TextGranularity::ParagraphBoundary:
+    case TextGranularity::DocumentBoundary:
         currentPosition = startForPlatform();
         break;
     default:
@@ -1132,52 +1132,52 @@ VisiblePosition FrameSelection::modifyMovingBackward(TextGranularity granularity
     }
     VisiblePosition pos;
     switch (granularity) {
-    case CharacterGranularity:
+    case TextGranularity::CharacterGranularity:
         if (isRange())
             pos = VisiblePosition(m_selection.start(), m_selection.affinity());
         else
             pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).previous(CannotCrossEditingBoundary, reachedBoundary);
         break;
-    case WordGranularity:
+    case TextGranularity::WordGranularity:
         pos = previousWordPosition(currentPosition);
         break;
-    case SentenceGranularity:
+    case TextGranularity::SentenceGranularity:
         pos = previousSentencePosition(currentPosition);
         break;
-    case LineGranularity:
+    case TextGranularity::LineGranularity:
         pos = previousLinePosition(currentPosition, lineDirectionPointForBlockDirectionNavigation(START));
         break;
-    case ParagraphGranularity:
+    case TextGranularity::ParagraphGranularity:
         pos = previousParagraphPosition(currentPosition, lineDirectionPointForBlockDirectionNavigation(START));
         break;
-    case SentenceBoundary:
+    case TextGranularity::SentenceBoundary:
         pos = startOfSentence(currentPosition);
         break;
-    case LineBoundary:
+    case TextGranularity::LineBoundary:
         pos = logicalStartOfLine(startForPlatform(), reachedBoundary);
         break;
-    case ParagraphBoundary:
+    case TextGranularity::ParagraphBoundary:
         pos = startOfParagraph(currentPosition);
         break;
-    case DocumentBoundary:
+    case TextGranularity::DocumentBoundary:
         pos = currentPosition;
         if (isEditablePosition(pos.deepEquivalent()))
             pos = startOfEditableContent(pos);
         else
             pos = startOfDocument(pos);
         break;
-    case DocumentGranularity:
+    case TextGranularity::DocumentGranularity:
         ASSERT_NOT_REACHED();
         break;
     }
     switch (granularity) {
-    case WordGranularity:
-    case SentenceGranularity:
-    case LineGranularity:
-    case ParagraphGranularity:
-    case SentenceBoundary:
-    case ParagraphBoundary:
-    case DocumentBoundary:
+    case TextGranularity::WordGranularity:
+    case TextGranularity::SentenceGranularity:
+    case TextGranularity::LineGranularity:
+    case TextGranularity::ParagraphGranularity:
+    case TextGranularity::SentenceBoundary:
+    case TextGranularity::ParagraphBoundary:
+    case TextGranularity::DocumentBoundary:
         if (reachedBoundary)
             *reachedBoundary = pos == currentPosition;
         break;
@@ -1189,7 +1189,7 @@ VisiblePosition FrameSelection::modifyMovingBackward(TextGranularity granularity
 
 static bool isBoundary(TextGranularity granularity)
 {
-    return granularity == LineBoundary || granularity == ParagraphBoundary || granularity == DocumentBoundary;
+    return granularity == TextGranularity::LineBoundary || granularity == TextGranularity::ParagraphBoundary || granularity == TextGranularity::DocumentBoundary;
 }
 
 AXTextStateChangeIntent FrameSelection::textSelectionIntent(EAlteration alter, SelectionDirection direction, TextGranularity granularity)
@@ -1202,55 +1202,55 @@ AXTextStateChangeIntent FrameSelection::textSelectionIntent(EAlteration alter, S
     } else
         intent.type = AXTextStateChangeTypeSelectionExtend;
     switch (granularity) {
-    case CharacterGranularity:
+    case TextGranularity::CharacterGranularity:
         intent.selection.granularity = AXTextSelectionGranularityCharacter;
         break;
-    case WordGranularity:
+    case TextGranularity::WordGranularity:
         intent.selection.granularity = AXTextSelectionGranularityWord;
         break;
-    case SentenceGranularity:
-    case SentenceBoundary:
+    case TextGranularity::SentenceGranularity:
+    case TextGranularity::SentenceBoundary:
         intent.selection.granularity = AXTextSelectionGranularitySentence;
         break;
-    case LineGranularity:
-    case LineBoundary:
+    case TextGranularity::LineGranularity:
+    case TextGranularity::LineBoundary:
         intent.selection.granularity = AXTextSelectionGranularityLine;
         break;
-    case ParagraphGranularity:
-    case ParagraphBoundary:
+    case TextGranularity::ParagraphGranularity:
+    case TextGranularity::ParagraphBoundary:
         intent.selection.granularity = AXTextSelectionGranularityParagraph;
         break;
-    case DocumentGranularity:
-    case DocumentBoundary:
+    case TextGranularity::DocumentGranularity:
+    case TextGranularity::DocumentBoundary:
         intent.selection.granularity = AXTextSelectionGranularityDocument;
         break;
     }
     bool boundary = false;
     switch (granularity) {
-    case CharacterGranularity:
-    case WordGranularity:
-    case SentenceGranularity:
-    case LineGranularity:
-    case ParagraphGranularity:
-    case DocumentGranularity:
-        break;
-    case SentenceBoundary:
-    case LineBoundary:
-    case ParagraphBoundary:
-    case DocumentBoundary:
+    case TextGranularity::CharacterGranularity:
+    case TextGranularity::WordGranularity:
+    case TextGranularity::SentenceGranularity:
+    case TextGranularity::LineGranularity:
+    case TextGranularity::ParagraphGranularity:
+    case TextGranularity::DocumentGranularity:
+        break;
+    case TextGranularity::SentenceBoundary:
+    case TextGranularity::LineBoundary:
+    case TextGranularity::ParagraphBoundary:
+    case TextGranularity::DocumentBoundary:
         boundary = true;
         break;
     }
     switch (direction) {
-    case DirectionRight:
-    case DirectionForward:
+    case SelectionDirection::Right:
+    case SelectionDirection::Forward:
         if (boundary)
             intent.selection.direction = flip ? AXTextSelectionDirectionBeginning : AXTextSelectionDirectionEnd;
         else
             intent.selection.direction = flip ? AXTextSelectionDirectionPrevious : AXTextSelectionDirectionNext;
         break;
-    case DirectionLeft:
-    case DirectionBackward:
+    case SelectionDirection::Left:
+    case SelectionDirection::Backward:
         if (boundary)
             intent.selection.direction = flip ? AXTextSelectionDirectionEnd : AXTextSelectionDirectionBeginning;
         else
@@ -1262,58 +1262,58 @@ AXTextStateChangeIntent FrameSelection::textSelectionIntent(EAlteration alter, S
 
 static AXTextSelection textSelectionWithDirectionAndGranularity(SelectionDirection direction, TextGranularity granularity)
 {
-    // FIXME: Account for BIDI in DirectionRight & DirectionLeft. (In a RTL block, Right would map to Previous/Beginning and Left to Next/End.)
+    // FIXME: Account for BIDI in SelectionDirection::Right & SelectionDirection::Left. (In a RTL block, Right would map to Previous/Beginning and Left to Next/End.)
     AXTextSelectionDirection intentDirection = AXTextSelectionDirectionUnknown;
     switch (direction) {
-    case DirectionForward:
+    case SelectionDirection::Forward:
         intentDirection = AXTextSelectionDirectionNext;
         break;
-    case DirectionRight:
+    case SelectionDirection::Right:
         intentDirection = AXTextSelectionDirectionNext;
         break;
-    case DirectionBackward:
+    case SelectionDirection::Backward:
         intentDirection = AXTextSelectionDirectionPrevious;
         break;
-    case DirectionLeft:
+    case SelectionDirection::Left:
         intentDirection = AXTextSelectionDirectionPrevious;
         break;
     }
     AXTextSelectionGranularity intentGranularity = AXTextSelectionGranularityUnknown;
     switch (granularity) {
-    case CharacterGranularity:
+    case TextGranularity::CharacterGranularity:
         intentGranularity = AXTextSelectionGranularityCharacter;
         break;
-    case WordGranularity:
+    case TextGranularity::WordGranularity:
         intentGranularity = AXTextSelectionGranularityWord;
         break;
-    case SentenceGranularity:
-    case SentenceBoundary: // FIXME: Boundary should affect direction.
+    case TextGranularity::SentenceGranularity:
+    case TextGranularity::SentenceBoundary: // FIXME: Boundary should affect direction.
         intentGranularity = AXTextSelectionGranularitySentence;
         break;
-    case LineGranularity:
+    case TextGranularity::LineGranularity:
         intentGranularity = AXTextSelectionGranularityLine;
         break;
-    case ParagraphGranularity:
-    case ParagraphBoundary: // FIXME: Boundary should affect direction.
+    case TextGranularity::ParagraphGranularity:
+    case TextGranularity::ParagraphBoundary: // FIXME: Boundary should affect direction.
         intentGranularity = AXTextSelectionGranularityParagraph;
         break;
-    case DocumentGranularity:
-    case DocumentBoundary: // FIXME: Boundary should affect direction.
+    case TextGranularity::DocumentGranularity:
+    case TextGranularity::DocumentBoundary: // FIXME: Boundary should affect direction.
         intentGranularity = AXTextSelectionGranularityDocument;
         break;
-    case LineBoundary:
+    case TextGranularity::LineBoundary:
         intentGranularity = AXTextSelectionGranularityLine;
         switch (direction) {
-        case DirectionForward:
+        case SelectionDirection::Forward:
             intentDirection = AXTextSelectionDirectionEnd;
             break;
-        case DirectionRight:
+        case SelectionDirection::Right:
             intentDirection = AXTextSelectionDirectionEnd;
             break;
-        case DirectionBackward:
+        case SelectionDirection::Backward:
             intentDirection = AXTextSelectionDirectionBeginning;
             break;
-        case DirectionLeft:
+        case SelectionDirection::Left:
             intentDirection = AXTextSelectionDirectionBeginning;
             break;
         }
@@ -1344,25 +1344,25 @@ bool FrameSelection::modify(EAlteration alter, SelectionDirection direction, Tex
     Position originalStartPosition = m_selection.start();
     VisiblePosition position;
     switch (direction) {
-    case DirectionRight:
+    case SelectionDirection::Right:
         if (alter == AlterationMove)
             position = modifyMovingRight(granularity, &reachedBoundary);
         else
             position = modifyExtendingRight(granularity);
         break;
-    case DirectionForward:
+    case SelectionDirection::Forward:
         if (alter == AlterationExtend)
             position = modifyExtendingForward(granularity);
         else
             position = modifyMovingForward(granularity, &reachedBoundary);
         break;
-    case DirectionLeft:
+    case SelectionDirection::Left:
         if (alter == AlterationMove)
             position = modifyMovingLeft(granularity, &reachedBoundary);
         else
             position = modifyExtendingLeft(granularity);
         break;
-    case DirectionBackward:
+    case SelectionDirection::Backward:
         if (alter == AlterationExtend)
             position = modifyExtendingBackward(granularity);
         else
@@ -1402,7 +1402,7 @@ bool FrameSelection::modify(EAlteration alter, SelectionDirection direction, Tex
     case AlterationExtend:
 
         if (!m_selection.isCaret()
-            && (granularity == WordGranularity || granularity == ParagraphGranularity || granularity == LineGranularity)
+            && (granularity == TextGranularity::WordGranularity || granularity == TextGranularity::ParagraphGranularity || granularity == TextGranularity::LineGranularity)
             && m_document && !m_document->editor().behavior().shouldExtendSelectionByWordOrLineAcrossCaret()) {
             // Don't let the selection go across the base position directly. Needed to match mac
             // behavior when, for instance, word-selecting backwards starting with the caret in
@@ -1420,7 +1420,7 @@ bool FrameSelection::modify(EAlteration alter, SelectionDirection direction, Tex
             setExtent(position, userTriggered);
         else {
             TextDirection textDirection = directionOfEnclosingBlock();
-            if (direction == DirectionForward || (textDirection == TextDirection::LTR && direction == DirectionRight) || (textDirection == TextDirection::RTL && direction == DirectionLeft))
+            if (direction == SelectionDirection::Forward || (textDirection == TextDirection::LTR && direction == SelectionDirection::Right) || (textDirection == TextDirection::RTL && direction == SelectionDirection::Left))
                 setEnd(position, userTriggered);
             else
                 setStart(position, userTriggered);
@@ -1428,11 +1428,11 @@ bool FrameSelection::modify(EAlteration alter, SelectionDirection direction, Tex
         break;
     }
     
-    if (granularity == LineGranularity || granularity == ParagraphGranularity)
+    if (granularity == TextGranularity::LineGranularity || granularity == TextGranularity::ParagraphGranularity)
         m_xPosForVerticalArrowNavigation = x;
 
     if (userTriggered == UserTriggered)
-        m_granularity = CharacterGranularity;
+        m_granularity = TextGranularity::CharacterGranularity;
 
     setCaretRectNeedsUpdate();
 
@@ -1464,7 +1464,7 @@ bool FrameSelection::modify(EAlteration alter, unsigned verticalDistance, Vertic
             return false;
     }
 
-    willBeModified(alter, direction == DirectionUp ? DirectionBackward : DirectionForward);
+    willBeModified(alter, direction == DirectionUp ? SelectionDirection::Backward : SelectionDirection::Forward);
 
     VisiblePosition pos;
     LayoutUnit xPos;
@@ -1524,7 +1524,7 @@ bool FrameSelection::modify(EAlteration alter, unsigned verticalDistance, Vertic
     }
 
     if (userTriggered == UserTriggered)
-        m_granularity = CharacterGranularity;
+        m_granularity = TextGranularity::CharacterGranularity;
 
     m_selection.setIsDirectional(shouldAlwaysUseDirectionalSelection(m_document) || alter == AlterationExtend);
 
@@ -1572,13 +1572,13 @@ LayoutUnit FrameSelection::lineDirectionPointForBlockDirectionNavigation(EPositi
 
 void FrameSelection::clear()
 {
-    m_granularity = CharacterGranularity;
+    m_granularity = TextGranularity::CharacterGranularity;
     setSelection(VisibleSelection());
 }
 
 void FrameSelection::willBeRemovedFromFrame()
 {
-    m_granularity = CharacterGranularity;
+    m_granularity = TextGranularity::CharacterGranularity;
 
 #if ENABLE(TEXT_CARET)
     m_caretBlinkTimer.stop();
@@ -1587,7 +1587,7 @@ void FrameSelection::willBeRemovedFromFrame()
     if (auto* view = m_document->renderView())
         view->selection().clearSelection();
 
-    setSelectionWithoutUpdatingAppearance(VisibleSelection(), defaultSetSelectionOptions(), AlignCursorOnScrollIfNeeded, CharacterGranularity);
+    setSelectionWithoutUpdatingAppearance(VisibleSelection(), defaultSetSelectionOptions(), AlignCursorOnScrollIfNeeded, TextGranularity::CharacterGranularity);
     m_previousCaretNode = nullptr;
     m_typingStyle = nullptr;
     m_appearanceUpdateTimer.stop();
@@ -2165,7 +2165,7 @@ void FrameSelection::updateAppearance()
     // Construct a new VisibleSolution, since m_selection is not necessarily valid, and the following steps
     // assume a valid selection. See <https://bugs.webkit.org/show_bug.cgi?id=69563> and <rdar://problem/10232866>.
 #if ENABLE(TEXT_CARET)
-    VisiblePosition endVisiblePosition = paintBlockCursor ? modifyExtendingForward(CharacterGranularity) : oldSelection.visibleEnd();
+    VisiblePosition endVisiblePosition = paintBlockCursor ? modifyExtendingForward(TextGranularity::CharacterGranularity) : oldSelection.visibleEnd();
     VisibleSelection selection(oldSelection.visibleStart(), endVisiblePosition);
 #else
     VisibleSelection selection(oldSelection.visibleStart(), oldSelection.visibleEnd());
@@ -2743,10 +2743,10 @@ VisibleSelection FrameSelection::wordSelectionContainingCaretSelection(const Vis
     // This has the effect of selecting the word on the line (which is
     // what we want, rather than selecting past the end of the line).
     if (isEndOfParagraph(endVisiblePosBeforeExpansion) && !isStartOfParagraph(endVisiblePosBeforeExpansion))
-        frameSelection.modify(FrameSelection::AlterationMove, DirectionBackward, CharacterGranularity);
+        frameSelection.modify(FrameSelection::AlterationMove, SelectionDirection::Backward, TextGranularity::CharacterGranularity);
 
     VisibleSelection newSelection = frameSelection.selection();
-    newSelection.expandUsingGranularity(WordGranularity);
+    newSelection.expandUsingGranularity(TextGranularity::WordGranularity);
     frameSelection.setSelection(newSelection, defaultSetSelectionOptions(), AXTextStateChangeIntent(), AlignCursorOnScrollIfNeeded, frameSelection.granularity());
 
     Position startPos(frameSelection.selection().start());
@@ -2796,7 +2796,7 @@ VisibleSelection FrameSelection::wordSelectionContainingCaretSelection(const Vis
             return VisibleSelection();
         }
         frameSelection.moveTo(startVisiblePos);
-        frameSelection.modify(FrameSelection::AlterationExtend, DirectionBackward, WordGranularity);
+        frameSelection.modify(FrameSelection::AlterationExtend, SelectionDirection::Backward, TextGranularity::WordGranularity);
         startPos = frameSelection.selection().start();
         endPos = frameSelection.selection().end();
         startVisiblePos = VisiblePosition(startPos, VP_DEFAULT_AFFINITY);
@@ -2872,9 +2872,9 @@ Optional<SimpleRange> FrameSelection::rangeByAlteringCurrentSelection(EAlteratio
 
     FrameSelection frameSelection;
     frameSelection.setSelection(m_selection);
-    SelectionDirection direction = amount > 0 ? DirectionForward : DirectionBackward;
+    SelectionDirection direction = amount > 0 ? SelectionDirection::Forward : SelectionDirection::Backward;
     for (int i = 0; i < abs(amount); i++)
-        frameSelection.modify(alteration, direction, CharacterGranularity);
+        frameSelection.modify(alteration, direction, TextGranularity::CharacterGranularity);
     return frameSelection.selection().toNormalizedRange();
 }
 
index ee073a6..895c652 100644 (file)
@@ -152,7 +152,7 @@ public:
     void moveWithoutValidationTo(const Position&, const Position&, bool selectionHasDirection, bool shouldSetFocus, SelectionRevealMode, const AXTextStateChangeIntent& = AXTextStateChangeIntent());
 
     const VisibleSelection& selection() const { return m_selection; }
-    WEBCORE_EXPORT void setSelection(const VisibleSelection&, OptionSet<SetSelectionOption> = defaultSetSelectionOptions(), AXTextStateChangeIntent = AXTextStateChangeIntent(), CursorAlignOnScroll = AlignCursorOnScrollIfNeeded, TextGranularity = CharacterGranularity);
+    WEBCORE_EXPORT void setSelection(const VisibleSelection&, OptionSet<SetSelectionOption> = defaultSetSelectionOptions(), AXTextStateChangeIntent = AXTextStateChangeIntent(), CursorAlignOnScroll = AlignCursorOnScrollIfNeeded, TextGranularity = TextGranularity::CharacterGranularity);
 
     enum class ShouldCloseTyping : bool { No, Yes };
     WEBCORE_EXPORT bool setSelectedRange(Range*, EAffinity, ShouldCloseTyping, EUserTriggered = NotUserTriggered);
index c0f536a..a341c52 100644 (file)
@@ -31,7 +31,7 @@ namespace WebCore {
 
 // FIXME: This really should be broken up into more than one concept.
 // Frame doesn't need the 3 boundaries in this enum.
-enum TextGranularity {
+enum class TextGranularity : uint8_t {
     CharacterGranularity,
     WordGranularity,
     SentenceGranularity,
index 8b9e7d0..af5eb1b 100644 (file)
@@ -101,16 +101,16 @@ static inline EditAction editActionForTypingCommand(TypingCommand::ETypingComman
     case TypingCommand::DeleteSelection:
         return EditAction::TypingDeleteSelection;
     case TypingCommand::DeleteKey: {
-        if (granularity == WordGranularity)
+        if (granularity == TextGranularity::WordGranularity)
             return EditAction::TypingDeleteWordBackward;
-        if (granularity == LineBoundary)
+        if (granularity == TextGranularity::LineBoundary)
             return EditAction::TypingDeleteLineBackward;
         return EditAction::TypingDeleteBackward;
     }
     case TypingCommand::ForwardDeleteKey:
-        if (granularity == WordGranularity)
+        if (granularity == TextGranularity::WordGranularity)
             return EditAction::TypingDeleteWordForward;
-        if (granularity == LineBoundary)
+        if (granularity == TextGranularity::LineBoundary)
             return EditAction::TypingDeleteLineForward;
         return EditAction::TypingDeleteForward;
     case TypingCommand::InsertText:
@@ -179,7 +179,7 @@ void TypingCommand::deleteSelection(Document& document, Options options, TextCom
 
 void TypingCommand::deleteKeyPressed(Document& document, Options options, TextGranularity granularity)
 {
-    if (granularity == CharacterGranularity) {
+    if (granularity == TextGranularity::CharacterGranularity) {
         if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document)) {
             updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand.get(), document);
             lastTypingCommand->setIsAutocompletion(options & IsAutocompletion);
@@ -196,7 +196,7 @@ void TypingCommand::deleteKeyPressed(Document& document, Options options, TextGr
 void TypingCommand::forwardDeleteKeyPressed(Document& document, Options options, TextGranularity granularity)
 {
     // FIXME: Forward delete in TextEdit appears to open and close a new typing command.
-    if (granularity == CharacterGranularity) {
+    if (granularity == TextGranularity::CharacterGranularity) {
         if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document)) {
             updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand.get(), document);
             lastTypingCommand->setIsAutocompletion(options & IsAutocompletion);
@@ -530,7 +530,7 @@ void TypingCommand::insertTextAndNotifyAccessibility(const String &text, bool se
 
 void TypingCommand::insertTextRunWithoutNewlines(const String &text, bool selectInsertedText)
 {
-    if (!willAddTypingToOpenCommand(InsertText, CharacterGranularity, text))
+    if (!willAddTypingToOpenCommand(InsertText, TextGranularity::CharacterGranularity, text))
         return;
 
     auto command = InsertTextCommand::create(document(), text, selectInsertedText,
@@ -545,7 +545,7 @@ void TypingCommand::insertLineBreak()
     if (!canAppendNewLineFeedToSelection(endingSelection()))
         return;
 
-    if (!willAddTypingToOpenCommand(InsertLineBreak, LineGranularity))
+    if (!willAddTypingToOpenCommand(InsertLineBreak, TextGranularity::LineGranularity))
         return;
 
     applyCommandToComposite(InsertLineBreakCommand::create(document()));
@@ -565,7 +565,7 @@ void TypingCommand::insertParagraphSeparator()
     if (!canAppendNewLineFeedToSelection(endingSelection()))
         return;
 
-    if (!willAddTypingToOpenCommand(InsertParagraphSeparator, ParagraphGranularity))
+    if (!willAddTypingToOpenCommand(InsertParagraphSeparator, TextGranularity::ParagraphGranularity))
         return;
 
     applyCommandToComposite(InsertParagraphSeparatorCommand::create(document(), false, false, EditAction::TypingInsertParagraph));
@@ -582,7 +582,7 @@ void TypingCommand::insertParagraphSeparatorAndNotifyAccessibility()
 
 void TypingCommand::insertParagraphSeparatorInQuotedContent()
 {
-    if (!willAddTypingToOpenCommand(InsertParagraphSeparatorInQuotedContent, ParagraphGranularity))
+    if (!willAddTypingToOpenCommand(InsertParagraphSeparatorInQuotedContent, TextGranularity::ParagraphGranularity))
         return;
 
     // If the selection starts inside a table, just insert the paragraph separator normally
@@ -650,9 +650,9 @@ void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool shouldAdd
 
         FrameSelection selection;
         selection.setSelection(endingSelection());
-        selection.modify(FrameSelection::AlterationExtend, DirectionBackward, granularity);
-        if (shouldAddToKillRing && selection.isCaret() && granularity != CharacterGranularity)
-            selection.modify(FrameSelection::AlterationExtend, DirectionBackward, CharacterGranularity);
+        selection.modify(FrameSelection::AlterationExtend, SelectionDirection::Backward, granularity);
+        if (shouldAddToKillRing && selection.isCaret() && granularity != TextGranularity::CharacterGranularity)
+            selection.modify(FrameSelection::AlterationExtend, SelectionDirection::Backward, TextGranularity::CharacterGranularity);
 
         const VisiblePosition& visibleStart = endingSelection().visibleStart();
         const VisiblePosition& previousPosition = visibleStart.previous(CannotCrossEditingBoundary);
@@ -687,7 +687,7 @@ void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool shouldAdd
             if (isLastPositionBeforeTable(visibleStart))
                 return;
             // Extend the selection backward into the last cell, then deletion will handle the move.
-            selection.modify(FrameSelection::AlterationExtend, DirectionBackward, granularity);
+            selection.modify(FrameSelection::AlterationExtend, SelectionDirection::Backward, granularity);
         // If the caret is just after a table, select the table and don't delete anything.
         } else if (Node* table = isFirstPositionAfterTable(visibleStart)) {
             setEndingSelection(VisibleSelection(positionBeforeNode(table), endingSelection().start(), DOWNSTREAM, endingSelection().isDirectional()));
@@ -697,7 +697,7 @@ void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool shouldAdd
 
         selectionToDelete = selection.selection();
 
-        if (granularity == CharacterGranularity && selectionToDelete.end().containerNode() == selectionToDelete.start().containerNode()
+        if (granularity == TextGranularity::CharacterGranularity && selectionToDelete.end().containerNode() == selectionToDelete.start().containerNode()
             && selectionToDelete.end().computeOffsetInContainerNode() - selectionToDelete.start().computeOffsetInContainerNode() > 1) {
             // If there are multiple Unicode code points to be deleted, adjust the range to match platform conventions.
             selectionToDelete.setWithoutValidation(selectionToDelete.end(), selectionToDelete.end().previous(BackwardDeletion));
@@ -773,11 +773,11 @@ void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool sh
         // root editable element or at the start of a document.
         FrameSelection selection;
         selection.setSelection(endingSelection());
-        selection.modify(FrameSelection::AlterationExtend, DirectionForward, granularity);
+        selection.modify(FrameSelection::AlterationExtend, SelectionDirection::Forward, granularity);
         if (selection.isNone())
             return;
-        if (shouldAddToKillRing && selection.isCaret() && granularity != CharacterGranularity)
-            selection.modify(FrameSelection::AlterationExtend, DirectionForward, CharacterGranularity);
+        if (shouldAddToKillRing && selection.isCaret() && granularity != TextGranularity::CharacterGranularity)
+            selection.modify(FrameSelection::AlterationExtend, SelectionDirection::Forward, TextGranularity::CharacterGranularity);
 
         Position downstreamEnd = endingSelection().end().downstream();
         VisiblePosition visibleEnd = endingSelection().visibleEnd();
@@ -795,8 +795,8 @@ void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool sh
         }
 
         // deleting to end of paragraph when at end of paragraph needs to merge the next paragraph (if any)
-        if (granularity == ParagraphBoundary && selection.selection().isCaret() && isEndOfParagraph(selection.selection().visibleEnd()))
-            selection.modify(FrameSelection::AlterationExtend, DirectionForward, CharacterGranularity);
+        if (granularity == TextGranularity::ParagraphBoundary && selection.selection().isCaret() && isEndOfParagraph(selection.selection().visibleEnd()))
+            selection.modify(FrameSelection::AlterationExtend, SelectionDirection::Forward, TextGranularity::CharacterGranularity);
 
         selectionToDelete = selection.selection();
         if (!startingSelection().isRange() || selectionToDelete.base() != startingSelection().start())
@@ -856,7 +856,7 @@ void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool sh
 
 void TypingCommand::deleteSelection(bool smartDelete)
 {
-    if (!willAddTypingToOpenCommand(DeleteSelection, CharacterGranularity))
+    if (!willAddTypingToOpenCommand(DeleteSelection, TextGranularity::CharacterGranularity))
         return;
 
     CompositeEditCommand::deleteSelection(smartDelete);
index 896bf0b..e976a6b 100644 (file)
@@ -58,8 +58,8 @@ public:
     typedef unsigned Options;
 
     static void deleteSelection(Document&, Options = 0, TextCompositionType = TextCompositionNone);
-    static void deleteKeyPressed(Document&, Options = 0, TextGranularity = CharacterGranularity);
-    static void forwardDeleteKeyPressed(Document&, Options = 0, TextGranularity = CharacterGranularity);
+    static void deleteKeyPressed(Document&, Options = 0, TextGranularity = TextGranularity::CharacterGranularity);
+    static void forwardDeleteKeyPressed(Document&, Options = 0, TextGranularity = TextGranularity::CharacterGranularity);
     static void insertText(Document&, const String&, Options, TextCompositionType = TextCompositionNone);
     static void insertText(Document&, const String&, const VisibleSelection&, Options, TextCompositionType = TextCompositionNone);
     static void insertLineBreak(Document&, Options);
@@ -86,14 +86,14 @@ public:
 #endif
 
 private:
-    static Ref<TypingCommand> create(Document& document, ETypingCommand command, const String& text = emptyString(), Options options = 0, TextGranularity granularity = CharacterGranularity, TextCompositionType compositionType = TextCompositionNone)
+    static Ref<TypingCommand> create(Document& document, ETypingCommand command, const String& text = emptyString(), Options options = 0, TextGranularity granularity = TextGranularity::CharacterGranularity, TextCompositionType compositionType = TextCompositionNone)
     {
         return adoptRef(*new TypingCommand(document, command, text, options, granularity, compositionType));
     }
 
     static Ref<TypingCommand> create(Document& document, ETypingCommand command, const String& text, Options options, TextCompositionType compositionType)
     {
-        return adoptRef(*new TypingCommand(document, command, text, options, CharacterGranularity, compositionType));
+        return adoptRef(*new TypingCommand(document, command, text, options, TextGranularity::CharacterGranularity, compositionType));
     }
 
     TypingCommand(Document&, ETypingCommand, const String& text, Options, TextGranularity, TextCompositionType);
index bda4b1e..5acb0d4 100644 (file)
@@ -271,10 +271,10 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text
     }
 
     switch (granularity) {
-        case CharacterGranularity:
+        case TextGranularity::CharacterGranularity:
             // Don't do any expansion.
             break;
-        case WordGranularity: {
+        case TextGranularity::WordGranularity: {
             // General case: Select the word the caret is positioned inside of, or at the start of (RightWordIfOnBoundary).
             // Edge case: If the caret is after the last word in a soft-wrapped line or the last word in
             // the document, select that last word (LeftWordIfOnBoundary).
@@ -289,7 +289,7 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text
             side = RightWordIfOnBoundary;
             if (isEndOfEditableOrNonEditableContent(originalEnd) || (isEndOfLine(originalEnd) && !isStartOfLine(originalEnd) && !isEndOfParagraph(originalEnd)))
                 side = LeftWordIfOnBoundary;
-                
+
             VisiblePosition wordEnd(endOfWord(originalEnd, side));
             VisiblePosition end(wordEnd);
             
@@ -321,12 +321,12 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text
             }
             break;
         }
-        case SentenceGranularity: {
+        case TextGranularity::SentenceGranularity: {
             m_start = startOfSentence(VisiblePosition(m_start, m_affinity)).deepEquivalent();
             m_end = endOfSentence(VisiblePosition(m_end, m_affinity)).deepEquivalent();
             break;
         }
-        case LineGranularity: {
+        case TextGranularity::LineGranularity: {
             m_start = startOfLine(VisiblePosition(m_start, m_affinity)).deepEquivalent();
             VisiblePosition end = endOfLine(VisiblePosition(m_end, m_affinity));
             // If the end of this line is at the end of a paragraph, include the space 
@@ -339,11 +339,11 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text
             m_end = end.deepEquivalent();
             break;
         }
-        case LineBoundary:
+        case TextGranularity::LineBoundary:
             m_start = startOfLine(VisiblePosition(m_start, m_affinity)).deepEquivalent();
             m_end = endOfLine(VisiblePosition(m_end, m_affinity)).deepEquivalent();
             break;
-        case ParagraphGranularity: {
+        case TextGranularity::ParagraphGranularity: {
             VisiblePosition pos(m_start, m_affinity);
             if (isStartOfLine(pos) && isEndOfEditableOrNonEditableContent(pos))
                 pos = pos.previous();
@@ -353,7 +353,7 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text
             // Include the "paragraph break" (the space from the end of this paragraph to the start
             // of the next one) in the selection.
             VisiblePosition end(visibleParagraphEnd.next());
-             
+
             if (Node* table = isFirstPositionAfterTable(end)) {
                 // The paragraph break after the last paragraph in the last cell of a block table ends
                 // at the start of the paragraph after the table, not at the position just after the table.
@@ -363,26 +363,26 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text
                 else
                     end = visibleParagraphEnd;
             }
-             
+
             if (end.isNull())
                 end = visibleParagraphEnd;
-                
+
             m_end = end.deepEquivalent();
             break;
         }
-        case DocumentBoundary:
+        case TextGranularity::DocumentBoundary:
             m_start = startOfDocument(m_start.document()).deepEquivalent();
             m_end = endOfDocument(m_end.document()).deepEquivalent();
             break;
-        case ParagraphBoundary:
+        case TextGranularity::ParagraphBoundary:
             m_start = startOfParagraph(VisiblePosition(m_start, m_affinity)).deepEquivalent();
             m_end = endOfParagraph(VisiblePosition(m_end, m_affinity)).deepEquivalent();
             break;
-        case SentenceBoundary:
+        case TextGranularity::SentenceBoundary:
             m_start = startOfSentence(VisiblePosition(m_start, m_affinity)).deepEquivalent();
             m_end = endOfSentence(VisiblePosition(m_end, m_affinity)).deepEquivalent();
             break;
-        case DocumentGranularity:
+        case TextGranularity::DocumentGranularity:
             ASSERT_NOT_REACHED();
             break;
     }
index 8f4fc98..3f882e1 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "TextGranularity.h"
 #include "VisiblePosition.h"
+#include <wtf/EnumTraits.h>
 
 namespace WebCore {
 
@@ -35,7 +36,7 @@ class Position;
 struct SimpleRange;
 
 const EAffinity SEL_DEFAULT_AFFINITY = DOWNSTREAM;
-enum SelectionDirection : uint8_t { DirectionForward, DirectionBackward, DirectionRight, DirectionLeft };
+enum class SelectionDirection : uint8_t { Forward, Backward, Right, Left };
 
 class VisibleSelection {
 public:
@@ -117,7 +118,7 @@ public:
     void setWithoutValidation(const Position&, const Position&);
 
 private:
-    void validate(TextGranularity = CharacterGranularity);
+    void validate(TextGranularity = TextGranularity::CharacterGranularity);
 
     // Support methods for validate()
     void setBaseAndExtentToDeepEquivalents();
@@ -164,3 +165,17 @@ WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, const VisibleSelect
 void showTree(const WebCore::VisibleSelection&);
 void showTree(const WebCore::VisibleSelection*);
 #endif
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::SelectionDirection> {
+    using values = EnumValues<
+        WebCore::SelectionDirection,
+        WebCore::SelectionDirection::Forward,
+        WebCore::SelectionDirection::Backward,
+        WebCore::SelectionDirection::Right,
+        WebCore::SelectionDirection::Left
+    >;
+};
+
+} // namespace WTF
index 27a7f9c..12d4cac 100644 (file)
@@ -1558,20 +1558,20 @@ VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire
 
 static bool directionIsDownstream(SelectionDirection direction)
 {
-    if (direction == DirectionBackward)
+    if (direction == SelectionDirection::Backward)
         return false;
-    else if (direction == DirectionForward)
+    if (direction == SelectionDirection::Forward)
         return true;
 
     // FIXME: this code doesn't take into account the original direction of the element.
     // I'm not fixing this now because I'm afraid there is some code in UIKit relying on
     // this wrong behavior.
-    return direction == DirectionRight;
+    return direction == SelectionDirection::Right;
 }
 
 bool atBoundaryOfGranularity(const VisiblePosition& vp, TextGranularity granularity, SelectionDirection direction)
 {
-    if (granularity == CharacterGranularity)
+    if (granularity == TextGranularity::CharacterGranularity)
         return true;
 
     VisiblePosition boundary;
@@ -1579,7 +1579,7 @@ bool atBoundaryOfGranularity(const VisiblePosition& vp, TextGranularity granular
     bool useDownstream = directionIsDownstream(direction);
 
     switch (granularity) {
-    case WordGranularity:
+    case TextGranularity::WordGranularity:
         // visible_units claims erroneously that the start and the end
         // of a paragraph are the end and start of a word, respectively.
         if ((useDownstream && isStartOfParagraph(vp)) || (!useDownstream && isEndOfParagraph(vp)))
@@ -1589,22 +1589,22 @@ bool atBoundaryOfGranularity(const VisiblePosition& vp, TextGranularity granular
         boundary = useDownstream ? endOfWord(vp, LeftWordIfOnBoundary) : startOfWord(vp, RightWordIfOnBoundary);
         break;
 
-    case SentenceGranularity:
+    case TextGranularity::SentenceGranularity:
         boundary = useDownstream ? endOfSentence(previousSentencePosition(vp)) : startOfSentence(nextSentencePosition(vp));
         break;
 
-    case LineGranularity:
+    case TextGranularity::LineGranularity:
         // Affinity has to be set to get right boundary of the line.
         boundary = vp;
         boundary.setAffinity(useDownstream ? VP_UPSTREAM_IF_POSSIBLE : DOWNSTREAM);
         boundary = useDownstream ? endOfLine(boundary) : startOfLine(boundary);
         break;
 
-    case ParagraphGranularity:
+    case TextGranularity::ParagraphGranularity:
         boundary = useDownstream ? endOfParagraph(vp) : startOfParagraph(vp);
         break;
 
-    case DocumentGranularity:
+    case TextGranularity::DocumentGranularity:
         boundary = useDownstream ? endOfDocument(vp) : startOfDocument(vp);
         break;
 
@@ -1618,7 +1618,7 @@ bool atBoundaryOfGranularity(const VisiblePosition& vp, TextGranularity granular
 
 bool withinTextUnitOfGranularity(const VisiblePosition& vp, TextGranularity granularity, SelectionDirection direction)
 {
-    if (granularity == CharacterGranularity || granularity == DocumentGranularity)
+    if (granularity == TextGranularity::CharacterGranularity || granularity == TextGranularity::DocumentGranularity)
         return true;
 
     bool useDownstream = directionIsDownstream(direction);
@@ -1627,7 +1627,7 @@ bool withinTextUnitOfGranularity(const VisiblePosition& vp, TextGranularity gran
     VisiblePosition nextBoundary;
     
     switch (granularity) {
-    case WordGranularity:
+    case TextGranularity::WordGranularity:
         // Note that "Left" and "Right" in this context apparently mean "upstream/previous" and "downstream/next".
         prevBoundary = startOfWord(vp, (useDownstream ? RightWordIfOnBoundary : LeftWordIfOnBoundary));
         nextBoundary = endOfWord(vp, (useDownstream ? RightWordIfOnBoundary : LeftWordIfOnBoundary));
@@ -1638,12 +1638,12 @@ bool withinTextUnitOfGranularity(const VisiblePosition& vp, TextGranularity gran
 
         break;
 
-    case SentenceGranularity:
+    case TextGranularity::SentenceGranularity:
         prevBoundary = startOfSentence(vp);
         nextBoundary = endOfSentence(vp);
         break;
 
-    case LineGranularity:
+    case TextGranularity::LineGranularity:
         prevBoundary = startOfLine(vp);
         nextBoundary = endOfLine(vp);
 
@@ -1655,7 +1655,7 @@ bool withinTextUnitOfGranularity(const VisiblePosition& vp, TextGranularity gran
         }
         break;
 
-    case ParagraphGranularity:
+    case TextGranularity::ParagraphGranularity:
         prevBoundary = startOfParagraph(vp);
         nextBoundary = endOfParagraph(vp);
         break;
@@ -1685,7 +1685,7 @@ static VisiblePosition nextCharacterBoundaryInDirection(const VisiblePosition& v
 static VisiblePosition nextWordBoundaryInDirection(const VisiblePosition& vp, SelectionDirection direction)
 {
     bool useDownstream = directionIsDownstream(direction);
-    bool withinUnitOfGranularity = withinTextUnitOfGranularity(vp, WordGranularity, direction);
+    bool withinUnitOfGranularity = withinTextUnitOfGranularity(vp, TextGranularity::WordGranularity, direction);
     VisiblePosition result;
     
     if (useDownstream) {
@@ -1759,7 +1759,7 @@ static VisiblePosition nextWordBoundaryInDirection(const VisiblePosition& vp, Se
 static VisiblePosition nextSentenceBoundaryInDirection(const VisiblePosition& vp, SelectionDirection direction)
 {
     bool useDownstream = directionIsDownstream(direction);
-    bool withinUnitOfGranularity = withinTextUnitOfGranularity(vp, SentenceGranularity, direction);
+    bool withinUnitOfGranularity = withinTextUnitOfGranularity(vp, TextGranularity::SentenceGranularity, direction);
     VisiblePosition result;
 
     if (withinUnitOfGranularity)
@@ -1801,9 +1801,9 @@ static VisiblePosition nextParagraphBoundaryInDirection(const VisiblePosition& p
 {
     auto useDownstream = directionIsDownstream(direction);
     auto lineDirection = position.lineDirectionPointForBlockDirectionNavigation();
-    if (atBoundaryOfGranularity(position, ParagraphGranularity, direction))
+    if (atBoundaryOfGranularity(position, TextGranularity::ParagraphGranularity, direction))
         return useDownstream ? startOfParagraph(nextParagraphPosition(position, lineDirection)) : endOfParagraph(previousParagraphPosition(position, lineDirection));
-    ASSERT(withinTextUnitOfGranularity(position, ParagraphGranularity, direction));
+    ASSERT(withinTextUnitOfGranularity(position, TextGranularity::ParagraphGranularity, direction));
     return useDownstream ? endOfParagraph(position) : startOfParagraph(position);
 }
 
@@ -1815,17 +1815,17 @@ static VisiblePosition nextDocumentBoundaryInDirection(const VisiblePosition& vp
 VisiblePosition positionOfNextBoundaryOfGranularity(const VisiblePosition& vp, TextGranularity granularity, SelectionDirection direction)
 {
     switch (granularity) {
-    case CharacterGranularity:
+    case TextGranularity::CharacterGranularity:
         return nextCharacterBoundaryInDirection(vp, direction, CanCrossEditingBoundary);
-    case WordGranularity:
+    case TextGranularity::WordGranularity:
         return nextWordBoundaryInDirection(vp, direction);
-    case SentenceGranularity:
+    case TextGranularity::SentenceGranularity:
         return nextSentenceBoundaryInDirection(vp, direction);
-    case LineGranularity:
+    case TextGranularity::LineGranularity:
         return nextLineBoundaryInDirection(vp, direction);
-    case ParagraphGranularity:
+    case TextGranularity::ParagraphGranularity:
         return nextParagraphBoundaryInDirection(vp, direction);
-    case DocumentGranularity:
+    case TextGranularity::DocumentGranularity:
         return nextDocumentBoundaryInDirection(vp, direction);
     default:
         ASSERT_NOT_REACHED();
@@ -1844,12 +1844,12 @@ RefPtr<Range> enclosingTextUnitOfGranularity(const VisiblePosition& vp, TextGran
     bool useDownstream = directionIsDownstream(direction);
 
     switch (granularity) {
-        case CharacterGranularity:
+        case TextGranularity::CharacterGranularity:
             prevBoundary = vp;
             nextBoundary = prevBoundary.next();
             break;
 
-        case WordGranularity:
+        case TextGranularity::WordGranularity:
             // NB: "Left" and "Right" in this context apparently mean "upstream/previous" and "downstream/next".
             if (useDownstream) {
                 prevBoundary = startOfWord(vp, RightWordIfOnBoundary);
@@ -1860,12 +1860,12 @@ RefPtr<Range> enclosingTextUnitOfGranularity(const VisiblePosition& vp, TextGran
             }
             break;
 
-        case SentenceGranularity:
+        case TextGranularity::SentenceGranularity:
             prevBoundary = startOfSentence(vp);
             nextBoundary = endOfSentence(vp);
             break;
 
-        case LineGranularity:
+        case TextGranularity::LineGranularity:
             prevBoundary = startOfLine(vp);
             nextBoundary = endOfLine(vp);
 
@@ -1877,12 +1877,12 @@ RefPtr<Range> enclosingTextUnitOfGranularity(const VisiblePosition& vp, TextGran
             }
             break;
 
-        case ParagraphGranularity:
+        case TextGranularity::ParagraphGranularity:
             prevBoundary = startOfParagraph(vp);
             nextBoundary = endOfParagraph(vp);
             break;
 
-        case DocumentGranularity:
+        case TextGranularity::DocumentGranularity:
             prevBoundary = startOfDocument(vp);
             nextBoundary = endOfDocument(vp);
             break;
@@ -1921,14 +1921,14 @@ void charactersAroundPosition(const VisiblePosition& position, UChar32& oneAfter
     VisiblePosition startPosition = position;
     VisiblePosition endPosition = position;
 
-    VisiblePosition nextPosition = nextCharacterBoundaryInDirection(position, DirectionForward, CannotCrossEditingBoundary);
+    VisiblePosition nextPosition = nextCharacterBoundaryInDirection(position, SelectionDirection::Forward, CannotCrossEditingBoundary);
     if (nextPosition.isNotNull())
         endPosition = nextPosition;
 
-    VisiblePosition previousPosition = nextCharacterBoundaryInDirection(position, DirectionBackward, CannotCrossEditingBoundary);
+    VisiblePosition previousPosition = nextCharacterBoundaryInDirection(position, SelectionDirection::Backward, CannotCrossEditingBoundary);
     if (previousPosition.isNotNull()) {
         startPosition = previousPosition;
-        previousPosition = nextCharacterBoundaryInDirection(previousPosition, DirectionBackward, CannotCrossEditingBoundary);
+        previousPosition = nextCharacterBoundaryInDirection(previousPosition, SelectionDirection::Backward, CannotCrossEditingBoundary);
         if (previousPosition.isNotNull())
             startPosition = previousPosition;
     }
@@ -1952,11 +1952,11 @@ RefPtr<Range> wordRangeFromPosition(const VisiblePosition& position)
     if (position.isNull())
         return nullptr;
 
-    RefPtr<Range> range = enclosingTextUnitOfGranularity(position, WordGranularity, DirectionBackward);
+    RefPtr<Range> range = enclosingTextUnitOfGranularity(position, TextGranularity::WordGranularity, SelectionDirection::Backward);
 
     if (!range) {
         // We could be at the start of a word, try forward.
-        range = enclosingTextUnitOfGranularity(position, WordGranularity, DirectionForward);
+        range = enclosingTextUnitOfGranularity(position, TextGranularity::WordGranularity, SelectionDirection::Forward);
     }
 
     if (range)
@@ -1964,11 +1964,11 @@ RefPtr<Range> wordRangeFromPosition(const VisiblePosition& position)
 
     VisiblePosition currentPosition = position;
     do {
-        currentPosition = positionOfNextBoundaryOfGranularity(currentPosition, WordGranularity, DirectionBackward);
-    } while (currentPosition.isNotNull() && !atBoundaryOfGranularity(currentPosition, WordGranularity, DirectionBackward));
+        currentPosition = positionOfNextBoundaryOfGranularity(currentPosition, TextGranularity::WordGranularity, SelectionDirection::Backward);
+    } while (currentPosition.isNotNull() && !atBoundaryOfGranularity(currentPosition, TextGranularity::WordGranularity, SelectionDirection::Backward));
 
     if (currentPosition.isNull())
-        currentPosition = positionOfNextBoundaryOfGranularity(position, WordGranularity, DirectionForward);
+        currentPosition = positionOfNextBoundaryOfGranularity(position, TextGranularity::WordGranularity, SelectionDirection::Forward);
 
     if (currentPosition.isNotNull()) {
         range = Range::create(position.deepEquivalent().deprecatedNode()->document(), currentPosition, position);
@@ -1983,23 +1983,23 @@ VisiblePosition closestWordBoundaryForPosition(const VisiblePosition& position)
     VisiblePosition result;
 
     // move the position at the end of the word
-    if (atBoundaryOfGranularity(position, LineGranularity, DirectionForward)) {
+    if (atBoundaryOfGranularity(position, TextGranularity::LineGranularity, SelectionDirection::Forward)) {
         // Don't cross line boundaries.
         result = position;
-    } else if (withinTextUnitOfGranularity(position, WordGranularity, DirectionForward)) {
+    } else if (withinTextUnitOfGranularity(position, TextGranularity::WordGranularity, SelectionDirection::Forward)) {
         // The position lies within a word.
-        RefPtr<Range> wordRange = enclosingTextUnitOfGranularity(position, WordGranularity, DirectionForward);
+        RefPtr<Range> wordRange = enclosingTextUnitOfGranularity(position, TextGranularity::WordGranularity, SelectionDirection::Forward);
 
         result = wordRange->startPosition();
         if (distanceBetweenPositions(position, result) > 1)
             result = wordRange->endPosition();
-    } else if (atBoundaryOfGranularity(position, WordGranularity, DirectionBackward)) {
+    } else if (atBoundaryOfGranularity(position, TextGranularity::WordGranularity, SelectionDirection::Backward)) {
         // The position is at the end of a word.
         result = position;
     } else {
         // The position is not within a word.
         // Go to the next boundary.
-        result = positionOfNextBoundaryOfGranularity(position, WordGranularity, DirectionForward);
+        result = positionOfNextBoundaryOfGranularity(position, TextGranularity::WordGranularity, SelectionDirection::Forward);
 
         // If there is no such boundary we go to the end of the element.
         if (result.isNull())
@@ -2013,15 +2013,15 @@ RefPtr<Range> rangeExpandedByCharactersInDirectionAtWordBoundary(const VisiblePo
     Position start = position.deepEquivalent();
     Position end = position.deepEquivalent();
     for (int i = 0; i < numberOfCharactersToExpand; ++i) {
-        if (direction == DirectionBackward)
+        if (direction == SelectionDirection::Backward)
             start = start.previous(Character);
         else
             end = end.next(Character);
     }
     
-    if (direction == DirectionBackward && !atBoundaryOfGranularity(start, WordGranularity, DirectionBackward))
+    if (direction == SelectionDirection::Backward && !atBoundaryOfGranularity(start, TextGranularity::WordGranularity, SelectionDirection::Backward))
         start = startOfWord(start).deepEquivalent();
-    if (direction == DirectionForward && !atBoundaryOfGranularity(end, WordGranularity, DirectionForward))
+    if (direction == SelectionDirection::Forward && !atBoundaryOfGranularity(end, TextGranularity::WordGranularity, SelectionDirection::Forward))
         end = endOfWord(end).deepEquivalent();
 
     return makeRange(start, end);
@@ -2041,12 +2041,12 @@ RefPtr<Range> rangeExpandedAroundPositionByCharacters(const VisiblePosition& pos
 
 std::pair<VisiblePosition, WithinWordBoundary> wordBoundaryForPositionWithoutCrossingLine(const VisiblePosition& position)
 {
-    if (atBoundaryOfGranularity(position, LineGranularity, DirectionForward))
+    if (atBoundaryOfGranularity(position, TextGranularity::LineGranularity, SelectionDirection::Forward))
         return { position, WithinWordBoundary::No };
 
-    if (withinTextUnitOfGranularity(position, WordGranularity, DirectionForward)) {
+    if (withinTextUnitOfGranularity(position, TextGranularity::WordGranularity, SelectionDirection::Forward)) {
         auto adjustedPosition = position;
-        if (auto wordRange = enclosingTextUnitOfGranularity(position, WordGranularity, DirectionForward)) {
+        if (auto wordRange = enclosingTextUnitOfGranularity(position, TextGranularity::WordGranularity, SelectionDirection::Forward)) {
             adjustedPosition = wordRange->startPosition();
             if (distanceBetweenPositions(position, adjustedPosition) > 1)
                 adjustedPosition = wordRange->endPosition();
@@ -2054,10 +2054,10 @@ std::pair<VisiblePosition, WithinWordBoundary> wordBoundaryForPositionWithoutCro
         return { adjustedPosition, WithinWordBoundary::Yes };
     }
 
-    if (atBoundaryOfGranularity(position, WordGranularity, DirectionBackward))
+    if (atBoundaryOfGranularity(position, TextGranularity::WordGranularity, SelectionDirection::Backward))
         return { position, WithinWordBoundary::No };
 
-    auto nextWordBoundary = positionOfNextBoundaryOfGranularity(position, WordGranularity, DirectionForward);
+    auto nextWordBoundary = positionOfNextBoundaryOfGranularity(position, TextGranularity::WordGranularity, SelectionDirection::Forward);
     return { nextWordBoundary.isNotNull() ? nextWordBoundary : endOfEditableContent(position), WithinWordBoundary::No };
 }
 
index 084edbf..dce04e9 100644 (file)
@@ -147,7 +147,7 @@ Optional<DetectedItem> DataDetection::detectItemAroundHitTestResult(const HitTes
         if (position.isNull())
             return { };
 
-        contextRange = enclosingTextUnitOfGranularity(position, LineGranularity, DirectionForward);
+        contextRange = enclosingTextUnitOfGranularity(position, TextGranularity::LineGranularity, SelectionDirection::Forward);
     }
 
     if (!contextRange)
index 089a21f..5dfe72d 100644 (file)
@@ -338,7 +338,7 @@ std::tuple<RefPtr<Range>, NSDictionary *> DictionaryLookup::rangeAtHitTestResult
         hitIndex = characterCount({ *makeBoundaryPoint(paragraphStart), *makeBoundaryPoint(position) });
     } else {
         VisibleSelection selectionAccountingForLineRules { position };
-        selectionAccountingForLineRules.expandUsingGranularity(WordGranularity);
+        selectionAccountingForLineRules.expandUsingGranularity(TextGranularity::WordGranularity);
         position = selectionAccountingForLineRules.start();
 
         // As context, we are going to use 250 characters of text before and after the point.
index 557b022..83c5408 100644 (file)
@@ -125,7 +125,7 @@ std::tuple<RefPtr<Range>, NSDictionary *> DictionaryLookup::rangeAtHitTestResult
         return rangeForSelection(selection);
 
     VisibleSelection selectionAccountingForLineRules { position };
-    selectionAccountingForLineRules.expandUsingGranularity(WordGranularity);
+    selectionAccountingForLineRules.expandUsingGranularity(TextGranularity::WordGranularity);
     position = selectionAccountingForLineRules.start();
 
     // As context, we are going to use 250 characters of text before and after the point.
index e4a1d36..ca274de 100644 (file)
@@ -652,14 +652,14 @@ std::unique_ptr<WebGLRenderingContextBase> WebGLRenderingContextBase::create(Can
         bool forcingPendingPolicy = frame->settings().isForcePendingWebGLPolicy();
 
         if (forcingPendingPolicy || (page && !topDocument.url().isLocalFile())) {
-            WebGLLoadPolicy policy = forcingPendingPolicy ? WebGLPendingCreation : page->mainFrame().loader().client().webGLPolicyForURL(topDocument.url());
+            WebGLLoadPolicy policy = forcingPendingPolicy ? WebGLLoadPolicy::WebGLPendingCreation : page->mainFrame().loader().client().webGLPolicyForURL(topDocument.url());
 
-            if (policy == WebGLBlockCreation) {
+            if (policy == WebGLLoadPolicy::WebGLBlockCreation) {
                 LOG(WebGL, "The policy for this URL (%s) is to block WebGL.", topDocument.url().host().utf8().data());
                 return nullptr;
             }
 
-            if (policy == WebGLPendingCreation) {
+            if (policy == WebGLLoadPolicy::WebGLPendingCreation) {
                 LOG(WebGL, "WebGL policy is pending. May need to be resolved later.");
                 isPendingPolicyResolution = true;
             }
index 0facc27..9cd172a 100644 (file)
@@ -339,8 +339,8 @@ public:
     // Informs the embedder that a WebGL canvas inside this frame received a lost context
     // notification with the given GL_ARB_robustness guilt/innocence code (see ExtensionsGL.h).
     virtual void didLoseWebGLContext(int) { }
-    virtual WebGLLoadPolicy webGLPolicyForURL(const URL&) const { return WebGLAllowCreation; }
-    virtual WebGLLoadPolicy resolveWebGLPolicyForURL(const URL&) const { return WebGLAllowCreation; }
+    virtual WebGLLoadPolicy webGLPolicyForURL(const URL&) const { return WebGLLoadPolicy::WebGLAllowCreation; }
+    virtual WebGLLoadPolicy resolveWebGLPolicyForURL(const URL&) const { return WebGLLoadPolicy::WebGLAllowCreation; }
 #endif
 
     virtual void completePageTransitionIfNeeded() { }
index f9dc9b8..46b4254 100644 (file)
@@ -174,7 +174,7 @@ enum ShouldReplaceDocumentIfJavaScriptURL {
     DoNotReplaceDocumentIfJavaScriptURL
 };
 
-enum WebGLLoadPolicy {
+enum class WebGLLoadPolicy : uint8_t {
     WebGLBlockCreation,
     WebGLAllowCreation,
     WebGLPendingCreation
@@ -222,12 +222,12 @@ Optional<SystemPreviewInfo> SystemPreviewInfo::decode(Decoder& decoder)
     return { { WTFMove(*element), WTFMove(*previewRect), WTFMove(*isPreview) } };
 }
 
-enum class LoadCompletionType : uint8_t {
+enum class LoadCompletionType : bool {
     Finish,
     Cancel
 };
 
-enum class AllowsContentJavaScript : uint8_t {
+enum class AllowsContentJavaScript : bool {
     Yes,
     No,
 };
@@ -271,11 +271,12 @@ template<> struct EnumTraits<WebCore::ShouldOpenExternalURLsPolicy> {
     >;
 };
 
-template<> struct EnumTraits<WebCore::AllowsContentJavaScript> {
+template<> struct EnumTraits<WebCore::WebGLLoadPolicy> {
     using values = EnumValues<
-        WebCore::AllowsContentJavaScript,
-        WebCore::AllowsContentJavaScript::Yes,
-        WebCore::AllowsContentJavaScript::No
+        WebCore::WebGLLoadPolicy,
+        WebCore::WebGLLoadPolicy::WebGLBlockCreation,
+        WebCore::WebGLLoadPolicy::WebGLAllowCreation,
+        WebCore::WebGLLoadPolicy::WebGLPendingCreation
     >;
 };
 
index 3190546..f142041 100644 (file)
@@ -378,7 +378,7 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuAction action, co
             if (frame->editor().behavior().shouldAllowSpellingSuggestionsWithoutSelection()) {
                 ASSERT(selection.isCaretOrRange());
                 VisibleSelection wordSelection(selection.base());
-                wordSelection.expandUsingGranularity(WordGranularity);
+                wordSelection.expandUsingGranularity(TextGranularity::WordGranularity);
                 frame->selection().setSelection(wordSelection);
             } else {
                 ASSERT(frame->editor().selectedText().length());
index 4a9c429..df135af 100644 (file)
@@ -246,35 +246,35 @@ void DOMSelection::modify(const String& alterString, const String& directionStri
 
     SelectionDirection direction;
     if (equalLettersIgnoringASCIICase(directionString, "forward"))
-        direction = DirectionForward;
+        direction = SelectionDirection::Forward;
     else if (equalLettersIgnoringASCIICase(directionString, "backward"))
-        direction = DirectionBackward;
+        direction = SelectionDirection::Backward;
     else if (equalLettersIgnoringASCIICase(directionString, "left"))
-        direction = DirectionLeft;
+        direction = SelectionDirection::Left;
     else if (equalLettersIgnoringASCIICase(directionString, "right"))
-        direction = DirectionRight;
+        direction = SelectionDirection::Right;
     else
         return;
 
     TextGranularity granularity;
     if (equalLettersIgnoringASCIICase(granularityString, "character"))
-        granularity = CharacterGranularity;
+        granularity = TextGranularity::CharacterGranularity;
     else if (equalLettersIgnoringASCIICase(granularityString, "word"))
-        granularity = WordGranularity;
+        granularity = TextGranularity::WordGranularity;
     else if (equalLettersIgnoringASCIICase(granularityString, "sentence"))
-        granularity = SentenceGranularity;
+        granularity = TextGranularity::SentenceGranularity;
     else if (equalLettersIgnoringASCIICase(granularityString, "line"))
-        granularity = LineGranularity;
+        granularity = TextGranularity::LineGranularity;
     else if (equalLettersIgnoringASCIICase(granularityString, "paragraph"))
-        granularity = ParagraphGranularity;
+        granularity = TextGranularity::ParagraphGranularity;
     else if (equalLettersIgnoringASCIICase(granularityString, "lineboundary"))
-        granularity = LineBoundary;
+        granularity = TextGranularity::LineBoundary;
     else if (equalLettersIgnoringASCIICase(granularityString, "sentenceboundary"))
-        granularity = SentenceBoundary;
+        granularity = TextGranularity::SentenceBoundary;
     else if (equalLettersIgnoringASCIICase(granularityString, "paragraphboundary"))
-        granularity = ParagraphBoundary;
+        granularity = TextGranularity::ParagraphBoundary;
     else if (equalLettersIgnoringASCIICase(granularityString, "documentboundary"))
-        granularity = DocumentBoundary;
+        granularity = TextGranularity::DocumentBoundary;
     else
         return;
 
index ba2008e..5cac180 100644 (file)
@@ -614,7 +614,7 @@ bool DragController::concludeEditDrag(const DragData& dragData)
             // NSTextView behavior is to always smart delete on moving a selection,
             // but only to smart insert if the selection granularity is word granularity.
             bool smartDelete = editor.smartInsertDeleteEnabled();
-            bool smartInsert = smartDelete && innerFrame->selection().granularity() == WordGranularity && dragData.canSmartReplace();
+            bool smartInsert = smartDelete && innerFrame->selection().granularity() == TextGranularity::WordGranularity && dragData.canSmartReplace();
             MoveSelectionCommand::create(fragment.releaseNonNull(), dragCaret.base(), smartInsert, smartDelete)->apply();
         } else {
             if (setSelectionToDragCaret(innerFrame.get(), dragCaret, point)) {
index 2cdee17..55bd026 100644 (file)
@@ -542,7 +542,7 @@ bool EventHandler::updateSelectionForMouseDownDispatchingSelectStart(Node* targe
     if (selection.isRange())
         m_selectionInitiationState = ExtendedSelection;
     else {
-        granularity = CharacterGranularity;
+        granularity = TextGranularity::CharacterGranularity;
         m_selectionInitiationState = PlacedCaret;
     }
 
@@ -560,13 +560,13 @@ void EventHandler::selectClosestWordFromHitTestResult(const HitTestResult& resul
         VisiblePosition pos(targetNode->renderer()->positionForPoint(result.localPoint(), nullptr));
         if (pos.isNotNull()) {
             newSelection = VisibleSelection(pos);
-            newSelection.expandUsingGranularity(WordGranularity);
+            newSelection.expandUsingGranularity(TextGranularity::WordGranularity);
         }
 
         if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSelection.isRange())
             newSelection.appendTrailingWhitespace();
 
-        updateSelectionForMouseDownDispatchingSelectStart(targetNode, expandSelectionToRespectSelectOnMouseDown(*targetNode, newSelection), WordGranularity);
+        updateSelectionForMouseDownDispatchingSelectStart(targetNode, expandSelectionToRespectSelectOnMouseDown(*targetNode, newSelection), TextGranularity::WordGranularity);
     }
 }
 
@@ -601,14 +601,14 @@ void EventHandler::selectClosestContextualWordFromMouseEvent(const MouseEventWit
             VisiblePosition pos(targetNode->renderer()->positionForPoint(result.localPoint(), nullptr));
             if (pos.isNotNull()) {
                 newSelection = VisibleSelection(pos);
-                newSelection.expandUsingGranularity(WordGranularity);
+                newSelection.expandUsingGranularity(TextGranularity::WordGranularity);
             }
         }
         
         if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSelection.isRange())
             newSelection.appendTrailingWhitespace();
         
-        updateSelectionForMouseDownDispatchingSelectStart(targetNode, expandSelectionToRespectSelectOnMouseDown(*targetNode, newSelection), WordGranularity);
+        updateSelectionForMouseDownDispatchingSelectStart(targetNode, expandSelectionToRespectSelectOnMouseDown(*targetNode, newSelection), TextGranularity::WordGranularity);
     }
 }
     
@@ -632,7 +632,7 @@ void EventHandler::selectClosestContextualWordOrLinkFromMouseEvent(const MouseEv
         if (pos.isNotNull() && pos.deepEquivalent().deprecatedNode()->isDescendantOf(*urlElement))
             newSelection = VisibleSelection::selectionFromContentsOfNode(urlElement);
 
-        updateSelectionForMouseDownDispatchingSelectStart(targetNode, expandSelectionToRespectSelectOnMouseDown(*targetNode, newSelection), WordGranularity);
+        updateSelectionForMouseDownDispatchingSelectStart(targetNode, expandSelectionToRespectSelectOnMouseDown(*targetNode, newSelection), TextGranularity::WordGranularity);
     }
 }
 
@@ -667,10 +667,10 @@ bool EventHandler::handleMousePressEventTripleClick(const MouseEventWithHitTestR
     VisiblePosition pos(targetNode->renderer()->positionForPoint(event.localPoint(), nullptr));
     if (pos.isNotNull()) {
         newSelection = VisibleSelection(pos);
-        newSelection.expandUsingGranularity(ParagraphGranularity);
+        newSelection.expandUsingGranularity(TextGranularity::ParagraphGranularity);
     }
 
-    return updateSelectionForMouseDownDispatchingSelectStart(targetNode, expandSelectionToRespectSelectOnMouseDown(*targetNode, newSelection), ParagraphGranularity);
+    return updateSelectionForMouseDownDispatchingSelectStart(targetNode, expandSelectionToRespectSelectOnMouseDown(*targetNode, newSelection), TextGranularity::ParagraphGranularity);
 }
 
 static uint64_t textDistance(const Position& start, const Position& end)
@@ -710,7 +710,7 @@ bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR
     Position pos = visiblePosition.deepEquivalent();
 
     VisibleSelection newSelection = m_frame.selection().selection();
-    TextGranularity granularity = CharacterGranularity;
+    TextGranularity granularity = TextGranularity::CharacterGranularity;
 
     if (!m_frame.editor().client()->shouldAllowSingleClickToChangeSelection(*targetNode, newSelection))
         return true;
@@ -738,7 +738,7 @@ bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR
         } else
             newSelection.setExtent(pos);
 
-        if (m_frame.selection().granularity() != CharacterGranularity) {
+        if (m_frame.selection().granularity() != TextGranularity::CharacterGranularity) {
             granularity = m_frame.selection().granularity();
             newSelection.expandUsingGranularity(m_frame.selection().granularity());
         }
@@ -1056,7 +1056,7 @@ void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
     newSelection.setExtent(targetPosition);
 #endif
 
-    if (m_frame.selection().granularity() != CharacterGranularity)
+    if (m_frame.selection().granularity() != TextGranularity::CharacterGranularity)
         newSelection.expandUsingGranularity(m_frame.selection().granularity());
 
     m_frame.selection().setSelectionByMouseIfDifferent(newSelection, m_frame.selection().granularity(),
@@ -3516,15 +3516,15 @@ static void setInitialKeyboardSelection(Frame& frame, SelectionDirection directi
     VisiblePosition visiblePosition;
 
     switch (direction) {
-    case DirectionBackward:
-    case DirectionLeft:
+    case SelectionDirection::Backward:
+    case SelectionDirection::Left:
         if (focusedElement)
             visiblePosition = VisiblePosition(positionBeforeNode(focusedElement));
         else
             visiblePosition = endOfDocument(document);
         break;
-    case DirectionForward:
-    case DirectionRight:
+    case SelectionDirection::Forward:
+    case SelectionDirection::Right:
         if (focusedElement)
             visiblePosition = VisiblePosition(positionAfterNode(focusedElement));
         else
@@ -3545,8 +3545,8 @@ static void handleKeyboardSelectionMovement(Frame& frame, KeyboardEvent& event)
     bool isSelection = !selection.isNone();
 
     FrameSelection::EAlteration alternation = event.getModifierState("Shift") ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove;
-    SelectionDirection direction = DirectionForward;
-    TextGranularity granularity = CharacterGranularity;
+    SelectionDirection direction = SelectionDirection::Forward;
+    TextGranularity granularity = TextGranularity::CharacterGranularity;
 
     switch (focusDirectionForKey(event.keyIdentifier())) {
     case FocusDirectionNone:
@@ -3556,20 +3556,20 @@ static void handleKeyboardSelectionMovement(Frame& frame, KeyboardEvent& event)
         ASSERT_NOT_REACHED();
         return;
     case FocusDirectionUp:
-        direction = DirectionBackward;
-        granularity = isCommanded ? DocumentBoundary : LineGranularity;
+        direction = SelectionDirection::Backward;
+        granularity = isCommanded ? TextGranularity::DocumentBoundary : TextGranularity::LineGranularity;
         break;
     case FocusDirectionDown:
-        direction = DirectionForward;
-        granularity = isCommanded ? DocumentBoundary : LineGranularity;
+        direction = SelectionDirection::Forward;
+        granularity = isCommanded ? TextGranularity::DocumentBoundary : TextGranularity::LineGranularity;
         break;
     case FocusDirectionLeft:
-        direction = DirectionLeft;
-        granularity = (isCommanded) ? LineBoundary : (isOptioned) ? WordGranularity : CharacterGranularity;
+        direction = SelectionDirection::Left;
+        granularity = (isCommanded) ? TextGranularity::LineBoundary : (isOptioned) ? TextGranularity::WordGranularity : TextGranularity::CharacterGranularity;
         break;
     case FocusDirectionRight:
-        direction = DirectionRight;
-        granularity = (isCommanded) ? LineBoundary : (isOptioned) ? WordGranularity : CharacterGranularity;
+        direction = SelectionDirection::Right;
+        granularity = (isCommanded) ? TextGranularity::LineBoundary : (isOptioned) ? TextGranularity::WordGranularity : TextGranularity::CharacterGranularity;
         break;
     }
 
index d756e9c..406d5be 100644 (file)
@@ -579,7 +579,7 @@ bool HitTestResult::isOverTextInsideFormControlElement() const
     if (position.isNull())
         return false;
 
-    RefPtr<Range> wordRange = enclosingTextUnitOfGranularity(position, WordGranularity, DirectionForward);
+    RefPtr<Range> wordRange = enclosingTextUnitOfGranularity(position, TextGranularity::WordGranularity, SelectionDirection::Forward);
     if (!wordRange)
         return false;
 
index 716a1d2..5566b7b 100644 (file)
@@ -1,5 +1,87 @@
 2020-05-15  Alex Christensen  <achristensen@webkit.org>
 
+        Use enum serialization instead of casting to/from uint32_t
+        https://bugs.webkit.org/show_bug.cgi?id=211885
+
+        Reviewed by Geoffrey Garen.
+
+        * Scripts/webkit/messages.py:
+        * Shared/DocumentEditingContext.h:
+        * Shared/ios/GestureTypes.h:
+        * UIProcess/API/C/WKAPICast.h:
+        (WebKit::toWebGLLoadPolicy):
+        (WebKit::toAPI):
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::toWebCoreWebGLLoadPolicy):
+        (WebKit::NavigationState::NavigationClient::webGLLoadPolicy const):
+        (WebKit::NavigationState::NavigationClient::resolveWebGLLoadPolicy const):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::webGLPolicyForURL):
+        (WebKit::WebPageProxy::resolveWebGLPolicyForURL):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView selectForWebView:]):
+        (toUIWKSelectionFlags):
+        (toSelectionFlags):
+        (toWKTextGranularity):
+        (toWKSelectionDirection):
+        (selectionChangedWithGesture):
+        (selectionChangedWithTouch):
+        (-[WKContentView changeSelectionWithGestureAt:withGesture:withState:withFlags:]):
+        (-[WKContentView changeSelectionWithTouchAt:withSelectionTouch:baseIsStart:withFlags:]):
+        (-[WKContentView changeSelectionWithTouchesFrom:to:withGesture:withState:]):
+        (-[WKContentView selectWordForReplacement]):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::gestureCallback):
+        (WebKit::WebPageProxy::touchesCallback):
+        (WebKit::WebPageProxy::selectWithGesture):
+        (WebKit::WebPageProxy::updateSelectionWithTouches):
+        (WebKit::WebPageProxy::selectTextWithGranularityAtPoint):
+        (WebKit::WebPageProxy::selectPositionAtBoundaryWithDirection):
+        (WebKit::WebPageProxy::moveSelectionAtBoundaryWithDirection):
+        (WebKit::WebPageProxy::selectWithTwoTouches):
+        (WebKit::WebPageProxy::extendSelection):
+        (WebKit::WebPageProxy::requestRectsForGranularityWithSelectionOffset):
+        * WebProcess/InjectedBundle/API/mac/WKDOMRange.mm:
+        (-[WKDOMRange rangeByExpandingToWordBoundaryByCharacters:inDirection:]):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::webGLPolicyForURL const):
+        (WebKit::WebFrameLoaderClient::resolveWebGLPolicyForURL const):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::webGLPolicyForURL):
+        (WebKit::WebPage::resolveWebGLPolicyForURL):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getPlatformEditorState const):
+        (WebKit::WebPage::getSelectionContext):
+        (WebKit::WebPage::selectWithGesture):
+        (WebKit::rangeAtWordBoundaryForPosition):
+        (WebKit::WebPage::updateSelectionWithTouches):
+        (WebKit::WebPage::selectWithTwoTouches):
+        (WebKit::WebPage::extendSelection):
+        (WebKit::WebPage::selectWordBackward):
+        (WebKit::WebPage::moveSelectionByOffset):
+        (WebKit::WebPage::getRectsForGranularityWithSelectionOffset):
+        (WebKit::WebPage::selectPositionAtBoundaryWithDirection):
+        (WebKit::WebPage::moveSelectionAtBoundaryWithDirection):
+        (WebKit::WebPage::rangeForGranularityAtPoint):
+        (WebKit::WebPage::selectTextWithGranularityAtPoint):
+        (WebKit::WebPage::beginSelectionInDirection):
+        (WebKit::WebPage::updateSelectionWithExtentPointAndBoundary):
+        (WebKit::WebPage::requestDictationContext):
+        (WebKit::WebPage::applyAutocorrectionInternal):
+        (WebKit::WebPage::autocorrectionContext):
+        (WebKit::dataDetectorLinkPositionInformation):
+        (WebKit::moveByGranularityRespectingWordBoundary):
+        (WebKit::WebPage::requestDocumentEditingContext):
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::webGLPolicyForURL):
+        (WebKit::WebPage::resolveWebGLPolicyForURL):
+
+2020-05-15  Alex Christensen  <achristensen@webkit.org>
+
         [iOS Simulator] TestWebKitAPI._WKDownload.Resume is a flaky crash
         https://bugs.webkit.org/show_bug.cgi?id=211786
 
index c346186..d5d0792 100644 (file)
@@ -34,6 +34,9 @@
 #if ENABLE(DEPRECATED_FEATURE) || ENABLE(EXPERIMENTAL_FEATURE)
 #include "DummyType.h"
 #endif
+#if PLATFORM(MAC)
+#include "GestureTypes.h"
+#endif
 #include "HandleMessage.h"
 #if PLATFORM(MAC)
 #include "MachPort.h"
@@ -52,6 +55,9 @@
 #include <WebCore/PluginData.h>
 #include <utility>
 #include <wtf/HashMap.h>
+#if PLATFORM(MAC)
+#include <wtf/OptionSet.h>
+#endif
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
index 94d37a0..460f9c5 100644 (file)
@@ -28,6 +28,9 @@
 
 #include "ArgumentCoders.h"
 #include "Connection.h"
+#if PLATFORM(IOS_FAMILY)
+#include "GestureTypes.h"
+#endif
 #include "MessageNames.h"
 #include "Plugin.h"
 #include "WebPageMessagesReplies.h"
@@ -37,6 +40,7 @@
 #include <utility>
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
+#include <wtf/OptionSet.h>
 #include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
@@ -452,13 +456,13 @@ private:
 #if PLATFORM(MAC)
 class DidCreateWebProcessConnection {
 public:
-    typedef std::tuple<const IPC::MachPort&> Arguments;
+    typedef std::tuple<const IPC::MachPort&, const OptionSet<WebKit::SelectionFlags>&> Arguments;
 
     static IPC::MessageName name() { return IPC::MessageName::WebPage_DidCreateWebProcessConnection; }
     static const bool isSync = false;
 
-    explicit DidCreateWebProcessConnection(const IPC::MachPort& connectionIdentifier)
-        : m_arguments(connectionIdentifier)
+    DidCreateWebProcessConnection(const IPC::MachPort& connectionIdentifier, const OptionSet<WebKit::SelectionFlags>& flags)
+        : m_arguments(connectionIdentifier, flags)
     {
     }
 
index b022fce..16ba288 100644 (file)
@@ -265,6 +265,7 @@ def conditions_for_header(header):
     conditions = {
         '"InputMethodState.h"': ["PLATFORM(GTK)", "PLATFORM(WPE)"],
         '"LayerHostingContext.h"': ["PLATFORM(COCOA)", ],
+        '"GestureTypes.h"': ["PLATFORM(IOS_FAMILY)"],
     }
     if not header in conditions:
         return None
@@ -615,6 +616,7 @@ def headers_for_type(type):
         'WebCore::RecentSearch': ['<WebCore/SearchPopupMenu.h>'],
         'WebCore::RouteSharingPolicy': ['<WebCore/AudioSession.h>'],
         'WebCore::SWServerConnectionIdentifier': ['<WebCore/ServiceWorkerTypes.h>'],
+        'WebCore::SelectionDirection': ['<WebCore/VisibleSelection.h>'],
         'WebCore::ServiceWorkerJobIdentifier': ['<WebCore/ServiceWorkerTypes.h>'],
         'WebCore::ServiceWorkerOrClientData': ['<WebCore/ServiceWorkerTypes.h>', '<WebCore/ServiceWorkerClientData.h>', '<WebCore/ServiceWorkerData.h>'],
         'WebCore::ServiceWorkerOrClientIdentifier': ['<WebCore/ServiceWorkerTypes.h>', '<WebCore/ServiceWorkerClientIdentifier.h>'],
@@ -639,17 +641,22 @@ def headers_for_type(type):
         'WebCore::FirstPartyWebsiteDataRemovalMode': ['<WebCore/NetworkStorageSession.h>'],
         'WebCore::UsedLegacyTLS': ['<WebCore/ResourceResponseBase.h>'],
         'WebCore::ViewportAttributes': ['<WebCore/ViewportArguments.h>'],
+        'WebCore::WebGLLoadPolicy': ['<WebCore/FrameLoaderTypes.h>'],
         'WebCore::WillContinueLoading': ['<WebCore/FrameLoaderTypes.h>'],
         'WebCore::SelectionRect': ['"EditorState.h"'],
         'WebKit::ActivityStateChangeID': ['"DrawingAreaInfo.h"'],
         'WebKit::BackForwardListItemState': ['"SessionState.h"'],
-        'WebKit::ContentWorldIdentifier' : ['"ContentWorldShared.h"'],
+        'WebKit::ContentWorldIdentifier': ['"ContentWorldShared.h"'],
+        'WebKit::GestureRecognizerState': ['"GestureTypes.h"'],
+        'WebKit::GestureType': ['"GestureTypes.h"'],
         'WebKit::LayerHostingContextID': ['"LayerHostingContext.h"'],
         'WebKit::LayerHostingMode': ['"LayerTreeContext.h"'],
         'WebKit::PageState': ['"SessionState.h"'],
         'WebKit::PaymentSetupConfiguration': ['"PaymentSetupConfigurationWebKit.h"'],
         'WebKit::PaymentSetupFeatures': ['"ApplePayPaymentSetupFeaturesWebKit.h"'],
         'WebKit::RespectSelectionAnchor': ['"GestureTypes.h"'],
+        'WebKit::SelectionFlags': ['"GestureTypes.h"'],
+        'WebKit::SelectionTouch': ['"GestureTypes.h"'],
         'WebKit::WebGestureEvent': ['"WebEvent.h"'],
         'WebKit::WebKeyboardEvent': ['"WebEvent.h"'],
         'WebKit::WebMouseEvent': ['"WebEvent.h"'],
index 3f23773..62425fa 100644 (file)
@@ -63,7 +63,7 @@ messages -> WebPage {
     SetVideoLayerID(WebCore::GraphicsLayer::PlatformLayerID videoLayerID)
 
 #if PLATFORM(MAC)
-    DidCreateWebProcessConnection(IPC::MachPort connectionIdentifier)
+    DidCreateWebProcessConnection(IPC::MachPort connectionIdentifier, OptionSet<WebKit::SelectionFlags> flags)
 #endif
 
 #if PLATFORM(MAC)
index 091f432..efc0a41 100644 (file)
@@ -52,7 +52,7 @@ struct DocumentEditingContextRequest {
 
     OptionSet<Options> options;
 
-    WebCore::TextGranularity surroundingGranularity { WebCore::CharacterGranularity };
+    WebCore::TextGranularity surroundingGranularity { WebCore::TextGranularity::CharacterGranularity };
     int64_t granularityCount { 0 };
 
     WebCore::FloatRect rect;
index 9c365eb..1dae1a1 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef GestureTypes_h
-#define GestureTypes_h
+#pragma once
+
+#include <wtf/EnumTraits.h>
 
 namespace WebKit {
 
-enum class GestureType {
+enum class GestureType : uint8_t {
     Loupe,
     OneFingerTap,
     TapAndAHalf,
@@ -45,7 +46,7 @@ enum class GestureType {
     PhraseBoundary
 };
 
-enum class SelectionTouch {
+enum class SelectionTouch : uint8_t {
     Started,
     Moved,
     Ended,
@@ -54,23 +55,21 @@ enum class SelectionTouch {
     EndedNotMoving
 };
 
-enum class GestureRecognizerState {
+enum class GestureRecognizerState : uint8_t {
     Possible,
     Began,
     Changed,
     Ended,
     Cancelled,
-    Failed,
-    Recognized = Ended
+    Failed
 };
 
-enum class SheetAction {
+enum class SheetAction : bool {
     Copy,
     SaveImage
 };
 
-enum SelectionFlags {
-    None = 0,
+enum SelectionFlags : uint8_t {
     WordIsNearTap = 1 << 0,
     PhraseBoundaryChanged = 1 << 1,
 };
@@ -82,4 +81,51 @@ enum class RespectSelectionAnchor : bool {
 
 } // namespace WebKit
 
-#endif // GestureTypes_h
+namespace WTF {
+
+template<> struct EnumTraits<WebKit::GestureType> {
+    using values = EnumValues<
+        WebKit::GestureType,
+        WebKit::GestureType::Loupe,
+        WebKit::GestureType::OneFingerTap,
+        WebKit::GestureType::TapAndAHalf,
+        WebKit::GestureType::DoubleTap,
+        WebKit::GestureType::TapAndHalf,
+        WebKit::GestureType::DoubleTapInUneditable,
+        WebKit::GestureType::OneFingerTapInUneditable,
+        WebKit::GestureType::OneFingerTapSelectsAll,
+        WebKit::GestureType::OneFingerDoubleTap,
+        WebKit::GestureType::OneFingerTripleTap,
+        WebKit::GestureType::TwoFingerSingleTap,
+        WebKit::GestureType::TwoFingerRangedSelectGesture,
+        WebKit::GestureType::TapOnLinkWithGesture,
+        WebKit::GestureType::PhraseBoundary
+    >;
+};
+
+template<> struct EnumTraits<WebKit::SelectionTouch> {
+    using values = EnumValues<
+        WebKit::SelectionTouch,
+        WebKit::SelectionTouch::Started,
+        WebKit::SelectionTouch::Moved,
+        WebKit::SelectionTouch::Ended,
+        WebKit::SelectionTouch::EndedMovingForward,
+        WebKit::SelectionTouch::EndedMovingBackward,
+        WebKit::SelectionTouch::EndedNotMoving
+    >;
+};
+
+
+template<> struct EnumTraits<WebKit::GestureRecognizerState> {
+    using values = EnumValues<
+        WebKit::GestureRecognizerState,
+        WebKit::GestureRecognizerState::Possible,
+        WebKit::GestureRecognizerState::Began,
+        WebKit::GestureRecognizerState::Changed,
+        WebKit::GestureRecognizerState::Ended,
+        WebKit::GestureRecognizerState::Cancelled,
+        WebKit::GestureRecognizerState::Failed
+    >;
+};
+
+} // namespace WTF
index 48b661f..a328198 100644 (file)
@@ -496,25 +496,25 @@ inline WebCore::WebGLLoadPolicy toWebGLLoadPolicy(WKWebGLLoadPolicy webGLLoadPol
 {
     switch (webGLLoadPolicy) {
     case kWKWebGLLoadPolicyLoadNormally:
-        return WebCore::WebGLAllowCreation;
+        return WebCore::WebGLLoadPolicy::WebGLAllowCreation;
     case kWKWebGLLoadPolicyBlocked:
-        return WebCore::WebGLBlockCreation;
+        return WebCore::WebGLLoadPolicy::WebGLBlockCreation;
     case kWKWebGLLoadPolicyPending:
-        return WebCore::WebGLPendingCreation;
+        return WebCore::WebGLLoadPolicy::WebGLPendingCreation;
     }
     
     ASSERT_NOT_REACHED();
-    return WebCore::WebGLAllowCreation;
+    return WebCore::WebGLLoadPolicy::WebGLAllowCreation;
 }
 
 inline WKWebGLLoadPolicy toAPI(WebCore::WebGLLoadPolicy webGLLoadPolicy)
 {
     switch (webGLLoadPolicy) {
-    case WebCore::WebGLAllowCreation:
+    case WebCore::WebGLLoadPolicy::WebGLAllowCreation:
         return kWKWebGLLoadPolicyLoadNormally;
-    case WebCore::WebGLBlockCreation:
+    case WebCore::WebGLLoadPolicy::WebGLBlockCreation:
         return kWKWebGLLoadPolicyBlocked;
-    case WebCore::WebGLPendingCreation:
+    case WebCore::WebGLLoadPolicy::WebGLPendingCreation:
         return kWKWebGLLoadPolicyPending;
     }
 
index 32f23f6..d9a31d3 100644 (file)
@@ -409,21 +409,21 @@ inline WebCore::WebGLLoadPolicy toWebCoreWebGLLoadPolicy(_WKWebGLLoadPolicy poli
 {
     switch (policy) {
     case _WKWebGLLoadPolicyAllowCreation:
-        return WebCore::WebGLAllowCreation;
+        return WebCore::WebGLLoadPolicy::WebGLAllowCreation;
     case _WKWebGLLoadPolicyBlockCreation:
-        return WebCore::WebGLBlockCreation;
+        return WebCore::WebGLLoadPolicy::WebGLBlockCreation;
     case _WKWebGLLoadPolicyPendingCreation:
-        return WebCore::WebGLPendingCreation;
+        return WebCore::WebGLLoadPolicy::WebGLPendingCreation;
     }
     
     ASSERT_NOT_REACHED();
-    return WebCore::WebGLAllowCreation;
+    return WebCore::WebGLLoadPolicy::WebGLAllowCreation;
 }
 
 void NavigationState::NavigationClient::webGLLoadPolicy(WebPageProxy&, const URL& url, CompletionHandler<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const
 {
     if (!m_navigationState.m_navigationDelegateMethods.webViewWebGLLoadPolicyForURL) {
-        completionHandler(WebGLAllowCreation);
+        completionHandler(WebGLLoadPolicy::WebGLAllowCreation);
         return;
     }
 
@@ -440,7 +440,7 @@ void NavigationState::NavigationClient::webGLLoadPolicy(WebPageProxy&, const URL
 void NavigationState::NavigationClient::resolveWebGLLoadPolicy(WebPageProxy&, const URL& url, CompletionHandler<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const
 {
     if (!m_navigationState.m_navigationDelegateMethods.webViewResolveWebGLLoadPolicyForURL) {
-        completionHandler(WebGLAllowCreation);
+        completionHandler(WebGLLoadPolicy::WebGLAllowCreation);
         return;
     }
     
index 3aaa822..6547f4b 100644 (file)
@@ -5753,16 +5753,12 @@ void WebPageProxy::unavailablePluginButtonClicked(uint32_t opaquePluginUnavailab
 #if ENABLE(WEBGL)
 void WebPageProxy::webGLPolicyForURL(URL&& url, Messages::WebPageProxy::WebGLPolicyForURL::DelayedReply&& reply)
 {
-    m_navigationClient->webGLLoadPolicy(*this, url, [reply = WTFMove(reply)] (WebGLLoadPolicy policy) mutable {
-        reply(static_cast<uint32_t>(policy));
-    });
+    m_navigationClient->webGLLoadPolicy(*this, url, WTFMove(reply));
 }
 
 void WebPageProxy::resolveWebGLPolicyForURL(URL&& url, Messages::WebPageProxy::ResolveWebGLPolicyForURL::DelayedReply&& reply)
 {
-    m_navigationClient->resolveWebGLLoadPolicy(*this, url, [reply = WTFMove(reply)] (WebGLLoadPolicy policy) mutable {
-        reply(static_cast<uint32_t>(policy));
-    });
+    m_navigationClient->resolveWebGLLoadPolicy(*this, url, WTFMove(reply));
 }
 #endif // ENABLE(WEBGL)
 
index e551ae5..32ec494 100644 (file)
@@ -223,8 +223,6 @@ class SharedBuffer;
 class TextIndicator;
 class ValidationBubble;
 
-enum SelectionDirection : uint8_t;
-
 enum class AutoplayEvent : uint8_t;
 enum class DOMPasteAccessResponse : uint8_t;
 enum class LockBackForwardList : bool;
@@ -232,6 +230,7 @@ enum class HasInsecureContent : bool;
 enum class MouseEventPolicy : uint8_t;
 enum class NotificationDirection : uint8_t;
 enum class RouteSharingPolicy : uint8_t;
+enum class SelectionDirection : uint8_t;
 enum class ShouldSample : bool;
 enum class ShouldTreatAsContinuingLoad : bool;
 enum class WritingDirection : uint8_t;
@@ -244,6 +243,7 @@ struct ContentRuleListResults;
 struct DataListSuggestionInformation;
 struct DictionaryPopupInfo;
 struct DragItem;
+struct ElementContext;
 struct ExceptionDetails;
 struct FileChooserSettings;
 struct GlobalWindowIdentifier;
@@ -279,10 +279,6 @@ typedef struct OpaqueJSContext* JSGlobalContextRef;
 typedef HWND PlatformViewWidget;
 #endif
 
-namespace WebCore {
-struct ElementContext;
-}
-
 namespace WebKit {
 class AudioSessionRoutingArbitratorProxy;
 class DrawingAreaProxy;
@@ -405,8 +401,8 @@ typedef GenericCallback<const FontInfo&, double, bool> FontAtSelectionCallback;
 #endif
 
 #if PLATFORM(IOS_FAMILY)
-typedef GenericCallback<const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t> GestureCallback;
-typedef GenericCallback<const WebCore::IntPoint&, uint32_t, uint32_t> TouchesCallback;
+typedef GenericCallback<const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>> GestureCallback;
+typedef GenericCallback<const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>> TouchesCallback;
 typedef GenericCallback<const Vector<WebCore::SelectionRect>&> SelectionRectsCallback;
 typedef GenericCallback<const FocusedElementInformation&> FocusedElementInformationCallback;
 #endif
@@ -756,9 +752,9 @@ public:
     void setOverrideViewportArguments(const Optional<WebCore::ViewportArguments>&);
     void willCommitLayerTree(TransactionID);
 
-    void selectWithGesture(const WebCore::IntPoint, WebCore::TextGranularity, uint32_t gestureType, uint32_t gestureState, bool isInteractingWithFocusedElement, WTF::Function<void(const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t, CallbackBase::Error)>&&);
-    void updateSelectionWithTouches(const WebCore::IntPoint, uint32_t touches, bool baseIsStart, WTF::Function<void (const WebCore::IntPoint&, uint32_t, uint32_t, CallbackBase::Error)>&&);
-    void selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, uint32_t gestureType, uint32_t gestureState, WTF::Function<void (const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t, CallbackBase::Error)>&&);
+    void selectWithGesture(const WebCore::IntPoint, GestureType, GestureRecognizerState, bool isInteractingWithFocusedElement, WTF::Function<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>, CallbackBase::Error)>&&);
+    void updateSelectionWithTouches(const WebCore::IntPoint, SelectionTouch, bool baseIsStart, Function<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>, CallbackBase::Error)>&&);
+    void selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, GestureType, GestureRecognizerState, Function<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>, CallbackBase::Error)>&&);
     void extendSelection(WebCore::TextGranularity);
     void selectWordBackward();
     void moveSelectionByOffset(int32_t offset, CompletionHandler<void()>&&);
@@ -2097,8 +2093,8 @@ private:
     void fontAtSelectionCallback(const FontInfo&, double, bool, CallbackID);
 #endif
 #if PLATFORM(IOS_FAMILY)
-    void gestureCallback(const WebCore::IntPoint&, uint32_t gestureType, uint32_t gestureState, uint32_t flags, CallbackID);
-    void touchesCallback(const WebCore::IntPoint&, uint32_t touches, uint32_t flags, CallbackID);
+    void gestureCallback(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>, CallbackID);
+    void touchesCallback(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>, CallbackID);
     void selectionContextCallback(const String& selectedText, const String& beforeText, const String& afterText, CallbackID);
     void interpretKeyEvent(const EditorState&, bool isCharEvent, CompletionHandler<void(bool)>&&);
     void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect, WebCore::RouteSharingPolicy, const String&);
index fc12f7b..49c19bd 100644 (file)
@@ -34,8 +34,8 @@ messages -> WebPageProxy {
     UnavailablePluginButtonClicked(uint32_t pluginUnavailabilityReason, String mimeType, String pluginURLString, String pluginspageAttributeURLString, String frameURLString, String pageURLString)
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 #if ENABLE(WEBGL)
-    WebGLPolicyForURL(URL url) -> (uint32_t loadPolicy) Synchronous
-    ResolveWebGLPolicyForURL(URL url) -> (uint32_t loadPolicy) Synchronous
+    WebGLPolicyForURL(URL url) -> (enum:uint8_t WebCore::WebGLLoadPolicy loadPolicy) Synchronous
+    ResolveWebGLPolicyForURL(URL url) -> (enum:uint8_t WebCore::WebGLLoadPolicy loadPolicy) Synchronous
 #endif // ENABLE(WEBGL)
     DidChangeViewportProperties(struct WebCore::ViewportAttributes attributes)
     DidReceiveEvent(uint32_t type, bool handled)
@@ -177,8 +177,8 @@ messages -> WebPageProxy {
 #endif
     FontAttributesCallback(struct WebCore::FontAttributes attributes, WebKit::CallbackID callbackID)
 #if PLATFORM(IOS_FAMILY)
-    GestureCallback(WebCore::IntPoint point, uint32_t gestureType, uint32_t gestureState, uint32_t flags, WebKit::CallbackID callbackID)
-    TouchesCallback(WebCore::IntPoint point, uint32_t touches, uint32_t flags, WebKit::CallbackID callbackID)
+    GestureCallback(WebCore::IntPoint point, enum:uint8_t WebKit::GestureType gestureType, enum:uint8_t WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackID callbackID)
+    TouchesCallback(WebCore::IntPoint point, enum:uint8_t WebKit::SelectionTouch touches, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackID callbackID)
     SelectionContextCallback(String selectedText, String beforeText, String afterText, WebKit::CallbackID callbackID)
     InterpretKeyEvent(struct WebKit::EditorState state, bool isCharEvent) -> (bool handled) Synchronous
     DidReceivePositionInformation(struct WebKit::InteractionInformationAtPosition information)
index 81c465d..7718268 100644 (file)
@@ -3515,7 +3515,7 @@ WEBCORE_COMMAND_FOR_WEBVIEW(pasteAndMatchStyle);
 {
     [_textInteractionAssistant selectWord];
     // We cannot use selectWord command, because we want to be able to select the word even when it is the last in the paragraph.
-    _page->extendSelection(WebCore::WordGranularity);
+    _page->extendSelection(WebCore::TextGranularity::WordGranularity);
 }
 
 - (void)selectAllForWebView:(id)sender
@@ -3823,32 +3823,42 @@ static inline UIGestureRecognizerState toUIGestureRecognizerState(WebKit::Gestur
     }
 }
 
-static inline UIWKSelectionFlags toUIWKSelectionFlags(WebKit::SelectionFlags flags)
+static inline UIWKSelectionFlags toUIWKSelectionFlags(OptionSet<WebKit::SelectionFlags> flags)
 {
     NSInteger uiFlags = UIWKNone;
-    if (flags & WebKit::WordIsNearTap)
+    if (flags.contains(WebKit::WordIsNearTap))
         uiFlags |= UIWKWordIsNearTap;
-    if (flags & WebKit::PhraseBoundaryChanged)
+    if (flags.contains(WebKit::PhraseBoundaryChanged))
         uiFlags |= UIWKPhraseBoundaryChanged;
 
     return static_cast<UIWKSelectionFlags>(uiFlags);
 }
 
+static inline OptionSet<WebKit::SelectionFlags> toSelectionFlags(UIWKSelectionFlags uiFlags)
+{
+    OptionSet<WebKit::SelectionFlags> flags;
+    if (uiFlags & UIWKWordIsNearTap)
+        flags.add(WebKit::WordIsNearTap);
+    if (uiFlags & UIWKPhraseBoundaryChanged)
+        flags.add(WebKit::PhraseBoundaryChanged);
+    return flags;
+}
+
 static inline WebCore::TextGranularity toWKTextGranularity(UITextGranularity granularity)
 {
     switch (granularity) {
     case UITextGranularityCharacter:
-        return WebCore::CharacterGranularity;
+        return WebCore::TextGranularity::CharacterGranularity;
     case UITextGranularityWord:
-        return WebCore::WordGranularity;
+        return WebCore::TextGranularity::WordGranularity;
     case UITextGranularitySentence:
-        return WebCore::SentenceGranularity;
+        return WebCore::TextGranularity::SentenceGranularity;
     case UITextGranularityParagraph:
-        return WebCore::ParagraphGranularity;
+        return WebCore::TextGranularity::ParagraphGranularity;
     case UITextGranularityLine:
-        return WebCore::LineGranularity;
+        return WebCore::TextGranularity::LineGranularity;
     case UITextGranularityDocument:
-        return WebCore::DocumentGranularity;
+        return WebCore::TextGranularity::DocumentGranularity;
     }
 }
 
@@ -3857,29 +3867,29 @@ static inline WebCore::SelectionDirection toWKSelectionDirection(UITextDirection
     switch (direction) {
     case UITextLayoutDirectionDown:
     case UITextLayoutDirectionRight:
-        return WebCore::DirectionRight;
+        return WebCore::SelectionDirection::Right;
     case UITextLayoutDirectionUp:
     case UITextLayoutDirectionLeft:
-        return WebCore::DirectionLeft;
+        return WebCore::SelectionDirection::Left;
     default:
         // UITextDirection is not an enum, but we only want to accept values from UITextLayoutDirection.
         ASSERT_NOT_REACHED();
-        return WebCore::DirectionRight;
+        return WebCore::SelectionDirection::Right;
     }
 }
 
-static void selectionChangedWithGesture(WKContentView *view, const WebCore::IntPoint& point, uint32_t gestureType, uint32_t gestureState, uint32_t flags, WebKit::CallbackBase::Error error)
+static void selectionChangedWithGesture(WKContentView *view, const WebCore::IntPoint& point, WebKit::GestureType gestureType, WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackBase::Error error)
 {
     if (error != WebKit::CallbackBase::Error::None)
         return;
-    [(UIWKTextInteractionAssistant *)[view interactionAssistant] selectionChangedWithGestureAt:(CGPoint)point withGesture:toUIWKGestureType((WebKit::GestureType)gestureType) withState:toUIGestureRecognizerState(static_cast<WebKit::GestureRecognizerState>(gestureState)) withFlags:(toUIWKSelectionFlags((WebKit::SelectionFlags)flags))];
+    [(UIWKTextInteractionAssistant *)[view interactionAssistant] selectionChangedWithGestureAt:(CGPoint)point withGesture:toUIWKGestureType(gestureType) withState:toUIGestureRecognizerState(gestureState) withFlags:toUIWKSelectionFlags(flags)];
 }
 
-static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoint& point, uint32_t touch, uint32_t flags, WebKit::CallbackBase::Error error)
+static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoint& point, WebKit::SelectionTouch touch, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackBase::Error error)
 {
     if (error != WebKit::CallbackBase::Error::None)
         return;
-    [(UIWKTextInteractionAssistant *)[view interactionAssistant] selectionChangedWithTouchAt:(CGPoint)point withSelectionTouch:toUIWKSelectionTouch((WebKit::SelectionTouch)touch) withFlags:static_cast<UIWKSelectionFlags>(flags)];
+    [(UIWKTextInteractionAssistant *)[view interactionAssistant] selectionChangedWithTouchAt:(CGPoint)point withSelectionTouch:toUIWKSelectionTouch((WebKit::SelectionTouch)touch) withFlags:toUIWKSelectionFlags(flags)];
 }
 
 - (BOOL)_hasFocusedElement
@@ -3895,8 +3905,8 @@ static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoi
 - (void)changeSelectionWithGestureAt:(CGPoint)point withGesture:(UIWKGestureType)gestureType withState:(UIGestureRecognizerState)state withFlags:(UIWKSelectionFlags)flags
 {
     _usingGestureForSelection = YES;
-    _page->selectWithGesture(WebCore::IntPoint(point), WebCore::CharacterGranularity, static_cast<uint32_t>(toGestureType(gestureType)), static_cast<uint32_t>(toGestureRecognizerState(state)), self._hasFocusedElement, [self, state, flags](const WebCore::IntPoint& point, uint32_t gestureType, uint32_t gestureState, uint32_t innerFlags, WebKit::CallbackBase::Error error) {
-        selectionChangedWithGesture(self, point, gestureType, gestureState, flags | innerFlags, error);
+    _page->selectWithGesture(WebCore::IntPoint(point), toGestureType(gestureType), toGestureRecognizerState(state), self._hasFocusedElement, [self, strongSelf = retainPtr(self), state, flags](const WebCore::IntPoint& point, WebKit::GestureType gestureType, WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> innerFlags, WebKit::CallbackBase::Error error) {
+        selectionChangedWithGesture(self, point, gestureType, gestureState, toSelectionFlags(flags) | innerFlags, error);
         if (state == UIGestureRecognizerStateEnded || state == UIGestureRecognizerStateCancelled)
             _usingGestureForSelection = NO;
     });
@@ -3905,9 +3915,9 @@ static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoi
 - (void)changeSelectionWithTouchAt:(CGPoint)point withSelectionTouch:(UIWKSelectionTouch)touch baseIsStart:(BOOL)baseIsStart withFlags:(UIWKSelectionFlags)flags
 {
     _usingGestureForSelection = YES;
-    _page->updateSelectionWithTouches(WebCore::IntPoint(point), static_cast<uint32_t>(toSelectionTouch(touch)), baseIsStart, [self, flags](const WebCore::IntPoint& point, uint32_t touch, uint32_t innerFlags, WebKit::CallbackBase::Error error) {
-        selectionChangedWithTouch(self, point, touch, flags | innerFlags, error);
-        if (touch != UIWKSelectionTouchStarted && touch != UIWKSelectionTouchMoved)
+    _page->updateSelectionWithTouches(WebCore::IntPoint(point), toSelectionTouch(touch), baseIsStart, [self, strongSelf = retainPtr(self), flags](const WebCore::IntPoint& point, WebKit::SelectionTouch touch, OptionSet<WebKit::SelectionFlags> innerFlags, WebKit::CallbackBase::Error error) {
+        selectionChangedWithTouch(self, point, touch, toSelectionFlags(flags) | innerFlags, error);
+        if (toUIWKSelectionTouch(touch) != UIWKSelectionTouchStarted && toUIWKSelectionTouch(touch) != UIWKSelectionTouchMoved)
             _usingGestureForSelection = NO;
     });
 }
@@ -3915,9 +3925,9 @@ static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoi
 - (void)changeSelectionWithTouchesFrom:(CGPoint)from to:(CGPoint)to withGesture:(UIWKGestureType)gestureType withState:(UIGestureRecognizerState)gestureState
 {
     _usingGestureForSelection = YES;
-    _page->selectWithTwoTouches(WebCore::IntPoint(from), WebCore::IntPoint(to), static_cast<uint32_t>(toGestureType(gestureType)), static_cast<uint32_t>(toGestureRecognizerState(gestureState)), [self](const WebCore::IntPoint& point, uint32_t gestureType, uint32_t gestureState, uint32_t flags, WebKit::CallbackBase::Error error) {
+    _page->selectWithTwoTouches(WebCore::IntPoint(from), WebCore::IntPoint(to), toGestureType(gestureType), toGestureRecognizerState(gestureState), [self, strongSelf = retainPtr(self)](const WebCore::IntPoint& point, WebKit::GestureType gestureType, WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackBase::Error error) {
         selectionChangedWithGesture(self, point, gestureType, gestureState, flags, error);
-        if (gestureState == UIGestureRecognizerStateEnded || gestureState == UIGestureRecognizerStateCancelled)
+        if (toUIGestureRecognizerState(gestureState) == UIGestureRecognizerStateEnded || toUIGestureRecognizerState(gestureState) == UIGestureRecognizerStateCancelled)
             _usingGestureForSelection = NO;
     });
 }
@@ -6509,7 +6519,7 @@ static BOOL allPasteboardItemOriginsMatchOrigin(UIPasteboard *pasteboard, const
 
 - (void)selectWordForReplacement
 {
-    _page->extendSelection(WebCore::WordGranularity);
+    _page->extendSelection(WebCore::TextGranularity::WordGranularity);
 }
 
 #if ENABLE(PLATFORM_DRIVEN_TEXT_CHECKING)
index d329227..24b57ea 100644 (file)
@@ -144,7 +144,7 @@ bool WebPageProxy::readSelectionFromPasteboard(const String&)
     return false;
 }
 
-void WebPageProxy::gestureCallback(const WebCore::IntPoint& point, uint32_t gestureType, uint32_t gestureState, uint32_t flags, CallbackID callbackID)
+void WebPageProxy::gestureCallback(const WebCore::IntPoint& point, GestureType gestureType, GestureRecognizerState gestureState, OptionSet<SelectionFlags> flags, CallbackID callbackID)
 {
     auto callback = m_callbacks.take<GestureCallback>(callbackID);
     if (!callback) {
@@ -155,7 +155,7 @@ void WebPageProxy::gestureCallback(const WebCore::IntPoint& point, uint32_t gest
     callback->performCallbackWithReturnValue(point, gestureType, gestureState, flags);
 }
 
-void WebPageProxy::touchesCallback(const WebCore::IntPoint& point, uint32_t touches, uint32_t flags, CallbackID callbackID)
+void WebPageProxy::touchesCallback(const WebCore::IntPoint& point, SelectionTouch touches, OptionSet<SelectionFlags> flags, CallbackID callbackID)
 {
     auto callback = m_callbacks.take<TouchesCallback>(callbackID);
     if (!callback) {
@@ -428,21 +428,21 @@ void WebPageProxy::layerTreeCommitComplete()
     pageClient().layerTreeCommitComplete();
 }
 
-void WebPageProxy::selectWithGesture(const WebCore::IntPoint point, WebCore::TextGranularity granularity, uint32_t gestureType, uint32_t gestureState, bool isInteractingWithFocusedElement, WTF::Function<void(const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::selectWithGesture(const WebCore::IntPoint point, GestureType gestureType, GestureRecognizerState gestureState, bool isInteractingWithFocusedElement, WTF::Function<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<WebKit::SelectionFlags>, CallbackBase::Error)>&& callbackFunction)
 {
     if (!hasRunningProcess()) {
-        callbackFunction(WebCore::IntPoint(), 0, 0, 0, CallbackBase::Error::Unknown);
+        callbackFunction(WebCore::IntPoint(), GestureType::Loupe, GestureRecognizerState::Possible, { }, CallbackBase::Error::Unknown);
         return;
     }
 
     auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::selectWithGesture"_s));
-    m_process->send(Messages::WebPage::SelectWithGesture(point, (uint32_t)granularity, gestureType, gestureState, isInteractingWithFocusedElement, callbackID), m_webPageID);
+    m_process->send(Messages::WebPage::SelectWithGesture(point, gestureType, gestureState, isInteractingWithFocusedElement, callbackID), m_webPageID);
 }
 
-void WebPageProxy::updateSelectionWithTouches(const WebCore::IntPoint point, uint32_t touches, bool baseIsStart, WTF::Function<void (const WebCore::IntPoint&, uint32_t, uint32_t, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::updateSelectionWithTouches(const WebCore::IntPoint point, SelectionTouch touches, bool baseIsStart, Function<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>, CallbackBase::Error)>&& callbackFunction)
 {
     if (!hasRunningProcess()) {
-        callbackFunction(WebCore::IntPoint(), 0, 0, CallbackBase::Error::Unknown);
+        callbackFunction(WebCore::IntPoint(), SelectionTouch::Started, { }, CallbackBase::Error::Unknown);
         return;
     }
 
@@ -512,7 +512,7 @@ void WebPageProxy::selectTextWithGranularityAtPoint(const WebCore::IntPoint poin
         return;
     }
     
-    sendWithAsyncReply(Messages::WebPage::SelectTextWithGranularityAtPoint(point, static_cast<uint32_t>(granularity), isInteractingWithFocusedElement), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::selectTextWithGranularityAtPoint"_s)] () mutable {
+    sendWithAsyncReply(Messages::WebPage::SelectTextWithGranularityAtPoint(point, granularity, isInteractingWithFocusedElement), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::selectTextWithGranularityAtPoint"_s)] () mutable {
         callbackFunction();
     });
 }
@@ -524,7 +524,7 @@ void WebPageProxy::selectPositionAtBoundaryWithDirection(const WebCore::IntPoint
         return;
     }
     
-    sendWithAsyncReply(Messages::WebPage::SelectPositionAtBoundaryWithDirection(point, static_cast<uint32_t>(granularity), static_cast<uint32_t>(direction), isInteractingWithFocusedElement), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::selectPositionAtBoundaryWithDirection"_s)] () mutable {
+    sendWithAsyncReply(Messages::WebPage::SelectPositionAtBoundaryWithDirection(point, granularity, direction, isInteractingWithFocusedElement), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::selectPositionAtBoundaryWithDirection"_s)] () mutable {
         callbackFunction();
     });
 }
@@ -536,7 +536,7 @@ void WebPageProxy::moveSelectionAtBoundaryWithDirection(WebCore::TextGranularity
         return;
     }
     
-    sendWithAsyncReply(Messages::WebPage::MoveSelectionAtBoundaryWithDirection(static_cast<uint32_t>(granularity), static_cast<uint32_t>(direction)), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::moveSelectionAtBoundaryWithDirection"_s)] () mutable {
+    sendWithAsyncReply(Messages::WebPage::MoveSelectionAtBoundaryWithDirection(granularity, direction), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::moveSelectionAtBoundaryWithDirection"_s)] () mutable {
         callbackFunction();
     });
 }
@@ -630,10 +630,10 @@ void WebPageProxy::handleStylusSingleTapAtPoint(const WebCore::IntPoint& point,
     send(Messages::WebPage::HandleStylusSingleTapAtPoint(point, requestID));
 }
 
-void WebPageProxy::selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, uint32_t gestureType, uint32_t gestureState, WTF::Function<void (const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, GestureType gestureType, GestureRecognizerState gestureState, Function<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>, CallbackBase::Error)>&& callbackFunction)
 {
     if (!hasRunningProcess()) {
-        callbackFunction(WebCore::IntPoint(), 0, 0, 0, CallbackBase::Error::Unknown);
+        callbackFunction(WebCore::IntPoint(), GestureType::Loupe, GestureRecognizerState::Possible, { }, CallbackBase::Error::Unknown);
         return;
     }
 
@@ -754,7 +754,7 @@ void WebPageProxy::applicationDidBecomeActive()
 
 void WebPageProxy::extendSelection(WebCore::TextGranularity granularity)
 {
-    m_process->send(Messages::WebPage::ExtendSelection(static_cast<uint32_t>(granularity)), m_webPageID);
+    m_process->send(Messages::WebPage::ExtendSelection(granularity), m_webPageID);
 }
 
 void WebPageProxy::selectWordBackward()
@@ -770,7 +770,7 @@ void WebPageProxy::requestRectsForGranularityWithSelectionOffset(WebCore::TextGr
     }
     
     auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::requestRectsForGranularityWithSelectionOffset"_s));
-    m_process->send(Messages::WebPage::GetRectsForGranularityWithSelectionOffset(static_cast<uint32_t>(granularity), offset, callbackID), m_webPageID);
+    m_process->send(Messages::WebPage::GetRectsForGranularityWithSelectionOffset(granularity, offset, callbackID), m_webPageID);
 }
 
 void WebPageProxy::requestRectsAtSelectionOffsetWithText(int32_t offset, const String& text, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&& callbackFunction)
index ee2965b..0090b89 100644 (file)
 
 - (WKDOMRange *)rangeByExpandingToWordBoundaryByCharacters:(NSUInteger)characters inDirection:(WKDOMRangeDirection)direction
 {
-    RefPtr<WebCore::Range> newRange = rangeExpandedByCharactersInDirectionAtWordBoundary(direction == WKDOMRangeDirectionForward ?  _impl->endPosition() : _impl->startPosition(), characters, direction == WKDOMRangeDirectionForward ? WebCore::DirectionForward : WebCore::DirectionBackward);
+    RefPtr<WebCore::Range> newRange = rangeExpandedByCharactersInDirectionAtWordBoundary(direction == WKDOMRangeDirectionForward ?  _impl->endPosition() : _impl->startPosition(), characters, direction == WKDOMRangeDirectionForward ? WebCore::SelectionDirection::Forward : WebCore::SelectionDirection::Backward);
 
     return [[[WKDOMRange alloc] _initWithImpl:newRange.get()] autorelease];
 }
index d93d545..65e4db8 100644 (file)
@@ -1619,7 +1619,7 @@ WebCore::WebGLLoadPolicy WebFrameLoaderClient::webGLPolicyForURL(const URL& url)
     if (auto* webPage = m_frame->page())
         return webPage->webGLPolicyForURL(m_frame.ptr(), url);
 
-    return WebGLAllowCreation;
+    return WebGLLoadPolicy::WebGLAllowCreation;
 }
 
 WebCore::WebGLLoadPolicy WebFrameLoaderClient::resolveWebGLPolicyForURL(const URL& url) const
@@ -1627,7 +1627,7 @@ WebCore::WebGLLoadPolicy WebFrameLoaderClient::resolveWebGLPolicyForURL(const UR
     if (auto* webPage = m_frame->page())
         return webPage->resolveWebGLPolicyForURL(m_frame.ptr(), url);
 
-    return WebGLAllowCreation;
+    return WebGLLoadPolicy::WebGLAllowCreation;
 }
 
 #endif
index 8ba9342..868531a 100644 (file)
@@ -1049,12 +1049,12 @@ RefPtr<Plugin> WebPage::createPlugin(WebFrame* frame, HTMLPlugInElement* pluginE
 #if ENABLE(WEBGL) && !PLATFORM(MAC)
 WebCore::WebGLLoadPolicy WebPage::webGLPolicyForURL(WebFrame*, const URL&)
 {
-    return WebGLAllowCreation;
+    return WebGLLoadPolicy::WebGLAllowCreation;
 }
 
 WebCore::WebGLLoadPolicy WebPage::resolveWebGLPolicyForURL(WebFrame*, const URL&)
 {
-    return WebGLAllowCreation;
+    return WebGLLoadPolicy::WebGLAllowCreation;
 }
 #endif
 
index 15f28cf..feb30eb 100644 (file)
@@ -195,10 +195,12 @@ class VisiblePosition;
 enum SyntheticClickType : int8_t;
 enum class DOMPasteAccessResponse : uint8_t;
 enum class DragHandlingMethod : uint8_t;
+enum class SelectionDirection : uint8_t;
 enum class ShouldTreatAsContinuingLoad : bool;
 enum class StorageAccessPromptWasShown : bool;
 enum class StorageAccessWasGranted : bool;
 enum class TextIndicatorPresentationTransition : uint8_t;
+enum class TextGranularity : uint8_t;
 enum class WritingDirection : uint8_t;
 
 struct AttributedString;
@@ -685,19 +687,19 @@ public:
 
     void blurFocusedElement();
     void requestFocusedElementInformation(CallbackID);
-    void selectWithGesture(const WebCore::IntPoint&, uint32_t granularity, uint32_t gestureType, uint32_t gestureState, bool isInteractingWithFocusedElement, CallbackID);
-    void updateSelectionWithTouches(const WebCore::IntPoint&, uint32_t touches, bool baseIsStart, CallbackID);
-    void selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, uint32_t gestureType, uint32_t gestureState, CallbackID);
-    void extendSelection(uint32_t granularity);
+    void selectWithGesture(const WebCore::IntPoint&, GestureType, GestureRecognizerState, bool isInteractingWithFocusedElement, CallbackID);
+    void updateSelectionWithTouches(const WebCore::IntPoint&, SelectionTouch, bool baseIsStart, CallbackID);
+    void selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, GestureType, GestureRecognizerState, CallbackID);
+    void extendSelection(WebCore::TextGranularity);
     void selectWordBackward();
     void moveSelectionByOffset(int32_t offset, CompletionHandler<void()>&&);
-    void selectTextWithGranularityAtPoint(const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithFocusedElement, CompletionHandler<void()>&&);
-    void selectPositionAtBoundaryWithDirection(const WebCore::IntPoint&, uint32_t granularity, uint32_t direction, bool isInteractingWithFocusedElement, CompletionHandler<void()>&&);
-    void moveSelectionAtBoundaryWithDirection(uint32_t granularity, uint32_t direction, CompletionHandler<void()>&&);
+    void selectTextWithGranularityAtPoint(const WebCore::IntPoint&, WebCore::TextGranularity, bool isInteractingWithFocusedElement, CompletionHandler<void()>&&);
+    void selectPositionAtBoundaryWithDirection(const WebCore::IntPoint&, WebCore::TextGranularity, WebCore::SelectionDirection, bool isInteractingWithFocusedElement, CompletionHandler<void()>&&);
+    void moveSelectionAtBoundaryWithDirection(WebCore::TextGranularity, WebCore::SelectionDirection, CompletionHandler<void()>&&);
     void selectPositionAtPoint(const WebCore::IntPoint&, bool isInteractingWithFocusedElement, CompletionHandler<void()>&&);
-    void beginSelectionInDirection(uint32_t direction, CallbackID);
+    void beginSelectionInDirection(WebCore::SelectionDirection, CallbackID);
     void updateSelectionWithExtentPoint(const WebCore::IntPoint&, bool isInteractingWithFocusedElement, RespectSelectionAnchor, CallbackID);
-    void updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithFocusedElement, CallbackID);
+    void updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint&, WebCore::TextGranularity, bool isInteractingWithFocusedElement, CallbackID);
 
     void requestDictationContext(CallbackID);
     void replaceDictatedText(const String& oldText, const String& newText);
@@ -722,7 +724,7 @@ public:
     void getSelectionContext(CallbackID);
     void handleTwoFingerTapAtPoint(const WebCore::IntPoint&, OptionSet<WebKit::WebEvent::Modifier>, uint64_t requestID);
     void handleStylusSingleTapAtPoint(const WebCore::IntPoint&, uint64_t requestID);
-    void getRectsForGranularityWithSelectionOffset(uint32_t, int32_t, CallbackID);
+    void getRectsForGranularityWithSelectionOffset(WebCore::TextGranularity, int32_t, CallbackID);
     void getRectsAtSelectionOffsetWithText(int32_t, const String&, CallbackID);
     void storeSelectionForAccessibility(bool);
     void startAutoscrollAtPosition(const WebCore::FloatPoint&);
@@ -1365,7 +1367,7 @@ private:
     void completeSyntheticClick(WebCore::Node& nodeRespondingToClick, const WebCore::FloatPoint& location, OptionSet<WebKit::WebEvent::Modifier>, WebCore::SyntheticClickType, WebCore::PointerID = WebCore::mousePointerID);
     void sendTapHighlightForNodeIfNecessary(uint64_t requestID, WebCore::Node*);
     WebCore::VisiblePosition visiblePositionInFocusedNodeForPoint(const WebCore::Frame&, const WebCore::IntPoint&, bool isInteractingWithFocusedElement);
-    RefPtr<WebCore::Range> rangeForGranularityAtPoint(WebCore::Frame&, const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithFocusedElement);
+    RefPtr<WebCore::Range> rangeForGranularityAtPoint(WebCore::Frame&, const WebCore::IntPoint&, WebCore::TextGranularity, bool isInteractingWithFocusedElement);
     void setFocusedFrameBeforeSelectingTextAtLocation(const WebCore::IntPoint&);
     void dispatchSyntheticMouseEventsForSelectionGesture(SelectionTouch, const WebCore::IntPoint&);
 
index c8c162b..eeb090f 100644 (file)
@@ -63,19 +63,19 @@ messages -> WebPage LegacyReceiver {
     InspectorNodeSearchMovedToPosition(WebCore::FloatPoint point)
     InspectorNodeSearchEndedAtPosition(WebCore::FloatPoint point)
     BlurFocusedElement()
-    SelectWithGesture(WebCore::IntPoint point, uint32_t granularity, uint32_t gestureType, uint32_t gestureState, bool isInteractingWithFocusedElement, WebKit::CallbackID callbackID)
-    UpdateSelectionWithTouches(WebCore::IntPoint point, uint32_t touches, bool baseIsStart, WebKit::CallbackID callbackID)
-    SelectWithTwoTouches(WebCore::IntPoint from, WebCore::IntPoint to, uint32_t gestureType, uint32_t gestureState, WebKit::CallbackID callbackID)
-    ExtendSelection(uint32_t granularity)
+    SelectWithGesture(WebCore::IntPoint point, enum:uint8_t WebKit::GestureType gestureType, enum:uint8_t WebKit::GestureRecognizerState gestureState, bool isInteractingWithFocusedElement, WebKit::CallbackID callbackID)
+    UpdateSelectionWithTouches(WebCore::IntPoint point, enum:uint8_t WebKit::SelectionTouch touches, bool baseIsStart, WebKit::CallbackID callbackID)
+    SelectWithTwoTouches(WebCore::IntPoint from, WebCore::IntPoint to, enum:uint8_t WebKit::GestureType gestureType, enum:uint8_t WebKit::GestureRecognizerState gestureState, WebKit::CallbackID callbackID)
+    ExtendSelection(enum:uint8_t WebCore::TextGranularity granularity)
     SelectWordBackward()
     MoveSelectionByOffset(int32_t offset) -> () Async
-    SelectTextWithGranularityAtPoint(WebCore::IntPoint point, uint32_t granularity, bool isInteractingWithFocusedElement) -> () Async
-    SelectPositionAtBoundaryWithDirection(WebCore::IntPoint point, uint32_t granularity, uint32_t direction, bool isInteractingWithFocusedElement) -> () Async
-    MoveSelectionAtBoundaryWithDirection(uint32_t granularity, uint32_t direction) -> () Async
+    SelectTextWithGranularityAtPoint(WebCore::IntPoint point, enum:uint8_t WebCore::TextGranularity granularity, bool isInteractingWithFocusedElement) -> () Async
+    SelectPositionAtBoundaryWithDirection(WebCore::IntPoint point, enum:uint8_t WebCore::TextGranularity granularity, enum:uint8_t WebCore::SelectionDirection direction, bool isInteractingWithFocusedElement) -> () Async
+    MoveSelectionAtBoundaryWithDirection(enum:uint8_t WebCore::TextGranularity granularity, enum:uint8_t WebCore::SelectionDirection direction) -> () Async
     SelectPositionAtPoint(WebCore::IntPoint point, bool isInteractingWithFocusedElement) -> () Async
-    BeginSelectionInDirection(uint32_t direction, WebKit::CallbackID callbackID)
+    BeginSelectionInDirection(enum:uint8_t WebCore::SelectionDirection direction, WebKit::CallbackID callbackID)
     UpdateSelectionWithExtentPoint(WebCore::IntPoint point, bool isInteractingWithFocusedElement, enum:bool WebKit::RespectSelectionAnchor respectSelectionAnchor, WebKit::CallbackID callbackID)
-    UpdateSelectionWithExtentPointAndBoundary(WebCore::IntPoint point, uint32_t granularity, bool isInteractingWithFocusedElement, WebKit::CallbackID callbackID)
+    UpdateSelectionWithExtentPointAndBoundary(WebCore::IntPoint point, enum:uint8_t WebCore::TextGranularity granularity, bool isInteractingWithFocusedElement, WebKit::CallbackID callbackID)
     RequestDictationContext(WebKit::CallbackID callbackID)
     ReplaceDictatedText(String oldText, String newText)
     ReplaceSelectedText(String oldText, String newText)
@@ -107,7 +107,7 @@ messages -> WebPage LegacyReceiver {
     HandleTwoFingerTapAtPoint(WebCore::IntPoint point, OptionSet<WebKit::WebEvent::Modifier> modifiers, uint64_t requestID)
     HandleStylusSingleTapAtPoint(WebCore::IntPoint point, uint64_t requestID)
     SetForceAlwaysUserScalable(bool userScalable)
-    GetRectsForGranularityWithSelectionOffset(uint32_t granularity, int32_t offset, WebKit::CallbackID callbackID)
+    GetRectsForGranularityWithSelectionOffset(enum:uint8_t WebCore::TextGranularity granularity, int32_t offset, WebKit::CallbackID callbackID)
     GetRectsAtSelectionOffsetWithText(int32_t offset, String text, WebKit::CallbackID callbackID)
     StoreSelectionForAccessibility(bool shouldStore)
     StartAutoscrollAtPosition(WebCore::FloatPoint positionInWindow)
index e3dea23..819fbbf 100644 (file)
@@ -287,7 +287,7 @@ void WebPage::getPlatformEditorState(Frame& frame, EditorState& result) const
         endNodeIsInsideFixedPosition = startNodeIsInsideFixedPosition;
         postLayoutData.caretRectAtEnd = postLayoutData.caretRectAtStart;
         // FIXME: The following check should take into account writing direction.
-        postLayoutData.isReplaceAllowed = result.isContentEditable && atBoundaryOfGranularity(selection.start(), WordGranularity, DirectionForward);
+        postLayoutData.isReplaceAllowed = result.isContentEditable && atBoundaryOfGranularity(selection.start(), TextGranularity::WordGranularity, SelectionDirection::Forward);
         postLayoutData.wordAtSelection = plainTextForContext(wordRangeFromPosition(selection.start()).get());
         if (selection.isContentEditable())
             charactersAroundPosition(selection.start(), postLayoutData.characterAfterSelection, postLayoutData.characterBeforeSelection, postLayoutData.twoCharacterBeforeSelection);
@@ -323,8 +323,8 @@ void WebPage::getPlatformEditorState(Frame& frame, EditorState& result) const
             }
         }
         computeEditableRootHasContentAndPlainText(selection, postLayoutData);
-        postLayoutData.selectionStartIsAtParagraphBoundary = atBoundaryOfGranularity(selection.visibleStart(), TextGranularity::ParagraphGranularity, SelectionDirection::DirectionBackward);
-        postLayoutData.selectionEndIsAtParagraphBoundary = atBoundaryOfGranularity(selection.visibleEnd(), TextGranularity::ParagraphGranularity, SelectionDirection::DirectionForward);
+        postLayoutData.selectionStartIsAtParagraphBoundary = atBoundaryOfGranularity(selection.visibleStart(), TextGranularity::ParagraphGranularity, SelectionDirection::Backward);
+        postLayoutData.selectionEndIsAtParagraphBoundary = atBoundaryOfGranularity(selection.visibleEnd(), TextGranularity::ParagraphGranularity, SelectionDirection::Forward);
     }
 }
 
@@ -549,8 +549,8 @@ void WebPage::getSelectionContext(CallbackID callbackID)
     const int selectionExtendedContextLength = 350;
     
     String selectedText = plainTextForContext(frame.selection().selection().toNormalizedRange());
-    String textBefore = plainTextForDisplay(rangeExpandedByCharactersInDirectionAtWordBoundary(frame.selection().selection().start(), selectionExtendedContextLength, DirectionBackward).get());
-    String textAfter = plainTextForDisplay(rangeExpandedByCharactersInDirectionAtWordBoundary(frame.selection().selection().end(), selectionExtendedContextLength, DirectionForward).get());
+    String textBefore = plainTextForDisplay(rangeExpandedByCharactersInDirectionAtWordBoundary(frame.selection().selection().start(), selectionExtendedContextLength, SelectionDirection::Backward).get());
+    String textAfter = plainTextForDisplay(rangeExpandedByCharactersInDirectionAtWordBoundary(frame.selection().selection().end(), selectionExtendedContextLength, SelectionDirection::Forward).get());
 
     send(Messages::WebPageProxy::SelectionContextCallback(selectedText, textBefore, textAfter, callbackID));
 }
@@ -1343,7 +1343,7 @@ static IntPoint constrainPoint(const IntPoint& point, const Frame& frame, const
     return constrainedPoint;
 }
 
-void WebPage::selectWithGesture(const IntPoint& point, uint32_t granularity, uint32_t gestureType, uint32_t gestureState, bool isInteractingWithFocusedElement, CallbackID callbackID)
+void WebPage::selectWithGesture(const IntPoint& point, GestureType gestureType, GestureRecognizerState gestureState, bool isInteractingWithFocusedElement, CallbackID callbackID)
 {
     if (static_cast<GestureRecognizerState>(gestureState) == GestureRecognizerState::Began)
         setFocusedFrameBeforeSelectingTextAtLocation(point);
@@ -1352,11 +1352,11 @@ void WebPage::selectWithGesture(const IntPoint& point, uint32_t granularity, uin
     VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithFocusedElement);
 
     if (position.isNull()) {
-        send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, 0, callbackID));
+        send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, { }, callbackID));
         return;
     }
     RefPtr<Range> range;
-    SelectionFlags flags = None;
+    OptionSet<SelectionFlags> flags;
     GestureRecognizerState wkGestureState = static_cast<GestureRecognizerState>(gestureState);
     switch (static_cast<GestureType>(gestureType)) {
     case GestureType::PhraseBoundary:
@@ -1369,7 +1369,7 @@ void WebPage::selectWithGesture(const IntPoint& point, uint32_t granularity, uin
         if (position > markedRange->endPosition())
             position = markedRange->endPosition();
         if (wkGestureState != GestureRecognizerState::Began)
-            flags = distanceBetweenPositions(markedRange->startPosition(), frame.selection().selection().start()) != distanceBetweenPositions(markedRange->startPosition(), position) ? PhraseBoundaryChanged : None;
+            flags = distanceBetweenPositions(markedRange->startPosition(), frame.selection().selection().start()) != distanceBetweenPositions(markedRange->startPosition(), position) ? PhraseBoundaryChanged : OptionSet<SelectionFlags> { };
         else
             flags = PhraseBoundaryChanged;
         range = Range::create(*frame.document(), position, position);
@@ -1443,7 +1443,7 @@ void WebPage::selectWithGesture(const IntPoint& point, uint32_t granularity, uin
         break;
 
     case GestureType::OneFingerDoubleTap:
-        if (atBoundaryOfGranularity(position, LineGranularity, DirectionForward)) {
+        if (atBoundaryOfGranularity(position, TextGranularity::LineGranularity, SelectionDirection::Forward)) {
             // Double-tap at end of line only places insertion point there.
             // This helps to get the callout for pasting at ends of lines,
             // paragraphs, and documents.
@@ -1454,17 +1454,17 @@ void WebPage::selectWithGesture(const IntPoint& point, uint32_t granularity, uin
 
     case GestureType::TwoFingerSingleTap:
         // Single tap with two fingers selects the entire paragraph.
-        range = enclosingTextUnitOfGranularity(position, ParagraphGranularity, DirectionForward);
+        range = enclosingTextUnitOfGranularity(position, TextGranularity::ParagraphGranularity, SelectionDirection::Forward);
         break;
 
     case GestureType::OneFingerTripleTap:
-        if (atBoundaryOfGranularity(position, LineGranularity, DirectionForward)) {
+        if (atBoundaryOfGranularity(position, TextGranularity::LineGranularity, SelectionDirection::Forward)) {
             // Triple-tap at end of line only places insertion point there.
             // This helps to get the callout for pasting at ends of lines,
             // paragraphs, and documents.
             range = Range::create(*frame.document(), position, position);
         } else
-            range = enclosingTextUnitOfGranularity(position, ParagraphGranularity, DirectionForward);
+            range = enclosingTextUnitOfGranularity(position, TextGranularity::ParagraphGranularity, SelectionDirection::Forward);
         break;
 
     default:
@@ -1473,7 +1473,7 @@ void WebPage::selectWithGesture(const IntPoint& point, uint32_t granularity, uin
     if (range)
         frame.selection().setSelectedRange(range.get(), position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
 
-    send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, static_cast<uint32_t>(flags), callbackID));
+    send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, flags, callbackID));
 }
 
 static RefPtr<Range> rangeForPointInRootViewCoordinates(Frame& frame, const IntPoint& pointInRootViewCoordinates, bool baseIsStart)
@@ -1527,27 +1527,27 @@ static RefPtr<Range> rangeForPointInRootViewCoordinates(Frame& frame, const IntP
 
 static RefPtr<Range> rangeAtWordBoundaryForPosition(Frame* frame, const VisiblePosition& position, bool baseIsStart, SelectionDirection direction)
 {
-    SelectionDirection sameDirection = baseIsStart ? DirectionForward : DirectionBackward;
-    SelectionDirection oppositeDirection = baseIsStart ? DirectionBackward : DirectionForward;
+    SelectionDirection sameDirection = baseIsStart ? SelectionDirection::Forward : SelectionDirection::Backward;
+    SelectionDirection oppositeDirection = baseIsStart ? SelectionDirection::Backward : SelectionDirection::Forward;
     VisiblePosition base = baseIsStart ? frame->selection().selection().visibleStart() : frame->selection().selection().visibleEnd();
     VisiblePosition extent = baseIsStart ? frame->selection().selection().visibleEnd() : frame->selection().selection().visibleStart();
     VisiblePosition initialExtent = position;
 
-    if (atBoundaryOfGranularity(extent, WordGranularity, sameDirection)) {
+    if (atBoundaryOfGranularity(extent, TextGranularity::WordGranularity, sameDirection)) {
         // This is a word boundary. Leave selection where it is.
         return nullptr;
     }
 
-    if (atBoundaryOfGranularity(extent, WordGranularity, oppositeDirection)) {
+    if (atBoundaryOfGranularity(extent, TextGranularity::WordGranularity, oppositeDirection)) {
         // This is a word boundary in the wrong direction. Nudge the selection to a character before proceeding.
         extent = baseIsStart ? extent.previous() : extent.next();
     }
 
     // Extend to the boundary of the word.
 
-    VisiblePosition wordBoundary = positionOfNextBoundaryOfGranularity(extent, WordGranularity, sameDirection);
+    VisiblePosition wordBoundary = positionOfNextBoundaryOfGranularity(extent, TextGranularity::WordGranularity, sameDirection);
     if (wordBoundary.isNotNull()
-        && atBoundaryOfGranularity(wordBoundary, WordGranularity, sameDirection)
+        && atBoundaryOfGranularity(wordBoundary, TextGranularity::WordGranularity, sameDirection)
         && initialExtent != wordBoundary) {
         extent = wordBoundary;
         return (base < extent) ? Range::create(*frame->document(), base, extent) : Range::create(*frame->document(), extent, base);
@@ -1558,10 +1558,10 @@ static RefPtr<Range> rangeAtWordBoundaryForPosition(Frame* frame, const VisibleP
 
     // If this is where the extent was initially, then iterate in the other direction in the document until we hit the next word.
     while (extent.isNotNull()
-        && !atBoundaryOfGranularity(extent, WordGranularity, sameDirection)
+        && !atBoundaryOfGranularity(extent, TextGranularity::WordGranularity, sameDirection)
         && extent != base
-        && !atBoundaryOfGranularity(extent, LineGranularity, sameDirection)
-        && !atBoundaryOfGranularity(extent, LineGranularity, oppositeDirection)) {
+        && !atBoundaryOfGranularity(extent, TextGranularity::LineGranularity, sameDirection)
+        && !atBoundaryOfGranularity(extent, TextGranularity::LineGranularity, oppositeDirection)) {
         extent = baseIsStart ? extent.next() : extent.previous();
     }
 
@@ -1677,21 +1677,20 @@ void WebPage::dispatchSyntheticMouseEventsForSelectionGesture(SelectionTouch tou
     }
 }
 
-void WebPage::updateSelectionWithTouches(const IntPoint& point, uint32_t touches, bool baseIsStart, CallbackID callbackID)
+void WebPage::updateSelectionWithTouches(const IntPoint& point, SelectionTouch selectionTouch, bool baseIsStart, CallbackID callbackID)
 {
     Frame& frame = m_page->focusController().focusedOrMainFrame();
     IntPoint pointInDocument = frame.view()->rootViewToContents(point);
     VisiblePosition position = frame.visiblePositionForPoint(pointInDocument);
     if (position.isNull()) {
-        send(Messages::WebPageProxy::TouchesCallback(point, touches, 0, callbackID));
+        send(Messages::WebPageProxy::TouchesCallback(point, selectionTouch, { }, callbackID));
         return;
     }
 
     RefPtr<Range> range;
     VisiblePosition result;
-    SelectionFlags flags = None;
+    OptionSet<SelectionFlags> flags;
 
-    auto selectionTouch = static_cast<SelectionTouch>(touches);
     if (shouldDispatchSyntheticMouseEventsWhenModifyingSelection())
         dispatchSyntheticMouseEventsForSelectionGesture(selectionTouch, point);
 
@@ -1710,11 +1709,11 @@ void WebPage::updateSelectionWithTouches(const IntPoint& point, uint32_t touches
         break;
 
     case SelectionTouch::EndedMovingForward:
-        range = rangeAtWordBoundaryForPosition(&frame, position, baseIsStart, DirectionForward);
+        range = rangeAtWordBoundaryForPosition(&frame, position, baseIsStart, SelectionDirection::Forward);
         break;
         
     case SelectionTouch::EndedMovingBackward:
-        range = rangeAtWordBoundaryForPosition(&frame, position, baseIsStart, DirectionBackward);
+        range = rangeAtWordBoundaryForPosition(&frame, position, baseIsStart, SelectionDirection::Backward);
         break;
 
     case SelectionTouch::Moved:
@@ -1724,10 +1723,10 @@ void WebPage::updateSelectionWithTouches(const IntPoint& point, uint32_t touches
     if (range)
         frame.selection().setSelectedRange(range.get(), position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
 
-    send(Messages::WebPageProxy::TouchesCallback(point, touches, flags, callbackID));
+    send(Messages::WebPageProxy::TouchesCallback(point, selectionTouch, flags, callbackID));
 }
 
-void WebPage::selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, uint32_t gestureType, uint32_t gestureState, CallbackID callbackID)
+void WebPage::selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, GestureType gestureType, GestureRecognizerState gestureState, CallbackID callbackID)
 {
     Frame& frame = m_page->focusController().focusedOrMainFrame();
     VisiblePosition fromPosition = frame.visiblePositionForPoint(frame.view()->rootViewToContents(from));
@@ -1742,14 +1741,14 @@ void WebPage::selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore:
     }
 
     // We can use the same callback for the gestures with one point.
-    send(Messages::WebPageProxy::GestureCallback(from, gestureType, gestureState, 0, callbackID));
+    send(Messages::WebPageProxy::GestureCallback(from, gestureType, gestureState, { }, callbackID));
 }
 
-void WebPage::extendSelection(uint32_t granularity)
+void WebPage::extendSelection(WebCore::TextGranularity granularity)
 {
     Frame& frame = m_page->focusController().focusedOrMainFrame();
-    // For the moment we handle only WordGranularity.
-    if (granularity != WordGranularity || !frame.selection().isCaret())
+    // For the moment we handle only TextGranularity::WordGranularity.
+    if (granularity != TextGranularity::WordGranularity || !frame.selection().isCaret())
         return;
 
     VisiblePosition position = frame.selection().selection().start();
@@ -1792,7 +1791,7 @@ void WebPage::selectWordBackward()
         return;
 
     VisiblePosition position = frame.selection().selection().start();
-    VisiblePosition startPosition = positionOfNextBoundaryOfGranularity(position, WordGranularity, DirectionBackward);
+    VisiblePosition startPosition = positionOfNextBoundaryOfGranularity(position, TextGranularity::WordGranularity, SelectionDirection::Backward);
     if (startPosition.isNotNull() && startPosition != position)
         frame.selection().setSelectedRange(Range::create(*frame.document(), startPosition, position).ptr(), position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
 }
@@ -1804,10 +1803,10 @@ void WebPage::moveSelectionByOffset(int32_t offset, CompletionHandler<void()>&&
     VisiblePosition startPosition = frame.selection().selection().end();
     if (startPosition.isNull())
         return;
-    SelectionDirection direction = offset < 0 ? DirectionBackward : DirectionForward;
+    SelectionDirection direction = offset < 0 ? SelectionDirection::Backward : SelectionDirection::Forward;
     VisiblePosition position = startPosition;
     for (int i = 0; i < abs(offset); ++i) {
-        position = positionOfNextBoundaryOfGranularity(position, CharacterGranularity, direction);
+        position = positionOfNextBoundaryOfGranularity(position, TextGranularity::CharacterGranularity, direction);
         if (position.isNull())
             break;
     }
@@ -1943,7 +1942,7 @@ void WebPage::requestEvasionRectsAboveSelection(CompletionHandler<void(const Vec
     reply(WTFMove(rectsToAvoidInRootViewCoordinates));
 }
 
-void WebPage::getRectsForGranularityWithSelectionOffset(uint32_t granularity, int32_t offset, CallbackID callbackID)
+void WebPage::getRectsForGranularityWithSelectionOffset(WebCore::TextGranularity granularity, int32_t offset, CallbackID callbackID)
 {
     Frame& frame = m_page->focusController().focusedOrMainFrame();
     VisibleSelection selection = m_storedSelectionForAccessibility.isNone() ? frame.selection().selection() : m_storedSelectionForAccessibility;
@@ -1955,9 +1954,9 @@ void WebPage::getRectsForGranularityWithSelectionOffset(uint32_t granularity, in
     }
 
     auto position = visiblePositionForPositionWithOffset(selectionStart, offset);
-    SelectionDirection direction = offset < 0 ? DirectionBackward : DirectionForward;
+    SelectionDirection direction = offset < 0 ? SelectionDirection::Backward : SelectionDirection::Forward;
 
-    auto range = enclosingTextUnitOfGranularity(position, static_cast<WebCore::TextGranularity>(granularity), direction);
+    auto range = enclosingTextUnitOfGranularity(position, granularity, direction);
     if (!range || range->collapsed()) {
         send(Messages::WebPageProxy::SelectionRectsCallback({ }, callbackID));
         return;
@@ -2048,52 +2047,52 @@ void WebPage::selectPositionAtPoint(const WebCore::IntPoint& point, bool isInter
     completionHandler();
 }
 
-void WebPage::selectPositionAtBoundaryWithDirection(const WebCore::IntPoint& point, uint32_t granularity, uint32_t direction, bool isInteractingWithFocusedElement, CompletionHandler<void()>&& completionHandler)
+void WebPage::selectPositionAtBoundaryWithDirection(const WebCore::IntPoint& point, WebCore::TextGranularity granularity, WebCore::SelectionDirection direction, bool isInteractingWithFocusedElement, CompletionHandler<void()>&& completionHandler)
 {
     auto& frame = m_page->focusController().focusedOrMainFrame();
     VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithFocusedElement);
 
     if (position.isNotNull()) {
-        position = positionOfNextBoundaryOfGranularity(position, static_cast<WebCore::TextGranularity>(granularity), static_cast<SelectionDirection>(direction));
+        position = positionOfNextBoundaryOfGranularity(position, granularity, direction);
         if (position.isNotNull())
             frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), UPSTREAM, WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
     }
     completionHandler();
 }
 
-void WebPage::moveSelectionAtBoundaryWithDirection(uint32_t granularity, uint32_t direction, CompletionHandler<void()>&& completionHandler)
+void WebPage::moveSelectionAtBoundaryWithDirection(WebCore::TextGranularity granularity, WebCore::SelectionDirection direction, CompletionHandler<void()>&& completionHandler)
 {
     Frame& frame = m_page->focusController().focusedOrMainFrame();
     
     if (!frame.selection().selection().isNone()) {
-        bool isForward = (direction == DirectionForward || direction == DirectionRight);
+        bool isForward = (direction == SelectionDirection::Forward || direction == SelectionDirection::Right);
         VisiblePosition position = (isForward) ? frame.selection().selection().visibleEnd() : frame.selection().selection().visibleStart();
-        position = positionOfNextBoundaryOfGranularity(position, static_cast<WebCore::TextGranularity>(granularity), static_cast<SelectionDirection>(direction));
+        position = positionOfNextBoundaryOfGranularity(position, granularity, direction);
         if (position.isNotNull())
             frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), isForward? UPSTREAM : DOWNSTREAM, WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
     }
     completionHandler();
 }
 
-RefPtr<Range> WebPage::rangeForGranularityAtPoint(Frame& frame, const WebCore::IntPoint& point, uint32_t granularity, bool isInteractingWithFocusedElement)
+RefPtr<Range> WebPage::rangeForGranularityAtPoint(Frame& frame, const WebCore::IntPoint& point, WebCore::TextGranularity granularity, bool isInteractingWithFocusedElement)
 {
     VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithFocusedElement);
 
     RefPtr<Range> range;
-    switch (static_cast<WebCore::TextGranularity>(granularity)) {
-    case CharacterGranularity:
+    switch (granularity) {
+    case TextGranularity::CharacterGranularity:
         range = makeRange(position, position);
         break;
-    case WordGranularity:
+    case TextGranularity::WordGranularity:
         range = wordRangeFromPosition(position);
         break;
-    case SentenceGranularity:
-        range = enclosingTextUnitOfGranularity(position, SentenceGranularity, DirectionForward);
+    case TextGranularity::SentenceGranularity:
+        range = enclosingTextUnitOfGranularity(position, TextGranularity::SentenceGranularity, SelectionDirection::Forward);
         break;
-    case ParagraphGranularity:
-        range = enclosingTextUnitOfGranularity(position, ParagraphGranularity, DirectionForward);
+    case TextGranularity::ParagraphGranularity:
+        range = enclosingTextUnitOfGranularity(position, TextGranularity::ParagraphGranularity, SelectionDirection::Forward);
         break;
-    case DocumentGranularity:
+    case TextGranularity::DocumentGranularity:
         // FIXME: It's not clear why this mutates the current selection and returns null.
         frame.selection().selectAll();
         break;
@@ -2118,7 +2117,7 @@ void WebPage::setFocusedFrameBeforeSelectingTextAtLocation(const IntPoint& point
         m_page->focusController().setFocusedFrame(result.innerNodeFrame());
 }
 
-void WebPage::selectTextWithGranularityAtPoint(const WebCore::IntPoint& point, uint32_t granularity, bool isInteractingWithFocusedElement, CompletionHandler<void()>&& completionHandler)
+void WebPage::selectTextWithGranularityAtPoint(const WebCore::IntPoint& point, WebCore::TextGranularity granularity, bool isInteractingWithFocusedElement, CompletionHandler<void()>&& completionHandler)
 {
     setFocusedFrameBeforeSelectingTextAtLocation(point);
 
@@ -2130,13 +2129,13 @@ void WebPage::selectTextWithGranularityAtPoint(const WebCore::IntPoint& point, u
     completionHandler();
 }
 
-void WebPage::beginSelectionInDirection(uint32_t direction, CallbackID callbackID)
+void WebPage::beginSelectionInDirection(WebCore::SelectionDirection direction, CallbackID callbackID)
 {
-    m_selectionAnchor = (static_cast<SelectionDirection>(direction) == DirectionLeft) ? Start : End;
+    m_selectionAnchor = direction == SelectionDirection::Left ? Start : End;
     send(Messages::WebPageProxy::UnsignedCallback(m_selectionAnchor == Start, callbackID));
 }
 
-void WebPage::updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint& point, uint32_t granularity, bool isInteractingWithFocusedElement, CallbackID callbackID)
+void WebPage::updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint& point, WebCore::TextGranularity granularity, bool isInteractingWithFocusedElement, CallbackID callbackID)
 {
     auto& frame = m_page->focusController().focusedOrMainFrame();
     VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithFocusedElement);
@@ -2232,7 +2231,7 @@ void WebPage::requestDictationContext(CallbackID callbackID)
         VisiblePosition currentPosition = startPosition;
         VisiblePosition lastPosition = startPosition;
         for (unsigned i = 0; i < dictationContextWordCount; ++i) {
-            currentPosition = startOfWord(positionOfNextBoundaryOfGranularity(lastPosition, WordGranularity, DirectionBackward));
+            currentPosition = startOfWord(positionOfNextBoundaryOfGranularity(lastPosition, TextGranularity::WordGranularity, SelectionDirection::Backward));
             if (currentPosition.isNull())
                 break;
             lastPosition = currentPosition;
@@ -2246,7 +2245,7 @@ void WebPage::requestDictationContext(CallbackID callbackID)
         VisiblePosition currentPosition = endPosition;
         VisiblePosition lastPosition = endPosition;
         for (unsigned i = 0; i < dictationContextWordCount; ++i) {
-            currentPosition = endOfWord(positionOfNextBoundaryOfGranularity(lastPosition, WordGranularity, DirectionForward));
+            currentPosition = endOfWord(positionOfNextBoundaryOfGranularity(lastPosition, TextGranularity::WordGranularity, SelectionDirection::Forward));
             if (currentPosition.isNull())
                 break;
             lastPosition = currentPosition;
@@ -2432,7 +2431,7 @@ bool WebPage::applyAutocorrectionInternal(const String& correction, const String
     if (correction.length())
         frame.editor().insertText(correction, 0, originalText.isEmpty() ? TextEventInputKeyboard : TextEventInputAutocompletion);
     else if (originalText.length())
-        frame.editor().deleteWithDirection(DirectionBackward, CharacterGranularity, false, true);
+        frame.editor().deleteWithDirection(SelectionDirection::Backward, TextGranularity::CharacterGranularity, false, true);
     return true;
 }
 
@@ -2477,7 +2476,7 @@ WebAutocorrectionContext WebPage::autocorrectionContext()
             for (unsigned i = 0; i < minContextWordCount; ++i) {
                 if (contextBefore.length() >= minContextLenght)
                     break;
-                previousPosition = startOfWord(positionOfNextBoundaryOfGranularity(currentPosition, WordGranularity, DirectionBackward));
+                previousPosition = startOfWord(positionOfNextBoundaryOfGranularity(currentPosition, TextGranularity::WordGranularity, SelectionDirection::Backward));
                 if (previousPosition.isNull())
                     break;
                 String currentWord = plainTextForContext(Range::create(*frame.document(), previousPosition, currentPosition).ptr());
@@ -2488,15 +2487,15 @@ WebAutocorrectionContext WebPage::autocorrectionContext()
             }
             if (currentPosition.isNotNull() && currentPosition != startPosition) {
                 contextBefore = plainTextForContext(Range::create(*frame.document(), currentPosition, startPosition).ptr());
-                if (atBoundaryOfGranularity(currentPosition, ParagraphGranularity, DirectionBackward))
+                if (atBoundaryOfGranularity(currentPosition, TextGranularity::ParagraphGranularity, SelectionDirection::Backward))
                     contextBefore = makeString("\n "_s, contextBefore);
             }
         }
 
         if (endPosition != endOfEditableContent(endPosition)) {
             VisiblePosition nextPosition;
-            if (!atBoundaryOfGranularity(endPosition, WordGranularity, DirectionForward) && withinTextUnitOfGranularity(endPosition, WordGranularity, DirectionForward))
-                nextPosition = positionOfNextBoundaryOfGranularity(endPosition, WordGranularity, DirectionForward);
+            if (!atBoundaryOfGranularity(endPosition, TextGranularity::WordGranularity, SelectionDirection::Forward) && withinTextUnitOfGranularity(endPosition, TextGranularity::WordGranularity, SelectionDirection::Forward))
+                nextPosition = positionOfNextBoundaryOfGranularity(endPosition, TextGranularity::WordGranularity, SelectionDirection::Forward);
             if (nextPosition.isNotNull())
                 contextAfter = plainTextForContext(Range::create(*frame.document(), endPosition, nextPosition).ptr());
         }
@@ -2630,9 +2629,9 @@ static void dataDetectorLinkPositionInformation(Element& element, InteractionInf
     auto linkRange = Range::create(element.document());
     linkRange->selectNodeContents(element);
     info.textBefore = plainTextForDisplay(rangeExpandedByCharactersInDirectionAtWordBoundary(linkRange->startPosition(),
-        dataDetectionExtendedContextLength, DirectionBackward).get());
+        dataDetectionExtendedContextLength, SelectionDirection::Backward).get());
     info.textAfter = plainTextForDisplay(rangeExpandedByCharactersInDirectionAtWordBoundary(linkRange->endPosition(),
-        dataDetectionExtendedContextLength, DirectionForward).get());
+        dataDetectionExtendedContextLength, SelectionDirection::Forward).get());
 }
 #endif
 
@@ -4069,7 +4068,7 @@ static VisiblePosition moveByGranularityRespectingWordBoundary(const VisiblePosi
 {
     ASSERT(granularityCount);
     ASSERT(position.isNotNull());
-    bool backwards = direction == DirectionBackward;
+    bool backwards = direction == SelectionDirection::Backward;
     auto farthestPositionInDirection = backwards ? startOfEditableContent(position) : endOfEditableContent(position);
     if (position == farthestPositionInDirection)
         return backwards ? startOfWord(position) : endOfWord(position);
@@ -4083,8 +4082,8 @@ static VisiblePosition moveByGranularityRespectingWordBoundary(const VisiblePosi
         if (atBoundaryOfGranularity(currentPosition, granularity, direction))
             --granularityCount;
     } while (granularityCount);
-    if (granularity == SentenceGranularity) {
-        ASSERT(atBoundaryOfGranularity(currentPosition, SentenceGranularity, direction));
+    if (granularity == TextGranularity::SentenceGranularity) {
+        ASSERT(atBoundaryOfGranularity(currentPosition, TextGranularity::SentenceGranularity, direction));
         return currentPosition;
     }
     // Note that this rounds to the nearest word, which may cross a line boundary when using line granularity.
@@ -4197,8 +4196,8 @@ void WebPage::requestDocumentEditingContext(DocumentEditingContextRequest reques
     VisiblePosition contextAfterEnd;
     auto compositionRange = frame->editor().compositionRange();
     if (request.granularityCount) {
-        contextBeforeStart = moveByGranularityRespectingWordBoundary(rangeOfInterestStart, request.surroundingGranularity, request.granularityCount, DirectionBackward);
-        contextAfterEnd = moveByGranularityRespectingWordBoundary(rangeOfInterestEnd, request.surroundingGranularity, request.granularityCount, DirectionForward);
+        contextBeforeStart = moveByGranularityRespectingWordBoundary(rangeOfInterestStart, request.surroundingGranularity, request.granularityCount, SelectionDirection::Backward);
+        contextAfterEnd = moveByGranularityRespectingWordBoundary(rangeOfInterestEnd, request.surroundingGranularity, request.granularityCount, SelectionDirection::Forward);
     } else {
         contextBeforeStart = rangeOfInterestStart;
         contextAfterEnd = rangeOfInterestEnd;
index 53d2f77..ae0a0ca 100644 (file)
@@ -65,6 +65,7 @@
 #import <WebCore/FocusController.h>
 #import <WebCore/Frame.h>
 #import <WebCore/FrameLoader.h>
+#import <WebCore/FrameLoaderTypes.h>
 #import <WebCore/FrameView.h>
 #import <WebCore/GraphicsContext.h>
 #import <WebCore/GraphicsContextGLOpenGL.h>
@@ -773,24 +774,18 @@ void WebPage::drawPagesToPDFFromPDFDocument(CGContextRef context, PDFDocument *p
 }
 
 #if ENABLE(WEBGL)
-WebCore::WebGLLoadPolicy WebPage::webGLPolicyForURL(WebFrame* frame, const URL& url)
+WebCore::WebGLLoadPolicy WebPage::webGLPolicyForURL(WebFrame*, const URL& url)
 {
-    uint32_t policyResult = 0;
-
-    if (sendSync(Messages::WebPageProxy::WebGLPolicyForURL(url), Messages::WebPageProxy::WebGLPolicyForURL::Reply(policyResult)))
-        return static_cast<WebGLLoadPolicy>(policyResult);
-
-    return WebGLAllowCreation;
+    WebGLLoadPolicy policyResult = WebGLLoadPolicy::WebGLAllowCreation;
+    sendSync(Messages::WebPageProxy::WebGLPolicyForURL(url), Messages::WebPageProxy::WebGLPolicyForURL::Reply(policyResult));
+    return policyResult;
 }
 
-WebCore::WebGLLoadPolicy WebPage::resolveWebGLPolicyForURL(WebFrame* frame, const URL& url)
+WebCore::WebGLLoadPolicy WebPage::resolveWebGLPolicyForURL(WebFrame*, const URL& url)
 {
-    uint32_t policyResult = 0;
-
-    if (sendSync(Messages::WebPageProxy::ResolveWebGLPolicyForURL(url), Messages::WebPageProxy::ResolveWebGLPolicyForURL::Reply(policyResult)))
-        return static_cast<WebGLLoadPolicy>(policyResult);
-
-    return WebGLAllowCreation;
+    WebGLLoadPolicy policyResult = WebGLLoadPolicy::WebGLAllowCreation;
+    sendSync(Messages::WebPageProxy::ResolveWebGLPolicyForURL(url), Messages::WebPageProxy::ResolveWebGLPolicyForURL::Reply(policyResult));
+    return policyResult;
 }
 #endif // ENABLE(WEBGL)
 
index b82f750..0b72192 100644 (file)
@@ -1,3 +1,17 @@
+2020-05-15  Alex Christensen  <achristensen@webkit.org>
+
+        Use enum serialization instead of casting to/from uint32_t
+        https://bugs.webkit.org/show_bug.cgi?id=211885
+
+        Reviewed by Geoffrey Garen.
+
+        * WebCoreSupport/WebFrameIOS.mm:
+        (-[WebFrame aggressivelyExpandSelectionToWordContainingCaretSelection]):
+        (-[WebFrame setSelectionGranularity:]):
+        * WebCoreSupport/WebVisiblePosition.mm:
+        (toTextGranularity):
+        (toSelectionDirection):
+
 2020-05-14  Daniel Bates  <dabates@apple.com>
 
         [iOS] Remove dead dictation code
index 671f4f3..8d6c487 100644 (file)
@@ -484,7 +484,7 @@ using namespace WebCore;
 
     // This is a temporary hack until we get the improvements
     // I'm working on for RTL selection.
-    if (frameSelection.granularity() == WordGranularity)
+    if (frameSelection.granularity() == TextGranularity::WordGranularity)
         frameSelection.moveTo(frameSelection.selection().start(), frameSelection.selection().end());
     
     if (frameSelection.selection().isCaret()) {
@@ -604,23 +604,23 @@ using namespace WebCore;
 
 - (void)setSelectionGranularity:(WebTextGranularity)granularity
 {
-    TextGranularity wcGranularity = CharacterGranularity;
+    TextGranularity wcGranularity = TextGranularity::CharacterGranularity;
     switch (granularity) {
         case WebTextGranularityCharacter:
-            wcGranularity = CharacterGranularity;
+            wcGranularity = TextGranularity::CharacterGranularity;
             break;
         case WebTextGranularityWord:
-            wcGranularity = WordGranularity;
+            wcGranularity = TextGranularity::WordGranularity;
             break;
         case WebTextGranularitySentence:
-            wcGranularity = SentenceGranularity;
+            wcGranularity = TextGranularity::SentenceGranularity;
             break;
         case WebTextGranularityParagraph:
-            wcGranularity = ParagraphGranularity;
+            wcGranularity = TextGranularity::ParagraphGranularity;
             break;
         case WebTextGranularityAll:
-            // FIXME: Add DocumentGranularity.
-            wcGranularity = ParagraphGranularity;
+            // FIXME: Add TextGranularity::DocumentGranularity.
+            wcGranularity = TextGranularity::ParagraphGranularity;
             break;
         default:
             ASSERT_NOT_REACHED();
index 54325ad..2b3d19c 100644 (file)
@@ -205,27 +205,27 @@ static inline TextGranularity toTextGranularity(WebTextGranularity webGranularit
     
     switch (webGranularity) {
         case WebTextGranularityCharacter:
-            granularity = CharacterGranularity;
+            granularity = TextGranularity::CharacterGranularity;
             break;
 
         case WebTextGranularityWord:
-            granularity = WordGranularity;
+            granularity = TextGranularity::WordGranularity;
             break;
 
         case WebTextGranularitySentence:
-            granularity = SentenceGranularity;
+            granularity = TextGranularity::SentenceGranularity;
             break;
 
         case WebTextGranularityLine:
-            granularity = LineGranularity;
+            granularity = TextGranularity::LineGranularity;
             break;
 
         case WebTextGranularityParagraph:
-            granularity = ParagraphGranularity;
+            granularity = TextGranularity::ParagraphGranularity;
             break;
 
         case WebTextGranularityAll:
-            granularity = DocumentGranularity;
+            granularity = TextGranularity::DocumentGranularity;
             break;
 
         default:
@@ -242,27 +242,27 @@ static inline SelectionDirection toSelectionDirection(WebTextAdjustmentDirection
     
     switch (direction) {
         case WebTextAdjustmentForward:
-            result = DirectionForward;
+            result = SelectionDirection::Forward;
             break;
             
         case WebTextAdjustmentBackward:
-            result = DirectionBackward;
+            result = SelectionDirection::Backward;
             break;
             
         case WebTextAdjustmentRight:
-            result = DirectionRight;
+            result = SelectionDirection::Right;
             break;
             
         case WebTextAdjustmentLeft:
-            result = DirectionLeft;
+            result = SelectionDirection::Left;
             break;
         
         case WebTextAdjustmentUp:
-            result = DirectionLeft;
+            result = SelectionDirection::Left;
             break;
         
         case WebTextAdjustmentDown:
-            result = DirectionRight;
+            result = SelectionDirection::Right;
             break;
     }
 
index c72bcee..0918be1 100644 (file)
@@ -1,3 +1,21 @@
+2020-05-15  Alex Christensen  <achristensen@webkit.org>
+
+        Use enum serialization instead of casting to/from uint32_t
+        https://bugs.webkit.org/show_bug.cgi?id=211885
+
+        Reviewed by Geoffrey Garen.
+
+        * DOM/DOMUIKitExtensions.mm:
+        (-[DOMRange move:inDirection:]):
+        (-[DOMRange extend:inDirection:]):
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::webGLPolicyForURL const):
+        (WebFrameLoaderClient::resolveWebGLPolicyForURL const):
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _canSmartCopyOrDelete]):
+        * WebView/WebTextCompletionController.mm:
+        (-[WebTextCompletionController doCompletion]):
+
 2020-05-14  Chris Dumez  <cdumez@apple.com>
 
         Regression(r254856) Family Health iOS app is broken due to lack for WebSQL support
index 3b09f3c..8100abe 100644 (file)
@@ -82,15 +82,15 @@ using WebCore::VisiblePosition;
     WebCore::FrameSelection frameSelection;
     frameSelection.moveTo(range);
     
-    WebCore::TextGranularity granularity = WebCore::CharacterGranularity;
+    WebCore::TextGranularity granularity = WebCore::TextGranularity::CharacterGranularity;
     // Until WebKit supports vertical layout, "down" is equivalent to "forward by a line" and
     // "up" is equivalent to "backward by a line".
     if (direction == WebTextAdjustmentDown) {
         direction = WebTextAdjustmentForward;
-        granularity = WebCore::LineGranularity;
+        granularity = WebCore::TextGranularity::LineGranularity;
     } else if (direction == WebTextAdjustmentUp) {
         direction = WebTextAdjustmentBackward;
-        granularity = WebCore::LineGranularity;
+        granularity = WebCore::TextGranularity::LineGranularity;
     }
     
     for (UInt32 i = 0; i < amount; i++)
@@ -111,7 +111,7 @@ using WebCore::VisiblePosition;
     frameSelection.moveTo(range);
     
     for (UInt32 i = 0; i < amount; i++)
-        frameSelection.modify(WebCore::FrameSelection::AlterationExtend, (WebCore::SelectionDirection)direction, WebCore::CharacterGranularity);
+        frameSelection.modify(WebCore::FrameSelection::AlterationExtend, (WebCore::SelectionDirection)direction, WebCore::TextGranularity::CharacterGranularity);
     
     Position start = frameSelection.selection().start().parentAnchoredEquivalent();
     Position end = frameSelection.selection().end().parentAnchoredEquivalent();
index ec02bdf..e95375f 100644 (file)
@@ -2112,12 +2112,12 @@ static bool shouldBlockWebGL()
 
 WebCore::WebGLLoadPolicy WebFrameLoaderClient::webGLPolicyForURL(const URL&) const
 {
-    return shouldBlockWebGL() ? WebCore::WebGLBlockCreation : WebCore::WebGLAllowCreation;
+    return shouldBlockWebGL() ? WebCore::WebGLLoadPolicy::WebGLBlockCreation : WebCore::WebGLLoadPolicy::WebGLAllowCreation;
 }
 
 WebCore::WebGLLoadPolicy WebFrameLoaderClient::resolveWebGLPolicyForURL(const URL&) const
 {
-    return shouldBlockWebGL() ? WebCore::WebGLBlockCreation : WebCore::WebGLAllowCreation;
+    return shouldBlockWebGL() ? WebCore::WebGLLoadPolicy::WebGLBlockCreation : WebCore::WebGLLoadPolicy::WebGLAllowCreation;
 }
 #endif // ENABLE(WEBGL)
 
index 039b7f4..e0d8b54 100644 (file)
@@ -5732,7 +5732,7 @@ static BOOL writingDirectionKeyBindingsEnabled()
     if (![[self _webView] smartInsertDeleteEnabled])
         return NO;
     auto* coreFrame = core([self _frame]);
-    return coreFrame && coreFrame->selection().granularity() == WebCore::WordGranularity;
+    return coreFrame && coreFrame->selection().granularity() == WebCore::TextGranularity::WordGranularity;
 }
 
 #if PLATFORM(MAC)
index c5f87dc..1e3b79d 100644 (file)
@@ -178,7 +178,7 @@ using namespace WebCore;
         WebFrame *frame = [_htmlView _frame];
         DOMRange *selection = kit(createLiveRange(core(frame)->selection().selection().toNormalizedRange()).get());
         DOMRange *wholeWord = [frame _rangeByAlteringCurrentSelection:FrameSelection::AlterationExtend
-            direction:DirectionBackward granularity:WordGranularity];
+            direction:SelectionDirection::Backward granularity:TextGranularity::WordGranularity];
         DOMRange *prefix = [wholeWord cloneRange];
         [prefix setEnd:[selection startContainer] offset:[selection startOffset]];
 
index b7e977d..40d59a6 100644 (file)
@@ -1,3 +1,17 @@
+2020-05-15  Alex Christensen  <achristensen@webkit.org>
+
+        Use enum serialization instead of casting to/from uint32_t
+        https://bugs.webkit.org/show_bug.cgi?id=211885
+
+        Reviewed by Geoffrey Garen.
+
+        * DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
+        (AccessibilityUIElement::increaseTextSelection):
+        (AccessibilityUIElement::decreaseTextSelection):
+        * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
+        (WTR::AccessibilityUIElement::increaseTextSelection):
+        (WTR::AccessibilityUIElement::decreaseTextSelection):
+
 2020-05-15  Ryan Haddad  <ryanhaddad@apple.com>
 
         [iOS EWS] TestWebKitAPI.WKWebsiteDataStore.RemoveAndFetchData is failing
index 951dddd..16ac6a0 100644 (file)
@@ -345,12 +345,12 @@ AccessibilityUIElement AccessibilityUIElement::disclosedByRow()
 
 void AccessibilityUIElement::increaseTextSelection()
 {
-    [m_element accessibilityModifySelection:WebCore::CharacterGranularity increase:YES];
+    [m_element accessibilityModifySelection:WebCore::TextGranularity::CharacterGranularity increase:YES];
 }
 
 void AccessibilityUIElement::decreaseTextSelection()
 {
-    [m_element accessibilityModifySelection:WebCore::CharacterGranularity increase:NO];    
+    [m_element accessibilityModifySelection:WebCore::TextGranularity::CharacterGranularity increase:NO];    
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::speakAs()
index 56d27b4..eadbe83 100644 (file)
@@ -936,12 +936,12 @@ bool AccessibilityUIElement::scrollPageRight()
 
 void AccessibilityUIElement::increaseTextSelection()
 {
-    [m_element accessibilityModifySelection:WebCore::CharacterGranularity increase:YES];
+    [m_element accessibilityModifySelection:WebCore::TextGranularity::CharacterGranularity increase:YES];
 }
 
 void AccessibilityUIElement::decreaseTextSelection()
 {
-    [m_element accessibilityModifySelection:WebCore::CharacterGranularity increase:NO];
+    [m_element accessibilityModifySelection:WebCore::TextGranularity::CharacterGranularity increase:NO];
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForSelection()