pdf: Use BUILDFLAG for OS checking
Use BUILDFLAG(IS_XXX) instead of defined(OS_XXX).
Generated by `os_buildflag_migration.py` (https://crrev.com/c/3311983).
R=thakis@chromium.org
Bug: 1234043
Test: No functionality change
Change-Id: I1ed5c9de7664fac7a093b8b2ee65b08f16cff389
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3373981
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#956794}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
a0f0753016
commit
874c8c3408
@ -75,7 +75,7 @@
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
#include "pdf/ppapi_migration/pdfium_font_linux.h"
|
||||
#endif
|
||||
|
||||
@ -735,7 +735,7 @@ void OutOfProcessInstance::RotateCounterclockwise() {
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::SetLastPluginInstance() {
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
SetLastPepperInstance(this);
|
||||
#endif
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "pdf/pdf_engine.h"
|
||||
#include "pdf/pdf_init.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
@ -35,15 +36,15 @@ class ScopedSdkInitializer {
|
||||
|
||||
} // namespace
|
||||
|
||||
#if defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
std::vector<uint8_t> CreateFlattenedPdf(
|
||||
base::span<const uint8_t> input_buffer) {
|
||||
ScopedSdkInitializer scoped_sdk_initializer(/*enable_v8=*/false);
|
||||
return PDFEngineExports::Get()->CreateFlattenedPdf(input_buffer);
|
||||
}
|
||||
#endif // defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
bool RenderPDFPageToDC(base::span<const uint8_t> pdf_buffer,
|
||||
int page_number,
|
||||
HDC dc,
|
||||
@ -78,7 +79,7 @@ void SetPDFEnsureTypefaceCharactersAccessible(
|
||||
void SetPDFUsePrintMode(int mode) {
|
||||
PDFEngineExports::Get()->SetPDFUsePrintMode(mode);
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
bool GetPDFDocInfo(base::span<const uint8_t> pdf_buffer,
|
||||
int* page_count,
|
||||
|
12
pdf/pdf.h
12
pdf/pdf.h
@ -12,11 +12,11 @@
|
||||
#include "build/build_config.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
typedef void (*PDFEnsureTypefaceCharactersAccessible)(const LOGFONT* font,
|
||||
const wchar_t* text,
|
||||
size_t text_length);
|
||||
@ -30,14 +30,14 @@ class SizeF;
|
||||
|
||||
namespace chrome_pdf {
|
||||
|
||||
#if defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
// Create a flattened PDF document from an existing PDF document.
|
||||
// `input_buffer` is the buffer that contains the entire PDF document to be
|
||||
// flattened.
|
||||
std::vector<uint8_t> CreateFlattenedPdf(base::span<const uint8_t> input_buffer);
|
||||
#endif // defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// Printing modes - type to convert PDF to for printing. See PDFium's
|
||||
// FPDF_SetPrintMode() for details.
|
||||
enum PrintingMode {
|
||||
@ -99,7 +99,7 @@ void SetPDFEnsureTypefaceCharactersAccessible(
|
||||
PDFEnsureTypefaceCharactersAccessible func);
|
||||
|
||||
void SetPDFUsePrintMode(int mode);
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
// `page_count` and `max_page_width` are optional and can be NULL.
|
||||
// Returns false if the document is not valid.
|
||||
|
@ -27,11 +27,11 @@
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
#include "ui/gfx/geometry/rect_f.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
typedef void (*PDFEnsureTypefaceCharactersAccessible)(const LOGFONT* font,
|
||||
const wchar_t* text,
|
||||
size_t text_length);
|
||||
@ -522,13 +522,13 @@ class PDFEngineExports {
|
||||
|
||||
static PDFEngineExports* Get();
|
||||
|
||||
#if defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
// See the definition of CreateFlattenedPdf in pdf.cc for details.
|
||||
virtual std::vector<uint8_t> CreateFlattenedPdf(
|
||||
base::span<const uint8_t> input_buffer) = 0;
|
||||
#endif // defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// See the definition of RenderPDFPageToDC in pdf.cc for details.
|
||||
virtual bool RenderPDFPageToDC(base::span<const uint8_t> pdf_buffer,
|
||||
int page_number,
|
||||
@ -539,7 +539,7 @@ class PDFEngineExports {
|
||||
PDFEnsureTypefaceCharactersAccessible func) = 0;
|
||||
|
||||
virtual void SetPDFUsePrintMode(int mode) = 0;
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
// See the definition of RenderPDFPageToBitmap in pdf.cc for details.
|
||||
virtual bool RenderPDFPageToBitmap(base::span<const uint8_t> pdf_buffer,
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "third_party/pdfium/public/fpdfview.h"
|
||||
#include "ui/events/keycodes/keyboard_codes.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "pdf/pdf.h"
|
||||
#endif
|
||||
|
||||
@ -257,7 +257,7 @@ STATIC_ASSERT_ENUM(PP_PRIVATEBUTTON_PUSHBUTTON, FPDF_FORMFIELD_PUSHBUTTON);
|
||||
STATIC_ASSERT_ENUM(PP_PRIVATEBUTTON_CHECKBOX, FPDF_FORMFIELD_CHECKBOX);
|
||||
STATIC_ASSERT_ENUM(PP_PRIVATEBUTTON_RADIOBUTTON, FPDF_FORMFIELD_RADIOBUTTON);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
STATIC_ASSERT_ENUM(kEmf, FPDF_PRINTMODE_EMF);
|
||||
STATIC_ASSERT_ENUM(kTextOnly, FPDF_PRINTMODE_TEXTONLY);
|
||||
STATIC_ASSERT_ENUM(kPostScript2, FPDF_PRINTMODE_POSTSCRIPT2);
|
||||
|
@ -84,7 +84,7 @@
|
||||
#include "gin/public/cppgc.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
#include "pdf/pdfium/pdfium_font_linux.h"
|
||||
#endif
|
||||
|
||||
@ -111,7 +111,7 @@ constexpr int kMaxPasswordTries = 3;
|
||||
constexpr base::TimeDelta kTouchLongPressTimeout = base::Milliseconds(300);
|
||||
|
||||
// Windows has native panning capabilities. No need to use our own.
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
constexpr bool kViewerImplementedPanning = false;
|
||||
#else
|
||||
constexpr bool kViewerImplementedPanning = true;
|
||||
@ -206,11 +206,11 @@ void FormatStringWithHyphens(std::u16string* text) {
|
||||
|
||||
// Replace CR/LF with just LF on POSIX.
|
||||
void FormatStringForOS(std::u16string* text) {
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
static constexpr char16_t kCr[] = {L'\r', L'\0'};
|
||||
static constexpr char16_t kBlank[] = {L'\0'};
|
||||
base::ReplaceChars(*text, kCr, kBlank, text);
|
||||
#elif defined(OS_WIN)
|
||||
#elif BUILDFLAG(IS_WIN)
|
||||
// Do nothing
|
||||
#else
|
||||
NOTIMPLEMENTED();
|
||||
@ -312,7 +312,7 @@ bool IsLinkArea(PDFiumPage::Area area) {
|
||||
// the ctrl + left button down events into a right button down event.
|
||||
blink::WebMouseEvent NormalizeMouseEvent(const blink::WebMouseEvent& event) {
|
||||
blink::WebMouseEvent normalized_event = event;
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
if ((event.GetModifiers() & blink::WebInputEvent::Modifiers::kControlKey) &&
|
||||
event.button == blink::WebPointerProperties::Button::kLeft &&
|
||||
event.GetType() == blink::WebInputEvent::Type::kMouseDown) {
|
||||
@ -519,7 +519,7 @@ void InitializeSDK(bool enable_v8, FontMappingMode font_mapping_mode) {
|
||||
|
||||
FPDF_InitLibraryWithConfig(&config);
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
g_font_mapping_mode = font_mapping_mode;
|
||||
InitializeLinuxFontMapper();
|
||||
#endif
|
||||
@ -1690,7 +1690,7 @@ bool PDFiumEngine::OnKeyDown(const blink::WebKeyboardEvent& event) {
|
||||
OnChar(synthesized);
|
||||
}
|
||||
|
||||
#if !defined(OS_MAC)
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
// macOS doesn't have keyboard-triggered context menus.
|
||||
// Scroll focused annotation into view when context menu is invoked through
|
||||
// keyboard <Shift-F10>.
|
||||
@ -2188,7 +2188,7 @@ std::string PDFiumEngine::GetSelectedText() {
|
||||
if (i != 0) {
|
||||
if (selection_[i - 1].page_index() > selection_[i].page_index())
|
||||
std::swap(current_selection_text, result);
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
result.push_back(L'\r');
|
||||
#endif
|
||||
result.push_back(L'\n');
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "build/build_config.h"
|
||||
#include "pdf/pdfium/pdfium_api_string_buffer_adapter.h"
|
||||
#include "pdf/pdfium/pdfium_mem_buffer_file_write.h"
|
||||
#include "pdf/pdfium/pdfium_print.h"
|
||||
@ -227,7 +228,7 @@ PDFiumEngineExports::PDFiumEngineExports() {}
|
||||
|
||||
PDFiumEngineExports::~PDFiumEngineExports() {}
|
||||
|
||||
#if defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
std::vector<uint8_t> PDFiumEngineExports::CreateFlattenedPdf(
|
||||
base::span<const uint8_t> input_buffer) {
|
||||
ScopedUnsupportedFeature scoped_unsupported_feature(
|
||||
@ -237,9 +238,9 @@ std::vector<uint8_t> PDFiumEngineExports::CreateFlattenedPdf(
|
||||
return std::vector<uint8_t>();
|
||||
return PDFiumPrint::CreateFlattenedPdf(std::move(doc));
|
||||
}
|
||||
#endif // defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
bool PDFiumEngineExports::RenderPDFPageToDC(
|
||||
base::span<const uint8_t> pdf_buffer,
|
||||
int page_number,
|
||||
@ -320,7 +321,7 @@ void PDFiumEngineExports::SetPDFEnsureTypefaceCharactersAccessible(
|
||||
void PDFiumEngineExports::SetPDFUsePrintMode(int mode) {
|
||||
FPDF_SetPrintMode(mode);
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
bool PDFiumEngineExports::RenderPDFPageToBitmap(
|
||||
base::span<const uint8_t> pdf_buffer,
|
||||
|
@ -21,11 +21,11 @@ class PDFiumEngineExports : public PDFEngineExports {
|
||||
~PDFiumEngineExports() override;
|
||||
|
||||
// PDFEngineExports:
|
||||
#if defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
std::vector<uint8_t> CreateFlattenedPdf(
|
||||
base::span<const uint8_t> input_buffer) override;
|
||||
#endif // defined(OS_CHROMEOS)
|
||||
#if defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
bool RenderPDFPageToDC(base::span<const uint8_t> pdf_buffer,
|
||||
int page_number,
|
||||
const RenderingSettings& settings,
|
||||
@ -34,7 +34,7 @@ class PDFiumEngineExports : public PDFEngineExports {
|
||||
PDFEnsureTypefaceCharactersAccessible func) override;
|
||||
|
||||
void SetPDFUsePrintMode(int mode) override;
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
bool RenderPDFPageToBitmap(base::span<const uint8_t> pdf_buffer,
|
||||
int page_number,
|
||||
const RenderingSettings& settings,
|
||||
|
@ -662,7 +662,7 @@ TEST_F(PDFiumEngineTest, SelectText) {
|
||||
EXPECT_THAT(engine->GetSelectedText(), IsEmpty());
|
||||
|
||||
engine->SelectAll();
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
constexpr char kExpectedText[] =
|
||||
"Hello, world!\r\nGoodbye, world!\r\nHello, world!\r\nGoodbye, world!";
|
||||
#else
|
||||
@ -681,7 +681,7 @@ TEST_F(PDFiumEngineTest, SelectCroppedText) {
|
||||
EXPECT_THAT(engine->GetSelectedText(), IsEmpty());
|
||||
|
||||
engine->SelectAll();
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
constexpr char kExpectedText[] = "world!\r\n";
|
||||
#else
|
||||
constexpr char kExpectedText[] = "world!\n";
|
||||
|
@ -117,7 +117,7 @@ TEST_F(FormFillerTest, DoURIActionWithKeyboardModifier) {
|
||||
}
|
||||
|
||||
constexpr blink::WebInputEvent::Modifiers kModifierKey =
|
||||
#if defined(OS_MAC)
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
blink::WebInputEvent::Modifiers::kMetaKey;
|
||||
#else
|
||||
blink::WebInputEvent::Modifiers::kControlKey;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "pdf/pdf_transform.h"
|
||||
#include "pdf/pdfium/pdfium_engine.h"
|
||||
#include "pdf/pdfium/pdfium_mem_buffer_file_write.h"
|
||||
@ -249,14 +250,14 @@ PDFiumPrint::PDFiumPrint(PDFiumEngine* engine) : engine_(engine) {}
|
||||
|
||||
PDFiumPrint::~PDFiumPrint() = default;
|
||||
|
||||
#if defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
// static
|
||||
std::vector<uint8_t> PDFiumPrint::CreateFlattenedPdf(ScopedFPDFDocument doc) {
|
||||
if (!FlattenPrintData(doc.get()))
|
||||
return std::vector<uint8_t>();
|
||||
return ConvertDocToBuffer(std::move(doc));
|
||||
}
|
||||
#endif // defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
// static
|
||||
std::vector<uint8_t> PDFiumPrint::CreateNupPdf(
|
||||
|
@ -32,12 +32,12 @@ class PDFiumPrint {
|
||||
PDFiumPrint& operator=(const PDFiumPrint&) = delete;
|
||||
~PDFiumPrint();
|
||||
|
||||
#if defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
// Flattens the `doc`.
|
||||
// On success, returns the flattened version of `doc` as a vector.
|
||||
// On failure, returns an empty vector.
|
||||
static std::vector<uint8_t> CreateFlattenedPdf(ScopedFPDFDocument doc);
|
||||
#endif // defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
// Performs N-up PDF generation for `doc` based on `pages_per_sheet`,
|
||||
// `page_size`, and `printable_area`.
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
#include "base/environment.h"
|
||||
#endif
|
||||
|
||||
@ -29,7 +29,7 @@ namespace chrome_pdf {
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
base::FilePath GetTestFontsDir() {
|
||||
// base::TestSuite::Initialize() should have already set this.
|
||||
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
||||
@ -37,7 +37,7 @@ base::FilePath GetTestFontsDir() {
|
||||
CHECK(env->GetVar("FONTCONFIG_SYSROOT", &fontconfig_sysroot));
|
||||
return base::FilePath(fontconfig_sysroot).AppendASCII("test_fonts");
|
||||
}
|
||||
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -47,7 +47,7 @@ PDFiumTestBase::~PDFiumTestBase() = default;
|
||||
|
||||
// static
|
||||
bool PDFiumTestBase::UsingTestFonts() {
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
@ -105,7 +105,7 @@ PDFiumTestBase::InitializeEngineWithoutLoading(
|
||||
|
||||
void PDFiumTestBase::InitializePDFium() {
|
||||
font_paths_.clear();
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
test_fonts_path_ = GetTestFontsDir();
|
||||
font_paths_.push_back(test_fonts_path_.value().c_str());
|
||||
// When non-empty, `font_paths_` has to be terminated with a nullptr.
|
||||
|
@ -76,7 +76,7 @@ class PDFiumTestBase : public testing::Test {
|
||||
private:
|
||||
void InitializePDFium();
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
base::FilePath test_fonts_path_;
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user