summaryrefslogtreecommitdiff
path: root/core
AgeCommit message (Collapse)Author
2016-09-13Remove more strcmp/memcmp usage.tsepez
Review-Url: https://codereview.chromium.org/2340513002
2016-09-13Stop converting widestring -> c_str -> widestring in several places.tsepez
Avoids a needless alloc and copy. Review-Url: https://codereview.chromium.org/2338553002
2016-09-13Get rid of memcmp in CFieldTree::Lookup()tsepez
Wide strings compare just fine on their own. Review-Url: https://codereview.chromium.org/2331233002
2016-09-13Make ipdf_formnotify a pure virtual interfacetsepez
Removes some unused code for the default implementation, Review-Url: https://codereview.chromium.org/2332983002
2016-09-12Remove GetDictBy("DR") from annot/field dictionariesnpm
We should not use DR field from annotation/field dictionaries, since these are not supposed to have one. In PDF spec 1.7, DR is defined only for the form dictionary, in 8.6.1. In addition, note 118 in Appendix H says "In PDF 1.2, an additional entry in the field dictionary, DR, was defined but was never implemented. Beginning with PDF 1.5, this entry is obsolete and should be ignored." The changes in CBA_FontMap fix the bug below. The changes in cpvt_generateap do not affect the bug but follow the reasoning from the above paragraph. BUG=pdfium:538 Review-Url: https://codereview.chromium.org/2337673002
2016-09-12Verify value of prec before usingdsinclair
The fx_codec_jpx_opj code will attempt to do a 1 << (prec - 1). If the prec value is >=32 then that shift will overflow the int value. This CL adds a check that prec is < 32 before attempting the shift. BUG=chromium:633208 Review-Url: https://codereview.chromium.org/2334823002
2016-09-12Refactor CPDF_Document by creating new methodsnpm
- Methods GetPagesDict, ProcessNonbCJK, CalculateFlags, and CalculateEncodingDict created to reduce duplicated code. - Code nits Review-Url: https://codereview.chromium.org/2323793003
2016-09-12change memcpy to memmove for potential nearby addressestracy_jiang
BUG=645186 Review-Url: https://codereview.chromium.org/2326103002
2016-09-12fix some uninitialized variableshong_zhang
BUG=627399 Review-Url: https://codereview.chromium.org/2328003002
2016-09-12Make CFX_Obeservable::Observer into a pointer-ish type;tsepez
This may be a better design because it avoids having a level of indirection that the Observer required. Review-Url: https://codereview.chromium.org/2326763002
2016-09-09Define behaviors of FPDF_RenderPageBitmap_Retail and FPDF_FFLDraw.chromium/2858chromium/2857chromium/2856jaepark
Previously, PDFium only supported widget annotations to draw forms. As we've implemented other annotations, the behavior of FPDF_RenderPageBitmap_Retail and FPDF_FFLDraw changed. So, this CL clearly defines what needs to be done in FPDF_RenderPageBitmap_Retail and FPDF_FFLDraw. This CL first assumes that PDFium users will always call FPDF_RenderPageBitmap_Retail and FPDF_FFLDraw to render PDF pages, because otherwise they are not able to support PDF forms. FPDF_RenderPageBitmap_Retail should only deal with non-widget annotations, such as highlight, underline, text, etc. If FPDF_ANNOT flag is passed, non-widget annotations are drawn. Otherwise, they are hidden. FPDF_FFLDraw should only deal with annotations that requires user-interaction, such as widget annotations and popup annotation. Since popup annotation is associated with non-widget annotation, they should not be drawn if the associated annotation is hidden. Thus, if FPDF_ANNOT flag is passed, popup annotations are drawn. Otherwise, they are hidden. Widget annotations should be always drawn regardless of FPDF_ANNOT flag since they need to be always displayed for PDF forms. Also, roll DEPS for testing/corpus to 8485b30. BUG=pdfium:594 Review-Url: https://codereview.chromium.org/2323203002
2016-09-08explicit operator bool for CFX_RetainPtr and CFX_CountRefchromium/2855tsepez
Review-Url: https://codereview.chromium.org/2324733003
2016-09-08Delete unused methods in CPDF_Documentnpm
Review-Url: https://codereview.chromium.org/2323933002
2016-09-08Check whether the annotation content is empty using CFX_WideString.jaepark
CFX_ByteString cannot properly check whether the contents string is empty because the first two bytes of text strings encoded in Unicode are always ASCII 254 followed by 255. So if we get contents in CFX_ByteString, the length will always be 2. Also, roll DEPS for testing/corpus to 608bf04. Review-Url: https://codereview.chromium.org/2293403003
2016-09-08Fix memory management errors for font loading and copyingweili
A few issues are fixed: --Change variable |m_bLogic| in CFX_Font to |m_bShallowCopy| to reflect its meaning better; --For a shallow copy of font, we must guarantee that the copied font will not be deleted until the shallow copy is deleted. So need to increase the src font's refcount when copying it; --The stream |m_pOwnedStream| needs to have matched new/delete These errors need to be fixed before we can properly delete all the fonts to address the leaks. BUG=pdfium:242 Review-Url: https://codereview.chromium.org/2322043002
2016-09-08Replace CJS_Runtime::Observer with CFX_Runtime<CJS_Runtime>::Observertsepez
Previously, the observer set a flag which conditionalized a null pointer return. Now, we just clear the pointer. Destruction order matters, so add a method to trigger notifications. Review-Url: https://codereview.chromium.org/2322743002
2016-09-08Switch to ValueOrDiedsinclair
We know the values are always valid at this point, so use ValueOrDie instead of ValueOrDefault. BUG=chromium:637984 Review-Url: https://codereview.chromium.org/2319343003
2016-09-07Make Observers into a templated classtsepez
Review-Url: https://codereview.chromium.org/2311343003
2016-09-07Verify image dimentions before usingdsinclair
Verify the provided image size is within bounds before loading. BUG=chromium:639160 Review-Url: https://codereview.chromium.org/2323473002
2016-09-07Verify pattern start values.dsinclair
When calculating the starting x and y for a pattern it is possible to overflow the int value. Use checked math to make sure we don't overflow. BUG=chromium:637984 Review-Url: https://codereview.chromium.org/2317283002
2016-09-07Maybe avoid a copy in CPDF_RenderStatus::SelectClipPathtsepez
Use the shared copy-on-write version instead of the underlying CFX_GraphStateData since it may not always get modified. Review-Url: https://codereview.chromium.org/2316823002
2016-09-06Make CPDF_TextStateData private to CPDF_TextState.chromium/2853tsepez
Review-Url: https://codereview.chromium.org/2313083002
2016-09-06Move CPDF_GraphState to CFX_GraphStatetsepez
The FX layer is spying on its private data, so make the job of ref-counting it live in FX as well, instead of up a layer at pdfapi. Pre-cursor to making this private and passing the graph state itself everywhere. Review-Url: https://codereview.chromium.org/2314223002
2016-09-06Make CPDF_ContentMarkData private to CPDF_ContentMarktsepez
Review-Url: https://codereview.chromium.org/2312743005
2016-09-06Make ColorStateData private to CPDF_ColorStatetsepez
Review-Url: https://codereview.chromium.org/2311313002
2016-09-06Move CFX_Font definition to its own file and clean upnpm
- Rename fx_ge_font.cpp to cfx_font.cpp - Deleted unused CONTRAST_RAMP_STEP in fx_ge_text.cpp - Move CFX_Font definitions and auxiliary methods in fx_ge_text to cfx_font - Remove extern "C", static, and underscore prefixes in new namespace methods in cfx_font.cpp Review-Url: https://codereview.chromium.org/2304493005
2016-09-06Move ShouldGenerateAPForAnnotation check to CPDF_Annot::GenerateAPIfNeededtonikitoo
By doing this, we simplify the code in cpvt_generateap.cpp, and avoid calling CPVT_GenerateAP methods altogether, when it is known that they are bailing out. This is a preparation to fix pdfium bug 585. BUG=pdfium:585 Review-Url: https://codereview.chromium.org/2310873002
2016-09-03Use safe bool conversion operators in fpdf_page/chromium/2852chromium/2851chromium/2850tsepez
Review-Url: https://codereview.chromium.org/2310693002
2016-09-02Make CPDF_ClipPath have a CPDF_ClipPathData rather than inheriting.tsepez
Make Data private to the ClipPath class which manages it transparently for its callers. This prevents the callers from having to remember to make a copy before dirtying the shared data, since the operations that modify state will do this under the covers for us. Review-Url: https://codereview.chromium.org/2301263003
2016-09-02Remove CFX_Matrix::Copy() in favor of assignmenttsepez
The default assignment operator will suffice and allows us to write matrix1 = matrix2; Review-Url: https://codereview.chromium.org/2307953003
2016-09-02Make CPDF_GeneralStateData private.tsepez
All interaction goes through the CPDF_GeneralState, which manages the underlying storage transparently to the callers. Make StateData use a real string and a real matrix rather than C-style arrays. Review-Url: https://codereview.chromium.org/2302683002
2016-09-02Make CPDF_Path have a CFX_Path rather than inheritingtsepez
Review-Url: https://codereview.chromium.org/2305103002
2016-09-02Make CPDF_GeneralState have a CPDF_GeneralStateDatachromium/2848tsepez
Remove a const cast along the way and propagate to callers. Review-Url: https://codereview.chromium.org/2303553002
2016-09-01Fix leaks due to created popup annotationschromium/2847weili
When we create popup annotations, we also create the dictionary associated with it. For regular annotations, the dictionary associated with an annotation is not owned by annotation, and will be released separately. But our created dictionary is not associated with any other data structure, it would be leaked if not released by the associated annotation. Add a boolean to indicate the ownership to the dictionary, and release the owned dictionary during the destruction of an annotation. BUG=pdfium:242 Review-Url: https://codereview.chromium.org/2301613002
2016-09-01Use unsigned page indexes in CPDF_HintTables.thestig
Fix up callers from CPDF_DataAvail. Review-Url: https://codereview.chromium.org/2294383003
2016-09-01Move CPDF_Type3Cache and CPDF_Type3Glyphs to their own filesnpm
Review-Url: https://codereview.chromium.org/2298163004
2016-09-01Fix CPDF_CIDFont::GlyphFromCharCode for fonts flagged with PDFFONT_SYMBOLICnpm
UnicodeFromCharCode should be tried even if the font is flagged as PDFFONT_SYMBOLIC. The result should be checked in case it's empty. This fixes some corpus tests that were being incorrectly rendered, as well as the bug below. A deps change will be required before landing this CL. BUG=chromium:591303 Review-Url: https://codereview.chromium.org/2300893003
2016-09-01Handle another integer overflow in ReadPageHintTable().thestig
Return false instead of crashing. BUG=641882 Review-Url: https://codereview.chromium.org/2300903002
2016-09-01Better validate hint table header bits entries.thestig
BUG=637119 Review-Url: https://codereview.chromium.org/2305443003
2016-09-01Make CPDF_ContentMark have a CPDF_ContentMarkData.tsepez
This one doesn't require an explict Emplace(), as the object seems to get constructed only as a side-effect of making a private copy. Review-Url: https://codereview.chromium.org/2298953002
2016-08-31Check first page number in CPDF_HintTables::ReadPageHintTable().thestig
BUG=642655 Review-Url: https://codereview.chromium.org/2298753003
2016-08-31Attempt to fix potential integer overflow in CFX_FaceCache::LoadGlyphPath().chromium/2846thestig
BUG=641333 Review-Url: https://codereview.chromium.org/2294183002
2016-08-31Use CheckedNumeric for strength calculation.dsinclair
Update the calculation of the outlines bold strength to use a CheckedNum instead of an int. BUG=chromium:639506 Review-Url: https://codereview.chromium.org/2296193002
2016-08-31Make CPDF_ColorState have a CFX_ColorStateData rather than inheritingtsepez
Review-Url: https://codereview.chromium.org/2294133002
2016-08-31Make CPDF_GraphState have a CPDF_GraphStateData instead of inheriting.tsepez
Get callers out of the copy-before-write business, and let the class manage it instead. Review-Url: https://codereview.chromium.org/2292363002
2016-08-31Use enum class for subtypes of CPDF_Annot.jaepark
Comparing CFX_ByteString for annotation subtypes is inefficient and error-prone. This CL uses enum class to compare annotation subtypes. Also, remove unused IPDFSDK_AnnotHandler::GetType() and FSDK_XFAWIDGET_TYPENAME. Review-Url: https://codereview.chromium.org/2295953002
2016-08-31Free the GifPlainText object when complete.dsinclair
We allocate the GifPlainText object on line ~685 inside GIF_D_STATUS_EXT_PTE. We cleanup the internal pointers in the gif_destroy_decompress() but we failed to cleanup the pointer itself. This CL frees the allocated pointer once the data is cleaned up. BUG=chromium:638499 Review-Url: https://codereview.chromium.org/2291143003
2016-08-30Clean up CPDF_CMap declarationchromium/2845npm
- Removed unused methods - Friendship with CPDF_PathManager is not needed - Protected may be changed to private Review-Url: https://codereview.chromium.org/2292023003
2016-08-30Make CPDF_TextState have a CPDF_TextStateData rather than inheriting one.tsepez
Review-Url: https://codereview.chromium.org/2287313004
2016-08-30Guard against overflow when calculating font weight.dsinclair
This CL uses the safe math libraries when calculating the font weight from the StemV value as very large values for StemV can cause the signed int to overflow. BUG=chromium:641418 Review-Url: https://codereview.chromium.org/2293633002