Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
1 parent c32181c commit 198662f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
23 changes: 9 additions & 14 deletions components/layout/construct.rs
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/layout_thread/lib.rs
Expand Up @@ -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) => {
Expand Down

0 comments on commit 198662f

Please sign in to comment.