Skip to content

Commit

Permalink
Reformat UseCounter code
Browse files Browse the repository at this point in the history
This CL reformat code of the format:
if/else/etc (..) 
   ...
   UseCounter::kFeatureName
   ...

to 
if/else/etc (..) {
   ...
   UseCounter::kFeatureName
   ...
}

In CL https://chromium-review.googlesource.com/c/524144/,
UseCounter::kFeatureName will be replaced by
WebFeature::kFeatureName. This CL fixes the presubmit error
(check-webkit-style) for issue 524144.

Bug: 724287
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I12b81c75d5ecab32943b788676e0c087719ec650
Reviewed-on: https://chromium-review.googlesource.com/524187
Reviewed-by: Kentaro Hara <[email protected]>
Commit-Queue: Luna Lu <[email protected]>
Cr-Commit-Position: refs/heads/master@{#477706}
  • Loading branch information
LoonyBean authored and Commit Bot committed Jun 7, 2017
1 parent 0d1c63e commit adecd2e
Show file tree
Hide file tree
Showing 39 changed files with 131 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@ StringKeyframeEffectModel* CreateKeyframeEffectModel(

StringKeyframeEffectModel* model =
StringKeyframeEffectModel::Create(keyframes, &keyframes[0]->Easing());
if (animation_index > 0 && model->HasSyntheticKeyframes())
if (animation_index > 0 && model->HasSyntheticKeyframes()) {
UseCounter::Count(element_for_scoping->GetDocument(),
UseCounter::kCSSAnimationsStackedNeutralKeyframe);
}
return model;
}

Expand Down
12 changes: 8 additions & 4 deletions third_party/WebKit/Source/core/css/SelectorChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,10 @@ SelectorChecker::MatchStatus SelectorChecker::MatchForRelation(

case CSSSelector::kShadowPseudo: {
if (!is_ua_rule_ && mode_ != kQueryingRules &&
context.selector->GetPseudoType() == CSSSelector::kPseudoShadow)
context.selector->GetPseudoType() == CSSSelector::kPseudoShadow) {
Deprecation::CountDeprecation(context.element->GetDocument(),
UseCounter::kCSSSelectorPseudoShadow);
}
// If we're in the same tree-scope as the scoping element, then following
// a shadow descendant combinator would escape that and thus the scope.
if (context.scope && context.scope->OwnerShadowHost() &&
Expand All @@ -435,9 +436,10 @@ SelectorChecker::MatchStatus SelectorChecker::MatchForRelation(
}

case CSSSelector::kShadowDeep: {
if (!is_ua_rule_ && mode_ != kQueryingRules)
if (!is_ua_rule_ && mode_ != kQueryingRules) {
Deprecation::CountDeprecation(context.element->GetDocument(),
UseCounter::kCSSDeepCombinator);
}
if (ShadowRoot* root = context.element->ContainingShadowRoot()) {
if (root->GetType() == ShadowRootType::kUserAgent)
return kSelectorFailsCompletely;
Expand All @@ -450,9 +452,10 @@ SelectorChecker::MatchStatus SelectorChecker::MatchForRelation(
element = element->ParentOrShadowHostElement()) {
if (MatchForPseudoContent(next_context, *element, result) ==
kSelectorMatches) {
if (context.element->IsInShadowTree())
if (context.element->IsInShadowTree()) {
UseCounter::Count(context.element->GetDocument(),
UseCounter::kCSSDeepCombinatorAndShadow);
}
return kSelectorMatches;
}
}
Expand All @@ -464,9 +467,10 @@ SelectorChecker::MatchStatus SelectorChecker::MatchForRelation(
next_context.element =
ParentOrV0ShadowHostElement(*next_context.element)) {
MatchStatus match = MatchSelector(next_context, result);
if (match == kSelectorMatches && context.element->IsInShadowTree())
if (match == kSelectorMatches && context.element->IsInShadowTree()) {
UseCounter::Count(context.element->GetDocument(),
UseCounter::kCSSDeepCombinatorAndShadow);
}
if (match == kSelectorMatches || match == kSelectorFailsCompletely)
return match;
if (NextSelectorExceedsScope(next_context))
Expand Down
3 changes: 2 additions & 1 deletion third_party/WebKit/Source/core/css/StyleSheetList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ HTMLStyleElement* StyleSheetList::GetNamedItem(const AtomicString& name) const {
}

CSSStyleSheet* StyleSheetList::AnonymousNamedGetter(const AtomicString& name) {
if (GetDocument())
if (GetDocument()) {
UseCounter::Count(*GetDocument(),
UseCounter::kStyleSheetListAnonymousNamedGetter);
}
HTMLStyleElement* item = GetNamedItem(name);
if (!item)
return nullptr;
Expand Down
6 changes: 4 additions & 2 deletions third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,14 @@ static void AdjustStyleForDisplay(ComputedStyle& style,
// because our current behavior is different from the spec and we want to
// gather compatibility data.
if (style.PaddingBefore().IsPercentOrCalc() ||
style.PaddingAfter().IsPercentOrCalc())
style.PaddingAfter().IsPercentOrCalc()) {
UseCounter::Count(document,
UseCounter::kFlexboxPercentagePaddingVertical);
}
if (style.MarginBefore().IsPercentOrCalc() ||
style.MarginAfter().IsPercentOrCalc())
style.MarginAfter().IsPercentOrCalc()) {
UseCounter::Count(document, UseCounter::kFlexboxPercentageMarginVertical);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,10 +745,11 @@ PassRefPtr<ComputedStyle> StyleResolver::StyleForElement(
const CSSValue* value =
it->properties->GetPropertyCSSValue(CSSPropertyDisplay);
if (value && value->IsIdentifierValue() &&
ToCSSIdentifierValue(*value).GetValueID() == CSSValueBlock)
ToCSSIdentifierValue(*value).GetValueID() == CSSValueBlock) {
UseCounter::Count(
element->GetDocument(),
UseCounter::kSummaryElementWithDisplayBlockAuthorRule);
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion third_party/WebKit/Source/core/dom/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6300,9 +6300,10 @@ Touch* Document::createTouch(DOMWindow* window,
if (!std::isfinite(force))
force = 0;

if (radius_x || radius_y || rotation_angle || force)
if (radius_x || radius_y || rotation_angle || force) {
UseCounter::Count(*this,
UseCounter::kDocumentCreateTouchMoreThanSevenArguments);
}

// FIXME: It's not clear from the documentation at
// http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html
Expand Down
3 changes: 2 additions & 1 deletion third_party/WebKit/Source/core/dom/ElementFullscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ void ElementFullscreen::requestFullscreen(Element& element) {
}

void ElementFullscreen::webkitRequestFullscreen(Element& element) {
if (element.IsInShadowTree())
if (element.IsInShadowTree()) {
UseCounter::Count(element.GetDocument(),
UseCounter::kPrefixedElementRequestFullscreenInShadow);
}
Fullscreen::RequestFullscreen(element, Fullscreen::RequestType::kPrefixed);
}

Expand Down
3 changes: 2 additions & 1 deletion third_party/WebKit/Source/core/dom/PseudoElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ PseudoElement::PseudoElement(Element* parent, PseudoId pseudo_id)
SetParentOrShadowHostNode(parent);
SetHasCustomStyleCallbacks();
if ((pseudo_id == kPseudoIdBefore || pseudo_id == kPseudoIdAfter) &&
parent->HasTagName(HTMLNames::inputTag))
parent->HasTagName(HTMLNames::inputTag)) {
UseCounter::Count(parent->GetDocument(),
UseCounter::kPseudoBeforeAfterForInputElement);
}
}

PassRefPtr<ComputedStyle> PseudoElement::CustomStyleForLayoutObject() {
Expand Down
3 changes: 2 additions & 1 deletion third_party/WebKit/Source/core/dom/StyleEngineContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ void StyleEngineContext::AddingPendingSheet(const Document& document) {
// treated as before-body.
if (!added_pending_sheet_before_body_) {
added_pending_sheet_before_body_ = !document.body();
if (!added_pending_sheet_before_body_)
if (!added_pending_sheet_before_body_) {
UseCounter::Count(document,
UseCounter::kPendingStylesheetAddedAfterBodyStarted);
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions third_party/WebKit/Source/core/events/EventTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,9 +652,10 @@ bool EventTarget::FireEventListeners(Event* event,
if (CheckTypeThenUseCount(event, EventTypeNames::beforeunload,
UseCounter::kDocumentBeforeUnloadFired)) {
if (LocalDOMWindow* executing_window = this->ExecutingWindow()) {
if (executing_window != executing_window->top())
if (executing_window != executing_window->top()) {
UseCounter::Count(executing_window->document(),
UseCounter::kSubFrameBeforeUnloadFired);
}
}
} else if (CheckTypeThenUseCount(event, EventTypeNames::unload,
UseCounter::kDocumentUnloadFired)) {
Expand All @@ -676,9 +677,10 @@ bool EventTarget::FireEventListeners(Event* event,
UseCounter::kPointerDownFired)) {
if (LocalDOMWindow* executing_window = this->ExecutingWindow()) {
if (event->IsPointerEvent() &&
static_cast<PointerEvent*>(event)->pointerType() == "touch")
static_cast<PointerEvent*>(event)->pointerType() == "touch") {
UseCounter::Count(executing_window->document(),
UseCounter::kPointerDownFiredForTouch);
}
}
} else if (CheckTypeThenUseCount(event, EventTypeNames::pointerenter,
UseCounter::kPointerEnterLeaveFired)) {
Expand Down
3 changes: 2 additions & 1 deletion third_party/WebKit/Source/core/frame/csp/CSPSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ bool CSPSource::HostMatches(const String& host) const {
// the following count measures when a match fails that would have
// passed the old, incorrect style, in case a lot of sites were
// relying on that behavior.
if (document && equal_hosts)
if (document && equal_hosts) {
UseCounter::Count(*document,
UseCounter::kCSPSourceWildcardWouldMatchExactHost);
}
} else {
// host-part = 1*host-char *( "." 1*host-char )
match = equal_hosts;
Expand Down
6 changes: 4 additions & 2 deletions third_party/WebKit/Source/core/html/HTMLElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ void HTMLElement::MapLanguageAttributeToLocale(const AtomicString& value,
first_separator = ui_language.find('_');
if (first_separator != kNotFound)
ui_language = ui_language.Left(first_separator);
if (!DeprecatedEqualIgnoringCase(html_language, ui_language))
if (!DeprecatedEqualIgnoringCase(html_language, ui_language)) {
UseCounter::Count(GetDocument(),
UseCounter::kLangAttributeDoesNotMatchToUILocale);
}
} else {
// The empty string means the language is explicitly unknown.
AddPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale,
Expand Down Expand Up @@ -248,9 +249,10 @@ void HTMLElement::CollectStyleForPresentationAttribute(
AddPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLineBreak,
CSSValueAfterWhiteSpace);
UseCounter::Count(GetDocument(), UseCounter::kContentEditableTrue);
if (HasTagName(htmlTag))
if (HasTagName(htmlTag)) {
UseCounter::Count(GetDocument(),
UseCounter::kContentEditableTrueOnHTML);
}
} else if (DeprecatedEqualIgnoringCase(value, "plaintext-only")) {
AddPropertyToPresentationAttributeStyle(
style, CSSPropertyWebkitUserModify, CSSValueReadWritePlaintextOnly);
Expand Down
6 changes: 4 additions & 2 deletions third_party/WebKit/Source/core/html/HTMLFormElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,10 @@ void HTMLFormElement::ScheduleFormSubmission(FormSubmission* submission) {

UseCounter::Count(GetDocument(), UseCounter::kFormsSubmitted);
if (MixedContentChecker::IsMixedFormAction(GetDocument().GetFrame(),
submission->Action()))
submission->Action())) {
UseCounter::Count(GetDocument().GetFrame(),
UseCounter::kMixedContentFormsSubmitted);
}

// TODO(lukasza): Investigate if the code below can uniformly handle remote
// and local frames (i.e. by calling virtual Frame::navigate from a timer).
Expand Down Expand Up @@ -527,9 +528,10 @@ void HTMLFormElement::ParseAttribute(
attributes_.Action().IsEmpty() ? GetDocument().Url().GetString()
: attributes_.Action());
if (MixedContentChecker::IsMixedFormAction(GetDocument().GetFrame(),
action_url))
action_url)) {
UseCounter::Count(GetDocument().GetFrame(),
UseCounter::kMixedContentFormPresent);
}
} else if (name == targetAttr) {
attributes_.SetTarget(params.new_value);
} else if (name == methodAttr) {
Expand Down
3 changes: 2 additions & 1 deletion third_party/WebKit/Source/core/html/HTMLImageElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,10 @@ ImageCandidate HTMLImageElement::FindBestFitImageFromPictureParent() {
continue;

HTMLSourceElement* source = toHTMLSourceElement(child);
if (!source->FastGetAttribute(srcAttr).IsNull())
if (!source->FastGetAttribute(srcAttr).IsNull()) {
Deprecation::CountDeprecation(GetDocument(),
UseCounter::kPictureSourceSrc);
}
String srcset = source->FastGetAttribute(srcsetAttr);
if (srcset.IsEmpty())
continue;
Expand Down
6 changes: 4 additions & 2 deletions third_party/WebKit/Source/core/html/HTMLLabelElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ LabelableElement* HTMLLabelElement::control() const {
for (LabelableElement& element :
Traversal<LabelableElement>::DescendantsOf(*this)) {
if (element.SupportLabels()) {
if (!element.IsFormControlElement())
if (!element.IsFormControlElement()) {
UseCounter::Count(
GetDocument(),
UseCounter::kHTMLLabelElementControlForNonFormAssociatedElement);
}
return &element;
}
}
Expand All @@ -75,10 +76,11 @@ LabelableElement* HTMLLabelElement::control() const {
if (Element* element = GetTreeScope().getElementById(control_id)) {
if (IsLabelableElement(*element) &&
ToLabelableElement(*element).SupportLabels()) {
if (!element->IsFormControlElement())
if (!element->IsFormControlElement()) {
UseCounter::Count(
GetDocument(),
UseCounter::kHTMLLabelElementControlForNonFormAssociatedElement);
}
return ToLabelableElement(element);
}
}
Expand Down
3 changes: 2 additions & 1 deletion third_party/WebKit/Source/core/html/HTMLScriptElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ Node::InsertionNotificationRequest HTMLScriptElement::InsertedInto(
ScriptType script_type = ScriptType::kClassic;
if (insertion_point->isConnected() && HasSourceAttribute() &&
!Loader()->IsScriptTypeSupported(
ScriptLoader::kDisallowLegacyTypeInTypeAttribute, script_type))
ScriptLoader::kDisallowLegacyTypeInTypeAttribute, script_type)) {
UseCounter::Count(GetDocument(),
UseCounter::kScriptElementWithInvalidTypeHasSrc);
}
HTMLElement::InsertedInto(insertion_point);
LogAddElementIfIsolatedWorldAndInDocument("script", srcAttr);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ void BaseCheckableInputType::SetValue(const String& sanitized_value,
}

void BaseCheckableInputType::ReadingChecked() const {
if (is_in_click_handler_)
if (is_in_click_handler_) {
UseCounter::Count(GetElement().GetDocument(),
UseCounter::kReadingCheckedInClickHandler);
}
}

bool BaseCheckableInputType::IsCheckable() {
Expand Down
3 changes: 2 additions & 1 deletion third_party/WebKit/Source/core/html/forms/RangeInputType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ InputType::ValueMode RangeInputType::GetValueMode() const {
void RangeInputType::CountUsage() {
CountUsageIfVisible(UseCounter::kInputTypeRange);
if (const ComputedStyle* style = GetElement().GetComputedStyle()) {
if (style->Appearance() == kSliderVerticalPart)
if (style->Appearance() == kSliderVerticalPart) {
UseCounter::Count(GetElement().GetDocument(),
UseCounter::kInputTypeRangeVerticalAppearance);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ void HTMLImportChild::DidFinish() {

void HTMLImportChild::DidFinishLoading() {
StateWillChange();
if (GetDocument() && GetDocument()->GetStyleEngine().HasStyleSheets())
if (GetDocument() && GetDocument()->GetStyleEngine().HasStyleSheets()) {
UseCounter::Count(Root()->GetDocument(),
UseCounter::kHTMLImportsHasStyleSheets);
}
V0CustomElement::DidFinishLoadingImport(*(Root()->GetDocument()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ HTMLImportChild* HTMLImportsController::CreateChild(
HTMLImport::SyncMode mode = client->IsSync() && !MakesCycle(parent, url)
? HTMLImport::kSync
: HTMLImport::kAsync;
if (mode == HTMLImport::kAsync)
if (mode == HTMLImport::kAsync) {
UseCounter::Count(Root()->GetDocument(),
UseCounter::kHTMLImportsAsyncAttribute);
}

HTMLImportChild* child = new HTMLImportChild(url, loader, mode);
child->SetClient(client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,10 @@ void KeyboardEventManager::DefaultBackspaceEventHandler(KeyboardEvent* event) {
if (!frame_->GetEditor().Behavior().ShouldNavigateBackOnBackspace())
return;
UseCounter::Count(frame_->GetDocument(), UseCounter::kBackspaceNavigatedBack);
if (frame_->GetPage()->GetChromeClient().HadFormInteraction())
if (frame_->GetPage()->GetChromeClient().HadFormInteraction()) {
UseCounter::Count(frame_->GetDocument(),
UseCounter::kBackspaceNavigatedBackAfterFormInteraction);
}
bool handled_event = frame_->Loader().Client()->NavigateBackForward(
event->shiftKey() ? 1 : -1);
if (handled_event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,15 @@ LayoutDeprecatedFlexibleBox::LayoutDeprecatedFlexibleBox(Element& element)
stretching_children_ = false;
if (!IsAnonymous()) {
const KURL& url = GetDocument().Url();
if (url.ProtocolIs("chrome"))
if (url.ProtocolIs("chrome")) {
UseCounter::Count(GetDocument(), UseCounter::kDeprecatedFlexboxChrome);
else if (url.ProtocolIs("chrome-extension"))
} else if (url.ProtocolIs("chrome-extension")) {
UseCounter::Count(GetDocument(),
UseCounter::kDeprecatedFlexboxChromeExtension);
else
} else {
UseCounter::Count(GetDocument(),
UseCounter::kDeprecatedFlexboxWebContent);
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ float LayoutFlexibleBox::CountIntrinsicSizeForAlgorithmChange(
float max_content_flex_fraction =
max_preferred_logical_width.ToFloat() / flex_grow;
if (previous_max_content_flex_fraction != -1 &&
max_content_flex_fraction != previous_max_content_flex_fraction)
max_content_flex_fraction != previous_max_content_flex_fraction) {
UseCounter::Count(GetDocument(),
UseCounter::kFlexboxIntrinsicSizeAlgorithmIsDifferent);
}
return max_content_flex_fraction;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,9 +843,10 @@ bool CompositedLayerMapping::UpdateGraphicsLayerConfiguration() {
style.HasWillChangeTransformHint());

if (style.Preserves3D() && style.HasOpacity() &&
owning_layer_.Has3DTransformedDescendant())
owning_layer_.Has3DTransformedDescendant()) {
UseCounter::Count(layout_object.GetDocument(),
UseCounter::kOpacityWithPreserve3DQuirk);
}

return layer_config_changed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ void PointerLockController::RequestPointerLock(Element* target) {

UseCounter::CountCrossOriginIframe(
target->GetDocument(), UseCounter::kElementRequestPointerLockIframe);
if (target->IsInShadowTree())
if (target->IsInShadowTree()) {
UseCounter::Count(target->GetDocument(),
UseCounter::kElementRequestPointerLockInShadow);
}

if (target->GetDocument().IsSandboxed(kSandboxPointerLock)) {
// FIXME: This message should be moved off the console once a solution to
Expand Down
Loading

0 comments on commit adecd2e

Please sign in to comment.