nsresult HTMLFrameSetElement::GetColSpec(int32_t *aNumValues, const nsFramesetSpec** aSpecs) { NS_PRECONDITION(aNumValues, "Must have a pointer to an integer here!"); NS_PRECONDITION(aSpecs, "Must have a pointer to an array of nsFramesetSpecs"); *aNumValues = 0; *aSpecs = nullptr; if (!mColSpecs) { const nsAttrValue* value = GetParsedAttr(nsGkAtoms::cols); if (value && value->Type() == nsAttrValue::eString) { nsresult rv = ParseRowCol(value->GetStringValue(), mNumCols, &mColSpecs); NS_ENSURE_SUCCESS(rv, rv); } if (!mColSpecs) { // we may not have had an attr or had an empty attr mColSpecs = MakeUnique<nsFramesetSpec[]>(1); mNumCols = 1; mColSpecs[0].mUnit = eFramesetUnit_Relative; mColSpecs[0].mValue = 1; } } *aSpecs = mColSpecs.get(); *aNumValues = mNumCols; return NS_OK; }
nsresult HTMLFrameSetElement::GetRowSpec(int32_t *aNumValues, const nsFramesetSpec** aSpecs) { NS_PRECONDITION(aNumValues, "Must have a pointer to an integer here!"); NS_PRECONDITION(aSpecs, "Must have a pointer to an array of nsFramesetSpecs"); *aNumValues = 0; *aSpecs = nullptr; if (!mRowSpecs) { const nsAttrValue* value = GetParsedAttr(nsGkAtoms::rows); if (value && value->Type() == nsAttrValue::eString) { nsresult rv = ParseRowCol(value->GetStringValue(), mNumRows, getter_Transfers(mRowSpecs)); NS_ENSURE_SUCCESS(rv, rv); } if (!mRowSpecs) { // we may not have had an attr or had an empty attr mRowSpecs = new nsFramesetSpec[1]; if (!mRowSpecs) { mNumRows = 0; return NS_ERROR_OUT_OF_MEMORY; } mNumRows = 1; mRowSpecs[0].mUnit = eFramesetUnit_Relative; mRowSpecs[0].mValue = 1; } } *aSpecs = mRowSpecs; *aNumValues = mNumRows; return NS_OK; }
nsresult HTMLFrameSetElement::BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValueOrString* aValue, bool aNotify) { /* The main goal here is to see whether the _number_ of rows or * columns has changed. If it has, we need to reframe; otherwise * we want to reflow. * Ideally, the style hint would be changed back to reflow after the reframe * has been performed. Unfortunately, however, the reframe will be performed * by the call to nsNodeUtils::AttributeChanged, which occurs *after* * AfterSetAttr is called, leaving us with no convenient way of changing the * value back to reflow afterwards. However, nsNodeUtils::AttributeChanged is * effectively the only consumer of this value, so as long as we always set * the value correctly here, we should be fine. */ mCurrentRowColHint = NS_STYLE_HINT_REFLOW; if (aNamespaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::rows) { if (aValue) { int32_t oldRows = mNumRows; ParseRowCol(aValue->String(), mNumRows, &mRowSpecs); if (mNumRows != oldRows) { mCurrentRowColHint = nsChangeHint_ReconstructFrame; } } } else if (aName == nsGkAtoms::cols) { if (aValue) { int32_t oldCols = mNumCols; ParseRowCol(aValue->String(), mNumCols, &mColSpecs); if (mNumCols != oldCols) { mCurrentRowColHint = nsChangeHint_ReconstructFrame; } } } } return nsGenericHTMLElement::BeforeSetAttr(aNamespaceID, aName, aValue, aNotify); }
nsresult HTMLFrameSetElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, nsIAtom* aPrefix, const nsAString& aValue, bool aNotify) { nsresult rv; /* The main goal here is to see whether the _number_ of rows or * columns has changed. If it has, we need to reframe; otherwise * we want to reflow. So we set mCurrentRowColHint here, then call * nsGenericHTMLElement::SetAttr, which will end up calling * GetAttributeChangeHint and notifying layout with that hint. * Once nsGenericHTMLElement::SetAttr returns, we want to go back to our * normal hint, which is NS_STYLE_HINT_REFLOW. */ if (aAttribute == nsGkAtoms::rows && aNameSpaceID == kNameSpaceID_None) { int32_t oldRows = mNumRows; ParseRowCol(aValue, mNumRows, &mRowSpecs); if (mNumRows != oldRows) { mCurrentRowColHint = nsChangeHint_ReconstructFrame; } } else if (aAttribute == nsGkAtoms::cols && aNameSpaceID == kNameSpaceID_None) { int32_t oldCols = mNumCols; ParseRowCol(aValue, mNumCols, &mColSpecs); if (mNumCols != oldCols) { mCurrentRowColHint = nsChangeHint_ReconstructFrame; } } rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aAttribute, aPrefix, aValue, aNotify); mCurrentRowColHint = NS_STYLE_HINT_REFLOW; return rv; }