Changeset 251693 in webkit
- Timestamp:
- Oct 28, 2019 7:34:20 PM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r251690 r251693 1 2019-10-28 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Replace InteractionInformationAtPosition.nodeAtPositionIsFocusedElement with an element context 4 https://bugs.webkit.org/show_bug.cgi?id=203498 5 6 Reviewed by Tim Horton. 7 8 Refactors InteractionInformationAtPosition, such that it doesn't need a special flag to indicate whether there 9 is a focused element at the position. This is a followup to webkit.org/b/203264; no new tests, as there should 10 be no change in behavior. 11 12 * Shared/FocusedElementInformation.cpp: 13 (WebKit::FocusedElementInformation::encode const): 14 (WebKit::FocusedElementInformation::decode): 15 * Shared/FocusedElementInformation.h: 16 17 Add an elementContext to FocusedElementInformation to represent the focused element; then, instead of checking 18 whether there is a focused element underneath the request position, simply check that the position information's 19 element context matches the FocusedElementInformation's element context. 20 21 Additionally, rename elementRect in FocusedElementInformation to interactionRect, to draw a distinction between 22 this rect and the new ElementContext's boundingRect. 23 24 * Shared/ios/InteractionInformationAtPosition.h: 25 * Shared/ios/InteractionInformationAtPosition.mm: 26 (WebKit::InteractionInformationAtPosition::encode const): 27 (WebKit::InteractionInformationAtPosition::decode): 28 29 Remove the nodeAtPositionIsFocusedElement flag. 30 31 * UIProcess/ios/WKContentViewInteraction.mm: 32 (-[WKContentView _didGetTapHighlightForRequest:color:quads:topLeftRadius:topRightRadius:bottomLeftRadius:bottomRightRadius:nodeHasBuiltInClickHandling:]): 33 (-[WKContentView _zoomToRevealFocusedElement]): 34 (-[WKContentView _selectionClipRect]): 35 (-[WKContentView gestureRecognizerShouldBegin:]): 36 (-[WKContentView textInteractionGesture:shouldBeginAtPoint:]): 37 38 In various places that consult nodeAtPositionIsFocusedElement, instead check that the position information's 39 hit-tested element context is the same as the focused element, via FocusedElementInformation. 40 41 (-[WKContentView _didCommitLoadForMainFrame]): 42 43 Nuke the cached position information data upon navigation; without this tweak, we will fail when running several 44 iOS layout tests back-to-back, that tap in exactly the same location. 45 46 (rectToRevealWhenZoomingToFocusedElement): 47 (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]): 48 (-[WKContentView _elementDidBlur]): 49 (-[WKContentView rectForFocusedFormControlView:]): 50 (-[WKContentView _didChangeFocusedElementRect:toRect:]): Deleted. 51 52 Remove code to invalidate cached position information when changing the focused element rect. 53 54 * UIProcess/ios/forms/WKFormPopover.mm: 55 (-[WKRotatingPopover presentPopoverAnimated:]): 56 * WebProcess/WebPage/ios/WebPageIOS.mm: 57 (WebKit::WebPage::positionInformation): 58 (WebKit::WebPage::getFocusedElementInformation): 59 1 60 2019-10-28 Adrian Perez de Castro <aperez@igalia.com> 2 61 -
trunk/Source/WebKit/Shared/FocusedElementInformation.cpp
r250345 r251693 64 64 void FocusedElementInformation::encode(IPC::Encoder& encoder) const 65 65 { 66 encoder << elementRect; 66 encoder << interactionRect; 67 encoder << elementContext; 67 68 encoder << lastInteractionLocation; 68 69 encoder << minimumScaleFactor; … … 114 115 bool FocusedElementInformation::decode(IPC::Decoder& decoder, FocusedElementInformation& result) 115 116 { 116 if (!decoder.decode(result.elementRect)) 117 if (!decoder.decode(result.interactionRect)) 118 return false; 119 120 if (!decoder.decode(result.elementContext)) 117 121 return false; 118 122 -
trunk/Source/WebKit/Shared/FocusedElementInformation.h
r250345 r251693 30 30 #include <WebCore/Autofill.h> 31 31 #include <WebCore/Color.h> 32 #include <WebCore/ElementContext.h> 32 33 #include <WebCore/GraphicsLayer.h> 33 34 #include <WebCore/InputMode.h> … … 97 98 98 99 struct FocusedElementInformation { 99 WebCore::IntRect elementRect; 100 WebCore::IntRect interactionRect; 101 WebCore::ElementContext elementContext; 100 102 WebCore::IntPoint lastInteractionLocation; 101 103 double minimumScaleFactor { -INFINITY }; -
trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.h
r251388 r251693 52 52 53 53 bool canBeValid { true }; 54 bool nodeAtPositionIsFocusedElement { false };55 54 bool nodeAtPositionHasDoubleClickHandler { false }; 56 55 #if ENABLE(DATA_INTERACTION) -
trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm
r250876 r251693 45 45 46 46 encoder << canBeValid; 47 encoder << nodeAtPositionIsFocusedElement;48 47 encoder << nodeAtPositionHasDoubleClickHandler; 49 48 #if ENABLE(DATA_INTERACTION) … … 97 96 return false; 98 97 99 if (!decoder.decode(result.nodeAtPositionIsFocusedElement))100 return false;101 102 98 if (!decoder.decode(result.nodeAtPositionHasDoubleClickHandler)) 103 99 return false; -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r251665 r251693 1697 1697 return; 1698 1698 1699 if (hasFocusedElement(_focusedElementInformation) && _positionInformation. nodeAtPositionIsFocusedElement)1699 if (hasFocusedElement(_focusedElementInformation) && _positionInformation.elementContext == _focusedElementInformation.elementContext) 1700 1700 return; 1701 1701 … … 1872 1872 // In case user scaling is force enabled, do not use that scaling when zooming in with an input field. 1873 1873 // Zooming above the page's default scale factor should only happen when the user performs it. 1874 [self _zoomToFocusRect:_focusedElementInformation. elementRect1874 [self _zoomToFocusRect:_focusedElementInformation.interactionRect 1875 1875 selectionRect:_didAccessoryTabInitiateFocus ? WebCore::FloatRect() : rectToRevealWhenZoomingToFocusedElement(_focusedElementInformation, _page->editorState()) 1876 1876 insideFixed:_focusedElementInformation.insideFixedPosition … … 1923 1923 1924 1924 if (_page->waitingForPostLayoutEditorStateUpdateAfterFocusingElement()) 1925 return _focusedElementInformation. elementRect;1925 return _focusedElementInformation.interactionRect; 1926 1926 1927 1927 return _page->editorState().postLayoutData().focusedElementRect; … … 2269 2269 if (![self ensurePositionInformationIsUpToDate:WebKit::InteractionInformationRequest(WebCore::roundedIntPoint(point))]) 2270 2270 return NO; 2271 if (_positionInformation. nodeAtPositionIsFocusedElement)2271 if (_positionInformation.elementContext == _focusedElementInformation.elementContext) 2272 2272 return NO; 2273 2273 } … … 2315 2315 if (hasFocusedElement(_focusedElementInformation)) { 2316 2316 // Prevent the gesture if it is the same node. 2317 if (_positionInformation. nodeAtPositionIsFocusedElement)2317 if (_positionInformation.elementContext == _focusedElementInformation.elementContext) 2318 2318 return NO; 2319 2319 } else { … … 2450 2450 // If we're currently focusing an editable element, only allow the selection to move within that focused element. 2451 2451 if (self.isFocusingElement) 2452 return _positionInformation. nodeAtPositionIsFocusedElement;2452 return _positionInformation.elementContext == _focusedElementInformation.elementContext; 2453 2453 2454 2454 // If we're selecting something, don't activate highlight. … … 4151 4151 [self _hideContextMenuHintContainer]; 4152 4152 [_webView _didCommitLoadForMainFrame]; 4153 4154 _hasValidPositionInformation = NO; 4155 _positionInformation = { }; 4153 4156 } 4154 4157 … … 5402 5405 { 5403 5406 WebCore::IntRect elementInteractionRect; 5404 if (elementInfo. elementRect.contains(elementInfo.lastInteractionLocation))5407 if (elementInfo.interactionRect.contains(elementInfo.lastInteractionLocation)) 5405 5408 elementInteractionRect = { elementInfo.lastInteractionLocation, { 1, 1 } }; 5406 5409 … … 5424 5427 selectionBoundingRect = postLayoutData.caretRectAtStart; 5425 5428 5426 selectionBoundingRect.intersect(elementInfo. elementRect);5429 selectionBoundingRect.intersect(elementInfo.interactionRect); 5427 5430 return selectionBoundingRect; 5428 5431 } … … 5525 5528 // FIXME: We should remove this check when we manage to send ElementDidFocus from the WebProcess 5526 5529 // only when it is truly time to show the keyboard. 5527 if (_focusedElementInformation.elementType == information.elementType && _focusedElementInformation. elementRect == information.elementRect) {5530 if (_focusedElementInformation.elementType == information.elementType && _focusedElementInformation.interactionRect == information.interactionRect) { 5528 5531 if (_inputPeripheral) { 5529 5532 if (!self.isFirstResponder) … … 5557 5560 [inputDelegate _webView:_webView willStartInputSession:_formInputSession.get()]; 5558 5561 5559 auto previousElementRect = _isChangingFocus ? _focusedElementInformation.elementRect : WebCore::IntRect();5560 5562 BOOL isSelectable = mayContainSelectableText(information.elementType); 5561 5563 BOOL editableChanged = [self setIsEditable:isSelectable]; … … 5604 5606 5605 5607 [_webView didStartFormControlInteraction]; 5606 5607 [self _didChangeFocusedElementRect:previousElementRect toRect:_focusedElementInformation.elementRect];5608 5608 } 5609 5609 … … 5629 5629 5630 5630 BOOL editableChanged = [self setIsEditable:NO]; 5631 auto previousElementRect = _focusedElementInformation.elementRect;5632 5631 // FIXME: We should completely invalidate _focusedElementInformation here, instead of a subset of individual members. 5633 5632 _focusedElementInformation.elementType = WebKit::InputType::None; … … 5663 5662 } 5664 5663 5665 if (!_isChangingFocus) {5664 if (!_isChangingFocus) 5666 5665 _didAccessoryTabInitiateFocus = NO; 5667 [self _didChangeFocusedElementRect:previousElementRect toRect:WebCore::IntRect()];5668 }5669 }5670 5671 - (void)_didChangeFocusedElementRect:(const WebCore::IntRect&)previousRect toRect:(const WebCore::IntRect&)newRect5672 {5673 if (previousRect == newRect)5674 return;5675 5676 if (newRect.isEmpty() && !_positionInformation.nodeAtPositionIsFocusedElement)5677 return;5678 5679 // If the focused element rect changed, the cached position information's nodeAtPositionIsFocusedElement may be stale.5680 _hasValidPositionInformation = NO;5681 _positionInformation = { };5682 5666 } 5683 5667 … … 5990 5974 - (CGRect)rectForFocusedFormControlView:(WKFocusedFormControlView *)view 5991 5975 { 5992 return [self convertRect:_focusedElementInformation. elementRect toView:view];5976 return [self convertRect:_focusedElementInformation.interactionRect toView:view]; 5993 5977 } 5994 5978 -
trunk/Source/WebKit/UIProcess/ios/forms/WKFormPopover.mm
r247837 r251693 143 143 animated:animated]; 144 144 } else { 145 CGRect boundingBoxOfDOMNode = _view.focusedElementInformation. elementRect;145 CGRect boundingBoxOfDOMNode = _view.focusedElementInformation.interactionRect; 146 146 [_popoverController presentPopoverFromRect:CGRectIntegral(boundingBoxOfDOMNode) 147 147 inView:_view -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r251445 r251693 2781 2781 auto* nodeRespondingToClickEvents = m_page->mainFrame().nodeRespondingToClickEvents(request.point, adjustedPoint); 2782 2782 2783 info.nodeAtPositionIsFocusedElement = nodeRespondingToClickEvents == m_focusedElement;2784 2783 info.adjustedPointForNodeRespondingToClickEvents = adjustedPoint; 2785 2784 info.nodeAtPositionHasDoubleClickHandler = m_page->mainFrame().nodeRespondingToDoubleClickEvent(request.point, adjustedPoint); … … 2906 2905 2907 2906 information.lastInteractionLocation = m_lastInteractionLocation; 2907 if (auto elementContext = contextForElement(*m_focusedElement)) 2908 information.elementContext = WTFMove(*elementContext); 2908 2909 2909 2910 if (auto* renderer = m_focusedElement->renderer()) { 2910 information. elementRect = rootViewInteractionBoundsForElement(*m_focusedElement);2911 information.interactionRect = rootViewInteractionBoundsForElement(*m_focusedElement); 2911 2912 information.nodeFontSize = renderer->style().fontDescription().computedSize(); 2912 2913 … … 2916 2917 information.isRTL = renderer->style().direction() == TextDirection::RTL; 2917 2918 } else 2918 information. elementRect = IntRect();2919 information.interactionRect = { }; 2919 2920 2920 2921 if (is<HTMLElement>(m_focusedElement))
Note: See TracChangeset
for help on using the changeset viewer.