Clang-format some more code in core/.
Use "git cl format --full" to tidy code a bit more. Then do some manual
updates to fix more nits.
Change-Id: I061400283e316e775b6e176fa735cfd5a6bdce9e
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/63770
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/cmaps/CNS1/ETenms-B5-H_0.cpp b/core/fpdfapi/cmaps/CNS1/ETenms-B5-H_0.cpp
index e02f9ed..3cc5573 100644
--- a/core/fpdfapi/cmaps/CNS1/ETenms-B5-H_0.cpp
+++ b/core/fpdfapi/cmaps/CNS1/ETenms-B5-H_0.cpp
@@ -7,5 +7,7 @@
#include "core/fpdfapi/cmaps/CNS1/cmaps_cns1.h"
const uint16_t g_FXCMAP_ETenms_B5_H_0[1 * 3] = {
- 0x0020, 0x007E, 0x0001,
+ 0x0020,
+ 0x007E,
+ 0x0001,
};
diff --git a/core/fpdfapi/font/cfx_cttgsubtable.cpp b/core/fpdfapi/font/cfx_cttgsubtable.cpp
index bb889b6..5492fc2 100644
--- a/core/fpdfapi/font/cfx_cttgsubtable.cpp
+++ b/core/fpdfapi/font/cfx_cttgsubtable.cpp
@@ -21,7 +21,8 @@
bool IsVerticalFeatureTag(uint32_t tag) {
static constexpr uint32_t kTags[] = {
- MakeTag('v', 'r', 't', '2'), MakeTag('v', 'e', 'r', 't'),
+ MakeTag('v', 'r', 't', '2'),
+ MakeTag('v', 'e', 'r', 't'),
};
return tag == kTags[0] || tag == kTags[1];
}
diff --git a/core/fpdfapi/parser/cpdf_stream.h b/core/fpdfapi/parser/cpdf_stream.h
index e7e1bff..d29f655 100644
--- a/core/fpdfapi/parser/cpdf_stream.h
+++ b/core/fpdfapi/parser/cpdf_stream.h
@@ -56,9 +56,7 @@
void InitStreamFromFile(const RetainPtr<IFX_SeekableReadStream>& pFile,
RetainPtr<CPDF_Dictionary> pDict);
- bool ReadRawData(FX_FILESIZE offset,
- uint8_t* pBuf,
- uint32_t buf_size) const;
+ bool ReadRawData(FX_FILESIZE offset, uint8_t* pBuf, uint32_t buf_size) const;
bool IsMemoryBased() const { return m_bMemoryBased; }
bool HasFilter() const;
diff --git a/core/fxcodec/gif/cfx_gifcontext_unittest.cpp b/core/fxcodec/gif/cfx_gifcontext_unittest.cpp
index 10ac6dc..20d34ea 100644
--- a/core/fxcodec/gif/cfx_gifcontext_unittest.cpp
+++ b/core/fxcodec/gif/cfx_gifcontext_unittest.cpp
@@ -50,38 +50,38 @@
std::vector<uint8_t> dest_buffer;
uint8_t src_buffer[] = {0x00, 0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08, 0x09};
- CFX_GifContextForTest context(nullptr, nullptr);
+ CFX_GifContextForTest context(nullptr, nullptr);
- context.SetTestInputBuffer({nullptr, 0});
- EXPECT_FALSE(context.ReadAllOrNone(nullptr, 0));
- EXPECT_FALSE(context.ReadAllOrNone(nullptr, 10));
+ context.SetTestInputBuffer({nullptr, 0});
+ EXPECT_FALSE(context.ReadAllOrNone(nullptr, 0));
+ EXPECT_FALSE(context.ReadAllOrNone(nullptr, 10));
- EXPECT_FALSE(context.ReadAllOrNone(dest_buffer.data(), 0));
- EXPECT_FALSE(context.ReadAllOrNone(dest_buffer.data(), 10));
+ EXPECT_FALSE(context.ReadAllOrNone(dest_buffer.data(), 0));
+ EXPECT_FALSE(context.ReadAllOrNone(dest_buffer.data(), 10));
- context.SetTestInputBuffer({src_buffer, 0});
- dest_buffer.resize(sizeof(src_buffer));
- EXPECT_FALSE(context.ReadAllOrNone(dest_buffer.data(), sizeof(src_buffer)));
+ context.SetTestInputBuffer({src_buffer, 0});
+ dest_buffer.resize(sizeof(src_buffer));
+ EXPECT_FALSE(context.ReadAllOrNone(dest_buffer.data(), sizeof(src_buffer)));
- context.SetTestInputBuffer({src_buffer, 1});
- EXPECT_FALSE(context.ReadAllOrNone(dest_buffer.data(), sizeof(src_buffer)));
- EXPECT_EQ(0u, context.InputBuffer()->GetPosition());
- EXPECT_FALSE(context.ReadAllOrNone(nullptr, sizeof(src_buffer)));
- EXPECT_FALSE(context.ReadAllOrNone(nullptr, 1));
+ context.SetTestInputBuffer({src_buffer, 1});
+ EXPECT_FALSE(context.ReadAllOrNone(dest_buffer.data(), sizeof(src_buffer)));
+ EXPECT_EQ(0u, context.InputBuffer()->GetPosition());
+ EXPECT_FALSE(context.ReadAllOrNone(nullptr, sizeof(src_buffer)));
+ EXPECT_FALSE(context.ReadAllOrNone(nullptr, 1));
+ EXPECT_TRUE(context.ReadAllOrNone(dest_buffer.data(), 1));
+ EXPECT_EQ(src_buffer[0], dest_buffer[0]);
+
+ context.SetTestInputBuffer(src_buffer);
+ EXPECT_FALSE(context.ReadAllOrNone(nullptr, sizeof(src_buffer)));
+ EXPECT_TRUE(context.ReadAllOrNone(dest_buffer.data(), sizeof(src_buffer)));
+ for (size_t i = 0; i < sizeof(src_buffer); i++)
+ EXPECT_EQ(src_buffer[i], dest_buffer[i]);
+
+ context.SetTestInputBuffer(src_buffer);
+ for (size_t i = 0; i < sizeof(src_buffer); i++) {
EXPECT_TRUE(context.ReadAllOrNone(dest_buffer.data(), 1));
- EXPECT_EQ(src_buffer[0], dest_buffer[0]);
-
- context.SetTestInputBuffer(src_buffer);
- EXPECT_FALSE(context.ReadAllOrNone(nullptr, sizeof(src_buffer)));
- EXPECT_TRUE(context.ReadAllOrNone(dest_buffer.data(), sizeof(src_buffer)));
- for (size_t i = 0; i < sizeof(src_buffer); i++)
- EXPECT_EQ(src_buffer[i], dest_buffer[i]);
-
- context.SetTestInputBuffer(src_buffer);
- for (size_t i = 0; i < sizeof(src_buffer); i++) {
- EXPECT_TRUE(context.ReadAllOrNone(dest_buffer.data(), 1));
- EXPECT_EQ(src_buffer[i], dest_buffer[0]);
- }
+ EXPECT_EQ(src_buffer[i], dest_buffer[0]);
+ }
}
TEST(CFX_GifContext, ReadGifSignature) {
diff --git a/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp b/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp
index 0a2c359..e31fb78 100644
--- a/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp
+++ b/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp
@@ -133,30 +133,30 @@
auto decompressor = CFX_LZWDecompressor::Create(palette_exp, code_exp);
ASSERT_NE(nullptr, decompressor);
- uint8_t image_data[] = {0x84, 0x8F, 0xA9, 0xCB, 0xED, 0x0F, 0x63, 0x2B};
- uint32_t image_size = FX_ArraySize(image_data);
+ static constexpr uint8_t kImageData[] = {0x84, 0x8F, 0xA9, 0xCB,
+ 0xED, 0x0F, 0x63, 0x2B};
+ uint32_t image_size = FX_ArraySize(kImageData);
- uint8_t expected_data[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- uint8_t output_data[FX_ArraySize(expected_data)];
+ static constexpr uint8_t kExpectedData[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00};
+ uint8_t output_data[FX_ArraySize(kExpectedData)];
memset(output_data, 0, sizeof(output_data));
uint32_t output_size = FX_ArraySize(output_data);
EXPECT_EQ(
CFX_GifDecodeStatus::Success,
- decompressor->Decode(image_data, image_size, output_data, &output_size));
+ decompressor->Decode(kImageData, image_size, output_data, &output_size));
EXPECT_EQ(FX_ArraySize(output_data), output_size);
- EXPECT_TRUE(0 == memcmp(expected_data, output_data, sizeof(expected_data)));
+ EXPECT_TRUE(0 == memcmp(kExpectedData, output_data, sizeof(kExpectedData)));
}
TEST(CFX_LZWDecompressor, Decode10x10MultipleColour) {
@@ -165,33 +165,32 @@
auto decompressor = CFX_LZWDecompressor::Create(palette_exp, code_exp);
ASSERT_NE(nullptr, decompressor);
- uint8_t image_data[] = {0x8C, 0x2D, 0x99, 0x87, 0x2A, 0x1C, 0xDC, 0x33,
- 0xA0, 0x02, 0x75, 0xEC, 0x95, 0xFA, 0xA8, 0xDE,
- 0x60, 0x8C, 0x04, 0x91, 0x4C, 0x01};
- uint32_t image_size = FX_ArraySize(image_data);
+ static constexpr uint8_t kImageData[] = {
+ 0x8C, 0x2D, 0x99, 0x87, 0x2A, 0x1C, 0xDC, 0x33, 0xA0, 0x02, 0x75,
+ 0xEC, 0x95, 0xFA, 0xA8, 0xDE, 0x60, 0x8C, 0x04, 0x91, 0x4C, 0x01};
+ uint32_t image_size = FX_ArraySize(kImageData);
- uint8_t expected_data[] = {
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02,
- 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
- 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01};
+ static constexpr uint8_t kExpectedData[] = {
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
+ 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01,
+ 0x01, 0x01, 0x01, 0x01};
- uint8_t output_data[FX_ArraySize(expected_data)];
+ uint8_t output_data[FX_ArraySize(kExpectedData)];
memset(output_data, 0, sizeof(output_data));
uint32_t output_size = FX_ArraySize(output_data);
EXPECT_EQ(
CFX_GifDecodeStatus::Success,
- decompressor->Decode(image_data, image_size, output_data, &output_size));
+ decompressor->Decode(kImageData, image_size, output_data, &output_size));
EXPECT_EQ(FX_ArraySize(output_data), output_size);
- EXPECT_TRUE(0 == memcmp(expected_data, output_data, sizeof(expected_data)));
+ EXPECT_TRUE(0 == memcmp(kExpectedData, output_data, sizeof(kExpectedData)));
}
TEST(CFX_LZWDecompressor, HandleColourCodeOutOfPalette) {
@@ -201,11 +200,11 @@
auto decompressor = CFX_LZWDecompressor::Create(palette_exp, code_exp);
ASSERT_NE(nullptr, decompressor);
- uint8_t image_data[] = {0x30, 0xC9, 0x49, 0x81, 0xBD, 0x78, 0xE8, 0xCD,
- 0x89, 0xFF, 0x60, 0x20, 0x8E, 0xE4, 0x61, 0x9E,
- 0xA8, 0xA1, 0xAE, 0x2C, 0xE2, 0xBE, 0xB0, 0x20,
- 0xCF, 0x74, 0x61, 0xDF, 0x78, 0x04};
- uint32_t image_size = FX_ArraySize(image_data);
+ static constexpr uint8_t kImageData[] = {
+ 0x30, 0xC9, 0x49, 0x81, 0xBD, 0x78, 0xE8, 0xCD, 0x89, 0xFF,
+ 0x60, 0x20, 0x8E, 0xE4, 0x61, 0x9E, 0xA8, 0xA1, 0xAE, 0x2C,
+ 0xE2, 0xBE, 0xB0, 0x20, 0xCF, 0x74, 0x61, 0xDF, 0x78, 0x04};
+ uint32_t image_size = FX_ArraySize(kImageData);
uint8_t output_data[100]; // The uncompressed data is for a 10x10 image
memset(output_data, 0, sizeof(output_data));
@@ -213,5 +212,5 @@
EXPECT_EQ(
CFX_GifDecodeStatus::Error,
- decompressor->Decode(image_data, image_size, output_data, &output_size));
+ decompressor->Decode(kImageData, image_size, output_data, &output_size));
}
diff --git a/core/fxcodec/jbig2/JBig2_PatternDict.cpp b/core/fxcodec/jbig2/JBig2_PatternDict.cpp
index 60131ab..4e7959f 100644
--- a/core/fxcodec/jbig2/JBig2_PatternDict.cpp
+++ b/core/fxcodec/jbig2/JBig2_PatternDict.cpp
@@ -6,7 +6,6 @@
#include "core/fxcodec/jbig2/JBig2_PatternDict.h"
-
CJBig2_PatternDict::CJBig2_PatternDict(uint32_t dict_size)
: NUMPATS(dict_size), HDPATS(dict_size) {}
diff --git a/core/fxcodec/jbig2/JBig2_Segment.cpp b/core/fxcodec/jbig2/JBig2_Segment.cpp
index 618b9d7..91fa2d9 100644
--- a/core/fxcodec/jbig2/JBig2_Segment.cpp
+++ b/core/fxcodec/jbig2/JBig2_Segment.cpp
@@ -6,7 +6,6 @@
#include "core/fxcodec/jbig2/JBig2_Segment.h"
-
CJBig2_Segment::CJBig2_Segment()
: m_dwNumber(0),
m_nReferred_to_segment_count(0),
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index e11fd50..8b07981 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -126,7 +126,7 @@
StringData::Create(reinterpret_cast<const char*>(pStr), nLen));
}
-ByteString::ByteString() {}
+ByteString::ByteString() = default;
ByteString::ByteString(const ByteString& other) : m_pData(other.m_pData) {}
@@ -143,9 +143,10 @@
: ByteString(ptr, ptr ? strlen(ptr) : 0) {}
ByteString::ByteString(ByteStringView bstrc) {
- if (!bstrc.IsEmpty())
- m_pData.Reset(StringData::Create(bstrc.unterminated_c_str(),
- bstrc.GetLength()));
+ if (!bstrc.IsEmpty()) {
+ m_pData.Reset(
+ StringData::Create(bstrc.unterminated_c_str(), bstrc.GetLength()));
+ }
}
ByteString::ByteString(ByteStringView str1, ByteStringView str2) {
diff --git a/core/fxcrt/css/cfx_cssdeclaration.cpp b/core/fxcrt/css/cfx_cssdeclaration.cpp
index 1695287..de97b64 100644
--- a/core/fxcrt/css/cfx_cssdeclaration.cpp
+++ b/core/fxcrt/css/cfx_cssdeclaration.cpp
@@ -182,8 +182,10 @@
switch (dwType & 0x0F) {
case CFX_CSSVALUETYPE_Primitive: {
static constexpr CFX_CSSVALUETYPE kValueGuessOrder[] = {
- CFX_CSSVALUETYPE_MaybeNumber, CFX_CSSVALUETYPE_MaybeEnum,
- CFX_CSSVALUETYPE_MaybeColor, CFX_CSSVALUETYPE_MaybeString,
+ CFX_CSSVALUETYPE_MaybeNumber,
+ CFX_CSSVALUETYPE_MaybeEnum,
+ CFX_CSSVALUETYPE_MaybeColor,
+ CFX_CSSVALUETYPE_MaybeString,
};
for (uint32_t guess : kValueGuessOrder) {
const uint32_t dwMatch = dwType & guess;
diff --git a/core/fxcrt/fx_system.cpp b/core/fxcrt/fx_system.cpp
index 0eb5b00..7358b75 100644
--- a/core/fxcrt/fx_system.cpp
+++ b/core/fxcrt/fx_system.cpp
@@ -144,7 +144,7 @@
return wcsftime(strDest, maxsize, format, timeptr);
}
-#else // defined(OS_WIN)
+#else // defined(OS_WIN)
int FXSYS_GetACP() {
return 0;
diff --git a/core/fxge/android/cfpf_skiapathfont.cpp b/core/fxge/android/cfpf_skiapathfont.cpp
index 8aaa9c7..a9f96ac 100644
--- a/core/fxge/android/cfpf_skiapathfont.cpp
+++ b/core/fxge/android/cfpf_skiapathfont.cpp
@@ -6,7 +6,6 @@
#include "core/fxge/android/cfpf_skiapathfont.h"
-
CFPF_SkiaPathFont::CFPF_SkiaPathFont(const ByteString& path,
const char* pFamily,
uint32_t dwStyle,
diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp
index 2dd8ee1..6342b22 100644
--- a/core/fxge/dib/cfx_imagetransformer.cpp
+++ b/core/fxge/dib/cfx_imagetransformer.cpp
@@ -319,7 +319,9 @@
pDestMask->Clear(0xff000000);
} else if (pDestMask) {
CalcData cdata = {
- pDestMask.Get(), result2stretch, pSrcMaskBuf,
+ pDestMask.Get(),
+ result2stretch,
+ pSrcMaskBuf,
m_Storer.GetBitmap()->m_pAlphaMask->GetPitch(),
};
CalcMask(cdata);
diff --git a/core/fxge/dib/cfx_scanlinecompositor.cpp b/core/fxge/dib/cfx_scanlinecompositor.cpp
index 4245e58..3473bc2 100644
--- a/core/fxge/dib/cfx_scanlinecompositor.cpp
+++ b/core/fxge/dib/cfx_scanlinecompositor.cpp
@@ -78,13 +78,11 @@
return Blend(BlendMode::kScreen, back_color, 2 * src_color - 255);
case BlendMode::kSoftLight: {
if (src_color < 128) {
- return back_color -
- (255 - 2 * src_color) * back_color * (255 - back_color) / 255 /
- 255;
+ return back_color - (255 - 2 * src_color) * back_color *
+ (255 - back_color) / 255 / 255;
}
- return back_color +
- (2 * src_color - 255) * (color_sqrt[back_color] - back_color) /
- 255;
+ return back_color + (2 * src_color - 255) *
+ (color_sqrt[back_color] - back_color) / 255;
}
case BlendMode::kDifference:
return back_color < src_color ? src_color - back_color
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index 441e036..9c38d58 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -431,7 +431,7 @@
lf.lfCharSet = FX_CHARSET_Default;
lf.lfFaceName[0] = 0;
lf.lfPitchAndFamily = 0;
- EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t) this,
+ EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t)this,
0);
return true;
}