Remove variable shadowing in blink/frame
In an effort to reduce or even ban variable shadowing, this renames a
couple of variables. I'm interested in prohibiting shadowing because I
think it might prevent potential jumbo problems.
The exact error this avoids is:
third_party/blink/renderer/core/frame/frame_serializer.cc:301:12: error: declaration shadows a local variable [-Werror,-Wshadow]
KURL url =
^
third_party/blink/renderer/core/frame/frame_serializer.cc:261:8: note: previous declaration is here
KURL url = document.Url();
^
third_party/blink/renderer/core/frame/frame_serializer.cc:307:14: error: declaration shadows a local variable [-Werror,-Wshadow]
KURL url = input->Src();
^
third_party/blink/renderer/core/frame/frame_serializer.cc:261:8: note: previous declaration is here
KURL url = document.Url();
^
third_party/blink/renderer/core/frame/frame_serializer.cc:313:14: error: declaration shadows a local variable [-Werror,-Wshadow]
KURL url =
^
third_party/blink/renderer/core/frame/frame_serializer.cc:261:8: note: previous declaration is here
KURL url = document.Url();
^
third_party/blink/renderer/core/frame/local_frame_ukm_aggregator.cc:110:14: error: declaration shadows a local variable [-Werror,-Wshadow]
String uma_name = uma_percentage_preamble;
^
third_party/blink/renderer/core/frame/local_frame_ukm_aggregator.cc:94:10: note: previous declaration is here
auto uma_name = uma_preamble;
^
third_party/blink/renderer/core/frame/rotation_viewport_anchor.cc:52:21: error: declaration shadows a local variable [-Werror,-Wshadow]
HitTestLocation location(point + point_offset);
^
third_party/blink/renderer/core/frame/rotation_viewport_anchor.cc:30:19: note: previous declaration is here
HitTestLocation location(point);
^
Bug: 923510
Change-Id: I9bd46559f31e6b3fdb412cf7787b764ae84c775b
Reviewed-on: https://chromium-review.googlesource.com/c/1494659
Commit-Queue: Daniel Bratell <bratell@opera.com>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Auto-Submit: Daniel Bratell <bratell@opera.com>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#636453}
diff --git a/third_party/blink/renderer/core/frame/frame_serializer.cc b/third_party/blink/renderer/core/frame/frame_serializer.cc
index cc15dd0..de81b2a 100644
--- a/third_party/blink/renderer/core/frame/frame_serializer.cc
+++ b/third_party/blink/renderer/core/frame/frame_serializer.cc
@@ -298,21 +298,21 @@
}
if (const auto* image = ToHTMLImageElementOrNull(element)) {
- KURL url =
+ KURL image_url =
document.CompleteURL(image->getAttribute(html_names::kSrcAttr));
ImageResourceContent* cached_image = image->CachedImage();
- AddImageToResources(cached_image, url);
+ AddImageToResources(cached_image, image_url);
} else if (const auto* input = ToHTMLInputElementOrNull(element)) {
if (input->type() == input_type_names::kImage && input->ImageLoader()) {
- KURL url = input->Src();
+ KURL image_url = input->Src();
ImageResourceContent* cached_image = input->ImageLoader()->GetContent();
- AddImageToResources(cached_image, url);
+ AddImageToResources(cached_image, image_url);
}
} else if (const auto* link = ToHTMLLinkElementOrNull(element)) {
if (CSSStyleSheet* sheet = link->sheet()) {
- KURL url =
+ KURL sheet_url =
document.CompleteURL(link->getAttribute(html_names::kHrefAttr));
- SerializeCSSStyleSheet(*sheet, url);
+ SerializeCSSStyleSheet(*sheet, sheet_url);
}
} else if (const auto* style = ToHTMLStyleElementOrNull(element)) {
if (CSSStyleSheet* sheet = style->sheet())
diff --git a/third_party/blink/renderer/core/frame/local_frame_ukm_aggregator.cc b/third_party/blink/renderer/core/frame/local_frame_ukm_aggregator.cc
index 152ba1b..feee735 100644
--- a/third_party/blink/renderer/core/frame/local_frame_ukm_aggregator.cc
+++ b/third_party/blink/renderer/core/frame/local_frame_ukm_aggregator.cc
@@ -91,7 +91,7 @@
absolute_record.average_metric_name = metric_name;
absolute_record.average_metric_name.append(".Average");
absolute_record.reset();
- auto uma_name = uma_preamble;
+ String uma_name = uma_preamble;
uma_name.append(metric_name);
uma_name.append(uma_postscript);
absolute_record.uma_counter.reset(
@@ -107,13 +107,13 @@
percentage_record.average_metric_name.append(".AverageRatio");
percentage_record.reset();
for (auto bucket_substring : threshold_substrings) {
- String uma_name = uma_percentage_preamble;
- uma_name.append(metric_name);
- uma_name.append(uma_percentage_postscript);
- uma_name.append(bucket_substring);
+ String uma_percentage_name = uma_percentage_preamble;
+ uma_percentage_name.append(metric_name);
+ uma_percentage_name.append(uma_percentage_postscript);
+ uma_percentage_name.append(bucket_substring);
percentage_record.uma_counters_per_bucket.push_back(
- std::make_unique<CustomCountHistogram>(uma_name.Utf8().data(), 0,
- 10000000, 50));
+ std::make_unique<CustomCountHistogram>(
+ uma_percentage_name.Utf8().data(), 0, 10000000, 50));
}
}
}
diff --git a/third_party/blink/renderer/core/frame/rotation_viewport_anchor.cc b/third_party/blink/renderer/core/frame/rotation_viewport_anchor.cc
index c87d81d..fa7863d 100644
--- a/third_party/blink/renderer/core/frame/rotation_viewport_anchor.cc
+++ b/third_party/blink/renderer/core/frame/rotation_viewport_anchor.cc
@@ -49,10 +49,11 @@
if (node_size.Width() * node_size.Height() > max_node_area) {
IntSize point_offset = view_rect.Size();
point_offset.Scale(kViewportAnchorRelativeEpsilon);
- HitTestLocation location(point + point_offset);
+ HitTestLocation alternative_location(point + point_offset);
node = event_handler
- .HitTestResultAtLocation(location, HitTestRequest::kReadOnly |
- HitTestRequest::kActive)
+ .HitTestResultAtLocation(
+ alternative_location,
+ HitTestRequest::kReadOnly | HitTestRequest::kActive)
.InnerNode();
}