Skip to content

Commit

Permalink
Remove 'presentational hints' from width attribute for <hr>
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=274605

Reviewed by Ryosuke Niwa.

This patch aligns WebKit with Gecko / Firefox and web specification [1]:

[1] https://html.spec.whatwg.org/#the-hr-element-2

"The width attribute on an hr element maps to the dimension property 'width' on the element."

As per above, there should not be any presentational hints'. Hence, this
patch removes them from WebKit's codebase.

* Source/WebCore/html/HTMLHRElement.cpp:
(WebCore::HTMLHRElement::collectPresentationalHintsForAttribute):
* LayoutTests/imported/w3c/web-platform-tests/html/rendering/dimension-attributes-expected.txt: Rebaseline

Canonical link: https://commits.webkit.org/279245@main
  • Loading branch information
Ahmad Saleem committed May 24, 2024
1 parent 26ef083 commit fe5976c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ PASS <hr width="200.%"> mapping to width
PASS <hr width="20.25e2"> mapping to width
PASS <hr width="20.25E2"> mapping to width
PASS <hr width="0"> mapping to width
FAIL <hr width="0%"> mapping to width assert_equals: expected "0%" but got "0px"
PASS <hr width="0%"> mapping to width
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="-0"> mapping to width
PASS <hr width="-0%"> mapping to width
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 "0px"
FAIL <hr width="+0%"> mapping to width assert_equals: expected "auto" but got "0px"
PASS <hr width="+0"> mapping to width
PASS <hr width="+0%"> mapping to width
PASS <hr width="."> mapping to width
PASS <hr width=".%"> mapping to width
PASS <hr width=".x"> mapping to width
Expand Down
7 changes: 2 additions & 5 deletions Source/WebCore/html/HTMLHRElement.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2003, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2003-2024 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
Expand Down Expand Up @@ -85,10 +85,7 @@ void HTMLHRElement::collectPresentationalHintsForAttribute(const QualifiedName&
}
break;
case AttributeNames::widthAttr:
if (auto valueInteger = parseHTMLInteger(value); valueInteger && !*valueInteger)
addPropertyToPresentationalHintStyle(style, CSSPropertyWidth, 0, CSSUnitType::CSS_PX);
else
addHTMLLengthToStyle(style, CSSPropertyWidth, value);
addHTMLLengthToStyle(style, CSSPropertyWidth, value);
break;
case AttributeNames::colorAttr:
addPropertyToPresentationalHintStyle(style, CSSPropertyBorderStyle, CSSValueSolid);
Expand Down

0 comments on commit fe5976c

Please sign in to comment.