summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_ffarc.cpp6
-rw-r--r--xfa/fxfa/cxfa_ffcheckbutton.cpp26
-rw-r--r--xfa/fxfa/cxfa_ffcheckbutton.h2
-rw-r--r--xfa/fxfa/cxfa_fffield.cpp45
-rw-r--r--xfa/fxfa/cxfa_fffield.h4
-rw-r--r--xfa/fxfa/cxfa_ffimage.cpp6
-rw-r--r--xfa/fxfa/cxfa_ffline.cpp6
-rw-r--r--xfa/fxfa/cxfa_ffpushbutton.cpp12
-rw-r--r--xfa/fxfa/cxfa_ffrectangle.cpp6
-rw-r--r--xfa/fxfa/cxfa_fftext.cpp23
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp15
-rw-r--r--xfa/fxfa/cxfa_ffwidget.h2
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp59
-rw-r--r--xfa/fxfa/cxfa_widgetacc.h1
-rw-r--r--xfa/fxfa/parser/cxfa_boxdata.cpp7
-rw-r--r--xfa/fxfa/parser/cxfa_boxdata.h4
-rw-r--r--xfa/fxfa/parser/cxfa_captiondata.cpp7
-rw-r--r--xfa/fxfa/parser/cxfa_captiondata.h4
-rw-r--r--xfa/fxfa/parser/cxfa_datadata.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_margin.cpp32
-rw-r--r--xfa/fxfa/parser/cxfa_margin.h10
-rw-r--r--xfa/fxfa/parser/cxfa_margindata.cpp41
-rw-r--r--xfa/fxfa/parser/cxfa_margindata.h30
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp25
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.h4
25 files changed, 174 insertions, 209 deletions
diff --git a/xfa/fxfa/cxfa_ffarc.cpp b/xfa/fxfa/cxfa_ffarc.cpp
index 7f9e938925..e670ba9785 100644
--- a/xfa/fxfa/cxfa_ffarc.cpp
+++ b/xfa/fxfa/cxfa_ffarc.cpp
@@ -23,9 +23,9 @@ void CXFA_FFArc::RenderWidget(CXFA_Graphics* pGS,
return;
CFX_RectF rtArc = GetRectWithoutRotate();
- CXFA_MarginData marginData = m_pDataAcc->GetMarginData();
- if (marginData.HasValidNode())
- XFA_RectWidthoutMargin(rtArc, marginData);
+ CXFA_Margin* margin = m_pDataAcc->GetMargin();
+ if (margin)
+ XFA_RectWidthoutMargin(rtArc, margin);
CFX_Matrix mtRotate = GetRotateMatrix();
mtRotate.Concat(matrix);
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.cpp b/xfa/fxfa/cxfa_ffcheckbutton.cpp
index 8dc2882504..00369784e1 100644
--- a/xfa/fxfa/cxfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp
@@ -89,10 +89,10 @@ bool CXFA_FFCheckButton::PerformLayout() {
CXFA_FFWidget::PerformLayout();
float fCheckSize = m_pDataAcc->GetCheckButtonSize();
- CXFA_MarginData marginData = m_pDataAcc->GetMarginData();
+ CXFA_Margin* margin = m_pDataAcc->GetMargin();
CFX_RectF rtWidget = GetRectWithoutRotate();
- if (marginData.HasValidNode())
- XFA_RectWidthoutMargin(rtWidget, marginData);
+ if (margin)
+ XFA_RectWidthoutMargin(rtWidget, margin);
XFA_AttributeEnum iCapPlacement = XFA_AttributeEnum::Unknown;
float fCapReserve = 0;
@@ -120,18 +120,18 @@ bool CXFA_FFCheckButton::PerformLayout() {
}
m_rtUI = rtWidget;
- CXFA_MarginData captionMarginData = captionData.GetMarginData();
+ CXFA_Margin* captionMargin = captionData.GetMargin();
switch (iCapPlacement) {
case XFA_AttributeEnum::Left: {
m_rtCaption.width = fCapReserve;
- CapLeftRightPlacement(captionMarginData);
+ CapLeftRightPlacement(captionMargin);
m_rtUI.width -= fCapReserve;
m_rtUI.left += fCapReserve;
break;
}
case XFA_AttributeEnum::Top: {
m_rtCaption.height = fCapReserve;
- XFA_RectWidthoutMargin(m_rtCaption, captionMarginData);
+ XFA_RectWidthoutMargin(m_rtCaption, captionMargin);
m_rtUI.height -= fCapReserve;
m_rtUI.top += fCapReserve;
break;
@@ -139,14 +139,14 @@ bool CXFA_FFCheckButton::PerformLayout() {
case XFA_AttributeEnum::Right: {
m_rtCaption.left = m_rtCaption.right() - fCapReserve;
m_rtCaption.width = fCapReserve;
- CapLeftRightPlacement(captionMarginData);
+ CapLeftRightPlacement(captionMargin);
m_rtUI.width -= fCapReserve;
break;
}
case XFA_AttributeEnum::Bottom: {
m_rtCaption.top = m_rtCaption.bottom() - fCapReserve;
m_rtCaption.height = fCapReserve;
- XFA_RectWidthoutMargin(m_rtCaption, captionMarginData);
+ XFA_RectWidthoutMargin(m_rtCaption, captionMargin);
m_rtUI.height -= fCapReserve;
break;
}
@@ -173,9 +173,9 @@ bool CXFA_FFCheckButton::PerformLayout() {
m_rtCheckBox = m_rtUI;
CXFA_BorderData borderUIData = m_pDataAcc->GetUIBorderData();
if (borderUIData.HasValidNode()) {
- CXFA_MarginData borderMarginData = borderUIData.GetMarginData();
- if (borderMarginData.HasValidNode())
- XFA_RectWidthoutMargin(m_rtUI, borderMarginData);
+ CXFA_Margin* borderMargin = borderUIData.GetMargin();
+ if (borderMargin)
+ XFA_RectWidthoutMargin(m_rtUI, borderMargin);
}
m_rtUI.Normalize();
@@ -188,8 +188,8 @@ bool CXFA_FFCheckButton::PerformLayout() {
}
void CXFA_FFCheckButton::CapLeftRightPlacement(
- const CXFA_MarginData& captionMarginData) {
- XFA_RectWidthoutMargin(m_rtCaption, captionMarginData);
+ const CXFA_Margin* captionMargin) {
+ XFA_RectWidthoutMargin(m_rtCaption, captionMargin);
if (m_rtCaption.height < 0)
m_rtCaption.top += m_rtCaption.height;
if (m_rtCaption.width < 0) {
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.h b/xfa/fxfa/cxfa_ffcheckbutton.h
index 36d97d78a9..56fd1c9d7b 100644
--- a/xfa/fxfa/cxfa_ffcheckbutton.h
+++ b/xfa/fxfa/cxfa_ffcheckbutton.h
@@ -35,7 +35,7 @@ class CXFA_FFCheckButton : public CXFA_FFField {
private:
bool CommitData() override;
bool IsDataChanged() override;
- void CapLeftRightPlacement(const CXFA_MarginData& captionMarginData);
+ void CapLeftRightPlacement(const CXFA_Margin* captionMargin);
void AddUIMargin(XFA_AttributeEnum iCapPlacement);
XFA_CHECKSTATE FWLState2XFAState();
diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp
index 827d38d8c3..75bd064e29 100644
--- a/xfa/fxfa/cxfa_fffield.cpp
+++ b/xfa/fxfa/cxfa_fffield.cpp
@@ -23,6 +23,7 @@
#include "xfa/fxfa/cxfa_fwltheme.h"
#include "xfa/fxfa/cxfa_textlayout.h"
#include "xfa/fxfa/parser/cxfa_calculate.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_script.h"
#include "xfa/fxgraphics/cxfa_gecolor.h"
@@ -168,13 +169,13 @@ bool CXFA_FFField::PerformLayout() {
void CXFA_FFField::CapPlacement() {
CFX_RectF rtWidget = GetRectWithoutRotate();
- CXFA_MarginData marginData = m_pDataAcc->GetMarginData();
- if (marginData.HasValidNode()) {
+ CXFA_Margin* margin = m_pDataAcc->GetMargin();
+ if (margin) {
CXFA_LayoutItem* pItem = this;
- float fLeftInset = marginData.GetLeftInset();
- float fRightInset = marginData.GetRightInset();
- float fTopInset = marginData.GetTopInset();
- float fBottomInset = marginData.GetBottomInset();
+ float fLeftInset = margin->GetLeftInset();
+ float fRightInset = margin->GetRightInset();
+ float fTopInset = margin->GetTopInset();
+ float fBottomInset = margin->GetBottomInset();
if (!pItem->GetPrev() && !pItem->GetNext()) {
rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset);
} else {
@@ -209,7 +210,7 @@ void CXFA_FFField::CapPlacement() {
m_rtCaption.height += pItem->GetRect(false).Height();
pItem = pItem->GetNext();
}
- XFA_RectWidthoutMargin(m_rtCaption, marginData);
+ XFA_RectWidthoutMargin(m_rtCaption, margin);
}
CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout();
@@ -231,16 +232,14 @@ void CXFA_FFField::CapPlacement() {
switch (iCapPlacement) {
case XFA_AttributeEnum::Left: {
m_rtCaption.width = fCapReserve;
- CapLeftRightPlacement(captionData.GetMarginData(), rtWidget,
- iCapPlacement);
+ CapLeftRightPlacement(captionData.GetMargin(), rtWidget, iCapPlacement);
m_rtUI.width -= fCapReserve;
m_rtUI.left += fCapReserve;
break;
}
case XFA_AttributeEnum::Top: {
m_rtCaption.height = fCapReserve;
- CapTopBottomPlacement(captionData.GetMarginData(), rtWidget,
- iCapPlacement);
+ CapTopBottomPlacement(captionData.GetMargin(), rtWidget, iCapPlacement);
m_rtUI.top += fCapReserve;
m_rtUI.height -= fCapReserve;
break;
@@ -248,16 +247,14 @@ void CXFA_FFField::CapPlacement() {
case XFA_AttributeEnum::Right: {
m_rtCaption.left = m_rtCaption.right() - fCapReserve;
m_rtCaption.width = fCapReserve;
- CapLeftRightPlacement(captionData.GetMarginData(), rtWidget,
- iCapPlacement);
+ CapLeftRightPlacement(captionData.GetMargin(), rtWidget, iCapPlacement);
m_rtUI.width -= fCapReserve;
break;
}
case XFA_AttributeEnum::Bottom: {
m_rtCaption.top = m_rtCaption.bottom() - fCapReserve;
m_rtCaption.height = fCapReserve;
- CapTopBottomPlacement(captionData.GetMarginData(), rtWidget,
- iCapPlacement);
+ CapTopBottomPlacement(captionData.GetMargin(), rtWidget, iCapPlacement);
m_rtUI.height -= fCapReserve;
break;
}
@@ -269,20 +266,20 @@ void CXFA_FFField::CapPlacement() {
CXFA_BorderData borderUIData = m_pDataAcc->GetUIBorderData();
if (borderUIData.HasValidNode()) {
- CXFA_MarginData borderMarginData = borderUIData.GetMarginData();
- if (borderMarginData.HasValidNode())
- XFA_RectWidthoutMargin(m_rtUI, borderMarginData);
+ CXFA_Margin* borderMargin = borderUIData.GetMargin();
+ if (borderMargin)
+ XFA_RectWidthoutMargin(m_rtUI, borderMargin);
}
m_rtUI.Normalize();
}
-void CXFA_FFField::CapTopBottomPlacement(const CXFA_MarginData& marginData,
+void CXFA_FFField::CapTopBottomPlacement(const CXFA_Margin* margin,
const CFX_RectF& rtWidget,
XFA_AttributeEnum iCapPlacement) {
CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin();
m_rtCaption.left += rtUIMargin.left;
- if (marginData.HasValidNode()) {
- XFA_RectWidthoutMargin(m_rtCaption, marginData);
+ if (margin) {
+ XFA_RectWidthoutMargin(m_rtCaption, margin);
if (m_rtCaption.height < 0)
m_rtCaption.top += m_rtCaption.height;
}
@@ -302,14 +299,14 @@ void CXFA_FFField::CapTopBottomPlacement(const CXFA_MarginData& marginData,
}
}
-void CXFA_FFField::CapLeftRightPlacement(const CXFA_MarginData& marginData,
+void CXFA_FFField::CapLeftRightPlacement(const CXFA_Margin* margin,
const CFX_RectF& rtWidget,
XFA_AttributeEnum iCapPlacement) {
CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin();
m_rtCaption.top += rtUIMargin.top;
m_rtCaption.height -= rtUIMargin.top;
- if (marginData.HasValidNode()) {
- XFA_RectWidthoutMargin(m_rtCaption, marginData);
+ if (margin) {
+ XFA_RectWidthoutMargin(m_rtCaption, margin);
if (m_rtCaption.height < 0)
m_rtCaption.top += m_rtCaption.height;
}
diff --git a/xfa/fxfa/cxfa_fffield.h b/xfa/fxfa/cxfa_fffield.h
index b566fe970d..f6051275d2 100644
--- a/xfa/fxfa/cxfa_fffield.h
+++ b/xfa/fxfa/cxfa_fffield.h
@@ -83,10 +83,10 @@ class CXFA_FFField : public CXFA_FFWidget, public IFWL_WidgetDelegate {
void DrawFocus(CXFA_Graphics* pGS, CFX_Matrix* pMatrix);
void TranslateFWLMessage(CFWL_Message* pMessage);
void CapPlacement();
- void CapTopBottomPlacement(const CXFA_MarginData& marginData,
+ void CapTopBottomPlacement(const CXFA_Margin* margin,
const CFX_RectF& rtWidget,
XFA_AttributeEnum iCapPlacement);
- void CapLeftRightPlacement(const CXFA_MarginData& marginData,
+ void CapLeftRightPlacement(const CXFA_Margin* margin,
const CFX_RectF& rtWidget,
XFA_AttributeEnum iCapPlacement);
void SetEditScrollOffset();
diff --git a/xfa/fxfa/cxfa_ffimage.cpp b/xfa/fxfa/cxfa_ffimage.cpp
index 864d34e101..c37234c686 100644
--- a/xfa/fxfa/cxfa_ffimage.cpp
+++ b/xfa/fxfa/cxfa_ffimage.cpp
@@ -51,9 +51,9 @@ void CXFA_FFImage::RenderWidget(CXFA_Graphics* pGS,
return;
CFX_RectF rtImage = GetRectWithoutRotate();
- CXFA_MarginData marginData = m_pDataAcc->GetMarginData();
- if (marginData.HasValidNode())
- XFA_RectWidthoutMargin(rtImage, marginData);
+ CXFA_Margin* margin = m_pDataAcc->GetMargin();
+ if (margin)
+ XFA_RectWidthoutMargin(rtImage, margin);
XFA_AttributeEnum iHorzAlign = XFA_AttributeEnum::Left;
XFA_AttributeEnum iVertAlign = XFA_AttributeEnum::Top;
diff --git a/xfa/fxfa/cxfa_ffline.cpp b/xfa/fxfa/cxfa_ffline.cpp
index fb2c98a1a9..bbe928f91a 100644
--- a/xfa/fxfa/cxfa_ffline.cpp
+++ b/xfa/fxfa/cxfa_ffline.cpp
@@ -109,9 +109,9 @@ void CXFA_FFLine::RenderWidget(CXFA_Graphics* pGS,
mtRotate.Concat(matrix);
CFX_RectF rtLine = GetRectWithoutRotate();
- CXFA_MarginData marginData = m_pDataAcc->GetMarginData();
- if (marginData.HasValidNode())
- XFA_RectWidthoutMargin(rtLine, marginData);
+ CXFA_Margin* margin = m_pDataAcc->GetMargin();
+ if (margin)
+ XFA_RectWidthoutMargin(rtLine, margin);
GetRectFromHand(rtLine, lineData.GetHand(), fLineWidth);
CXFA_GEPath linePath;
diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp
index 615c8ae16c..914b350767 100644
--- a/xfa/fxfa/cxfa_ffpushbutton.cpp
+++ b/xfa/fxfa/cxfa_ffpushbutton.cpp
@@ -97,15 +97,15 @@ bool CXFA_FFPushButton::PerformLayout() {
CFX_RectF rtWidget = GetRectWithoutRotate();
m_rtUI = rtWidget;
- CXFA_MarginData marginData = m_pDataAcc->GetMarginData();
- if (marginData.HasValidNode())
- XFA_RectWidthoutMargin(rtWidget, marginData);
+ CXFA_Margin* margin = m_pDataAcc->GetMargin();
+ if (margin)
+ XFA_RectWidthoutMargin(rtWidget, margin);
CXFA_CaptionData captionData = m_pDataAcc->GetCaptionData();
m_rtCaption = rtWidget;
- CXFA_MarginData captionMarginData = captionData.GetMarginData();
- if (captionMarginData.HasValidNode())
- XFA_RectWidthoutMargin(m_rtCaption, captionMarginData);
+ CXFA_Margin* captionMargin = captionData.GetMargin();
+ if (captionMargin)
+ XFA_RectWidthoutMargin(m_rtCaption, captionMargin);
LayoutHighlightCaption();
SetFWLRect();
diff --git a/xfa/fxfa/cxfa_ffrectangle.cpp b/xfa/fxfa/cxfa_ffrectangle.cpp
index 063a9e9865..080488418d 100644
--- a/xfa/fxfa/cxfa_ffrectangle.cpp
+++ b/xfa/fxfa/cxfa_ffrectangle.cpp
@@ -24,9 +24,9 @@ void CXFA_FFRectangle::RenderWidget(CXFA_Graphics* pGS,
return;
CFX_RectF rect = GetRectWithoutRotate();
- CXFA_MarginData marginData = m_pDataAcc->GetMarginData();
- if (marginData.HasValidNode())
- XFA_RectWidthoutMargin(rect, marginData);
+ CXFA_Margin* margin = m_pDataAcc->GetMargin();
+ if (margin)
+ XFA_RectWidthoutMargin(rect, margin);
CFX_Matrix mtRotate = GetRotateMatrix();
mtRotate.Concat(matrix);
diff --git a/xfa/fxfa/cxfa_fftext.cpp b/xfa/fxfa/cxfa_fftext.cpp
index 606c22e130..46a58c24c9 100644
--- a/xfa/fxfa/cxfa_fftext.cpp
+++ b/xfa/fxfa/cxfa_fftext.cpp
@@ -17,6 +17,7 @@
#include "xfa/fxfa/cxfa_pieceline.h"
#include "xfa/fxfa/cxfa_textlayout.h"
#include "xfa/fxfa/cxfa_textpiece.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxgraphics/cxfa_graphics.h"
CXFA_FFText::CXFA_FFText(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {}
@@ -40,21 +41,21 @@ void CXFA_FFText::RenderWidget(CXFA_Graphics* pGS,
CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice();
CFX_RectF rtText = GetRectWithoutRotate();
- CXFA_MarginData marginData = m_pDataAcc->GetMarginData();
- if (marginData.HasValidNode()) {
+ CXFA_Margin* margin = m_pDataAcc->GetMargin();
+ if (margin) {
CXFA_LayoutItem* pItem = this;
if (!pItem->GetPrev() && !pItem->GetNext()) {
- XFA_RectWidthoutMargin(rtText, marginData);
+ XFA_RectWidthoutMargin(rtText, margin);
} else {
float fTopInset = 0;
float fBottomInset = 0;
if (!pItem->GetPrev())
- fTopInset = marginData.GetTopInset();
+ fTopInset = margin->GetTopInset();
else if (!pItem->GetNext())
- fBottomInset = marginData.GetBottomInset();
+ fBottomInset = margin->GetBottomInset();
- rtText.Deflate(marginData.GetLeftInset(), fTopInset,
- marginData.GetRightInset(), fBottomInset);
+ rtText.Deflate(margin->GetLeftInset(), fTopInset, margin->GetRightInset(),
+ fBottomInset);
}
}
@@ -85,12 +86,12 @@ bool CXFA_FFText::PerformLayout() {
pItem = pItem->GetFirst();
while (pItem) {
CFX_RectF rtText = pItem->GetRect(false);
- CXFA_MarginData marginData = m_pDataAcc->GetMarginData();
- if (marginData.HasValidNode()) {
+ CXFA_Margin* margin = m_pDataAcc->GetMargin();
+ if (margin) {
if (!pItem->GetPrev())
- rtText.height -= marginData.GetTopInset();
+ rtText.height -= margin->GetTopInset();
else if (!pItem->GetNext())
- rtText.height -= marginData.GetBottomInset();
+ rtText.height -= margin->GetBottomInset();
}
pTextLayout->ItemBlocks(rtText, pItem->GetIndex());
pItem = pItem->GetNext();
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index fdb10a34f2..9367301175 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -31,6 +31,7 @@
#include "xfa/fxfa/cxfa_textlayout.h"
#include "xfa/fxfa/cxfa_widgetacc.h"
#include "xfa/fxfa/parser/cxfa_cornerdata.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxgraphics/cxfa_gecolor.h"
#include "xfa/fxgraphics/cxfa_gepath.h"
@@ -989,9 +990,9 @@ void CXFA_FFWidget::RenderWidget(CXFA_Graphics* pGS,
return;
CFX_RectF rtBorder = GetRectWithoutRotate();
- CXFA_MarginData marginData = borderData.GetMarginData();
- if (marginData.HasValidNode())
- XFA_RectWidthoutMargin(rtBorder, marginData);
+ CXFA_Margin* margin = borderData.GetMargin();
+ if (margin)
+ XFA_RectWidthoutMargin(rtBorder, margin);
rtBorder.Normalize();
DrawBorder(pGS, borderData, rtBorder, matrix);
@@ -2016,13 +2017,13 @@ RetainPtr<CFX_DIBitmap> XFA_LoadImageFromBuffer(
}
void XFA_RectWidthoutMargin(CFX_RectF& rt,
- const CXFA_MarginData& marginData,
+ const CXFA_Margin* margin,
bool bUI) {
- if (!marginData.HasValidNode())
+ if (!margin)
return;
- rt.Deflate(marginData.GetLeftInset(), marginData.GetTopInset(),
- marginData.GetRightInset(), marginData.GetBottomInset());
+ rt.Deflate(margin->GetLeftInset(), margin->GetTopInset(),
+ margin->GetRightInset(), margin->GetBottomInset());
}
CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem) {
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index a258e02e38..ac3d985094 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -63,7 +63,7 @@ RetainPtr<CFX_DIBitmap> XFA_LoadImageFromBuffer(
FXCODEC_IMAGE_TYPE XFA_GetImageType(const WideString& wsType);
char* XFA_Base64Encode(const uint8_t* buf, int32_t buf_len);
void XFA_RectWidthoutMargin(CFX_RectF& rt,
- const CXFA_MarginData& marginData,
+ const CXFA_Margin* margin,
bool bUI = false);
CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem);
bool XFA_IsCreateWidget(XFA_Element iType);
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index dcf621f442..ec33159055 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -25,6 +25,7 @@
#include "xfa/fxfa/parser/cxfa_items.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_localevalue.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_para.h"
#include "xfa/fxfa/parser/cxfa_script.h"
@@ -725,12 +726,12 @@ void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) {
}
}
- CXFA_MarginData captionMarginData = captionData.GetMarginData();
- if (captionMarginData.HasValidNode()) {
- float fLeftInset = captionMarginData.GetLeftInset();
- float fTopInset = captionMarginData.GetTopInset();
- float fRightInset = captionMarginData.GetRightInset();
- float fBottomInset = captionMarginData.GetBottomInset();
+ CXFA_Margin* captionMargin = captionData.GetMargin();
+ if (captionMargin) {
+ float fLeftInset = captionMargin->GetLeftInset();
+ float fTopInset = captionMargin->GetTopInset();
+ float fRightInset = captionMargin->GetRightInset();
+ float fBottomInset = captionMargin->GetBottomInset();
if (bReserveExit) {
bVert ? (szCap.width += fLeftInset + fRightInset)
: (szCap.height += fTopInset + fBottomInset);
@@ -768,10 +769,10 @@ bool CXFA_WidgetAcc::CalculateFieldAutoSize(CFX_SizeF& size) {
}
bool CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) {
- CXFA_MarginData marginData = GetMarginData();
- if (marginData.HasValidNode()) {
- size.width += marginData.GetLeftInset() + marginData.GetRightInset();
- size.height += marginData.GetTopInset() + marginData.GetBottomInset();
+ CXFA_Margin* margin = GetMargin();
+ if (margin) {
+ size.width += margin->GetLeftInset() + margin->GetRightInset();
+ size.height += margin->GetTopInset() + margin->GetBottomInset();
}
CXFA_Para* para = GetPara();
@@ -860,9 +861,9 @@ bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) {
}
CFX_RectF rtUIMargin = GetUIMargin();
size.width -= rtUIMargin.left + rtUIMargin.width;
- CXFA_MarginData marginData = GetMarginData();
- if (marginData.HasValidNode())
- size.width -= marginData.GetLeftInset() + marginData.GetRightInset();
+ CXFA_Margin* margin = GetMargin();
+ if (margin)
+ size.width -= margin->GetLeftInset() + margin->GetRightInset();
CalculateTextContentSize(size);
size.height += rtUIMargin.top + rtUIMargin.height;
@@ -1005,9 +1006,9 @@ void CXFA_WidgetAcc::LoadText() {
}
float CXFA_WidgetAcc::CalculateWidgetAutoWidth(float fWidthCalc) {
- CXFA_MarginData marginData = GetMarginData();
- if (marginData.HasValidNode())
- fWidthCalc += marginData.GetLeftInset() + marginData.GetRightInset();
+ CXFA_Margin* margin = GetMargin();
+ if (margin)
+ fWidthCalc += margin->GetLeftInset() + margin->GetRightInset();
pdfium::Optional<float> min = TryMinWidth();
if (min)
@@ -1021,16 +1022,16 @@ float CXFA_WidgetAcc::CalculateWidgetAutoWidth(float fWidthCalc) {
}
float CXFA_WidgetAcc::GetWidthWithoutMargin(float fWidthCalc) {
- CXFA_MarginData marginData = GetMarginData();
- if (marginData.HasValidNode())
- fWidthCalc -= marginData.GetLeftInset() + marginData.GetRightInset();
+ CXFA_Margin* margin = GetMargin();
+ if (margin)
+ fWidthCalc -= margin->GetLeftInset() + margin->GetRightInset();
return fWidthCalc;
}
float CXFA_WidgetAcc::CalculateWidgetAutoHeight(float fHeightCalc) {
- CXFA_MarginData marginData = GetMarginData();
- if (marginData.HasValidNode())
- fHeightCalc += marginData.GetTopInset() + marginData.GetBottomInset();
+ CXFA_Margin* margin = GetMargin();
+ if (margin)
+ fHeightCalc += margin->GetTopInset() + margin->GetBottomInset();
pdfium::Optional<float> min = TryMinHeight();
if (min)
@@ -1044,9 +1045,9 @@ float CXFA_WidgetAcc::CalculateWidgetAutoHeight(float fHeightCalc) {
}
float CXFA_WidgetAcc::GetHeightWithoutMargin(float fHeightCalc) {
- CXFA_MarginData marginData = GetMarginData();
- if (marginData.HasValidNode())
- fHeightCalc -= marginData.GetTopInset() + marginData.GetBottomInset();
+ CXFA_Margin* margin = GetMargin();
+ if (margin)
+ fHeightCalc -= margin->GetTopInset() + margin->GetBottomInset();
return fHeightCalc;
}
@@ -1149,10 +1150,10 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) {
float fTopInset = 0;
float fBottomInset = 0;
if (iBlockIndex == 0) {
- CXFA_MarginData marginData = GetMarginData();
- if (marginData.HasValidNode()) {
- fTopInset = marginData.GetTopInset();
- fBottomInset = marginData.GetBottomInset();
+ CXFA_Margin* margin = GetMargin();
+ if (margin) {
+ fTopInset = margin->GetTopInset();
+ fBottomInset = margin->GetBottomInset();
}
CFX_RectF rtUIMargin = GetUIMargin();
diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h
index e193bd2069..35bed64db1 100644
--- a/xfa/fxfa/cxfa_widgetacc.h
+++ b/xfa/fxfa/cxfa_widgetacc.h
@@ -17,7 +17,6 @@
#include "xfa/fxfa/parser/cxfa_boxdata.h"
#include "xfa/fxfa/parser/cxfa_eventdata.h"
#include "xfa/fxfa/parser/cxfa_imagedata.h"
-#include "xfa/fxfa/parser/cxfa_margindata.h"
#include "xfa/fxfa/parser/cxfa_widgetdata.h"
class CFGAS_GEFont;
diff --git a/xfa/fxfa/parser/cxfa_boxdata.cpp b/xfa/fxfa/parser/cxfa_boxdata.cpp
index 6e27c71e56..31fefbf93d 100644
--- a/xfa/fxfa/parser/cxfa_boxdata.cpp
+++ b/xfa/fxfa/parser/cxfa_boxdata.cpp
@@ -139,10 +139,9 @@ CXFA_FillData CXFA_BoxData::GetFillData(bool bModified) const {
return CXFA_FillData(pFillNode);
}
-CXFA_MarginData CXFA_BoxData::GetMarginData() const {
- return CXFA_MarginData(
- m_pNode ? m_pNode->GetChild<CXFA_Margin>(0, XFA_Element::Margin, false)
- : nullptr);
+CXFA_Margin* CXFA_BoxData::GetMargin() const {
+ return m_pNode ? m_pNode->GetChild<CXFA_Margin>(0, XFA_Element::Margin, false)
+ : nullptr;
}
std::tuple<XFA_AttributeEnum, bool, float> CXFA_BoxData::Get3DStyle() const {
diff --git a/xfa/fxfa/parser/cxfa_boxdata.h b/xfa/fxfa/parser/cxfa_boxdata.h
index 38a7faa38c..c44065f67e 100644
--- a/xfa/fxfa/parser/cxfa_boxdata.h
+++ b/xfa/fxfa/parser/cxfa_boxdata.h
@@ -14,8 +14,8 @@
#include "xfa/fxfa/parser/cxfa_datadata.h"
#include "xfa/fxfa/parser/cxfa_edgedata.h"
#include "xfa/fxfa/parser/cxfa_filldata.h"
-#include "xfa/fxfa/parser/cxfa_margindata.h"
+class CXFA_Margin;
class CXFA_Node;
class CXFA_BoxData : public CXFA_DataData {
@@ -32,7 +32,7 @@ class CXFA_BoxData : public CXFA_DataData {
int32_t CountEdges() const;
CXFA_EdgeData GetEdgeData(int32_t nIndex) const;
CXFA_FillData GetFillData(bool bModified) const;
- CXFA_MarginData GetMarginData() const;
+ CXFA_Margin* GetMargin() const;
std::vector<CXFA_StrokeData> GetStrokes() const;
diff --git a/xfa/fxfa/parser/cxfa_captiondata.cpp b/xfa/fxfa/parser/cxfa_captiondata.cpp
index 59dbb2b008..276d10c354 100644
--- a/xfa/fxfa/parser/cxfa_captiondata.cpp
+++ b/xfa/fxfa/parser/cxfa_captiondata.cpp
@@ -39,10 +39,9 @@ float CXFA_CaptionData::GetReserve() const {
.ToUnit(XFA_Unit::Pt);
}
-CXFA_MarginData CXFA_CaptionData::GetMarginData() const {
- return CXFA_MarginData(
- m_pNode ? m_pNode->GetChild<CXFA_Margin>(0, XFA_Element::Margin, false)
- : nullptr);
+CXFA_Margin* CXFA_CaptionData::GetMargin() const {
+ return m_pNode ? m_pNode->GetChild<CXFA_Margin>(0, XFA_Element::Margin, false)
+ : nullptr;
}
CXFA_FontData CXFA_CaptionData::GetFontData() const {
diff --git a/xfa/fxfa/parser/cxfa_captiondata.h b/xfa/fxfa/parser/cxfa_captiondata.h
index 119c34e4b1..4b526b6754 100644
--- a/xfa/fxfa/parser/cxfa_captiondata.h
+++ b/xfa/fxfa/parser/cxfa_captiondata.h
@@ -9,8 +9,8 @@
#include "xfa/fxfa/parser/cxfa_datadata.h"
#include "xfa/fxfa/parser/cxfa_fontdata.h"
-#include "xfa/fxfa/parser/cxfa_margindata.h"
+class CXFA_Margin;
class CXFA_Node;
class CXFA_Value;
@@ -22,7 +22,7 @@ class CXFA_CaptionData : public CXFA_DataData {
bool IsHidden() const;
XFA_AttributeEnum GetPlacementType() const;
float GetReserve() const;
- CXFA_MarginData GetMarginData() const;
+ CXFA_Margin* GetMargin() const;
CXFA_FontData GetFontData() const;
CXFA_Value* GetValue() const;
};
diff --git a/xfa/fxfa/parser/cxfa_datadata.cpp b/xfa/fxfa/parser/cxfa_datadata.cpp
index b2c8119639..76a4651d0d 100644
--- a/xfa/fxfa/parser/cxfa_datadata.cpp
+++ b/xfa/fxfa/parser/cxfa_datadata.cpp
@@ -71,9 +71,5 @@ XFA_Element CXFA_DataData::GetElementType() const {
pdfium::Optional<float> CXFA_DataData::TryMeasureAsFloat(
XFA_Attribute attr) const {
- pdfium::Optional<CXFA_Measurement> measure =
- m_pNode->JSObject()->TryMeasure(attr, false);
- if (measure)
- return {measure->ToUnit(XFA_Unit::Pt)};
- return {};
+ return m_pNode->JSObject()->TryMeasureAsFloat(attr);
}
diff --git a/xfa/fxfa/parser/cxfa_margin.cpp b/xfa/fxfa/parser/cxfa_margin.cpp
index 6a50d13e4d..6dd4d39ee4 100644
--- a/xfa/fxfa/parser/cxfa_margin.cpp
+++ b/xfa/fxfa/parser/cxfa_margin.cpp
@@ -39,3 +39,35 @@ CXFA_Margin::CXFA_Margin(CXFA_Document* doc, XFA_PacketType packet)
pdfium::MakeUnique<CJX_Margin>(this)) {}
CXFA_Margin::~CXFA_Margin() {}
+
+float CXFA_Margin::GetLeftInset() const {
+ return TryLeftInset().value_or(0);
+}
+
+float CXFA_Margin::GetTopInset() const {
+ return TryTopInset().value_or(0);
+}
+
+float CXFA_Margin::GetRightInset() const {
+ return TryRightInset().value_or(0);
+}
+
+float CXFA_Margin::GetBottomInset() const {
+ return TryBottomInset().value_or(0);
+}
+
+pdfium::Optional<float> CXFA_Margin::TryLeftInset() const {
+ return JSObject()->TryMeasureAsFloat(XFA_Attribute::LeftInset);
+}
+
+pdfium::Optional<float> CXFA_Margin::TryTopInset() const {
+ return JSObject()->TryMeasureAsFloat(XFA_Attribute::TopInset);
+}
+
+pdfium::Optional<float> CXFA_Margin::TryRightInset() const {
+ return JSObject()->TryMeasureAsFloat(XFA_Attribute::RightInset);
+}
+
+pdfium::Optional<float> CXFA_Margin::TryBottomInset() const {
+ return JSObject()->TryMeasureAsFloat(XFA_Attribute::BottomInset);
+}
diff --git a/xfa/fxfa/parser/cxfa_margin.h b/xfa/fxfa/parser/cxfa_margin.h
index 3ac7657d17..621704ab7a 100644
--- a/xfa/fxfa/parser/cxfa_margin.h
+++ b/xfa/fxfa/parser/cxfa_margin.h
@@ -13,6 +13,16 @@ class CXFA_Margin : public CXFA_Node {
public:
CXFA_Margin(CXFA_Document* doc, XFA_PacketType packet);
~CXFA_Margin() override;
+
+ float GetLeftInset() const;
+ float GetTopInset() const;
+ float GetRightInset() const;
+ float GetBottomInset() const;
+
+ pdfium::Optional<float> TryLeftInset() const;
+ pdfium::Optional<float> TryTopInset() const;
+ pdfium::Optional<float> TryRightInset() const;
+ pdfium::Optional<float> TryBottomInset() const;
};
#endif // XFA_FXFA_PARSER_CXFA_MARGIN_H_
diff --git a/xfa/fxfa/parser/cxfa_margindata.cpp b/xfa/fxfa/parser/cxfa_margindata.cpp
deleted file mode 100644
index c8baf2d05a..0000000000
--- a/xfa/fxfa/parser/cxfa_margindata.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2016 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_margindata.h"
-
-CXFA_MarginData::CXFA_MarginData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
-
-float CXFA_MarginData::GetLeftInset() const {
- return TryLeftInset().value_or(0);
-}
-
-float CXFA_MarginData::GetTopInset() const {
- return TryTopInset().value_or(0);
-}
-
-float CXFA_MarginData::GetRightInset() const {
- return TryRightInset().value_or(0);
-}
-
-float CXFA_MarginData::GetBottomInset() const {
- return TryBottomInset().value_or(0);
-}
-
-pdfium::Optional<float> CXFA_MarginData::TryLeftInset() const {
- return TryMeasureAsFloat(XFA_Attribute::LeftInset);
-}
-
-pdfium::Optional<float> CXFA_MarginData::TryTopInset() const {
- return TryMeasureAsFloat(XFA_Attribute::TopInset);
-}
-
-pdfium::Optional<float> CXFA_MarginData::TryRightInset() const {
- return TryMeasureAsFloat(XFA_Attribute::RightInset);
-}
-
-pdfium::Optional<float> CXFA_MarginData::TryBottomInset() const {
- return TryMeasureAsFloat(XFA_Attribute::BottomInset);
-}
diff --git a/xfa/fxfa/parser/cxfa_margindata.h b/xfa/fxfa/parser/cxfa_margindata.h
deleted file mode 100644
index 069aa7cc2d..0000000000
--- a/xfa/fxfa/parser/cxfa_margindata.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2016 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
-
-#ifndef XFA_FXFA_PARSER_CXFA_MARGINDATA_H_
-#define XFA_FXFA_PARSER_CXFA_MARGINDATA_H_
-
-#include "core/fxcrt/fx_system.h"
-#include "xfa/fxfa/parser/cxfa_datadata.h"
-
-class CXFA_Node;
-
-class CXFA_MarginData : public CXFA_DataData {
- public:
- explicit CXFA_MarginData(CXFA_Node* pNode);
-
- float GetLeftInset() const;
- float GetTopInset() const;
- float GetRightInset() const;
- float GetBottomInset() const;
-
- pdfium::Optional<float> TryLeftInset() const;
- pdfium::Optional<float> TryTopInset() const;
- pdfium::Optional<float> TryRightInset() const;
- pdfium::Optional<float> TryBottomInset() const;
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_MARGINDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index ba10f244d3..0f31fbafaa 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -275,9 +275,9 @@ CXFA_FontData CXFA_WidgetData::GetFontData(bool bModified) {
0, XFA_Element::Font, bModified));
}
-CXFA_MarginData CXFA_WidgetData::GetMarginData() {
- return CXFA_MarginData(m_pNode->JSObject()->GetProperty<CXFA_Margin>(
- 0, XFA_Element::Margin, false));
+CXFA_Margin* CXFA_WidgetData::GetMargin() {
+ return m_pNode->JSObject()->GetProperty<CXFA_Margin>(0, XFA_Element::Margin,
+ false);
}
CXFA_Para* CXFA_WidgetData::GetPara() {
@@ -373,12 +373,13 @@ CXFA_BorderData CXFA_WidgetData::GetUIBorderData() {
CFX_RectF CXFA_WidgetData::GetUIMargin() {
CXFA_Node* pUIChild = GetUIChild();
- CXFA_MarginData mgUI =
- CXFA_MarginData(pUIChild ? pUIChild->JSObject()->GetProperty<CXFA_Margin>(
- 0, XFA_Element::Margin, false)
- : nullptr);
+ CXFA_Margin* mgUI = nullptr;
+ if (pUIChild) {
+ mgUI = pUIChild->JSObject()->GetProperty<CXFA_Margin>(
+ 0, XFA_Element::Margin, false);
+ }
- if (!mgUI.HasValidNode())
+ if (!mgUI)
return CFX_RectF();
CXFA_BorderData borderData = GetUIBorderData();
@@ -387,10 +388,10 @@ CFX_RectF CXFA_WidgetData::GetUIMargin() {
return CFX_RectF();
}
- pdfium::Optional<float> left = mgUI.TryLeftInset();
- pdfium::Optional<float> top = mgUI.TryTopInset();
- pdfium::Optional<float> right = mgUI.TryRightInset();
- pdfium::Optional<float> bottom = mgUI.TryBottomInset();
+ pdfium::Optional<float> left = mgUI->TryLeftInset();
+ pdfium::Optional<float> top = mgUI->TryTopInset();
+ pdfium::Optional<float> right = mgUI->TryRightInset();
+ pdfium::Optional<float> bottom = mgUI->TryBottomInset();
if (borderData.HasValidNode()) {
bool bVisible = false;
float fThickness = 0;
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index e7016bda91..e2dbfbfafd 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -19,7 +19,6 @@
#include "xfa/fxfa/parser/cxfa_captiondata.h"
#include "xfa/fxfa/parser/cxfa_datadata.h"
#include "xfa/fxfa/parser/cxfa_fontdata.h"
-#include "xfa/fxfa/parser/cxfa_margindata.h"
enum XFA_CHECKSTATE {
XFA_CHECKSTATE_On = 0,
@@ -35,6 +34,7 @@ enum XFA_VALUEPICTURE {
};
class CXFA_Calculate;
+class CXFA_Margin;
class CXFA_Node;
class CXFA_Para;
class CXFA_Validate;
@@ -61,7 +61,7 @@ class CXFA_WidgetData : public CXFA_DataData {
CXFA_BorderData GetBorderData(bool bModified);
CXFA_CaptionData GetCaptionData();
CXFA_FontData GetFontData(bool bModified);
- CXFA_MarginData GetMarginData();
+ CXFA_Margin* GetMargin();
CXFA_Para* GetPara();
CXFA_Value* GetDefaultValue();
CXFA_Value* GetFormValue();