Title: [209050] trunk/Source/WebCore
Revision
209050
Author
cdu...@apple.com
Date
2016-11-28 17:08:46 -0800 (Mon, 28 Nov 2016)

Log Message

[iOS] Use UIKit SPI to force popover presentation style on iPhone for html validation popovers
https://bugs.webkit.org/show_bug.cgi?id=165107

Reviewed by Simon Fraser.

Use UIKit SPI to force popover presentation style on iPhone for html validation
popovers as this results in simpler code and achieves the same behavior.

* platform/ValidationBubble.h:
* platform/ios/ValidationBubbleIOS.mm:
(WebCore::ValidationBubble::setAnchorRect):
(-[WebValidationBubbleDelegate adaptivePresentationStyleForPresentationController:traitCollection:]): Deleted.
* platform/spi/ios/UIKitSPI.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (209049 => 209050)


--- trunk/Source/WebCore/ChangeLog	2016-11-29 01:08:29 UTC (rev 209049)
+++ trunk/Source/WebCore/ChangeLog	2016-11-29 01:08:46 UTC (rev 209050)
@@ -1,5 +1,21 @@
 2016-11-28  Chris Dumez  <cdu...@apple.com>
 
+        [iOS] Use UIKit SPI to force popover presentation style on iPhone for html validation popovers
+        https://bugs.webkit.org/show_bug.cgi?id=165107
+
+        Reviewed by Simon Fraser.
+
+        Use UIKit SPI to force popover presentation style on iPhone for html validation
+        popovers as this results in simpler code and achieves the same behavior.
+
+        * platform/ValidationBubble.h:
+        * platform/ios/ValidationBubbleIOS.mm:
+        (WebCore::ValidationBubble::setAnchorRect):
+        (-[WebValidationBubbleDelegate adaptivePresentationStyleForPresentationController:traitCollection:]): Deleted.
+        * platform/spi/ios/UIKitSPI.h:
+
+2016-11-28  Chris Dumez  <cdu...@apple.com>
+
         [Mac] Clicking on an HTML validation bubble should dismiss it
         https://bugs.webkit.org/show_bug.cgi?id=165117
         <rdar://problem/29409837>

Modified: trunk/Source/WebCore/platform/ValidationBubble.h (209049 => 209050)


--- trunk/Source/WebCore/platform/ValidationBubble.h	2016-11-29 01:08:29 UTC (rev 209049)
+++ trunk/Source/WebCore/platform/ValidationBubble.h	2016-11-29 01:08:46 UTC (rev 209050)
@@ -37,7 +37,6 @@
 OBJC_CLASS NSPopover;
 #elif PLATFORM(IOS)
 OBJC_CLASS UIViewController;
-OBJC_CLASS WebValidationBubbleDelegate;
 #endif
 
 #if PLATFORM(MAC)
@@ -73,7 +72,6 @@
     RetainPtr<NSPopover> m_popover;
 #elif PLATFORM(IOS)
     RetainPtr<UIViewController> m_popoverController;
-    RetainPtr<WebValidationBubbleDelegate> m_popoverDelegate;
     UIViewController *m_presentingViewController;
 #endif
 };

Modified: trunk/Source/WebCore/platform/ios/ValidationBubbleIOS.mm (209049 => 209050)


--- trunk/Source/WebCore/platform/ios/ValidationBubbleIOS.mm	2016-11-29 01:08:29 UTC (rev 209049)
+++ trunk/Source/WebCore/platform/ios/ValidationBubbleIOS.mm	2016-11-29 01:08:46 UTC (rev 209050)
@@ -34,25 +34,10 @@
 
 SOFT_LINK_FRAMEWORK(UIKit);
 SOFT_LINK_CLASS(UIKit, UILabel);
+SOFT_LINK_CLASS(UIKit, UIPopoverPresentationController);
 SOFT_LINK_CLASS(UIKit, UIView);
 SOFT_LINK_CLASS(UIKit, UIViewController);
 
-@interface WebValidationBubbleDelegate : NSObject <UIPopoverPresentationControllerDelegate> {
-}
-@end
-
-@implementation WebValidationBubbleDelegate
-
-- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection
-{
-    UNUSED_PARAM(controller);
-    UNUSED_PARAM(traitCollection);
-    // This is needed to force UIKit to use a popover on iPhone as well.
-    return UIModalPresentationNone;
-}
-
-@end
-
 namespace WebCore {
 
 static const CGFloat horizontalPadding = 8;
@@ -95,8 +80,8 @@
 void ValidationBubble::setAnchorRect(const IntRect& anchorRect, UIViewController* presentingViewController)
 {
     UIPopoverPresentationController *presentationController = [m_popoverController popoverPresentationController];
-    m_popoverDelegate = adoptNS([[WebValidationBubbleDelegate alloc] init]);
-    presentationController.delegate = m_popoverDelegate.get();
+    // This is needed to force UIKit to use a popover on iPhone as well.
+    [getUIPopoverPresentationControllerClass() _setAlwaysAllowPopoverPresentations:YES];
     presentationController.passthroughViews = [NSArray arrayWithObjects:presentingViewController.view, m_view, nil];
 
     presentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;

Modified: trunk/Source/WebCore/platform/spi/ios/UIKitSPI.h (209049 => 209050)


--- trunk/Source/WebCore/platform/spi/ios/UIKitSPI.h	2016-11-29 01:08:29 UTC (rev 209049)
+++ trunk/Source/WebCore/platform/spi/ios/UIKitSPI.h	2016-11-29 01:08:46 UTC (rev 209050)
@@ -27,6 +27,7 @@
 
 #import <UIKit/UIApplication_Private.h>
 #import <UIKit/UIInterface_Private.h>
+#import <UIKit/UIPopoverPresentationController_Private.h>
 #import <UIKit/UIScreen_Private.h>
 
 #else
@@ -57,4 +58,10 @@
 
 @end
 
+@interface UIPopoverPresentationController()
+
++ (void)_setAlwaysAllowPopoverPresentations:(BOOL)flag;
+
+@end
+
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to