Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
'hr' with width as 0 or 0px get 1px
https://bugs.webkit.org/show_bug.cgi?id=259620

Reviewed by Simon Fraser.

Prior to this patch, WebKit used to return 1px as width length even if it is
configured as `hr width=0` or `hr width=0px`, which is not correct. Only
Gecko / Firefox, return expected '0' properly. This patch will align WebKit
with Gecko / Firefox and correctly return 0px for above cases.

* Source/WebCore/html/HTMLHRElement.cpp:
(HTMLHRElement::collectPresentationalHintsForAttribute): For 'widthAttr' return 0px instead of 1px
* LayoutTests/imported/w3c/web-platform-tests/html/rendering/dimension-attributes-expected.txt: Rebaselined

Canonical link: https://commits.webkit.org/266418@main
  • Loading branch information
Ahmad-S792 authored and Ahmad Saleem committed Jul 29, 2023
1 parent 5290364 commit 57717fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Expand Up @@ -15,11 +15,11 @@ PASS <hr width="200.25%"> mapping to width
PASS <hr width="200.%"> mapping to width
PASS <hr width="20.25e2"> mapping to width
PASS <hr width="20.25E2"> mapping to width
FAIL <hr width="0"> mapping to width assert_equals: expected "0px" but got "1px"
FAIL <hr width="0%"> mapping to width assert_equals: expected "0%" but got "1px"
FAIL <hr width="0px"> mapping to width assert_equals: expected "0px" but got "1px"
FAIL <hr width="-0"> mapping to width assert_equals: expected "auto" but got "1px"
FAIL <hr width="-0%"> mapping to width assert_equals: expected "auto" but got "1px"
PASS <hr width="0"> mapping to width
FAIL <hr width="0%"> mapping to width assert_equals: expected "0%" but got "0px"
PASS <hr width="0px"> mapping to width
FAIL <hr width="-0"> mapping to width assert_equals: expected "auto" but got "0px"
FAIL <hr width="-0%"> mapping to width assert_equals: expected "auto" but got "0px"
PASS <hr width="-200"> mapping to width
PASS <hr width="-200px"> mapping to width
PASS <hr width=" -200"> mapping to width
Expand All @@ -32,8 +32,8 @@ PASS <hr width=" +200.25in "> mapping to width
PASS <hr width="+200%"> mapping to width
PASS <hr width=" +200.25% "> mapping to width
PASS <hr width=" +200.25%abc"> mapping to width
FAIL <hr width="+0"> mapping to width assert_equals: expected "auto" but got "1px"
FAIL <hr width="+0%"> mapping to width assert_equals: expected "auto" but got "1px"
FAIL <hr width="+0"> mapping to width assert_equals: expected "auto" but got "0px"
FAIL <hr width="+0%"> mapping to width assert_equals: expected "auto" but got "0px"
PASS <hr width="."> mapping to width
PASS <hr width=".%"> mapping to width
PASS <hr width=".x"> mapping to width
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/html/HTMLHRElement.cpp
Expand Up @@ -86,7 +86,7 @@ void HTMLHRElement::collectPresentationalHintsForAttribute(const QualifiedName&
break;
case AttributeNames::widthAttr:
if (auto valueInteger = parseHTMLInteger(value); valueInteger && !*valueInteger)
addPropertyToPresentationalHintStyle(style, CSSPropertyWidth, 1, CSSUnitType::CSS_PX);
addPropertyToPresentationalHintStyle(style, CSSPropertyWidth, 0, CSSUnitType::CSS_PX);
else
addHTMLLengthToStyle(style, CSSPropertyWidth, value);
break;
Expand Down

0 comments on commit 57717fd

Please sign in to comment.