commit a74ba85d3bf8b572de02f154e3dfe6e89a969a65
parent de638bb57abff3e1263cdc57626b65096af3b150
Author: Andrew McCreight <continuation@gmail.com>
Date: Tue, 7 Oct 2025 22:22:08 +0000
Bug 1992422 - part 4: Clean up some integer types in HTMLFrameSetElement::ParseRowCol(). r=layout-reviewers,emilio
Also, remove some code that has been commented out since 2002.
Differential Revision: https://phabricator.services.mozilla.com/D267675
Diffstat:
1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/dom/html/HTMLFrameSetElement.cpp b/dom/html/HTMLFrameSetElement.cpp
@@ -163,7 +163,7 @@ nsresult HTMLFrameSetElement::ParseRowCol(const nsAttrValue& aValue,
static_assert(NS_MAX_FRAMESET_SPEC_COUNT * sizeof(nsFramesetSpec) < (1 << 30),
"Too many frameset specs allowed to allocate");
int32_t commaX = spec.FindChar(sComma);
- int32_t count = 1;
+ size_t count = 1;
while (commaX != kNotFound && count < NS_MAX_FRAMESET_SPEC_COUNT) {
count++;
commaX = spec.FindChar(sComma, commaX + 1);
@@ -181,15 +181,15 @@ nsresult HTMLFrameSetElement::ParseRowCol(const nsAttrValue& aValue,
// Parse each comma separated token
- int32_t start = 0;
- int32_t specLen = spec.Length();
+ size_t start = 0;
+ size_t specLen = spec.Length();
- for (int32_t i = 0; i < count; i++) {
+ for (size_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;
+ 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).
@@ -197,7 +197,7 @@ nsresult HTMLFrameSetElement::ParseRowCol(const nsAttrValue& aValue,
specs[i].mUnit = eFramesetUnit_Fixed;
specs[i].mValue = 0;
if (end > start) {
- int32_t numberEnd = end;
+ size_t numberEnd = end;
char16_t ch = spec.CharAt(numberEnd - 1);
if (sAster == ch) {
specs[i].mUnit = eFramesetUnit_Relative;
@@ -239,18 +239,6 @@ nsresult HTMLFrameSetElement::ParseRowCol(const nsAttrValue& aValue,
}
}
- // 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;
@@ -259,7 +247,7 @@ nsresult HTMLFrameSetElement::ParseRowCol(const nsAttrValue& aValue,
}
}
- aNumSpecs = count;
+ aNumSpecs = static_cast<int32_t>(count);
// Transfer ownership to caller here
*aSpecs = std::move(specs);