Commit 2de0ccb8 authored by Eric Roman's avatar Eric Roman Committed by Commit Bot

Make use of new hex decoding function for extensions color string parser.

Bug: 1021236
Change-Id: I1d1b5180048eb36fa78406a02fc3277cba0dcf63
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1904809
Commit-Queue: Eric Roman <eroman@chromium.org>
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Auto-Submit: Eric Roman <eroman@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713942}
parent 2c68826c
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <stdint.h> #include <stdint.h>
#include <algorithm> #include <algorithm>
#include <vector>
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
...@@ -65,9 +64,9 @@ bool ParseHexColorString(const std::string& color_string, SkColor* result) { ...@@ -65,9 +64,9 @@ bool ParseHexColorString(const std::string& color_string, SkColor* result) {
formatted_color += color_string[i]; formatted_color += color_string[i];
} }
} else if (color_string.length() == 7) { } else if (color_string.length() == 7) {
formatted_color = color_string.substr(1, 6); formatted_color.assign(color_string, 1, 6);
} else if (color_string.length() == 9) { } else if (color_string.length() == 9) {
formatted_color = color_string.substr(1, 8); formatted_color.assign(color_string, 1, 8);
} else { } else {
return false; return false;
} }
...@@ -77,10 +76,9 @@ bool ParseHexColorString(const std::string& color_string, SkColor* result) { ...@@ -77,10 +76,9 @@ bool ParseHexColorString(const std::string& color_string, SkColor* result) {
formatted_color += "FF"; formatted_color += "FF";
} }
// Convert the string to an integer and make sure it is in the correct value // Convert the hex string to an integer.
// range. std::array<uint8_t, 4> color_bytes;
std::vector<uint8_t> color_bytes; if (!base::HexStringToSpan(formatted_color, color_bytes))
if (!base::HexStringToBytes(formatted_color, &color_bytes))
return false; return false;
*result = SkColorSetARGB(color_bytes[3], color_bytes[0], color_bytes[1], *result = SkColorSetARGB(color_bytes[3], color_bytes[0], color_bytes[1],
......
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