diff options
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fwl/theme/cfwl_edittp.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffcheckbutton.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_fffield.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffpushbutton.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidget.cpp | 35 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_box.cpp | 12 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_box.h | 8 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_edge.h | 2 |
8 files changed, 43 insertions, 26 deletions
diff --git a/xfa/fwl/theme/cfwl_edittp.cpp b/xfa/fwl/theme/cfwl_edittp.cpp index a1df805df0..599a4dda69 100644 --- a/xfa/fwl/theme/cfwl_edittp.cpp +++ b/xfa/fwl/theme/cfwl_edittp.cpp @@ -27,7 +27,7 @@ void CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) { FX_ARGB cr = 0xFF000000; float fWidth = 1.0f; if (borderUI) { - CXFA_Edge* edge = borderUI->GetEdge(0); + CXFA_Edge* edge = borderUI->GetEdgeIfExists(0); if (edge) { cr = edge->GetColor(); fWidth = edge->GetThickness(); diff --git a/xfa/fxfa/cxfa_ffcheckbutton.cpp b/xfa/fxfa/cxfa_ffcheckbutton.cpp index 2f79408e74..b50349f211 100644 --- a/xfa/fxfa/cxfa_ffcheckbutton.cpp +++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp @@ -175,7 +175,7 @@ bool CXFA_FFCheckButton::PerformLayout() { m_rtCheckBox = m_rtUI; CXFA_Border* borderUI = m_pNode->GetWidgetAcc()->GetUIBorder(); if (borderUI) { - CXFA_Margin* borderMargin = borderUI->GetMargin(); + CXFA_Margin* borderMargin = borderUI->GetMarginIfExists(); if (borderMargin) XFA_RectWithoutMargin(m_rtUI, borderMargin); } diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp index 53a81bdad9..b07d80f108 100644 --- a/xfa/fxfa/cxfa_fffield.cpp +++ b/xfa/fxfa/cxfa_fffield.cpp @@ -269,7 +269,7 @@ void CXFA_FFField::CapPlacement() { CXFA_Border* borderUI = m_pNode->GetWidgetAcc()->GetUIBorder(); if (borderUI) { - CXFA_Margin* borderMargin = borderUI->GetMargin(); + CXFA_Margin* borderMargin = borderUI->GetMarginIfExists(); if (borderMargin) XFA_RectWithoutMargin(m_rtUI, borderMargin); } diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp index 779fada905..85805b4d76 100644 --- a/xfa/fxfa/cxfa_ffpushbutton.cpp +++ b/xfa/fxfa/cxfa_ffpushbutton.cpp @@ -121,8 +121,10 @@ bool CXFA_FFPushButton::PerformLayout() { float CXFA_FFPushButton::GetLineWidth() { CXFA_Border* border = m_pNode->GetBorderIfExists(); - if (border && border->GetPresence() == XFA_AttributeEnum::Visible) - return border->GetEdge(0)->GetThickness(); + if (border && border->GetPresence() == XFA_AttributeEnum::Visible) { + CXFA_Edge* edge = border->GetEdgeIfExists(0); + return edge ? edge->GetThickness() : 0; + } return 0; } diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index cff0697c82..e28aa4314e 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -250,7 +250,8 @@ void XFA_BOX_GetFillPath(CXFA_Box* box, CXFA_GEPath& fillPath, uint16_t dwFlags) { if (box->IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { - float fThickness = std::fmax(0.0, box->GetEdge(0)->GetThickness()); + CXFA_Edge* edge = box->GetEdgeIfExists(0); + float fThickness = std::fmax(0.0, edge ? edge->GetThickness() : 0); float fHalf = fThickness / 2; XFA_AttributeEnum iHand = box->GetHand(); if (iHand == XFA_AttributeEnum::Left) @@ -391,12 +392,13 @@ void XFA_BOX_GetFillPath(CXFA_Box* box, } } -void XFA_BOX_Fill_Radial(CXFA_Box* box, +void XFA_BOX_Fill_Radial(CXFA_Fill* fill, CXFA_Graphics* pGS, CXFA_GEPath& fillPath, CFX_RectF rtFill, const CFX_Matrix& matrix) { - CXFA_Fill* fill = box->GetFill(); + ASSERT(fill); + FX_ARGB crStart = fill->GetColor(false); FX_ARGB crEnd = fill->GetRadialColor(); if (!fill->IsRadialToEdge()) @@ -411,12 +413,13 @@ void XFA_BOX_Fill_Radial(CXFA_Box* box, pGS->FillPath(&fillPath, FXFILL_WINDING, &matrix); } -void XFA_BOX_Fill_Pattern(CXFA_Box* box, +void XFA_BOX_Fill_Pattern(CXFA_Fill* fill, CXFA_Graphics* pGS, CXFA_GEPath& fillPath, CFX_RectF rtFill, const CFX_Matrix& matrix) { - CXFA_Fill* fill = box->GetFill(); + ASSERT(fill); + FX_ARGB crStart = fill->GetColor(false); FX_ARGB crEnd = fill->GetPatternColor(); FX_HatchStyle iHatch = FX_HatchStyle::Cross; @@ -445,12 +448,13 @@ void XFA_BOX_Fill_Pattern(CXFA_Box* box, pGS->FillPath(&fillPath, FXFILL_WINDING, &matrix); } -void XFA_BOX_Fill_Linear(CXFA_Box* box, +void XFA_BOX_Fill_Linear(CXFA_Fill* fill, CXFA_Graphics* pGS, CXFA_GEPath& fillPath, CFX_RectF rtFill, const CFX_Matrix& matrix) { - CXFA_Fill* fill = box->GetFill(); + ASSERT(fill); + FX_ARGB crStart = fill->GetColor(false); FX_ARGB crEnd = fill->GetLinearColor(); @@ -488,7 +492,7 @@ void XFA_BOX_Fill(CXFA_Box* box, const CFX_RectF& rtWidget, const CFX_Matrix& matrix, uint32_t dwFlags) { - CXFA_Fill* fill = box->GetFill(); + CXFA_Fill* fill = box->GetFillIfExists(); if (!fill || !fill->IsVisible()) return; @@ -500,13 +504,13 @@ void XFA_BOX_Fill(CXFA_Box* box, XFA_Element eType = fill->GetFillType(); switch (eType) { case XFA_Element::Radial: - XFA_BOX_Fill_Radial(box, pGS, fillPath, rtWidget, matrix); + XFA_BOX_Fill_Radial(fill, pGS, fillPath, rtWidget, matrix); break; case XFA_Element::Pattern: - XFA_BOX_Fill_Pattern(box, pGS, fillPath, rtWidget, matrix); + XFA_BOX_Fill_Pattern(fill, pGS, fillPath, rtWidget, matrix); break; case XFA_Element::Linear: - XFA_BOX_Fill_Linear(box, pGS, fillPath, rtWidget, matrix); + XFA_BOX_Fill_Linear(fill, pGS, fillPath, rtWidget, matrix); break; default: { FX_ARGB cr; @@ -559,7 +563,7 @@ void XFA_BOX_StrokeArc(CXFA_Box* box, CFX_RectF rtWidget, const CFX_Matrix& matrix, uint32_t dwFlags) { - CXFA_Edge* edge = box->GetEdge(0); + CXFA_Edge* edge = box->GetEdgeIfExists(0); if (!edge || !edge->IsVisible()) return; @@ -987,7 +991,7 @@ void CXFA_FFWidget::RenderWidget(CXFA_Graphics* pGS, return; CFX_RectF rtBorder = GetRectWithoutRotate(); - CXFA_Margin* margin = border->GetMargin(); + CXFA_Margin* margin = border->GetMarginIfExists(); if (margin) XFA_RectWithoutMargin(rtBorder, margin); @@ -998,18 +1002,23 @@ void CXFA_FFWidget::RenderWidget(CXFA_Graphics* pGS, bool CXFA_FFWidget::IsLoaded() { return !!m_pPageView; } + bool CXFA_FFWidget::LoadWidget() { PerformLayout(); return true; } + void CXFA_FFWidget::UnloadWidget() {} + bool CXFA_FFWidget::PerformLayout() { RecacheWidgetRect(); return true; } + bool CXFA_FFWidget::UpdateFWLData() { return false; } + void CXFA_FFWidget::UpdateWidgetProperty() {} void CXFA_FFWidget::DrawBorder(CXFA_Graphics* pGS, diff --git a/xfa/fxfa/parser/cxfa_box.cpp b/xfa/fxfa/parser/cxfa_box.cpp index 443362f449..5f8bed9aa1 100644 --- a/xfa/fxfa/parser/cxfa_box.cpp +++ b/xfa/fxfa/parser/cxfa_box.cpp @@ -81,7 +81,7 @@ int32_t CXFA_Box::CountEdges() { return CountChildren(XFA_Element::Edge, false); } -CXFA_Edge* CXFA_Box::GetEdge(int32_t nIndex) { +CXFA_Edge* CXFA_Box::GetEdgeIfExists(int32_t nIndex) { if (nIndex == 0) return JSObject()->GetOrCreateProperty<CXFA_Edge>(nIndex, XFA_Element::Edge); @@ -104,15 +104,15 @@ Optional<int32_t> CXFA_Box::GetSweepAngle() { return JSObject()->TryInteger(XFA_Attribute::SweepAngle, false); } -CXFA_Fill* CXFA_Box::GetFill() const { +CXFA_Fill* CXFA_Box::GetFillIfExists() const { return JSObject()->GetProperty<CXFA_Fill>(0, XFA_Element::Fill); } -CXFA_Fill* CXFA_Box::GetOrCreateFill() { +CXFA_Fill* CXFA_Box::GetOrCreateFillIfPossible() { return JSObject()->GetOrCreateProperty<CXFA_Fill>(0, XFA_Element::Fill); } -CXFA_Margin* CXFA_Box::GetMargin() { +CXFA_Margin* CXFA_Box::GetMarginIfExists() { return GetChild<CXFA_Margin>(0, XFA_Element::Margin, false); } @@ -144,6 +144,8 @@ std::vector<CXFA_Stroke*> CXFA_Box::GetStrokesInternal(bool bNull) { corner = JSObject()->GetProperty<CXFA_Corner>(i, XFA_Element::Corner); } + // TODO(dsinclair): If i == 0 and GetOrCreateProperty failed, we can end up + // with a null corner in the first position. if (corner || i == 0) { strokes[j] = corner; } else if (!bNull) { @@ -160,6 +162,8 @@ std::vector<CXFA_Stroke*> CXFA_Box::GetStrokesInternal(bool bNull) { else edge = JSObject()->GetProperty<CXFA_Edge>(i, XFA_Element::Edge); + // TODO(dsinclair): If i == 0 and GetOrCreateProperty failed, we can end up + // with a null edge in the first position. if (edge || i == 0) { strokes[j] = edge; } else if (!bNull) { diff --git a/xfa/fxfa/parser/cxfa_box.h b/xfa/fxfa/parser/cxfa_box.h index c85d0164af..216a981c83 100644 --- a/xfa/fxfa/parser/cxfa_box.h +++ b/xfa/fxfa/parser/cxfa_box.h @@ -30,10 +30,10 @@ class CXFA_Box : public CXFA_Node { std::tuple<XFA_AttributeEnum, bool, float> Get3DStyle(); int32_t CountEdges(); - CXFA_Edge* GetEdge(int32_t nIndex); - CXFA_Fill* GetFill() const; - CXFA_Fill* GetOrCreateFill(); - CXFA_Margin* GetMargin(); + CXFA_Edge* GetEdgeIfExists(int32_t nIndex); + CXFA_Fill* GetFillIfExists() const; + CXFA_Fill* GetOrCreateFillIfPossible(); + CXFA_Margin* GetMarginIfExists(); std::vector<CXFA_Stroke*> GetStrokes(); diff --git a/xfa/fxfa/parser/cxfa_edge.h b/xfa/fxfa/parser/cxfa_edge.h index 8bf9f6ea28..36fee55624 100644 --- a/xfa/fxfa/parser/cxfa_edge.h +++ b/xfa/fxfa/parser/cxfa_edge.h @@ -11,6 +11,8 @@ class CXFA_Edge : public CXFA_Stroke { public: + static constexpr FX_ARGB kDefaultColor = 0xFF000000; + CXFA_Edge(CXFA_Document* doc, XFA_PacketType packet); ~CXFA_Edge() override; }; |