Title: [295607] trunk/Source
- Revision
- 295607
- Author
- [email protected]
- Date
- 2022-06-16 13:00:12 -0700 (Thu, 16 Jun 2022)
Log Message
Implement alternate fullscreen controls.
https://bugs.webkit.org/show_bug.cgi?id=241654
Reviewed by Tim Horton.
Alternative UI for fullscreen video controls.
* Source/WTF/Scripts/Preferences/WebPreferences.yaml:
* Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
(-[WKFullScreenViewController loadView]):
Canonical link: https://commits.webkit.org/251612@main
Modified Paths
Diff
Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml (295606 => 295607)
--- trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml 2022-06-16 19:51:36 UTC (rev 295606)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml 2022-06-16 20:00:12 UTC (rev 295607)
@@ -231,6 +231,18 @@
default: false
WebCore:
default: false
+
+AlternateFullScreenControlDesignEnabled:
+ type: bool
+ condition: PLATFORM(IOS_FAMILY)
+ defaultValue:
+ WebKitLegacy:
+ default: false
+ WebKit:
+ "HAVE(UIKIT_WEBKIT_INTERNALS)": true
+ default: false
+ WebCore:
+ default: false
AnimatedImageAsyncDecodingEnabled:
type: bool
Modified: trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm (295606 => 295607)
--- trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm 2022-06-16 19:51:36 UTC (rev 295606)
+++ trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm 2022-06-16 20:00:12 UTC (rev 295607)
@@ -115,7 +115,7 @@
BOOL _valid;
RetainPtr<UILongPressGestureRecognizer> _touchGestureRecognizer;
RetainPtr<UIView> _animatingView;
- RetainPtr<WKFullscreenStackView> _stackView;
+ RetainPtr<UIStackView> _stackView;
RetainPtr<_WKExtrinsicButton> _cancelButton;
RetainPtr<_WKExtrinsicButton> _pipButton;
RetainPtr<UIButton> _locationButton;
@@ -314,6 +314,25 @@
- (void)loadView
{
+ CGSize buttonSize;
+ UIImage *doneImage;
+ UIImage *startPiPImage;
+ UIImage *stopPiPImage;
+ auto fullScreenControlDesignEnabled = self._webView._page->preferences().alternateFullScreenControlDesignEnabled();
+
+ if (fullScreenControlDesignEnabled) {
+ buttonSize = CGSizeMake(38.0, 38.0);
+ doneImage = [UIImage systemImageNamed:@"arrow.down.right.and.arrow.up.left"];
+ startPiPImage = [UIImage systemImageNamed:@"pip.enter"];
+ stopPiPImage = [UIImage systemImageNamed:@"pip.exit"];
+ } else {
+ buttonSize = CGSizeMake(60.0, 47.0);
+ NSBundle *bundle = [NSBundle bundleForClass:self.class];
+ doneImage = [UIImage imageNamed:@"Done" inBundle:bundle compatibleWithTraitCollection:nil];
+ startPiPImage = [UIImage imageNamed:@"StartPictureInPictureButton" inBundle:bundle compatibleWithTraitCollection:nil];
+ stopPiPImage = [UIImage imageNamed:@"StopPictureInPictureButton" inBundle:bundle compatibleWithTraitCollection:nil];
+ }
+
[self setView:adoptNS([[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]).get()];
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.view.backgroundColor = [UIColor blackColor];
@@ -327,9 +346,8 @@
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
[_cancelButton setAdjustsImageWhenHighlighted:NO];
ALLOW_DEPRECATED_DECLARATIONS_END
- [_cancelButton setExtrinsicContentSize:CGSizeMake(60.0, 47.0)];
- NSBundle *bundle = [NSBundle bundleForClass:self.class];
- UIImage *doneImage = [UIImage imageNamed:@"Done" inBundle:bundle compatibleWithTraitCollection:nil];
+ [_cancelButton setExtrinsicContentSize:buttonSize];
+
[_cancelButton setImage:[doneImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
[_cancelButton setTintColor:[UIColor whiteColor]];
[_cancelButton sizeToFit];
@@ -340,9 +358,8 @@
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
[_pipButton setAdjustsImageWhenHighlighted:NO];
ALLOW_DEPRECATED_DECLARATIONS_END
- [_pipButton setExtrinsicContentSize:CGSizeMake(60.0, 47.0)];
- UIImage *startPiPImage = [UIImage imageNamed:@"StartPictureInPictureButton" inBundle:bundle compatibleWithTraitCollection:nil];
- UIImage *stopPiPImage = [UIImage imageNamed:@"StopPictureInPictureButton" inBundle:bundle compatibleWithTraitCollection:nil];
+ [_pipButton setExtrinsicContentSize:buttonSize];
+
[_pipButton setImage:[startPiPImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
[_pipButton setImage:[stopPiPImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateSelected];
[_pipButton setTintColor:[UIColor whiteColor]];
@@ -349,11 +366,31 @@
[_pipButton sizeToFit];
[_pipButton addTarget:self action:@selector(_togglePiPAction:) forControlEvents:UIControlEventTouchUpInside];
- _stackView = adoptNS([[WKFullscreenStackView alloc] init]);
+ if (fullScreenControlDesignEnabled) {
+
+ UIButtonConfiguration *cancelButtonConfiguration = [UIButtonConfiguration filledButtonConfiguration];
+ // FIXME: this color specification should not be necessary.
+ cancelButtonConfiguration.baseBackgroundColor = [UIColor colorWithWhite:1.0 alpha:0.15];
+ [_cancelButton setConfiguration:cancelButtonConfiguration];
+
+ UIButtonConfiguration *pipButtonConfiguration = [UIButtonConfiguration filledButtonConfiguration];
+ // FIXME: this color specification should not be necessary.
+ pipButtonConfiguration.baseBackgroundColor = [UIColor colorWithWhite:1.0 alpha:0.15];
+ [_pipButton setConfiguration:pipButtonConfiguration];
+
+ _stackView = adoptNS([[UIStackView alloc] init]);
+ [_stackView addArrangedSubview:_cancelButton.get()];
+ [_stackView addArrangedSubview:_pipButton.get()];
+ [_stackView setSpacing:24.0];
+ } else {
+ RetainPtr<WKFullscreenStackView> stackView = adoptNS([[WKFullscreenStackView alloc] init]);
+ [stackView addArrangedSubview:_cancelButton.get() applyingMaterialStyle:AVBackgroundViewMaterialStyleSecondary tintEffectStyle:AVBackgroundViewTintEffectStyleSecondary];
+ [stackView addArrangedSubview:_pipButton.get() applyingMaterialStyle:AVBackgroundViewMaterialStylePrimary tintEffectStyle:AVBackgroundViewTintEffectStyleSecondary];
+ _stackView = WTFMove(stackView);
+ }
+
[_stackView setTranslatesAutoresizingMaskIntoConstraints:NO];
- [_stackView addArrangedSubview:_cancelButton.get() applyingMaterialStyle:AVBackgroundViewMaterialStyleSecondary tintEffectStyle:AVBackgroundViewTintEffectStyleSecondary];
- [_stackView addArrangedSubview:_pipButton.get() applyingMaterialStyle:AVBackgroundViewMaterialStylePrimary tintEffectStyle:AVBackgroundViewTintEffectStyleSecondary];
- [_animatingView addSubview:_stackView.get()];
+ [_animatingView addSubview:_stackView.get()];
UILayoutGuide *safeArea = self.view.safeAreaLayoutGuide;
UILayoutGuide *margins = self.view.layoutMarginsGuide;
@@ -360,11 +397,16 @@
_topGuide = adoptNS([[UILayoutGuide alloc] init]);
[self.view addLayoutGuide:_topGuide.get()];
- NSLayoutAnchor *topAnchor = [_topGuide topAnchor];
+ NSLayoutYAxisAnchor *topAnchor = [_topGuide topAnchor];
+ NSLayoutConstraint *stackViewToTopGuideConstraint;
+ if (fullScreenControlDesignEnabled)
+ stackViewToTopGuideConstraint = [[_stackView topAnchor] constraintEqualToSystemSpacingBelowAnchor:topAnchor multiplier:2];
+ else
+ stackViewToTopGuideConstraint = [topAnchor constraintEqualToAnchor:topAnchor];
_topConstraint = [topAnchor constraintEqualToAnchor:safeArea.topAnchor];
[NSLayoutConstraint activateConstraints:@[
_topConstraint.get(),
- [[_stackView topAnchor] constraintEqualToAnchor:topAnchor],
+ stackViewToTopGuideConstraint,
[[_stackView leadingAnchor] constraintEqualToAnchor:margins.leadingAnchor],
]];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes