|
|
|
Lines 478-505
pub extern "C" fn Servo_ComputedValues_G
|
Link Here
|
|---|
|
| 478 |
#[no_mangle] |
478 |
#[no_mangle] |
| 479 |
pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed, |
479 |
pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed, |
| 480 |
pseudo_tag: *mut nsIAtom, is_probe: bool, |
480 |
pseudo_tag: *mut nsIAtom, is_probe: bool, |
| 481 |
raw_data: RawServoStyleSetBorrowed) |
481 |
raw_data: RawServoStyleSetBorrowed) |
| 482 |
-> ServoComputedValuesStrong |
482 |
-> ServoComputedValuesStrong |
| 483 |
{ |
483 |
{ |
| 484 |
let element = GeckoElement(element); |
484 |
let element = GeckoElement(element); |
| 485 |
let data = unsafe { element.ensure_data() }.borrow_mut(); |
485 |
let data = unsafe { element.ensure_data() }.borrow_mut(); |
|
|
486 |
let doc_data = PerDocumentStyleData::from_ffi(raw_data); |
| 486 |
|
487 |
|
| 487 |
// FIXME(bholley): Assert against this. |
488 |
// FIXME(bholley): Assert against this. |
| 488 |
if data.get_styles().is_none() { |
489 |
if data.get_styles().is_none() { |
| 489 |
error!("Calling Servo_ResolvePseudoStyle on unstyled element"); |
490 |
error!("Calling Servo_ResolvePseudoStyle on unstyled element"); |
| 490 |
return if is_probe { |
491 |
return if is_probe { |
| 491 |
Strong::null() |
492 |
Strong::null() |
| 492 |
} else { |
493 |
} else { |
| 493 |
Arc::new(ComputedValues::initial_values().clone()).into_strong() |
494 |
doc_data.borrow().default_computed_values.clone().into_strong() |
| 494 |
}; |
495 |
}; |
| 495 |
} |
496 |
} |
| 496 |
|
497 |
|
| 497 |
let doc_data = PerDocumentStyleData::from_ffi(raw_data); |
|
|
| 498 |
match get_pseudo_style(element, pseudo_tag, data.styles(), doc_data) { |
498 |
match get_pseudo_style(element, pseudo_tag, data.styles(), doc_data) { |
| 499 |
Some(values) => values.into_strong(), |
499 |
Some(values) => values.into_strong(), |
| 500 |
None if !is_probe => data.styles().primary.values.clone().into_strong(), |
500 |
None if !is_probe => data.styles().primary.values.clone().into_strong(), |
| 501 |
None => Strong::null(), |
501 |
None => Strong::null(), |
| 502 |
} |
502 |
} |
| 503 |
} |
503 |
} |
| 504 |
|
504 |
|
| 505 |
fn get_pseudo_style(element: GeckoElement, pseudo_tag: *mut nsIAtom, |
505 |
fn get_pseudo_style(element: GeckoElement, pseudo_tag: *mut nsIAtom, |
|
Lines 876-904
pub extern "C" fn Servo_ResolveStyle(ele
|
Link Here
|
|---|
|
| 876 |
raw_data: RawServoStyleSetBorrowed, |
876 |
raw_data: RawServoStyleSetBorrowed, |
| 877 |
consume: structs::ConsumeStyleBehavior, |
877 |
consume: structs::ConsumeStyleBehavior, |
| 878 |
compute: structs::LazyComputeBehavior) -> ServoComputedValuesStrong |
878 |
compute: structs::LazyComputeBehavior) -> ServoComputedValuesStrong |
| 879 |
{ |
879 |
{ |
| 880 |
let element = GeckoElement(element); |
880 |
let element = GeckoElement(element); |
| 881 |
debug!("Servo_ResolveStyle: {:?}, consume={:?}, compute={:?}", element, consume, compute); |
881 |
debug!("Servo_ResolveStyle: {:?}, consume={:?}, compute={:?}", element, consume, compute); |
| 882 |
|
882 |
|
| 883 |
let mut data = unsafe { element.ensure_data() }.borrow_mut(); |
883 |
let mut data = unsafe { element.ensure_data() }.borrow_mut(); |
|
|
884 |
let per_doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow(); |
| 884 |
|
885 |
|
| 885 |
if compute == structs::LazyComputeBehavior::Allow { |
886 |
if compute == structs::LazyComputeBehavior::Allow { |
| 886 |
let should_compute = !data.has_current_styles(); |
887 |
let should_compute = !data.has_current_styles(); |
| 887 |
if should_compute { |
888 |
if should_compute { |
| 888 |
debug!("Performing manual style computation"); |
889 |
debug!("Performing manual style computation"); |
| 889 |
if let Some(parent) = element.parent_element() { |
890 |
if let Some(parent) = element.parent_element() { |
| 890 |
if parent.borrow_data().map_or(true, |d| !d.has_current_styles()) { |
891 |
if parent.borrow_data().map_or(true, |d| !d.has_current_styles()) { |
| 891 |
error!("Attempting manual style computation with unstyled parent"); |
892 |
error!("Attempting manual style computation with unstyled parent"); |
| 892 |
return Arc::new(ComputedValues::initial_values().clone()).into_strong(); |
893 |
return per_doc_data.default_computed_values.clone().into_strong() |
| 893 |
} |
894 |
} |
| 894 |
} |
895 |
} |
| 895 |
|
896 |
|
| 896 |
let per_doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); |
|
|
| 897 |
let shared_style_context = create_shared_context(&per_doc_data); |
897 |
let shared_style_context = create_shared_context(&per_doc_data); |
| 898 |
let traversal = RecalcStyleOnly::new(shared_style_context); |
898 |
let traversal = RecalcStyleOnly::new(shared_style_context); |
| 899 |
|
899 |
|
| 900 |
let mut traversal_data = PerLevelTraversalData { |
900 |
let mut traversal_data = PerLevelTraversalData { |
| 901 |
current_dom_depth: None, |
901 |
current_dom_depth: None, |
| 902 |
}; |
902 |
}; |
| 903 |
|
903 |
|
| 904 |
let mut tlc = ThreadLocalStyleContext::new(traversal.shared_context()); |
904 |
let mut tlc = ThreadLocalStyleContext::new(traversal.shared_context()); |
|
Lines 915-931
pub extern "C" fn Servo_ResolveStyle(ele
|
Link Here
|
|---|
|
| 915 |
if element.first_child_element().is_some() { |
915 |
if element.first_child_element().is_some() { |
| 916 |
unsafe { element.set_dirty_descendants() }; |
916 |
unsafe { element.set_dirty_descendants() }; |
| 917 |
} |
917 |
} |
| 918 |
} |
918 |
} |
| 919 |
} |
919 |
} |
| 920 |
|
920 |
|
| 921 |
if !data.has_current_styles() { |
921 |
if !data.has_current_styles() { |
| 922 |
error!("Resolving style on unstyled element with lazy computation forbidden."); |
922 |
error!("Resolving style on unstyled element with lazy computation forbidden."); |
| 923 |
return Arc::new(ComputedValues::initial_values().clone()).into_strong(); |
923 |
return per_doc_data.default_computed_values.clone().into_strong(); |
| 924 |
} |
924 |
} |
| 925 |
|
925 |
|
| 926 |
let values = data.styles().primary.values.clone(); |
926 |
let values = data.styles().primary.values.clone(); |
| 927 |
|
927 |
|
| 928 |
if consume == structs::ConsumeStyleBehavior::Consume { |
928 |
if consume == structs::ConsumeStyleBehavior::Consume { |
| 929 |
// FIXME(bholley): Once we start storing style data on frames, we'll want to |
929 |
// FIXME(bholley): Once we start storing style data on frames, we'll want to |
| 930 |
// drop the data here instead. |
930 |
// drop the data here instead. |
| 931 |
data.persist(); |
931 |
data.persist(); |