This CL adds boolean values to the /Private dictionary in the
hello_world_pieceinfo test resources. This updates the PDF test files to
support upcoming APIs for getting and setting boolean dictionary
entries.
Bug: 42270521
Change-Id: I4ccbc205955bb7e81308e93bfcc811f6cdc99663
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153490
Reviewed-by: Andy Phan <andyphan@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Bot hypothesis about flakey windows component build tests.
In pdfium_test.cc, call fflush(stdout) after printf calls in example
embedder callbacks (such as ExampleAppAlert and ExampleAppResponse)
and call fflush(stdout) and fflush(stderr) at the end of main().
On Windows MSVC CRT, block-buffered piped streams can be truncated if
the process terminates before the buffer is flushed. Explicitly
flushing stdout prevents truncation in text diff tests.
TAG=agy
CONV=8e1e302a-cea2-4f5a-972f-5b3625f86d6d
Change-Id: Iea9180efccf3ec4b4db329c88c24efb83aca0466
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153630
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Move SkiaBmpContext, CJpegContext, CPngContext, and SkiaPngContext out
of anonymous namespaces and internal source files into their own
dedicated header and implementation files.
Eventually, the foo_decoder.{h,cpp} files will be removed as they
are static wrappers with all the action taking place in the context.
There is no funny business in this move: each class is transferred
line by line without renaming, modifying signatures, or changing any
behavior.
TAG=agy
CONV=794fb8a5-48ac-429f-a73a-af68dfabff99
Change-Id: I1677537a2ef502c8f40431ce6c523cf9f2c2ca30
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153550
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Short ISO date strings caused out-of-bounds indexing past the end of the
input span at two unguarded digit checks (month- and day-position),
tripping the span's CHECK() and aborting the process.
Add a bounds check before both digit guards, mirroring the existing
IsIsoTimeFormat() handling, and extend the IsIsoDateFormat unittest with
both valid and malformed-short inputs.
Bug: 539204640
Change-Id: I6645831217a418ccc8d8c54ae0a9a36c582114c6
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153230
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
This CL removes additional newlines in bmp_decoder.cpp,
skia_bmp_decoder.cpp and gif_decoder.cpp.
Change-Id: I938a891591eca618c738ea334ac69fe31641548a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153530
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Auto-Submit: Aryan Krishnan <aryankrishnan4b@gmail.com>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Longstanding irritation given other numbers in these function names
signify pixel depths.
sed -i 's/\(ConvertBuffer_\w*\)2\([A-Z]\)/\1To\2/g'
Change-Id: I18e3d705302cbfe8a4bed4f3921418da28ae0fff
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153470
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Refactor ConvertBuffer_8bppMask2Rgb(), ConvertBuffer_8bppPlt2Rgb(),
and ConvertBuffer_Rgb2Rgb32().
This replaces UNSAFE_TODO() raw pointer increments with compile-time
fixed stride loops using GetScanlineAs<>() and fxcrt::Zip() over typed
color structs.
In ConvertBuffer_8bppPlt2Rgb(), also replace the raw array palette
initialization loop with std::array<FX_BGR_STRUCT<uint8_t>, 256> and
fxcrt::Zip().
TAG=agy
CONV=b9441e85-7a2d-45eb-b5fc-45a5305e1279
Change-Id: I042de3f15de41470ec14a543d437af2a98f81326
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153430
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Replace UNSAFE_TODO() raw pointer loops with compile-time fixed
stride loops using GetScanlineAs<>() and fxcrt::Zip() by templating
for 24 or 32 BPP and updating caller.
TAG=agy
CONV=79149323-9e55-44bc-a43a-b9aedc44a81b
Change-Id: I0e92603cd6a082de393988130a6b00dabcb3be8b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153410
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Add virtual DecodeImage(size_t frame_index) method to
ProgressiveDecoderContext. Override DecodeImage in CFX_BmpContext,
SkiaBmpContext, and CFX_GifContext. Update BmpContinueDecode and
GifContinueDecode in ProgressiveDecoder to call DecodeImage directly
on context_ instead of via static wrapper classes.
TAG=agy
CONV=7a82d35c-037e-4042-8882-448367a075e7
Change-Id: Iea8f46fd873bed74013664ca91dcd8a87df2a6ab
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153290
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Replace bmp_context_, gif_context_, jpeg_context_, png_context_, and
tiff_context_ in ProgressiveDecoder with a single context_ member of
type std::unique_ptr<ProgressiveDecoderContext>.
Simplify ProgressiveDecoder to reference context_ across all supported
image formats.
TAG=agy
CONV=be5c4020-7f57-4f8c-b6e2-d0099cfddd2c
Change-Id: I500f1337bfa7d36c81c0af17bff0205abf0eee38
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153130
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
This CL adds hello_world_pieceinfo.in/.pdf, which includes the
/PieceInfo dictionary attached to both the document catalog root and
individual page objects. These files allow for future testing of APIs to
access or edit /PieceInfo.
Bug: 42270521
Change-Id: Ic8d110e618703b2f59ab894498b6200eae2397e7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152970
Reviewed-by: Andy Phan <andyphan@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Refactor ProgressiveDecoderContext into a virtual base class for image
decoding contexts. Replace format-specific context pointers in
ProgressiveDecoder with a single ProgressiveDecoderContext pointer and
eliminate static_cast downcasts across decoder implementations. Add
static Create factory methods to ProgressiveDecoder and
ProgressiveDecoderContext.
TAG=agy
CONV=f7421c5c-5a62-488b-85d3-5c6de8bdc632
Change-Id: Ie29f9fdfc852654f489a51c02c657e21dd52c86f
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153090
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Update CFX_BmpDecompressor::ReadHeader() to explicitly set the alpha
byte of BMP palette entries to opaque (0xFF). Previously, old BMP
palettes set alpha to 0x00 and newer palettes copied the reserved fourth
byte (which is typically 0x00 in BMP files).
With valid alpha in BMP palette entries, remove the BMP-specific special
case block in ProgressiveDecoder 8BPP RGB-to-ARGB resampling, allowing
both BMP and GIF to use the same palette resampling loop.
TAG=agy
CONV=7a82d35c-037e-4042-8882-448367a075e7
Change-Id: I994c27923a70c6d1885b3c427e1b5f97249f3f81
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153350
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Define Status enum in ProgressiveDecoderContext with kError, kSuccess,
and kContinue values. Update BmpDecoder and GifDecoder to directly
use ProgressiveDecoderContext::Status.
TAG=agy
CONV=7a82d35c-037e-4042-8882-448367a075e7
Change-Id: I42fb0bc107e9d2b6b5c25b40bd4f9beefd6c73bd
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153270
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Refactor CPDF_DIB::GetScanline() to improve safety and readability:
- Use fxcrt::Zip() and structured spans instead of raw index
calculations. This removes several UNSAFE_TODO blocks. Using Zip()
allows the compiler to prove loop accesses are in-bounds and optimize
away the runtime checks, avoiding bounds checking performance
regressions.
- Cache `GetWidth()` as a `const size_t width` at the function scope
to avoid redundant calls and ensure type-safe loop comparisons.
TAG=agy
CONV=40e28386-4f52-4db6-a72f-2fbe86431c92
Bug: 536543461
Change-Id: Ia98f187dda798e63f8b898376053dafce0a867cc
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152691
Commit-Queue: Andy Phan <andyphan@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
In CPDF_DIB::GetScanline(), color key masking was only implemented for
images with 8 or fewer bits per pixel, or for 24-bit RGB images. For
other image formats, such as 16-bit grayscale, the code fell back to
filling the mask buffer's alpha channel with 0xFF (opaque), effectively
ignoring the color key mask. This caused masked pixels to render with
their raw color (usually black) instead of being transparent.
To resolve this, generalize the fallback path in CPDF_DIB::GetScanline()
to handle arbitrary bit-depths and component counts. A new helper
function IsPixelInColorKeyRange() extracts pixel components using
GetBits8() and checks them against the color key bounds. The fallback
path uses this helper to correctly populate the alpha channel, setting
it to 0 for masked pixels and 0xFF for opaque pixels.
TAG=agy
CONV=40e28386-4f52-4db6-a72f-2fbe86431c92
Bug: 536543461
Change-Id: I5f7f96adfc35cad5251375ff52aaad12f175eae6
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152711
Commit-Queue: Andy Phan <andyphan@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Explain the purpose of CPDF_DIB class.
TAG=agy
CONV=e8ed28e6-3ab6-4f24-956c-232d5559604f
Change-Id: I9c6d5fde1a7e33446adfcdcea1f8685917442b6d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153150
Commit-Queue: Andy Phan <andyphan@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
The test is currently suppressed because PDFium does not correctly
apply color key masks to 16-bit grayscale images.
TAG=agy
CONV=40e28386-4f52-4db6-a72f-2fbe86431c92
Bug: 536543461
Change-Id: I5a008350438e1a16825e5dad503363106fe6005c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152710
Commit-Queue: Andy Phan <andyphan@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Document the difference between GetOrCreatePageView() and GetPageView().
Mainly that GetOrCreatePageView() never returns nullptr. Then transitively
document that CFFL_FormField::GetCurPageView() never returns nullptr.
Separately audit all the callers and remove dead code that assumed
GetCurPageView() can return nullptr. Upgrade some cheap DCHECK() calls
to CHECK().
Change-Id: Iaa99257306dd6f152dc03e082c0e19ce80395f19
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153170
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Embedder tests often install stack-local delegates, but EmbedderTest can
invoke delegate callbacks while closing the document in TearDown(). By
then, a stack delegate may already have been destroyed.
Add SetOwnedDelegate() so the fixture owns the custom delegate through
document teardown, then restores the default delegate before releasing
it. Migrate all existing call sites, remove the raw SetDelegate() API,
and store the active delegate as an UnownedPtr.
Bug: 535697671
Change-Id: I8e8da028e9c563e82d40099637c63978122077eb
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152110
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Disable automatic whole-line Bidi segment reversal for text extraction,
preserving the original logical ordering of text segments on the page to
match Acrobat behavior and prevent semantic phrase reversals in mixed
English/Hebrew sentences. Then update FPDFTextEmbedderTest.ActualTextRtl
test expectations to match this behavior change.
TAG=agy
CONV=f944b222-25e8-4814-ac19-fc1a0101da16
Bug: 525087036
Change-Id: Ia48be8bb74ed60e4bd1bd34b34461ea5d46b3db0
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152910
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Honor the pdf_enable_rust_bmp GN build argument to allow building
PDFium with Skia's Rust-based BMP decoder instead of the legacy C++ BMP
decoder.
Add SkiaBmpDecoder and BmpDecoderDelegate to adapt the Rust BMP decoder
for ProgressiveDecoder.
-- Adjust minimum input size calculation for 24/32 bit skia results
in ProgressiveDecoder.
TAG=agy
CONV=19661998-5d2f-4919-b147-d44fa811807c
Bug: 537855738
Change-Id: If87228e8e2b3b1224d631044a7931c2cdc79fd4d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152570
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Fix /ActualText character ordering: Identify RTL text segments generated
from marked content /ActualText spans and process their characters in
forward logical order rather than reversing them. Update
FPDFTextEmbedderTest.ActualTextRtl with the improved test expectations
to match the new behavior.
TAG=agy
CONV=117163e4-c12b-43d7-9709-b718d4450d3e
Bug: 525087036
Change-Id: I73529d1103329e741d259002c437afb6bad7fb7b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/151070
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Add a second parameter to the CFX_BidiString constructor to allow the
internal predominant-segment reversal heuristic to be optionally turned
off. This will be used in https://pdfium-review.googlesource.com/151070
to improve /ActualText ordering.
- Migrate existing CFX_BidiString users to explicitly turn on
auto-ordering to preserve pre-existing behavior.
- Add unit test for turning off auto-ordering.
TAG=agy
CONV=117163e4-c12b-43d7-9709-b718d4450d3e
Bug: 525087036
Change-Id: I062690884127b14e933f74ae9c874d294effd3c5
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152390
Auto-Submit: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Change CPDF_TextPage::ProcessTextObjectItems() to return a boolean to
indicate whether to call ReverseTempTextBufs() or not. Move the RTL and
matrix determinant logic for calculating that boolean from the only
caller into ProcessTextObjectItems(). This refactoring will align
ProcessTextObjectItems() behavior with the upcoming
ProcessMarkedContent() change in
https://pdfium-review.googlesource.com/152751.
TAG=agy
CONV=42897bdc-5c71-4a3e-9f56-a4ef21ac2a39
Change-Id: I15bcd98e3e740ec912c5cf2c39ca9eca777582c4
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152751
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Update CFX_BidiString's constructor to break ties between equal numbers
of LTR and RTL segments by defaulting to LTR rather than RTL.
- Add a CFX_BidiString unit test for this case.
- Update FPDFTextEmbedderTest.ActualTextRtl expectation to match this
change. The behavior is now closer to Acrobat's behavior.
TAG=agy
CONV=117163e4-c12b-43d7-9709-b718d4450d3e
Bug: 525087036
Change-Id: Ibe2501522012de91cf9ed1e2cca112930bae9211
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152371
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Replace CFX_BidiString usage in CPVT_Section::OutputLines() with
CFX_BidiResolver to implement the Unicode Bidirectional Algorithm. Pass
the state from CPVT_VariableText::GetDirection() down to the resolver to
establish the base paragraph direction context. Resolve visual runs
globally across the entire paragraph to correctly reverse mixed
direction text and handle trailing spaces. Update unit tests to assert
new layout coordinates.
Bug: 534486929
Change-Id: I67ce57e19f25a7e99ad09e19d0cef0aca076fd67
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152251
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Seung Hyun Jin <seunghyunjin@google.com>
Introduce tests for `kCenter` and `kRight` alignments. Document the
correct horizontal positioning behavior for an empty text string, where
the expected caret coordinates are 50.0f and 100.0f respectively.
Demonstrate that internal alignment offset calculation must execute even
when word array contains zero elements. Loop must correctly apply the
offset to the empty line to guarantee the caret is shifted correctly
before the layout engine terminates.
Bug: 534486929
Change-Id: I28233e473a1aeb5d98310bea89f88caed7550e0d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152650
Commit-Queue: Seung Hyun Jin <seunghyunjin@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Add a new class that is similar to MaybeOwned, but focused on storing
either a span that points to external data, or a span that points to an
owned DataVector. It is currently tailored to CJBig2_Image's needs. Use
it in CJBig2_Image to replace all the manual memory management.
Change-Id: Ia5564685150422a0f20d625f6295345b7c44d476
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/147510
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Introduce baseline unit tests for CPVT_Section that assert buggy layout
behaviors of CPVT_Section. Document the exact failure mode where mixed
directional text containing Hebrew and English fail to reverse correctly
due to CFX_BidiString evaluation of each physical line instead of per
paragraph. Layout behavior will be fixed in
https://pdfium-review.googlesource.com/c/152251 by introducing explicit
layout engine.
TAG=agy
Bug: 534486929
Change-Id: Ic781e182ea3bb46e13daa06560d392db0c5af554
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152270
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Seung Hyun Jin <seunghyunjin@google.com>
Add CFX_BidiResolver::ParagraphDirection to CPVT_VariableText to track
explicit text directionality (kAuto, kLeftToRight, kRightToLeft). Add
GetTextDirection() and SetTextDirection() accessors to CPVT_VariableText
and pass the state through CPWL_EditImpl. Allow form fields to enforce a
base paragraph direction during layout, overriding the text's natural
direction (implemented in
https://pdfium-review.googlesource.com/c/152251).
Bug: 534486929
Change-Id: I75c25959422a60f7242bbf22071123664f821f41
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152191
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Seung Hyun Jin <seunghyunjin@google.com>
Create a new class with RAII wrappers for ICU UBiDi structs. It extracts
visual text runs for bi-directional text layout, laying the foundation
to replace the legacy Foxit custom bidi logic. Constructor implements
paragraph initialization using ubidi_setPara(), alongside a safe
UBiDiDeleter. It introduces the core logical-to-visual data mapping via
GetVisualRunsForLine(), which uses ubidi_setLine() and
ubidi_getVisualRun() to calculate the correct visual display order of
bidi text segments as a data vector. Add unit tests to verify index
mapping calculations are correct and ensure early exits return without
leaking memory. In upcoming CLs, GetVisualRunsForLine() will be called
by CPVT_Section::OutputLines() for mixed directional text layout
support.
Bug: 534486929
Change-Id: I67c27f1b63c74ef35879f79c2147559bf570fc07
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/151971
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Seung Hyun Jin <seunghyunjin@google.com>
Replace the implicit capture in the `position_word` lambda with an
explicit capture list to comply with Google C++ style. Replace `auto`
with type declarations for std::unique_ptr<CPVT_WordInfo> and
CFX_BidiChar::Segment in the internal loops to improve code readability
Document the overall purpose of CPVT_Section::OutputLines() in header
file.
Bug: 534486929
Change-Id: I2556fbf84b3c6c101fb647f2f34eb900590a8383
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152670
Commit-Queue: Seung Hyun Jin <seunghyunjin@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Update actual_text_rtl.in to include literal Hebrew text rendered using
the same font as hebrew_mirrored.in, followed by /ActualText text. Reuse
hebrew_truetype_font.fragment and hebrew_cmap.fragment to avoid
duplication. Then update FPDFTextEmbedderTest.ActualTextRtl expectations
to match the new test input.
TAG=agy
CONV=117163e4-c12b-43d7-9709-b718d4450d3e
Bug: 525087036
Change-Id: I9ce2030ddb6d146532f4cf83c2c56f4a2c1661ae
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152770
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Auto-Submit: Lei Zhang <thestig@chromium.org>
This CL removes the cache for /ICCBased gradients to remove the
quantization for gradients, hence fixing the issue.
Bug: 41244214
Change-Id: I0c749b43b09e1740f800531fcf055ce352f40418
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/151770
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Declare the pdf_enable_rust_bmp build argument, its override
pdf_enable_rust_bmp_override, and define the PDF_ENABLE_RUST_BMP
preprocessor macro when pdf_use_skia && pdf_enable_rust_bmp is active.
This allows external build recipes to configure the GN argument prior to
activating the Rust-based BMP decoder in a follow-up change.
TAG=agy
CONV=f457c92a-036e-44c5-89eb-1caaf0d672f5
Bug: 537855738
Change-Id: Ia44c2b798b5c26cac89a8025b83d8244e1978655
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152810
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
FPDFPage_Flatten() converted its page handle to CPDF_Page but checked
the original handle for null. A full-XFA page without PDF backing
therefore reached a null CPDF_Page dereference.
Check the converted pointer and cover the failure with an XFA embedder
test.
Bug: 533167360
Change-Id: Ifa1fd59f5fe4d1639f6c6c9e69e0ee412d720758
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/151810
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Move the NotoSansHebrew TrueType font data stream and ToUnicode CMap
stream from hebrew_mirrored.in to separate .fragment files so they can
be reused in other PDFs. This is effectively a refactor, as regenerating
hebrew_mirrored.pdf produces no changes.
TAG=agy
CONV=117163e4-c12b-43d7-9709-b718d4450d3e
Change-Id: I3c249f1380f79415befaa01cd2d4f6815884c663
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152750
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Consistently use std::ranges::reverse() within SwapTempTextBuf() to do
the work. With that in mind, rename it to ReverseTempTextBufs() to
better describe what it does. Also switch away from Hungarian notation
along the way.
Change-Id: I765ddddf911f11d7747630a227fb987de21f0c3d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152671
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Update CPVT_Section::GetWordRangeSpan() to receive start and length
integer arguments instead of explicit bounds. Clarifies and helps
prevent off-by-one errors by removing ambiguity of whether an end index
is inclusive or exclusive. Aligns with standard span slicing semantics.
Adjust CPVT_Section::GetWordRangeIteratorPair() to compute the end
index inline. Update the existing caller in CPVT_Section::OutputLines()
to calculate `line_length` before passing to span generator.
Bug: 534486929
Change-Id: I2eece9bfc6ce7664af5bc7e06bca32d2c024051b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152590
Commit-Queue: Seung Hyun Jin <seunghyunjin@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Bring testing/resources/hebrew_mirrored.pdf up to spec so Acrobat Reader
can open it by adding the required /Length1 key-value pair to the
TrueType font stream. Do this by editing hebrew_mirrored.in and
regenerating hebrew_mirrored.pdf. The other /Length values are also
slightly different due to fixup_pdf_template.py changes in
https://pdfium-review.googlesource.com/c/128570.
TAG=agy
CONV=117163e4-c12b-43d7-9709-b718d4450d3e
Change-Id: I4cf2bcf70466e6bdd21f57ee5aca6fa3f04ad5f2
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152730
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Refactor alignment coordinate calculations inside
CPVT_Section::OutputLines() by introducing a get_alignment_offset()
lambda. Replace multiple switch statements used to calculate fMinX and
fPosX with direct calls to this lambda. Relies on Alignment enum in
https://pdfium-review.googlesource.com/c/152210.
Bug: 534486929
Change-Id: I688815ef4833c7fe8878f310497f543ca1e535a8
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152230
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Seung Hyun Jin <seunghyunjin@google.com>
Replace the integer-based alignment constants with a strongly typed enum
class Alignment. Update CPVT_VariableText to exclusively store and
return Alignment instead of int32_t primitives. Modify callers to
explicitly use kLeft, KCenter, and kRight. Ensure bounds-checking and
safe casting occurs at I/O boundaries.
Bug: 534486929
Change-Id: I2785c463265544b09745d2e7f0890276b11c2eb2
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152210
Commit-Queue: Seung Hyun Jin <seunghyunjin@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
This CL improves the readability, safety, and structure of the color
translation logic in CPDF_ICCBasedCS.
Key changes include:
- Replacing unsafe pointers by swapping raw pointer arithmetic inside
the UNSAFE_TODO block with safe index-based access on spans.
- Preventing overflows by using FX_SAFE_INT32 for color and pixel count
calculations to ensure safe integer arithmetic.
- Eliminating magic numbers by define kNumQuantizedLevels (52) and
kQuantizationDegree (5) constants to replace raw literals and
document the quantization logic.
- Removing the `components > 3` condition that always evaluates to
false.
- Replacing some hungarian variable naming with snake case.
Change-Id: I90a2c93bc9279361aeb9b06c17ee52e9fbcd2b73
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/152130
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>