Changeset 238657 in webkit


Ignore:
Timestamp:
Nov 28, 2018 6:55:59 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r238653 and r238656.
https://bugs.webkit.org/show_bug.cgi?id=192130

Breaks iOS build (Requested by smfr on #webkit).

Reverted changesets:

"Move Lookup Code for better cross platform usage"
https://bugs.webkit.org/show_bug.cgi?id=191732
https://trac.webkit.org/changeset/238653

"Attempt to fix the iOS build by only including RevealSPI.h
when it's needed."
https://trac.webkit.org/changeset/238656

Location:
trunk/Source
Files:
18 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r238656 r238657  
     12018-11-28  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r238653 and r238656.
     4        https://bugs.webkit.org/show_bug.cgi?id=192130
     5
     6        Breaks iOS build (Requested by smfr on #webkit).
     7
     8        Reverted changesets:
     9
     10        "Move Lookup Code for better cross platform usage"
     11        https://bugs.webkit.org/show_bug.cgi?id=191732
     12        https://trac.webkit.org/changeset/238653
     13
     14        "Attempt to fix the iOS build by only including RevealSPI.h
     15        when it's needed."
     16        https://trac.webkit.org/changeset/238656
     17
    1182018-11-28  Simon Fraser  <simon.fraser@apple.com>
    219
  • trunk/Source/WebCore/PAL/ChangeLog

    r238653 r238657  
     12018-11-28  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r238653 and r238656.
     4        https://bugs.webkit.org/show_bug.cgi?id=192130
     5
     6        Breaks iOS build (Requested by smfr on #webkit).
     7
     8        Reverted changesets:
     9
     10        "Move Lookup Code for better cross platform usage"
     11        https://bugs.webkit.org/show_bug.cgi?id=191732
     12        https://trac.webkit.org/changeset/238653
     13
     14        "Attempt to fix the iOS build by only including RevealSPI.h
     15        when it's needed."
     16        https://trac.webkit.org/changeset/238656
     17
    1182018-11-15  Megan Gardner  <megan_gardner@apple.com>
    219
  • trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj

    r238653 r238657  
    407407                                0C2DA13A1F3BEB4900DBC317 /* pthreadSPI.h */,
    408408                                0C2DA13B1F3BEB4900DBC317 /* QuartzCoreSPI.h */,
    409                                 442956CC218A72DE0080DB54 /* RevealSPI.h */,
    410409                                570AB8F020AE2E8D00B8BE87 /* SecKeyProxySPI.h */,
    411410                                0C2DA13C1F3BEB4900DBC317 /* ServersSPI.h */,
     
    473472                                A102658A1F56748C00B4C844 /* QuickDrawSPI.h */,
    474473                                0C7785871F45130F00F4EBB6 /* QuickLookMacSPI.h */,
     474                                442956CC218A72DE0080DB54 /* RevealSPI.h */,
    475475                                A1175B481F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h */,
    476476                                0C7785881F45130F00F4EBB6 /* TUCallSPI.h */,
  • trunk/Source/WebCore/PAL/pal/spi/mac/LookupSPI.h

    r238653 r238657  
    2424 */
    2525
    26 
    27 #if PLATFORM(MAC)
    28 
    2926#import <objc/runtime.h>
    3027#import <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
    3128#import <wtf/SoftLinking.h>
     29
     30#if PLATFORM(MAC)
    3231
    3332SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(Lookup)
  • trunk/Source/WebCore/PAL/pal/spi/mac/RevealSPI.h

    r238656 r238657  
    2525
    2626#import <objc/runtime.h>
    27 #if PLATFORM(MAC)
    2827#import <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
    29 #endif // PLATFORM(MAC)
    3028#import <wtf/SoftLinking.h>
    3129
     
    3937#if USE(APPLE_INTERNAL_SDK)
    4038
    41 #if PLATFORM(MAC)
    4239#import <Reveal/RVPresenter.h>
    4340#import <Reveal/Reveal.h>
    44 #endif // PLATFORM(MAC)
    4541#import <RevealCore/RVSelection.h>
    4642#import <RevealCore/RevealCore.h>
    4743
    48 #else // USE(APPLE_INTERNAL_SDK)
    4944
    50 
    51 @protocol RVPresenterHighlightDelegate;
     45#else
    5246
    5347@interface RVItem : NSObject <NSSecureCoding>
     
    5953@end
    6054
    61 @interface RVPresentingContext : NSObject
    62 - (instancetype)initWithPointerLocationInView:(NSPoint)pointerLocationInView inView:(NSView *)view highlightDelegate:(id<RVPresenterHighlightDelegate>)highlightDelegate;
    63 @end
    64 
    65 @protocol RVPresenterHighlightDelegate <NSObject>
    66 @required
    67 - (NSArray <NSValue *> *)revealContext:(RVPresentingContext *)context rectsForItem:(RVItem *)item;
    68 @optional
    69 - (void)revealContext:(RVPresentingContext *)context stopHighlightingItem:(RVItem *)item;
    70 - (void)revealContext:(RVPresentingContext *)context drawRectsForItem:(RVItem *)item;
    71 @end
    72 
    73 @interface RVDocumentContext : NSObject < NSSecureCoding >
    74 @end
    75 
    7655@interface RVPresenter : NSObject
    77 #if PLATFORM(MAC)
    7856- (id<NSImmediateActionAnimationController>)animationControllerForItem:(RVItem *)item documentContext:(RVDocumentContext *)documentContext presentingContext:(RVPresentingContext *)presentingContext options:(NSDictionary *)options;
    79 #endif // PLATFORM(MAC)
    8057- (BOOL)revealItem:(RVItem *)item documentContext:(RVDocumentContext *)documentContext presentingContext:(RVPresentingContext *)presentingContext options:(NSDictionary *)options;
    8158@end
  • trunk/Source/WebCore/SourcesCocoa.txt

    r238653 r238657  
    7878
    7979editing/cocoa/DataDetection.mm
    80 editing/cocoa/DictionaryLookup.mm
    8180editing/cocoa/EditorCocoa.mm
    8281editing/cocoa/FontAttributeChangesCocoa.mm
     
    9291
    9392editing/mac/AlternativeTextUIController.mm
     93editing/mac/DictionaryLookup.mm
    9494editing/mac/DictionaryLookupLegacy.mm
    9595editing/mac/EditorMac.mm
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r238653 r238657  
    2052020520                                C5227DEF1C3C6DD700F5ED54 /* DataDetection.h */,
    2052120521                                C5227DF01C3C6DD700F5ED54 /* DataDetection.mm */,
    20522                                 937FF3D61A10131B008EBA31 /* DictionaryLookup.mm */,
    2052320522                                9B55EEE81B3E8898005342BC /* EditorCocoa.mm */,
    2052420523                                F42CEB54214031EE002DCA72 /* FontAttributeChangesCocoa.mm */,
     
    2622726226                                CE7B2DB01586ABAD0098B3FA /* AlternativeTextUIController.mm */,
    2622826227                                937FF3D41A1012D6008EBA31 /* DictionaryLookup.h */,
     26228                                937FF3D61A10131B008EBA31 /* DictionaryLookup.mm */,
    2622926229                                442956CA218A6D300080DB54 /* DictionaryLookupLegacy.mm */,
    2623026230                                ED501DC50B249F2900AE18D9 /* EditorMac.mm */,
  • trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm

    r238653 r238657  
    3535#import "DocumentFragment.h"
    3636#import "DocumentLoader.h"
    37 #import "Editor.h"
    38 #import "EditorClient.h"
    3937#import "File.h"
    4038#import "FileSystem.h"
  • trunk/Source/WebCore/editing/mac/DictionaryLookup.h

    r238653 r238657  
    2424 */
    2525
    26 #pragma once
    27 
    28 #if PLATFORM(COCOA)
     26#if PLATFORM(MAC)
    2927
    3028#include "DictionaryPopupInfo.h"
    31 #if PLATFORM(MAC)
    32 #import <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
    33 #endif // PLATFORM(MAC)
     29#include <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
    3430#include <wtf/Function.h>
    3531
    3632OBJC_CLASS NSView;
    3733OBJC_CLASS PDFSelection;
    38 
    39 #if PLATFORM(MAC)
    40 typedef id <NSImmediateActionAnimationController> WKRevealController;
    41 #else
    42 typedef id WKRevealController;
    43 #endif // PLATFORM(MAC)
    4434
    4535namespace WebCore {
     
    5949    WEBCORE_EXPORT static void showPopup(const DictionaryPopupInfo&, NSView *, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback = nullptr, WTF::Function<void()>&& clearTextIndicator = nullptr);
    6050    WEBCORE_EXPORT static void hidePopup();
    61    
    62 #if PLATFORM(MAC)
    63     WEBCORE_EXPORT static WKRevealController animationControllerForPopup(const DictionaryPopupInfo&, NSView *, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback = nullptr, WTF::Function<void()>&& clearTextIndicator = nullptr);
    64 #endif // PLATFORM(MAC)
    65    
     51
     52    WEBCORE_EXPORT static id <NSImmediateActionAnimationController> animationControllerForPopup(const DictionaryPopupInfo&, NSView *, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback = nullptr, WTF::Function<void()>&& clearTextIndicator = nullptr);
    6653};
    6754
  • trunk/Source/WebCore/editing/mac/DictionaryLookup.mm

    r238656 r238657  
    2727#import "DictionaryLookup.h"
    2828
    29 #if PLATFORM(COCOA)
     29#if PLATFORM(MAC) && ENABLE(REVEAL)
    3030
    3131#import "Document.h"
     
    3636#import "HTMLConverter.h"
    3737#import "HitTestResult.h"
    38 #import "NotImplemented.h"
    3938#import "Page.h"
    4039#import "Range.h"
     
    4645#import <PDFKit/PDFKit.h>
    4746#import <pal/spi/mac/LookupSPI.h>
     47#import <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
     48#import <pal/spi/mac/RevealSPI.h>
    4849#import <wtf/BlockObjCExceptions.h>
    4950#import <wtf/RefPtr.h>
    50 
    51 #if ENABLE(REVEAL)
    52 #import <pal/spi/cocoa/RevealSPI.h>
    53 
    54 #if PLATFORM(MAC)
    5551
    5652@interface WebRevealHighlight <RVPresenterHighlightDelegate> : NSObject {
     
    137133@end
    138134
    139 #endif // PLATFORM(MAC)
    140 
    141 #endif // ENABLE(REVEAL)
    142 
    143135namespace WebCore {
    144 
    145 #if ENABLE(REVEAL)
    146136
    147137std::tuple<RefPtr<Range>, NSDictionary *> DictionaryLookup::rangeForSelection(const VisibleSelection& selection)
     
    313303}
    314304
    315 static WKRevealController showPopupOrCreateAnimationController(bool createAnimationController, const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
    316 {
    317     BEGIN_BLOCK_OBJC_EXCEPTIONS;
    318    
    319 #if PLATFORM(MAC)
    320    
    321     if (!getRVItemClass() || !getRVPresenterClass())
     305static id <NSImmediateActionAnimationController> showPopupOrCreateAnimationController(bool createAnimationController, const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
     306{
     307    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     308   
     309    if (!getRVItemClass())
    322310        return nil;
    323311
     
    370358    [presenter revealItem:item.get() documentContext:nil presentingContext:context.get() options:nil];
    371359    return nil;
    372    
    373 #else // PLATFORM(MAC)
    374    
    375     UNUSED_PARAM(createAnimationController);
    376     UNUSED_PARAM(dictionaryPopupInfo);
    377     UNUSED_PARAM(view);
    378     UNUSED_PARAM(textIndicatorInstallationCallback);
    379     UNUSED_PARAM(rootViewToViewConversionCallback);
    380     UNUSED_PARAM(clearTextIndicator);
    381    
     360
     361    END_BLOCK_OBJC_EXCEPTIONS;
    382362    return nil;
     363}
     364
     365void DictionaryLookup::showPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
     366{
     367    showPopupOrCreateAnimationController(false, dictionaryPopupInfo, view, textIndicatorInstallationCallback, rootViewToViewConversionCallback, WTFMove(clearTextIndicator));
     368}
     369
     370void DictionaryLookup::hidePopup()
     371{
     372    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     373
     374    if (!getLULookupDefinitionModuleClass())
     375        return;
     376    [getLULookupDefinitionModuleClass() hideDefinition];
     377
     378    END_BLOCK_OBJC_EXCEPTIONS;
     379}
     380
     381id <NSImmediateActionAnimationController> DictionaryLookup::animationControllerForPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
     382{
     383    return showPopupOrCreateAnimationController(true, dictionaryPopupInfo, view, textIndicatorInstallationCallback, rootViewToViewConversionCallback, WTFMove(clearTextIndicator));
     384}
     385
     386} // namespace WebCore
     387
    383388#endif // PLATFORM(MAC)
    384    
    385     END_BLOCK_OBJC_EXCEPTIONS;
    386    
    387 }
    388 
    389 void DictionaryLookup::showPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
    390 {
    391     showPopupOrCreateAnimationController(false, dictionaryPopupInfo, view, textIndicatorInstallationCallback, rootViewToViewConversionCallback, WTFMove(clearTextIndicator));
    392 }
    393 
    394 void DictionaryLookup::hidePopup()
    395 {
    396     notImplemented();
    397 }
    398 
    399 #if PLATFORM(MAC)
    400 
    401 WKRevealController DictionaryLookup::animationControllerForPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
    402 {
    403     return showPopupOrCreateAnimationController(true, dictionaryPopupInfo, view, textIndicatorInstallationCallback, rootViewToViewConversionCallback, WTFMove(clearTextIndicator));
    404 }
    405 
    406 #endif // PLATFORM(MAC)
    407 
    408 #elif PLATFORM(IOS_FAMILY) // ENABLE(REVEAL)
    409 
    410 std::tuple<RefPtr<Range>, NSDictionary *> DictionaryLookup::rangeForSelection(const VisibleSelection&)
    411 {
    412     return { nullptr, nil };
    413 }
    414 
    415 std::tuple<RefPtr<Range>, NSDictionary *> DictionaryLookup::rangeAtHitTestResult(const HitTestResult&)
    416 {
    417     return { nullptr, nil };
    418 }
    419 
    420 #endif // ENABLE(REVEAL)
    421 
    422 } // namespace WebCore
    423 
    424 #endif // PLATFORM(COCOA)
  • trunk/Source/WebKit/ChangeLog

    r238655 r238657  
     12018-11-28  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r238653 and r238656.
     4        https://bugs.webkit.org/show_bug.cgi?id=192130
     5
     6        Breaks iOS build (Requested by smfr on #webkit).
     7
     8        Reverted changesets:
     9
     10        "Move Lookup Code for better cross platform usage"
     11        https://bugs.webkit.org/show_bug.cgi?id=191732
     12        https://trac.webkit.org/changeset/238653
     13
     14        "Attempt to fix the iOS build by only including RevealSPI.h
     15        when it's needed."
     16        https://trac.webkit.org/changeset/238656
    117
    2182018-11-28  Alex Christensen  <achristensen@webkit.org>
  • trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h

    r238653 r238657  
    734734};
    735735
    736 @interface _UILookupGestureRecognizer : UIGestureRecognizer
    737 @end
    738 
    739736@class UIWebTouchEventsGestureRecognizer;
    740737
  • trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm

    r238653 r238657  
    3434#import "SafeBrowsingSPI.h"
    3535#import "SafeBrowsingWarning.h"
    36 #import "WebPageMessages.h"
    3736#import "WebProcessProxy.h"
    3837#import <WebCore/DragItem.h>
     
    191190
    192191#endif // ENABLE(ATTACHMENT_ELEMENT)
    193    
    194 void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint& point)
    195 {
    196     if (!isValid())
    197         return;
    198    
    199     process().send(Messages::WebPage::PerformDictionaryLookupAtLocation(point), m_pageID);
     192
    200193}
    201 
    202 void WebPageProxy::performDictionaryLookupOfCurrentSelection()
    203 {
    204     if (!isValid())
    205         return;
    206    
    207     process().send(Messages::WebPage::PerformDictionaryLookupOfCurrentSelection(), m_pageID);
    208 }
    209 
    210 } // namespace WebKit
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h

    r238653 r238657  
    8888}
    8989
    90 @class _UILookupGestureRecognizer;
    9190@class _UIHighlightView;
    9291@class _UIWebHighlightLongPressGestureRecognizer;
     
    217216#if PLATFORM(IOSMAC)
    218217    RetainPtr<UIHoverGestureRecognizer> _hoverGestureRecognizer;
    219     RetainPtr<_UILookupGestureRecognizer> _lookupGestureRecognizer;
    220218#endif
    221219
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r238653 r238657  
    113113#import "NativeWebMouseEvent.h"
    114114#import <UIKit/UIHoverGestureRecognizer.h>
    115 #import <UIKit/_UILookupGestureRecognizer.h>
    116115#import <pal/spi/ios/GraphicsServicesSPI.h>
    117116#endif
     
    651650    [_hoverGestureRecognizer setDelegate:self];
    652651    [self addGestureRecognizer:_hoverGestureRecognizer.get()];
    653    
    654     _lookupGestureRecognizer = adoptNS([[_UILookupGestureRecognizer alloc] initWithTarget:self action:@selector(_lookupGestureRecognized:)]);
    655     [_lookupGestureRecognizer setDelegate:self];
    656     [self addGestureRecognizer:_lookupGestureRecognizer.get()];
    657    
    658652#endif
    659653
     
    766760    [_hoverGestureRecognizer setDelegate:nil];
    767761    [self removeGestureRecognizer:_hoverGestureRecognizer.get()];
    768    
    769     [_lookupGestureRecognizer setDelegate:nil];
    770     [self removeGestureRecognizer:_lookupGestureRecognizer.get()];
    771762#endif
    772763
     
    856847#if PLATFORM(IOSMAC)
    857848    [self removeGestureRecognizer:_hoverGestureRecognizer.get()];
    858     [self removeGestureRecognizer:_lookupGestureRecognizer.get()];
    859849#endif
    860850}
     
    872862#if PLATFORM(IOSMAC)
    873863    [self addGestureRecognizer:_hoverGestureRecognizer.get()];
    874     [self addGestureRecognizer:_lookupGestureRecognizer.get()];
    875864#endif
    876865}
     
    14791468    if ([gestureRecognizer isKindOfClass:[UIHoverGestureRecognizer class]] || [otherGestureRecognizer isKindOfClass:[UIHoverGestureRecognizer class]])
    14801469        return YES;
    1481    
    1482     if (([gestureRecognizer isKindOfClass:[_UILookupGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) || ([otherGestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]] && [gestureRecognizer isKindOfClass:[_UILookupGestureRecognizer class]]))
    1483         return YES;
    1484 
    14851470#endif
    14861471    if (isSamePair(gestureRecognizer, otherGestureRecognizer, _highlightLongPressGestureRecognizer.get(), _textSelectionAssistant.get().forcePressGesture))
     
    60736058
    60746059#if PLATFORM(IOSMAC)
    6075 - (void)_lookupGestureRecognized:(UIGestureRecognizer *)gestureRecognizer
    6076 {
    6077     NSPoint locationInViewCoordinates = [gestureRecognizer locationInView:self];
    6078     _page->performDictionaryLookupAtLocation(WebCore::FloatPoint(locationInViewCoordinates));
    6079 }
    6080 
    60816060- (void)_hoverGestureRecognizerChanged:(UIGestureRecognizer *)gestureRecognizer
    60826061{
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r238653 r238657  
    122122}
    123123
     124void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint&)
     125{
     126    notImplemented();
     127}
     128
    124129void WebPageProxy::gestureCallback(const WebCore::IntPoint& point, uint32_t gestureType, uint32_t gestureState, uint32_t flags, CallbackID callbackID)
    125130{
  • trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm

    r238653 r238657  
    324324#endif
    325325
     326void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint& point)
     327{
     328    if (!isValid())
     329        return;
     330
     331    process().send(Messages::WebPage::PerformDictionaryLookupAtLocation(point), m_pageID);
     332}
     333
     334void WebPageProxy::performDictionaryLookupOfCurrentSelection()
     335{
     336    if (!isValid())
     337        return;
     338
     339    process().send(Messages::WebPage::PerformDictionaryLookupOfCurrentSelection(), m_pageID);
     340}
     341
    326342// Complex text input support for plug-ins.
    327343void WebPageProxy::sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput)
  • trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm

    r238653 r238657  
    2727#import "WebPage.h"
    2828
    29 
    3029#import "LoadParameters.h"
    31 #import "PluginView.h"
    3230#import "WebPageProxyMessages.h"
    33 #import <WebCore/DictionaryLookup.h>
    34 #import <WebCore/Editor.h>
    35 #import <WebCore/EventHandler.h>
    36 #import <WebCore/FocusController.h>
    37 #import <WebCore/HTMLConverter.h>
    38 #import <WebCore/HitTestResult.h>
    39 #import <WebCore/NodeRenderStyle.h>
    4031#import <WebCore/PlatformMediaSessionManager.h>
    41 #import <WebCore/RenderElement.h>
    42 #import <WebCore/RenderObject.h>
    4332
    4433#if PLATFORM(COCOA)
     
    7160    send(Messages::WebPageProxy::NowPlayingInfoCallback(hasActiveSession, registeredAsNowPlayingApplication, title, duration, elapsedTime, uniqueIdentifier, callbackID));
    7261}
    73    
    74 void WebPage::performDictionaryLookupAtLocation(const FloatPoint& floatPoint)
    75 {
    76     if (auto* pluginView = pluginViewForFrame(&m_page->mainFrame())) {
    77         if (pluginView->performDictionaryLookupAtLocation(floatPoint))
    78             return;
    79     }
    80    
    81     // Find the frame the point is over.
    82     HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint(m_page->mainFrame().view()->windowToContents(roundedIntPoint(floatPoint)));
    83     RefPtr<Range> range;
    84     NSDictionary *options;
    85     std::tie(range, options) = DictionaryLookup::rangeAtHitTestResult(result);
    86     if (!range)
    87         return;
    88    
    89     auto* frame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document().frame() : &m_page->focusController().focusedOrMainFrame();
    90     if (!frame)
    91         return;
    92    
    93     performDictionaryLookupForRange(*frame, *range, options, TextIndicatorPresentationTransition::Bounce);
    94 }
    95 
    96 void WebPage::performDictionaryLookupForSelection(Frame& frame, const VisibleSelection& selection, TextIndicatorPresentationTransition presentationTransition)
    97 {
    98     RefPtr<Range> selectedRange;
    99     NSDictionary *options;
    100     std::tie(selectedRange, options) = DictionaryLookup::rangeForSelection(selection);
    101     if (selectedRange)
    102         performDictionaryLookupForRange(frame, *selectedRange, options, presentationTransition);
    103 }
    104 
    105 void WebPage::performDictionaryLookupOfCurrentSelection()
    106 {
    107     auto& frame = m_page->focusController().focusedOrMainFrame();
    108     performDictionaryLookupForSelection(frame, frame.selection().selection(), TextIndicatorPresentationTransition::BounceAndCrossfade);
    109 }
    110    
    111 void WebPage::performDictionaryLookupForRange(Frame& frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
    112 {
    113     send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfoForRange(frame, range, options, presentationTransition)));
    114 }
    115 
    116 DictionaryPopupInfo WebPage::dictionaryPopupInfoForRange(Frame& frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
    117 {
    118     Editor& editor = frame.editor();
    119     editor.setIsGettingDictionaryPopupInfo(true);
    120    
    121     DictionaryPopupInfo dictionaryPopupInfo;
    122     if (range.text().stripWhiteSpace().isEmpty()) {
    123         editor.setIsGettingDictionaryPopupInfo(false);
    124         return dictionaryPopupInfo;
    125     }
    126    
    127     Vector<FloatQuad> quads;
    128     range.absoluteTextQuads(quads);
    129     if (quads.isEmpty()) {
    130         editor.setIsGettingDictionaryPopupInfo(false);
    131         return dictionaryPopupInfo;
    132     }
    133    
    134     IntRect rangeRect = frame.view()->contentsToWindow(quads[0].enclosingBoundingBox());
    135    
    136     const RenderStyle* style = range.startContainer().renderStyle();
    137     float scaledAscent = style ? style->fontMetrics().ascent() * pageScaleFactor() : 0;
    138     dictionaryPopupInfo.origin = FloatPoint(rangeRect.x(), rangeRect.y() + scaledAscent);
    139     dictionaryPopupInfo.options = options;
    140 
    141 #if PLATFORM(MAC)
    142 
    143     NSAttributedString *nsAttributedString = editingAttributedStringFromRange(range, IncludeImagesInAttributedString::No);
    144    
    145     RetainPtr<NSMutableAttributedString> scaledNSAttributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[nsAttributedString string]]);
    146    
    147     NSFontManager *fontManager = [NSFontManager sharedFontManager];
    148    
    149     [nsAttributedString enumerateAttributesInRange:NSMakeRange(0, [nsAttributedString length]) options:0 usingBlock:^(NSDictionary *attributes, NSRange range, BOOL *stop) {
    150         RetainPtr<NSMutableDictionary> scaledAttributes = adoptNS([attributes mutableCopy]);
    151        
    152         NSFont *font = [scaledAttributes objectForKey:NSFontAttributeName];
    153         if (font)
    154             font = [fontManager convertFont:font toSize:font.pointSize * pageScaleFactor()];
    155         if (font)
    156             [scaledAttributes setObject:font forKey:NSFontAttributeName];
    157        
    158         [scaledNSAttributedString addAttributes:scaledAttributes.get() range:range];
    159     }];
    160 
    161 #endif // PLATFORM(MAC)
    162    
    163     TextIndicatorOptions indicatorOptions = TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges;
    164     if (presentationTransition == TextIndicatorPresentationTransition::BounceAndCrossfade)
    165         indicatorOptions |= TextIndicatorOptionIncludeSnapshotWithSelectionHighlight;
    166    
    167     RefPtr<TextIndicator> textIndicator = TextIndicator::createWithRange(range, indicatorOptions, presentationTransition);
    168     if (!textIndicator) {
    169         editor.setIsGettingDictionaryPopupInfo(false);
    170         return dictionaryPopupInfo;
    171     }
    172    
    173     dictionaryPopupInfo.textIndicator = textIndicator->data();
    174 #if PLATFORM(MAC)
    175     dictionaryPopupInfo.attributedString = scaledNSAttributedString;
    176 #endif // PLATFORM(MAC)
    177    
    178     editor.setIsGettingDictionaryPopupInfo(false);
    179     return dictionaryPopupInfo;
    180 }
    18162
    18263} // namespace WebKit
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r238653 r238657  
    418418}
    419419
     420void WebPage::performDictionaryLookupAtLocation(const FloatPoint&)
     421{
     422    notImplemented();
     423}
     424
     425void WebPage::performDictionaryLookupForSelection(Frame&, const VisibleSelection&, TextIndicatorPresentationTransition)
     426{
     427    notImplemented();
     428}
     429
     430void WebPage::performDictionaryLookupForRange(Frame&, Range&, NSDictionary *, TextIndicatorPresentationTransition)
     431{
     432    notImplemented();
     433}
     434
    420435bool WebPage::performNonEditingBehaviorForSelector(const String&, WebCore::KeyboardEvent*)
    421436{
  • trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm

    r238653 r238657  
    390390}
    391391   
    392 
     392void WebPage::performDictionaryLookupAtLocation(const FloatPoint& floatPoint)
     393{
     394    if (auto* pluginView = pluginViewForFrame(&m_page->mainFrame())) {
     395        if (pluginView->performDictionaryLookupAtLocation(floatPoint))
     396            return;
     397    }
     398
     399    // Find the frame the point is over.
     400    HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint(m_page->mainFrame().view()->windowToContents(roundedIntPoint(floatPoint)));
     401    RefPtr<Range> range;
     402    NSDictionary *options;
     403    std::tie(range, options) = DictionaryLookup::rangeAtHitTestResult(result);
     404    if (!range)
     405        return;
     406
     407    auto* frame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document().frame() : &m_page->focusController().focusedOrMainFrame();
     408    if (!frame)
     409        return;
     410
     411    performDictionaryLookupForRange(*frame, *range, options, TextIndicatorPresentationTransition::Bounce);
     412}
     413
     414void WebPage::performDictionaryLookupForSelection(Frame& frame, const VisibleSelection& selection, TextIndicatorPresentationTransition presentationTransition)
     415{
     416    RefPtr<Range> selectedRange;
     417    NSDictionary *options;
     418    std::tie(selectedRange, options) = DictionaryLookup::rangeForSelection(selection);
     419    if (selectedRange)
     420        performDictionaryLookupForRange(frame, *selectedRange, options, presentationTransition);
     421}
     422
     423void WebPage::performDictionaryLookupOfCurrentSelection()
     424{
     425    auto& frame = m_page->focusController().focusedOrMainFrame();
     426    performDictionaryLookupForSelection(frame, frame.selection().selection(), TextIndicatorPresentationTransition::BounceAndCrossfade);
     427}
     428
     429DictionaryPopupInfo WebPage::dictionaryPopupInfoForRange(Frame& frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
     430{
     431    Editor& editor = frame.editor();
     432    editor.setIsGettingDictionaryPopupInfo(true);
     433
     434    DictionaryPopupInfo dictionaryPopupInfo;
     435    if (range.text().stripWhiteSpace().isEmpty()) {
     436        editor.setIsGettingDictionaryPopupInfo(false);
     437        return dictionaryPopupInfo;
     438    }
     439
     440    Vector<FloatQuad> quads;
     441    range.absoluteTextQuads(quads);
     442    if (quads.isEmpty()) {
     443        editor.setIsGettingDictionaryPopupInfo(false);
     444        return dictionaryPopupInfo;
     445    }
     446
     447    IntRect rangeRect = frame.view()->contentsToWindow(quads[0].enclosingBoundingBox());
     448
     449    const RenderStyle* style = range.startContainer().renderStyle();
     450    float scaledAscent = style ? style->fontMetrics().ascent() * pageScaleFactor() : 0;
     451    dictionaryPopupInfo.origin = FloatPoint(rangeRect.x(), rangeRect.y() + scaledAscent);
     452    dictionaryPopupInfo.options = options;
     453
     454    NSAttributedString *nsAttributedString = editingAttributedStringFromRange(range, IncludeImagesInAttributedString::No);
     455
     456    RetainPtr<NSMutableAttributedString> scaledNSAttributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[nsAttributedString string]]);
     457
     458    NSFontManager *fontManager = [NSFontManager sharedFontManager];
     459
     460    [nsAttributedString enumerateAttributesInRange:NSMakeRange(0, [nsAttributedString length]) options:0 usingBlock:^(NSDictionary *attributes, NSRange range, BOOL *stop) {
     461        RetainPtr<NSMutableDictionary> scaledAttributes = adoptNS([attributes mutableCopy]);
     462
     463        NSFont *font = [scaledAttributes objectForKey:NSFontAttributeName];
     464        if (font)
     465            font = [fontManager convertFont:font toSize:font.pointSize * pageScaleFactor()];
     466        if (font)
     467            [scaledAttributes setObject:font forKey:NSFontAttributeName];
     468
     469        [scaledNSAttributedString addAttributes:scaledAttributes.get() range:range];
     470    }];
     471
     472    TextIndicatorOptions indicatorOptions = TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges;
     473    if (presentationTransition == TextIndicatorPresentationTransition::BounceAndCrossfade)
     474        indicatorOptions |= TextIndicatorOptionIncludeSnapshotWithSelectionHighlight;
     475
     476    RefPtr<TextIndicator> textIndicator = TextIndicator::createWithRange(range, indicatorOptions, presentationTransition);
     477    if (!textIndicator) {
     478        editor.setIsGettingDictionaryPopupInfo(false);
     479        return dictionaryPopupInfo;
     480    }
     481
     482    dictionaryPopupInfo.textIndicator = textIndicator->data();
     483    dictionaryPopupInfo.attributedString = scaledNSAttributedString;
     484
     485    editor.setIsGettingDictionaryPopupInfo(false);
     486    return dictionaryPopupInfo;
     487}
    393488
    394489#if ENABLE(PDFKIT_PLUGIN)
     
    444539
    445540#endif
     541
     542void WebPage::performDictionaryLookupForRange(Frame& frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
     543{
     544    send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfoForRange(frame, range, options, presentationTransition)));
     545}
    446546
    447547bool WebPage::performNonEditingBehaviorForSelector(const String& selector, KeyboardEvent* event)
Note: See TracChangeset for help on using the changeset viewer.