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

Pseudo element build flow and box #1496

Closed

Rebase PR

  • Loading branch information
parkjaeman authored and sammykim committed Feb 10, 2014
commit 49dff11d4ac03ae2eb6cc3c70db8abd4cb3506bc
@@ -31,10 +31,9 @@ use layout::flow::{Flow, FlowLeafSet, ImmutableFlowUtils, MutableOwnedFlowUtils}
use layout::inline::InlineFlow;
use layout::text::TextRunScanner;
use layout::util::{LayoutDataAccess, OpaqueNode};
use layout::wrapper::{PostorderNodeMutTraversal, TLayoutNode, ThreadSafeLayoutNode};
use layout::util::PrivateLayoutData;
use layout::wrapper::{LayoutNode, PostorderNodeMutTraversal};
use layout::wrapper::{LayoutPseudoNode};
use layout::wrapper::{PostorderNodeMutTraversal, TLayoutNode, ThreadSafeLayoutNode};
use layout::wrapper::LayoutPseudoNode;
use layout::extra::LayoutAuxMethods;

use gfx::font_context::FontContext;
@@ -627,8 +626,8 @@ impl<'fc> FlowConstructor<'fc> {
}
}

fn build_flow_or_boxes_for_pseudo_element(&mut self, node: LayoutNode, pseudo_element: PseudoElement) {
let p = node.parent_node().expect("Text node should have its parent");
fn build_flow_or_boxes_for_pseudo_element(&mut self, node: ThreadSafeLayoutNode, pseudo_element: PseudoElement) {
let p = unsafe { node.parent_node().expect("Text node should have its parent") };
let mut content = ~"";

// Create pseudo parent_node
@@ -641,10 +640,12 @@ impl<'fc> FlowConstructor<'fc> {

// Create layout data for pseudo parent node
let layout_data_ref = p.borrow_layout_data();
let pseudo_parent_ldw = layout_data_ref.get().get_ref();
let pseudo_parent_ldw = layout_data_ref.get().get_ref();

match pseudo_parent_ldw.chan {
Some(ref chan) => pseudo_parent_node.initialize_layout_data(chan.clone()),
Some(ref chan) => {
ThreadSafeLayoutNode::to_pseudo_layout_node(pseudo_parent_node).initialize_layout_data(chan.clone());
}
None => {}
}

@@ -669,12 +670,16 @@ impl<'fc> FlowConstructor<'fc> {

match pseudo_child_ldw.chan {
Some(ref chan) => {
pseudo_node.initialize_layout_data(chan.clone());
ThreadSafeLayoutNode::to_pseudo_layout_node(pseudo_node).initialize_layout_data(chan.clone());
}
None => {}
}

insert_layout_data(&pseudo_node, ~PrivateLayoutData::new());
if pseudo_element == Before {
insert_layout_data(&pseudo_node, ~PrivateLayoutData::new_with_style(pseudo_parent_ldw.data.before_style.clone()));
} else if pseudo_element == After {
insert_layout_data(&pseudo_node, ~PrivateLayoutData::new_with_style(pseudo_parent_ldw.data.after_style.clone()));
}

// Store pseudo_parent_node & pseudo_node in node
if pseudo_element == Before {
@@ -684,7 +689,7 @@ impl<'fc> FlowConstructor<'fc> {
pseudo_child_ldw.data.after_parent_node = Some(LayoutPseudoNode::from_layout_pseudo(pseudo_parent_abstract_node, pseudo_parent_display));
pseudo_child_ldw.data.after_node = Some(LayoutPseudoNode::from_layout_pseudo(pseudo_abstract_node, display::none));
}

// Set relation between pseudo_node and pseudo_parent_node
pseudo_parent_node.set_first_child(&mut pseudo_node);
pseudo_node.set_parent_node(&mut pseudo_parent_node);
@@ -934,7 +939,7 @@ fn strip_ignorable_whitespace_from_end(opt_boxes: &mut Option<~[Box]>) {
}
}

fn insert_layout_data(node: &LayoutNode, new_layout_data: ~PrivateLayoutData) {
fn insert_layout_data(node: &ThreadSafeLayoutNode, new_layout_data: ~PrivateLayoutData) {
let mut layout_data = node.mutate_layout_data();
match *layout_data.get() {
Some(ref mut layout_data_wrapper) => layout_data_wrapper.data = new_layout_data,
@@ -180,14 +180,15 @@ impl PrivateLayoutData {
after_node: None,
restyle_damage: None,
flow_construction_result: NoConstructionResult,
parallel: DomParallelInfo::new(),
}
}

pub fn new_with_style(style: Option<Arc<ComputedValues>>) -> PrivateLayoutData {
PrivateLayoutData {
applicable_declarations: ~[],
before_applicable_declarations: ~[],
after_applicable_declarations: ~[],
applicable_declarations: SmallVec16::new(),
before_applicable_declarations: SmallVec0::new(),
after_applicable_declarations: SmallVec0::new(),
before_style: None,
style: style,
after_style: None,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.