Skip to content

Commit

Permalink
[watchOS] Text input list view controller is not legible when present…
Browse files Browse the repository at this point in the history
…ed over a transparent background

https://bugs.webkit.org/show_bug.cgi?id=270821
rdar://118537615

Reviewed by Abrar Rahman Protyasha and Tim Horton.

Explicitly set the input view controllers' views' background colors to be `+systemBackgroundColor`.
Currently, these views are transparent, which works well in practice (since they present over a
black background anyways), but for certain clients that use a transparent background, this can cause
system UI to show up from behind the input view controllers.

* Source/WebKit/Platform/spi/watchos/PepperUICoreSPI.h:

Drive-by fix: remove some dead code, now that `-listView` is no longer implemented by the base
class when presenting a single or multi-select menu. Instead, reloading the `-collectionView` is
sufficient.

* Source/WebKit/UIProcess/ios/forms/WKDatePickerViewController.mm:
(-[WKDatePickerViewController viewDidLoad]):
* Source/WebKit/UIProcess/ios/forms/WKNumberPadViewController.mm:
(-[WKNumberPadViewController viewDidLoad]):
* Source/WebKit/UIProcess/ios/forms/WKSelectMenuListViewController.mm:
(-[WKSelectMenuListViewController viewDidLoad]):
(-[WKSelectMenuListViewController didSelectListItemAtIndexPath:]):
(-[WKSelectMenuListViewController cellForListItem:]): Deleted.
* Source/WebKit/UIProcess/ios/forms/WKTextInputListViewController.mm:
(-[WKTextInputListViewController viewDidLoad]):
* Source/WebKit/UIProcess/ios/forms/WKTimePickerViewController.mm:
(-[WKTimePickerViewController viewDidLoad]):

Canonical link: https://commits.webkit.org/275947@main
  • Loading branch information
whsieh committed Mar 12, 2024
1 parent fc415ab commit 3218bc2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 33 deletions.
1 change: 0 additions & 1 deletion Source/WebKit/Platform/spi/watchos/PepperUICoreSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ extern UIButtonType const PUICButtonTypePill;
#endif

@interface PUICQuickboardListViewController : PUICQuickboardViewController
@property (nonatomic, readonly) PUICTableView *listView;
@property (strong, nonatomic, readonly) PUICQuickboardListViewSpecs *specs;
@property (nonatomic, copy) UITextContentType textContentType;
@property (nonatomic, strong) PUICTextInputContext *textInputContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ - (void)viewDidLoad
{
[super viewDidLoad];

self.view.backgroundColor = UIColor.systemBackgroundColor;

self.headerView.hidden = YES;

NSString *localeIdentifier = [NSLocale currentLocale].localeIdentifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ - (void)viewDidLoad
{
[super viewDidLoad];

self.view.backgroundColor = UIColor.systemBackgroundColor;

_numberPadView = adoptNS([[WKNumberPadView alloc] initWithFrame:UIRectInset(self.contentView.bounds, numberPadViewTopMargin, 0, 0, 0) controller:self]);
[self.contentView addSubview:_numberPadView.get()];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ - (void)viewDidLoad
{
[super viewDidLoad];

self.view.backgroundColor = UIColor.systemBackgroundColor;

self.cancelButton.hidden = YES;
self.showsAcceptButton = YES;

Expand Down Expand Up @@ -202,11 +204,6 @@ - (void)didSelectListItemAtIndexPath:(NSIndexPath *)indexPath
if (!indexPathsToReload.count)
return;

if (self.listView) {
[self.listView reloadRowsAtIndexPaths:indexPathsToReload withRowAnimation:UITableViewRowAnimationNone];
return;
}

#if HAVE(QUICKBOARD_COLLECTION_VIEWS)
[self.collectionView reloadItemsAtIndexPaths:indexPathsToReload];
#endif
Expand All @@ -222,33 +219,6 @@ - (CGFloat)heightForListItem:(NSInteger)itemNumber width:(CGFloat)width
return selectMenuItemCellHeight;
}

// FIXME: This method can be removed when <rdar://problem/57807445> lands in a build.
- (PUICQuickboardListItemCell *)cellForListItem:(NSInteger)itemNumber
{
auto reusableCell = retainPtr([self.listView dequeueReusableCellWithIdentifier:selectMenuCellReuseIdentifier]);
if (!reusableCell) {
reusableCell = adoptNS([[WKSelectMenuItemCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:selectMenuCellReuseIdentifier]);
[reusableCell itemLabel].numberOfLines = 1;
[reusableCell itemLabel].lineBreakMode = NSLineBreakByTruncatingTail;
[reusableCell itemLabel].allowsDefaultTighteningForTruncation = YES;
[reusableCell imageView].frame = UIRectInset([reusableCell contentView].bounds, 0, 0, 0, CGRectGetWidth([reusableCell contentView].bounds) - checkmarkImageViewWidth);
}

NSString *optionText = [self.delegate selectMenu:self displayTextForItemAtIndex:itemNumber];
[reusableCell configureForText:optionText width:CGRectGetWidth(self.listView.bounds)];
[reusableCell setRadioSectionCell:!_isMultipleSelect];

if ([_indicesOfCheckedOptions containsIndex:itemNumber]) {
[reusableCell itemLabel].frame = UIRectInset([reusableCell contentView].bounds, 0, selectMenuItemHorizontalMargin + checkmarkImageViewWidth, 0, selectMenuItemHorizontalMargin);
[reusableCell imageView].hidden = NO;
} else {
[reusableCell itemLabel].frame = UIRectInset([reusableCell contentView].bounds, 0, selectMenuItemHorizontalMargin, 0, selectMenuItemHorizontalMargin);
[reusableCell imageView].hidden = YES;
}

return reusableCell.autorelease();
}

- (NSString *)listItemCellReuseIdentifier
{
return selectMenuCellReuseIdentifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ - (instancetype)initWithDelegate:(id <WKTextInputListViewControllerDelegate>)del
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];

self.view.backgroundColor = UIColor.systemBackgroundColor;
}

- (void)reloadContextView
{
_contextViewNeedsUpdate = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ - (void)viewDidLoad
{
[super viewDidLoad];

self.view.backgroundColor = UIColor.systemBackgroundColor;

self.headerView.hidden = YES;

_timePicker = adoptNS([allocCLKUIWheelsOfTimeViewInstance() initWithFrame:self.view.bounds style:CLKUIWheelsOfTimeStyleAlarm12]);
Expand Down

0 comments on commit 3218bc2

Please sign in to comment.