From 84a21551418e7a2601728756bf2388331be287be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 4 Apr 2020 12:39:56 +0000 Subject: [PATCH] Bug 1618678 - Make scrollbar style caching work on Android. r=heycam Differential Revision: https://phabricator.services.mozilla.com/D65915 --HG-- extra : moz-landing-system : lando --- layout/base/nsCSSFrameConstructor.cpp | 8 +++++++- toolkit/themes/mobile/global/scrollbars.css | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 3c42e392c605..33c1f4fff1a5 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -3863,7 +3863,8 @@ nsresult nsCSSFrameConstructor::GetAnonymousContent( // * when visibility or pointer-events is anything other than the initial // value; we rely on visibility and pointer-events inheriting into anonymous // content, but don't bother adding this state to the AnonymousContentKey, - // since it's not so common + // since it's not so common. Note that on android scrollbars always have + // pointer-events: none so we don't need to check for that. // // * when the medium is anything other than screen; some UA style sheet rules // apply in e.g. print medium, and will give different results from the @@ -3871,7 +3872,9 @@ nsresult nsCSSFrameConstructor::GetAnonymousContent( bool allowStyleCaching = StaticPrefs::layout_css_cached_scrollbar_styles_enabled() && aParentFrame->StyleVisibility()->mVisible == StyleVisibility::Visible && +#ifndef ANDROID aParentFrame->StyleUI()->mPointerEvents == StylePointerEvents::Auto && +#endif mPresShell->GetPresContext()->Medium() == nsGkAtoms::screen; // Compute styles for the anonymous content tree. @@ -3925,6 +3928,9 @@ nsresult nsCSSFrameConstructor::GetAnonymousContent( cachedStyles[i]->EqualForCachedAnonymousContentStyle(*cs), "cached anonymous content styles should be identical to those we " "would compute normally"); +#ifdef ANDROID + MOZ_ASSERT(cs->StyleUI()->mPointerEvents == StylePointerEvents::None); +#endif #endif Servo_SetExplicitStyle(elements[i], cachedStyles[i]); } diff --git a/toolkit/themes/mobile/global/scrollbars.css b/toolkit/themes/mobile/global/scrollbars.css index b9692f384866..224146d736ca 100644 --- a/toolkit/themes/mobile/global/scrollbars.css +++ b/toolkit/themes/mobile/global/scrollbars.css @@ -20,6 +20,13 @@ xul|scrollbar { display: block; } +/* We don't show resizers on android, so they may as well have + * pointer-events: none to simplify scrollbar caching */ +xul|resizer, +xul|scrollcorner { + pointer-events: none; +} + xul|scrollbar[orient="vertical"] { min-width: 6px; max-width: 6px;