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

Changeset 246090 in webkit


Ignore:
Timestamp:
Jun 4, 2019, 5:23:59 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r246086.
https://bugs.webkit.org/show_bug.cgi?id=198549

Causing Internal build failures (Requested by ShawnRoberts on
#webkit).

Reverted changeset:

"Remove some unused selection code"
https://bugs.webkit.org/show_bug.cgi?id=198451
https://trac.webkit.org/changeset/246086

Location:
trunk/Source/WebKit
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r246088 r246090  
     12019-06-04  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r246086.
     4        https://bugs.webkit.org/show_bug.cgi?id=198549
     5
     6        Causing Internal build failures (Requested by ShawnRoberts on
     7        #webkit).
     8
     9        Reverted changeset:
     10
     11        "Remove some unused selection code"
     12        https://bugs.webkit.org/show_bug.cgi?id=198451
     13        https://trac.webkit.org/changeset/246086
     14
    1152019-06-04  Tim Horton  <timothy_horton@apple.com>
    216
  • trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h

    r246086 r246090  
    531531@end
    532532
     533@interface UIWebSelectionView : UIView
     534@end
     535
     536@interface UIWebSelectionAssistant : NSObject <UIGestureRecognizerDelegate>
     537@end
     538
    533539@protocol UISelectionInteractionAssistant
    534540- (void)showSelectionCommands;
     541@end
     542
     543@interface UIWebSelectionAssistant ()
     544- (BOOL)isSelectionGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer;
     545- (id)initWithView:(UIView *)view;
     546- (void)clearSelection;
     547- (void)didEndScrollingOrZoomingPage;
     548- (void)didEndScrollingOverflow;
     549- (void)resignedFirstResponder;
     550- (void)selectionChanged;
     551- (void)setGestureRecognizers;
     552- (void)willStartScrollingOrZoomingPage;
     553- (void)willStartScrollingOverflow;
     554#if !PLATFORM(IOSMAC)
     555@property (nonatomic, retain) UIWebSelectionView *selectionView;
     556#endif
     557@property (nonatomic, readonly) CGRect selectionFrame;
    535558@end
    536559
     
    564587    UIWKGestureTwoFingerRangedSelectGesture = 11,
    565588    UIWKGestureTapOnLinkWithGesture = 12,
     589    UIWKGestureMakeWebSelection = 13,
    566590    UIWKGesturePhraseBoundary = 14,
    567591};
    568592
    569 @interface UIWebSelectionAssistant : NSObject
    570 @end
    571 
    572593@interface UIWKSelectionAssistant : UIWebSelectionAssistant
    573594@end
    574595
    575596@interface UIWKSelectionAssistant ()
    576 - (id)initWithView:(UIView *)view;
     597- (BOOL)shouldHandleSingleTapAtPoint:(CGPoint)point;
     598- (void)selectionChangedWithGestureAt:(CGPoint)point withGesture:(UIWKGestureType)gestureType withState:(UIGestureRecognizerState)gestureState withFlags:(UIWKSelectionFlags)flags;
     599- (void)selectionChangedWithTouchAt:(CGPoint)point withSelectionTouch:(UIWKSelectionTouch)touch withFlags:(UIWKSelectionFlags)flags;
     600- (void)showDictionaryFor:(NSString *)selectedTerm fromRect:(CGRect)presentationRect;
    577601- (void)showShareSheetFor:(NSString *)selectedTerm fromRect:(CGRect)presentationRect;
     602- (void)showTextServiceFor:(NSString *)selectedTerm fromRect:(CGRect)presentationRect;
     603- (void)lookup:(NSString *)textWithContext withRange:(NSRange)range fromRect:(CGRect)presentationRect;
     604@property (nonatomic, readonly) UILongPressGestureRecognizer *selectionLongPressRecognizer;
    578605@end
    579606
  • trunk/Source/WebKit/Shared/ios/GestureTypes.h

    r246086 r246090  
    4343    TwoFingerRangedSelectGesture,
    4444    TapOnLinkWithGesture,
     45    MakeWebSelection,
    4546    PhraseBoundary
    4647};
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r246086 r246090  
    32793279    case UIWKGestureTapOnLinkWithGesture:
    32803280        return WebKit::GestureType::TapOnLinkWithGesture;
     3281    case UIWKGestureMakeWebSelection:
     3282        return WebKit::GestureType::MakeWebSelection;
    32813283    case UIWKGesturePhraseBoundary:
    32823284        return WebKit::GestureType::PhraseBoundary;
     
    33153317    case WebKit::GestureType::TapOnLinkWithGesture:
    33163318        return UIWKGestureTapOnLinkWithGesture;
     3319    case WebKit::GestureType::MakeWebSelection:
     3320        return UIWKGestureMakeWebSelection;
    33173321    case WebKit::GestureType::PhraseBoundary:
    33183322        return UIWKGesturePhraseBoundary;
  • trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm

    r246086 r246090  
    523523- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant shareElementWithURL:(NSURL *)url rect:(CGRect)boundingRect
    524524{
    525     // FIXME: We should use WKShareSheet instead of UIWKSelectionAssistant for this.
    526525    auto selectionAssistant = adoptNS([[UIWKSelectionAssistant alloc] initWithView:[_hostViewController view]]);
    527526    [selectionAssistant showShareSheetFor:WTF::userVisibleString(url) fromRect:boundingRect];
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r246086 r246090  
    12391239
    12401240    static void convertSelectionRectsToRootView(WebCore::FrameView*, Vector<WebCore::SelectionRect>&);
     1241    RefPtr<WebCore::Range> rangeForWebSelectionAtPosition(const WebCore::IntPoint&, const WebCore::VisiblePosition&, SelectionFlags&);
    12411242    void getFocusedElementInformation(FocusedElementInformation&);
    12421243    void platformInitializeAccessibility();
     
    18501851    RefPtr<WebCore::Range> m_initialSelection;
    18511852    WebCore::VisibleSelection m_storedSelectionForAccessibility { WebCore::VisibleSelection() };
     1853    WebCore::IntSize m_blockSelectionDesiredSize;
    18521854    WebCore::FloatSize m_maximumUnobscuredSize;
    18531855    int32_t m_deviceOrientation { 0 };
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r246088 r246090  
    134134using namespace WebCore;
    135135
     136const int blockSelectionStartWidth = 100;
     137const int blockSelectionStartHeight = 100;
     138
    136139void WebPage::platformInitialize()
    137140{
     
    12311234    }
    12321235    return boundingRect;
     1236}
     1237
     1238static bool canShrinkToTextSelection(Node* node)
     1239{
     1240    if (node && !is<Element>(*node))
     1241        node = node->parentElement();
     1242   
     1243    auto* renderer = (node) ? node->renderer() : nullptr;
     1244    return renderer && renderer->childrenInline() && (is<RenderBlock>(*renderer) && !downcast<RenderBlock>(*renderer).inlineContinuation()) && !renderer->isTable();
     1245}
     1246
     1247static bool hasCustomLineHeight(Node& node)
     1248{
     1249    auto* renderer = node.renderer();
     1250    return renderer && renderer->style().lineHeight().isSpecified();
     1251}
     1252   
     1253RefPtr<Range> WebPage::rangeForWebSelectionAtPosition(const IntPoint& point, const VisiblePosition& position, SelectionFlags& flags)
     1254{
     1255    HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint((point), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowUserAgentShadowContent | HitTestRequest::AllowChildFrameContent);
     1256
     1257    Node* currentNode = result.innerNode();
     1258    if (!currentNode)
     1259        return nullptr;
     1260    RefPtr<Range> range;
     1261    FloatRect boundingRectInScrollViewCoordinates;
     1262
     1263    if (!currentNode->isTextNode() && !canShrinkToTextSelection(currentNode) && hasCustomLineHeight(*currentNode)) {
     1264        auto* renderer = currentNode->renderer();
     1265        if (is<RenderBlockFlow>(renderer)) {
     1266            auto* renderText = downcast<RenderBlockFlow>(*renderer).findClosestTextAtAbsolutePoint(point);
     1267            if (renderText && renderText->textNode())
     1268                currentNode = renderText->textNode();
     1269        }
     1270    }
     1271
     1272    if (currentNode->isTextNode()) {
     1273        range = enclosingTextUnitOfGranularity(position, ParagraphGranularity, DirectionForward);
     1274        if (!range || range->collapsed())
     1275            range = Range::create(currentNode->document(), position, position);
     1276        else {
     1277            m_blockRectForTextSelection = selectionBoxForRange(range.get());
     1278            range = wordRangeFromPosition(position);
     1279        }
     1280
     1281        return range;
     1282    }
     1283
     1284    if (!currentNode->isElementNode())
     1285        currentNode = currentNode->parentElement();
     1286
     1287    Node* bestChoice = currentNode;
     1288    while (currentNode) {
     1289        if (currentNode->renderer()) {
     1290            boundingRectInScrollViewCoordinates = currentNode->renderer()->absoluteBoundingBoxRect(true);
     1291            boundingRectInScrollViewCoordinates.scale(m_page->pageScaleFactor());
     1292            if (boundingRectInScrollViewCoordinates.width() > m_blockSelectionDesiredSize.width() && boundingRectInScrollViewCoordinates.height() > m_blockSelectionDesiredSize.height())
     1293                break;
     1294            bestChoice = currentNode;
     1295        }
     1296        currentNode = currentNode->parentElement();
     1297    }
     1298
     1299    if (!bestChoice)
     1300        return nullptr;
     1301
     1302    RenderObject* renderer = bestChoice->renderer();
     1303    if (!renderer || renderer->style().userSelect() == UserSelect::None)
     1304        return nullptr;
     1305
     1306    if (renderer->childrenInline() && (is<RenderBlock>(*renderer) && !downcast<RenderBlock>(*renderer).inlineContinuation()) && !renderer->isTable()) {
     1307        range = enclosingTextUnitOfGranularity(position, WordGranularity, DirectionBackward);
     1308        if (range && !range->collapsed())
     1309            return range;
     1310    }
     1311
     1312    // If all we could find is a block whose height is very close to the height
     1313    // of the visible area, don't use it.
     1314    const float adjustmentFactor = .97;
     1315    boundingRectInScrollViewCoordinates = renderer->absoluteBoundingBoxRect(true);
     1316
     1317    if (boundingRectInScrollViewCoordinates.height() > m_page->mainFrame().view()->exposedContentRect().height() * adjustmentFactor)
     1318        return nullptr;
     1319
     1320    range = Range::create(bestChoice->document());
     1321    range->selectNodeContents(*bestChoice);
     1322    return range->collapsed() ? nullptr : range;
    12331323}
    12341324
     
    13761466        break;
    13771467
     1468    case GestureType::MakeWebSelection:
     1469        if (wkGestureState == GestureRecognizerState::Began) {
     1470            m_blockSelectionDesiredSize.setWidth(blockSelectionStartWidth);
     1471            m_blockSelectionDesiredSize.setHeight(blockSelectionStartHeight);
     1472        }
     1473        range = rangeForWebSelectionAtPosition(point, position, flags);
     1474        break;
     1475
    13781476    default:
    13791477        break;
     
    19592057    RefPtr<Range> range = rangeForGranularityAtPoint(frame, point, granularity, isInteractingWithFocusedElement);
    19602058    if (!isInteractingWithFocusedElement) {
     2059        m_blockSelectionDesiredSize.setWidth(blockSelectionStartWidth);
     2060        m_blockSelectionDesiredSize.setHeight(blockSelectionStartHeight);
    19612061        auto* renderer = range ? range->startContainer().renderer() : nullptr;
    19622062        if (renderer && renderer->style().preserveNewline())
Note: See TracChangeset for help on using the changeset viewer.