Bug 192301

Summary: Remove "using namespace WebKit" under Source/WebKit/WebProcess/InjectedBundle/API
Product: WebKit Reporter: Fujii Hironori <Hironori.Fujii>
Component: WebKit2Assignee: Fujii Hironori <Hironori.Fujii>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, darin, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 192449    
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Fujii Hironori 2018-12-03 00:17:07 PST
Remove "using namespace WebKit" under Source/WebKit/WebProcess/InjectedBundle/API

(In reply to Darin Adler from bug #191995 comment #8)
> Same applies to "using namespace WebKit" and those should be removed for the
> same reason.
Comment 1 Fujii Hironori 2018-12-03 00:18:23 PST
Here are commands I invoked: 

> sed -i -e '/using namespace WebKit;/d' *.cpp
> name="(toFloatRect|SnapshotOptions|SnapshotOptionsInViewCoordinates|WebPageGroupProxy|WebPageOverlay|WebRenderLayer|WebRenderObject|snapshotOptionsFromImageOptions|toFindOptions|toIntRect|toLayoutMilestones|InjectedBundlePageContextMenuClient|InjectedBundlePageEditorClient|InjectedBundlePageFormClient|InjectedBundlePageLoaderClient|InjectedBundlePageResourceLoadClient|InjectedBundlePageUIClient|InjectedBundleRangeHandle|WebContextMenu|WebContextMenuItem|WebImage|WebPage|toIntPoint|toSnapshotOptions|toImpl|InjectedBundleDOMWindowExtension|InjectedBundleHitTestResult|InjectedBundleNavigationAction|InjectedBundleNodeHandle|SecurityOriginData|WebFrame|WebInspector|toAPI|toCopiedAPI|toCopiedURLAPI|InjectedBundleClient|InjectedBundle|toWTFString|toUserScriptInjectionTime|toUserContentInjectedFrames|toUserContentInjectedFrames|InjectedBundleScriptWorld)"; sed -Ei -e "s/WebKit::$name\\b/\\1/g" -e "s/\\b$name\\b/WebKit::\\1/g" -e "s/\\bWebKit::$name\\.h\\b/\\1.h/g" *.cpp
Comment 2 Fujii Hironori 2018-12-03 00:28:17 PST
Created attachment 356363 [details]
Patch
Comment 3 Fujii Hironori 2018-12-03 01:03:57 PST
Created attachment 356366 [details]
Patch
Comment 4 Darin Adler 2018-12-03 01:05:18 PST
Comment on attachment 356363 [details]
Patch

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

Argument-dependent lookup means that some small number of these might not be needed. If any argument has a type in the WebKit namespace, then the function name doesn’t need to include a WebKit prefix. But that only affects a very small number of these.

> Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePageBanner.cpp:35
> +    return WebKit::toAPI(PageBanner::APIType);

Looks ike this needs to be WebKit::PageBanner::APIType.
Comment 5 Fujii Hironori 2018-12-03 01:47:36 PST
Created attachment 356367 [details]
Patch
Comment 6 Fujii Hironori 2018-12-03 01:51:09 PST
Comment on attachment 356367 [details]
Patch

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

> Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp:53
> +    return WebKit::toAPI(WebKit::InjectedBundle::APIType);

Some "WebKit::" can not be removed even though its argument's namespace is WebKit.
For example, this "WebKit::" of toAPI can not be removed. 


> In file included from DerivedSources\WebKit\unified-sources\UnifiedSource43.cpp:4:
> ..\..\Source\WebKit\WebProcess/InjectedBundle/API/c/WKBundle.cpp(53,12):  error: use of undeclared identifier 'toAPI'; did you mean 'WebKit::toAPI'?
>     return toAPI(WebKit::InjectedBundle::APIType);
>            ^~~~~
>            WebKit::toAPI
> ..\..\Source\WebKit\Shared\API\c\WKSharedAPICast.h(279,17):  note: 'WebKit::toAPI' declared here
> inline WKTypeID toAPI(API::Object::Type type)
>                 ^
> 1 error generated.
Comment 7 Fujii Hironori 2018-12-03 01:53:22 PST
Comment on attachment 356367 [details]
Patch

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

>> Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp:53
>> +    return WebKit::toAPI(WebKit::InjectedBundle::APIType);
> 
> Some "WebKit::" can not be removed even though its argument's namespace is WebKit.
> For example, this "WebKit::" of toAPI can not be removed.

Its argument namespace is WebKit::InjectedBundle, not WebKit in that case?
Comment 8 Fujii Hironori 2018-12-03 17:13:18 PST
Comment on attachment 356367 [details]
Patch

Clearing flags on attachment: 356367

Committed r238832: <https://trac.webkit.org/changeset/238832>
Comment 9 Fujii Hironori 2018-12-03 17:13:21 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2018-12-03 17:14:36 PST
<rdar://problem/46438085>