-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Find in Note: Dark gray outline (shadow) appears behind gray/yellow highlights when matched text found in HTML note. #25600
Find in Note: Dark gray outline (shadow) appears behind gray/yellow highlights when matched text found in HTML note. #25600
Conversation
EWS run on previous version of this PR (hash d56bafe) |
@@ -201,6 +201,15 @@ struct PerWebProcessState { | |||
|
|||
#endif // PLATFORM(IOS_FAMILY) | |||
|
|||
#if HAVE(UIFINDINTERACTION) | |||
enum FindOverlayView { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be an enum class : uint8_t ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe it should just be a struct instead of an enum + a loosely-ordered vector? like
struct FindOverlayViews {
RetainPtr<UIView> left;
// etc
}
@@ -201,6 +201,15 @@ struct PerWebProcessState { | |||
|
|||
#endif // PLATFORM(IOS_FAMILY) | |||
|
|||
#if HAVE(UIFINDINTERACTION) | |||
enum FindOverlayView { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum FindOverlayView { | |
enum class FindOverlayViewPosition : uint8_t { |
Probably best to also move this to the .mm
file, since it isn't needed outside of it.
@@ -247,7 +256,7 @@ struct PerWebProcessState { | |||
|
|||
BOOL _findInteractionEnabled; | |||
#if HAVE(UIFINDINTERACTION) | |||
RetainPtr<UIView> _findOverlay; | |||
Vector<RetainPtr<UIView>> _findOverlaysForOverflowScroll; // Top, right, bottom, left |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"OverflowScroll" is bit of an overloaded term here, since this is not really about overflow: scroll
.
_findOverlaysOutsideContentView
might be more accurate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix LGTM actually -- I'm suggesting an alternative approach to manage the overlays
@@ -201,6 +201,15 @@ struct PerWebProcessState { | |||
|
|||
#endif // PLATFORM(IOS_FAMILY) | |||
|
|||
#if HAVE(UIFINDINTERACTION) | |||
enum FindOverlayView { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this an enum class please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see why you did it like this. My other comment speaks in a different direction if you want to consider that.
@@ -247,7 +256,7 @@ struct PerWebProcessState { | |||
|
|||
BOOL _findInteractionEnabled; | |||
#if HAVE(UIFINDINTERACTION) | |||
RetainPtr<UIView> _findOverlay; | |||
Vector<RetainPtr<UIView>> _findOverlaysForOverflowScroll; // Top, right, bottom, left |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overlay ordering enforcement is a little fragile... particularly since it's documented through a comment. What do you think about introducing a structure that captures what is going on?
struct OverflowScrollOverlays {
RetainPtr<UIView> top;
RetainPtr<UIView> right;
RetainPtr<UIView> bottom;
RetainPtr<UIView> left;
};
OverflowScrollOverlays _findOverlaysForOverflowScroll;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That way you can also get rid of enum FindOverlayView
?
auto topView = _findOverlaysForOverflowScroll[FindOverlayView::Top].get(); | ||
auto rightView = _findOverlaysForOverflowScroll[FindOverlayView::Right].get(); | ||
auto bottomView = _findOverlaysForOverflowScroll[FindOverlayView::Bottom].get(); | ||
auto leftView = _findOverlaysForOverflowScroll[FindOverlayView::Left].get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our smart pointer guidelines suggest these should remain as smart pointers on the stack, so I think we prefer:
auto topView = _findOverlaysForOverflowScroll[FindOverlayView::Top].get(); | |
auto rightView = _findOverlaysForOverflowScroll[FindOverlayView::Right].get(); | |
auto bottomView = _findOverlaysForOverflowScroll[FindOverlayView::Bottom].get(); | |
auto leftView = _findOverlaysForOverflowScroll[FindOverlayView::Left].get(); | |
RetainPtr topView = _findOverlaysForOverflowScroll[FindOverlayView::Top]; | |
RetainPtr rightView = _findOverlaysForOverflowScroll[FindOverlayView::Right]; | |
RetainPtr bottomView = _findOverlaysForOverflowScroll[FindOverlayView::Bottom]; | |
RetainPtr leftView = _findOverlaysForOverflowScroll[FindOverlayView::Left]; |
UIColor *overlayColor = [UIColor colorWithRed:(26. / 255) green:(26. / 255) blue:(26. / 255) alpha:(64. / 255)]; | ||
[_findOverlay setBackgroundColor:overlayColor]; | ||
UIColor *overlayColor = [UIColor colorWithRed:(26. / 255) green:(26. / 255) blue:(26. / 255) alpha:(64. / 255)]; | ||
if (!_findOverlaysForOverflowScroll.size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: _findOverlaysForOverflowScroll.isEmpty()
is a little easier to read
_findOverlay = adoptNS([[UIView alloc] init]); | ||
UIColor *overlayColor = [UIColor colorWithRed:(26. / 255) green:(26. / 255) blue:(26. / 255) alpha:(64. / 255)]; | ||
[_findOverlay setBackgroundColor:overlayColor]; | ||
UIColor *overlayColor = [UIColor colorWithRed:(26. / 255) green:(26. / 255) blue:(26. / 255) alpha:(64. / 255)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be moved inside the if
.
|
||
if (CALayer *contentViewFindOverlayLayer = [self _layerForFindOverlay]) { | ||
[[_findOverlay layer] removeAllAnimations]; | ||
[contentViewFindOverlayLayer removeAllAnimations]; | ||
for (RetainPtr overlay : _findOverlaysForOverflowScroll) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the repetition of this loop, we could have a method like _updateFindOverlaysOutsideContentView:
that takes a block, and calls the block on each view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or just make it an initializer list like for (RetainPtr overlay : { _findOverlaysForOverflowScroll.left, _findOverlaysForOverflowScroll.right, etc {)
?
|
||
[strongSelf _removeLayerForFindOverlay]; | ||
}]; | ||
|
||
[contentViewFindOverlayLayer addAnimation:animation forKey:@"findOverlayFadeOut"]; | ||
[findOverlayLayer addAnimation:animation forKey:@"findOverlayFadeOut"]; | ||
for (RetainPtr overlay : _findOverlaysForOverflowScroll) | ||
[overlay addAnimation:animation forKey:@"findOverlayFadeOut"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[overlay addAnimation:animation forKey:@"findOverlayFadeOut"]; | |
[[overlay layer] addAnimation:animation forKey:@"findOverlayFadeOut"]; |
d56bafe
to
9ff9300
Compare
EWS run on previous version of this PR (hash 9ff9300) |
@@ -247,7 +247,13 @@ struct PerWebProcessState { | |||
|
|||
BOOL _findInteractionEnabled; | |||
#if HAVE(UIFINDINTERACTION) | |||
RetainPtr<UIView> _findOverlay; | |||
struct findOverlays { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should be FindOverlays
|
||
[CATransaction commit]; | ||
|
||
contentViewFindOverlayLayer.opacity = 0; | ||
findOverlayLayer.opacity = 0; | ||
[_findOverlaysOutsideContentView.value().top layer].opacity = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anywhere you use value()
should just be ->
.
But please also try to do this #25600 (comment), so that only needs to happen in one place.
9ff9300
to
9d068dd
Compare
EWS run on previous version of this PR (hash 9d068dd) |
9d068dd
to
58f0910
Compare
EWS run on previous version of this PR (hash 58f0910) |
[self _addLayerForFindOverlay]; | ||
} | ||
} | ||
|
||
- (void)_hideFindOverlay | ||
{ | ||
CALayer *contentViewFindOverlayLayer = [self _layerForFindOverlay]; | ||
CALayer *findOverlayLayer = [_findOverlay layer]; | ||
CALayer *findOverlayLayer = [_findOverlaysOutsideContentView.value().top layer]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What guarantees _findOverlaysOutsideContentView
is not std::nullopt
here? I think you need to update the check of line 3430 to check for that, and then move this line after the early return β otherwise this is a change in logic.
[self _addLayerForFindOverlay]; | ||
} | ||
} | ||
|
||
- (void)_hideFindOverlay | ||
{ | ||
CALayer *contentViewFindOverlayLayer = [self _layerForFindOverlay]; | ||
CALayer *findOverlayLayer = [_findOverlay layer]; | ||
CALayer *findOverlayLayer = [_findOverlaysOutsideContentView.value().top layer]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also ->
rather than value()
.
@@ -3559,20 +3608,33 @@ - (_UIDataOwner)_effectiveDataOwner:(_UIDataOwner)clientSuppliedDataOwner | |||
return _UIDataOwnerUndefined; | |||
} | |||
|
|||
#if HAVE(UIFINDINTERACTION) | |||
- (void)_updateFindOverlaysOutsideContentView:(void(^)(RetainPtr<UIView>))updateFindOverlays |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- (void)_updateFindOverlaysOutsideContentView:(void(^)(RetainPtr<UIView>))updateFindOverlays | |
- (void)_updateFindOverlaysOutsideContentView:(void(^)(UIView *))updateFindOverlays |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be UIView *
rather than RetainPtr
to avoid ref-churn.
updateFindOverlays(_findOverlaysOutsideContentView->top); | ||
updateFindOverlays(_findOverlaysOutsideContentView->bottom); | ||
updateFindOverlays(_findOverlaysOutsideContentView->left); | ||
updateFindOverlays(_findOverlaysOutsideContentView->right); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateFindOverlays(_findOverlaysOutsideContentView->top); | |
updateFindOverlays(_findOverlaysOutsideContentView->bottom); | |
updateFindOverlays(_findOverlaysOutsideContentView->left); | |
updateFindOverlays(_findOverlaysOutsideContentView->right); | |
updateFindOverlay(_findOverlaysOutsideContentView->top); | |
updateFindOverlay(_findOverlaysOutsideContentView->bottom); | |
updateFindOverlay(_findOverlaysOutsideContentView->left); | |
updateFindOverlay(_findOverlaysOutsideContentView->right); |
[contentViewFindOverlayLayer setOpacity:1]; | ||
} else { | ||
[_findOverlay setAlpha:0]; | ||
if (_findOverlaysOutsideContentView) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this check is necessary? The variable is always initialized by this method.
58f0910
to
2ccc05f
Compare
EWS run on previous version of this PR (hash 2ccc05f) |
2ccc05f
to
b299aa4
Compare
EWS run on previous version of this PR (hash b299aa4) |
@@ -3404,22 +3445,28 @@ - (void)_hideFindOverlay | |||
if (!strongSelf) | |||
return; | |||
|
|||
if ([strongSelf->_findOverlay alpha]) | |||
return; | |||
[strongSelf _removeLayerForFindOverlay]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be after the early return, as it was before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is in the right place, I added the other early return to check of the new overlays are in place before calling remove from them. It's possible, but unlikely, that we have an overlay layer without the overlay views, and I don't want to not remove the layer just because the views aren't there. (Or I could be misunderstanding your concern.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible to have the overlay views outside the content view without the PageOverlay layer, but not vice-versa. This is because _showFindOverlay
always creates the overlay views outside the content view, before creating the PageOverlay.
I think the existing structure of the code is necessary in order to guard against scenarios where the find overlay is brought up again as it's animating out β which is possible due to the async nature of the code.
So the way this code needs to be written to preserve the existing structure is:
bool hasOverlaysOutsideContentView = strongSelf->_findOverlaysOutsideContentView.has_value();
if (hasOverlaysOutsideContentView && [strongSelf->_findOverlaysOutsideContentView->top alpha]])
return;
[strongSelf _removeLayerForFindOverlay];
if (hasOverlaysOutsideContentView) {
[strongSelf _updateFindOverlaysOutsideContentView:^(UIView *view) {
[view removeFromSuperview];
}];
strongSelf->_findOverlaysOutsideContentView.reset();
}
b299aa4
to
7c64366
Compare
EWS run on previous version of this PR (hash 7c64366) |
7c64366
to
e2c2fca
Compare
EWS run on current version of this PR (hash e2c2fca) |
Safe-Merge-Queue: Build #14419. |
β¦ighlights when matched text found in HTML note. https://bugs.webkit.org/show_bug.cgi?id=270666 rdar://122843511 Reviewed by Aditya Keerthi. In notes, the WKContentView is transparent, so our original solution of putting an additional grey layer behind the content view that filled up the empty parts of the scroll view would show through and make the find ui have a incorrect grey cast. So instead, we make four views that surround the WKContentView to fill in any part of the scrollView that isn't covered by the contentView. These are arranged around the content view like so: ----- ----------- | | | | |----------| | | | | | | | | ----- ------ | | | | |__________|____| Each view is expanded to reach the edges of the scroll view every time the view is scrolled or the bounds change. This means that no matter where the content view is scrolled to, there will be a view that gives the correct grey cast to the scroll view. * Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h: * Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm: (-[WKWebView scrollViewDidScroll:]): (-[WKWebView _frameOrBoundsMayHaveChanged]): (-[WKWebView _updateFindOverlayForOverflowScrollPositions]): (-[WKWebView _showFindOverlay]): (-[WKWebView _hideFindOverlay]): (-[WKWebView _didAddLayerForFindOverlay:]): (-[WKWebView _updateFindOverlayPosition]): Deleted. Canonical link: https://commits.webkit.org/275873@main
e2c2fca
to
89bc7dd
Compare
Committed 275873@main (89bc7dd): https://commits.webkit.org/275873@main Reviewed commits have been landed. Closing PR #25600 and removing active labels. |
89bc7dd
e2c2fca