mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
Auto merge of #17799 - upsuper:body-color-panic, r=heycam
Don't panic when body element don't have style data This is the Servo side change of [bug 1381233](https://bugzilla.mozilla.org/show_bug.cgi?id=1381233). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17799) <!-- Reviewable:end -->
This commit is contained in:
commit
fafb8476e8
1 changed files with 6 additions and 10 deletions
|
@ -269,16 +269,12 @@ impl ToComputedValue for Color {
|
|||
use gecko::wrapper::GeckoElement;
|
||||
use gecko_bindings::bindings::Gecko_GetBody;
|
||||
let pres_context = _context.device().pres_context();
|
||||
let body = unsafe {
|
||||
Gecko_GetBody(pres_context)
|
||||
};
|
||||
if let Some(body) = body {
|
||||
let wrap = GeckoElement(body);
|
||||
let borrow = wrap.borrow_data();
|
||||
ComputedColor::rgba(borrow.as_ref().unwrap()
|
||||
.styles.primary()
|
||||
.get_color()
|
||||
.clone_color())
|
||||
let body = unsafe { Gecko_GetBody(pres_context) }.map(GeckoElement);
|
||||
let data = body.as_ref().and_then(|wrap| wrap.borrow_data());
|
||||
if let Some(data) = data {
|
||||
ComputedColor::rgba(data.styles.primary()
|
||||
.get_color()
|
||||
.clone_color())
|
||||
} else {
|
||||
convert_nscolor_to_computedcolor(pres_context.mDefaultColor)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue