Bug 200017

Summary: Fix inspector override conversion in InspectorPageAgent::overrideSetting
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebRTCAssignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, hi, joepeck, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=199924
Attachments:
Description Flags
Patch
none
Patch for landing none

Description youenn fablet 2019-07-22 15:26:57 PDT
Fix inspector override conversion in InspectorPageAgent::overrideSetting
Comment 1 Radar WebKit Bug Importer 2019-07-22 15:30:48 PDT
<rdar://problem/53419693>
Comment 2 youenn fablet 2019-07-22 15:31:17 PDT
Created attachment 374643 [details]
Patch
Comment 3 Devin Rousso 2019-07-22 16:00:59 PDT
Comment on attachment 374643 [details]
Patch

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

r=me, nice catch!

> Source/WebCore/ChangeLog:15
> +         Previously, the conversion for the mock capture value was implicit from a bool pointer to an optional.
> +         Make an explicit conversion as done for regular settings.

Style: there seems to be an extra space before each of these lines.

> Source/WebCore/inspector/agents/InspectorPageAgent.cpp:429
> +    return *value;

Style: I prefer using `.value()` with `WTF::Optional` so it's a bit clearer that it's not a pointer.

> Source/WebCore/inspector/agents/InspectorPageAgent.cpp:445
> +    auto overrideValue = toOptionalBool(value);

NIT: Web Inspector typically uses `as*` instead of `to*` for it's type conversions (see `asBool` in InspectorRuntimeAgent.cpp).

> Source/WebCore/inspector/agents/InspectorPageAgent.cpp:448
> +    case Inspector::Protocol::Page::Setting::name: {                            \

NIT: we can remove the `{` and `}` and make this slightly simpler.
Comment 4 youenn fablet 2019-07-22 16:14:21 PDT
Created attachment 374649 [details]
Patch for landing
Comment 5 youenn fablet 2019-07-22 16:23:32 PDT
Done.

> Style: I prefer using `.value()` with `WTF::Optional` so it's a bit clearer
> that it's not a pointer.

I like using pointer-like code, for instance "if(value) value->doSomething()" or "if(value) doSomething(*value)".
The one case I am sometimes using .value() is when moving the value.
"if (value) doSomething(WTFMove(*value))" seems a bit strange.
Comment 6 WebKit Commit Bot 2019-07-22 17:01:11 PDT
Comment on attachment 374649 [details]
Patch for landing

Clearing flags on attachment: 374649

Committed r247707: <https://trac.webkit.org/changeset/247707>
Comment 7 WebKit Commit Bot 2019-07-22 17:01:12 PDT
All reviewed patches have been landed.  Closing bug.