mirror of
https://github.com/servo/servo.git
synced 2025-07-02 21:13:39 +01:00
Bug 1334579: Ensure constructors for nsStyleContentData run. r=bholley
MozReview-Commit-ID: 9Y6tQ6BD2c8 Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
b5c94bad37
commit
a5bc898c21
2 changed files with 15 additions and 12 deletions
|
@ -644,7 +644,8 @@ extern "C" {
|
|||
pub fn Gecko_DropElementSnapshot(snapshot: ServoElementSnapshotOwned);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_ClearStyleContents(content: *mut nsStyleContent);
|
||||
pub fn Gecko_ClearAndResizeStyleContents(content: *mut nsStyleContent,
|
||||
how_many: u32);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CopyStyleContentsFrom(content: *mut nsStyleContent,
|
||||
|
|
|
@ -2692,7 +2692,7 @@ clip-path
|
|||
use properties::longhands::content::computed_value::T;
|
||||
use properties::longhands::content::computed_value::ContentItem;
|
||||
use gecko_bindings::structs::nsStyleContentType::*;
|
||||
use gecko_bindings::bindings::Gecko_ClearStyleContents;
|
||||
use gecko_bindings::bindings::Gecko_ClearAndResizeStyleContents;
|
||||
|
||||
// Converts a string as utf16, and returns an owned, zero-terminated raw buffer.
|
||||
fn as_utf16_and_forget(s: &str) -> *mut u16 {
|
||||
|
@ -2704,19 +2704,21 @@ clip-path
|
|||
ptr
|
||||
}
|
||||
|
||||
// Ensure destructors run, otherwise we could leak.
|
||||
if !self.gecko.mContents.is_empty() {
|
||||
unsafe {
|
||||
Gecko_ClearStyleContents(&mut self.gecko);
|
||||
}
|
||||
}
|
||||
|
||||
match v {
|
||||
T::none |
|
||||
T::normal => {}, // Do nothing, already cleared.
|
||||
T::normal => {
|
||||
// Ensure destructors run, otherwise we could leak.
|
||||
if !self.gecko.mContents.is_empty() {
|
||||
unsafe {
|
||||
Gecko_ClearAndResizeStyleContents(&mut self.gecko, 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
T::Content(items) => {
|
||||
// NB: set_len also reserves the appropriate space.
|
||||
unsafe { self.gecko.mContents.set_len(items.len() as u32) }
|
||||
unsafe {
|
||||
Gecko_ClearAndResizeStyleContents(&mut self.gecko,
|
||||
items.len() as u32);
|
||||
}
|
||||
for (i, item) in items.into_iter().enumerate() {
|
||||
// TODO: Servo lacks support for attr(), and URIs.
|
||||
// NB: Gecko compares the mString value if type is not image
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue