- Revision
- 246697
- Author
- timothy_hor...@apple.com
- Date
- 2019-06-21 14:22:51 -0700 (Fri, 21 Jun 2019)
Log Message
WebKit context menu highlights include extra padding
https://bugs.webkit.org/show_bug.cgi?id=199080
<rdar://problem/51140126>
Reviewed by Dean Jackson.
* Shared/ios/InteractionInformationRequest.cpp:
(WebKit::InteractionInformationRequest::encode const):
(WebKit::InteractionInformationRequest::decode):
(WebKit::InteractionInformationRequest::isValidForRequest):
(WebKit::InteractionInformationRequest::isApproximatelyValidForRequest):
* Shared/ios/InteractionInformationRequest.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView gestureRecognizerShouldBegin:]):
(-[WKContentView positionInformationForActionSheetAssistant:]):
(-[WKContentView updatePositionInformationForActionSheetAssistant:]):
(-[WKContentView _contextMenuInteraction:configurationForMenuAtLocation:completion:]):
(-[WKContentView _interactionShouldBeginFromPreviewItemController:forPosition:]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::linkIndicatorPositionInformation):
Disable the margin going forward, but leave it if we're using the legacy
API, because there is no way to add margin at the platform level with
the legacy API.
In the future we should always have no margin in our indicator, and just
apply it in whatever consumes the indicator, so that there is no
disagreement between clients about the size of the margin.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (246696 => 246697)
--- trunk/Source/WebKit/ChangeLog 2019-06-21 21:02:41 UTC (rev 246696)
+++ trunk/Source/WebKit/ChangeLog 2019-06-21 21:22:51 UTC (rev 246697)
@@ -1,3 +1,33 @@
+2019-06-21 Tim Horton <timothy_hor...@apple.com>
+
+ WebKit context menu highlights include extra padding
+ https://bugs.webkit.org/show_bug.cgi?id=199080
+ <rdar://problem/51140126>
+
+ Reviewed by Dean Jackson.
+
+ * Shared/ios/InteractionInformationRequest.cpp:
+ (WebKit::InteractionInformationRequest::encode const):
+ (WebKit::InteractionInformationRequest::decode):
+ (WebKit::InteractionInformationRequest::isValidForRequest):
+ (WebKit::InteractionInformationRequest::isApproximatelyValidForRequest):
+ * Shared/ios/InteractionInformationRequest.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView gestureRecognizerShouldBegin:]):
+ (-[WKContentView positionInformationForActionSheetAssistant:]):
+ (-[WKContentView updatePositionInformationForActionSheetAssistant:]):
+ (-[WKContentView _contextMenuInteraction:configurationForMenuAtLocation:completion:]):
+ (-[WKContentView _interactionShouldBeginFromPreviewItemController:forPosition:]):
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::linkIndicatorPositionInformation):
+ Disable the margin going forward, but leave it if we're using the legacy
+ API, because there is no way to add margin at the platform level with
+ the legacy API.
+
+ In the future we should always have no margin in our indicator, and just
+ apply it in whatever consumes the indicator, so that there is no
+ disagreement between clients about the size of the margin.
+
2019-06-21 Youenn Fablet <you...@apple.com>
WebPageProxy should use the right path for sandbox extension
Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.cpp (246696 => 246697)
--- trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.cpp 2019-06-21 21:02:41 UTC (rev 246696)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.cpp 2019-06-21 21:22:51 UTC (rev 246697)
@@ -38,6 +38,7 @@
encoder << point;
encoder << includeSnapshot;
encoder << includeLinkIndicator;
+ encoder << linkIndicatorShouldHaveLegacyMargins;
encoder << readonly;
}
@@ -52,6 +53,9 @@
if (!decoder.decode(result.includeLinkIndicator))
return false;
+ if (!decoder.decode(result.linkIndicatorShouldHaveLegacyMargins))
+ return false;
+
if (!decoder.decode(result.readonly))
return false;
@@ -69,6 +73,9 @@
if (other.includeLinkIndicator && !includeLinkIndicator)
return false;
+ if (other.linkIndicatorShouldHaveLegacyMargins != linkIndicatorShouldHaveLegacyMargins)
+ return false;
+
if (!other.readonly && readonly)
return false;
@@ -85,6 +92,9 @@
if (!other.readonly && readonly)
return false;
+
+ if (other.linkIndicatorShouldHaveLegacyMargins != linkIndicatorShouldHaveLegacyMargins)
+ return false;
return (other.point - point).diagonalLengthSquared() <= 4;
}
Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h (246696 => 246697)
--- trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h 2019-06-21 21:02:41 UTC (rev 246696)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h 2019-06-21 21:22:51 UTC (rev 246697)
@@ -42,6 +42,8 @@
bool includeSnapshot { false };
bool includeLinkIndicator { false };
+ bool linkIndicatorShouldHaveLegacyMargins { false };
+
// FIXME: This readonly flag ought to be true by default, but there are a number of interactions (e.g. selection) that currently
// rely on the fact that interaction information requests additionally change the focused frame. We should explicitly turn the
// readonly bit off in these scenarios, and make sure that all other position information requests don't move focus around.
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (246696 => 246697)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2019-06-21 21:02:41 UTC (rev 246696)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2019-06-21 21:22:51 UTC (rev 246697)
@@ -524,6 +524,8 @@
- (void)_didStartProvisionalLoadForMainFrame;
+@property (nonatomic, readonly, getter=_shouldUseContextMenus) BOOL _shouldUseContextMenus;
+
@end
@interface WKContentView (WKTesting)
@@ -548,7 +550,6 @@
#else
@interface WKContentView (WKInteractionPreview) <UIPreviewItemDelegate>
#endif
-- (bool)_shouldUseContextMenus;
- (void)_registerPreview;
- (void)_unregisterPreview;
@end
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (246696 => 246697)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-06-21 21:02:41 UTC (rev 246696)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-06-21 21:22:51 UTC (rev 246697)
@@ -770,7 +770,7 @@
[_highlightLongPressGestureRecognizer setDelegate:self];
#if HAVE(LINK_PREVIEW)
- if (![self _shouldUseContextMenus]) {
+ if (!self._shouldUseContextMenus) {
[self addGestureRecognizer:_highlightLongPressGestureRecognizer.get()];
[self _createAndConfigureLongPressGestureRecognizer];
}
@@ -2066,6 +2066,7 @@
if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) {
request.includeSnapshot = true;
request.includeLinkIndicator = true;
+ request.linkIndicatorShouldHaveLegacyMargins = !self._shouldUseContextMenus;
}
[self requestAsynchronousPositionInformationUpdate:request];
@@ -6074,6 +6075,7 @@
WebKit::InteractionInformationRequest request(_positionInformation.request.point);
request.includeSnapshot = true;
request.includeLinkIndicator = assistant.needsLinkIndicator;
+ request.linkIndicatorShouldHaveLegacyMargins = !self._shouldUseContextMenus;
if (![self ensurePositionInformationIsUpToDate:request])
return WTF::nullopt;
@@ -6086,6 +6088,7 @@
WebKit::InteractionInformationRequest request(_positionInformation.request.point);
request.includeSnapshot = true;
request.includeLinkIndicator = assistant.needsLinkIndicator;
+ request.linkIndicatorShouldHaveLegacyMargins = !self._shouldUseContextMenus;
[self requestAsynchronousPositionInformationUpdate:request];
}
@@ -6204,6 +6207,14 @@
completion(nil, nil);
}
+- (BOOL)_shouldUseContextMenus
+{
+#if HAVE(LINK_PREVIEW) && USE(UICONTEXTMENU)
+ return linkedOnOrAfter(WebKit::SDKVersion::FirstThatHasUIContextMenuInteraction);
+#endif
+ return NO;
+}
+
#if ENABLE(DRAG_SUPPORT)
static BOOL shouldEnableDragInteractionForPolicy(_WKDragInteractionPolicy policy)
@@ -7382,7 +7393,7 @@
#if HAVE(LINK_PREVIEW)
if ([userInterfaceItem isEqualToString:@"linkPreviewPopoverContents"]) {
- if ([self _shouldUseContextMenus])
+ if (self._shouldUseContextMenus)
return @{ userInterfaceItem: @{ @"pageURL": WTF::userVisibleString(_positionInformation.url) } };
NSString *url = "" previewData][UIPreviewDataLink];
@@ -7427,14 +7438,6 @@
@implementation WKContentView (WKInteractionPreview)
-- (bool)_shouldUseContextMenus
-{
-#if USE(UICONTEXTMENU)
- return linkedOnOrAfter(WebKit::SDKVersion::FirstThatHasUIContextMenuInteraction);
-#endif
- return false;
-}
-
- (void)_registerPreview
{
if (!_webView.allowsLinkPreview)
@@ -7441,7 +7444,7 @@
return;
#if USE(UICONTEXTMENU)
- if ([self _shouldUseContextMenus]) {
+ if (self._shouldUseContextMenus) {
_contextMenuInteraction = adoptNS([[UIContextMenuInteraction alloc] initWithDelegate:self]);
_contextMenuHasRequestedLegacyData = NO;
[self addInteraction:_contextMenuInteraction.get()];
@@ -7460,9 +7463,6 @@
}
#endif
- if (!_webView.allowsLinkPreview)
- return;
-
_previewItemController = adoptNS([[UIPreviewItemController alloc] initWithView:self]);
[_previewItemController setDelegate:self];
_previewGestureRecognizer = _previewItemController.get().presentationGestureRecognizer;
@@ -7473,7 +7473,7 @@
- (void)_unregisterPreview
{
#if USE(UICONTEXTMENU)
- if ([self _shouldUseContextMenus]) {
+ if (self._shouldUseContextMenus) {
if (!_contextMenuInteraction)
return;
@@ -7712,6 +7712,7 @@
WebKit::InteractionInformationRequest request { WebCore::roundedIntPoint(position) };
request.includeSnapshot = true;
request.includeLinkIndicator = true;
+ request.linkIndicatorShouldHaveLegacyMargins = !self._shouldUseContextMenus;
[self doAfterPositionInformationUpdate:[weakSelf = WeakObjCPtr<WKContentView>(self), completion = makeBlockPtr(completion)] (WebKit::InteractionInformationAtPosition) {
auto strongSelf = weakSelf.get();
@@ -8067,6 +8068,7 @@
WebKit::InteractionInformationRequest request(WebCore::roundedIntPoint(position));
request.includeSnapshot = true;
request.includeLinkIndicator = true;
+ request.linkIndicatorShouldHaveLegacyMargins = !self._shouldUseContextMenus;
if (![self ensurePositionInformationIsUpToDate:request])
return NO;
if (!_positionInformation.isLink && !_positionInformation.isImage && !_positionInformation.isAttachment)
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (246696 => 246697)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2019-06-21 21:02:41 UTC (rev 246696)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2019-06-21 21:22:51 UTC (rev 246697)
@@ -2492,7 +2492,7 @@
auto linkRange = rangeOfContents(linkElement);
float deviceScaleFactor = page.corePage()->deviceScaleFactor();
- const float marginInPoints = 4;
+ const float marginInPoints = request.linkIndicatorShouldHaveLegacyMargins ? 4 : 0;
auto textIndicator = TextIndicator::createWithRange(linkRange.get(),
TextIndicatorOptionTightlyFitContent | TextIndicatorOptionRespectTextColor | TextIndicatorOptionPaintBackgrounds |