Commit f2c8dd2a authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Refactor: unsigned short -> uint8_t/uint16_t in...

Refactor: unsigned short -> uint8_t/uint16_t in third_party/blink/renderer/platform/wtf/text/utf8.cc

- unsigned short -> uint8_t/uint16_t.
- Reference: https://google.github.io/styleguide/cppguide.html#Integer_Types

Bug: 929986
Change-Id: I497af04207c19c5d390b42c6874001844f023363
Reviewed-on: https://chromium-review.googlesource.com/c/1496121
Commit-Queue: Miyoung Shin <myid.shin@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636784}
parent 235a1c62
...@@ -66,12 +66,12 @@ ConversionResult ConvertLatin1ToUTF8(const LChar** source_start, ...@@ -66,12 +66,12 @@ ConversionResult ConvertLatin1ToUTF8(const LChar** source_start,
char* target = *target_start; char* target = *target_start;
while (source < source_end) { while (source < source_end) {
UChar32 ch; UChar32 ch;
unsigned short bytes_to_write = 0; uint8_t bytes_to_write = 0;
const UChar32 kByteMask = 0xBF; const UChar32 kByteMask = 0xBF;
const UChar32 kByteMark = 0x80; const UChar32 kByteMark = 0x80;
const LChar* old_source = const LChar* old_source =
source; // In case we have to back up because of target overflow. source; // In case we have to back up because of target overflow.
ch = static_cast<unsigned short>(*source++); ch = static_cast<UChar32>(*source++);
// Figure out how many bytes the result will require // Figure out how many bytes the result will require
if (ch < (UChar32)0x80) if (ch < (UChar32)0x80)
...@@ -111,17 +111,17 @@ ConversionResult ConvertUTF16ToUTF8(const UChar** source_start, ...@@ -111,17 +111,17 @@ ConversionResult ConvertUTF16ToUTF8(const UChar** source_start,
char* target = *target_start; char* target = *target_start;
while (source < source_end) { while (source < source_end) {
UChar32 ch; UChar32 ch;
unsigned short bytes_to_write = 0; uint8_t bytes_to_write = 0;
const UChar32 kByteMask = 0xBF; const UChar32 kByteMask = 0xBF;
const UChar32 kByteMark = 0x80; const UChar32 kByteMark = 0x80;
const UChar* old_source = const UChar* old_source =
source; // In case we have to back up because of target overflow. source; // In case we have to back up because of target overflow.
ch = static_cast<unsigned short>(*source++); ch = static_cast<UChar32>(*source++);
// If we have a surrogate pair, convert to UChar32 first. // If we have a surrogate pair, convert to UChar32 first.
if (ch >= 0xD800 && ch <= 0xDBFF) { if (ch >= 0xD800 && ch <= 0xDBFF) {
// If the 16 bits following the high surrogate are in the source buffer... // If the 16 bits following the high surrogate are in the source buffer...
if (source < source_end) { if (source < source_end) {
UChar32 ch2 = static_cast<unsigned short>(*source); UChar32 ch2 = static_cast<UChar32>(*source);
// If it's a low surrogate, convert to UChar32. // If it's a low surrogate, convert to UChar32.
if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) { if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) {
ch = ((ch - 0xD800) << 10) + (ch2 - 0xDC00) + 0x0010000; ch = ((ch - 0xD800) << 10) + (ch2 - 0xDC00) + 0x0010000;
......
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