Changeset 192037 in webkit
- Timestamp:
- Nov 4, 2015, 2:34:01 PM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
Shared/InteractionInformationAtPosition.cpp (modified) (2 diffs)
-
Shared/InteractionInformationAtPosition.h (modified) (1 diff)
-
UIProcess/ios/WKContentViewInteraction.mm (modified) (5 diffs)
-
WebProcess/WebPage/ios/WebPageIOS.mm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r192036 r192037 1 2015-11-04 Beth Dakin <bdakin@apple.com> 2 3 Link preview doesn't work on XHTML pages with Content-Type header as 4 `application/xhtml+xml` 5 https://bugs.webkit.org/show_bug.cgi?id=150740 6 -and corresponding- 7 rdar://problem/23063585 8 9 Reviewed by Darin Adler. 10 11 My original fix for this bug was incorrect in the presence of non-HTML 12 elements that happen to have the same local name as HTML elements. Since it 13 seems silly to have all of this logic in the UI process to determine whether 14 to treat something as a link or an image, this patch fixes the bug by adding 15 isLink and isImage to InteractionInformationAtPosition in order to simplify 16 everything. The only remaining uses of clickableElementName just use it to 17 compare against isNull and isEmpty, so that can be a bool too. 18 19 Add isLink and isImage, and turn clickableElementName into isClickableElement 20 * Shared/InteractionInformationAtPosition.cpp: 21 (WebKit::InteractionInformationAtPosition::encode): 22 (WebKit::InteractionInformationAtPosition::decode): 23 * Shared/InteractionInformationAtPosition.h: 24 25 Use the new isLink, isImage, and isClickableElement 26 * UIProcess/ios/WKContentViewInteraction.mm: 27 (-[WKContentView _actionForLongPress]): 28 (-[WKContentView gestureRecognizerShouldBegin:]): 29 (-[WKContentView _highlightLongPressRecognized:]): 30 (-[WKContentView _interactionShouldBeginFromPreviewItemController:forPosition:]): 31 (-[WKContentView _dataForPreviewItemController:atPosition:type:]): 32 33 Set everything correctly. 34 * WebProcess/WebPage/ios/WebPageIOS.mm: 35 (WebKit::WebPage::getPositionInformation): 36 1 37 2015-11-04 Wenson Hsieh <wenson_hsieh@apple.com> 2 38 -
trunk/Source/WebKit2/Shared/InteractionInformationAtPosition.cpp
r187173 r192037 40 40 encoder << isNearMarkedText; 41 41 encoder << touchCalloutEnabled; 42 encoder << isLink; 43 encoder << isImage; 42 44 encoder << isAnimatedImage; 43 encoder << clickableElementName;45 encoder << isClickableElement; 44 46 encoder << url; 45 47 encoder << imageURL; … … 71 73 return false; 72 74 75 if (!decoder.decode(result.isLink)) 76 return false; 77 78 if (!decoder.decode(result.isImage)) 79 return false; 80 73 81 if (!decoder.decode(result.isAnimatedImage)) 74 82 return false; 75 83 76 if (!decoder.decode(result. clickableElementName))84 if (!decoder.decode(result.isClickableElement)) 77 85 return false; 78 86 -
trunk/Source/WebKit2/Shared/InteractionInformationAtPosition.h
r187173 r192037 44 44 bool isNearMarkedText { false }; 45 45 bool touchCalloutEnabled { true }; 46 bool isLink { false }; 47 bool isImage { false }; 46 48 bool isAnimatedImage { false }; 47 String clickableElementName;49 bool isClickableElement { false }; 48 50 String url; 49 51 String imageURL; -
trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
r192036 r192037 1050 1050 return nil; 1051 1051 1052 if ( equalIgnoringCase(_positionInformation.clickableElementName, "IMG"))1052 if (_positionInformation.isImage) 1053 1053 return @selector(_showImageSheet); 1054 1054 1055 if ( equalIgnoringCase(_positionInformation.clickableElementName, "A")) {1055 if (_positionInformation.isLink) { 1056 1056 NSURL *targetURL = [NSURL URLWithString:_positionInformation.url]; 1057 1057 if ([[getDDDetectionControllerClass() tapAndHoldSchemes] containsObject:[targetURL scheme]]) … … 1095 1095 // Prevent the gesture if there is no node. 1096 1096 // Allow the gesture if it is a node that wants highlight or if there is an action for it. 1097 if ( _positionInformation.clickableElementName.isNull())1097 if (!_positionInformation.isClickableElement) 1098 1098 return NO; 1099 1099 return [self _actionForLongPress] != nil; … … 1209 1209 break; 1210 1210 case UIGestureRecognizerStateEnded: 1211 if (_highlightLongPressCanClick && !_positionInformation.clickableElementName.isEmpty()) {1211 if (_highlightLongPressCanClick && _positionInformation.isClickableElement) { 1212 1212 [self _attemptClickAtLocation:[gestureRecognizer startPoint]]; 1213 1213 [self _finishInteraction]; … … 3435 3435 3436 3436 [self ensurePositionInformationIsUpToDate:position]; 3437 if ( equalIgnoringCase(_positionInformation.clickableElementName, "A") && equalIgnoringCase(_positionInformation.clickableElementName, "IMG"))3437 if (!_positionInformation.isLink && !_positionInformation.isImage) 3438 3438 return NO; 3439 3439 3440 3440 String absoluteLinkURL = _positionInformation.url; 3441 if ( equalIgnoringCase(_positionInformation.clickableElementName, "A")) {3441 if (_positionInformation.isLink) { 3442 3442 if (absoluteLinkURL.isEmpty()) 3443 3443 return NO; … … 3458 3458 id <WKUIDelegatePrivate> uiDelegate = static_cast<id <WKUIDelegatePrivate>>([_webView UIDelegate]); 3459 3459 BOOL supportsImagePreview = [uiDelegate respondsToSelector:@selector(_webView:commitPreviewedImageWithURL:)]; 3460 BOOL canShowImagePreview = equalIgnoringCase(_positionInformation.clickableElementName, "IMG")&& supportsImagePreview;3461 BOOL canShowLinkPreview = equalIgnoringCase(_positionInformation.clickableElementName, "A")|| canShowImagePreview;3460 BOOL canShowImagePreview = _positionInformation.isImage && supportsImagePreview; 3461 BOOL canShowLinkPreview = _positionInformation.isLink || canShowImagePreview; 3462 3462 BOOL useImageURLForLink = NO; 3463 3463 -
trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
r191904 r192037 2176 2176 bool elementIsLinkOrImage = false; 2177 2177 if (hitNode) { 2178 info.clickableElementName = hitNode->nodeName();2179 2180 2178 Element* element = is<Element>(*hitNode) ? downcast<Element>(hitNode) : nullptr; 2181 2179 if (element) { 2180 info.isClickableElement = true; 2182 2181 Element* linkElement = nullptr; 2183 2182 if (element->renderer() && element->renderer()->isRenderImage()) { … … 2191 2190 if (elementIsLinkOrImage) { 2192 2191 if (linkElement) { 2192 info.isLink = true; 2193 2193 2194 // Ensure that the image contains at most 600K pixels, so that it is not too big. 2194 2195 if (RefPtr<WebImage> snapshot = snapshotNode(*element, SnapshotOptionsShareable, 600 * 1024)) … … 2206 2207 } 2207 2208 } else if (element->renderer() && element->renderer()->isRenderImage()) { 2209 info.isImage = true; 2208 2210 auto& renderImage = downcast<RenderImage>(*(element->renderer())); 2209 2211 if (renderImage.cachedImage() && !renderImage.cachedImage()->errorOccurred()) {
Note:
See TracChangeset
for help on using the changeset viewer.