Commit 980663c9 authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Remove some variable shadowing in blink/core

In an effort to reduce or even ban variable shadowing, this renames
some variables. I'm interested in prohibiting shadowing because
I think it might prevent potential jumbo problems.

The exact warnings this prevents is:

third_party/blink/renderer/core/fileapi/file_reader_loader.cc:358:16: error: declaration shadows a local variable [-Werror,-Wshadow]
    MojoResult result = consumer_handle_->BeginReadData(
               ^
third_party/blink/renderer/core/fileapi/file_reader_loader.cc:346:54: note: previous declaration is here
void FileReaderLoader::OnDataPipeReadable(MojoResult result) {
                                                     ^

third_party/blink/renderer/core/aom/accessible_node.cc:288:16: error: declaration shadows a local variable [-Werror,-Wshadow]
      Element* element = accessible_node->element();
               ^
third_party/blink/renderer/core/aom/accessible_node.cc:278:43: note: previous declaration is here
bool AccessibleNode::GetProperty(Element* element,
                                          ^

third_party/blink/renderer/core/invisible_dom/invisible_dom.cc:43:16: error: declaration shadows a local variable [-Werror,-Wshadow]
    for (Node& node : FlatTreeTraversal::AncestorsOf(node)) {
               ^
third_party/blink/renderer/core/invisible_dom/invisible_dom.cc:40:14: note: previous declaration is here
  for (Node& node : range.Nodes()) {
             ^

third_party/blink/renderer/core/loader/frame_loader.cc:892:10: error: declaration shadows a local variable [-Werror,-Wshadow]
    auto request = mojo::MakeRequest(&navigation_initiator);
         ^
third_party/blink/renderer/core/loader/frame_loader.cc:798:20: note: previous declaration is here
  FrameLoadRequest request(passed_request);
                   ^

third_party/blink/renderer/core/script/modulator.cc:52:20: error: declaration shadows a local variable [-Werror,-Wshadow]
  } else if (auto* scope = DynamicTo<WorkerGlobalScope>(execution_context)) {
                   ^
third_party/blink/renderer/core/script/modulator.cc:45:20: note: previous declaration is here
  } else if (auto* scope = DynamicTo<WorkletGlobalScope>(execution_context)) {
                   ^

Bug: 923510
Change-Id: I82659c403eb15b4f676d24b97414bfbbced9d701
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1508517
Commit-Queue: Daniel Bratell <bratell@opera.com>
Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#638662}
parent d8cc4739
......@@ -285,9 +285,8 @@ bool AccessibleNode::GetProperty(Element* element,
for (wtf_size_t i = 0; i < node_list->length(); ++i) {
AccessibleNode* accessible_node = node_list->item(i);
if (accessible_node) {
Element* element = accessible_node->element();
if (element)
targets.push_back(element);
if (Element* target_element = accessible_node->element())
targets.push_back(target_element);
}
}
......
......@@ -355,17 +355,18 @@ void FileReaderLoader::OnDataPipeReadable(MojoResult result) {
while (true) {
uint32_t num_bytes;
const void* buffer;
MojoResult result = consumer_handle_->BeginReadData(
MojoResult pipe_result = consumer_handle_->BeginReadData(
&buffer, &num_bytes, MOJO_READ_DATA_FLAG_NONE);
if (result == MOJO_RESULT_SHOULD_WAIT) {
if (pipe_result == MOJO_RESULT_SHOULD_WAIT) {
if (!IsSyncLoad())
return;
result = mojo::Wait(consumer_handle_.get(), MOJO_HANDLE_SIGNAL_READABLE);
if (result == MOJO_RESULT_OK)
pipe_result =
mojo::Wait(consumer_handle_.get(), MOJO_HANDLE_SIGNAL_READABLE);
if (pipe_result == MOJO_RESULT_OK)
continue;
}
if (result == MOJO_RESULT_FAILED_PRECONDITION) {
if (pipe_result == MOJO_RESULT_FAILED_PRECONDITION) {
// Pipe closed.
if (!received_all_data_) {
Failed(FileErrorCode::kNotReadableErr,
......@@ -373,7 +374,7 @@ void FileReaderLoader::OnDataPipeReadable(MojoResult result) {
}
return;
}
if (result != MOJO_RESULT_OK) {
if (pipe_result != MOJO_RESULT_OK) {
Failed(FileErrorCode::kNotReadableErr,
FailureType::kMojoPipeUnexpectedReadError);
return;
......
......@@ -46,9 +46,9 @@ bool InvisibleDOM::ActivateRangeIfNeeded(
for (Node& node : range.Nodes()) {
if (!InvisibleDOM::IsInsideInvisibleSubtree(node))
continue;
for (Node& node : FlatTreeTraversal::AncestorsOf(node)) {
if (node.IsElementNode()) {
elements_to_activate.push_back(ToElement(node));
for (Node& ancestor_node : FlatTreeTraversal::AncestorsOf(node)) {
if (ancestor_node.IsElementNode()) {
elements_to_activate.push_back(ToElement(ancestor_node));
break;
}
}
......
......@@ -893,8 +893,8 @@ void FrameLoader::StartNavigation(const FrameLoadRequest& passed_request,
->ExperimentalFeaturesEnabled()) {
initiator_csp = origin_document->GetContentSecurityPolicy()
->ExposeForNavigationalChecks();
auto request = mojo::MakeRequest(&navigation_initiator);
origin_document->BindNavigationInitiatorRequest(std::move(request));
auto mojo_request = mojo::MakeRequest(&navigation_initiator);
origin_document->BindNavigationInitiatorRequest(std::move(mojo_request));
}
if (origin_document && origin_document->GetContentSecurityPolicy()) {
......
......@@ -42,20 +42,22 @@ Modulator* Modulator::From(ScriptState* script_state) {
// See comment in LocalDOMWindow::modulator_ for this workaround.
LocalDOMWindow* window = document->ExecutingWindow();
window->SetModulator(modulator);
} else if (auto* scope = DynamicTo<WorkletGlobalScope>(execution_context)) {
} else if (auto* worklet_scope =
DynamicTo<WorkletGlobalScope>(execution_context)) {
modulator = WorkletModulatorImpl::Create(script_state);
Modulator::SetModulator(script_state, modulator);
// See comment in WorkerOrWorkletGlobalScope::modulator_ for this
// workaround.
scope->SetModulator(modulator);
} else if (auto* scope = DynamicTo<WorkerGlobalScope>(execution_context)) {
worklet_scope->SetModulator(modulator);
} else if (auto* worker_scope =
DynamicTo<WorkerGlobalScope>(execution_context)) {
modulator = WorkerModulatorImpl::Create(script_state);
Modulator::SetModulator(script_state, modulator);
// See comment in WorkerOrWorkletGlobalScope::modulator_ for this
// workaround.
scope->SetModulator(modulator);
worker_scope->SetModulator(modulator);
} else {
NOTREACHED();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment