summaryrefslogtreecommitdiff
path: root/core/fxcrt/xml/cfx_xmlelement.cpp
AgeCommit message (Collapse)Author
2018-10-18Remove some useless calls to the CFX_XMLNode ctor from subclasses.Lei Zhang
Also fix some nits: - Make member variable names consistent. - Make member variables const. - Make trivial getters return const-ref. Change-Id: Ibd34c9bc58ec0eed3edfc3a8ea39b533a41cad73 Reviewed-on: https://pdfium-review.googlesource.com/c/44151 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-10-12Remove more unnecessary includes and do IWYU as needed.Lei Zhang
Also move some implementations out of headers. Change-Id: I321fc26970c440d874b135bd28e8bc8156b9afee Reviewed-on: https://pdfium-review.googlesource.com/c/43890 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-09Do IWYU for ptr_util.h.Lei Zhang
Change-Id: Ib96a66eb47bea791f061e1d6da8aadad8037a99d Reviewed-on: https://pdfium-review.googlesource.com/c/43609 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-07-28Add ToXML{Instruction,Text,CharData}() checked conversion functionsTom Sepez
All usages were previously checked correctly, but this consolidates some code as well. Change-Id: I63711748b31b698a3f21f98fdb536db1e9e0b1cf Reviewed-on: https://pdfium-review.googlesource.com/39010 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-26Use moar ToXMLElement() in place of static_cast<>.Tom Sepez
Introduces checks in a few new places, but mainly just consolidates checking/casting logic. Change-Id: I634a03060d254db099972c6978249992367e146c Reviewed-on: https://pdfium-review.googlesource.com/38900 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-05-02Add a CFX_XMLDocument class.Dan Sinclair
This CL adds a CFX_XMLDocument to act as the XML node container. All nodes are now owned by the document and the document is returned by the CFX_XMLParser. Classes which parse XML files now store the document instead of the root node. BUG: chromium:835636 Change-Id: I1e07d6115cf14714911d6fd4c3fa920c94fd5faf Reviewed-on: https://pdfium-review.googlesource.com/31313 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-04-23Change CFX_XML Save to take a write streamDan Sinclair
This CL changes CFX_XML to use an IFX_SeekableWriteStream instead of the more generic IFX_SeekableStream. This is a reland of https://pdfium-review.googlesource.com/c/pdfium/+/30877 without pulling in the XML lifetime changes. Change-Id: I5091da6ad37715fff77f3f22d35ab0105f2bc3d0 Reviewed-on: https://pdfium-review.googlesource.com/31194 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-04-23Revert "Change CFX_XML Save to take a write stream"dsinclair
This reverts commit 9a3a7709103a872037dcea1f3cf0b7785a3da191. Reason for revert: Gerrit did not do what I expected.... Original change's description: > Change CFX_XML Save to take a write stream > > This CL changes CFX_XML to use an IFX_SeekableWriteStream instead of the more > generic IFX_SeekableStream. > > Change-Id: I6e4def380c43eca755d91ad5cb6146c2dfdaee10 > Reviewed-on: https://pdfium-review.googlesource.com/30877 > Commit-Queue: dsinclair <dsinclair@chromium.org> > Reviewed-by: Tom Sepez <tsepez@chromium.org> TBR=tsepez@chromium.org,dsinclair@chromium.org,hnakashima@chromium.org Change-Id: I137e53bf93285b88ade6832dedefca66e3b61e13 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://pdfium-review.googlesource.com/31211 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-04-23Change CFX_XML Save to take a write streamDan Sinclair
This CL changes CFX_XML to use an IFX_SeekableWriteStream instead of the more generic IFX_SeekableStream. Change-Id: I6e4def380c43eca755d91ad5cb6146c2dfdaee10 Reviewed-on: https://pdfium-review.googlesource.com/30877 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-04-19Fix UAF in CFX_XMLElement::SaveKe Liu
Use a ByteString object to store the returned value of WideString.UTF8Encode() instead of using a ByteStringView object to store the returned value of WideString.UTF8Encode().AsStringView(). Bug: chromium:834149 Change-Id: I8fa8dd7920140730c0417c188572d7b53e4ffb48 Reviewed-on: https://pdfium-review.googlesource.com/30890 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-04-17CFX_XML Cleanupdan sinclair
Cleanup formatting and unused variables in the CFX_XML classes. Change-Id: I1aff6317a3da38a141a071ba69c7893d0f669732 Reviewed-on: https://pdfium-review.googlesource.com/30730 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-17Add ownership to CFX_XMLNode childrendan sinclair
This CL sets the CFX_XML tree ownership. The pointers set into the tree must be unique_ptrs and the CFX_XMLNode children are set to be either unique_ptrs or UnownedPtrs. Change-Id: Ib0db495c81471e40f5b4533503f7bbe5a784fd77 Reviewed-on: https://pdfium-review.googlesource.com/30711 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-04-17Use an IFX_SeekableStream for XML savingdan sinclair
This CL converts the CFX_XML Save methods to take an IFX_SeekableStream instead of a CFX_SeekableStreamProxy. Change-Id: I6b3f6acc9f51e73b3c863b965b4dcdcbd25ba949 Reviewed-on: https://pdfium-review.googlesource.com/30850 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-04-16Merge CFX_XMLElement and CFX_XMLAttributeNodedan sinclair
CFX_XMLElement is the only subclass of CFX_XMLAttributeNode. This CL merges the two classes together. The {Set|Get}String method has been renamed to {Set|Get}Attribute to make it clearer what you're retrieving. Change-Id: I158c961d4d8c5f563d937a3e7a35321a33622562 Reviewed-on: https://pdfium-review.googlesource.com/30710 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-16Convert CXFA_XMLLocale to CFX_XMLdan sinclair
This CL converts CXFA_XMLLocale to use CFX_XML instead of CXML. Change-Id: I1db617a658548ae5979f2f38d72c5b3000998663 Reviewed-on: https://pdfium-review.googlesource.com/30693 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-02-13Add last_child to CFX_XMLNodeDan Sinclair
This CL adds the list_child_ member into CFX_XMLNode to keep it consistent with other tree's in the system. Change-Id: I2e64f11fb9c7df40dd3467edcce177fc492d2cd2 Reviewed-on: https://pdfium-review.googlesource.com/26670 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-02-13Split CFX_XMLNode::SaveXMLNode apartDan Sinclair
This CL removes the switch from SaveXMLNode and moves the required code into override methods in the child classes. The method is renamed from SaveXMLNode to just Save. Change-Id: I2011b80525e99635c573b4e0cf977e94f6b7cea6 Reviewed-on: https://pdfium-review.googlesource.com/26590 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-02-13Cleanup CFX_XMLNode pointersDan Sinclair
This CL cleans up hte CFX_XMLNode pointers. Each pointer has been renamed to make the usage clearer, the NodeItems method has been removed in favour of distinct accessors and the node pointers have been made private. Change-Id: I5459a77a0ae93b08741a0cd59266ef9c81ddad75 Reviewed-on: https://pdfium-review.googlesource.com/26550 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-02-13Cleanup CFX_XMLNode and friendschromium/3347Dan Sinclair
This CL removes unused methods from CFX_XMLNode, adds an AppendChild to handle the case of a -1 index to InsertChildNode, removes the InsertChildNode return value which is unused and cleans up various other things. Change-Id: I3a022e4dc2afffa6893ad11014034dd7ed301f13 Reviewed-on: https://pdfium-review.googlesource.com/26510 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@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-07Use std::move so this code compiles properly using gcc.chromium/3210chromium/3209Andrew Weintraub
R=dsinclair@chromium.org Bug: Change-Id: I34f9498f4e5942c5b10ab2848509de935882321d Reviewed-on: https://pdfium-review.googlesource.com/13470 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-08-30Move CFX_WideTextBuf out of fx_basicDan Sinclair
This CL moves CFX_WideTextBuf to its own files and updates includes as needed. Change-Id: Ibe66ecf3e66f8f01dd8e9eaf6b467588be86ad4f Reviewed-on: https://pdfium-review.googlesource.com/12413 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@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-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-19Move fde XML parser to coreDan Sinclair
This CL moves the XML parser from FDE into FXCRT and renames to CFX_ from CFDE_. Change-Id: I21a9590bf74daf5517df630d7e7a5de89da99ea4 Reviewed-on: https://pdfium-review.googlesource.com/4312 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>