Diff
Modified: trunk/Source/WebCore/ChangeLog (240020 => 240021)
--- trunk/Source/WebCore/ChangeLog 2019-01-16 01:14:21 UTC (rev 240020)
+++ trunk/Source/WebCore/ChangeLog 2019-01-16 01:19:19 UTC (rev 240021)
@@ -1,3 +1,34 @@
+2019-01-15 Megan Gardner <[email protected]>
+
+ Add Reveal support in iOSMac
+ https://bugs.webkit.org/show_bug.cgi?id=193408
+ <rdar://problem/47300699>
+
+ Reviewed by Tim Horton.
+
+ iOSMac and Reveal are currently not testable.
+
+ Add support for the reveal SPI specifically for iOSMac.
+ Show the controller when called, and implement the delegate to
+ correctly re-paint the content with the auto-generated highlight from
+ the reveal framework.
+
+ * Configurations/WebCore.xcconfig:
+ * editing/cocoa/DictionaryLookup.mm:
+ (-[WebRevealHighlight initWithHighlightRect:view:]):
+ (-[WebRevealHighlight setImage:]):
+ (-[WebRevealHighlight highlightRectsForItem:]):
+ (-[WebRevealHighlight startHighlightingItem:]):
+ (-[WebRevealHighlight highlightItem:withProgress:]):
+ (-[WebRevealHighlight completeHighlightingItem:]):
+ (-[WebRevealHighlight stopHighlightingItem:]):
+ (-[WebRevealHighlight highlightRangeChangedForItem:]):
+ (-[WebRevealHighlight highlighting]):
+ (-[WebRevealHighlight drawHighlightContentForItem:context:]):
+ (WebCore::showPopupOrCreateAnimationController):
+ (WebCore::DictionaryLookup::showPopup):
+ * editing/mac/DictionaryLookup.h:
+
2019-01-15 Myles C. Maxfield <[email protected]>
[WHLSL] Add ending namespace comments to make namespace boundaries more clear
Modified: trunk/Source/WebCore/PAL/ChangeLog (240020 => 240021)
--- trunk/Source/WebCore/PAL/ChangeLog 2019-01-16 01:14:21 UTC (rev 240020)
+++ trunk/Source/WebCore/PAL/ChangeLog 2019-01-16 01:19:19 UTC (rev 240021)
@@ -1,3 +1,15 @@
+2019-01-15 Megan Gardner <[email protected]>
+
+ Add Reveal support in iOSMac
+ https://bugs.webkit.org/show_bug.cgi?id=193408
+ <rdar://problem/47300699>
+
+ Reviewed by Tim Horton.
+
+ Add additional needed SPI.
+
+ * pal/spi/cocoa/RevealSPI.h:
+
2019-01-15 Tim Horton <[email protected]>
Cannot tab out of WKWebView on macOS
Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/RevealSPI.h (240020 => 240021)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/RevealSPI.h 2019-01-16 01:14:21 UTC (rev 240020)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/RevealSPI.h 2019-01-16 01:19:19 UTC (rev 240021)
@@ -44,9 +44,9 @@
#import <Reveal/RVPresenter.h>
#import <Reveal/Reveal.h>
#endif // PLATFORM(MAC)
+#import <RevealCore/RVItem_Private.h>
#import <RevealCore/RVSelection.h>
#import <RevealCore/RevealCore.h>
-
#else // USE(APPLE_INTERNAL_SDK)
Modified: trunk/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h (240020 => 240021)
--- trunk/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h 2019-01-16 01:14:21 UTC (rev 240020)
+++ trunk/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h 2019-01-16 01:19:19 UTC (rev 240021)
@@ -47,9 +47,10 @@
@interface UIApplication ()
+ (UIApplicationSceneClassicMode)_classicMode;
- (GSKeyboardRef)_hardwareKeyboard;
+- (CGFloat)_iOSMacScale;
@end
-#else
+#else // USE(APPLE_INTERNAL_SDK)
#import <UIKit/UIKit.h>
Modified: trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm (240020 => 240021)
--- trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm 2019-01-16 01:14:21 UTC (rev 240020)
+++ trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm 2019-01-16 01:19:19 UTC (rev 240021)
@@ -35,6 +35,7 @@
#import "FocusController.h"
#import "Frame.h"
#import "FrameSelection.h"
+#import "GraphicsContextCG.h"
#import "HTMLConverter.h"
#import "HitTestResult.h"
#import "NotImplemented.h"
@@ -45,17 +46,30 @@
#import "VisiblePosition.h"
#import "VisibleSelection.h"
#import "VisibleUnits.h"
+#import <pal/spi/cg/CoreGraphicsSPI.h>
#import <pal/spi/cocoa/RevealSPI.h>
+#import <pal/spi/ios/UIKitSPI.h>
#import <pal/spi/mac/LookupSPI.h>
#import <wtf/BlockObjCExceptions.h>
#import <wtf/RefPtr.h>
#if !PLATFORM(WATCH)
-
#import <PDFKit/PDFKit.h>
-
#endif // !PLATFORM(WATCH)
+#if PLATFORM(IOSMAC)
+extern "C" {
+#import <UIKitMacHelper/UINSRevealController.h>
+}
+SOFT_LINK_PRIVATE_FRAMEWORK(UIKitMacHelper)
+SOFT_LINK(UIKitMacHelper, UINSSharedRevealController, id<UINSRevealController>, (void), ())
+
+SOFT_LINK_FRAMEWORK(UIKit)
+SOFT_LINK_CLASS(UIKit, UIApplication)
+
+
+#endif // PLATFORM(IOSMAC)
+
#if PLATFORM(MAC)
@interface WebRevealHighlight <RVPresenterHighlightDelegate> : NSObject {
@@ -141,8 +155,109 @@
@end
-#endif // PLATFORM(MAC)
+#elif PLATFORM(IOSMAC) // PLATFORM(MAC)
+@interface WebRevealHighlight <UIRVPresenterHighlightDelegate> : NSObject {
+@private
+ RefPtr<WebCore::Image> _image;
+ CGRect _highlightRect;
+ BOOL _highlighting;
+ UIView *_view;
+}
+
+- (instancetype)initWithHighlightRect:(NSRect)highlightRect view:(UIView *)view image:(RefPtr<WebCore::Image>&&)image;
+
+@end
+
+@implementation WebRevealHighlight
+
+- (instancetype)initWithHighlightRect:(NSRect)highlightRect view:(UIView *)view image:(RefPtr<WebCore::Image>&&)image
+{
+ if (!(self = [super init]))
+ return nil;
+
+ _highlightRect = highlightRect;
+ _view = view;
+ _highlighting = NO;
+ _image = image;
+
+ return self;
+}
+
+- (void)setImage:(RefPtr<WebCore::Image>&&)image
+{
+ _image = WTFMove(image);
+}
+
+- (NSArray<NSValue *> *)highlightRectsForItem:(RVItem *)item
+{
+ UNUSED_PARAM(item);
+ return @[[NSValue valueWithCGRect:_highlightRect]];
+}
+
+- (void)startHighlightingItem:(RVItem *)item
+{
+ UNUSED_PARAM(item);
+ _highlighting = YES;
+}
+
+- (void)highlightItem:(RVItem *)item withProgress:(CGFloat)progress
+{
+ UNUSED_PARAM(item);
+ UNUSED_PARAM(progress);
+}
+
+- (void)completeHighlightingItem:(RVItem *)item
+{
+ UNUSED_PARAM(item);
+}
+
+- (void)stopHighlightingItem:(RVItem *)item
+{
+ UNUSED_PARAM(item);
+ _highlighting = NO;
+}
+
+- (void)highlightRangeChangedForItem:(RVItem *)item
+{
+ UNUSED_PARAM(item);
+}
+
+- (BOOL)highlighting
+{
+ return _highlighting;
+}
+
+- (void)drawHighlightContentForItem:(RVItem *)item context:(CGContextRef)context
+{
+ NSArray <NSValue *> *rects = [self highlightRectsForItem:item];
+ if (!rects.count)
+ return;
+
+ CGRect highlightRect = rects.firstObject.CGRectValue;
+ for (NSValue *rect in rects)
+ highlightRect = CGRectUnion(highlightRect, rect.CGRectValue);
+ highlightRect = [_view convertRect:highlightRect fromView:nil];
+
+ WebCore::CGContextStateSaver saveState(context);
+ CGAffineTransform contextTransform = CGContextGetCTM(context);
+ CGFloat backingScale = contextTransform.a;
+ CGFloat iOSMacScaleFactor = [getUIApplicationClass() sharedApplication]._iOSMacScale;
+ CGAffineTransform transform = CGAffineTransformMakeScale(iOSMacScaleFactor * backingScale, iOSMacScaleFactor * backingScale);
+ CGContextSetCTM(context, transform);
+
+ for (NSValue *v in rects) {
+ CGRect imgSrcRect = [_view convertRect:v.CGRectValue fromView:nil];
+ RetainPtr<CGImageRef> imageRef = _image->nativeImage();
+ CGRect origin = CGRectMake(imgSrcRect.origin.x - highlightRect.origin.x, imgSrcRect.origin.y - highlightRect.origin.y, highlightRect.size.width, highlightRect.size.height);
+ CGContextDrawImage(context, origin, imageRef.get());
+ }
+}
+
+@end
+
+#endif // PLATFORM(IOSMAC)
+
#endif // ENABLE(REVEAL)
namespace WebCore {
@@ -321,7 +436,7 @@
#endif // !PLATFORM(WATCH)
-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)
+static WKRevealController showPopupOrCreateAnimationController(bool createAnimationController, const DictionaryPopupInfo& dictionaryPopupInfo, RevealView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
@@ -379,8 +494,24 @@
[presenter revealItem:item.get() documentContext:nil presentingContext:context.get() options:nil];
return nil;
-#else // PLATFORM(MAC)
+#elif PLATFORM(IOSMAC)
+ UNUSED_PARAM(textIndicatorInstallationCallback);
+ UNUSED_PARAM(rootViewToViewConversionCallback);
+ UNUSED_PARAM(clearTextIndicator);
+ ASSERT_UNUSED(createAnimationController, !createAnimationController);
+
+ auto textIndicator = TextIndicator::create(dictionaryPopupInfo.textIndicator);
+
+ RetainPtr<WebRevealHighlight> webHighlight = adoptNS([[WebRevealHighlight alloc] initWithHighlightRect:[view convertRect:textIndicator->selectionRectInRootViewCoordinates() toView:nil] view:view image:textIndicator->contentImage()]);
+
+ RetainPtr<RVItem> item = adoptNS([allocRVItemInstance() initWithText:dictionaryPopupInfo.attributedString.get().string selectedRange:NSMakeRange(0, 0)]);
+
+ [UINSSharedRevealController() revealItem:item.get() locationInWindow:dictionaryPopupInfo.origin window:view.window highlighter:(id<UIRVPresenterHighlightDelegate>) webHighlight.get()];
+ return nil;
+
+#else // PLATFORM(IOS_FAMILY)
+
UNUSED_PARAM(createAnimationController);
UNUSED_PARAM(dictionaryPopupInfo);
UNUSED_PARAM(view);
@@ -389,13 +520,13 @@
UNUSED_PARAM(clearTextIndicator);
return nil;
-#endif // PLATFORM(MAC)
+#endif // PLATFORM(IOS_FAMILY)
END_BLOCK_OBJC_EXCEPTIONS;
}
-void DictionaryLookup::showPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
+void DictionaryLookup::showPopup(const DictionaryPopupInfo& dictionaryPopupInfo, RevealView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
{
showPopupOrCreateAnimationController(false, dictionaryPopupInfo, view, textIndicatorInstallationCallback, rootViewToViewConversionCallback, WTFMove(clearTextIndicator));
}
Modified: trunk/Source/WebCore/editing/mac/DictionaryLookup.h (240020 => 240021)
--- trunk/Source/WebCore/editing/mac/DictionaryLookup.h 2019-01-16 01:14:21 UTC (rev 240020)
+++ trunk/Source/WebCore/editing/mac/DictionaryLookup.h 2019-01-16 01:19:19 UTC (rev 240021)
@@ -34,12 +34,15 @@
#include <wtf/Function.h>
OBJC_CLASS NSView;
+OBJC_CLASS UIView;
OBJC_CLASS PDFSelection;
#if PLATFORM(MAC)
typedef id <NSImmediateActionAnimationController> WKRevealController;
+using RevealView = NSView;
#else
typedef id WKRevealController;
+using RevealView = UIView;
#endif // PLATFORM(MAC)
namespace WebCore {
@@ -56,7 +59,7 @@
// FIXME: Should move/unify dictionaryPopupInfoForRange here too.
- 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);
+ WEBCORE_EXPORT static void showPopup(const DictionaryPopupInfo&, RevealView *, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback = nullptr, WTF::Function<void()>&& clearTextIndicator = nullptr);
WEBCORE_EXPORT static void hidePopup();
#if PLATFORM(MAC)
Modified: trunk/Source/WebKit/ChangeLog (240020 => 240021)
--- trunk/Source/WebKit/ChangeLog 2019-01-16 01:14:21 UTC (rev 240020)
+++ trunk/Source/WebKit/ChangeLog 2019-01-16 01:19:19 UTC (rev 240021)
@@ -1,3 +1,22 @@
+2019-01-15 Megan Gardner <[email protected]>
+
+ Add Reveal support in iOSMac
+ https://bugs.webkit.org/show_bug.cgi?id=193408
+ <rdar://problem/47300699>
+
+ Reviewed by Tim Horton.
+
+ Add calls to DictionaryLookup from the appropriate places.
+
+ * UIProcess/PageClient.h:
+ * UIProcess/ios/PageClientImplIOS.h:
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::didPerformDictionaryLookup):
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::didPerformDictionaryLookup):
+ * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+ (WebKit::WebPage::dictionaryPopupInfoForRange):
+
2019-01-15 Claudio Saavedra <[email protected]>
[SOUP] Remove usage of NetworkProcess::singleton()
Modified: trunk/Source/WebKit/UIProcess/PageClient.h (240020 => 240021)
--- trunk/Source/WebKit/UIProcess/PageClient.h 2019-01-16 01:14:21 UTC (rev 240020)
+++ trunk/Source/WebKit/UIProcess/PageClient.h 2019-01-16 01:19:19 UTC (rev 240021)
@@ -304,6 +304,8 @@
virtual void setTextIndicator(Ref<WebCore::TextIndicator>, WebCore::TextIndicatorWindowLifetime) = 0;
virtual void clearTextIndicator(WebCore::TextIndicatorWindowDismissalAnimation) = 0;
virtual void setTextIndicatorAnimationProgress(float) = 0;
+
+ virtual void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&) = 0;
#endif
virtual void enterAcceleratedCompositingMode(const LayerTreeContext&) = 0;
@@ -315,7 +317,6 @@
#if PLATFORM(MAC)
virtual void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) = 0;
virtual void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState) = 0;
- virtual void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&) = 0;
virtual void showCorrectionPanel(WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) = 0;
virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingAlternativeText) = 0;
virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText) = 0;
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (240020 => 240021)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2019-01-16 01:14:21 UTC (rev 240020)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2019-01-16 01:19:19 UTC (rev 240021)
@@ -134,6 +134,8 @@
void didCommitLayerTree(const RemoteLayerTreeTransaction&) override;
void layerTreeCommitComplete() override;
+
+ void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&) override;
void couldNotRestorePageState() override;
void restorePageState(Optional<WebCore::FloatPoint>, const WebCore::FloatPoint&, const WebCore::FloatBoxExtent&, double) override;
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (240020 => 240021)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2019-01-16 01:14:21 UTC (rev 240020)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2019-01-16 01:19:19 UTC (rev 240021)
@@ -54,6 +54,7 @@
#import "WebEditCommandProxy.h"
#import "WebProcessProxy.h"
#import "_WKDownloadInternal.h"
+#import <WebCore/DictionaryLookup.h>
#import <WebCore/NotImplemented.h>
#import <WebCore/PlatformScreen.h>
#import <WebCore/PromisedAttachmentInfo.h>
@@ -453,6 +454,15 @@
{
}
+void PageClientImpl::didPerformDictionaryLookup(const DictionaryPopupInfo& dictionaryPopupInfo)
+{
+#if ENABLE(REVEAL)
+ DictionaryLookup::showPopup(dictionaryPopupInfo, m_contentView, nullptr);
+#else
+ UNUSED_PARAM(dictionaryPopupInfo);
+#endif // ENABLE(REVEAL)
+}
+
void PageClientImpl::setRemoteLayerTreeRootNode(RemoteLayerTreeNode* rootNode)
{
[m_contentView _setAcceleratedCompositingRootView:rootNode ? rootNode->uiView() : nil];
Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (240020 => 240021)
--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2019-01-16 01:14:21 UTC (rev 240020)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2019-01-16 01:19:19 UTC (rev 240021)
@@ -981,9 +981,9 @@
process().send(Messages::WebPage::SetFocusedElementSelectedIndex(index, allowMultipleSelection), m_pageID);
}
-void WebPageProxy::didPerformDictionaryLookup(const DictionaryPopupInfo&)
+void WebPageProxy::didPerformDictionaryLookup(const DictionaryPopupInfo& dictionaryPopupInfo)
{
- notImplemented();
+ pageClient().didPerformDictionaryLookup(dictionaryPopupInfo);
}
void WebPageProxy::savePDFToTemporaryFolderAndOpenWithNativeApplication(const String&, const String&, const IPC::DataReference&, const String&)
Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm (240020 => 240021)
--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2019-01-16 01:14:21 UTC (rev 240020)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2019-01-16 01:19:19 UTC (rev 240021)
@@ -175,6 +175,10 @@
dictionaryPopupInfo.attributedString = scaledNSAttributedString;
#endif // PLATFORM(MAC)
+#if PLATFORM(IOSMAC)
+ dictionaryPopupInfo.attributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:range.text()]);
+#endif // PLATFORM(IOSMAC)
+
editor.setIsGettingDictionaryPopupInfo(false);
return dictionaryPopupInfo;
}