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

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

Issue 1890563003: Simplify XFA event handling. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: remove CXFA_FFNotify::OnLayoutEvent, XFA_LAYOUTEVENT 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 "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" 7 #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h"
8 8
9 #include "xfa/fxfa/app/xfa_ffnotify.h" 9 #include "xfa/fxfa/app/xfa_ffnotify.h"
10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 static void XFA_SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem, 1500 static void XFA_SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem,
1501 CXFA_FFNotify* pNotify, 1501 CXFA_FFNotify* pNotify,
1502 CXFA_LayoutProcessor* pDocLayout) { 1502 CXFA_LayoutProcessor* pDocLayout) {
1503 CXFA_LayoutItem* pNextLayoutItem; 1503 CXFA_LayoutItem* pNextLayoutItem;
1504 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; 1504 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild;
1505 while (pCurLayoutItem) { 1505 while (pCurLayoutItem) {
1506 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; 1506 pNextLayoutItem = pCurLayoutItem->m_pNextSibling;
1507 if (pCurLayoutItem->m_pFirstChild) { 1507 if (pCurLayoutItem->m_pFirstChild) {
1508 XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); 1508 XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout);
1509 } 1509 }
1510 pNotify->OnLayoutEvent(pDocLayout, pCurLayoutItem, 1510 pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem);
1511 XFA_LAYOUTEVENT_ItemRemoving);
1512 delete pCurLayoutItem; 1511 delete pCurLayoutItem;
1513 pCurLayoutItem = pNextLayoutItem; 1512 pCurLayoutItem = pNextLayoutItem;
1514 } 1513 }
1515 } 1514 }
1516 void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) { 1515 void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) {
1517 CXFA_LayoutItem* pNextLayoutItem; 1516 CXFA_LayoutItem* pNextLayoutItem;
1518 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; 1517 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild;
1519 while (pCurLayoutItem) { 1518 while (pCurLayoutItem) {
1520 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; 1519 pNextLayoutItem = pCurLayoutItem->m_pNextSibling;
1521 if (pCurLayoutItem->IsContentLayoutItem()) { 1520 if (pCurLayoutItem->IsContentLayoutItem()) {
1522 uint32_t dwFlag = pCurLayoutItem->m_pFormNode->GetFlag(); 1521 uint32_t dwFlag = pCurLayoutItem->m_pFormNode->GetFlag();
1523 if (dwFlag & (XFA_NODEFLAG_HasRemoved)) { 1522 if (dwFlag & (XFA_NODEFLAG_HasRemoved)) {
1524 CXFA_FFNotify* pNotify = 1523 CXFA_FFNotify* pNotify =
1525 m_pTemplatePageSetRoot->GetDocument()->GetParser()->GetNotify(); 1524 m_pTemplatePageSetRoot->GetDocument()->GetParser()->GetNotify();
1526 CXFA_LayoutProcessor* pDocLayout = 1525 CXFA_LayoutProcessor* pDocLayout =
1527 m_pTemplatePageSetRoot->GetDocument()->GetDocLayout(); 1526 m_pTemplatePageSetRoot->GetDocument()->GetDocLayout();
1528 if (pCurLayoutItem->m_pFirstChild) { 1527 if (pCurLayoutItem->m_pFirstChild) {
1529 XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); 1528 XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout);
1530 } 1529 }
1531 pNotify->OnLayoutEvent(pDocLayout, pCurLayoutItem, 1530 pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem);
1532 XFA_LAYOUTEVENT_ItemRemoving);
1533 delete pCurLayoutItem; 1531 delete pCurLayoutItem;
1534 pCurLayoutItem = pNextLayoutItem; 1532 pCurLayoutItem = pNextLayoutItem;
1535 continue; 1533 continue;
1536 } 1534 }
1537 if (dwFlag & XFA_NODEFLAG_LayoutGeneratedNode) { 1535 if (dwFlag & XFA_NODEFLAG_LayoutGeneratedNode) {
1538 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> 1536 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode>
1539 sIterator(pCurLayoutItem->m_pFormNode); 1537 sIterator(pCurLayoutItem->m_pFormNode);
1540 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; 1538 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
1541 pNode = sIterator.MoveToNext()) { 1539 pNode = sIterator.MoveToNext()) {
1542 pNode->SetFlag(XFA_NODEFLAG_UnusedNode, TRUE, FALSE); 1540 pNode->SetFlag(XFA_NODEFLAG_UnusedNode, TRUE, FALSE);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( 1670 CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance(
1673 pDocument, pContainerItem->m_pFormNode->GetClassID(), 1671 pDocument, pContainerItem->m_pFormNode->GetClassID(),
1674 pContainerItem->m_pFormNode->GetNameHash(), pParentNode); 1672 pContainerItem->m_pFormNode->GetNameHash(), pParentNode);
1675 CXFA_ContainerIterator sIterator(pExistingNode); 1673 CXFA_ContainerIterator sIterator(pExistingNode);
1676 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; 1674 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
1677 pNode = sIterator.MoveToNext()) { 1675 pNode = sIterator.MoveToNext()) {
1678 if (pNode->GetClassID() != XFA_ELEMENT_ContentArea) { 1676 if (pNode->GetClassID() != XFA_ELEMENT_ContentArea) {
1679 CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( 1677 CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>(
1680 pNode->GetUserData(XFA_LAYOUTITEMKEY)); 1678 pNode->GetUserData(XFA_LAYOUTITEMKEY));
1681 if (pLayoutItem) { 1679 if (pLayoutItem) {
1682 pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, 1680 pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem);
1683 XFA_LAYOUTEVENT_ItemRemoving);
1684 delete pLayoutItem; 1681 delete pLayoutItem;
1685 } 1682 }
1686 } 1683 }
1687 } 1684 }
1688 if (pExistingNode) { 1685 if (pExistingNode) {
1689 pParentNode->RemoveChild(pExistingNode); 1686 pParentNode->RemoveChild(pExistingNode);
1690 } 1687 }
1691 } 1688 }
1692 pContainerItem->m_pOldSubform = pNewSubform; 1689 pContainerItem->m_pOldSubform = pNewSubform;
1693 } 1690 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 if (pNode->HasFlag(XFA_NODEFLAG_UnusedNode)) { 1730 if (pNode->HasFlag(XFA_NODEFLAG_UnusedNode)) {
1734 if (pNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode) { 1731 if (pNode->GetObjectType() == XFA_OBJECTTYPE_ContainerNode) {
1735 XFA_ELEMENT eCurId = pNode->GetClassID(); 1732 XFA_ELEMENT eCurId = pNode->GetClassID();
1736 if (eCurId == XFA_ELEMENT_PageArea || eCurId == XFA_ELEMENT_PageSet) { 1733 if (eCurId == XFA_ELEMENT_PageArea || eCurId == XFA_ELEMENT_PageSet) {
1737 CXFA_ContainerIterator iteChild(pNode); 1734 CXFA_ContainerIterator iteChild(pNode);
1738 CXFA_Node* pChildNode = iteChild.MoveToNext(); 1735 CXFA_Node* pChildNode = iteChild.MoveToNext();
1739 for (; pChildNode; pChildNode = iteChild.MoveToNext()) { 1736 for (; pChildNode; pChildNode = iteChild.MoveToNext()) {
1740 CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( 1737 CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>(
1741 pChildNode->GetUserData(XFA_LAYOUTITEMKEY)); 1738 pChildNode->GetUserData(XFA_LAYOUTITEMKEY));
1742 if (pLayoutItem) { 1739 if (pLayoutItem) {
1743 pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, 1740 pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem);
1744 XFA_LAYOUTEVENT_ItemRemoving);
1745 delete pLayoutItem; 1741 delete pLayoutItem;
1746 } 1742 }
1747 } 1743 }
1748 } else if (eCurId != XFA_ELEMENT_ContentArea) { 1744 } else if (eCurId != XFA_ELEMENT_ContentArea) {
1749 CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( 1745 CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>(
1750 pNode->GetUserData(XFA_LAYOUTITEMKEY)); 1746 pNode->GetUserData(XFA_LAYOUTITEMKEY));
1751 if (pLayoutItem) { 1747 if (pLayoutItem) {
1752 pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, 1748 pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem);
1753 XFA_LAYOUTEVENT_ItemRemoving);
1754 delete pLayoutItem; 1749 delete pLayoutItem;
1755 } 1750 }
1756 } 1751 }
1757 CXFA_Node* pNext = sIterator.SkipChildrenAndMoveToNext(); 1752 CXFA_Node* pNext = sIterator.SkipChildrenAndMoveToNext();
1758 pNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pNode); 1753 pNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pNode);
1759 pNode = pNext; 1754 pNode = pNext;
1760 } else { 1755 } else {
1761 pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE); 1756 pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE);
1762 pNode->SetFlag(XFA_NODEFLAG_Initialized); 1757 pNode->SetFlag(XFA_NODEFLAG_Initialized);
1763 pNode = sIterator.MoveToNext(); 1758 pNode = sIterator.MoveToNext();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence); 1802 pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence);
1808 if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible || 1803 if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible ||
1809 eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) { 1804 eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) {
1810 bVisibleItem = TRUE; 1805 bVisibleItem = TRUE;
1811 } 1806 }
1812 dwRelevantContainer = 1807 dwRelevantContainer =
1813 XFA_GetRelevant(pContainerItem->m_pFormNode, dwRelevant); 1808 XFA_GetRelevant(pContainerItem->m_pFormNode, dwRelevant);
1814 dwStatus = 1809 dwStatus =
1815 (bVisibleItem ? XFA_LAYOUTSTATUS_Visible : 0) | dwRelevantContainer; 1810 (bVisibleItem ? XFA_LAYOUTSTATUS_Visible : 0) | dwRelevantContainer;
1816 } 1811 }
1817 pNotify->OnLayoutEvent(pDocLayout, pContainerItem, XFA_LAYOUTEVENT_ItemAdded, 1812 pNotify->OnLayoutItemAdd(pDocLayout, pContainerItem, nPageIndex, dwStatus);
1818 (void*)(uintptr_t)nPageIndex,
1819 (void*)(uintptr_t)dwStatus);
1820 for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild; 1813 for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild;
1821 pChild = pChild->m_pNextSibling) { 1814 pChild = pChild->m_pNextSibling) {
1822 if (pChild->IsContentLayoutItem()) { 1815 if (pChild->IsContentLayoutItem()) {
1823 XFA_SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer, 1816 XFA_SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer,
1824 bVisibleItem, nPageIndex); 1817 bVisibleItem, nPageIndex);
1825 } 1818 }
1826 } 1819 }
1827 } 1820 }
1828 void CXFA_LayoutPageMgr::SyncLayoutData() { 1821 void CXFA_LayoutPageMgr::SyncLayoutData() {
1829 MergePageSetContents(); 1822 MergePageSetContents();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 } 1918 }
1926 pRootLayoutItem = m_pPageSetLayoutItemRoot; 1919 pRootLayoutItem = m_pPageSetLayoutItemRoot;
1927 CXFA_ContainerLayoutItem* pNextLayout = NULL; 1920 CXFA_ContainerLayoutItem* pNextLayout = NULL;
1928 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { 1921 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) {
1929 pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling; 1922 pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling;
1930 SaveLayoutItem(pRootLayoutItem); 1923 SaveLayoutItem(pRootLayoutItem);
1931 delete pRootLayoutItem; 1924 delete pRootLayoutItem;
1932 } 1925 }
1933 m_pPageSetLayoutItemRoot = NULL; 1926 m_pPageSetLayoutItemRoot = NULL;
1934 } 1927 }
OLDNEW
« xfa/fxfa/app/xfa_ffnotify.h ('K') | « xfa/fxfa/parser/xfa_layout_itemlayout.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698