Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3a7fd86e2a6810aa8376d1de3703dcd6e63195a1
https://github.com/WebKit/WebKit/commit/3a7fd86e2a6810aa8376d1de3703dcd6e63195a1
Author: Ahmad Saleem <ahmad.saleem792+git...@gmail.com>
Date: 2026-03-02 (Mon, 02 Mar 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/html/rendering/pixel-length-attributes-expected.txt
R
LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/rendering/pixel-length-attributes-expected.txt
M Source/WebCore/html/HTMLAttributeNames.in
M Source/WebCore/html/HTMLBodyElement.cpp
M Source/WebCore/html/HTMLElement.cpp
M Source/WebCore/html/HTMLElement.h
M Source/WebCore/html/HTMLFrameElementBase.cpp
Log Message:
-----------
<body> and <iframe>/<frame> pixel-length margin attributes parsed incorrectly
https://bugs.webkit.org/show_bug.cgi?id=308708
rdar://171240848
Reviewed by Ryosuke Niwa.
The HTML spec defines "maps to the pixel length property" using the
rules for parsing non-negative integers, not the rules for parsing
dimension values.
Previously, `addHTMLLengthToStyle` (which uses `parseHTMLDimension`)
was used for `marginwidth`, `marginheight`, `leftmargin`, `topmargin`,
`rightmargin`, and `bottommargin` on `<body>`. This incorrectly accepted
fractional values ("200.25" → "200.25px"), percentage values ("200%" →
"200%"), and the `+` prefix ("+200" → "200px"). Non-negative integer
parsing rejects all of these.
Additionally, `rightmargin` and `bottommargin` on `<body>` were entirely
unimplemented: missing from `HTMLAttributeNames.in`,
`hasPresentationalHintsForAttribute`, and
`collectPresentationalHintsForAttribute`. The spec requires:
"For each property in the table below, given a body element, the
first attribute that exists maps to the pixel length property on
the body element. If none of the attributes for a property are
found, or if the value of the attribute that was found cannot be
parsed successfully, then a default value of 8px is expected to
be used for that property instead."
— https://html.spec.whatwg.org/multipage/rendering.html#the-body-element-2
Also, `marginwidth`/`marginheight` changes on `<iframe>`/`<frame>` after
insertion were not propagated to the content document's `<body>`.
Fix by introducing `HTMLElement::addHTMLPixelLengthToStyle` which uses
`parseHTMLNonNegativeInteger`, adding `rightmargin`/`bottommargin` to
the attribute registry and presentational hint pipeline, and propagating
`marginwidth`/`marginheight` attribute changes dynamically in
`HTMLFrameElementBase::attributeChanged`.
* Source/WebCore/html/HTMLAttributeNames.in:
* Source/WebCore/html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::hasPresentationalHintsForAttribute const):
(WebCore::HTMLBodyElement::collectPresentationalHintsForAttribute):
* Source/WebCore/html/HTMLElement.cpp:
(WebCore::HTMLElement::addHTMLPixelLengthToStyle):
* Source/WebCore/html/HTMLElement.h:
* Source/WebCore/html/HTMLFrameElementBase.cpp:
(WebCore::HTMLFrameElementBase::attributeChanged):
*
LayoutTests/imported/w3c/web-platform-tests/html/rendering/pixel-length-attributes-expected.txt:
Progression
*
LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/rendering/pixel-length-attributes-expected.txt:
Removed.
Canonical link: https://commits.webkit.org/308526@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications