Skip to content

Commit

Permalink
Replace UseCounter::Feature by WebFeature in Blink
Browse files Browse the repository at this point in the history
Script used in third_party/WebKit/
for f in $(find -name "*.cpp" -or -name "*.h"); do
  ### Replace enum values UseCounter::kFeatureName by WebFeature::kFeatureName
  sed -i 's/UseCounter::k/WebFeature::k/g' "$f"
  sed -i ':a;N;!ba;s/UseCounter::\n\s*k/WebFeature::k/g' "$f"
  ### Replace enum type UseCounter::Feature by WebFeature
  sed -i 's/UseCounter::Feature /WebFeature /g' "$f"
  ### Undo changes to UseCounter::Context
  sed -i 's/WebFeature::kDefaultContext/UseCounter::kDefaultContext/g' "$f"
  sed -i 's/WebFeature::kSVGImageContext/UseCounter::kSVGImageContext/g' "$f"
  sed -i 's/WebFeature::kExtensionContext/UseCounter::kExtensionContext/g' "$f"
  sed -i 's/WebFeature::kDisabledContext/UseCounter::kDisabledContext/g' "$f"
done

Additional changes in *Internals.cpp:
  static_cast<uint32_t>(WebFeature::kNumberOfFeatures) *bi_opt* feature

Additional changes in UseCounter.h, UseCounter.cpp, Deprecation.h

A few additional casting is also added.

Bug: 724287
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I0e18a017542c4d6bb5ddf0f50a3522dfe115dba1
Reviewed-on: https://chromium-review.googlesource.com/524144
Commit-Queue: Luna Lu <[email protected]>
Reviewed-by: Kentaro Hara <[email protected]>
Cr-Commit-Position: refs/heads/master@{#477785}
  • Loading branch information
LoonyBean authored and Commit Bot committed Jun 7, 2017
1 parent cd65501 commit 6a083ac
Show file tree
Hide file tree
Showing 270 changed files with 1,066 additions and 1,129 deletions.
16 changes: 8 additions & 8 deletions third_party/WebKit/Source/bindings/core/v8/BindingSecurity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ bool BindingSecurity::ShouldAllowAccessTo(

if (!can_access) {
UseCounter::Count(accessing_window->GetFrame(),
UseCounter::kCrossOriginPropertyAccess);
WebFeature::kCrossOriginPropertyAccess);
if (target->opener() == accessing_window) {
UseCounter::Count(accessing_window->GetFrame(),
UseCounter::kCrossOriginPropertyAccessFromOpener);
WebFeature::kCrossOriginPropertyAccessFromOpener);
}
}

Expand All @@ -166,10 +166,10 @@ bool BindingSecurity::ShouldAllowAccessTo(

if (!can_access) {
UseCounter::Count(accessing_window->GetFrame(),
UseCounter::kCrossOriginPropertyAccess);
WebFeature::kCrossOriginPropertyAccess);
if (target->opener() == accessing_window) {
UseCounter::Count(accessing_window->GetFrame(),
UseCounter::kCrossOriginPropertyAccessFromOpener);
WebFeature::kCrossOriginPropertyAccessFromOpener);
}
}

Expand All @@ -195,10 +195,10 @@ bool BindingSecurity::ShouldAllowAccessTo(

if (!can_access) {
UseCounter::Count(accessing_window->GetFrame(),
UseCounter::kCrossOriginPropertyAccess);
WebFeature::kCrossOriginPropertyAccess);
if (target->DomWindow()->opener() == accessing_window) {
UseCounter::Count(accessing_window->GetFrame(),
UseCounter::kCrossOriginPropertyAccessFromOpener);
WebFeature::kCrossOriginPropertyAccessFromOpener);
}
}

Expand All @@ -224,10 +224,10 @@ bool BindingSecurity::ShouldAllowAccessTo(

if (!can_access) {
UseCounter::Count(accessing_window->GetFrame(),
UseCounter::kCrossOriginPropertyAccess);
WebFeature::kCrossOriginPropertyAccess);
if (target->DomWindow()->opener() == accessing_window) {
UseCounter::Count(accessing_window->GetFrame(),
UseCounter::kCrossOriginPropertyAccessFromOpener);
WebFeature::kCrossOriginPropertyAccessFromOpener);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,33 +107,33 @@ INSTANTIATE_TEST_CASE_P(WindowProperties,
TEST_P(BindingSecurityCounterTest, CrossOriginWindow) {
LoadWindowAndAccessProperty(OriginDisposition::CrossOrigin, GetParam());
EXPECT_TRUE(GetDocument().GetPage()->GetUseCounter().HasRecordedMeasurement(
UseCounter::kCrossOriginPropertyAccess));
WebFeature::kCrossOriginPropertyAccess));
EXPECT_TRUE(GetDocument().GetPage()->GetUseCounter().HasRecordedMeasurement(
UseCounter::kCrossOriginPropertyAccessFromOpener));
WebFeature::kCrossOriginPropertyAccessFromOpener));
}

