Replace defined(OS_APPLE) with BUILDFLAG(IS_APPLE).

Bug: chromium:1234043
Change-Id: I35f293235e7fad0547ca2aa8d377f9f2be9c43c6
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/89230
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index 19261b5..8981824 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -679,7 +679,7 @@
     uint16_t cid = CIDFromCharCode(charcode);
     wchar_t unicode = 0;
     if (m_bCIDIsGID) {
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
       if (FontStyleIsSymbolic(m_Flags))
         return cid;
 
@@ -744,7 +744,7 @@
     if (m_Charset == CIDSET_JAPAN1) {
       if (unicode == '\\') {
         unicode = '/';
-#if !defined(OS_APPLE)
+#if !BUILDFLAG(IS_APPLE)
       } else if (unicode == 0xa5) {
         unicode = 0x5c;
 #endif
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index f8c8a28..77cbdcd 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -114,7 +114,7 @@
   return pString.GetLength();
 }
 
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
 int CPDF_Font::GlyphFromCharCodeExt(uint32_t charcode) {
   return GlyphFromCharCode(charcode, nullptr);
 }
diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h
index 160d497..d92da3c 100644
--- a/core/fpdfapi/font/cpdf_font.h
+++ b/core/fpdfapi/font/cpdf_font.h
@@ -88,7 +88,7 @@
   virtual size_t CountChar(ByteStringView pString) const;
   virtual int AppendChar(char* buf, uint32_t charcode) const;
   virtual int GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) = 0;
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   virtual int GlyphFromCharCodeExt(uint32_t charcode);
 #endif
   virtual WideString UnicodeFromCharCode(uint32_t charcode) const;
diff --git a/core/fpdfapi/font/cpdf_type1font.cpp b/core/fpdfapi/font/cpdf_type1font.cpp
index 51f0e88..0205b02 100644
--- a/core/fpdfapi/font/cpdf_type1font.cpp
+++ b/core/fpdfapi/font/cpdf_type1font.cpp
@@ -18,13 +18,13 @@
 #include "core/fxge/fx_font.h"
 #include "core/fxge/fx_freetype.h"
 
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
 #include <Carbon/Carbon.h>
-#endif  // defined(OS_APPLE)
+#endif  // BUILDFLAG(IS_APPLE)
 
 namespace {
 
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
 struct GlyphNameMap {
   const char* m_pStrAdobe;    // Raw, POD struct.
   const char* m_pStrUnicode;  // Raw, POD struct.
@@ -44,7 +44,7 @@
   return nullptr;
 }
 
-#endif  // defined(OS_APPLE)
+#endif  // BUILDFLAG(IS_APPLE)
 
 bool FT_UseType1Charmap(FXFT_FaceRec* face) {
   if (FXFT_Get_Face_CharmapCount(face) == 0) {
@@ -69,7 +69,7 @@
 CPDF_Type1Font::CPDF_Type1Font(CPDF_Document* pDocument,
                                CPDF_Dictionary* pFontDict)
     : CPDF_SimpleFont(pDocument, pFontDict) {
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   memset(m_ExtGID, 0xff, sizeof(m_ExtGID));
 #endif
 }
@@ -113,7 +113,7 @@
   return LoadCommon();
 }
 
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
 int CPDF_Type1Font::GlyphFromCharCodeExt(uint32_t charcode) {
   if (charcode > 0xff)
     return -1;
@@ -127,7 +127,7 @@
   if (!m_Font.GetFaceRec())
     return;
 
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   bool bCoreText = true;
   if (!m_Font.GetPlatformFont()) {
     if (m_Font.GetPsName() == "DFHeiStd-W5")
@@ -149,7 +149,7 @@
           uint16_t unicode = prefix[j] * 256 + charcode;
           m_GlyphIndex[charcode] =
               FT_Get_Char_Index(m_Font.GetFaceRec(), unicode);
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
           CalcExtGID(charcode);
 #endif
           if (m_GlyphIndex[charcode]) {
@@ -159,7 +159,7 @@
         }
       }
       if (bGotOne) {
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
         if (!bCoreText)
           memcpy(m_ExtGID, m_GlyphIndex, sizeof(m_ExtGID));
 #endif
@@ -179,18 +179,18 @@
       m_Encoding.SetUnicode(charcode, PDF_UnicodeFromAdobeName(name));
       m_GlyphIndex[charcode] = FT_Get_Char_Index(
           m_Font.GetFaceRec(), m_Encoding.UnicodeFromCharCode(charcode));
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
       CalcExtGID(charcode);
 #endif
       if (m_GlyphIndex[charcode] == 0 && strcmp(name, ".notdef") == 0) {
         m_Encoding.SetUnicode(charcode, 0x20);
         m_GlyphIndex[charcode] = FT_Get_Char_Index(m_Font.GetFaceRec(), 0x20);
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
         CalcExtGID(charcode);
 #endif
       }
     }
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
     if (!bCoreText) {
       fxcrt::spancpy(pdfium::make_span(m_ExtGID),
                      pdfium::make_span(m_GlyphIndex));
@@ -199,7 +199,7 @@
     return;
   }
   FT_UseType1Charmap(m_Font.GetFaceRec());
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   if (bCoreText) {
     if (FontStyleIsSymbolic(m_Flags)) {
       for (uint32_t charcode = 0; charcode < kInternalTableSize; charcode++) {
@@ -264,7 +264,7 @@
     }
     return;
   }
-#endif  // defined(OS_APPLE)
+#endif  // BUILDFLAG(IS_APPLE)
   if (FontStyleIsSymbolic(m_Flags)) {
     for (size_t charcode = 0; charcode < kInternalTableSize; charcode++) {
       const char* name =
@@ -290,7 +290,7 @@
         }
       }
     }
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
     if (!bCoreText)
       memcpy(m_ExtGID, m_GlyphIndex, sizeof(m_ExtGID));
 #endif
@@ -318,7 +318,7 @@
       m_GlyphIndex[charcode] = 0xffff;
     }
   }
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   if (!bCoreText)
     memcpy(m_ExtGID, m_GlyphIndex, sizeof(m_ExtGID));
 #endif
@@ -334,7 +334,7 @@
          CFX_FontMapper::IsFixedFont(m_Base14Font.value());
 }
 
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
 void CPDF_Type1Font::SetExtGID(const char* name, uint32_t charcode) {
   CFStringRef name_ct = CFStringCreateWithCStringNoCopy(
       kCFAllocatorDefault, name, kCFStringEncodingASCII, kCFAllocatorNull);
@@ -351,4 +351,4 @@
   name_glyph[kInternalTableSize - 1] = 0;
   SetExtGID(name_glyph, charcode);
 }
-#endif  // defined(OS_APPLE)
+#endif  // BUILDFLAG(IS_APPLE)
diff --git a/core/fpdfapi/font/cpdf_type1font.h b/core/fpdfapi/font/cpdf_type1font.h
index a0094a7..0f68f43 100644
--- a/core/fpdfapi/font/cpdf_type1font.h
+++ b/core/fpdfapi/font/cpdf_type1font.h
@@ -23,7 +23,7 @@
   bool IsType1Font() const override;
   const CPDF_Type1Font* AsType1Font() const override;
   CPDF_Type1Font* AsType1Font() override;
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   int GlyphFromCharCodeExt(uint32_t charcode) override;
 #endif
 
@@ -41,7 +41,7 @@
   bool IsSymbolicFont() const;
   bool IsFixedFont() const;
 
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   void SetExtGID(const char* name, uint32_t charcode);
   void CalcExtGID(uint32_t charcode);
 
diff --git a/core/fpdfapi/page/cpdf_transferfuncdib.cpp b/core/fpdfapi/page/cpdf_transferfuncdib.cpp
index 01dbb06..96ddbf0 100644
--- a/core/fpdfapi/page/cpdf_transferfuncdib.cpp
+++ b/core/fpdfapi/page/cpdf_transferfuncdib.cpp
@@ -63,7 +63,7 @@
           m_Scanline[index++] = g0;
           m_Scanline[index++] = r0;
         }
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
         index++;
 #endif
       }
