- Revision
- 233052
- Author
- jer.no...@apple.com
- Date
- 2018-06-21 11:59:12 -0700 (Thu, 21 Jun 2018)
Log Message
[Fullscreen] Use secondary glyph style for fullscreen controls
https://bugs.webkit.org/show_bug.cgi?id=186862
<rdar://problem/41212210>
Reviewed by Tim Horton.
Source/WebCore/PAL:
* pal/spi/cocoa/AVKitSPI.h:
Source/WebKit:
Adopt AVBackgroundView, and use its predefined enums to set the material and tint styles for
the fullscreen controls.
* UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
(-[WKFullScreenViewController loadView]):
* UIProcess/ios/fullscreen/WKFullscreenStackView.h:
* UIProcess/ios/fullscreen/WKFullscreenStackView.mm:
(-[WKFullscreenStackView init]):
(-[WKFullscreenStackView dealloc]):
(-[WKFullscreenStackView addArrangedSubview:applyingMaterialStyle:tintEffectStyle:]):
(-[WKFullscreenStackView layoutSubviews]):
(+[WKFullscreenStackView baseEffects]): Deleted.
(+[WKFullscreenStackView configureView:forTintEffectWithColor:filterType:]): Deleted.
(+[WKFullscreenStackView configureView:withBackgroundFillOfColor:opacity:filter:]): Deleted.
(+[WKFullscreenStackView secondaryMaterialOverlayView]): Deleted.
(+[WKFullscreenStackView applyPrimaryGlyphTintToView:]): Deleted.
(+[WKFullscreenStackView applySecondaryGlyphTintToView:]): Deleted.
(-[WKFullscreenStackView initWithArrangedSubviews:axis:]): Deleted.
(-[WKFullscreenStackView setTargetViewForSecondaryMaterialOverlay:]): Deleted.
(-[WKFullscreenStackView contentView]): Deleted.
(-[WKFullscreenStackView _setArrangedSubviews:axis:]): Deleted.
(-[WKFullscreenStackView setBounds:]): Deleted.
(-[WKFullscreenStackView updateConstraints]): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/PAL/ChangeLog (233051 => 233052)
--- trunk/Source/WebCore/PAL/ChangeLog 2018-06-21 18:54:45 UTC (rev 233051)
+++ trunk/Source/WebCore/PAL/ChangeLog 2018-06-21 18:59:12 UTC (rev 233052)
@@ -1,3 +1,13 @@
+2018-06-21 Jer Noble <jer.no...@apple.com>
+
+ [Fullscreen] Use secondary glyph style for fullscreen controls
+ https://bugs.webkit.org/show_bug.cgi?id=186862
+ <rdar://problem/41212210>
+
+ Reviewed by Tim Horton.
+
+ * pal/spi/cocoa/AVKitSPI.h:
+
2018-06-15 Jonathan Bedard <jbed...@apple.com>
Complex text handling should opt out of bounded text layout (follow-up fix)
Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/AVKitSPI.h (233051 => 233052)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/AVKitSPI.h 2018-06-21 18:54:45 UTC (rev 233051)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/AVKitSPI.h 2018-06-21 18:59:12 UTC (rev 233052)
@@ -33,6 +33,7 @@
#if USE(APPLE_INTERNAL_SDK)
+#import <AVKit/AVBackgroundView.h>
#import <AVKit/AVPlayerController.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-property-no-attribute"
@@ -90,6 +91,21 @@
#else
+NS_ASSUME_NONNULL_BEGIN
+
+@interface AVBackgroundView : UIView
+@property (nonatomic) BOOL automaticallyDrawsRoundedCorners;
+typedef NS_ENUM(NSInteger, AVBackgroundViewMaterialStyle) {
+ AVBackgroundViewMaterialStylePrimary,
+ AVBackgroundViewMaterialStyleSecondary
+};
+typedef NS_ENUM(NSInteger, AVBackgroundViewTintEffectStyle) {
+ AVBackgroundViewTintEffectStylePrimary,
+ AVBackgroundViewTintEffectStyleSecondary
+};
+- (void)addSubview:(UIView *)subview applyingMaterialStyle:(AVBackgroundViewMaterialStyle)materialStyle tintEffectStyle:(AVBackgroundViewTintEffectStyle)tintEffectStyle;
+@end
+
@interface AVPlayerController : UIResponder
@end
@@ -108,8 +124,6 @@
@property (NS_NONATOMIC_IOSONLY, readonly) AVPlayerControllerStatus status;
@end
-NS_ASSUME_NONNULL_BEGIN
-
@class AVPlayerLayer;
@interface AVPictureInPicturePlayerLayerView : UIView
Modified: trunk/Source/WebKit/ChangeLog (233051 => 233052)
--- trunk/Source/WebKit/ChangeLog 2018-06-21 18:54:45 UTC (rev 233051)
+++ trunk/Source/WebKit/ChangeLog 2018-06-21 18:59:12 UTC (rev 233052)
@@ -1,5 +1,37 @@
2018-06-21 Jer Noble <jer.no...@apple.com>
+ [Fullscreen] Use secondary glyph style for fullscreen controls
+ https://bugs.webkit.org/show_bug.cgi?id=186862
+ <rdar://problem/41212210>
+
+ Reviewed by Tim Horton.
+
+ Adopt AVBackgroundView, and use its predefined enums to set the material and tint styles for
+ the fullscreen controls.
+
+ * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
+ (-[WKFullScreenViewController loadView]):
+ * UIProcess/ios/fullscreen/WKFullscreenStackView.h:
+ * UIProcess/ios/fullscreen/WKFullscreenStackView.mm:
+ (-[WKFullscreenStackView init]):
+ (-[WKFullscreenStackView dealloc]):
+ (-[WKFullscreenStackView addArrangedSubview:applyingMaterialStyle:tintEffectStyle:]):
+ (-[WKFullscreenStackView layoutSubviews]):
+ (+[WKFullscreenStackView baseEffects]): Deleted.
+ (+[WKFullscreenStackView configureView:forTintEffectWithColor:filterType:]): Deleted.
+ (+[WKFullscreenStackView configureView:withBackgroundFillOfColor:opacity:filter:]): Deleted.
+ (+[WKFullscreenStackView secondaryMaterialOverlayView]): Deleted.
+ (+[WKFullscreenStackView applyPrimaryGlyphTintToView:]): Deleted.
+ (+[WKFullscreenStackView applySecondaryGlyphTintToView:]): Deleted.
+ (-[WKFullscreenStackView initWithArrangedSubviews:axis:]): Deleted.
+ (-[WKFullscreenStackView setTargetViewForSecondaryMaterialOverlay:]): Deleted.
+ (-[WKFullscreenStackView contentView]): Deleted.
+ (-[WKFullscreenStackView _setArrangedSubviews:axis:]): Deleted.
+ (-[WKFullscreenStackView setBounds:]): Deleted.
+ (-[WKFullscreenStackView updateConstraints]): Deleted.
+
+2018-06-21 Jer Noble <jer.no...@apple.com>
+
[Fullscreen] Suspend page (and pause video) while phishing warning is presented
https://bugs.webkit.org/show_bug.cgi?id=186856
<rdar://problem/41212444>
Modified: trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm (233051 => 233052)
--- trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm 2018-06-21 18:54:45 UTC (rev 233051)
+++ trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm 2018-06-21 18:59:12 UTC (rev 233052)
@@ -36,6 +36,7 @@
#import "WebFullScreenManagerProxy.h"
#import "WebPageProxy.h"
#import <WebCore/LocalizedStrings.h>
+#import <pal/spi/cocoa/AVKitSPI.h>
#import <wtf/RetainPtr.h>
using namespace WebCore;
@@ -245,7 +246,6 @@
[_cancelButton setTranslatesAutoresizingMaskIntoConstraints:NO];
[_cancelButton setAdjustsImageWhenHighlighted:NO];
[_cancelButton setExtrinsicContentSize:CGSizeMake(60.0, 47.0)];
- [WKFullscreenStackView applyPrimaryGlyphTintToView:_cancelButton.get()];
NSBundle *bundle = [NSBundle bundleForClass:self.class];
UIImage *doneImage = [UIImage imageNamed:@"Done" inBundle:bundle compatibleWithTraitCollection:nil];
[_cancelButton setImage:[doneImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
@@ -257,7 +257,6 @@
[_pipButton setTranslatesAutoresizingMaskIntoConstraints:NO];
[_pipButton setAdjustsImageWhenHighlighted:NO];
[_pipButton setExtrinsicContentSize:CGSizeMake(60.0, 47.0)];
- [WKFullscreenStackView applyPrimaryGlyphTintToView:_pipButton.get()];
UIImage *startPiPImage = [UIImage imageNamed:@"StartPictureInPictureButton" inBundle:bundle compatibleWithTraitCollection:nil];
UIImage *stopPiPImage = [UIImage imageNamed:@"StopPictureInPictureButton" inBundle:bundle compatibleWithTraitCollection:nil];
[_pipButton setImage:[startPiPImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
@@ -266,9 +265,10 @@
[_pipButton sizeToFit];
[_pipButton addTarget:self action:@selector(_togglePiPAction:) forControlEvents:UIControlEventTouchUpInside];
- _stackView = adoptNS([[WKFullscreenStackView alloc] initWithArrangedSubviews:@[_cancelButton.get(), _pipButton.get()] axis:UILayoutConstraintAxisHorizontal]);
+ _stackView = adoptNS([[WKFullscreenStackView alloc] init]);
[_stackView setTranslatesAutoresizingMaskIntoConstraints:NO];
- [_stackView setTargetViewForSecondaryMaterialOverlay:_cancelButton.get()];
+ [_stackView addArrangedSubview:_cancelButton.get() applyingMaterialStyle:AVBackgroundViewMaterialStyleSecondary tintEffectStyle:AVBackgroundViewTintEffectStyleSecondary];
+ [_stackView addArrangedSubview:_pipButton.get() applyingMaterialStyle:AVBackgroundViewMaterialStylePrimary tintEffectStyle:AVBackgroundViewTintEffectStyleSecondary];
[[self view] addSubview:_stackView.get()];
UILayoutGuide *safeArea = self.view.safeAreaLayoutGuide;
Modified: trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullscreenStackView.h (233051 => 233052)
--- trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullscreenStackView.h 2018-06-21 18:54:45 UTC (rev 233051)
+++ trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullscreenStackView.h 2018-06-21 18:59:12 UTC (rev 233052)
@@ -28,17 +28,12 @@
#if ENABLE(FULLSCREEN_API) && PLATFORM(IOS)
#import <UIKit/UIView.h>
+#import <pal/spi/cocoa/AVKitSPI.h>
NS_ASSUME_NONNULL_BEGIN
-@interface WKFullscreenStackView : UIView
-+ (void)applyPrimaryGlyphTintToView:(UIView *)view;
-+ (void)applySecondaryGlyphTintToView:(UIView *)view;
-
-- (instancetype)initWithArrangedSubviews:(NSArray<UIView *> *)arrangedSubviews axis:(UILayoutConstraintAxis)axis;
-
-@property (nonatomic, retain, nullable) UIView *targetViewForSecondaryMaterialOverlay;
-@property (nonatomic, readonly) UIView *contentView;
+@interface WKFullscreenStackView : UIStackView
+- (void)addArrangedSubview:(UIView *)subview applyingMaterialStyle:(AVBackgroundViewMaterialStyle)materialStyle tintEffectStyle:(AVBackgroundViewTintEffectStyle)tintEffectStyle;
@end
NS_ASSUME_NONNULL_END
Modified: trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullscreenStackView.mm (233051 => 233052)
--- trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullscreenStackView.mm 2018-06-21 18:54:45 UTC (rev 233051)
+++ trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullscreenStackView.mm 2018-06-21 18:59:12 UTC (rev 233052)
@@ -31,215 +31,52 @@
#import "UIKitSPI.h"
#import <QuartzCore/CAFilter.h>
#import <UIKit/UIVisualEffectView.h>
+#import <pal/cf/CoreMediaSoftLink.h>
#import <wtf/NeverDestroyed.h>
#import <wtf/RetainPtr.h>
-static NSArray<UIVisualEffect *>* reducedTransparencyEffects()
-{
- static NeverDestroyed<RetainPtr<NSArray<UIVisualEffect *>>> effects;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- effects.get() = @[[UIVisualEffect effectCompositingColor:[UIColor colorWithRed:(43.0 / 255.0) green:(46.0 / 255.0) blue:(48.0 / 255.0) alpha:1.0] withMode:UICompositingModeNormal alpha:1.0]];
- });
- return effects.get().get();
-}
+SOFTLINK_AVKIT_FRAMEWORK()
+SOFT_LINK_CLASS_OPTIONAL(AVKit, AVBackgroundView)
-static NSArray<UIVisualEffect *>* normalTransparencyEffects()
-{
- static NeverDestroyed<RetainPtr<NSArray<UIVisualEffect *>>> effects;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- effects.get() = @[
- [UIVisualEffect effectCompositingColor:[UIColor blackColor] withMode:UICompositingModeNormal alpha:0.55],
- [UIBlurEffect effectWithBlurRadius:UIRoundToScreenScale(17.5, [UIScreen mainScreen])],
- [UIColorEffect colorEffectSaturate:1.8],
- [UIVisualEffect effectCompositingColor:[UIColor whiteColor] withMode:UICompositingModeNormal alpha:0.14]
- ];
- });
- return effects.get().get();
+@interface WKFullscreenStackView () {
+ RetainPtr<AVBackgroundView> _backgroundView;
}
-
-@interface UIVisualEffectView (WebKitPrivate)
-@property (nonatomic, readwrite, copy) NSArray<UIVisualEffect *> *backgroundEffects;
@end
-@interface WKFullscreenStackView ()
-@property (nonatomic, readonly) UIStackView *_stackView;
-@property (nonatomic, readonly) UIVisualEffectView *_visualEffectView;
-@property (nonatomic, assign) UIVisualEffectView *secondaryMaterialOverlayView;
-@property (nonatomic, retain) NSArray<NSLayoutConstraint *> *secondaryMaterialOverlayViewConstraints;
-@end
-
@implementation WKFullscreenStackView
-#pragma mark - Class Methods
-+ (NSArray<UIVisualEffect *> *)baseEffects
-{
- if (UIAccessibilityIsReduceTransparencyEnabled())
- return reducedTransparencyEffects();
- return normalTransparencyEffects();
-}
-
-+ (void)configureView:(UIView *)view forTintEffectWithColor:(UIColor *)tintColor filterType:(NSString *)filterType
-{
- if ([view isKindOfClass:[UILabel class]]) {
- [(UILabel *)view setTextColor:tintColor];
- [view setTintColor:tintColor];
- [[view layer] setCompositingFilter:[CAFilter filterWithType:kCAFilterPlusL]];
- return;
- }
-
- _UIVisualEffectTintLayerConfig *tintLayerConfig = [_UIVisualEffectTintLayerConfig layerWithTintColor:tintColor filterType:filterType];
- [[[_UIVisualEffectConfig configWithContentConfig:tintLayerConfig] contentConfig] configureLayerView:view];
-}
-
-+ (void)configureView:(UIView *)view withBackgroundFillOfColor:(UIColor *)fillColor opacity:(CGFloat)opacity filter:(NSString *)filter
-{
- _UIVisualEffectLayerConfig *baseLayerConfig = [_UIVisualEffectLayerConfig layerWithFillColor:fillColor opacity:opacity filterType:filter];
- [[[_UIVisualEffectConfig configWithContentConfig:baseLayerConfig] contentConfig] configureLayerView:view];
-}
-
-+ (UIVisualEffectView *)secondaryMaterialOverlayView
-{
- UIVisualEffectView *secondaryMaterialOverlayView = [[UIVisualEffectView alloc] initWithEffect:nil];
- [secondaryMaterialOverlayView setUserInteractionEnabled:NO];
- [secondaryMaterialOverlayView setBackgroundEffects:@[[UIVisualEffect effectCompositingColor:[UIColor blackColor] withMode:UICompositingModePlusDarker alpha:0.06]]];
- return [secondaryMaterialOverlayView autorelease];
-}
-
#pragma mark - External Interface
-+ (void)applyPrimaryGlyphTintToView:(UIView *)view
+- (instancetype)init
{
- [self configureView:view forTintEffectWithColor:[UIColor colorWithWhite:1.0 alpha:0.75] filterType:kCAFilterPlusL];
-}
+ CGRect frame = CGRectMake(0, 0, 100, 100);
+ self = [self initWithFrame:frame];
-+ (void)applySecondaryGlyphTintToView:(UIView *)view
-{
- [self configureView:view forTintEffectWithColor:[UIColor colorWithWhite:1.0 alpha:0.55] filterType:kCAFilterPlusL];
-}
-
-- (instancetype)initWithArrangedSubviews:(NSArray<UIView *> *)arrangedSubviews axis:(UILayoutConstraintAxis)axis
-{
- self = [self initWithFrame:CGRectMake(0, 0, 100, 100)];
-
if (!self)
return nil;
[self setClipsToBounds:YES];
- _visualEffectView = [[UIVisualEffectView alloc] initWithEffect:nil];
- [self addSubview:_visualEffectView];
- [_visualEffectView setBackgroundEffects:[[self class] baseEffects]];
+ _backgroundView = adoptNS([allocAVBackgroundViewInstance() initWithFrame:frame]);
+ [self addSubview:_backgroundView.get()];
- _stackView = [[UIStackView alloc] initWithArrangedSubviews:arrangedSubviews];
- [_stackView setAxis:axis];
- [_stackView setLayoutMarginsRelativeArrangement:YES];
- [_stackView setInsetsLayoutMarginsFromSafeArea:NO];
- [self insertSubview:_stackView above:_visualEffectView];
-
- [self _setArrangedSubviews:arrangedSubviews axis:axis];
-
return self;
}
-- (void)dealloc
+- (void)addArrangedSubview:(UIView *)subview applyingMaterialStyle:(AVBackgroundViewMaterialStyle)materialStyle tintEffectStyle:(AVBackgroundViewTintEffectStyle)tintEffectStyle
{
- [_targetViewForSecondaryMaterialOverlay release];
- [_visualEffectView release];
- [_stackView release];
- [_secondaryMaterialOverlayViewConstraints release];
- [super dealloc];
+ [_backgroundView.get() addSubview:subview applyingMaterialStyle:materialStyle tintEffectStyle:tintEffectStyle];
+ [self addArrangedSubview:subview];
}
-- (void)setTargetViewForSecondaryMaterialOverlay:(UIView *)targetViewForSecondaryMaterialOverlay
-{
- if (_targetViewForSecondaryMaterialOverlay == targetViewForSecondaryMaterialOverlay)
- return;
-
- _targetViewForSecondaryMaterialOverlay = [targetViewForSecondaryMaterialOverlay retain];
- [self setNeedsUpdateConstraints];
-}
-
-- (UIView *)contentView
-{
- return [_visualEffectView contentView];
-}
-
-#pragma mark - Internal Interface
-
-@synthesize _stackView=_stackView;
-@synthesize _visualEffectView=_visualEffectView;
-
-- (void)_setArrangedSubviews:(NSArray<UIView *> *)arrangedSubviews axis:(UILayoutConstraintAxis)axis
-{
- for (UIView *view in [_stackView arrangedSubviews])
- [view removeFromSuperview];
-
- for (UIView *view in arrangedSubviews)
- [_stackView addArrangedSubview:view];
-
- [_stackView setAxis:axis];
-}
-
#pragma mark - UIView Overrides
-- (void)setBounds:(CGRect)bounds
+- (void)layoutSubviews
{
- CGSize oldSize = [self bounds].size;
-
- [super setBounds:bounds];
-
- if (!CGSizeEqualToSize(oldSize, bounds.size))
- [self _setContinuousCornerRadius:((CGRectGetHeight(bounds) > 40.0) ? 16.0 : 8.0)];
+ [_backgroundView.get() setFrame:self.bounds];
+ [super layoutSubviews];
}
-- (void)updateConstraints
-{
- if ([_stackView translatesAutoresizingMaskIntoConstraints] || [_visualEffectView translatesAutoresizingMaskIntoConstraints]) {
- [_visualEffectView setTranslatesAutoresizingMaskIntoConstraints:NO];
- [_stackView setTranslatesAutoresizingMaskIntoConstraints:NO];
-
- NSArray<NSLayoutConstraint *> *constraints = @[
- [[_visualEffectView leadingAnchor] constraintEqualToAnchor:[self leadingAnchor]],
- [[_visualEffectView topAnchor] constraintEqualToAnchor:[self topAnchor]],
- [[_visualEffectView trailingAnchor] constraintEqualToAnchor:[self trailingAnchor]],
- [[_visualEffectView bottomAnchor] constraintEqualToAnchor:[self bottomAnchor]],
- [[_stackView leadingAnchor] constraintEqualToAnchor:[self leadingAnchor]],
- [[_stackView topAnchor] constraintEqualToAnchor:[self topAnchor]],
- [[_stackView trailingAnchor] constraintEqualToAnchor:[self trailingAnchor]],
- [[_stackView bottomAnchor] constraintEqualToAnchor:[self bottomAnchor]],
- ];
-
- for (NSLayoutConstraint *constraint in constraints)
- [constraint setPriority:(UILayoutPriorityRequired - 1)];
-
- [NSLayoutConstraint activateConstraints:constraints];
- }
-
- if ([[self targetViewForSecondaryMaterialOverlay] isDescendantOfView:self]) {
- if (!_secondaryMaterialOverlayView) {
- [self setSecondaryMaterialOverlayView:[[self class] secondaryMaterialOverlayView]];
- [self addSubview:[self secondaryMaterialOverlayView]];
- }
-
- if ([[self secondaryMaterialOverlayView] isDescendantOfView:self] && !_secondaryMaterialOverlayViewConstraints) {
- [[self secondaryMaterialOverlayView] setTranslatesAutoresizingMaskIntoConstraints:NO];
- NSArray<NSLayoutConstraint *> *constraints = @[
- [[_secondaryMaterialOverlayView centerXAnchor] constraintEqualToAnchor:[_targetViewForSecondaryMaterialOverlay centerXAnchor]],
- [[_secondaryMaterialOverlayView centerYAnchor] constraintEqualToAnchor:[_targetViewForSecondaryMaterialOverlay centerYAnchor]],
- [[_secondaryMaterialOverlayView widthAnchor] constraintEqualToAnchor:[_targetViewForSecondaryMaterialOverlay widthAnchor]],
- [[_secondaryMaterialOverlayView heightAnchor] constraintEqualToAnchor:[_targetViewForSecondaryMaterialOverlay heightAnchor]]
- ];
- [self setSecondaryMaterialOverlayViewConstraints:constraints];
- [NSLayoutConstraint activateConstraints:[self secondaryMaterialOverlayViewConstraints]];
- }
- } else
- [_secondaryMaterialOverlayView removeFromSuperview];
-
- [super updateConstraints];
-}
-
@end
#endif // ENABLE(FULLSCREEN_API) && PLATFORM(IOS)