Bug 1336646 - Use the bloom filter for manual style resolves and pass a mutable StyleContext into match_element. r=emilio

We need to do something here to avoid a double-borrow when passing a mutable
StyleContext to match_element. After some discussion on IRC, we decided that
building the bloom filter for this case is probably worthwhile.
This commit is contained in:
Bobby Holley 2017-02-06 12:57:25 -08:00
parent 8aec1ccdd2
commit e7a8f5ec30
3 changed files with 35 additions and 15 deletions

View file

@ -66,7 +66,7 @@ impl<E: TElement> StyleBloom<E> {
/// Push an element to the bloom filter, knowing that it's a child of the
/// last element parent.
fn push(&mut self, element: E) {
pub fn push(&mut self, element: E) {
if cfg!(debug_assertions) {
if self.elements.is_empty() {
assert!(element.parent_element().is_none());
@ -86,12 +86,20 @@ impl<E: TElement> StyleBloom<E> {
popped
}
fn clear(&mut self) {
/// Returns true if the bloom filter is empty.
pub fn is_empty(&self) -> bool {
self.elements.is_empty()
}
/// Clears the bloom filter.
pub fn clear(&mut self) {
self.filter.clear();
self.elements.clear();
}
fn rebuild(&mut self, mut element: E) -> usize {
/// Rebuilds the bloom filter up to the parent of the given element.
pub fn rebuild(&mut self, mut element: E) -> usize {
self.clear();
while let Some(parent) = element.parent_element() {