Skip to content

Commit 381ad0c

Browse files
committed
Adjust Quirks for hotels.com to remove the flickering
https://bugs.webkit.org/show_bug.cgi?id=308116 rdar://170331800 Reviewed by Brandon Stewart, Antoine Quint, and Sam Weinig. The previous quirk stopped working, but the markup and CSS do not seem to have changed at all. This is another strategy to make it work. The flickering doesn't happen. * LayoutTests/fast/css/hotels-animation-quirk.html: Added Test for making sure any future changes will not break this quirk. * LayoutTests/fast/css/hotels-animation-quirk-expected.txt: Added. * Source/WebCore/page/Quirks.cpp: (WebCore::Quirks::needsHotelsAnimationQuirk const): * Source/WebCore/style/StyleAdjuster.cpp: (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const): Canonical link: https://commits.webkit.org/308678@main
1 parent d9b3841 commit 381ad0c

File tree

3 files changed

+65
-2
lines changed

3 files changed

+65
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
PASS hotels.com animation quirk overrides animation:none for the menu container element
3+
PASS hotels.com animation quirk sets correct animation-delay and animation-duration
4+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!DOCTYPE html>
2+
<!-- Test for hotels.com animation quirk (https://webkit.org/b/308116)
3+
The quirk restores menu-grow-left and menu-fade-in animations for elements
4+
matching .uitk-menu-mounted .uitk-menu-container.uitk-menu-container-autoposition.uitk-menu-container-has-intersection-root-el
5+
which otherwise receive animation:none from a @supports (-webkit-hyphens:none) block on the real site. -->
6+
<head>
7+
<script src="../../resources/testharness.js"></script>
8+
<script src="../../resources/testharnessreport.js"></script>
9+
</head>
10+
<style>
11+
/* Mirrors the relevant hotels.com CSS that this quirk is meant to fix.
12+
The real site uses @supports (-webkit-hyphens:none) and (stroke-color:transparent)
13+
to set animation:none on Safari, overriding the intended open-menu animations. */
14+
.uitk-menu-mounted .uitk-menu-container.uitk-menu-container-autoposition.uitk-menu-container-has-intersection-root-el {
15+
animation: none;
16+
}
17+
</style>
18+
<body>
19+
<!-- Minimal DOM structure matching the hotels.com menu, per the quirk's CSS selector -->
20+
<div class="uitk-menu-mounted">
21+
<div id="target" class="uitk-menu-container uitk-menu-container-autoposition uitk-menu-container-has-intersection-root-el"></div>
22+
</div>
23+
<script>
24+
"use strict";
25+
26+
if (window.internals)
27+
window.internals.setTopDocumentURLForQuirks("https://www.hotels.com");
28+
29+
test(function() {
30+
assert_true(!!window.internals, "This test requires window.internals");
31+
32+
const target = document.getElementById("target");
33+
const animations = getComputedStyle(target).animationName;
34+
// Without the quirk, the element would have animationName "none" due to the CSS above.
35+
// With the quirk, WebCore overrides the computed style to apply the two named animations.
36+
assert_not_equals(animations, "none", "animation:none should be overridden by the quirk");
37+
assert_true(animations.includes("menu-grow-left"), "quirk should apply menu-grow-left animation");
38+
assert_true(animations.includes("menu-fade-in"), "quirk should apply menu-fade-in animation");
39+
}, "hotels.com animation quirk overrides animation:none for the menu container element");
40+
41+
test(function() {
42+
assert_true(!!window.internals, "This test requires window.internals");
43+
44+
const target = document.getElementById("target");
45+
const style = getComputedStyle(target);
46+
// animation-delay: 0s for menu-grow-left, 0.06s for menu-fade-in
47+
const delays = style.animationDelay;
48+
assert_true(delays.includes("0s") || delays.includes("0.06s"),
49+
"quirk should set correct animation delays (0s, 0.06s); got: " + delays);
50+
// animation-duration: 0.18s for menu-grow-left, 0.06s for menu-fade-in
51+
const durations = style.animationDuration;
52+
assert_true(durations.includes("0.18s") || durations.includes("0.06s"),
53+
"quirk should set correct animation durations (0.18s, 0.06s); got: " + durations);
54+
}, "hotels.com animation quirk sets correct animation-delay and animation-duration");
55+
</script>
56+
</body>
57+
</html>

Source/WebCore/style/StyleAdjuster.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,16 +1064,18 @@ void Adjuster::adjustForSiteSpecificQuirks(RenderStyle& style) const
10641064
// animation-fill-mode: none, forwards;
10651065
// animation-name: menu-grow-left, menu-fade-in;
10661066
auto menuGrowLeftAnimation = Style::Animation { { ScopedName { "menu-grow-left"_s } } };
1067+
menuGrowLeftAnimation.setDelay(0_css_s);
10671068
menuGrowLeftAnimation.setDuration(.18_css_s);
1069+
menuGrowLeftAnimation.setFillMode(AnimationFillMode::None);
10681070

10691071
auto menuFadeInAnimation = Style::Animation { { ScopedName { "menu-fade-in"_s } } };
10701072
menuFadeInAnimation.setDelay(.06_css_s);
10711073
menuFadeInAnimation.setDuration(.06_css_s);
10721074
menuFadeInAnimation.setFillMode(AnimationFillMode::Forwards);
10731075

10741076
auto& animations = style.ensureAnimations();
1075-
animations.append(WTF::move(menuGrowLeftAnimation));
1076-
animations.append(WTF::move(menuFadeInAnimation));
1077+
animations = Style::Animations { WTF::move(menuGrowLeftAnimation), WTF::move(menuFadeInAnimation) };
1078+
animations.prepareForUse();
10771079
}
10781080

10791081
#if PLATFORM(IOS_FAMILY)

0 commit comments

Comments
 (0)