Span<const nsFramesetSpec> HTMLFrameSetElement::GetRowSpec() { if (mRowSpecs.IsEmpty()) { if (const nsAttrValue* value = GetParsedAttr(nsGkAtoms::rows)) { if (NS_FAILED(ParseRowCol(*value, mRowSpecs))) { return {};
}
}
if (mRowSpecs.IsEmpty()) { // We may not have had an attr or had an empty attr.
mRowSpecs.SetLength(1);
mRowSpecs[0].mUnit = eFramesetUnit_Relative;
mRowSpecs[0].mValue = 1;
}
}
return Span(mRowSpecs);
}
Span<const nsFramesetSpec> HTMLFrameSetElement::GetColSpec() { if (mColSpecs.IsEmpty()) { if (const nsAttrValue* value = GetParsedAttr(nsGkAtoms::cols)) { if (NS_FAILED(ParseRowCol(*value, mColSpecs))) { return {};
}
}
if (mColSpecs.IsEmpty()) { // We may not have had an attr or had an empty attr.
mColSpecs.SetLength(1);
mColSpecs[0].mUnit = eFramesetUnit_Relative;
mColSpecs[0].mValue = 1;
}
}
nsAutoString spec(nsAttrValueOrString(&aValue).String()); // remove whitespace (Bug 33699) and quotation marks (bug 224598) // also remove leading/trailing commas (bug 31482)
spec.StripChars(u" \n\r\t\"\'");
spec.Trim(",");
// Count the commas. Don't count more than X commas (bug 576447).
static_assert(NS_MAX_FRAMESET_SPEC_COUNT * sizeof(nsFramesetSpec) < (1 << 30), "Too many frameset specs allowed to allocate");
int32_t commaX = spec.FindChar(sComma);
size_t count = 1; while (commaX != kNotFound && count < NS_MAX_FRAMESET_SPEC_COUNT) {
count++;
commaX = spec.FindChar(sComma, commaX + 1);
}
nsTArray<nsFramesetSpec> specs; if (!specs.SetLength(count, fallible)) {
aSpecs.Clear(); return NS_ERROR_OUT_OF_MEMORY;
}
// Pre-grab the compat mode; we may need it later in the loop. bool isInQuirks = InNavQuirksMode(OwnerDoc());
// Parse each comma separated token
size_t start = 0;
size_t specLen = spec.Length();
for (size_t i = 0; i < count; i++) { // Find our comma
commaX = spec.FindChar(sComma, start);
MOZ_ASSERT(i == count - 1 || commaX != kNotFound, "Failed to find comma, somehow");
size_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) {
size_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;
}
}
// In standards mode, just set negative sizes to zero if (specs[i].mValue < 0) {
specs[i].mValue = 0;
}
start = end + 1;
}
}
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 und die Messung sind noch experimentell.