Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: xfa/fxfa/parser/xfa_document_imp.cpp

Issue 1890563003: Simplify XFA event handling. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: address comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fxcrt/include/fx_ext.h" 7 #include "core/fxcrt/include/fx_ext.h"
8 #include "xfa/fxfa/app/xfa_ffnotify.h" 8 #include "xfa/fxfa/app/xfa_ffnotify.h"
9 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" 9 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
10 #include "xfa/fxfa/parser/xfa_basic_imp.h" 10 #include "xfa/fxfa/parser/xfa_basic_imp.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 CXFA_Node* pDestNodeParent, 305 CXFA_Node* pDestNodeParent,
306 CXFA_Node* pProtoNode) { 306 CXFA_Node* pProtoNode) {
307 CXFA_Node* pExistingNode = NULL; 307 CXFA_Node* pExistingNode = NULL;
308 for (CXFA_Node* pFormChild = 308 for (CXFA_Node* pFormChild =
309 pDestNodeParent->GetNodeItem(XFA_NODEITEM_FirstChild); 309 pDestNodeParent->GetNodeItem(XFA_NODEITEM_FirstChild);
310 pFormChild; 310 pFormChild;
311 pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { 311 pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
312 if (pFormChild->GetClassID() == pProtoNode->GetClassID() && 312 if (pFormChild->GetClassID() == pProtoNode->GetClassID() &&
313 pFormChild->GetNameHash() == pProtoNode->GetNameHash() && 313 pFormChild->GetNameHash() == pProtoNode->GetNameHash() &&
314 pFormChild->HasFlag(XFA_NODEFLAG_UnusedNode)) { 314 pFormChild->HasFlag(XFA_NODEFLAG_UnusedNode)) {
315 pFormChild->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); 315 pFormChild->ClearFlag(XFA_NODEFLAG_UnusedNode);
316 pExistingNode = pFormChild; 316 pExistingNode = pFormChild;
317 break; 317 break;
318 } 318 }
319 } 319 }
320 if (pExistingNode) { 320 if (pExistingNode) {
321 pExistingNode->SetTemplateNode(pProtoNode); 321 pExistingNode->SetTemplateNode(pProtoNode);
322 for (CXFA_Node* pTemplateChild = 322 for (CXFA_Node* pTemplateChild =
323 pProtoNode->GetNodeItem(XFA_NODEITEM_FirstChild); 323 pProtoNode->GetNodeItem(XFA_NODEITEM_FirstChild);
324 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( 324 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
325 XFA_NODEITEM_NextSibling)) { 325 XFA_NODEITEM_NextSibling)) {
326 XFA_ProtoMerge_MergeNodeRecurse(pDocument, pExistingNode, pTemplateChild); 326 XFA_ProtoMerge_MergeNodeRecurse(pDocument, pExistingNode, pTemplateChild);
327 } 327 }
328 return; 328 return;
329 } 329 }
330 CXFA_Node* pNewNode = pProtoNode->Clone(TRUE); 330 CXFA_Node* pNewNode = pProtoNode->Clone(TRUE);
331 pNewNode->SetTemplateNode(pProtoNode); 331 pNewNode->SetTemplateNode(pProtoNode);
332 pDestNodeParent->InsertChild(pNewNode, NULL); 332 pDestNodeParent->InsertChild(pNewNode, NULL);
333 } 333 }
334 static void XFA_ProtoMerge_MergeNode(CXFA_Document* pDocument, 334 static void XFA_ProtoMerge_MergeNode(CXFA_Document* pDocument,
335 CXFA_Node* pDestNode, 335 CXFA_Node* pDestNode,
336 CXFA_Node* pProtoNode) { 336 CXFA_Node* pProtoNode) {
337 { 337 {
338 CXFA_NodeIterator sIterator(pDestNode); 338 CXFA_NodeIterator sIterator(pDestNode);
339 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; 339 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
340 pNode = sIterator.MoveToNext()) { 340 pNode = sIterator.MoveToNext()) {
341 pNode->SetFlag(XFA_NODEFLAG_UnusedNode); 341 pNode->SetFlag(XFA_NODEFLAG_UnusedNode, true);
342 } 342 }
343 } 343 }
344 pDestNode->SetTemplateNode(pProtoNode); 344 pDestNode->SetTemplateNode(pProtoNode);
345 for (CXFA_Node* pTemplateChild = 345 for (CXFA_Node* pTemplateChild =
346 pProtoNode->GetNodeItem(XFA_NODEITEM_FirstChild); 346 pProtoNode->GetNodeItem(XFA_NODEITEM_FirstChild);
347 pTemplateChild; 347 pTemplateChild;
348 pTemplateChild = pTemplateChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { 348 pTemplateChild = pTemplateChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
349 XFA_ProtoMerge_MergeNodeRecurse(pDocument, pDestNode, pTemplateChild); 349 XFA_ProtoMerge_MergeNodeRecurse(pDocument, pDestNode, pTemplateChild);
350 } 350 }
351 { 351 {
352 CXFA_NodeIterator sIterator(pDestNode); 352 CXFA_NodeIterator sIterator(pDestNode);
353 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; 353 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
354 pNode = sIterator.MoveToNext()) { 354 pNode = sIterator.MoveToNext()) {
355 pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); 355 pNode->ClearFlag(XFA_NODEFLAG_UnusedNode);
356 } 356 }
357 } 357 }
358 } 358 }
359 void CXFA_Document::DoProtoMerge() { 359 void CXFA_Document::DoProtoMerge() {
360 CXFA_Node* pTemplateRoot = ToNode(GetXFAObject(XFA_HASHCODE_Template)); 360 CXFA_Node* pTemplateRoot = ToNode(GetXFAObject(XFA_HASHCODE_Template));
361 if (!pTemplateRoot) { 361 if (!pTemplateRoot) {
362 return; 362 return;
363 } 363 }
364 CFX_MapPtrTemplate<uint32_t, CXFA_Node*> mIDMap; 364 CFX_MapPtrTemplate<uint32_t, CXFA_Node*> mIDMap;
365 CXFA_NodeSet sUseNodes; 365 CXFA_NodeSet sUseNodes;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 pProtoNode)) { 432 pProtoNode)) {
433 continue; 433 continue;
434 } 434 }
435 } 435 }
436 if (!pProtoNode) { 436 if (!pProtoNode) {
437 continue; 437 continue;
438 } 438 }
439 XFA_ProtoMerge_MergeNode(this, pUseHrefNode, pProtoNode); 439 XFA_ProtoMerge_MergeNode(this, pUseHrefNode, pProtoNode);
440 } 440 }
441 } 441 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_document_datamerger_imp.cpp ('k') | xfa/fxfa/parser/xfa_layout_appadapter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698