Return span<> from CFX_DIBbase::GetAlphaMaskScanline()

Then immediately apply .data() at callers to minimize size of the
change. We can convert these in a follow-up CL.

Change-Id: Ifd940bf41f7bc4c823fabd8b0e5dd52b472266ce
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/85574
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/dib/cfx_bitmapcomposer.cpp b/core/fxge/dib/cfx_bitmapcomposer.cpp
index 6fbf1bd..75c9bea 100644
--- a/core/fxge/dib/cfx_bitmapcomposer.cpp
+++ b/core/fxge/dib/cfx_bitmapcomposer.cpp
@@ -125,7 +125,7 @@
     dest_scan += static_cast<uint32_t>(offset.ValueOrDie());
   }
   uint8_t* dest_alpha_scan =
-      m_pBitmap->GetWritableAlphaMaskScanline(line + m_DestTop);
+      m_pBitmap->GetWritableAlphaMaskScanline(line + m_DestTop).data();
   if (dest_alpha_scan)
     dest_alpha_scan += m_DestLeft;
 
diff --git a/core/fxge/dib/cfx_bitmapstorer.cpp b/core/fxge/dib/cfx_bitmapstorer.cpp
index e4d0eaf..2de8ba8 100644
--- a/core/fxge/dib/cfx_bitmapstorer.cpp
+++ b/core/fxge/dib/cfx_bitmapstorer.cpp
@@ -31,7 +31,8 @@
   if (dest_buf)
     memcpy(dest_buf, scanline, m_pBitmap->GetPitch());
 
-  uint8_t* dest_alpha_buf = m_pBitmap->GetWritableAlphaMaskScanline(line);
+  uint8_t* dest_alpha_buf =
+      m_pBitmap->GetWritableAlphaMaskScanline(line).data();
   if (dest_alpha_buf)
     memcpy(dest_alpha_buf, scan_extra_alpha, m_pBitmap->GetAlphaMaskPitch());
 }
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp
index 2e396a9..c3fe802 100644
--- a/core/fxge/dib/cfx_dibbase.cpp
+++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -854,13 +854,14 @@
   return m_pAlphaMask ? m_pAlphaMask->GetPitch() : 0;
 }
 
-const uint8_t* CFX_DIBBase::GetAlphaMaskScanline(int line) const {
-  return m_pAlphaMask ? m_pAlphaMask->GetScanline(line).data() : nullptr;
+pdfium::span<const uint8_t> CFX_DIBBase::GetAlphaMaskScanline(int line) const {
+  return m_pAlphaMask ? m_pAlphaMask->GetScanline(line)
+                      : pdfium::span<const uint8_t>();
 }
 
-uint8_t* CFX_DIBBase::GetWritableAlphaMaskScanline(int line) {
-  return m_pAlphaMask ? m_pAlphaMask->GetWritableScanline(line).data()
-                      : nullptr;
+pdfium::span<uint8_t> CFX_DIBBase::GetWritableAlphaMaskScanline(int line) {
+  return m_pAlphaMask ? m_pAlphaMask->GetWritableScanline(line)
+                      : pdfium::span<uint8_t>();
 }
 
 uint8_t* CFX_DIBBase::GetAlphaMaskBuffer() {
diff --git a/core/fxge/dib/cfx_dibbase.h b/core/fxge/dib/cfx_dibbase.h
index d671b0c..fb50e51 100644
--- a/core/fxge/dib/cfx_dibbase.h
+++ b/core/fxge/dib/cfx_dibbase.h
@@ -73,8 +73,8 @@
 
   bool HasAlphaMask() const { return !!m_pAlphaMask; }
   uint32_t GetAlphaMaskPitch() const;
-  const uint8_t* GetAlphaMaskScanline(int line) const;
-  uint8_t* GetWritableAlphaMaskScanline(int line);
+  pdfium::span<const uint8_t> GetAlphaMaskScanline(int line) const;
+  pdfium::span<uint8_t> GetWritableAlphaMaskScanline(int line);
   uint8_t* GetAlphaMaskBuffer();
   RetainPtr<CFX_DIBitmap> GetAlphaMask();
   RetainPtr<CFX_DIBitmap> CloneAlphaMask() const;
diff --git a/core/fxge/dib/cstretchengine.cpp b/core/fxge/dib/cstretchengine.cpp
index e09541d..db4830c 100644
--- a/core/fxge/dib/cstretchengine.cpp
+++ b/core/fxge/dib/cstretchengine.cpp
@@ -311,7 +311,7 @@
     const uint8_t* src_scan_mask = nullptr;
     uint8_t* dest_scan_mask = nullptr;
     if (!m_ExtraAlphaBuf.empty()) {
-      src_scan_mask = m_pSource->GetAlphaMaskScanline(m_CurRow);
+      src_scan_mask = m_pSource->GetAlphaMaskScanline(m_CurRow).data();
       dest_scan_mask = m_ExtraAlphaBuf.data() +
                        (m_CurRow - m_SrcClip.top) * m_ExtraMaskPitch;
     }