Skip to content

Commit

Permalink
Revert changes in Flows and Fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
julienw committed Dec 1, 2016
1 parent 2b1a61c commit 3fe7d5b
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 110 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion components/layout/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ gfx = {path = "../gfx"}
gfx_traits = {path = "../gfx_traits"}
heapsize = "0.3.0"
heapsize_derive = "0.1"
html5ever = {version = "0.10.2", features = ["heap_size", "unstable"]}
html5ever-atoms = "0.1"
ipc-channel = "0.5"
libc = "0.2"
Expand Down
4 changes: 1 addition & 3 deletions components/layout/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,11 @@ impl BlockFlow {
pub fn from_fragment_and_float_kind(fragment: Fragment, float_kind: Option<FloatKind>)
-> BlockFlow {
let writing_mode = fragment.style().writing_mode;
let quirks_mode = fragment.quirks_mode();

BlockFlow {
base: BaseFlow::new(Some(fragment.style()), writing_mode, match float_kind {
Some(_) => ForceNonfloatedFlag::FloatIfNecessary,
None => ForceNonfloatedFlag::ForceNonfloated,
}, quirks_mode),
}),
fragment: fragment,
float: float_kind.map(|kind| box FloatedBlockInfo::new(kind)),
flags: BlockFlowFlags::empty(),
Expand Down
49 changes: 30 additions & 19 deletions components/layout/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ impl InlineFragmentsAccumulator {
style: node.style(style_context),
selected_style: node.selected_style(),
flags: FIRST_FRAGMENT_OF_ELEMENT | LAST_FRAGMENT_OF_ELEMENT,
quirks_mode: node.quirks_mode(),
}),
bidi_control_chars: None,
restyle_damage: node.restyle_damage(),
Expand Down Expand Up @@ -556,8 +555,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
whitespace_style,
node.selected_style(),
whitespace_damage,
fragment_info,
Some(node.quirks_mode()));
fragment_info);
inline_fragment_accumulator.fragments.fragments.push_back(fragment);
}
ConstructionResult::ConstructionItem(ConstructionItem::TableColumnFragment(_)) => {
Expand Down Expand Up @@ -687,13 +685,18 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
_ => properties::modify_style_for_text(&mut style)
}

let selected_style = node.selected_style();

match text_content {
TextContent::Text(string) => {
let info = box UnscannedTextFragmentInfo::new(string, node.selection());
let specific_fragment_info = SpecificFragmentInfo::UnscannedText(info);
fragments.fragments.push_back(Fragment::from_node_and_style(
node,
fragments.fragments.push_back(Fragment::from_opaque_node_and_style(
node.opaque(),
node.get_pseudo_element_type().strip(),
style,
selected_style,
node.restyle_damage(),
specific_fragment_info))
}
TextContent::GeneratedContent(content_items) => {
Expand All @@ -708,9 +711,12 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
SpecificFragmentInfo::GeneratedContent(content_item)
}
};
fragments.fragments.push_back(Fragment::from_node_and_style(
node,
fragments.fragments.push_back(Fragment::from_opaque_node_and_style(
node.opaque(),
node.get_pseudo_element_type().strip(),
style.clone(),
selected_style.clone(),
node.restyle_damage(),
specific_fragment_info))
}
}
Expand Down Expand Up @@ -791,8 +797,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
kid_style,
kid_selected_style,
kid_restyle_damage,
fragment_info,
Some(node.quirks_mode())));
fragment_info));
fragment_accumulator.fragments
.absolute_descendants
.push_descendants(kid_abs_descendants);
Expand Down Expand Up @@ -828,8 +833,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
whitespace_style,
node.selected_style(),
whitespace_damage,
fragment_info,
Some(node.quirks_mode()));
fragment_info);
fragment_accumulator.fragments.fragments.push_back(fragment)
}
ConstructionResult::ConstructionItem(ConstructionItem::TableColumnFragment(_)) => {
Expand All @@ -847,7 +851,12 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
let mut modified_style = node_style.clone();
properties::modify_style_for_replaced_content(&mut modified_style);
properties::modify_style_for_text(&mut modified_style);
let fragment = Fragment::from_node_and_style(node, modified_style, info);
let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
node.get_pseudo_element_type().strip(),
modified_style,
node.selected_style(),
node.restyle_damage(),
info);
fragment_accumulator.fragments.fragments.push_back(fragment)
}

Expand Down Expand Up @@ -936,7 +945,12 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
properties::modify_style_for_outer_inline_block_fragment(&mut modified_style);
let fragment_info = SpecificFragmentInfo::InlineBlock(InlineBlockFragmentInfo::new(
block_flow));
let fragment = Fragment::from_node_and_style(node, modified_style, fragment_info);
let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
node.get_pseudo_element_type().strip(),
modified_style,
node.selected_style(),
node.restyle_damage(),
fragment_info);

let mut fragment_accumulator = InlineFragmentsAccumulator::new();
fragment_accumulator.fragments.fragments.push_back(fragment);
Expand Down Expand Up @@ -971,8 +985,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
style,
node.selected_style(),
node.restyle_damage(),
fragment_info,
Some(node.quirks_mode()));
fragment_info);

let mut fragment_accumulator = InlineFragmentsAccumulator::from_inline_node(node, self.style_context());
fragment_accumulator.fragments.fragments.push_back(fragment);
Expand Down Expand Up @@ -1084,8 +1097,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
wrapper_style,
node.selected_style(),
node.restyle_damage(),
SpecificFragmentInfo::TableWrapper,
Some(node.quirks_mode()));
SpecificFragmentInfo::TableWrapper);
let wrapper_float_kind = FloatKind::from_property(float_value);
let mut wrapper_flow =
FlowRef::new(Arc::new(TableWrapperFlow::from_fragment_and_float_kind(wrapper_fragment,
Expand Down Expand Up @@ -1823,8 +1835,7 @@ fn control_chars_to_fragment(node: &InlineFragmentNodeInfo,
style.clone(),
node.selected_style.clone(),
restyle_damage,
info,
Some(node.quirks_mode))
info)
}

/// Convenience methods for computed CSS values
Expand Down
13 changes: 3 additions & 10 deletions components/layout/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx::display_list::{ClippingRegion, StackingContext};
use gfx_traits::{ScrollRootId, StackingContextId};
use gfx_traits::print_tree::PrintTree;
use html5ever::tree_builder::QuirksMode;
use inline::InlineFlow;
use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo};
use multicol::MulticolFlow;
Expand Down Expand Up @@ -939,9 +938,6 @@ pub struct BaseFlow {
pub stacking_context_id: StackingContextId,

pub scroll_root_id: ScrollRootId,

// Mode for the current document.
pub quirks_mode: QuirksMode,
}

impl fmt::Debug for BaseFlow {
Expand All @@ -967,7 +963,7 @@ impl fmt::Debug for BaseFlow {

write!(f,
"sc={:?} pos={:?}, {}{} floatspec-in={:?}, floatspec-out={:?}, \
overflow={:?}{}{}{}, quirks={:?}",
overflow={:?}{}{}{}",
self.stacking_context_id,
self.position,
if self.flags.contains(FLOATS_LEFT) { "FL" } else { "" },
Expand All @@ -977,8 +973,7 @@ impl fmt::Debug for BaseFlow {
self.overflow,
child_count_string,
absolute_descendants_string,
damage_string,
self.quirks_mode)
damage_string)
}
}

