зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1812868 - Expose scrollbar-inline-size as a chrome-only environment variable. r=mstange
After the previous patches this is rather straight-forward. Reviewed in: https://phabricator.services.mozilla.com/D168148
This commit is contained in:
Родитель
122d6ccddd
Коммит
f837a4541f
|
@ -305,6 +305,16 @@ bool Gecko_AnimationNameMayBeReferencedFromStyle(
|
|||
return aPresContext->AnimationManager()->AnimationMayBeReferenced(aName);
|
||||
}
|
||||
|
||||
float Gecko_GetScrollbarInlineSize(const nsPresContext* aPc) {
|
||||
MOZ_ASSERT(aPc);
|
||||
AutoWriteLock guard(*sServoFFILock); // We read some look&feel values.
|
||||
auto overlay = aPc->UseOverlayScrollbars() ? nsITheme::Overlay::Yes
|
||||
: nsITheme::Overlay::No;
|
||||
LayoutDeviceIntCoord size =
|
||||
aPc->Theme()->GetScrollbarSize(aPc, StyleScrollbarWidth::Auto, overlay);
|
||||
return aPc->DevPixelsToFloatCSSPixels(size);
|
||||
}
|
||||
|
||||
PseudoStyleType Gecko_GetImplementedPseudo(const Element* aElement) {
|
||||
return aElement->GetPseudoElementType();
|
||||
}
|
||||
|
|
|
@ -350,6 +350,8 @@ void Gecko_NoteAnimationOnlyDirtyElement(const mozilla::dom::Element*);
|
|||
bool Gecko_AnimationNameMayBeReferencedFromStyle(const nsPresContext*,
|
||||
nsAtom* name);
|
||||
|
||||
float Gecko_GetScrollbarInlineSize(const nsPresContext*);
|
||||
|
||||
// Incremental restyle.
|
||||
mozilla::PseudoStyleType Gecko_GetImplementedPseudo(
|
||||
const mozilla::dom::Element*);
|
||||
|
|
|
@ -78,6 +78,10 @@ fn get_content_preferred_color_scheme(device: &Device) -> VariableValue {
|
|||
})
|
||||
}
|
||||
|
||||
fn get_scrollbar_inline_size(device: &Device) -> VariableValue {
|
||||
VariableValue::pixels(device.scrollbar_inline_size().px())
|
||||
}
|
||||
|
||||
static ENVIRONMENT_VARIABLES: [EnvironmentVariable; 4] = [
|
||||
make_variable!(atom!("safe-area-inset-top"), get_safearea_inset_top),
|
||||
make_variable!(atom!("safe-area-inset-bottom"), get_safearea_inset_bottom),
|
||||
|
@ -104,7 +108,7 @@ macro_rules! lnf_int_variable {
|
|||
}};
|
||||
}
|
||||
|
||||
static CHROME_ENVIRONMENT_VARIABLES: [EnvironmentVariable; 6] = [
|
||||
static CHROME_ENVIRONMENT_VARIABLES: [EnvironmentVariable; 7] = [
|
||||
lnf_int_variable!(
|
||||
atom!("-moz-gtk-csd-titlebar-radius"),
|
||||
TitlebarRadius,
|
||||
|
@ -130,6 +134,10 @@ static CHROME_ENVIRONMENT_VARIABLES: [EnvironmentVariable; 6] = [
|
|||
atom!("-moz-content-preferred-color-scheme"),
|
||||
get_content_preferred_color_scheme
|
||||
),
|
||||
make_variable!(
|
||||
atom!("scrollbar-inline-size"),
|
||||
get_scrollbar_inline_size
|
||||
),
|
||||
];
|
||||
|
||||
impl CssEnvironment {
|
||||
|
|
|
@ -199,6 +199,18 @@ impl Device {
|
|||
unsafe { bindings::Gecko_GetBaseSize(self.document(), language.as_ptr(), generic) }
|
||||
}
|
||||
|
||||
/// Gets the size of the scrollbar in CSS pixels.
|
||||
pub fn scrollbar_inline_size(&self) -> Length {
|
||||
let pc = match self.pres_context() {
|
||||
Some(pc) => pc,
|
||||
// XXX: we could have a more reasonable default perhaps.
|
||||
None => return Length::new(0.0),
|
||||
};
|
||||
Length::new(unsafe {
|
||||
bindings::Gecko_GetScrollbarInlineSize(pc)
|
||||
})
|
||||
}
|
||||
|
||||
/// Queries font metrics
|
||||
pub fn query_font_metrics(
|
||||
&self,
|
||||
|
|
|
@ -1117,6 +1117,7 @@ STATIC_ATOMS = [
|
|||
Atom("scrollbarbutton", "scrollbarbutton"),
|
||||
Atom("scrollbarDownBottom", "scrollbar-down-bottom"),
|
||||
Atom("scrollbarDownTop", "scrollbar-down-top"),
|
||||
Atom("scrollbarInlineSize", "scrollbar-inline-size"),
|
||||
Atom("scrollbarUpBottom", "scrollbar-up-bottom"),
|
||||
Atom("scrollbarUpTop", "scrollbar-up-top"),
|
||||
Atom("scrollbox", "scrollbox"),
|
||||
|
|
Загрузка…
Ссылка в новой задаче