Skip to content
Permalink
Browse files
[CSS-Typed-OM] Make sure orphans & widows value gets clamped to […
…1, inf]

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

Reviewed by Alan Baradlay.

Make sure `orphans` & `widows` value gets clamped to [1, inf], as per:
- https://w3c.github.io/csswg-drafts/css-break/#widows-orphans

* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/orphans-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/widows-expected.txt:
* Source/WebCore/rendering/style/RenderStyle.h:
(WebCore::RenderStyle::setWidows):
(WebCore::RenderStyle::setOrphans):

Canonical link: https://commits.webkit.org/258243@main
  • Loading branch information
cdumez committed Dec 22, 2022
1 parent add3c91 commit fffeff450095e2a4ee3fd22e7461c062a72c117f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
@@ -4,8 +4,8 @@ PASS Can set 'orphans' to CSS-wide keywords: inherit
PASS Can set 'orphans' to CSS-wide keywords: unset
PASS Can set 'orphans' to CSS-wide keywords: revert
PASS Can set 'orphans' to var() references: var(--A)
FAIL Can set 'orphans' to a number: 0 assert_approx_equals: expected 1 +/- 0.000001 but got 0
FAIL Can set 'orphans' to a number: -3.14 assert_approx_equals: expected 1 +/- 0.000001 but got 0
PASS Can set 'orphans' to a number: 0
PASS Can set 'orphans' to a number: -3.14
PASS Can set 'orphans' to a number: 3.14
PASS Can set 'orphans' to a number: calc(2 + 3)
PASS Setting 'orphans' to a length: 0px throws TypeError
@@ -4,8 +4,8 @@ PASS Can set 'widows' to CSS-wide keywords: inherit
PASS Can set 'widows' to CSS-wide keywords: unset
PASS Can set 'widows' to CSS-wide keywords: revert
PASS Can set 'widows' to var() references: var(--A)
FAIL Can set 'widows' to a number: 0 assert_approx_equals: expected 1 +/- 0.000001 but got 0
FAIL Can set 'widows' to a number: -3.14 assert_approx_equals: expected 1 +/- 0.000001 but got 0
PASS Can set 'widows' to a number: 0
PASS Can set 'widows' to a number: -3.14
PASS Can set 'widows' to a number: 3.14
PASS Can set 'widows' to a number: calc(2 + 3)
PASS Setting 'widows' to a length: 0px throws TypeError
@@ -1205,10 +1205,10 @@ class RenderStyle {
}

void setHasAutoWidows() { SET_VAR(m_rareInheritedData, hasAutoWidows, true); SET_VAR(m_rareInheritedData, widows, initialWidows()); }
void setWidows(unsigned short w) { SET_VAR(m_rareInheritedData, hasAutoWidows, false); SET_VAR(m_rareInheritedData, widows, w); }
void setWidows(unsigned short w) { SET_VAR(m_rareInheritedData, hasAutoWidows, false); SET_VAR(m_rareInheritedData, widows, std::max<unsigned short>(w, 1)); }

void setHasAutoOrphans() { SET_VAR(m_rareInheritedData, hasAutoOrphans, true); SET_VAR(m_rareInheritedData, orphans, initialOrphans()); }
void setOrphans(unsigned short o) { SET_VAR(m_rareInheritedData, hasAutoOrphans, false); SET_VAR(m_rareInheritedData, orphans, o); }
void setOrphans(unsigned short o) { SET_VAR(m_rareInheritedData, hasAutoOrphans, false); SET_VAR(m_rareInheritedData, orphans, std::max<unsigned short>(o, 1)); }

// CSS3 Setters
void setOutlineOffset(float v) { SET_VAR(m_backgroundData, outline.m_offset, v); }

0 comments on commit fffeff4

Please sign in to comment.