/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
void HTMLFrameSetElement::BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* 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 MutationObservers::AttributeChanged, which occurs *after* * AfterSetAttr is called, leaving us with no convenient way of changing the * value back to reflow afterwards. However, * MutationObservers::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, mNumRows, &mRowSpecs); if (mNumRows != oldRows) {
mCurrentRowColHint = nsChangeHint_ReconstructFrame;
}
}
} elseif (aName == nsGkAtoms::cols) { if (aValue) {
int32_t oldCols = mNumCols;
ParseRowCol(*aValue, mNumCols, &mColSpecs); if (mNumCols != oldCols) {
mCurrentRowColHint = nsChangeHint_ReconstructFrame;
}
}
}
}
nsresult HTMLFrameSetElement::GetRowSpec(int32_t* aNumValues, const nsFramesetSpec** aSpecs) {
MOZ_ASSERT(aNumValues, "Must have a pointer to an integer here!");
MOZ_ASSERT(aSpecs, "Must have a pointer to an array of nsFramesetSpecs");
*aNumValues = 0;
*aSpecs = nullptr;
if (!mRowSpecs) { if (const nsAttrValue* value = GetParsedAttr(nsGkAtoms::rows)) {
MOZ_TRY(ParseRowCol(*value, mNumRows, &mRowSpecs));
}
if (!mRowSpecs) { // we may not have had an attr or had an empty attr
mRowSpecs = MakeUnique<nsFramesetSpec[]>(1);
mNumRows = 1;
mRowSpecs[0].mUnit = eFramesetUnit_Relative;
mRowSpecs[0].mValue = 1;
}
}
nsresult HTMLFrameSetElement::GetColSpec(int32_t* aNumValues, const nsFramesetSpec** aSpecs) {
MOZ_ASSERT(aNumValues, "Must have a pointer to an integer here!");
MOZ_ASSERT(aSpecs, "Must have a pointer to an array of nsFramesetSpecs");
*aNumValues = 0;
*aSpecs = nullptr;
if (!mColSpecs) { if (const nsAttrValue* value = GetParsedAttr(nsGkAtoms::cols)) {
MOZ_TRY(ParseRowCol(*value, mNumCols, &mColSpecs));
}
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;
}
}
for (int32_t i = 0; i < count; i++) { // Find our comma
commaX = spec.FindChar(sComma, start);
NS_ASSERTION(i == count - 1 || commaX != kNotFound, "Failed to find comma, somehow");
int32_t end = (commaX == kNotFound) ? specLen : commaX;
// Note: If end == start then it means that the token has no // data in it other than a terminating comma (or the end of the spec). // So default to a fixed width of 0.
specs[i].mUnit = eFramesetUnit_Fixed;
specs[i].mValue = 0; if (end > start) {
int32_t numberEnd = end;
char16_t ch = spec.CharAt(numberEnd - 1); if (sAster == ch) {
specs[i].mUnit = eFramesetUnit_Relative;
numberEnd--;
} elseif (sPercent == ch) {
specs[i].mUnit = eFramesetUnit_Percent;
numberEnd--; // check for "*%" if (numberEnd > start) {
ch = spec.CharAt(numberEnd - 1); if (sAster == ch) {
specs[i].mUnit = eFramesetUnit_Relative;
numberEnd--;
}
}
}
// Translate value to an integer
nsAutoString token;
spec.Mid(token, start, numberEnd - start);
// Treat * as 1* if ((eFramesetUnit_Relative == specs[i].mUnit) && (0 == token.Length())) {
specs[i].mValue = 1;
} else { // Otherwise just convert to integer.
nsresult err;
specs[i].mValue = token.ToInteger(&err); if (NS_FAILED(err)) {
specs[i].mValue = 0;
}
}
// Treat 0* as 1* in quirks mode (bug 40383) if (isInQuirks) { if ((eFramesetUnit_Relative == specs[i].mUnit) &&
(0 == specs[i].mValue)) {
specs[i].mValue = 1;
}
}
// Catch zero and negative frame sizes for Nav compatibility // Nav resized absolute and relative frames to "1" and // percent frames to an even percentage of the width // // if (isInQuirks && (specs[i].mValue <= 0)) { // if (eFramesetUnit_Percent == specs[i].mUnit) { // specs[i].mValue = 100 / count; // } else { // specs[i].mValue = 1; // } //} else {
// In standards mode, just set negative sizes to zero if (specs[i].mValue < 0) {
specs[i].mValue = 0;
}
start = end + 1;
}
}
aNumSpecs = count; // Transfer ownership to caller here
*aSpecs = std::move(specs);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.