Commit 5534eb6f authored by Joao Victor Almeida's avatar Joao Victor Almeida Committed by Commit Bot

Add base::ClampToRange to Blink allowed dependencies.

There are some definitions of ClampToRange functions within Blink
avoiding the usage of base::ClampToRange.
But there are already dependencies from Blink to base/numerics and
to other clamping functions in base so it doesn't appear to be any
particular reason to exclude this from the allowed dependencies.

Bug: 1071230
Change-Id: I2c99eddafe79020490d3dcf722aab5c1dce56140
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2153757Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarDaniel Libby <dlibby@microsoft.com>
Commit-Queue: João Victor Almeida de Aguiar <joalmei@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#759881}
parent 2883cd18
......@@ -28,6 +28,7 @@ include_rules = [
"+base/metrics/single_sample_metrics.h",
"+base/numerics/checked_math.h",
"+base/numerics/clamped_math.h",
"+base/numerics/ranges.h",
"+base/numerics/safe_conversions.h",
"+base/optional.h",
"+base/rand_util.h",
......
......@@ -7,6 +7,7 @@
#include <algorithm>
#include "base/metrics/histogram_macros.h"
#include "base/numerics/ranges.h"
#include "skia/ext/image_operations.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
......@@ -23,15 +24,6 @@
namespace blink {
namespace {
// Because including base::ClampToRange would be a dependency violation.
int ClampToRange(const int value, const int min, const int max) {
return std::min(std::max(value, min), max);
}
} // namespace
void ThreadedIconLoader::Start(
ExecutionContext* execution_context,
const ResourceRequest& resource_request,
......@@ -146,11 +138,11 @@ void ThreadedIconLoader::DecodeAndResizeImageOnBackgroundThread(
}
int resized_width =
ClampToRange(static_cast<int>(scale * decoded_icon_.width()), 1,
resize_dimensions_->width());
base::ClampToRange(static_cast<int>(scale * decoded_icon_.width()), 1,
resize_dimensions_->width());
int resized_height =
ClampToRange(static_cast<int>(scale * decoded_icon_.height()), 1,
resize_dimensions_->height());
base::ClampToRange(static_cast<int>(scale * decoded_icon_.height()), 1,
resize_dimensions_->height());
// Use the RESIZE_GOOD quality allowing the implementation to pick an
// appropriate method for the resize. Can be increased to RESIZE_BETTER
......
......@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/modules/xr/xr_webgl_layer.h"
#include "base/numerics/ranges.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
......@@ -32,11 +33,6 @@ const char kCleanFrameWarning[] =
"drawing anything to the baseLayer's framebuffer, resulting in no visible "
"output.";
// Because including base::ClampToRange would be a dependency violation
double ClampToRange(const double value, const double min, const double max) {
return std::min(std::max(value, min), max);
}
} // namespace
XRWebGLLayer* XRWebGLLayer::Create(
......@@ -119,8 +115,8 @@ XRWebGLLayer* XRWebGLLayer::Create(
// small to see or unreasonably large.
// TODO: Would be best to have the max value communicated from the service
// rather than limited to the native res.
framebuffer_scale = ClampToRange(initializer->framebufferScaleFactor(),
kFramebufferMinScale, max_scale);
framebuffer_scale = base::ClampToRange(
initializer->framebufferScaleFactor(), kFramebufferMinScale, max_scale);
}
DoubleSize framebuffers_size = session->DefaultFramebufferSize();
......
......@@ -26,6 +26,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_FONT_SELECTION_TYPES_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_FONT_SELECTION_TYPES_H_
#include "base/numerics/ranges.h"
#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/hash_table_deleted_value_type.h"
......@@ -341,11 +342,7 @@ struct FontSelectionRange {
}
FontSelectionValue clampToRange(FontSelectionValue selection_value) const {
if (selection_value < minimum)
return minimum;
if (selection_value > maximum)
return maximum;
return selection_value;
return base::ClampToRange(selection_value, minimum, maximum);
}
FontSelectionValue minimum{FontSelectionValue(1)};
......
......@@ -174,6 +174,9 @@ _CONFIG = [
'base::ClampSub',
'base::MakeClampedNum',
# //base/numerics/ranges.h.
"base::ClampToRange",
# //base/strings/strcat.h.
'base::StrCat',
......
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