Changeset 246086 in webkit


Ignore:
Timestamp:
Jun 4, 2019 4:27:30 PM (5 years ago)
Author:
timothy_horton@apple.com
Message:

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

Reviewed by Wenson Hsieh.

  • Platform/spi/ios/UIKitSPI.h:
  • Shared/ios/GestureTypes.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(toGestureType):
(toUIWKGestureType):

  • UIProcess/ios/WKPDFView.mm:

(-[WKPDFView actionSheetAssistant:shareElementWithURL:rect:]):

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::selectWithGesture):
(WebKit::WebPage::selectTextWithGranularityAtPoint):
(WebKit::canShrinkToTextSelection): Deleted.
(WebKit::hasCustomLineHeight): Deleted.
(WebKit::WebPage::rangeForWebSelectionAtPosition): Deleted.

Location:
trunk/Source/WebKit
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r246079 r246086  
     12019-06-04  Tim Horton  <timothy_horton@apple.com>
     2
     3        Remove some unused selection code
     4        https://bugs.webkit.org/show_bug.cgi?id=198451
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * Platform/spi/ios/UIKitSPI.h:
     9        * Shared/ios/GestureTypes.h:
     10        * UIProcess/ios/WKContentViewInteraction.mm:
     11        (toGestureType):
     12        (toUIWKGestureType):
     13        * UIProcess/ios/WKPDFView.mm:
     14        (-[WKPDFView actionSheetAssistant:shareElementWithURL:rect:]):
     15        * WebProcess/WebPage/WebPage.h:
     16        * WebProcess/WebPage/ios/WebPageIOS.mm:
     17        (WebKit::WebPage::selectWithGesture):
     18        (WebKit::WebPage::selectTextWithGranularityAtPoint):
     19        (WebKit::canShrinkToTextSelection): Deleted.
     20        (WebKit::hasCustomLineHeight): Deleted.
     21        (WebKit::WebPage::rangeForWebSelectionAtPosition): Deleted.
     22
    1232019-06-04  Sihui Liu  <sihui_liu@apple.com>
    224
  • trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h

    r245832 r246086  
    531531@end
    532532
    533 @interface UIWebSelectionView : UIView
    534 @end
    535 
    536 @interface UIWebSelectionAssistant : NSObject <UIGestureRecognizerDelegate>
    537 @end
    538 
    539533@protocol UISelectionInteractionAssistant
    540534- (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;
    558535@end
    559536
     
    587564    UIWKGestureTwoFingerRangedSelectGesture = 11,
    588565    UIWKGestureTapOnLinkWithGesture = 12,
    589     UIWKGestureMakeWebSelection = 13,
    590566    UIWKGesturePhraseBoundary = 14,
    591567};
    592568
     569@interface UIWebSelectionAssistant : NSObject
     570@end
     571
    593572@interface UIWKSelectionAssistant : UIWebSelectionAssistant
    594573@end
    595574
    596575@interface UIWKSelectionAssistant ()
    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;
     576- (id)initWithView:(UIView *)view;
    601577- (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;
    605578@end
    606579
  • trunk/Source/WebKit/Shared/ios/GestureTypes.h

    r221443 r246086  
    4343    TwoFingerRangedSelectGesture,
    4444    TapOnLinkWithGesture,
    45     MakeWebSelection,
    4645    PhraseBoundary
    4746};
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r246013 r246086  
    32793279    case UIWKGestureTapOnLinkWithGesture:
    32803280        return WebKit::GestureType::TapOnLinkWithGesture;
    3281     case UIWKGestureMakeWebSelection:
    3282         return WebKit::GestureType::MakeWebSelection;
    32833281    case UIWKGesturePhraseBoundary:
    32843282        return WebKit::GestureType::PhraseBoundary;
     
    33173315    case WebKit::GestureType::TapOnLinkWithGesture:
    33183316        return UIWKGestureTapOnLinkWithGesture;
    3319     case WebKit::GestureType::MakeWebSelection:
    3320         return UIWKGestureMakeWebSelection;
    33213317    case WebKit::GestureType::PhraseBoundary:
    33223318        return UIWKGesturePhraseBoundary;
  • trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm

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

    r245998 r246086  
    12391239
    12401240    static void convertSelectionRectsToRootView(WebCore::FrameView*, Vector<WebCore::SelectionRect>&);
    1241     RefPtr<WebCore::Range> rangeForWebSelectionAtPosition(const WebCore::IntPoint&, const WebCore::VisiblePosition&, SelectionFlags&);
    12421241    void getFocusedElementInformation(FocusedElementInformation&);
    12431242    void platformInitializeAccessibility();
     
    18511850    RefPtr<WebCore::Range> m_initialSelection;
    18521851    WebCore::VisibleSelection m_storedSelectionForAccessibility { WebCore::VisibleSelection() };
    1853     WebCore::IntSize m_blockSelectionDesiredSize;
    18541852    WebCore::FloatSize m_maximumUnobscuredSize;
    18551853    int32_t m_deviceOrientation { 0 };
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r246048 r246086  
    134134using namespace WebCore;
    135135
    136 const int blockSelectionStartWidth = 100;
    137 const int blockSelectionStartHeight = 100;
    138 
    139136void WebPage::platformInitialize()
    140137{
     
    12341231    }
    12351232    return boundingRect;
    1236 }
    1237 
    1238 static 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 
    1247 static bool hasCustomLineHeight(Node& node)
    1248 {
    1249     auto* renderer = node.renderer();
    1250     return renderer && renderer->style().lineHeight().isSpecified();
    1251 }
    1252    
    1253 RefPtr<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;
    13231233}
    13241234
     
    14661376        break;
    14671377
    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 
    14761378    default:
    14771379        break;
     
    20571959    RefPtr<Range> range = rangeForGranularityAtPoint(frame, point, granularity, isInteractingWithFocusedElement);
    20581960    if (!isInteractingWithFocusedElement) {
    2059         m_blockSelectionDesiredSize.setWidth(blockSelectionStartWidth);
    2060         m_blockSelectionDesiredSize.setHeight(blockSelectionStartHeight);
    20611961        auto* renderer = range ? range->startContainer().renderer() : nullptr;
    20621962        if (renderer && renderer->style().preserveNewline())
Note: See TracChangeset for help on using the changeset viewer.