Expand Down Expand Up @@ -1010,8 +1005,7 @@ impl BaseFlow {
#[inline]
pub fn new(style: Option<&ServoComputedValues>,
writing_mode: WritingMode,
force_nonfloated: ForceNonfloatedFlag,
quirks_mode: QuirksMode)
force_nonfloated: ForceNonfloatedFlag)
-> BaseFlow {
let mut flags = FlowFlags::empty();
match style {
Expand Down Expand Up @@ -1088,7 +1082,6 @@ impl BaseFlow {
thread_id: 0,
stacking_context_id: StackingContextId::new(0),
scroll_root_id: ScrollRootId::root(),
quirks_mode: quirks_mode,
}
}

Expand Down
70 changes: 5 additions & 65 deletions components/layout/fragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use gfx::display_list::{BLUR_INFLATION_FACTOR, OpaqueNode};
use gfx::text::glyph::ByteIndex;
use gfx::text::text_run::{TextRun, TextRunSlice};
use gfx_traits::{FragmentType, StackingContextId};
use html5ever::tree_builder::QuirksMode;
use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFragmentContext, InlineFragmentNodeInfo};
use inline::{InlineMetrics, LAST_FRAGMENT_OF_ELEMENT, LineMetrics};
use ipc_channel::ipc::IpcSender;
Expand Down Expand Up @@ -922,34 +921,7 @@ impl Fragment {
specific: specific,
inline_context: None,
pseudo: node.get_pseudo_element_type().strip(),
flags: FragmentFlags::with_quirks_mode(node.quirks_mode()),
debug_id: DebugId::new(),
stacking_context_id: StackingContextId::new(0),
}
}

/// Constructs a new `Fragment` from a node, overriding its style
pub fn from_node_and_style<N: ThreadSafeLayoutNode>(node: &N,
style: Arc<ServoComputedValues>,
specific: SpecificFragmentInfo)
-> Fragment {
let writing_mode = style.writing_mode;

let mut restyle_damage = node.restyle_damage();
restyle_damage.remove(RECONSTRUCT_FLOW);

Fragment {
node: node.opaque(),
style: style,
selected_style: node.selected_style(),
restyle_damage: restyle_damage,
border_box: LogicalRect::zero(writing_mode),
border_padding: LogicalMargin::zero(writing_mode),
margin: LogicalMargin::zero(writing_mode),
specific: specific,
inline_context: None,
pseudo: node.get_pseudo_element_type().strip(),
flags: FragmentFlags::with_quirks_mode(node.quirks_mode()),
flags: FragmentFlags::empty(),
debug_id: DebugId::new(),
stacking_context_id: StackingContextId::new(0),
}
Expand All @@ -961,8 +933,7 @@ impl Fragment {
style: Arc<ServoComputedValues>,
selected_style: Arc<ServoComputedValues>,
mut restyle_damage: RestyleDamage,
specific: SpecificFragmentInfo,
quirks_mode: Option<QuirksMode>)
specific: SpecificFragmentInfo)
-> Fragment {
let writing_mode = style.writing_mode;

Expand All @@ -979,7 +950,7 @@ impl Fragment {
specific: specific,
inline_context: None,
pseudo: pseudo,
flags: FragmentFlags::with_quirks_mode(quirks_mode.unwrap_or(QuirksMode::NoQuirks)),
flags: FragmentFlags::empty(),
debug_id: DebugId::new(),
stacking_context_id: StackingContextId::new(0),
}
Expand All @@ -1004,7 +975,7 @@ impl Fragment {
specific: specific,
inline_context: None,
pseudo: self.pseudo,
flags: FragmentFlags::with_quirks_mode(self.flags.quirks_mode()),
flags: FragmentFlags::empty(),
debug_id: DebugId::new(),
stacking_context_id: StackingContextId::new(0),
}
Expand Down Expand Up @@ -1032,7 +1003,7 @@ impl Fragment {
specific: info,
inline_context: self.inline_context.clone(),
pseudo: self.pseudo.clone(),
flags: FragmentFlags::with_quirks_mode(self.flags.quirks_mode()),
flags: FragmentFlags::empty(),
debug_id: self.debug_id.clone(),
stacking_context_id: StackingContextId::new(0),
}
Expand Down Expand Up @@ -2986,11 +2957,6 @@ impl Fragment {
SpecificFragmentInfo::UnscannedText(_) => true
}
}

#[inline]
pub fn quirks_mode(&self) -> QuirksMode {
self.flags.quirks_mode()
}
}

impl fmt::Debug for Fragment {
Expand Down Expand Up @@ -3163,32 +3129,6 @@ bitflags! {
const IS_INLINE_FLEX_ITEM = 0b0000_0001,
/// Whether this fragment represents a child in a column flex container.
const IS_BLOCK_FLEX_ITEM = 0b0000_0010,
/// Whether this fragment is part of a document in quirks mode.
const IS_QUIRKS_MODE = 0b0000_0100,
/// Which quirks mode we're in: 0 is quirks, 1 is limited quirks
const QUIRKS_MODE = 0b0000_1000,
}
}

impl FragmentFlags {
pub fn quirks_mode(&self) -> QuirksMode {
if !self.contains(IS_QUIRKS_MODE) {
QuirksMode::NoQuirks
} else if self.contains(QUIRKS_MODE) {
QuirksMode::Quirks
} else {
QuirksMode::LimitedQuirks
}
}

pub fn with_quirks_mode(quirks_mode: QuirksMode) -> FragmentFlags {
let mut flags = FragmentFlags::empty();
match quirks_mode {
QuirksMode::LimitedQuirks => flags.insert(IS_QUIRKS_MODE),
QuirksMode::Quirks => flags.insert(IS_QUIRKS_MODE | QUIRKS_MODE),
_ => {}
};
flags
}
}

Expand Down
3 changes: 1 addition & 2 deletions components/layout/generated_content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,7 @@ fn render_text(layout_context: &LayoutContext,
style.clone(),
style,
RestyleDamage::rebuild_and_reflow(),
info,
None));
info));
// FIXME(pcwalton): This should properly handle multiple marker fragments. This could happen
// due to text run splitting.
let fragments = TextRunScanner::new().scan_for_runs(&mut layout_context.font_context(),
Expand Down
7 changes: 1 addition & 6 deletions components/layout/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use gfx::font::FontMetrics;
use gfx::font_context::FontContext;
use gfx_traits::ScrollRootId;
use gfx_traits::print_tree::PrintTree;
use html5ever::tree_builder::QuirksMode;
use layout_debug;
use model::IntrinsicISizesContribution;
use range::{Range, RangeIndex};
Expand Down Expand Up @@ -863,11 +862,8 @@ pub struct InlineFlow {

impl InlineFlow {
pub fn from_fragments(fragments: InlineFragments, writing_mode: WritingMode) -> InlineFlow {
debug_assert!(!fragments.is_empty());

let quirks_mode = fragments.get(0).quirks_mode();
let mut flow = InlineFlow {
base: BaseFlow::new(None, writing_mode, ForceNonfloatedFlag::ForceNonfloated, quirks_mode),
base: BaseFlow::new(None, writing_mode, ForceNonfloatedFlag::ForceNonfloated),
fragments: fragments,
lines: Vec::new(),
minimum_line_metrics: LineMetrics::new(Au(0), Au(0)),
Expand Down Expand Up @@ -1731,7 +1727,6 @@ pub struct InlineFragmentNodeInfo {
pub selected_style: Arc<ServoComputedValues>,
pub pseudo: PseudoElementType<()>,
pub flags: InlineFragmentNodeFlags,
pub quirks_mode: QuirksMode,
}

bitflags! {
Expand Down
1 change: 0 additions & 1 deletion components/layout/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ extern crate gfx;
extern crate gfx_traits;
extern crate heapsize;
#[macro_use] extern crate heapsize_derive;
extern crate html5ever;
#[macro_use] extern crate html5ever_atoms;
extern crate ipc_channel;
extern crate libc;
Expand Down

0 comments on commit 3fe7d5b

Please sign in to comment.