Changeset 278633 in webkit
- Timestamp:
- Jun 8, 2021, 4:30:21 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/events/ios/non-meaningful-click-when-tapping-document-expected.txt (added)
-
LayoutTests/fast/events/ios/non-meaningful-click-when-tapping-document.html (added)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/WebPage.h (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r278632 r278633 1 2021-06-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Safari tab pill should toggle visibility when tapping on article text on adventure.com 4 https://bugs.webkit.org/show_bug.cgi?id=226775 5 rdar://78826820 6 7 Reviewed by Tim Horton and Devin Rousso. 8 9 * fast/events/ios/non-meaningful-click-when-tapping-document-expected.txt: Added. 10 * fast/events/ios/non-meaningful-click-when-tapping-document.html: Added. 11 1 12 2021-06-08 Diego Pino Garcia <dpino@igalia.com> 2 13 -
trunk/Source/WebKit/ChangeLog
r278630 r278633 1 2021-06-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Safari tab pill should toggle visibility when tapping on article text on adventure.com 4 https://bugs.webkit.org/show_bug.cgi?id=226775 5 rdar://78826820 6 7 Reviewed by Tim Horton and Devin Rousso. 8 9 Adjust the meaningful click heuristic to account for click event listeners added to the document node. See below 10 for more details. 11 12 Test: fast/events/ios/non-meaningful-click-when-tapping-document.html 13 14 * WebProcess/WebPage/WebPage.h: 15 * WebProcess/WebPage/ios/WebPageIOS.mm: 16 (WebKit::WebPage::getPlatformEditorState const): 17 (WebKit::isProbablyMeaningfulClick): 18 19 Remove a check for whether or not the clicked node is an Element; this existed because the call to 20 `rootViewBoundsForElement` below takes an Element rather than just a Node; however, this method doesn't do 21 anything that requires an Element instead of a Node, so we can just remove the check and refactor these static 22 methods to accept Nodes. This allows us to bail early if the clicked node is *either* the body or the document 23 node, instead of just the body. 24 25 (WebKit::WebPage::insertDroppedImagePlaceholders): 26 (WebKit::elementBoundsInFrame): 27 (WebKit::WebPage::rootViewBounds): 28 (WebKit::WebPage::absoluteInteractionBounds): 29 (WebKit::WebPage::rootViewInteractionBounds): 30 31 Drive-by refactoring: drop the `-ForElement` suffixes on these helper methods, and additionally make them accept 32 a Node instead of requiring an Element. This allows us to remove the `is<Element>()` check from the meaningful 33 click heuristic above. 34 35 Also deploy RefPtr in a few more places. 36 37 (WebKit::WebPage::dispatchSyntheticMouseEventsForSelectionGesture): 38 (WebKit::WebPage::focusedElementInformation): 39 (WebKit::WebPage::rootViewBoundsForElement): Deleted. 40 (WebKit::WebPage::absoluteInteractionBoundsForElement): Deleted. 41 (WebKit::WebPage::rootViewInteractionBoundsForElement): Deleted. 42 1 43 2021-06-08 Devin Rousso <drousso@apple.com> 2 44 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r278575 r278633 1357 1357 #if PLATFORM(IOS_FAMILY) 1358 1358 // This excludes layout overflow, includes borders. 1359 static WebCore::IntRect rootViewBounds ForElement(const WebCore::Element&);1359 static WebCore::IntRect rootViewBounds(const WebCore::Node&); 1360 1360 // These include layout overflow for overflow:visible elements, but exclude borders. 1361 static WebCore::IntRect absoluteInteractionBounds ForElement(const WebCore::Element&);1362 static WebCore::IntRect rootViewInteractionBounds ForElement(const WebCore::Element&);1361 static WebCore::IntRect absoluteInteractionBounds(const WebCore::Node&); 1362 static WebCore::IntRect rootViewInteractionBounds(const WebCore::Node&); 1363 1363 1364 1364 InteractionInformationAtPosition positionInformation(const InteractionInformationRequest&); -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r278542 r278633 345 345 346 346 if (auto editableRootOrFormControl = makeRefPtr(enclosingTextFormControl(selection.start()) ?: selection.rootEditableElement())) { 347 postLayoutData.selectionClipRect = rootViewInteractionBounds ForElement(*editableRootOrFormControl);347 postLayoutData.selectionClipRect = rootViewInteractionBounds(*editableRootOrFormControl); 348 348 postLayoutData.editableRootIsTransparentOrFullyClipped = result.isContentEditable && isTransparentOrFullyClipped(*editableRootOrFormControl); 349 349 } … … 840 840 { 841 841 auto frame = makeRefPtr(clickNode.document().frame()); 842 if (! is<Element>(clickNode) || !clickNode.isConnected() || !frame)842 if (!frame || !clickNode.isConnected()) 843 843 return true; 844 844 845 if (is<HTMLBodyElement>(clickNode) )845 if (is<HTMLBodyElement>(clickNode) || is<Document>(clickNode) || clickNode.document().documentElement() == &clickNode) 846 846 return false; 847 847 848 848 if (auto view = makeRefPtr(frame->mainFrame().view())) { 849 auto elementBounds = WebPage::rootView BoundsForElement(downcast<Element>(clickNode));849 auto elementBounds = WebPage::rootViewInteractionBounds(clickNode); 850 850 auto unobscuredRect = view->unobscuredContentRect(); 851 851 if (elementBounds.width() >= unobscuredRect.width() / 2 && elementBounds.height() >= unobscuredRect.height() / 2) … … 1006 1006 m_page->dragController().insertDroppedImagePlaceholdersAtCaret(imageSizes); 1007 1007 auto placeholderRects = m_page->dragController().droppedImagePlaceholders().map([&] (auto& element) { 1008 return rootViewBounds ForElement(element);1008 return rootViewBounds(element); 1009 1009 }); 1010 1010 … … 1361 1361 1362 1362 if (focusedElement.hasTagName(HTMLNames::textareaTag) || focusedElement.hasTagName(HTMLNames::inputTag) || focusedElement.hasTagName(HTMLNames::selectTag)) 1363 return WebPage::absoluteInteractionBounds ForElement(focusedElement);1363 return WebPage::absoluteInteractionBounds(focusedElement); 1364 1364 1365 1365 if (auto* rootEditableElement = focusedElement.rootEditableElement()) 1366 return WebPage::absoluteInteractionBounds ForElement(*rootEditableElement);1366 return WebPage::absoluteInteractionBounds(*rootEditableElement); 1367 1367 1368 1368 return { }; … … 1679 1679 } 1680 1680 1681 IntRect WebPage::rootViewBounds ForElement(const Element& element)1682 { 1683 auto * frame = element.document().frame();1681 IntRect WebPage::rootViewBounds(const Node& node) 1682 { 1683 auto frame = makeRefPtr(node.document().frame()); 1684 1684 if (!frame) 1685 1685 return { }; 1686 1686 1687 auto * view = frame->view();1687 auto view = makeRefPtr(frame->view()); 1688 1688 if (!view) 1689 1689 return { }; 1690 1690 1691 auto* renderer = element.renderer();1691 auto* renderer = node.renderer(); 1692 1692 if (!renderer) 1693 1693 return { }; … … 1696 1696 } 1697 1697 1698 IntRect WebPage::absoluteInteractionBounds ForElement(const Element& element)1699 { 1700 auto * frame = element.document().frame();1698 IntRect WebPage::absoluteInteractionBounds(const Node& node) 1699 { 1700 auto frame = makeRefPtr(node.document().frame()); 1701 1701 if (!frame) 1702 1702 return { }; 1703 1703 1704 auto * view = frame->view();1704 auto view = makeRefPtr(frame->view()); 1705 1705 if (!view) 1706 1706 return { }; 1707 1707 1708 auto* renderer = element.renderer();1708 auto* renderer = node.renderer(); 1709 1709 if (!renderer) 1710 1710 return { }; … … 1731 1731 } 1732 1732 1733 IntRect WebPage::rootViewInteractionBounds ForElement(const Element& element)1734 { 1735 auto * frame = element.document().frame();1733 IntRect WebPage::rootViewInteractionBounds(const Node& node) 1734 { 1735 auto frame = makeRefPtr(node.document().frame()); 1736 1736 if (!frame) 1737 1737 return { }; 1738 1738 1739 auto * view = frame->view();1739 auto view = makeRefPtr(frame->view()); 1740 1740 if (!view) 1741 1741 return { }; 1742 1742 1743 return view->contentsToRootView(absoluteInteractionBounds ForElement(element));1743 return view->contentsToRootView(absoluteInteractionBounds(node)); 1744 1744 } 1745 1745 … … 1758 1758 IntRect focusedElementRect; 1759 1759 if (m_focusedElement) 1760 focusedElementRect = rootViewInteractionBounds ForElement(*m_focusedElement);1760 focusedElementRect = rootViewInteractionBounds(*m_focusedElement); 1761 1761 1762 1762 if (focusedElementRect.isEmpty()) … … 3243 3243 3244 3244 if (auto* renderer = focusedElement->renderer()) { 3245 information.interactionRect = rootViewInteractionBounds ForElement(*focusedElement);3245 information.interactionRect = rootViewInteractionBounds(*focusedElement); 3246 3246 information.nodeFontSize = renderer->style().fontDescription().computedSize(); 3247 3247 … … 3270 3270 information.allowsUserScalingIgnoringAlwaysScalable = m_viewportConfiguration.allowsUserScalingIgnoringAlwaysScalable(); 3271 3271 if (auto* nextElement = nextAssistableElement(focusedElement.get(), *m_page, true)) { 3272 information.nextNodeRect = rootViewBounds ForElement(*nextElement);3272 information.nextNodeRect = rootViewBounds(*nextElement); 3273 3273 information.hasNextNode = true; 3274 3274 } 3275 3275 if (auto* previousElement = nextAssistableElement(focusedElement.get(), *m_page, false)) { 3276 information.previousNodeRect = rootViewBounds ForElement(*previousElement);3276 information.previousNodeRect = rootViewBounds(*previousElement); 3277 3277 information.hasPreviousNode = true; 3278 3278 }
Note:
See TracChangeset
for help on using the changeset viewer.