TEST_P(BindingSecurityCounterTest, SameOriginWindow) {
LoadWindowAndAccessProperty(OriginDisposition::SameOrigin, GetParam());
EXPECT_FALSE(GetDocument().GetPage()->GetUseCounter().HasRecordedMeasurement(
UseCounter::kCrossOriginPropertyAccess));
WebFeature::kCrossOriginPropertyAccess));
EXPECT_FALSE(GetDocument().GetPage()->GetUseCounter().HasRecordedMeasurement(
UseCounter::kCrossOriginPropertyAccessFromOpener));
WebFeature::kCrossOriginPropertyAccessFromOpener));
}

TEST_P(BindingSecurityCounterTest, CrossOriginFrame) {
LoadFrameAndAccessProperty(OriginDisposition::CrossOrigin, GetParam());
EXPECT_TRUE(GetDocument().GetPage()->GetUseCounter().HasRecordedMeasurement(
UseCounter::kCrossOriginPropertyAccess));
WebFeature::kCrossOriginPropertyAccess));
EXPECT_FALSE(GetDocument().GetPage()->GetUseCounter().HasRecordedMeasurement(
UseCounter::kCrossOriginPropertyAccessFromOpener));
WebFeature::kCrossOriginPropertyAccessFromOpener));
}

TEST_P(BindingSecurityCounterTest, SameOriginFrame) {
LoadFrameAndAccessProperty(OriginDisposition::SameOrigin, GetParam());
EXPECT_FALSE(GetDocument().GetPage()->GetUseCounter().HasRecordedMeasurement(
UseCounter::kCrossOriginPropertyAccess));
WebFeature::kCrossOriginPropertyAccess));
EXPECT_FALSE(GetDocument().GetPage()->GetUseCounter().HasRecordedMeasurement(
UseCounter::kCrossOriginPropertyAccessFromOpener));
WebFeature::kCrossOriginPropertyAccessFromOpener));
}

} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ScheduledAction* ScheduledAction::Create(ScriptState* script_state,
EnteredDOMWindow(script_state->GetIsolate()),
ToDocument(target)->GetFrame(),
BindingSecurity::ErrorReportOption::kDoNotReport)) {
UseCounter::Count(target, UseCounter::kScheduledActionIgnored);
UseCounter::Count(target, WebFeature::kScheduledActionIgnored);
return new ScheduledAction(script_state);
}
}
Expand All @@ -73,7 +73,7 @@ ScheduledAction* ScheduledAction::Create(ScriptState* script_state,
EnteredDOMWindow(script_state->GetIsolate()),
ToDocument(target)->GetFrame(),
BindingSecurity::ErrorReportOption::kDoNotReport)) {
UseCounter::Count(target, UseCounter::kScheduledActionIgnored);
UseCounter::Count(target, WebFeature::kScheduledActionIgnored);
return new ScheduledAction(script_state);
}
}
Expand Down
70 changes: 35 additions & 35 deletions third_party/WebKit/Source/bindings/core/v8/UseCounterCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,110 +16,110 @@ void UseCounterCallback(v8::Isolate* isolate,
if (V8PerIsolateData::From(isolate)->IsUseCounterDisabled())
return;

UseCounter::Feature blink_feature;
WebFeature blink_feature;
bool deprecated = false;
switch (feature) {
case v8::Isolate::kUseAsm:
blink_feature = UseCounter::kUseAsm;
blink_feature = WebFeature::kUseAsm;
break;
case v8::Isolate::kBreakIterator:
blink_feature = UseCounter::kBreakIterator;
blink_feature = WebFeature::kBreakIterator;
break;
case v8::Isolate::kLegacyConst:
blink_feature = UseCounter::kLegacyConst;
blink_feature = WebFeature::kLegacyConst;
break;
case v8::Isolate::kSloppyMode:
blink_feature = UseCounter::kV8SloppyMode;
blink_feature = WebFeature::kV8SloppyMode;
break;
case v8::Isolate::kStrictMode:
blink_feature = UseCounter::kV8StrictMode;
blink_feature = WebFeature::kV8StrictMode;
break;
case v8::Isolate::kStrongMode:
blink_feature = UseCounter::kV8StrongMode;
blink_feature = WebFeature::kV8StrongMode;
break;
case v8::Isolate::kRegExpPrototypeStickyGetter:
blink_feature = UseCounter::kV8RegExpPrototypeStickyGetter;
blink_feature = WebFeature::kV8RegExpPrototypeStickyGetter;
break;
case v8::Isolate::kRegExpPrototypeToString:
blink_feature = UseCounter::kV8RegExpPrototypeToString;
blink_feature = WebFeature::kV8RegExpPrototypeToString;
break;
case v8::Isolate::kRegExpPrototypeUnicodeGetter:
blink_feature = UseCounter::kV8RegExpPrototypeUnicodeGetter;
blink_feature = WebFeature::kV8RegExpPrototypeUnicodeGetter;
break;
case v8::Isolate::kIntlV8Parse:
blink_feature = UseCounter::kV8IntlV8Parse;
blink_feature = WebFeature::kV8IntlV8Parse;
break;
case v8::Isolate::kIntlPattern:
blink_feature = UseCounter::kV8IntlPattern;
blink_feature = WebFeature::kV8IntlPattern;
break;
case v8::Isolate::kIntlResolved:
blink_feature = UseCounter::kV8IntlResolved;
blink_feature = WebFeature::kV8IntlResolved;
break;
case v8::Isolate::kPromiseChain:
blink_feature = UseCounter::kV8PromiseChain;
blink_feature = WebFeature::kV8PromiseChain;
break;
case v8::Isolate::kPromiseAccept:
blink_feature = UseCounter::kV8PromiseAccept;
blink_feature = WebFeature::kV8PromiseAccept;
break;
case v8::Isolate::kPromiseDefer:
blink_feature = UseCounter::kV8PromiseDefer;
blink_feature = WebFeature::kV8PromiseDefer;
break;
case v8::Isolate::kHtmlCommentInExternalScript:
blink_feature = UseCounter::kV8HTMLCommentInExternalScript;
blink_feature = WebFeature::kV8HTMLCommentInExternalScript;
break;
case v8::Isolate::kHtmlComment:
blink_feature = UseCounter::kV8HTMLComment;
blink_feature = WebFeature::kV8HTMLComment;
break;
case v8::Isolate::kSloppyModeBlockScopedFunctionRedefinition:
blink_feature = UseCounter::kV8SloppyModeBlockScopedFunctionRedefinition;
blink_feature = WebFeature::kV8SloppyModeBlockScopedFunctionRedefinition;
break;
case v8::Isolate::kForInInitializer:
blink_feature = UseCounter::kV8ForInInitializer;
blink_feature = WebFeature::kV8ForInInitializer;
break;
case v8::Isolate::kArrayProtectorDirtied:
blink_feature = UseCounter::kV8ArrayProtectorDirtied;
blink_feature = WebFeature::kV8ArrayProtectorDirtied;
break;
case v8::Isolate::kArraySpeciesModified:
blink_feature = UseCounter::kV8ArraySpeciesModified;
blink_feature = WebFeature::kV8ArraySpeciesModified;
break;
case v8::Isolate::kArrayPrototypeConstructorModified:
blink_feature = UseCounter::kV8ArrayPrototypeConstructorModified;
blink_feature = WebFeature::kV8ArrayPrototypeConstructorModified;
break;
case v8::Isolate::kArrayInstanceProtoModified:
blink_feature = UseCounter::kV8ArrayInstanceProtoModified;
blink_feature = WebFeature::kV8ArrayInstanceProtoModified;
break;
case v8::Isolate::kArrayInstanceConstructorModified:
blink_feature = UseCounter::kV8ArrayInstanceConstructorModified;
blink_feature = WebFeature::kV8ArrayInstanceConstructorModified;
break;
case v8::Isolate::kLegacyFunctionDeclaration:
blink_feature = UseCounter::kV8LegacyFunctionDeclaration;
blink_feature = WebFeature::kV8LegacyFunctionDeclaration;
break;
case v8::Isolate::kRegExpPrototypeSourceGetter:
blink_feature = UseCounter::kV8RegExpPrototypeSourceGetter;
blink_feature = WebFeature::kV8RegExpPrototypeSourceGetter;
break;
case v8::Isolate::kRegExpPrototypeOldFlagGetter:
blink_feature = UseCounter::kV8RegExpPrototypeOldFlagGetter;
blink_feature = WebFeature::kV8RegExpPrototypeOldFlagGetter;
break;
case v8::Isolate::kDecimalWithLeadingZeroInStrictMode:
blink_feature = UseCounter::kV8DecimalWithLeadingZeroInStrictMode;
blink_feature = WebFeature::kV8DecimalWithLeadingZeroInStrictMode;
break;
case v8::Isolate::kLegacyDateParser:
blink_feature = UseCounter::kV8LegacyDateParser;
blink_feature = WebFeature::kV8LegacyDateParser;
break;
case v8::Isolate::kDefineGetterOrSetterWouldThrow:
blink_feature = UseCounter::kV8DefineGetterOrSetterWouldThrow;
blink_feature = WebFeature::kV8DefineGetterOrSetterWouldThrow;
break;
case v8::Isolate::kFunctionConstructorReturnedUndefined:
blink_feature = UseCounter::kV8FunctionConstructorReturnedUndefined;
blink_feature = WebFeature::kV8FunctionConstructorReturnedUndefined;
break;
case v8::Isolate::kAssigmentExpressionLHSIsCallInSloppy:
blink_feature = UseCounter::kV8AssigmentExpressionLHSIsCallInSloppy;
blink_feature = WebFeature::kV8AssigmentExpressionLHSIsCallInSloppy;
break;
case v8::Isolate::kAssigmentExpressionLHSIsCallInStrict:
blink_feature = UseCounter::kV8AssigmentExpressionLHSIsCallInStrict;
blink_feature = WebFeature::kV8AssigmentExpressionLHSIsCallInStrict;
break;
case v8::Isolate::kPromiseConstructorReturnedUndefined:
blink_feature = UseCounter::kV8PromiseConstructorReturnedUndefined;
blink_feature = WebFeature::kV8PromiseConstructorReturnedUndefined;
break;
default:
// This can happen if V8 has added counters that this version of Blink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ static void ConstructCustomElement(
StringOrDictionary::fromString(maybe_type->IsNull() ? g_null_atom : type),
exception_state);
if (element) {
UseCounter::Count(document, UseCounter::kV0CustomElementsConstruct);
UseCounter::Count(document, WebFeature::kV0CustomElementsConstruct);
}
V8SetReturnValueFast(info, element, document);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ unsigned V8NodeFilterCondition::acceptNode(
v8::Local<v8::Value> receiver;
if (filter->IsFunction()) {
UseCounter::Count(CurrentExecutionContext(isolate),
UseCounter::kNodeFilterIsFunction);
WebFeature::kNodeFilterIsFunction);
callback = v8::Local<v8::Function>::Cast(filter);
receiver = v8::Undefined(isolate);
} else {
Expand All @@ -89,7 +89,7 @@ unsigned V8NodeFilterCondition::acceptNode(
return NodeFilter::kFilterReject;
}
UseCounter::Count(CurrentExecutionContext(isolate),
UseCounter::kNodeFilterIsObject);
WebFeature::kNodeFilterIsObject);
callback = v8::Local<v8::Function>::Cast(value);
receiver = filter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@ void V8Document::createTouchMethodPrologueCustom(
v8::Local<v8::Value> v8_window = info[0];
if (IsUndefinedOrNull(v8_window)) {
UseCounter::Count(CurrentExecutionContext(info.GetIsolate()),
UseCounter::kDocumentCreateTouchWindowNull);
WebFeature::kDocumentCreateTouchWindowNull);
} else if (!ToDOMWindow(info.GetIsolate(), v8_window)) {
UseCounter::Count(CurrentExecutionContext(info.GetIsolate()),
UseCounter::kDocumentCreateTouchWindowWrongType);
WebFeature::kDocumentCreateTouchWindowWrongType);
}

