Changeset 238657 in webkit
- Timestamp:
- Nov 28, 2018 6:55:59 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 18 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r238656 r238657 1 2018-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 1 18 2018-11-28 Simon Fraser <simon.fraser@apple.com> 2 19 -
trunk/Source/WebCore/PAL/ChangeLog
r238653 r238657 1 2018-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 1 18 2018-11-15 Megan Gardner <megan_gardner@apple.com> 2 19 -
trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj
r238653 r238657 407 407 0C2DA13A1F3BEB4900DBC317 /* pthreadSPI.h */, 408 408 0C2DA13B1F3BEB4900DBC317 /* QuartzCoreSPI.h */, 409 442956CC218A72DE0080DB54 /* RevealSPI.h */,410 409 570AB8F020AE2E8D00B8BE87 /* SecKeyProxySPI.h */, 411 410 0C2DA13C1F3BEB4900DBC317 /* ServersSPI.h */, … … 473 472 A102658A1F56748C00B4C844 /* QuickDrawSPI.h */, 474 473 0C7785871F45130F00F4EBB6 /* QuickLookMacSPI.h */, 474 442956CC218A72DE0080DB54 /* RevealSPI.h */, 475 475 A1175B481F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h */, 476 476 0C7785881F45130F00F4EBB6 /* TUCallSPI.h */, -
trunk/Source/WebCore/PAL/pal/spi/mac/LookupSPI.h
r238653 r238657 24 24 */ 25 25 26 27 #if PLATFORM(MAC)28 29 26 #import <objc/runtime.h> 30 27 #import <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h> 31 28 #import <wtf/SoftLinking.h> 29 30 #if PLATFORM(MAC) 32 31 33 32 SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(Lookup) -
trunk/Source/WebCore/PAL/pal/spi/mac/RevealSPI.h
r238656 r238657 25 25 26 26 #import <objc/runtime.h> 27 #if PLATFORM(MAC)28 27 #import <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h> 29 #endif // PLATFORM(MAC)30 28 #import <wtf/SoftLinking.h> 31 29 … … 39 37 #if USE(APPLE_INTERNAL_SDK) 40 38 41 #if PLATFORM(MAC)42 39 #import <Reveal/RVPresenter.h> 43 40 #import <Reveal/Reveal.h> 44 #endif // PLATFORM(MAC)45 41 #import <RevealCore/RVSelection.h> 46 42 #import <RevealCore/RevealCore.h> 47 43 48 #else // USE(APPLE_INTERNAL_SDK)49 44 50 51 @protocol RVPresenterHighlightDelegate; 45 #else 52 46 53 47 @interface RVItem : NSObject <NSSecureCoding> … … 59 53 @end 60 54 61 @interface RVPresentingContext : NSObject62 - (instancetype)initWithPointerLocationInView:(NSPoint)pointerLocationInView inView:(NSView *)view highlightDelegate:(id<RVPresenterHighlightDelegate>)highlightDelegate;63 @end64 65 @protocol RVPresenterHighlightDelegate <NSObject>66 @required67 - (NSArray <NSValue *> *)revealContext:(RVPresentingContext *)context rectsForItem:(RVItem *)item;68 @optional69 - (void)revealContext:(RVPresentingContext *)context stopHighlightingItem:(RVItem *)item;70 - (void)revealContext:(RVPresentingContext *)context drawRectsForItem:(RVItem *)item;71 @end72 73 @interface RVDocumentContext : NSObject < NSSecureCoding >74 @end75 76 55 @interface RVPresenter : NSObject 77 #if PLATFORM(MAC)78 56 - (id<NSImmediateActionAnimationController>)animationControllerForItem:(RVItem *)item documentContext:(RVDocumentContext *)documentContext presentingContext:(RVPresentingContext *)presentingContext options:(NSDictionary *)options; 79 #endif // PLATFORM(MAC)80 57 - (BOOL)revealItem:(RVItem *)item documentContext:(RVDocumentContext *)documentContext presentingContext:(RVPresentingContext *)presentingContext options:(NSDictionary *)options; 81 58 @end -
trunk/Source/WebCore/SourcesCocoa.txt
r238653 r238657 78 78 79 79 editing/cocoa/DataDetection.mm 80 editing/cocoa/DictionaryLookup.mm81 80 editing/cocoa/EditorCocoa.mm 82 81 editing/cocoa/FontAttributeChangesCocoa.mm … … 92 91 93 92 editing/mac/AlternativeTextUIController.mm 93 editing/mac/DictionaryLookup.mm 94 94 editing/mac/DictionaryLookupLegacy.mm 95 95 editing/mac/EditorMac.mm -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r238653 r238657 20520 20520 C5227DEF1C3C6DD700F5ED54 /* DataDetection.h */, 20521 20521 C5227DF01C3C6DD700F5ED54 /* DataDetection.mm */, 20522 937FF3D61A10131B008EBA31 /* DictionaryLookup.mm */,20523 20522 9B55EEE81B3E8898005342BC /* EditorCocoa.mm */, 20524 20523 F42CEB54214031EE002DCA72 /* FontAttributeChangesCocoa.mm */, … … 26227 26226 CE7B2DB01586ABAD0098B3FA /* AlternativeTextUIController.mm */, 26228 26227 937FF3D41A1012D6008EBA31 /* DictionaryLookup.h */, 26228 937FF3D61A10131B008EBA31 /* DictionaryLookup.mm */, 26229 26229 442956CA218A6D300080DB54 /* DictionaryLookupLegacy.mm */, 26230 26230 ED501DC50B249F2900AE18D9 /* EditorMac.mm */, -
trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
r238653 r238657 35 35 #import "DocumentFragment.h" 36 36 #import "DocumentLoader.h" 37 #import "Editor.h"38 #import "EditorClient.h"39 37 #import "File.h" 40 38 #import "FileSystem.h" -
trunk/Source/WebCore/editing/mac/DictionaryLookup.h
r238653 r238657 24 24 */ 25 25 26 #pragma once 27 28 #if PLATFORM(COCOA) 26 #if PLATFORM(MAC) 29 27 30 28 #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> 34 30 #include <wtf/Function.h> 35 31 36 32 OBJC_CLASS NSView; 37 33 OBJC_CLASS PDFSelection; 38 39 #if PLATFORM(MAC)40 typedef id <NSImmediateActionAnimationController> WKRevealController;41 #else42 typedef id WKRevealController;43 #endif // PLATFORM(MAC)44 34 45 35 namespace WebCore { … … 59 49 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); 60 50 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); 66 53 }; 67 54 -
trunk/Source/WebCore/editing/mac/DictionaryLookup.mm
r238656 r238657 27 27 #import "DictionaryLookup.h" 28 28 29 #if PLATFORM( COCOA)29 #if PLATFORM(MAC) && ENABLE(REVEAL) 30 30 31 31 #import "Document.h" … … 36 36 #import "HTMLConverter.h" 37 37 #import "HitTestResult.h" 38 #import "NotImplemented.h"39 38 #import "Page.h" 40 39 #import "Range.h" … … 46 45 #import <PDFKit/PDFKit.h> 47 46 #import <pal/spi/mac/LookupSPI.h> 47 #import <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h> 48 #import <pal/spi/mac/RevealSPI.h> 48 49 #import <wtf/BlockObjCExceptions.h> 49 50 #import <wtf/RefPtr.h> 50 51 #if ENABLE(REVEAL)52 #import <pal/spi/cocoa/RevealSPI.h>53 54 #if PLATFORM(MAC)55 51 56 52 @interface WebRevealHighlight <RVPresenterHighlightDelegate> : NSObject { … … 137 133 @end 138 134 139 #endif // PLATFORM(MAC)140 141 #endif // ENABLE(REVEAL)142 143 135 namespace WebCore { 144 145 #if ENABLE(REVEAL)146 136 147 137 std::tuple<RefPtr<Range>, NSDictionary *> DictionaryLookup::rangeForSelection(const VisibleSelection& selection) … … 313 303 } 314 304 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()) 305 static 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()) 322 310 return nil; 323 311 … … 370 358 [presenter revealItem:item.get() documentContext:nil presentingContext:context.get() options:nil]; 371 359 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; 382 362 return nil; 363 } 364 365 void 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 370 void 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 381 id <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 383 388 #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 WebCore423 424 #endif // PLATFORM(COCOA) -
trunk/Source/WebKit/ChangeLog
r238655 r238657 1 2018-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 1 17 2 18 2018-11-28 Alex Christensen <achristensen@webkit.org> -
trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h
r238653 r238657 734 734 }; 735 735 736 @interface _UILookupGestureRecognizer : UIGestureRecognizer737 @end738 739 736 @class UIWebTouchEventsGestureRecognizer; 740 737 -
trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
r238653 r238657 34 34 #import "SafeBrowsingSPI.h" 35 35 #import "SafeBrowsingWarning.h" 36 #import "WebPageMessages.h"37 36 #import "WebProcessProxy.h" 38 37 #import <WebCore/DragItem.h> … … 191 190 192 191 #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 200 193 } 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 88 88 } 89 89 90 @class _UILookupGestureRecognizer;91 90 @class _UIHighlightView; 92 91 @class _UIWebHighlightLongPressGestureRecognizer; … … 217 216 #if PLATFORM(IOSMAC) 218 217 RetainPtr<UIHoverGestureRecognizer> _hoverGestureRecognizer; 219 RetainPtr<_UILookupGestureRecognizer> _lookupGestureRecognizer;220 218 #endif 221 219 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r238653 r238657 113 113 #import "NativeWebMouseEvent.h" 114 114 #import <UIKit/UIHoverGestureRecognizer.h> 115 #import <UIKit/_UILookupGestureRecognizer.h>116 115 #import <pal/spi/ios/GraphicsServicesSPI.h> 117 116 #endif … … 651 650 [_hoverGestureRecognizer setDelegate:self]; 652 651 [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 658 652 #endif 659 653 … … 766 760 [_hoverGestureRecognizer setDelegate:nil]; 767 761 [self removeGestureRecognizer:_hoverGestureRecognizer.get()]; 768 769 [_lookupGestureRecognizer setDelegate:nil];770 [self removeGestureRecognizer:_lookupGestureRecognizer.get()];771 762 #endif 772 763 … … 856 847 #if PLATFORM(IOSMAC) 857 848 [self removeGestureRecognizer:_hoverGestureRecognizer.get()]; 858 [self removeGestureRecognizer:_lookupGestureRecognizer.get()];859 849 #endif 860 850 } … … 872 862 #if PLATFORM(IOSMAC) 873 863 [self addGestureRecognizer:_hoverGestureRecognizer.get()]; 874 [self addGestureRecognizer:_lookupGestureRecognizer.get()];875 864 #endif 876 865 } … … 1479 1468 if ([gestureRecognizer isKindOfClass:[UIHoverGestureRecognizer class]] || [otherGestureRecognizer isKindOfClass:[UIHoverGestureRecognizer class]]) 1480 1469 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 1485 1470 #endif 1486 1471 if (isSamePair(gestureRecognizer, otherGestureRecognizer, _highlightLongPressGestureRecognizer.get(), _textSelectionAssistant.get().forcePressGesture)) … … 6073 6058 6074 6059 #if PLATFORM(IOSMAC) 6075 - (void)_lookupGestureRecognized:(UIGestureRecognizer *)gestureRecognizer6076 {6077 NSPoint locationInViewCoordinates = [gestureRecognizer locationInView:self];6078 _page->performDictionaryLookupAtLocation(WebCore::FloatPoint(locationInViewCoordinates));6079 }6080 6081 6060 - (void)_hoverGestureRecognizerChanged:(UIGestureRecognizer *)gestureRecognizer 6082 6061 { -
trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
r238653 r238657 122 122 } 123 123 124 void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint&) 125 { 126 notImplemented(); 127 } 128 124 129 void WebPageProxy::gestureCallback(const WebCore::IntPoint& point, uint32_t gestureType, uint32_t gestureState, uint32_t flags, CallbackID callbackID) 125 130 { -
trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
r238653 r238657 324 324 #endif 325 325 326 void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint& point) 327 { 328 if (!isValid()) 329 return; 330 331 process().send(Messages::WebPage::PerformDictionaryLookupAtLocation(point), m_pageID); 332 } 333 334 void WebPageProxy::performDictionaryLookupOfCurrentSelection() 335 { 336 if (!isValid()) 337 return; 338 339 process().send(Messages::WebPage::PerformDictionaryLookupOfCurrentSelection(), m_pageID); 340 } 341 326 342 // Complex text input support for plug-ins. 327 343 void WebPageProxy::sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput) -
trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm
r238653 r238657 27 27 #import "WebPage.h" 28 28 29 30 29 #import "LoadParameters.h" 31 #import "PluginView.h"32 30 #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>40 31 #import <WebCore/PlatformMediaSessionManager.h> 41 #import <WebCore/RenderElement.h>42 #import <WebCore/RenderObject.h>43 32 44 33 #if PLATFORM(COCOA) … … 71 60 send(Messages::WebPageProxy::NowPlayingInfoCallback(hasActiveSession, registeredAsNowPlayingApplication, title, duration, elapsedTime, uniqueIdentifier, callbackID)); 72 61 } 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 }181 62 182 63 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r238653 r238657 418 418 } 419 419 420 void WebPage::performDictionaryLookupAtLocation(const FloatPoint&) 421 { 422 notImplemented(); 423 } 424 425 void WebPage::performDictionaryLookupForSelection(Frame&, const VisibleSelection&, TextIndicatorPresentationTransition) 426 { 427 notImplemented(); 428 } 429 430 void WebPage::performDictionaryLookupForRange(Frame&, Range&, NSDictionary *, TextIndicatorPresentationTransition) 431 { 432 notImplemented(); 433 } 434 420 435 bool WebPage::performNonEditingBehaviorForSelector(const String&, WebCore::KeyboardEvent*) 421 436 { -
trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
r238653 r238657 390 390 } 391 391 392 392 void 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 414 void 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 423 void WebPage::performDictionaryLookupOfCurrentSelection() 424 { 425 auto& frame = m_page->focusController().focusedOrMainFrame(); 426 performDictionaryLookupForSelection(frame, frame.selection().selection(), TextIndicatorPresentationTransition::BounceAndCrossfade); 427 } 428 429 DictionaryPopupInfo 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 } 393 488 394 489 #if ENABLE(PDFKIT_PLUGIN) … … 444 539 445 540 #endif 541 542 void WebPage::performDictionaryLookupForRange(Frame& frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition) 543 { 544 send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfoForRange(frame, range, options, presentationTransition))); 545 } 446 546 447 547 bool WebPage::performNonEditingBehaviorForSelector(const String& selector, KeyboardEvent* event)
Note: See TracChangeset
for help on using the changeset viewer.