[webkit-reviews] review granted: [Bug 211521] REGRESSION (r253267): issues on touchstart/touchend/touchmove (pointerdown/pointerup/pointermove) events : [Attachment 398999] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun May 10 23:37:59 PDT 2020


Darin Adler <darin at apple.com> has granted Wenson Hsieh
<wenson_hsieh at apple.com>'s request for review:
Bug 211521: REGRESSION (r253267): issues on touchstart/touchend/touchmove
(pointerdown/pointerup/pointermove) events
https://bugs.webkit.org/show_bug.cgi?id=211521

Attachment 398999: Patch

https://bugs.webkit.org/attachment.cgi?id=398999&action=review




--- Comment #9 from Darin Adler <darin at apple.com> ---
Comment on attachment 398999
  --> https://bugs.webkit.org/attachment.cgi?id=398999
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=398999&action=review

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:719
> +- (NSArray<WKDeferringGestureRecognizer *> *)_deferringGestureRecognizers

I think this needs to go inside:

    #if ENABLE(IOS_TOUCH_EVENTS)

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:728
> +    NSMutableArray *deferringGestureRecognizers = [NSMutableArray
arrayWithCapacity:3];
> +    if (_deferringGestureRecognizerForImmediatelyResettableGestures)
> +	   [deferringGestureRecognizers
addObject:_deferringGestureRecognizerForImmediatelyResettableGestures.get()];
> +    if (_deferringGestureRecognizerForDelayedResettableGestures)
> +	   [deferringGestureRecognizers
addObject:_deferringGestureRecognizerForDelayedResettableGestures.get()];
> +    if (_deferringGestureRecognizerForSyntheticTapGestures)
> +	   [deferringGestureRecognizers
addObject:_deferringGestureRecognizerForSyntheticTapGestures.get()];
> +    return deferringGestureRecognizers;

There are more efficient ways to do this than using an NSMutableArray. The
simplest I can think of is to use a C array. Something like this:

    WKDeferringGestureRecognizer *recognizers[3];
    NSUInteger count = 0;
    auto add = [&] (const RetainPtr<WKDeferringGestureRecognizer>& recognizer)
{
	if (recognizer)
	    recognizers[count++] = recognizer.get();
    };
    add(_deferringGestureRecognizerForImmediatelyResettableGestures);
    add(_deferringGestureRecognizerForDelayedResettableGestures);
    add(_deferringGestureRecognizerForSyntheticTapGestures);
    return [[NSArray arrayWithObjects:recognizers count:count];

That’s more lines of code, but it always seems better to me not to use a
mutable array.


More information about the webkit-reviews mailing list