v8::Local<v8::Value> v8_target = info[1];
if (IsUndefinedOrNull(v8_target)) {
UseCounter::Count(CurrentExecutionContext(info.GetIsolate()),
UseCounter::kDocumentCreateTouchTargetNull);
WebFeature::kDocumentCreateTouchTargetNull);
} else if (!V8EventTarget::hasInstance(v8_target, info.GetIsolate())) {
UseCounter::Count(CurrentExecutionContext(info.GetIsolate()),
UseCounter::kDocumentCreateTouchTargetWrongType);
WebFeature::kDocumentCreateTouchTargetWrongType);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ void V8EventTarget::addEventListenerMethodPrologueCustom(
EventTarget*) {
if (info.Length() >= 3 && info[2]->IsObject()) {
UseCounter::Count(CurrentExecutionContext(info.GetIsolate()),
UseCounter::kAddEventListenerThirdArgumentIsObject);
WebFeature::kAddEventListenerThirdArgumentIsObject);
}
if (info.Length() >= 4) {
UseCounter::Count(CurrentExecutionContext(info.GetIsolate()),
UseCounter::kAddEventListenerFourArguments);
WebFeature::kAddEventListenerFourArguments);
}
}

Expand All @@ -62,11 +62,11 @@ void V8EventTarget::removeEventListenerMethodPrologueCustom(
EventTarget*) {
if (info.Length() >= 3 && info[2]->IsObject()) {
UseCounter::Count(CurrentExecutionContext(info.GetIsolate()),
UseCounter::kRemoveEventListenerThirdArgumentIsObject);
WebFeature::kRemoveEventListenerThirdArgumentIsObject);
}
if (info.Length() >= 4) {
UseCounter::Count(CurrentExecutionContext(info.GetIsolate()),
UseCounter::kRemoveEventListenerFourArguments);
WebFeature::kRemoveEventListenerFourArguments);
}
}

Expand Down
Loading

0 comments on commit 6a083ac

Please sign in to comment.