Adding in style_unchecked and style_unchecked_signal methods
This commit is contained in:
parent
c87c6018bf
commit
29083bf288
92
src/dom.rs
92
src/dom.rs
|
@ -368,6 +368,33 @@ fn set_style_signal<A, B, C, D>(style: CssStyleDeclaration, callbacks: &mut Call
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO should this inline ?
|
||||||
|
fn set_style_unchecked_signal<A, B, C, D>(style: CssStyleDeclaration, callbacks: &mut Callbacks, name: A, value: D, important: bool)
|
||||||
|
where A: AsStr + 'static,
|
||||||
|
B: AsStr,
|
||||||
|
C: OptionStr<Output = B>,
|
||||||
|
D: Signal<Item = C> + 'static {
|
||||||
|
|
||||||
|
set_option(style, callbacks, value, move |style, value| {
|
||||||
|
match value {
|
||||||
|
Some(value) => {
|
||||||
|
name.with_str(|name| {
|
||||||
|
let name: &str = intern(name);
|
||||||
|
|
||||||
|
value.with_str(|value| {
|
||||||
|
bindings::set_style(style, name, value, important);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
name.with_str(|name| {
|
||||||
|
bindings::remove_style(style, intern(name));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// TODO check that the property *actually* was changed ?
|
// TODO check that the property *actually* was changed ?
|
||||||
// TODO maybe use AsRef<Object> ?
|
// TODO maybe use AsRef<Object> ?
|
||||||
// TODO should this inline ?
|
// TODO should this inline ?
|
||||||
|
@ -906,6 +933,18 @@ impl<A> DomBuilder<A> where A: AsRef<HtmlElement> {
|
||||||
set_style(&self.element.as_ref().style(), &name, value, true);
|
set_style(&self.element.as_ref().style(), &name, value, true);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn style_unchecked<B, C>(self, name: B, value: C) -> Self
|
||||||
|
where B: AsStr,
|
||||||
|
C: AsStr {
|
||||||
|
name.with_str(|name| {
|
||||||
|
value.with_str(|value| {
|
||||||
|
bindings::set_style(&self.element.as_ref().style(), intern(name), value, false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A> DomBuilder<A> where A: AsRef<HtmlElement> {
|
impl<A> DomBuilder<A> where A: AsRef<HtmlElement> {
|
||||||
|
@ -931,6 +970,17 @@ impl<A> DomBuilder<A> where A: AsRef<HtmlElement> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn style_unchecked_signal<B, C, D, E>(mut self, name: B, value: E) -> Self
|
||||||
|
where B: AsStr + 'static,
|
||||||
|
C: AsStr,
|
||||||
|
D: OptionStr<Output = C>,
|
||||||
|
E: Signal<Item = D> + 'static {
|
||||||
|
|
||||||
|
set_style_unchecked_signal(self.element.as_ref().style(), &mut self.callbacks, name, value, false);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO remove the `value` argument ?
|
// TODO remove the `value` argument ?
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1051,6 +1101,18 @@ impl StylesheetBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn style_unchecked<B, C>(self, name: B, value: C) -> Self
|
||||||
|
where B: AsStr,
|
||||||
|
C: AsStr {
|
||||||
|
name.with_str(|name| {
|
||||||
|
value.with_str(|value| {
|
||||||
|
bindings::set_style(&self.element, intern(name), value, false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn style_signal<B, C, D, E>(mut self, name: B, value: E) -> Self
|
pub fn style_signal<B, C, D, E>(mut self, name: B, value: E) -> Self
|
||||||
where B: MultiStr + 'static,
|
where B: MultiStr + 'static,
|
||||||
|
@ -1073,6 +1135,17 @@ impl StylesheetBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn style_unchecked_signal<B, C, D, E>(mut self, name: B, value: E) -> Self
|
||||||
|
where B: AsStr + 'static,
|
||||||
|
C: AsStr,
|
||||||
|
D: OptionStr<Output = C>,
|
||||||
|
E: Signal<Item = D> + 'static {
|
||||||
|
|
||||||
|
set_style_unchecked_signal(self.element.clone(), &mut self.callbacks, name, value, false);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
// TODO return a Handle
|
// TODO return a Handle
|
||||||
#[inline]
|
#[inline]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
@ -1127,6 +1200,14 @@ impl ClassBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn style_unchecked<B, C>(mut self, name: B, value: C) -> Self
|
||||||
|
where B: AsStr,
|
||||||
|
C: AsStr {
|
||||||
|
self.stylesheet = self.stylesheet.style_unchecked(name, value);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn style_signal<B, C, D, E>(mut self, name: B, value: E) -> Self
|
pub fn style_signal<B, C, D, E>(mut self, name: B, value: E) -> Self
|
||||||
where B: MultiStr + 'static,
|
where B: MultiStr + 'static,
|
||||||
|
@ -1149,6 +1230,17 @@ impl ClassBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn style_unchecked_signal<B, C, D, E>(mut self, name: B, value: E) -> Self
|
||||||
|
where B: AsStr + 'static,
|
||||||
|
C: AsStr,
|
||||||
|
D: OptionStr<Output = C>,
|
||||||
|
E: Signal<Item = D> + 'static {
|
||||||
|
|
||||||
|
self.stylesheet = self.stylesheet.style_unchecked_signal(name, value);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
// TODO return a Handle ?
|
// TODO return a Handle ?
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Reference in New Issue