Title: [243520] trunk/Source/WebKit
- Revision
- 243520
- Author
- dba...@webkit.org
- Date
- 2019-03-26 15:08:52 -0700 (Tue, 26 Mar 2019)
Log Message
[iOS][WK2] Use a better concept to describe the reason we defer zooming a focused element: selectabiltiy
https://bugs.webkit.org/show_bug.cgi?id=196264
Reviewed by Wenson Hsieh.
Rename shouldDeferZoomingToSelectionWhenRevealingFocusedElement() to mayContainSelectableText() to describe
the criterion that we will use to decide whether to defer zooming or not. We defer zooming only for elements
that may support text selection on initial focus because we do not have an up-to-date selection rect at that
time. For element, like <select>, that do not support text selection, we can zoom them immediately when focused.
* UIProcess/ios/WKContentViewInteraction.mm:
(mayContainSelectableText): Renamed from shouldDeferZoomingToSelectionWhenRevealingFocusedElement.
List all the input types in the switch block and remove the default case to force the compiler to check that we
covered all cases. This will prevent unforseen keyboard issues (why isn't the keyboard shown? or why is the keyboard shown?)
for future input types that we may add.
(rectToRevealWhenZoomingToFocusedElement): Update for renaming.
(-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]): Add a
comment to explain why we may need to defer the zoom: the focused element supports text selection and we need
to wait for the web process to call back to provide an up-to-date selection rect for us to zoom and reveal.
(-[WKContentView _didReceiveEditorStateUpdateAfterFocus]): Update for renaming.
(shouldDeferZoomingToSelectionWhenRevealingFocusedElement): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (243519 => 243520)
--- trunk/Source/WebKit/ChangeLog 2019-03-26 21:15:16 UTC (rev 243519)
+++ trunk/Source/WebKit/ChangeLog 2019-03-26 22:08:52 UTC (rev 243520)
@@ -1,3 +1,27 @@
+2019-03-26 Daniel Bates <daba...@apple.com>
+
+ [iOS][WK2] Use a better concept to describe the reason we defer zooming a focused element: selectabiltiy
+ https://bugs.webkit.org/show_bug.cgi?id=196264
+
+ Reviewed by Wenson Hsieh.
+
+ Rename shouldDeferZoomingToSelectionWhenRevealingFocusedElement() to mayContainSelectableText() to describe
+ the criterion that we will use to decide whether to defer zooming or not. We defer zooming only for elements
+ that may support text selection on initial focus because we do not have an up-to-date selection rect at that
+ time. For element, like <select>, that do not support text selection, we can zoom them immediately when focused.
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (mayContainSelectableText): Renamed from shouldDeferZoomingToSelectionWhenRevealingFocusedElement.
+ List all the input types in the switch block and remove the default case to force the compiler to check that we
+ covered all cases. This will prevent unforseen keyboard issues (why isn't the keyboard shown? or why is the keyboard shown?)
+ for future input types that we may add.
+ (rectToRevealWhenZoomingToFocusedElement): Update for renaming.
+ (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]): Add a
+ comment to explain why we may need to defer the zoom: the focused element supports text selection and we need
+ to wait for the web process to call back to provide an up-to-date selection rect for us to zoom and reveal.
+ (-[WKContentView _didReceiveEditorStateUpdateAfterFocus]): Update for renaming.
+ (shouldDeferZoomingToSelectionWhenRevealingFocusedElement): Deleted.
+
2019-03-26 Wenson Hsieh <wenson_hs...@apple.com>
Implement async paste method on UIWKInteractionViewProtocol
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (243519 => 243520)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-03-26 21:15:16 UTC (rev 243519)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-03-26 22:08:52 UTC (rev 243520)
@@ -4812,22 +4812,36 @@
return _focusedElementInformation.selectOptions;
}
-static bool shouldDeferZoomingToSelectionWhenRevealingFocusedElement(WebKit::InputType type)
+// Note that selectability is also affected by the CSS property user-select.
+static bool mayContainSelectableText(WebKit::InputType type)
{
switch (type) {
+ case WebKit::InputType::None:
+ // The following types have custom UI and do not look or behave like a text field.
+#if ENABLE(INPUT_TYPE_COLOR)
+ case WebKit::InputType::Color:
+#endif
+ case WebKit::InputType::Date:
+ case WebKit::InputType::DateTimeLocal:
+ case WebKit::InputType::Drawing:
+ case WebKit::InputType::Month:
+ case WebKit::InputType::Select:
+ case WebKit::InputType::Time:
+ return false;
+ // The following types look and behave like a text field.
case WebKit::InputType::ContentEditable:
+ case WebKit::InputType::DateTime:
+ case WebKit::InputType::Email:
+ case WebKit::InputType::Number:
+ case WebKit::InputType::NumberPad:
+ case WebKit::InputType::Password:
+ case WebKit::InputType::Phone:
+ case WebKit::InputType::Search:
case WebKit::InputType::Text:
- case WebKit::InputType::Password:
case WebKit::InputType::TextArea:
- case WebKit::InputType::Search:
- case WebKit::InputType::Email:
case WebKit::InputType::URL:
- case WebKit::InputType::Phone:
- case WebKit::InputType::Number:
- case WebKit::InputType::NumberPad:
+ case WebKit::InputType::Week:
return true;
- default:
- return false;
}
}
@@ -4837,7 +4851,7 @@
if (elementInfo.elementRect.contains(elementInfo.lastInteractionLocation))
elementInteractionRect = { elementInfo.lastInteractionLocation, { 1, 1 } };
- if (!shouldDeferZoomingToSelectionWhenRevealingFocusedElement(elementInfo.elementType))
+ if (!mayContainSelectableText(elementInfo.elementType))
return elementInteractionRect;
if (editorState.isMissingPostLayoutData) {
@@ -4973,28 +4987,19 @@
#else
[self reloadInputViews];
#endif
-
- switch (information.elementType) {
- case WebKit::InputType::Select:
- case WebKit::InputType::DateTimeLocal:
- case WebKit::InputType::Time:
- case WebKit::InputType::Month:
- case WebKit::InputType::Date:
- case WebKit::InputType::Drawing:
-#if ENABLE(INPUT_TYPE_COLOR)
- case WebKit::InputType::Color:
-#endif
- break;
- default:
+
+ if (mayContainSelectableText(_focusedElementInformation.elementType))
[self _showKeyboard];
- break;
- }
-
+
// The custom fixed position rect behavior is affected by -isFocusingElement, so if that changes we need to recompute rects.
if (editableChanged)
[_webView _scheduleVisibleContentRectUpdate];
-
- if (!shouldDeferZoomingToSelectionWhenRevealingFocusedElement(_focusedElementInformation.elementType))
+
+ // For elements that have selectable content (e.g. text field) we need to wait for the web process to send an up-to-date
+ // selection rect before we can zoom and reveal the selection. Non-selectable elements (e.g. <select>) can be zoomed
+ // immediately because they have no selection to reveal.
+ BOOL needsEditorStateUpdate = mayContainSelectableText(_focusedElementInformation.elementType);
+ if (!needsEditorStateUpdate)
[self _zoomToRevealFocusedElement];
[self _updateAccessory];
@@ -5146,7 +5151,7 @@
// FIXME: If the initial writing direction just changed, we should wait until we get the next post-layout editor state
// before zooming to reveal the selection rect.
- if (shouldDeferZoomingToSelectionWhenRevealingFocusedElement(_focusedElementInformation.elementType))
+ if (mayContainSelectableText(_focusedElementInformation.elementType))
[self _zoomToRevealFocusedElement];
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes