Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of layout queries and requestAnimationFrame #15816

Merged
merged 2 commits into from Mar 5, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

layout: Replace ConstructionResult::swap_out() with get()

It only actually swaps out in nonincremental mode (which isn't suitable
for real world use), so the name is confusing.
  • Loading branch information
pcwalton authored and nox committed Mar 3, 2017
commit 198662f8cbbffa53de5a9d036a77934a36102134
@@ -84,11 +84,7 @@ pub enum ConstructionResult {
}

impl ConstructionResult {
pub fn swap_out(&mut self) -> ConstructionResult {
if opts::get().nonincremental_layout {
return mem::replace(self, ConstructionResult::None)
}

pub fn get(&mut self) -> ConstructionResult {
// FIXME(pcwalton): Stop doing this with inline fragments. Cloning fragments is very
// inefficient!
(*self).clone()
@@ -485,7 +481,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
inline_fragment_accumulator: &mut InlineFragmentsAccumulator,
abs_descendants: &mut AbsoluteDescendants,
legalizer: &mut Legalizer) {
match kid.swap_out_construction_result() {
match kid.get_construction_result() {
ConstructionResult::None => {}
ConstructionResult::Flow(kid_flow, kid_abs_descendants) => {
// If kid_flow is TableCaptionFlow, kid_flow should be added under
@@ -784,7 +780,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
if kid.get_pseudo_element_type() != PseudoElementType::Normal {
self.process(&kid);
}
match kid.swap_out_construction_result() {
match kid.get_construction_result() {
ConstructionResult::None => {}
ConstructionResult::Flow(flow, kid_abs_descendants) => {
if !flow::base(&*flow).flags.contains(IS_ABSOLUTELY_POSITIONED) {
@@ -1035,7 +1031,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
side: caption_side::T) {
// Only flows that are table captions are matched here.
for kid in node.children() {
match kid.swap_out_construction_result() {
match kid.get_construction_result() {
ConstructionResult::Flow(kid_flow, _) => {
if kid_flow.is_table_caption() &&
kid_flow.as_block()
@@ -1304,7 +1300,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
// CSS 2.1 § 17.2.1. Treat all non-column child fragments of `table-column-group`
// as `display: none`.
if let ConstructionResult::ConstructionItem(ConstructionItem::TableColumnFragment(fragment)) =
kid.swap_out_construction_result() {
kid.get_construction_result() {
col_fragments.push(fragment)
}
}
@@ -1641,9 +1637,8 @@ trait NodeUtils {
/// Sets the construction result of a flow.
fn set_flow_construction_result(self, result: ConstructionResult);

/// Replaces the flow construction result in a node with `ConstructionResult::None` and returns
/// the old value.
fn swap_out_construction_result(self) -> ConstructionResult;
/// Returns the construction result for this node.
fn get_construction_result(self) -> ConstructionResult;
}

impl<ConcreteThreadSafeLayoutNode> NodeUtils for ConcreteThreadSafeLayoutNode
@@ -1686,9 +1681,9 @@ impl<ConcreteThreadSafeLayoutNode> NodeUtils for ConcreteThreadSafeLayoutNode
}

#[inline(always)]
fn swap_out_construction_result(self) -> ConstructionResult {
fn get_construction_result(self) -> ConstructionResult {
let mut layout_data = self.mutate_layout_data().unwrap();
self.construction_result_mut(&mut *layout_data).swap_out()
self.construction_result_mut(&mut *layout_data).get()
}
}

@@ -774,7 +774,7 @@ impl LayoutThread {
Some(x) => x,
None => return None,
};
let result = data.flow_construction_result.swap_out();
let result = data.flow_construction_result.get();

let mut flow = match result {
ConstructionResult::Flow(mut flow, abs_descendants) => {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.