Skip to content
Permalink
Browse files
web-platform-tests/html/rendering/dimension-attributes.html is failin…
…g when table width is set to 0px

https://bugs.webkit.org/show_bug.cgi?id=235267

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

* web-platform-tests/html/rendering/dimension-attributes-expected.txt:

Source/WebCore:

This patch is based on the following Blink commit:
  https://chromium-review.googlesource.com/c/chromium/src/+/2458587

This only applies to width (not height) - see:
  https://wpt.fyi/results/html/rendering/dimension-attributes.html?label=master&label=experimental&aligned&q=dimension-attributes

See also: https://drafts.csswg.org/css-tables-3/#mapping

* html/HTMLElement.cpp:
(WebCore::HTMLElement::addHTMLLengthToStyle):
* html/HTMLElement.h:
* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::collectPresentationalHintsForAttribute):



Canonical link: https://commits.webkit.org/246081@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288061 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Jan 15, 2022
1 parent 40c2537 commit 84d2f199bf3bc58e92bd7c165a8854c20a6d3090
Showing 6 changed files with 41 additions and 10 deletions.
@@ -1,3 +1,12 @@
2022-01-15 Alan Bujtas <zalan@apple.com>

web-platform-tests/html/rendering/dimension-attributes.html is failing when table width is set to 0px
https://bugs.webkit.org/show_bug.cgi?id=235267

Reviewed by Antti Koivisto.

* web-platform-tests/html/rendering/dimension-attributes-expected.txt:

2022-01-14 Antoine Quint <graouts@webkit.org>

Setting `content: normal` on a ::marker should make computed style return resolved values
@@ -716,9 +716,9 @@ PASS <table width=".%"> mapping to width
PASS <table width=".x"> mapping to width
PASS <table width=".5"> mapping to width
PASS <table width=".5%"> mapping to width
FAIL <table width="0"> mapping to width assert_equals: expected "auto" but got "0px"
FAIL <table width="0%"> mapping to width assert_equals: expected "auto" but got "0%"
FAIL <table width="0px"> mapping to width assert_equals: expected "auto" but got "0px"
PASS <table width="0"> mapping to width
PASS <table width="0%"> mapping to width
PASS <table width="0px"> mapping to width
PASS <table height="200"> mapping to height
PASS <table height="1007"> mapping to height
PASS <table height=" 00523 "> mapping to height
@@ -1,3 +1,24 @@
2022-01-15 Alan Bujtas <zalan@apple.com>

web-platform-tests/html/rendering/dimension-attributes.html is failing when table width is set to 0px
https://bugs.webkit.org/show_bug.cgi?id=235267

Reviewed by Antti Koivisto.

This patch is based on the following Blink commit:
https://chromium-review.googlesource.com/c/chromium/src/+/2458587

This only applies to width (not height) - see:
https://wpt.fyi/results/html/rendering/dimension-attributes.html?label=master&label=experimental&aligned&q=dimension-attributes

See also: https://drafts.csswg.org/css-tables-3/#mapping

* html/HTMLElement.cpp:
(WebCore::HTMLElement::addHTMLLengthToStyle):
* html/HTMLElement.h:
* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::collectPresentationalHintsForAttribute):

2022-01-15 Simon Fraser <simon.fraser@apple.com>

Share some code that looks at visibility in order to short-circuit repaint rect computation
@@ -892,10 +892,10 @@ void HTMLElement::adjustDirectionalityIfNeededAfterChildrenChanged(Element* befo
}
}

void HTMLElement::addHTMLLengthToStyle(MutableStyleProperties& style, CSSPropertyID propertyID, StringView value, AllowPercentage allowPercentage, UseCSSPXAsUnitType useCSSPX, IsMultiLength isMultiLength)
void HTMLElement::addHTMLLengthToStyle(MutableStyleProperties& style, CSSPropertyID propertyID, StringView value, AllowPercentage allowPercentage, UseCSSPXAsUnitType useCSSPX, IsMultiLength isMultiLength, AllowZeroValue allowZeroValue)
{
auto dimensionValue = isMultiLength == IsMultiLength::No ? parseHTMLDimension(value) : parseHTMLMultiLength(value);
if (!dimensionValue)
if (!dimensionValue || (!dimensionValue->number && allowZeroValue == AllowZeroValue::No))
return;
if (dimensionValue->type == HTMLDimension::Type::Percentage) {
if (allowPercentage == AllowPercentage::Yes)
@@ -909,9 +909,9 @@ void HTMLElement::addHTMLLengthToStyle(MutableStyleProperties& style, CSSPropert
}

// https://www.w3.org/TR/html4/sgml/dtd.html#Length, including pixel and percentage values.
void HTMLElement::addHTMLLengthToStyle(MutableStyleProperties& style, CSSPropertyID propertyID, StringView value)
void HTMLElement::addHTMLLengthToStyle(MutableStyleProperties& style, CSSPropertyID propertyID, StringView value, AllowZeroValue allowZeroValue)
{
addHTMLLengthToStyle(style, propertyID, value, AllowPercentage::Yes, UseCSSPXAsUnitType::Yes, IsMultiLength::No);
addHTMLLengthToStyle(style, propertyID, value, AllowPercentage::Yes, UseCSSPXAsUnitType::Yes, IsMultiLength::No, allowZeroValue);
}

// https://www.w3.org/TR/html4/sgml/dtd.html#MultiLength, including pixel, percentage, and relative values.
@@ -140,7 +140,8 @@ class HTMLElement : public StyledElement {
protected:
HTMLElement(const QualifiedName& tagName, Document&, ConstructionType);

void addHTMLLengthToStyle(MutableStyleProperties&, CSSPropertyID, StringView value);
enum class AllowZeroValue : bool { No, Yes };
void addHTMLLengthToStyle(MutableStyleProperties&, CSSPropertyID, StringView value, AllowZeroValue = AllowZeroValue::Yes);
void addHTMLMultiLengthToStyle(MutableStyleProperties&, CSSPropertyID, StringView value);
void addHTMLPixelsToStyle(MutableStyleProperties&, CSSPropertyID, StringView value);
void addHTMLNumberToStyle(MutableStyleProperties&, CSSPropertyID, StringView value);
@@ -177,7 +178,7 @@ class HTMLElement : public StyledElement {
enum class AllowPercentage : bool { No, Yes };
enum class UseCSSPXAsUnitType : bool { No, Yes };
enum class IsMultiLength : bool { No, Yes };
void addHTMLLengthToStyle(MutableStyleProperties&, CSSPropertyID, StringView value, AllowPercentage, UseCSSPXAsUnitType, IsMultiLength);
void addHTMLLengthToStyle(MutableStyleProperties&, CSSPropertyID, StringView value, AllowPercentage, UseCSSPXAsUnitType, IsMultiLength, AllowZeroValue = AllowZeroValue::Yes);
};

inline HTMLElement::HTMLElement(const QualifiedName& tagName, Document& document, ConstructionType type = CreateHTMLElement)
@@ -307,7 +307,7 @@ static bool getBordersFromFrameAttributeValue(const AtomString& value, bool& bor
void HTMLTableElement::collectPresentationalHintsForAttribute(const QualifiedName& name, const AtomString& value, MutableStyleProperties& style)
{
if (name == widthAttr)
addHTMLLengthToStyle(style, CSSPropertyWidth, value);
addHTMLLengthToStyle(style, CSSPropertyWidth, value, AllowZeroValue::No);
else if (name == heightAttr)
addHTMLLengthToStyle(style, CSSPropertyHeight, value);
else if (name == borderAttr)

0 comments on commit 84d2f19

Please sign in to comment.