mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Add style sheet parsing functions.
This commit is contained in:
parent
b794efee05
commit
da079c5b63
2 changed files with 33 additions and 2 deletions
|
@ -49,6 +49,8 @@ pub enum Struct_RawGeckoDocument { }
|
|||
pub type RawGeckoDocument = Struct_RawGeckoDocument;
|
||||
pub enum Struct_ServoNodeData { }
|
||||
pub type ServoNodeData = Struct_ServoNodeData;
|
||||
pub enum Struct_ServoArcStyleSheet { }
|
||||
pub type ServoArcStyleSheet = Struct_ServoArcStyleSheet;
|
||||
extern "C" {
|
||||
pub fn Gecko_ElementState(element: *mut RawGeckoElement) -> uint8_t;
|
||||
pub fn Gecko_GetAttrAsUTF8(element: *mut RawGeckoElement, ns: *const uint8_t,
|
||||
|
@ -78,4 +80,8 @@ extern "C" {
|
|||
data: *mut ServoNodeData) -> ();
|
||||
pub fn Servo_RestyleDocument(aDoc: *mut RawGeckoDocument) -> ();
|
||||
pub fn Servo_DropNodeData(data: *mut ServoNodeData) -> ();
|
||||
pub fn Servo_StylesheetFromUTF8Bytes(bytes: *const uint8_t,
|
||||
length: uint32_t)
|
||||
-> *mut ServoArcStyleSheet;
|
||||
pub fn Servo_DropStylesheet(sheet: *mut ServoArcStyleSheet) -> ();
|
||||
}
|
||||
|
|
|
@ -6,12 +6,15 @@
|
|||
|
||||
use app_units::Au;
|
||||
use bindings::RawGeckoDocument;
|
||||
use bindings::ServoNodeData;
|
||||
use bindings::{ServoNodeData, ServoArcStyleSheet, uint8_t, uint32_t};
|
||||
use euclid::Size2D;
|
||||
use euclid::size::TypedSize2D;
|
||||
use num_cpus;
|
||||
use std::cmp;
|
||||
use std::collections::HashMap;
|
||||
use std::mem::transmute;
|
||||
use std::slice;
|
||||
use std::str::from_utf8_unchecked;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
use style::animation::Animation;
|
||||
|
@ -21,8 +24,9 @@ use style::error_reporting::StdoutErrorReporter;
|
|||
use style::media_queries::{Device, MediaType};
|
||||
use style::parallel::{self, WorkQueueData};
|
||||
use style::selector_matching::Stylist;
|
||||
use style::stylesheets::Stylesheet;
|
||||
use style::stylesheets::{Origin, Stylesheet};
|
||||
use style::traversal::RecalcStyleOnly;
|
||||
use url::Url;
|
||||
use util::geometry::ViewportPx;
|
||||
use util::resource_files::set_resources_path;
|
||||
use util::thread_state;
|
||||
|
@ -90,3 +94,24 @@ pub extern "C" fn Servo_DropNodeData(data: *mut ServoNodeData) -> () {
|
|||
let _ = Box::<NonOpaqueStyleData>::from_raw(data as *mut NonOpaqueStyleData);
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StylesheetFromUTF8Bytes(bytes: *const uint8_t,
|
||||
length: uint32_t) -> *mut ServoArcStyleSheet {
|
||||
|
||||
let input = unsafe { from_utf8_unchecked(slice::from_raw_parts(bytes, length as usize)) };
|
||||
|
||||
// FIXME(heycam): Pass in the real base URL and sheet origin to use.
|
||||
let url = Url::parse("about:none").unwrap();
|
||||
let sheet = Arc::new(Stylesheet::from_str(input, url, Origin::Author, Box::new(StdoutErrorReporter)));
|
||||
unsafe {
|
||||
transmute(sheet)
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_DropStylesheet(sheet: *mut ServoArcStyleSheet) -> () {
|
||||
unsafe {
|
||||
let _ : Arc<Stylesheet> = transmute(sheet);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue