[PDF Ink Signatures] Move CheckToolSizeIsInRange() into pdf_ink_brush.h
Move this function out of an anonymous namespace, and make it a static method in PdfInkBrush. Then the function can be used in more places. Bug: 342602620 Change-Id: Id0b445b8ef672bc213acadab20573c5e7fb88dd7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5778759 Commit-Queue: Lei Zhang <thestig@chromium.org> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Reviewed-by: Andy Phan <andyphan@chromium.org> Cr-Commit-Position: refs/heads/main@{#1339990}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
e589e0d80e
commit
c1d35982e6
@ -91,6 +91,12 @@ std::optional<PdfInkBrush::Type> PdfInkBrush::StringToType(
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// static
|
||||
void PdfInkBrush::CheckToolSizeIsInRange(float size) {
|
||||
CHECK_GE(size, 1);
|
||||
CHECK_LE(size, 16);
|
||||
}
|
||||
|
||||
PdfInkBrush::PdfInkBrush(Type brush_type, Params brush_params)
|
||||
: ink_brush_(CreateInkBrush(brush_type, brush_params)) {
|
||||
CHECK(ink_brush_);
|
||||
|
@ -53,6 +53,9 @@ class PdfInkBrush {
|
||||
// does not correspond to any `Type`.
|
||||
static std::optional<Type> StringToType(const std::string& brush_type);
|
||||
|
||||
// Validates `size` is in range.
|
||||
static void CheckToolSizeIsInRange(float size);
|
||||
|
||||
// Returns the `InkBrush` that `this` represents.
|
||||
const InkBrush& GetInkBrush() const;
|
||||
|
||||
|
@ -104,11 +104,6 @@ gfx::Rect InkRectToEnclosingGfxRect(const InkRect& rect) {
|
||||
return gfx::ToEnclosingRect(gfx::RectF(x, y, width, height));
|
||||
}
|
||||
|
||||
void CheckToolSizeIsInRange(float size) {
|
||||
CHECK_GE(size, 1);
|
||||
CHECK_LE(size, 16);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
PdfInkModule::PdfInkModule(Client& client) : client_(client) {
|
||||
@ -556,7 +551,7 @@ void PdfInkModule::HandleSetAnnotationBrushMessage(
|
||||
CHECK(data);
|
||||
|
||||
float size = base::checked_cast<float>(data->FindDouble("size").value());
|
||||
CheckToolSizeIsInRange(size);
|
||||
PdfInkBrush::CheckToolSizeIsInRange(size);
|
||||
|
||||
const std::string& brush_type_string = *data->FindString("type");
|
||||
if (brush_type_string == "eraser") {
|
||||
|
Reference in New Issue
Block a user