@@ -97,7 +97,7 @@
           m_Scanline[index++] = m_RampR[src_byte];
         }
         src_buf++;
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
         index++;
 #endif
       }
@@ -115,7 +115,7 @@
         m_Scanline[index++] = m_RampB[*(src_buf++)];
         m_Scanline[index++] = m_RampG[*(src_buf++)];
         m_Scanline[index++] = m_RampR[*(src_buf++)];
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
         index++;
 #endif
       }
@@ -132,7 +132,7 @@
         m_Scanline[index++] = m_RampR[*(src_buf++)];
         if (!bSkip) {
           m_Scanline[index++] = *src_buf;
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
         } else {
           index++;
 #endif
diff --git a/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp b/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp
index fda5ed9..940121e 100644
--- a/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp
+++ b/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp
@@ -136,7 +136,7 @@
 TEST_F(CPDFSecurityHandlerEmbedderTest, PasswordAfterGenerateSave) {
 #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
   const char kChecksum[] = "c3c4fc0032f5d252327bf52d29a074fa";
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
   const char kChecksum[] = "2a308e8cc20a6221112c387d122075a8";
 #else
   const char kChecksum[] = "9fe7eef8e51d15a604001854be6ed1ee";
diff --git a/core/fpdfapi/render/charposlist.cpp b/core/fpdfapi/render/charposlist.cpp
index 26df52c..6c171d2 100644
--- a/core/fpdfapi/render/charposlist.cpp
+++ b/core/fpdfapi/render/charposlist.cpp
@@ -37,7 +37,7 @@
     text_char_pos.m_GlyphIndex =
         font->GlyphFromCharCode(char_code, &is_vertical_glyph);
     uint32_t glyph_id = text_char_pos.m_GlyphIndex;
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
     text_char_pos.m_ExtGID = font->GlyphFromCharCodeExt(char_code);
     glyph_id = text_char_pos.m_ExtGID != static_cast<uint32_t>(-1)
                    ? text_char_pos.m_ExtGID
@@ -73,7 +73,7 @@
     if (use_fallback_font) {
       current_font =
           font->GetFontFallback(text_char_pos.m_FallbackFontPosition);
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
       text_char_pos.m_ExtGID = text_char_pos.m_GlyphIndex;
 #endif
     } else {
diff --git a/core/fpdfapi/render/cpdf_devicebuffer.cpp b/core/fpdfapi/render/cpdf_devicebuffer.cpp
index 08ca657..2c27370 100644
--- a/core/fpdfapi/render/cpdf_devicebuffer.cpp
+++ b/core/fpdfapi/render/cpdf_devicebuffer.cpp
@@ -17,7 +17,7 @@
 
 namespace {
 
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
 constexpr bool kScaleDeviceBuffer = false;
 #else
 constexpr bool kScaleDeviceBuffer = true;
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 5ec9419..bca567d 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1402,7 +1402,7 @@
   int width = pClipRect->right - pClipRect->left;
   int height = pClipRect->bottom - pClipRect->top;
   FXDIB_Format format;
-#if defined(OS_APPLE) || defined(_SKIA_SUPPORT_) || \
+#if BUILDFLAG(IS_APPLE) || defined(_SKIA_SUPPORT_) || \
     defined(_SKIA_SUPPORT_PATHS_)
   format = bLuminosity ? FXDIB_Format::kRgb32 : FXDIB_Format::k8bppMask;
 #else
diff --git a/core/fpdfapi/render/fpdf_progressive_render_embeddertest.cpp b/core/fpdfapi/render/fpdf_progressive_render_embeddertest.cpp
index 13c3567..e337aeb 100644
--- a/core/fpdfapi/render/fpdf_progressive_render_embeddertest.cpp
+++ b/core/fpdfapi/render/fpdf_progressive_render_embeddertest.cpp
@@ -25,7 +25,7 @@
 #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
 static constexpr char kAnnotationStampWithApBaseContentChecksum[] =
     "1a6cb54b1cfc5bb9f6ec3923a52ea7cc";
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
 static constexpr char kAnnotationStampWithApBaseContentChecksum[] =
     "243f3d6267d9db09198fed9f8c4957fd";
 #else
@@ -315,7 +315,7 @@
 #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
   static constexpr char kContentWithTextChecksum[] =
       "6bbe5a547115b4aa30b49fe7c34030e3";
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
   static constexpr char kContentWithTextChecksum[] =
       "ee4ec12f54ce8d117a73bd9b85a8954d";
 #else
@@ -386,13 +386,13 @@
   static constexpr char kContentWithHighlightFillChecksum[] =
       "fa25846c61d0253e86e8512d3be06ebb";
 #else
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   static constexpr char kContentWithHighlightFillChecksum[] =
       "a820afec9b99d3d3f2e9e9382bbad7c1";
 #else
   static constexpr char kContentWithHighlightFillChecksum[] =
       "a08a0639f89446f66f3689ee8e08b9fe";
-#endif  // defined(OS_APPLE)
+#endif  // BUILDFLAG(IS_APPLE)
 #endif  // defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
 
   ASSERT_TRUE(OpenDocument("annotation_highlight_square_with_ap.pdf"));
@@ -419,7 +419,7 @@
 // Note: The stroke color rendered for highlight is different from the normal
 // path since highlights have Multiply blend mode, while the other path has
 // Normal blend mode.
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   static constexpr char kMD5ContentWithHighlight[] =
       "8837bea0b3520164b1784e513c882a2d";
 #else
@@ -446,13 +446,13 @@
 TEST_F(FPDFProgressiveRenderEmbedderTest, MAYBE_RenderInkWithColorScheme) {
 // Test rendering of multiple ink with forced color scheme on.
 #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   static constexpr char kContentWithInkChecksum[] =
       "ebc57721e4c8da34156e09b9b2e62fb0";
 #else
   static constexpr char kContentWithInkChecksum[] =
       "b39d9f68ff71963d82c43eb20caa8f4d";
-#endif  // defined(OS_APPLE)
+#endif  // BUILDFLAG(IS_APPLE)
 #else
 #if BUILDFLAG(IS_WIN)
   static constexpr char kContentWithInkChecksum[] =
@@ -475,7 +475,7 @@
 #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
   static constexpr char kContentWithStampChecksum[] =
       "bdcd2b91223b1a73582b341d0153a73f";
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
   static constexpr char kContentWithStampChecksum[] =
       "7a209e29caeeab7d2b25b34570a4ace6";
 #else
diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp
index e0688bf..faa681e 100644
--- a/core/fpdfdoc/cpdf_filespec.cpp
+++ b/core/fpdfdoc/cpdf_filespec.cpp
@@ -21,12 +21,12 @@
 
 namespace {
 
-#if defined(OS_APPLE) || BUILDFLAG(IS_WIN)
+#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_WIN)
 WideString ChangeSlashToPlatform(const wchar_t* str) {
   WideString result;
   while (*str) {
     if (*str == '/') {
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
       result += L':';
 #else
       result += L'\\';
@@ -51,7 +51,7 @@
   }
   return result;
 }
-#endif  // defined(OS_APPLE) || BUILDFLAG(IS_WIN)
+#endif  // BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_WIN)
 
 }  // namespace
 
@@ -70,7 +70,7 @@
   if (filepath.GetLength() <= 1)
     return WideString();
 
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   if (filepath.First(sizeof("/Mac") - 1) == WideStringView(L"/Mac"))
     return ChangeSlashToPlatform(filepath.c_str() + 1);
   return ChangeSlashToPlatform(filepath.c_str());
@@ -191,7 +191,7 @@
   if (filepath[0] == L'\\')
     return L'/' + ChangeSlashToPDF(filepath.c_str());
   return ChangeSlashToPDF(filepath.c_str());
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
   if (filepath.First(sizeof("Mac") - 1).EqualsASCII("Mac"))
     return L'/' + ChangeSlashToPDF(filepath.c_str());
   return ChangeSlashToPDF(filepath.c_str());
diff --git a/core/fpdfdoc/cpdf_filespec_unittest.cpp b/core/fpdfdoc/cpdf_filespec_unittest.cpp
index 0f23a41..aef0810 100644
--- a/core/fpdfdoc/cpdf_filespec_unittest.cpp
+++ b/core/fpdfdoc/cpdf_filespec_unittest.cpp
@@ -35,7 +35,7 @@
     {L"\\\\pdfdocs\\spec.pdf", L"/pdfdocs/spec.pdf"},
 // Network resource name. It is not supported yet.
 // {L"pclib/eng:\\pdfdocs\\spec.pdf", L"/pclib/eng/pdfdocs/spec.pdf"},
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
     // Absolute path with colon separator.
     {L"Mac HD:PDFDocs:spec.pdf", L"/Mac HD/PDFDocs/spec.pdf"},
     // Relative path with colon separator.
@@ -65,7 +65,7 @@
 #if BUILDFLAG(IS_WIN)
       L"/C/docs/test.pdf",
       L"C:\\docs\\test.pdf"
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
       L"/Mac HD/docs/test.pdf",
       L"Mac HD:docs:test.pdf"
 #else
@@ -86,7 +86,7 @@
       {L"/E/docs/test.pdf", L"E:\\docs\\test.pdf"},
       {L"/F/docs/test.pdf", L"F:\\docs\\test.pdf"},
       {L"/G/docs/test.pdf", L"G:\\docs\\test.pdf"},
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
       {L"/Mac HD/docs1/test.pdf", L"Mac HD:docs1:test.pdf"},
       {L"/Mac HD/docs2/test.pdf", L"Mac HD:docs2:test.pdf"},
       {L"/Mac HD/docs3/test.pdf", L"Mac HD:docs3:test.pdf"},
@@ -141,7 +141,7 @@
 #if BUILDFLAG(IS_WIN)
     L"C:\\docs\\test.pdf",
     L"/C/docs/test.pdf"
-#elif defined(OS_APPLE)
+#elif BUILDFLAG(IS_APPLE)
     L"Mac HD:docs:test.pdf",
     L"/Mac HD/docs/test.pdf"
 #else
diff --git a/core/fxcodec/progressive_decoder.cpp b/core/fxcodec/progressive_decoder.cpp
index 98c8c6a..9612025 100644
--- a/core/fxcodec/progressive_decoder.cpp
+++ b/core/fxcodec/progressive_decoder.cpp
@@ -45,11 +45,11 @@
 constexpr size_t kBlockSize = 4096;
 
 #ifdef PDF_ENABLE_XFA_PNG
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
 const double kPngGamma = 1.7;
 #else
 const double kPngGamma = 2.2;
-#endif  // defined(OS_APPLE)
+#endif  // BUILDFLAG(IS_APPLE)
 #endif  // PDF_ENABLE_XFA_PNG
 
 void RGB2BGR(uint8_t* buffer, int width = 1) {
diff --git a/core/fxcrt/cfx_datetime.cpp b/core/fxcrt/cfx_datetime.cpp
index e919275..bedddfd 100644
--- a/core/fxcrt/cfx_datetime.cpp
+++ b/core/fxcrt/cfx_datetime.cpp
@@ -11,7 +11,7 @@
 #include "third_party/base/check.h"
 
 #if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \
-    defined(OS_APPLE) || defined(OS_ASMJS)
+    BUILDFLAG(IS_APPLE) || defined(OS_ASMJS)
 #include <sys/time.h>
 #include <time.h>
 #endif
diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp
index c5ecc59..80370b5 100644
--- a/core/fxcrt/widestring_unittest.cpp
+++ b/core/fxcrt/widestring_unittest.cpp
@@ -1691,7 +1691,7 @@
   EXPECT_EQ(L"cla", WideString::Format(L"%.3ls", L"clams"));
   EXPECT_EQ(L"\u043e\u043f", WideString(L"\u043e\u043f"));
 
-#if !defined(OS_APPLE)
+#if !BUILDFLAG(IS_APPLE)
   // See https://bugs.chromium.org/p/pdfium/issues/detail?id=1132
   EXPECT_EQ(L"\u043e\u043f", WideString::Format(L"\u043e\u043f"));
   EXPECT_EQ(L"\u043e\u043f", WideString::Format(L"%ls", L"\u043e\u043f"));
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index 7b2d476..5dcd97b 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -1029,7 +1029,7 @@
   DestroyPlatform();
 }
 
-#if !defined(OS_APPLE)
+#if !BUILDFLAG(IS_APPLE)
 void CFX_AggDeviceDriver::InitPlatform() {}
 
 void CFX_AggDeviceDriver::DestroyPlatform() {}
@@ -1043,7 +1043,7 @@
                                          const CFX_TextRenderOptions& options) {
   return false;
 }
-#endif  // !defined(OS_APPLE)
+#endif  // !BUILDFLAG(IS_APPLE)
 
 DeviceType CFX_AggDeviceDriver::GetDeviceType() const {
   return DeviceType::kDisplay;
diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h
index 51fe418..e408408 100644
--- a/core/fxge/agg/fx_agg_driver.h
+++ b/core/fxge/agg/fx_agg_driver.h
@@ -107,7 +107,7 @@
   RetainPtr<CFX_DIBitmap> const m_pBitmap;
   std::unique_ptr<CFX_ClipRgn> m_pClipRgn;
   std::vector<std::unique_ptr<CFX_ClipRgn>> m_StateStack;
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   void* m_pPlatformGraphics = nullptr;
 #endif
   CFX_FillRenderOptions m_FillOptions;
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
index 771851c..c08fe96 100644
--- a/core/fxge/cfx_font.cpp
+++ b/core/fxge/cfx_font.cpp
@@ -361,7 +361,7 @@
   m_FontData = {};  // m_FontData can't outive m_Face.
   m_Face.Reset();
 
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   ReleasePlatformResource();
 #endif
 }
diff --git a/core/fxge/cfx_font.h b/core/fxge/cfx_font.h
index a45fc3b..b506f36 100644
--- a/core/fxge/cfx_font.h
+++ b/core/fxge/cfx_font.h
@@ -140,7 +140,7 @@
   bool IsSubstFontBold() const;
 #endif
 
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   void* GetPlatformFont() const { return m_pPlatformFont; }
   void SetPlatformFont(void* font) { m_pPlatformFont = font; }
 #endif
@@ -148,7 +148,7 @@
  private:
   RetainPtr<CFX_GlyphCache> GetOrCreateGlyphCache() const;
   void ClearGlyphCache();
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   void ReleasePlatformResource();
 #endif
   ByteString GetFamilyNameOrUntitled() const;
@@ -169,7 +169,7 @@
   uint64_t m_ObjectTag = 0;
   bool m_bEmbedded = false;
   bool m_bVertical = false;
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   void* m_pPlatformFont = nullptr;
 #endif
 };
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index 56b393e..35bd091 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -604,7 +604,7 @@
       }
     } else {
       if (Charset == FX_Charset::kSymbol) {
-#if defined(OS_APPLE) || defined(OS_ANDROID)
+#if BUILDFLAG(IS_APPLE) || defined(OS_ANDROID)
         if (SubstName == "Symbol") {
           pSubstFont->m_Family = "Chrome Symbol";
           pSubstFont->m_Charset = FX_Charset::kSymbol;
diff --git a/core/fxge/cfx_gemodule.h b/core/fxge/cfx_gemodule.h
index 47e23ec..6c7caae 100644
--- a/core/fxge/cfx_gemodule.h
+++ b/core/fxge/cfx_gemodule.h
@@ -13,7 +13,7 @@
 
 #include "build/build_config.h"
 
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
 #include "third_party/base/span.h"
 #endif
 
@@ -31,7 +31,7 @@
     virtual void Init() = 0;
     virtual std::unique_ptr<SystemFontInfoIface>
     CreateDefaultSystemFontInfo() = 0;
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
     virtual void* CreatePlatformFont(pdfium::span<const uint8_t> font_span) = 0;
 #endif
   };
diff --git a/core/fxge/cfx_glyphcache.cpp b/core/fxge/cfx_glyphcache.cpp
index 82fa8d4..49abaeb 100644
--- a/core/fxge/cfx_glyphcache.cpp
+++ b/core/fxge/cfx_glyphcache.cpp
@@ -36,7 +36,7 @@
 #endif
 #endif
 
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
 #include "core/fxge/cfx_textrenderoptions.h"
 #endif
 
@@ -253,7 +253,7 @@
     return nullptr;
 
   UniqueKeyGen keygen;
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   const bool bNative = text_options->native_text;
 #else
   const bool bNative = false;
@@ -261,7 +261,7 @@
   GenKey(&keygen, pFont, matrix, dest_width, anti_alias, bNative);
   ByteString FaceGlyphsKey(keygen.key_, keygen.key_len_);
 
-#if defined(OS_APPLE) && !defined(_SKIA_SUPPORT_) && \
+#if BUILDFLAG(IS_APPLE) && !defined(_SKIA_SUPPORT_) && \
     !defined(_SKIA_SUPPORT_PATHS_)
   const bool bDoLookUp = !text_options->native_text;
 #else
@@ -272,7 +272,7 @@
                              bFontStyle, dest_width, anti_alias);
   }
 
-#if defined(OS_APPLE) && !defined(_SKIA_SUPPORT_) && \
+#if BUILDFLAG(IS_APPLE) && !defined(_SKIA_SUPPORT_) && \
     !defined(_SKIA_SUPPORT_PATHS_)
   std::unique_ptr<CFX_GlyphBitmap> pGlyphBitmap;
   auto it = m_SizeMap.find(FaceGlyphsKey);
@@ -329,7 +329,7 @@
 }
 #endif  // defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
 
-#if !defined(OS_APPLE)
+#if !BUILDFLAG(IS_APPLE)
 void CFX_GlyphCache::InitPlatform() {}
 #endif
 
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index dd472d5..1606a05 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -301,7 +301,7 @@
 
 bool ShouldDrawDeviceText(const CFX_Font* pFont,
                           const CFX_TextRenderOptions& options) {
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   if (options.font_is_cid)
     return false;
 
diff --git a/core/fxge/dib/cfx_dibbase.h b/core/fxge/dib/cfx_dibbase.h
index 4052f41..aebdb03 100644
--- a/core/fxge/dib/cfx_dibbase.h
+++ b/core/fxge/dib/cfx_dibbase.h
@@ -23,12 +23,12 @@
 // Base class for all Device-Independent Bitmaps.
 class CFX_DIBBase : public Retainable {
  public:
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   // Matches Apple's kCGBitmapByteOrder32Little in fx_quartz_device.cpp.
   static constexpr FXDIB_Format kPlatformRGBFormat = FXDIB_Format::kRgb32;
-#else   // defined(OS_APPLE)
+#else   // BUILDFLAG(IS_APPLE)
   static constexpr FXDIB_Format kPlatformRGBFormat = FXDIB_Format::kRgb;
-#endif  // defined(OS_APPLE)
+#endif  // BUILDFLAG(IS_APPLE)
 
   ~CFX_DIBBase() override;
 
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 5c1adcd..4f9cd05 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -944,7 +944,7 @@
       m_charDetails.SetGlyphAt(cur_index,
                                static_cast<uint16_t>(cp.m_GlyphIndex));
       m_charDetails.SetFontCharWidthAt(cur_index, cp.m_FontCharWidth);
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
       if (cp.m_ExtGID) {
         m_charDetails.SetGlyphAt(cur_index, static_cast<uint16_t>(cp.m_ExtGID));
       }
@@ -1750,7 +1750,7 @@
       }
     }
     glyphs[index] = static_cast<uint16_t>(cp.m_GlyphIndex);
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
     if (cp.m_ExtGID)
       glyphs[index] = static_cast<uint16_t>(cp.m_ExtGID);
 #endif
diff --git a/core/fxge/text_char_pos.h b/core/fxge/text_char_pos.h
index b28d249..6be2671 100644
--- a/core/fxge/text_char_pos.h
+++ b/core/fxge/text_char_pos.h
@@ -20,7 +20,7 @@
   uint32_t m_Unicode = 0;
   uint32_t m_GlyphIndex = 0;
   int m_FontCharWidth = 0;
-#if defined(OS_APPLE)
+#if BUILDFLAG(IS_APPLE)
   uint32_t m_ExtGID = 0;
 #endif
   int32_t m_FallbackFontPosition = 0;