summaryrefslogtreecommitdiff
path: root/xfa/fgas/font/cfgas_fontmgr.cpp
AgeCommit message (Collapse)Author
2018-04-16Fix UAF in CFGAS_FontMgr::FindFontchromium/3398Ke Liu
Fix an use-after-free issue which was introduced by commit 53279b1dcabae4913f7f0a58e741942e82ab7d59. Bug: chromium:832589 Change-Id: Id7da791c3aa2d71d0a9e56d062069f41b7eb48d1 Reviewed-on: https://pdfium-review.googlesource.com/30570 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-03-06Rename IFX classes in core/fxge to Ifacechromium/3364Dan Sinclair
This CL renames IFX classes in core/fxge to Iface. Change-Id: I137167ddd4ff1563d8002d9501222c27183408cc Reviewed-on: https://pdfium-review.googlesource.com/27990 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-02-16Avoid 100 blank FX_FONTDESCRIPTOR entries.Tom Sepez
Change-Id: Ibaf53ee27eefc692ac4f002c3ab28b7738676b31 Reviewed-on: https://pdfium-review.googlesource.com/26991 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-02-16m_pEnumerator only ever has one value, indirection not needed.Tom Sepez
Change-Id: Ic1d63e8ef54a820b01d67dbf1dd6f6f72a06b77c Reviewed-on: https://pdfium-review.googlesource.com/26990 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-02-07Handle removed fonts correctly in GetFontByCodePageRyan Harrison
The existing code has a couple of issues that need to be addressed. First it assumes that for a hash, there will be an entry in the map and blindly calls the [] operator and takes the address of the result. If there isn't an entry for the hash then this will cause a crash. This has been converted to a call to find and returning nullptr, which is the fail result, if it cannot find an entry for the hash. The other issue is that it assumed that the first entry in the vector would be a valid pointer. When removing fonts from the vector, RemoveFont, first nulls out entries. Once all of the entries have been removed from a vector on subsequent calls to RemoveFont, then the vector is removed from the map. Thus the first entry in the vector might not be the correct value to return. This has been changed to a linear scan of the vector for a valid pointer. BUG=chromium:648177 Change-Id: Ife758636545f0d10fb726c243e3e0a5b7c1d1138 Reviewed-on: https://pdfium-review.googlesource.com/25930 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-01-31Remove handrolled search from GetCodePageFromCharsetRyan Harrison
BUG=pdfium:798 Change-Id: If89c162f8a6c15a8a0f4313fbf4713ee2fde5357 Reviewed-on: https://pdfium-review.googlesource.com/24719 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-12-07Add WARN_UNUSED_RESULT to ByteString::Format* methods.Henrique Nakashima
Change-Id: I0caba99cb8e99ea5af49d906b576f580275620bb Reviewed-on: https://pdfium-review.googlesource.com/20570 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2017-12-06Fix ps rendering.chromium/3287Henrique Nakashima
Also fix other occurrences that were missed. Bug:pdfium:947 Change-Id: Ic7e909ff9ce3abdf91e8e9ba108c84ad28b2fd65 Reviewed-on: https://pdfium-review.googlesource.com/20472 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2017-11-16Refactor CFGAS_FontMgr's Windows implementationNicolas Pena
This CL unifies a bit the public methods of CFGAS_FontMgr. It does so by replacing the multiple maps on the Windows implementation to a single map from hash to font. Also, cloning CFX_Fonts is avoided with the use of SetLogicalFontStyle. These Windows changes are just mimicking other OS's. As a side-effect, some members of CFX_Fonts are now owned so the raw pointers are replaced with unique_ptrs. Change-Id: I576d438572ccbe6c48f8f5cc434d66fc6adba372 Reviewed-on: https://pdfium-review.googlesource.com/18131 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2017-11-07Remove m_bFlagExact from CFX_SubstFontNicolas Pena
This CL removes the single use case from |m_bFlagExact|. This flag allows the PDF viewer to treat a substitute font with a matching name as if it was actually an embedded font, which is wrong. For all substitute fonts, it is important to follow the longer process of first obtaining the unicode from the charcode to then obtain the glyph in the substitute font that corresponds to that unicode. Bug: chromium:781785 Change-Id: Ie5958b43914e0e46334b89b7c2c55c02d0da0c11 Reviewed-on: https://pdfium-review.googlesource.com/17859 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2017-10-04Remove CFX_CRTFileAccessDan Sinclair
The CFX_CRTFileAccess class was only used in one place and only provided one method. That method was folded back into the caller and the class removed. Change-Id: I5e670474244a9ec037b6d099d67bd5091cac7ff4 Reviewed-on: https://pdfium-review.googlesource.com/15410 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-28Cleanup font definesDan Sinclair
Use methods to match font information; cleanup some font code. Change-Id: Ib99c1e466e56723cb5d264d49e1caf9bbbc0daed Reviewed-on: https://pdfium-review.googlesource.com/15072 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-28Cleanup font definesDan Sinclair
This CL removes duplicate defines between XFA and core. Several OR'd values have been coverted into individual booleans to make the code clearer. Change-Id: Ic32a71c711cffd9a0cf1136e5a22f0502e085c39 Reviewed-on: https://pdfium-review.googlesource.com/15071 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-27Move CFX_Font definition to cfx_font.hDan Sinclair
This CL moves the CFX_Font definition out of fx_font.h and into cfx_font.h to match the cfx_font.cpp implementation. Change-Id: Icc2fc7463fa4b9d0bec925e80b60a638136a83a1 Reviewed-on: https://pdfium-review.googlesource.com/14951 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2017-09-27Move static methods to anonymous namespaceDan Sinclair
This CL moves the static CFGAS_FontMgr methods to the anonymous namespace. Change-Id: I2835099ed9e503ee04daca3012a4ddd278255fdc Reviewed-on: https://pdfium-review.googlesource.com/14830 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2017-09-27Cleanup FX macrosDan Sinclair
This CL renames the FX_OS defines to have _OS_ in their names and drops the _DESKTOP suffix. The FXM defines have been changed to just FX. Change-Id: Iab172fba541713b5f6d14fb8098baf68e3364c74 Reviewed-on: https://pdfium-review.googlesource.com/14833 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-26Hide FX_HandleParentPathDan Sinclair
This CL moves FX_HandleParentPath to be a private inner class of CFX_FontSourceEnum_File. Change-Id: I5e2d16c4d78457a28e1833d0b937547019cdece6 Reviewed-on: https://pdfium-review.googlesource.com/14818 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-26Share public part of CFGAS_FontMgr declarationDan Sinclair
This CL moves the public part of the CFGAS_FontMgr declaration to be shared across all platforms. Change-Id: I92e587fe06611c92f72746477775802c2f3b8b57 Reviewed-on: https://pdfium-review.googlesource.com/14817 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-26Move font source into CFGAS_FontMgrDan Sinclair
This CL moves the font source into the font manager so it doesn't need to be stored by each caller (and removes the platform dependant code). The |EnumFonts| method is exposed on the CFGAS_FontMgr so the caller can clear the manager if the enumeration fails. Change-Id: Iecce3d2e09ff01152b7bb79a34fe2b728320da9c Reviewed-on: https://pdfium-review.googlesource.com/14816 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-26Remove font default paramsDan Sinclair
This CL removes some default parameters from the font code. Change-Id: If6f6e09c93474e1e8b7ffaae53eb37dd40c32fab Reviewed-on: https://pdfium-review.googlesource.com/14815 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-21Rename CFX_RetainPtr to RetainPtrDan Sinclair
This CL renames CFX_RetainPtr to RetainPtr and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: I8798a9f79cb0840d3f037e8d04937cedd742914e Reviewed-on: https://pdfium-review.googlesource.com/14616 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-18Convert string class namesRyan Harrison
Automated using git grep & sed. Replace StringC classes with StringView classes. Remove the CFX_ prefix and put string classes in fxcrt namespace. Change AsStringC() to AsStringView(). Rename tests from TEST(fxcrt, *String*Foo) to TEST(*String*, Foo). Couple of tests needed to have their names regularlized. BUG=pdfium:894 Change-Id: I7ca038685c8d803795f3ed02545124f7a224c83d Reviewed-on: https://pdfium-review.googlesource.com/14151 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-15Make static const char* arrays more const.Lei Zhang
Change-Id: I87b5e6cefe973b82b4868e56fc5285c95c53a12b Reviewed-on: https://pdfium-review.googlesource.com/12550 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-08-31Cleanup fx_basic_* filesDan Sinclair
Remove dead code, move code to namespaces where possible, cleanup some single use items. Change-Id: Ia734477ceb2105a1ed272463bd8220f1205a7ce9 Reviewed-on: https://pdfium-review.googlesource.com/12732 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-08-23Convert string Find methods to return an OptionalRyan Harrison
The Find and ReverseFind methods for WideString, WideStringC, ByteString, and ByteStringC have been converted from returning a raw FX_STRSIZE, to returning Optional<FX_STRSIZE>, so that success/failure can be indicated without using FX_STRNPOS. This allows for removing FX_STRNPOS and by association makes the conversion of FX_STRSIZE to size_t easier, since it forces checking the return value of Find to be explictly done as well as taking the error value out of the range of FX_STRSIZE. New Contains methods have been added for cases where the success or failure is all the call site to Find cared about, and the actual position was ignored. BUG=pdfium:828 Change-Id: Id827e508c8660affa68cc08a13d96121369364b7 Reviewed-on: https://pdfium-review.googlesource.com/11350 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-08-01Replace raw value for constant error value in string operationsRyan Harrison
Currently Find() and other methods that return a FX_STRSIZE return -1 to indicate error/failure. This means that there is a lot of magic numbers and magic checks floating around. The standard library for similar operations uses a npos constant. This CL implements FX_STRNPOS, and replaces usages of magic number checking. It also does some type cleanup along the way where it was obvious that FX_STRSIZE should be being used. Removing the magic numbers should make eventually changing FX_STRSIZE to be unsigned easier in the future. BUG=pdfium:828 Change-Id: I67e481e44cf2f75a1698afa8fbee4f375a74c490 Reviewed-on: https://pdfium-review.googlesource.com/9651 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-06-22Add a |gGeneralPartitionAllocator| and use it in the |FX_*Alloc| wrappers.chromium/3142chromium/3141chromium/3140chromium/3139Chris Palmer
BUG=pdfium:690 Change-Id: I922279e4bdc8b411f47f49798155e8f9118c1396 Reviewed-on: https://pdfium-review.googlesource.com/6552 Commit-Queue: Chris Palmer <palmer@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-04-20Convert IFX_MemoryStream to CFX_MemoryStreamDan Sinclair
The CFX_MemoryStream is the only implementation of IFX_MemoryStream. This CL removes the interfaces and uses CFX_MemoryStream directly. Change-Id: I2f43fa39e82dafa7673517d214ae15fd2d0df331 Reviewed-on: https://pdfium-review.googlesource.com/4391 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-04-20Cleanup the fx_extension code.Dan Sinclair
This CL cleans up the fx_extension file. The stream code was moved to fx_stream. IFX_FileAccess was removed and CFX_CRTFileAccess split to its own file. Code shuffled from header to cpp file. Change-Id: I700fdfcc9797cf4e8050cd9ba010ad8854feefbf Reviewed-on: https://pdfium-review.googlesource.com/4371 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-04-19Cleanup codepage and charset definitions.Dan Sinclair
This Cl cleans up the unused defines in fx_codepage.h. The FXFONT_CHARSET_ defines are replaced with fx_codepage defines, this moves fx_codepage into core instead of xfa only. Static asserts are added to verify the public/ charsets match the fx_codepage charsets. Change-Id: Ie2f749e093de60a9a6743128a1fb087912e4cc96 Reviewed-on: https://pdfium-review.googlesource.com/4316 Commit-Queue: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-04-19Move CFGAS_Stream to CFX_SeekableStreamProxyDan Sinclair
This CL moves the FGAS stream code into core/fxcrt and renames to CFX_SeekableStreamProxy. Change-Id: I6641fe0cca45a128ef3ec281b0b40f8d60296387 Reviewed-on: https://pdfium-review.googlesource.com/4311 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-04-18Codepage code into anonymouse namespaceDan Sinclair
This CL moves the FX_GetCodePageFromCharset method into cfgas_fontmgr anonymouse namespace. Change-Id: I1232341b8639328035f12aebfb7a65a4fc0ba08f Reviewed-on: https://pdfium-review.googlesource.com/4291 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-03Drop FXSYS_ from mem methodsDan Sinclair
This Cl drops the FXSYS_ from mem methods which are the same on all platforms. Bug: pdfium:694 Change-Id: I9d5ae905997dbaaec5aa0b2ae4c07358ed9c6236 Reviewed-on: https://pdfium-review.googlesource.com/3613 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-15Remove unused methods and data from fgas_codepageDan Sinclair
The methods are not called, so the data is not used. Removed. Change-Id: I29e904da2a000fd5173d2f5240ad377613db200a Reviewed-on: https://pdfium-review.googlesource.com/3050 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-15Replace FX_POSITION in GFGAS_FontMgr with boolDan Sinclair
Change-Id: Iddd99312aee6447c05be5633eead023a004e65e1 Reviewed-on: https://pdfium-review.googlesource.com/3034 Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-14Replace FX_CHAR and FX_WCHAR with underlying types.Dan Sinclair
Change-Id: I96e0a20d66b9184d22f64d8e4ce0dadd5a78c1e8 Reviewed-on: https://pdfium-review.googlesource.com/2967 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-02Use std::deque for CFX_FontDescriptorsTom Sepez
Change-Id: Ic6edc7740513075c2a738cc8897460af17bb0103 Reviewed-on: https://pdfium-review.googlesource.com/2895 Commit-Queue: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-01Fix font manager negation issueDan Sinclair
In https://codereview.chromium.org/2559903002 we refactored the font manager in XFA but got part of the negation wrong. Fixup logic. Change-Id: Idd51ff846fe64a56908ec26bf2798c1df8433611 Reviewed-on: https://pdfium-review.googlesource.com/2891 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-02-13Simplify FX_UTF8Encode variants.chromium/3012Tom Sepez
Doing so reveals places where there are needless copies and conversions. Change-Id: I24a868d40aa63836f4167eaf4541964049df7916 Reviewed-on: https://pdfium-review.googlesource.com/2555 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-01-10Remove more _LP* typedefs.tsepez
Code is much clearer when we use the actual types rather than this convention. Review-Url: https://codereview.chromium.org/2618993002
2017-01-09Tidy cfgas_fontmgr, remove custom sorting code.tsepez
Review-Url: https://codereview.chromium.org/2610813010
2017-01-06Remove CFX_MapPtrToPtr in xfa/fgas, part 2tsepez
Review-Url: https://codereview.chromium.org/2616623005
2017-01-05Properly ref-count CFGAS_GEFont with CFX_RetainPtr.tsepez
We worry about cyclical references, but no leaks found. Review-Url: https://codereview.chromium.org/2609423003
2016-12-08Replace CFX_WideStringArray with std::vectortsepez
Minimalist changes with the tidying of the code to use better loop iterators as a follow-up. Review-Url: https://codereview.chromium.org/2556963004
2016-12-07Replace CFX_ByteStringArray with std::vector.tsepez
Also convernt one nearby array to vector as well. Review-Url: https://codereview.chromium.org/2559903002
2016-12-07Properly ref count IFX_FileAccess.tsepez
Review-Url: https://codereview.chromium.org/2562563002
2016-12-07Refcount all the IFX_ stream classes all the time.tsepez
We can remove a lot of "bOwnsStream" logic in the process. Always pass these by const reference, in case the called method wants to hang on to the stream (one exception is where we stick a raw pointer into a void* slot in a context from another layer). Review-Url: https://codereview.chromium.org/2451493002
2016-12-02Tidy fx_stream.htsepez
Group related IFX_ classes. Move #defines to .cpp file that uses them. Replace loose function with static method. Review-Url: https://codereview.chromium.org/2548583004
2016-11-30Convert loose FX_Create* functions into static methodstsepez
Also remove a bool that is always false. Review-Url: https://codereview.chromium.org/2539203002
2016-11-21Clean up CFGAS_GEFontnpm
Removed some unused method, named files properly, cleaned up a bit. Review-Url: https://codereview.chromium.org/2524493002