⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 187117 in webkit


Ignore:
Timestamp:
Jul 21, 2015, 12:58:02 PM (11 years ago)
Author:
timothy_horton@apple.com
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.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r187115 r187117  
     12015-07-21  Tim Horton  <timothy_horton@apple.com>
     2
     3        [iOS] Avoid using a TextIndicator if there are non-text things to indicate
     4        https://bugs.webkit.org/show_bug.cgi?id=147152
     5        <rdar://problem/21921061>
     6
     7        Reviewed by Beth Dakin.
     8
     9        * UIProcess/ios/WKContentViewInteraction.mm:
     10        (-[WKContentView willPresentPreviewViewController:forPosition:inSourceView:]):
     11        * WebProcess/WebPage/ios/WebPageIOS.mm:
     12        (WebKit::shouldUseTextIndicatorForLink):
     13        (WebKit::WebPage::getPositionInformation):
     14        Fall back to a rectangular area instead of a TextIndicator if there are any
     15        non-inline elements inside the link.
     16
    1172015-07-21  Andreas Kling  <akling@apple.com>
    218
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r186977 r187117  
    33323332    [_previewIndicatorView removeFromSuperview];
    33333333
     3334    float deviceScaleFactor = _page->deviceScaleFactor();
     3335
    33343336    RefPtr<Image> image = _positionInformation.linkIndicator.contentImage;
    33353337    if (!image) {
    3336         [[viewController presentationController] setSourceRect:_positionInformation.bounds];
     3338        IntRect sourceRect = _positionInformation.bounds;
     3339        const float marginInPoints = 4;
     3340        sourceRect.inflate(marginInPoints * deviceScaleFactor);
     3341        [[viewController presentationController] setSourceRect:sourceRect];
    33373342        [[viewController presentationController] setSourceView:self];
    33383343        return;
     
    33423347    _previewIndicatorView = adoptNS([[UIImageView alloc] initWithImage:indicatorImage.get()]);
    33433348
    3344     float deviceScaleFactor = _page->deviceScaleFactor();
    33453349    const float cornerRadiusInPoints = 5;
    33463350    Path path = PathUtilities::pathWithShrinkWrappedRects(_positionInformation.linkIndicator.textRectsInBoundingRectCoordinates, cornerRadiusInPoints * deviceScaleFactor);
  • trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

    r186978 r187117  
    6464#import <WebCore/HTMLElementTypeHelpers.h>
    6565#import <WebCore/HTMLFormElement.h>
     66#import <WebCore/HTMLImageElement.h>
    6667#import <WebCore/HTMLInputElement.h>
    6768#import <WebCore/HTMLOptGroupElement.h>
     
    21442145}
    21452146
     2147static bool shouldUseTextIndicatorForLink(Element& element)
     2148{
     2149    if (element.renderer() && !element.renderer()->isInline())
     2150        return false;
     2151
     2152    for (auto& child : descendantsOfType<Element>(element)) {
     2153        if (child.renderer() && !child.renderer()->isInline())
     2154            return false;
     2155    }
     2156
     2157    return true;
     2158}
     2159
    21462160void WebPage::getPositionInformation(const IntPoint& point, InteractionInformationAtPosition& info)
    21472161{
     
    21952209                        info.image = snapshot->bitmap();
    21962210
    2197                     RefPtr<Range> linkRange = rangeOfContents(*linkElement);
    2198                     if (linkRange) {
    2199                         float deviceScaleFactor = corePage()->deviceScaleFactor();
    2200                         const float marginInPoints = 4;
    2201                         RefPtr<TextIndicator> textIndicator = TextIndicator::createWithRange(*linkRange, TextIndicatorPresentationTransition::None, marginInPoints * deviceScaleFactor);
    2202                         if (textIndicator)
    2203                             info.linkIndicator = textIndicator->data();
     2211                    if (shouldUseTextIndicatorForLink(*linkElement)) {
     2212                        RefPtr<Range> linkRange = rangeOfContents(*linkElement);
     2213                        if (linkRange) {
     2214                            float deviceScaleFactor = corePage()->deviceScaleFactor();
     2215                            const float marginInPoints = 4;
     2216                            RefPtr<TextIndicator> textIndicator = TextIndicator::createWithRange(*linkRange, TextIndicatorPresentationTransition::None, marginInPoints * deviceScaleFactor);
     2217                            if (textIndicator)
     2218                                info.linkIndicator = textIndicator->data();
     2219                        }
    22042220                    }
    22052221                } else if (element->renderer() && element->renderer()->isRenderImage()) {
Note: See TracChangeset for help on using the changeset viewer.