Skip to content

Commit

Permalink
[macOS] <input type=color> swatch is too narrow in vertical writing mode
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=264298
rdar://118023600

Reviewed by Wenson Hsieh.

On macOS, color inputs have native styling similar to buttons. Add
`StyleAppearance::ColorWell` to the allowlist of button-like controls that
have transposed metrics for vertical writing modes.

* LayoutTests/imported/w3c/web-platform-tests/css/css-writing-modes/forms/color-input-appearance-native-computed-style-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-writing-modes/forms/color-input-appearance-native-computed-style.html: Added.
* LayoutTests/platform/wpe/TestExpectations:
* Source/WebCore/rendering/RenderTheme.cpp:
(WebCore::RenderTheme::adjustStyle):

Canonical link: https://commits.webkit.org/270314@main
  • Loading branch information
pxlcoder committed Nov 7, 2023
1 parent 5145197 commit 7ebe5b8
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


PASS input[type="color"][style="writing-mode: horizontal-tb"] block size should match height and inline size should match width
PASS input[type="color"][style="writing-mode: vertical-lr"] block size should match width and inline size should match height
PASS input[type="color"][style="writing-mode: vertical-rl"] block size should match width and inline size should match height

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!doctype html>
<link rel="author" title="Aditya Keerthi" href="https://github.com/pxlcoder">
<link rel="help" href="https://html.spec.whatwg.org/#color-state-(type=color)">
<link rel="help" href="https://drafts.csswg.org/css-writing-modes/#block-flow">
<title>Color input appearance native writing mode computed style</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<input type="color" style="writing-mode: horizontal-tb">
<input type="color" style="writing-mode: vertical-lr">
<input type="color" style="writing-mode: vertical-rl">

<script>
test(() => {
const input = document.querySelector(`input[type="color"][style="writing-mode: horizontal-tb"]`);
const style = getComputedStyle(input);
const blockSize = parseInt(style.blockSize, 10);
const inlineSize = parseInt(style.inlineSize, 10);
assert_not_equals(blockSize, 0);
assert_not_equals(inlineSize, 0);
assert_greater_than_equal(inlineSize, blockSize);
assert_equals(style.blockSize, style.height);
assert_equals(style.inlineSize, style.width);
}, `input[type="color"][style="writing-mode: horizontal-tb"] block size should match height and inline size should match width`);

for (const writingMode of ["vertical-lr", "vertical-rl"]) {
test(() => {
const input = document.querySelector(`input[type="color"][style="writing-mode: ${writingMode}"]`);
const style = getComputedStyle(input);
const blockSize = parseInt(style.blockSize, 10);
const inlineSize = parseInt(style.inlineSize, 10);
assert_not_equals(blockSize, 0);
assert_not_equals(inlineSize, 0);
assert_greater_than_equal(inlineSize, blockSize);
assert_equals(style.blockSize, style.width);
assert_equals(style.inlineSize, style.height);
}, `input[type="color"][style="writing-mode: ${writingMode}"] block size should match width and inline size should match height`);
};
</script>
2 changes: 2 additions & 0 deletions LayoutTests/platform/wpe/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,8 @@ webkit.org/b/180645 accessibility/color-input-value-changes.html [ Timeout ]
webkit.org/b/180648 imported/w3c/web-platform-tests/html/semantics/text-level-semantics/the-a-element/a-download-click-404.html [ Failure ]
webkit.org/b/180648 http/wpt/html/semantics/text-level-semantics/the-a-element/a-download-click-404.html [ Failure ]

webkit.org/b/180645 imported/w3c/web-platform-tests/css/css-writing-modes/forms/color-input-appearance-native-computed-style.html [ Failure ]

webkit.org/b/127676 imported/w3c/web-platform-tests/xhr/send-redirect-bogus.htm [ Skip ]
webkit.org/b/127676 imported/w3c/web-platform-tests/xhr/send-redirect-to-cors.htm [ Skip ]
webkit.org/b/127676 imported/w3c/web-platform-tests/xhr/send-redirect-to-non-cors.htm [ Skip ]
Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/rendering/RenderTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ void RenderTheme::adjustStyle(RenderStyle& style, const Element* element, const

auto supportsVerticalWritingMode = [](StyleAppearance appearance) {
return appearance == StyleAppearance::Button
#if ENABLE(INPUT_TYPE_COLOR)
|| appearance == StyleAppearance::ColorWell
#endif
|| appearance == StyleAppearance::DefaultButton
|| appearance == StyleAppearance::SquareButton
|| appearance == StyleAppearance::PushButton;
Expand Down

0 comments on commit 7ebe5b8

Please sign in to comment.