Title: [187117] trunk/Source/WebKit2
Revision
187117
Author
timothy_hor...@apple.com
Date
2015-07-21 12:58:02 -0700 (Tue, 21 Jul 2015)

Log Message

[iOS] Avoid using a TextIndicator if there are non-text things to indicate
https://bugs.webkit.org/show_bug.cgi?id=147152
<rdar://problem/21921061>

Reviewed by Beth Dakin.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView willPresentPreviewViewController:forPosition:inSourceView:]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::shouldUseTextIndicatorForLink):
(WebKit::WebPage::getPositionInformation):
Fall back to a rectangular area instead of a TextIndicator if there are any
non-inline elements inside the link.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (187116 => 187117)


--- trunk/Source/WebKit2/ChangeLog	2015-07-21 19:56:24 UTC (rev 187116)
+++ trunk/Source/WebKit2/ChangeLog	2015-07-21 19:58:02 UTC (rev 187117)
@@ -1,3 +1,19 @@
+2015-07-21  Tim Horton  <timothy_hor...@apple.com>
+
+        [iOS] Avoid using a TextIndicator if there are non-text things to indicate
+        https://bugs.webkit.org/show_bug.cgi?id=147152
+        <rdar://problem/21921061>
+
+        Reviewed by Beth Dakin.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView willPresentPreviewViewController:forPosition:inSourceView:]):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::shouldUseTextIndicatorForLink):
+        (WebKit::WebPage::getPositionInformation):
+        Fall back to a rectangular area instead of a TextIndicator if there are any
+        non-inline elements inside the link.
+
 2015-07-21  Andreas Kling  <akl...@apple.com>
 
         API::Session should clean up its storage in the network process when destroyed.

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (187116 => 187117)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-07-21 19:56:24 UTC (rev 187116)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-07-21 19:58:02 UTC (rev 187117)
@@ -3331,9 +3331,14 @@
 
     [_previewIndicatorView removeFromSuperview];
 
+    float deviceScaleFactor = _page->deviceScaleFactor();
+
     RefPtr<Image> image = _positionInformation.linkIndicator.contentImage;
     if (!image) {
-        [[viewController presentationController] setSourceRect:_positionInformation.bounds];
+        IntRect sourceRect = _positionInformation.bounds;
+        const float marginInPoints = 4;
+        sourceRect.inflate(marginInPoints * deviceScaleFactor);
+        [[viewController presentationController] setSourceRect:sourceRect];
         [[viewController presentationController] setSourceView:self];
         return;
     }
@@ -3341,7 +3346,6 @@
     RetainPtr<UIImage> indicatorImage = adoptNS([[UIImage alloc] initWithCGImage:image->getCGImageRef()]);
     _previewIndicatorView = adoptNS([[UIImageView alloc] initWithImage:indicatorImage.get()]);
 
-    float deviceScaleFactor = _page->deviceScaleFactor();
     const float cornerRadiusInPoints = 5;
     Path path = PathUtilities::pathWithShrinkWrappedRects(_positionInformation.linkIndicator.textRectsInBoundingRectCoordinates, cornerRadiusInPoints * deviceScaleFactor);
     RetainPtr<CAShapeLayer> maskLayer = adoptNS([[CAShapeLayer alloc] init]);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (187116 => 187117)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2015-07-21 19:56:24 UTC (rev 187116)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2015-07-21 19:58:02 UTC (rev 187117)
@@ -63,6 +63,7 @@
 #import <WebCore/GeometryUtilities.h>
 #import <WebCore/HTMLElementTypeHelpers.h>
 #import <WebCore/HTMLFormElement.h>
+#import <WebCore/HTMLImageElement.h>
 #import <WebCore/HTMLInputElement.h>
 #import <WebCore/HTMLOptGroupElement.h>
 #import <WebCore/HTMLOptionElement.h>
@@ -2143,6 +2144,19 @@
     return nullptr;
 }
 
+static bool shouldUseTextIndicatorForLink(Element& element)
+{
+    if (element.renderer() && !element.renderer()->isInline())
+        return false;
+
+    for (auto& child : descendantsOfType<Element>(element)) {
+        if (child.renderer() && !child.renderer()->isInline())
+            return false;
+    }
+
+    return true;
+}
+
 void WebPage::getPositionInformation(const IntPoint& point, InteractionInformationAtPosition& info)
 {
     FloatPoint adjustedPoint;
@@ -2194,13 +2208,15 @@
                     if (RefPtr<WebImage> snapshot = snapshotNode(*element, SnapshotOptionsShareable, 600 * 1024))
                         info.image = snapshot->bitmap();
 
-                    RefPtr<Range> linkRange = rangeOfContents(*linkElement);
-                    if (linkRange) {
-                        float deviceScaleFactor = corePage()->deviceScaleFactor();
-                        const float marginInPoints = 4;
-                        RefPtr<TextIndicator> textIndicator = TextIndicator::createWithRange(*linkRange, TextIndicatorPresentationTransition::None, marginInPoints * deviceScaleFactor);
-                        if (textIndicator)
-                            info.linkIndicator = textIndicator->data();
+                    if (shouldUseTextIndicatorForLink(*linkElement)) {
+                        RefPtr<Range> linkRange = rangeOfContents(*linkElement);
+                        if (linkRange) {
+                            float deviceScaleFactor = corePage()->deviceScaleFactor();
+                            const float marginInPoints = 4;
+                            RefPtr<TextIndicator> textIndicator = TextIndicator::createWithRange(*linkRange, TextIndicatorPresentationTransition::None, marginInPoints * deviceScaleFactor);
+                            if (textIndicator)
+                                info.linkIndicator = textIndicator->data();
+                        }
                     }
                 } else if (element->renderer() && element->renderer()->isRenderImage()) {
                     auto& renderImage = downcast<RenderImage>(*(element->renderer()));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to