Title: [187299] branches/safari-601.1-branch/Source/WebKit2

Diff

Modified: branches/safari-601.1-branch/Source/WebKit2/ChangeLog (187298 => 187299)


--- branches/safari-601.1-branch/Source/WebKit2/ChangeLog	2015-07-24 06:27:40 UTC (rev 187298)
+++ branches/safari-601.1-branch/Source/WebKit2/ChangeLog	2015-07-24 06:29:28 UTC (rev 187299)
@@ -1,5 +1,25 @@
 2015-07-23  Lucas Forschler  <[email protected]>
 
+        Merge r187117
+
+    2015-07-21  Tim Horton  <[email protected]>
+
+            [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-23  Lucas Forschler  <[email protected]>
+
         Merge r187115
 
     2015-07-21  Andreas Kling  <[email protected]>

Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (187298 => 187299)


--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-07-24 06:27:40 UTC (rev 187298)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-07-24 06:29:28 UTC (rev 187299)
@@ -3321,9 +3321,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;
     }
@@ -3331,7 +3336,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: branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (187298 => 187299)


--- branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2015-07-24 06:27:40 UTC (rev 187298)
+++ branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2015-07-24 06:29:28 UTC (rev 187299)
@@ -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>
@@ -2106,6 +2107,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;
@@ -2157,13 +2171,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
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to