summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp18
-rw-r--r--xfa/fxfa/parser/cxfa_layoutcontext.cpp11
-rw-r--r--xfa/fxfa/parser/cxfa_layoutcontext.h25
3 files changed, 30 insertions, 24 deletions
diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
index 2dfa956ee0..2ff9acd25a 100644
--- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
@@ -1143,18 +1143,17 @@ void CXFA_ItemLayoutProcessor::DoLayoutPositionedContainer(
if (iColSpan <= pdfium::CollectionSize<int32_t>(
*pContext->m_prgSpecifiedColumnWidths) -
iColIndex) {
- pContext->m_fCurColumnWidth = 0;
- pContext->m_bCurColumnWidthAvaiable = true;
+ pContext->m_fCurColumnWidth = 0.0f;
if (iColSpan == -1) {
iColSpan = pdfium::CollectionSize<int32_t>(
*pContext->m_prgSpecifiedColumnWidths);
}
for (int32_t i = 0; iColIndex + i < iColSpan; ++i) {
- pContext->m_fCurColumnWidth +=
+ pContext->m_fCurColumnWidth.value() +=
(*pContext->m_prgSpecifiedColumnWidths)[iColIndex + i];
}
- if (pContext->m_fCurColumnWidth == 0)
- pContext->m_bCurColumnWidthAvaiable = false;
+ if (pContext->m_fCurColumnWidth.value() == 0)
+ pContext->m_fCurColumnWidth.reset();
iColIndex += iColSpan >= 0 ? iColSpan : 0;
}
@@ -1273,8 +1272,7 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
for (; m_pCurChildNode; GotoNextContainerNode(
m_pCurChildNode, &m_nCurChildNodeStage, GetFormNode(), false)) {
- layoutContext.m_bCurColumnWidthAvaiable = false;
- layoutContext.m_fCurColumnWidth = 0;
+ layoutContext.m_fCurColumnWidth.reset();
if (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages::Container)
continue;
@@ -1605,9 +1603,9 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
CFX_SizeF containerSize = CalculateContainerSpecifiedSize(
GetFormNode(), &bContainerWidthAutoSize, &bContainerHeightAutoSize);
- if (pContext && pContext->m_bCurColumnWidthAvaiable) {
+ if (pContext && pContext->m_fCurColumnWidth.has_value()) {
+ containerSize.width = pContext->m_fCurColumnWidth.value();
bContainerWidthAutoSize = false;
- containerSize.width = pContext->m_fCurColumnWidth;
}
if (!bContainerHeightAutoSize)
containerSize.height -= m_fUsedSize;
@@ -2556,7 +2554,7 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::InsertFlowedItem(
pProcessor->GetFormNode()->GetIntact() == XFA_AttributeEnum::None) {
pFormNode = m_pPageMgr->QueryOverflow(pProcessor->GetFormNode());
if (!pFormNode && pLayoutContext && pLayoutContext->m_pOverflowProcessor) {
- pFormNode = pLayoutContext->m_pOverflowNode;
+ pFormNode = pLayoutContext->m_pOverflowNode.Get();
bUseInherited = true;
}
if (m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode,
diff --git a/xfa/fxfa/parser/cxfa_layoutcontext.cpp b/xfa/fxfa/parser/cxfa_layoutcontext.cpp
new file mode 100644
index 0000000000..24f0e8d803
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_layoutcontext.cpp
@@ -0,0 +1,11 @@
+// Copyright 2018 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_layoutcontext.h"
+
+CXFA_LayoutContext::CXFA_LayoutContext() = default;
+
+CXFA_LayoutContext::~CXFA_LayoutContext() = default;
diff --git a/xfa/fxfa/parser/cxfa_layoutcontext.h b/xfa/fxfa/parser/cxfa_layoutcontext.h
index a133ee19d9..9927d3e534 100644
--- a/xfa/fxfa/parser/cxfa_layoutcontext.h
+++ b/xfa/fxfa/parser/cxfa_layoutcontext.h
@@ -9,24 +9,21 @@
#include <vector>
-class CXFA_ItemLayoutProcess;
+#include "core/fxcrt/unowned_ptr.h"
+#include "third_party/base/optional.h"
+
+class CXFA_ItemLayoutProcessor;
class CXFA_Node;
class CXFA_LayoutContext {
public:
- CXFA_LayoutContext()
- : m_prgSpecifiedColumnWidths(nullptr),
- m_fCurColumnWidth(0),
- m_bCurColumnWidthAvaiable(false),
- m_pOverflowProcessor(nullptr),
- m_pOverflowNode(nullptr) {}
- ~CXFA_LayoutContext() {}
-
- std::vector<float>* m_prgSpecifiedColumnWidths;
- float m_fCurColumnWidth;
- bool m_bCurColumnWidthAvaiable;
- CXFA_ItemLayoutProcessor* m_pOverflowProcessor;
- CXFA_Node* m_pOverflowNode;
+ CXFA_LayoutContext();
+ ~CXFA_LayoutContext();
+
+ Optional<float> m_fCurColumnWidth;
+ UnownedPtr<std::vector<float>> m_prgSpecifiedColumnWidths;
+ UnownedPtr<CXFA_ItemLayoutProcessor> m_pOverflowProcessor;
+ UnownedPtr<CXFA_Node> m_pOverflowNode;
};
#endif // XFA_FXFA_PARSER_CXFA_LAYOUTCONTEXT_H_