// don't set mColCount here, it is done in AddColsToTable NS_IMETHODIMP nsTableColGroupFrame::SetInitialChildList(ChildListID aListID, nsFrameList& aChildList) { if (!mFrames.IsEmpty()) { // We already have child frames which means we've already been // initialized NS_NOTREACHED("unexpected second call to SetInitialChildList"); return NS_ERROR_UNEXPECTED; } if (aListID != kPrincipalList) { // All we know about is the principal child list. NS_NOTREACHED("unknown frame list"); return NS_ERROR_INVALID_ARG; } nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this); if (aChildList.IsEmpty()) { tableFrame->AppendAnonymousColFrames(this, GetSpan(), eColAnonymousColGroup, false); return NS_OK; } mFrames.AppendFrames(this, aChildList); return NS_OK; }
void FunctionNode::Accept(Visitor& visitor) { try { visitor.BeginVisit(*this); if (!visitor.SkipContent()) { templateParameters.Accept(visitor); parameters.Accept(visitor); if (visitor.VisitBodies()) { if (body) { body->Accept(visitor); } } } visitor.EndVisit(*this); } catch (Cm::Ast::Exception& ex) { ex.AddReference(GetSpan()); throw; } }
Node* TemplateParameterNode::Clone(CloneContext& cloneContext) const { Cm::Ast::Node* clonedDefaultTemplateargument = nullptr; if (defaultTemplateArgument) { clonedDefaultTemplateargument = defaultTemplateArgument->Clone(cloneContext); } return new TemplateParameterNode(GetSpan(), static_cast<IdentifierNode*>(id->Clone(cloneContext)), clonedDefaultTemplateargument); }
Node* TemplateIdNode::Clone(CloneContext& cloneContext) const { TemplateIdNode* clone = new TemplateIdNode(GetSpan(), subject->Clone(cloneContext)); for (const std::unique_ptr<Node>& templateArgument : templateArguments) { clone->AddTemplateArgument(templateArgument->Clone(cloneContext)); } return clone; }
NS_IMETHODIMP nsTableColGroupFrame::RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) { NS_ASSERTION(aListID == kPrincipalList, "unexpected child list"); if (!aOldFrame) return NS_OK; bool contentRemoval = false; if (nsGkAtoms::tableColFrame == aOldFrame->GetType()) { nsTableColFrame* colFrame = (nsTableColFrame*)aOldFrame; if (colFrame->GetColType() == eColContent) { contentRemoval = true; // Remove any anonymous column frames this <col> produced via a colspan nsTableColFrame* col = colFrame->GetNextCol(); nsTableColFrame* nextCol; while (col && col->GetColType() == eColAnonymousCol) { #ifdef DEBUG nsIFrame* providerFrame = colFrame->GetParentStyleContextFrame(); if (colFrame->GetStyleContext()->GetParent() == providerFrame->GetStyleContext()) { NS_ASSERTION(col->GetStyleContext() == colFrame->GetStyleContext() && col->GetContent() == colFrame->GetContent(), "How did that happen??"); } // else colFrame is being removed because of a frame // reconstruct on it, and its style context is still the old // one, so we can't assert anything about how it compares to // col's style context. #endif nextCol = col->GetNextCol(); RemoveFrame(kPrincipalList, col); col = nextCol; } } PRInt32 colIndex = colFrame->GetColIndex(); // The RemoveChild call handles calling FrameNeedsReflow on us. RemoveChild(*colFrame, true); nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this); tableFrame->RemoveCol(this, colIndex, true, true); if (mFrames.IsEmpty() && contentRemoval && GetColType() == eColGroupContent) { tableFrame->AppendAnonymousColFrames(this, GetSpan(), eColAnonymousColGroup, true); } } else { mFrames.DestroyFrame(aOldFrame); } return NS_OK; }
dBigVector dBezierSpline::CurveDerivative (dFloat64 u, int index) const { u = dClamp (u, dFloat64 (0.0f), dFloat64 (1.0f)); dAssert (index <= m_degree); dFloat64 basicsFuncDerivatives[D_BEZIER_LOCAL_BUFFER_SIZE]; int span = GetSpan(u); BasicsFunctionsDerivatives (u, span, basicsFuncDerivatives); const int with = m_degree + 1; dBigVector point (0.0f, 0.0f, 0.0f, 0.0f); for (int i = 0; i <= m_degree; i ++) { point += m_controlPoints[span - m_degree + i].Scale (basicsFuncDerivatives[with * index + i]); } return point; }
static unsigned DoTable (attr_t Style, unsigned MemberSize, void (*TableFunc) (unsigned)) /* Output a table of bytes */ { unsigned BytesLeft; /* Count how many bytes may be output. */ unsigned Count = GetSpan (Style); /* If the count is less than the member size, print a row of Count data ** bytes. We assume here that there is no member with a size that is less ** than BytesPerLine. */ if (Count < MemberSize) { DataByteLine (Count); PC += Count; return Count; } /* Make Count an even number of multiples of MemberSize */ Count &= ~(MemberSize-1); /* Output as many data bytes lines as needed */ BytesLeft = Count; while (BytesLeft > 0) { /* Calculate the number of bytes for the next line */ unsigned Chunk = (BytesLeft > BytesPerLine)? BytesPerLine : BytesLeft; /* Output a line with these bytes */ TableFunc (Chunk); /* Next line */ BytesLeft -= Chunk; PC += Chunk; } /* If the next line is not the same style, add a separator */ if (CodeLeft() && GetStyleAttr (PC) != Style) { SeparatorLine (); } /* Return the number of bytes output */ return Count; }
int dBezierSpline::CurveAllDerivatives (dFloat64 u, dBigVector* const derivatives) const { u = dMod (u, 1.0f); dFloat64 basicsFuncDerivatives[D_BEZIER_LOCAL_BUFFER_SIZE]; int span = GetSpan(u); BasicsFunctionsDerivatives (u, span, basicsFuncDerivatives); const int with = m_degree + 1; dBigVector point (0.0f, 0.0f, 0.0f, 0.0f); for (int j = 0; j <= m_degree; j ++) { dBigVector ck (0.0f, 0.0f, 0.0f, 0.0f); for (int i = 0; i <= m_degree; i ++) { ck += m_controlPoints[span - m_degree + i].Scale (basicsFuncDerivatives[with * j + i]); } derivatives[j] = ck; } return m_degree + 1; }
Node* FunctionNode::Clone(CloneContext& cloneContext) const { FunctionNode* clone = new FunctionNode(GetSpan(), specifiers, returnTypeExpr->Clone(cloneContext), static_cast<FunctionGroupIdNode*>(groupId->Clone(cloneContext))); if (!cloneContext.InstantiateFunctionNode()) { for (const std::unique_ptr<TemplateParameterNode>& templateParameter : templateParameters) { clone->AddTemplateParameter(static_cast<TemplateParameterNode*>(templateParameter->Clone(cloneContext))); } } for (const std::unique_ptr<ParameterNode>& parameter : parameters) { clone->AddParameter(static_cast<ParameterNode*>(parameter->Clone(cloneContext))); } if (constraint) { clone->SetConstraint(static_cast<WhereConstraintNode*>(constraint->Clone(cloneContext))); } clone->SetBody(static_cast<CompoundStatementNode*>(body->Clone(cloneContext))); return clone; }
void nsTableColGroupFrame::Dump(PRInt32 aIndent) { char* indent = new char[aIndent + 1]; if (!indent) return; for (PRInt32 i = 0; i < aIndent + 1; i++) { indent[i] = ' '; } indent[aIndent] = 0; printf("%s**START COLGROUP DUMP**\n%s startcolIndex=%d colcount=%d span=%d coltype=", indent, indent, GetStartColumnIndex(), GetColCount(), GetSpan()); nsTableColGroupType colType = GetColType(); switch (colType) { case eColGroupContent: printf(" content "); break; case eColGroupAnonymousCol: printf(" anonymous-column "); break; case eColGroupAnonymousCell: printf(" anonymous-cell "); break; } // verify the colindices PRInt32 j = GetStartColumnIndex(); nsTableColFrame* col = GetFirstColumn(); while (col) { NS_ASSERTION(j == col->GetColIndex(), "wrong colindex on col frame"); col = col->GetNextCol(); j++; } NS_ASSERTION((j - GetStartColumnIndex()) == GetColCount(), "number of cols out of sync"); printf("\n%s**END COLGROUP DUMP** ", indent); delete [] indent; }
unsigned TextTable (void) /* Output a table of text messages */ { /* Count how many bytes may be output. */ unsigned ByteCount = GetSpan (atTextTab); /* Output as many data bytes lines as needed. */ unsigned BytesLeft = ByteCount; while (BytesLeft > 0) { unsigned I; /* Count the number of characters that can be output as such */ unsigned Count = 0; while (Count < BytesLeft && Count < BytesPerLine*4-1) { unsigned char C = GetCodeByte (PC + Count); if (C >= 0x20 && C <= 0x7E && C != '\"') { ++Count; } else { break; } } /* If we have text, output it */ if (Count > 0) { unsigned CBytes; Indent (MCol); Output (".byte"); Indent (ACol); Output ("\""); for (I = 0; I < Count; ++I) { Output ("%c", GetCodeByte (PC+I)); } Output ("\""); CBytes = Count; while (CBytes > 0) { unsigned Chunk = CBytes; if (Chunk > BytesPerLine) { Chunk = BytesPerLine; } LineComment (PC, Chunk); LineFeed (); CBytes -= Chunk; PC += Chunk; } BytesLeft -= Count; } /* Count the number of bytes that must be output as bytes */ Count = 0; while (Count < BytesLeft && Count < BytesPerLine) { unsigned char C = GetCodeByte (PC + Count); if (C < 0x20 || C > 0x7E || C == '\"') { ++Count; } else { break; } } /* If we have raw output bytes, print them */ if (Count > 0) { DataByteLine (Count); PC += Count; BytesLeft -= Count; } } /* If the next line is not a byte table line, add a separator */ if (CodeLeft() && GetStyleAttr (PC) != atTextTab) { SeparatorLine (); } /* Return the number of bytes output */ return ByteCount; }
Node* FunctionGroupIdNode::Clone(CloneContext& cloneContext) const { return new FunctionGroupIdNode(GetSpan(), functionGroupId); }
bool CPDF_CIDFont::Load() { if (m_pFontDict->GetStringFor("Subtype") == "TrueType") { LoadGB2312(); return true; } const CPDF_Array* pFonts = m_pFontDict->GetArrayFor("DescendantFonts"); if (!pFonts || pFonts->size() != 1) return false; const CPDF_Dictionary* pCIDFontDict = pFonts->GetDictAt(0); if (!pCIDFontDict) return false; m_BaseFont = pCIDFontDict->GetStringFor("BaseFont"); if ((m_BaseFont.Compare("CourierStd") == 0 || m_BaseFont.Compare("CourierStd-Bold") == 0 || m_BaseFont.Compare("CourierStd-BoldOblique") == 0 || m_BaseFont.Compare("CourierStd-Oblique") == 0) && !IsEmbedded()) { m_bAdobeCourierStd = true; } const CPDF_Dictionary* pFontDesc = pCIDFontDict->GetDictFor("FontDescriptor"); if (pFontDesc) LoadFontDescriptor(pFontDesc); CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectFor("Encoding"); if (!pEncoding) return false; ByteString subtype = pCIDFontDict->GetStringFor("Subtype"); m_bType1 = (subtype == "CIDFontType0"); CPDF_CMapManager* manager = GetFontGlobals()->GetCMapManager(); if (pEncoding->IsName()) { ByteString cmap = pEncoding->GetString(); m_pCMap = manager->GetPredefinedCMap(cmap); if (!m_pCMap) return false; } else if (CPDF_Stream* pStream = pEncoding->AsStream()) { auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream); pAcc->LoadAllDataFiltered(); m_pCMap = pdfium::MakeRetain<CPDF_CMap>(); m_pCMap->LoadEmbedded(pAcc->GetSpan()); } else { return false; } m_Charset = m_pCMap->GetCharset(); if (m_Charset == CIDSET_UNKNOWN) { const CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDictFor("CIDSystemInfo"); if (pCIDInfo) { m_Charset = CPDF_CMapParser::CharsetFromOrdering( pCIDInfo->GetStringFor("Ordering").AsStringView()); } } if (m_Charset != CIDSET_UNKNOWN) { m_pCID2UnicodeMap = manager->GetCID2UnicodeMap(m_Charset); } if (m_Font.GetFace()) { if (m_bType1) FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE); else FT_UseCIDCharmap(m_Font.GetFace(), m_pCMap->GetCoding()); } m_DefaultWidth = pCIDFontDict->GetIntegerFor("DW", 1000); const CPDF_Array* pWidthArray = pCIDFontDict->GetArrayFor("W"); if (pWidthArray) LoadMetricsArray(pWidthArray, &m_WidthList, 1); if (!IsEmbedded()) LoadSubstFont(); const CPDF_Object* pmap = pCIDFontDict->GetDirectObjectFor("CIDToGIDMap"); if (pmap) { if (const CPDF_Stream* pStream = pmap->AsStream()) { m_pStreamAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream); m_pStreamAcc->LoadAllDataFiltered(); } else if (m_pFontFile && pmap->GetString() == "Identity") { m_bCIDIsGID = true; } } CheckFontMetrics(); if (IsVertWriting()) { pWidthArray = pCIDFontDict->GetArrayFor("W2"); if (pWidthArray) LoadMetricsArray(pWidthArray, &m_VertMetrics, 3); const CPDF_Array* pDefaultArray = pCIDFontDict->GetArrayFor("DW2"); if (pDefaultArray) { m_DefaultVY = pDefaultArray->GetIntegerAt(0); m_DefaultW1 = pDefaultArray->GetIntegerAt(1); } } return true; }
bool dBezierSpline::RemoveKnot (dFloat64 u, dFloat64 tol) { int r = GetSpan(u) + 1; dAssert (m_knotVector[r - 1] < u); if (dAbs (m_knotVector[r] - u) > 1.0e-5f) { return false; } int s = 1; int last = r - s; int first = r - m_degree; int ord = m_degree + 1; dBigVector temp[16]; bool removableFlag = false; int t = 0; for ( ; t < m_degree; t ++) { int off = first - 1; temp[0] = m_controlPoints[off]; temp[last + 1 - off] = m_controlPoints[last + 1]; int i = first; int j = last; int ii = 1; int jj = last - off; while ((j - i) > t) { dFloat64 alpha_i = (u - m_knotVector[i]) / (m_knotVector[i + ord + t] - m_knotVector[i]); dFloat64 alpha_j = (u - m_knotVector[j - t]) / (m_knotVector[j + ord] - m_knotVector[j - t]); temp[ii] = (m_controlPoints[i] - temp[ii - 1].Scale (dFloat64 (1.0f) - alpha_i)).Scale (dFloat64 (1.0f) / alpha_i); temp[jj] = (m_controlPoints[j] - temp[jj + 1].Scale (alpha_j)).Scale (dFloat64 (1.0f) / (dFloat64 (1.0f) - alpha_j)); i ++; j --; ii ++; jj --; } if ((j - i) < t) { dBigVector diff (temp[ii - 1] - temp[jj + 1]); removableFlag = diff.DotProduct3(diff) < (tol * tol); } else { dFloat64 alpha_i = (u - m_knotVector[i]) / (m_knotVector[i + ord + t] - m_knotVector[i]); dBigVector p (temp[ii + t + 1].Scale (alpha_i) + temp[ii - 1].Scale (dFloat64 (1.0f) - alpha_i)); dBigVector diff (m_controlPoints[i] - p); removableFlag = diff.DotProduct3(diff) < (tol * tol); } if (!removableFlag) { break; } i = first; j = last; while ((j - 1) > t) { m_controlPoints[i] = temp[i - off]; m_controlPoints[j] = temp[j - off]; i ++; j --; } first --; last ++; } if (t) { for (int k = r + t; k < m_knotsCount; k ++) { m_knotVector[k - t] = m_knotVector[k]; } int fOut = (2 * r - s - m_degree) / 2; int j = fOut; int i = j; for (int k = 1; k < t; k ++) { if ((k % 2) == 1) { i ++; } else { j = j - 1; } } for (int k = i + 1; k < m_controlPointsCount; k ++) { m_controlPoints[j] = m_controlPoints[k]; j ++; } m_knotsCount -= t; m_controlPointsCount -= t; } return removableFlag; }
void dBezierSpline::InsertKnot (dFloat64 u) { int k = GetSpan(u); int multiplicity = 0; for (int i = 0; i < m_degree; i ++) { multiplicity += (dAbs (m_knotVector[k + i + 1] - u) < dFloat64 (1.0e-5f)) ? 1 : 0; } if (multiplicity == m_degree) { return; } dFloat64 newKnotVector[D_BEZIER_LOCAL_BUFFER_SIZE]; dAssert ((m_knotsCount + 1)< D_BEZIER_LOCAL_BUFFER_SIZE); for (int i = 0; i <= k; i ++) { newKnotVector[i] = m_knotVector[i]; } newKnotVector[k + 1] = u; for (int i = k + 1; i < m_knotsCount; i ++) { newKnotVector[i + 1] = m_knotVector[i]; } dBigVector Rw[16]; dBigVector newControlPoints[D_BEZIER_LOCAL_BUFFER_SIZE]; for (int i = 0; i <= (k - m_degree); i ++) { newControlPoints[i] = m_controlPoints[i]; } for (int i = k; i < m_controlPointsCount; i ++) { newControlPoints[i + 1] = m_controlPoints[i]; } for (int i = 0; i <= m_degree; i ++) { Rw[i] = m_controlPoints[k - m_degree + i]; } int m = k - m_degree + 1; for (int i = 0; i <= (m_degree - 1); i ++) { dFloat64 alpha = (u - m_knotVector[m + i]) / (m_knotVector[i + k + 1] - m_knotVector[m + i]); Rw[i] = Rw[i + 1].Scale (alpha) + Rw[i].Scale (dFloat64 (1.0f) - alpha); } dAssert(m >= 0); dAssert((k + 1 - 1 - 0) >= 0); dAssert((m_degree - 1 - 0) >= 0); newControlPoints[m] = Rw[0]; newControlPoints[k + 1 - 1 - 0] = Rw[m_degree - 1 - 0]; for (int i = m + 1; i < k; i ++) { dAssert ((i - m) >= 0); newControlPoints[i] = Rw[i - m]; } Clear(); m_knotsCount ++; m_controlPointsCount ++; m_knotVector = (dFloat64*) Alloc (m_knotsCount * sizeof (dFloat64)); m_controlPoints = (dBigVector*) Alloc (m_controlPointsCount * sizeof (dBigVector)); memcpy (m_knotVector, newKnotVector, m_knotsCount * sizeof (dFloat64)); memcpy (m_controlPoints, newControlPoints, m_controlPointsCount * sizeof (dBigVector)); }
Node* CompileUnitNode::Clone(CloneContext& cloneContext) const { CompileUnitNode* clone = new CompileUnitNode(GetSpan(), filePath); clone->globalNs.reset(static_cast<NamespaceNode*>(globalNs->Clone(cloneContext))); return clone; }
Node* TypedefNode::Clone(CloneContext& cloneContext) const { return new TypedefNode(GetSpan(), specifiers, typeExpr->Clone(cloneContext), static_cast<IdentifierNode*>(id->Clone(cloneContext))); }
dBigVector dBezierSpline::CurvePoint (dFloat64 u) const { u = dClamp (u, dFloat64 (0.0f), dFloat64 (1.0f)); int span = GetSpan(u); return CurvePoint (u, span); }