mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #9852 - bholley:stylo_uplifts_3, r=bholley
Stylo uplifts 3 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9852) <!-- Reviewable:end -->
This commit is contained in:
commit
49e9594fb9
11 changed files with 214 additions and 162 deletions
|
@ -19,7 +19,7 @@ pub trait SelectorImplExt : SelectorImpl + Sized {
|
|||
|
||||
fn get_user_or_user_agent_stylesheets() -> &'static [Stylesheet<Self>];
|
||||
|
||||
fn get_quirks_mode_stylesheet() -> &'static Stylesheet<Self>;
|
||||
fn get_quirks_mode_stylesheet() -> Option<&'static Stylesheet<Self>>;
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, HeapSizeOf, Hash)]
|
||||
|
@ -135,7 +135,7 @@ impl SelectorImplExt for ServoSelectorImpl {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn get_quirks_mode_stylesheet() -> &'static Stylesheet<Self> {
|
||||
&*QUIRKS_MODE_STYLESHEET
|
||||
fn get_quirks_mode_stylesheet() -> Option<&'static Stylesheet<Self>> {
|
||||
Some(&*QUIRKS_MODE_STYLESHEET)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,7 +146,9 @@ impl<Impl: SelectorImplExt> Stylist<Impl> {
|
|||
}
|
||||
|
||||
if self.quirks_mode {
|
||||
self.add_stylesheet(&Impl::get_quirks_mode_stylesheet());
|
||||
if let Some(s) = Impl::get_quirks_mode_stylesheet() {
|
||||
self.add_stylesheet(s);
|
||||
}
|
||||
}
|
||||
|
||||
for ref stylesheet in doc_stylesheets.iter() {
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
/* automatically generated by rust-bindgen */
|
||||
|
||||
pub type int64_t = ::libc::c_longlong;
|
||||
pub type uint64_t = ::libc::c_ulonglong;
|
||||
pub type int64_t = i64;
|
||||
pub type uint64_t = u64;
|
||||
pub type int_least64_t = int64_t;
|
||||
pub type uint_least64_t = uint64_t;
|
||||
pub type int_fast64_t = int64_t;
|
||||
pub type uint_fast64_t = uint64_t;
|
||||
pub type int32_t = ::libc::c_int;
|
||||
pub type uint32_t = ::libc::c_uint;
|
||||
pub type int32_t = i32;
|
||||
pub type uint32_t = u32;
|
||||
pub type int_least32_t = int32_t;
|
||||
pub type uint_least32_t = uint32_t;
|
||||
pub type int_fast32_t = int32_t;
|
||||
pub type uint_fast32_t = uint32_t;
|
||||
pub type int16_t = ::libc::c_short;
|
||||
pub type uint16_t = ::libc::c_ushort;
|
||||
pub type int16_t = i16;
|
||||
pub type uint16_t = u16;
|
||||
pub type int_least16_t = int16_t;
|
||||
pub type uint_least16_t = uint16_t;
|
||||
pub type int_fast16_t = int16_t;
|
||||
pub type uint_fast16_t = uint16_t;
|
||||
pub type int8_t = ::libc::c_char;
|
||||
pub type uint8_t = ::libc::c_uchar;
|
||||
pub type uint8_t = u8;
|
||||
pub type int_least8_t = int8_t;
|
||||
pub type uint_least8_t = uint8_t;
|
||||
pub type int_fast8_t = int8_t;
|
||||
|
@ -28,43 +28,19 @@ pub type intptr_t = int64_t;
|
|||
pub type uintptr_t = uint64_t;
|
||||
pub type intmax_t = ::libc::c_long;
|
||||
pub type uintmax_t = ::libc::c_ulong;
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(u32)]
|
||||
pub enum Enum_NodeType {
|
||||
ELEMENT_NODE = 1,
|
||||
ATTRIBUTE_NODE = 2,
|
||||
TEXT_NODE = 3,
|
||||
CDATA_SECTION_NODE = 4,
|
||||
ENTITY_REFERENCE_NODE = 5,
|
||||
ENTITY_NODE = 6,
|
||||
PROCESSING_INSTRUCTION_NODE = 7,
|
||||
COMMENT_NODE = 8,
|
||||
DOCUMENT_NODE = 9,
|
||||
DOCUMENT_TYPE_NODE = 10,
|
||||
DOCUMENT_FRAGMENT_NODE = 11,
|
||||
NOTATION_NODE = 12,
|
||||
}
|
||||
pub enum Struct_RawGeckoNode { }
|
||||
pub type RawGeckoNode = Struct_RawGeckoNode;
|
||||
pub enum Struct_RawGeckoElement { }
|
||||
pub type RawGeckoElement = Struct_RawGeckoElement;
|
||||
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;
|
||||
pub enum Struct_ServoStyleSetData { }
|
||||
pub type ServoStyleSetData = Struct_ServoStyleSetData;
|
||||
pub enum nsINode { }
|
||||
pub type RawGeckoNode = nsINode;
|
||||
pub enum Element { }
|
||||
pub type RawGeckoElement = Element;
|
||||
pub enum nsIDocument { }
|
||||
pub type RawGeckoDocument = nsIDocument;
|
||||
pub enum ServoNodeData { }
|
||||
pub enum RawServoStyleSheet { }
|
||||
pub enum RawServoStyleSet { }
|
||||
extern "C" {
|
||||
pub fn Gecko_ElementState(element: *mut RawGeckoElement) -> uint8_t;
|
||||
pub fn Gecko_GetAttrAsUTF8(element: *mut RawGeckoElement,
|
||||
ns: *const uint8_t, name: *const uint8_t,
|
||||
length: *mut uint32_t)
|
||||
-> *const ::libc::c_char;
|
||||
pub fn Gecko_ChildrenCount(node: *mut RawGeckoNode) -> uint32_t;
|
||||
pub fn Gecko_GetDocumentElement(document: *mut RawGeckoDocument)
|
||||
-> *mut RawGeckoElement;
|
||||
pub fn Gecko_NodeIsElement(node: *mut RawGeckoNode) -> bool;
|
||||
pub fn Gecko_GetParentNode(node: *mut RawGeckoNode) -> *mut RawGeckoNode;
|
||||
pub fn Gecko_GetFirstChild(node: *mut RawGeckoNode) -> *mut RawGeckoNode;
|
||||
pub fn Gecko_GetLastChild(node: *mut RawGeckoNode) -> *mut RawGeckoNode;
|
||||
pub fn Gecko_GetPrevSibling(node: *mut RawGeckoNode) -> *mut RawGeckoNode;
|
||||
|
@ -79,40 +55,41 @@ extern "C" {
|
|||
-> *mut RawGeckoElement;
|
||||
pub fn Gecko_GetNextSiblingElement(element: *mut RawGeckoElement)
|
||||
-> *mut RawGeckoElement;
|
||||
pub fn Gecko_GetNodeData(node: *mut RawGeckoNode) -> *mut ServoNodeData;
|
||||
pub fn Gecko_GetParentNode(node: *mut RawGeckoNode) -> *mut RawGeckoNode;
|
||||
pub fn Gecko_LocalName(element: *mut RawGeckoElement,
|
||||
length: *mut uint32_t) -> *const uint16_t;
|
||||
pub fn Gecko_GetDocumentElement(document: *mut RawGeckoDocument)
|
||||
-> *mut RawGeckoElement;
|
||||
pub fn Gecko_ElementState(element: *mut RawGeckoElement) -> uint8_t;
|
||||
pub fn Gecko_IsHTMLElementInHTMLDocument(element: *mut RawGeckoElement)
|
||||
-> ::libc::c_int;
|
||||
pub fn Gecko_IsLink(element: *mut RawGeckoElement) -> ::libc::c_int;
|
||||
pub fn Gecko_IsTextNode(node: *mut RawGeckoNode) -> ::libc::c_int;
|
||||
pub fn Gecko_IsVisitedLink(element: *mut RawGeckoElement)
|
||||
-> ::libc::c_int;
|
||||
pub fn Gecko_IsUnvisitedLink(element: *mut RawGeckoElement)
|
||||
-> ::libc::c_int;
|
||||
pub fn Gecko_IsRootElement(element: *mut RawGeckoElement)
|
||||
-> ::libc::c_int;
|
||||
pub fn Gecko_Namespace(element: *mut RawGeckoElement,
|
||||
length: *mut uint32_t) -> *const uint16_t;
|
||||
pub fn Gecko_NodeIsElement(node: *mut RawGeckoNode) -> ::libc::c_int;
|
||||
-> bool;
|
||||
pub fn Gecko_IsLink(element: *mut RawGeckoElement) -> bool;
|
||||
pub fn Gecko_IsTextNode(node: *mut RawGeckoNode) -> bool;
|
||||
pub fn Gecko_IsVisitedLink(element: *mut RawGeckoElement) -> bool;
|
||||
pub fn Gecko_IsUnvisitedLink(element: *mut RawGeckoElement) -> bool;
|
||||
pub fn Gecko_IsRootElement(element: *mut RawGeckoElement) -> bool;
|
||||
pub fn Gecko_GetNodeData(node: *mut RawGeckoNode) -> *mut ServoNodeData;
|
||||
pub fn Gecko_SetNodeData(node: *mut RawGeckoNode,
|
||||
data: *mut ServoNodeData);
|
||||
pub fn Servo_RestyleDocument(doc: *mut RawGeckoDocument,
|
||||
data: *mut ServoStyleSetData);
|
||||
pub fn Servo_DropNodeData(data: *mut ServoNodeData);
|
||||
pub fn Servo_StylesheetFromUTF8Bytes(bytes: *const uint8_t,
|
||||
length: uint32_t)
|
||||
-> *mut ServoArcStyleSheet;
|
||||
pub fn Servo_AppendStyleSheet(sheet: *mut ServoArcStyleSheet,
|
||||
data: *mut ServoStyleSetData);
|
||||
pub fn Servo_PrependStyleSheet(sheet: *mut ServoArcStyleSheet,
|
||||
data: *mut ServoStyleSetData);
|
||||
pub fn Servo_RemoveStyleSheet(sheet: *mut ServoArcStyleSheet,
|
||||
data: *mut ServoStyleSetData);
|
||||
pub fn Servo_StyleSheetHasRules(sheet: *mut ServoArcStyleSheet)
|
||||
-> ::libc::c_int;
|
||||
pub fn Servo_DropStylesheet(sheet: *mut ServoArcStyleSheet);
|
||||
pub fn Servo_InitStyleSetData() -> *mut ServoStyleSetData;
|
||||
pub fn Servo_DropStyleSetData(data: *mut ServoStyleSetData);
|
||||
-> *mut RawServoStyleSheet;
|
||||
pub fn Servo_ReleaseStylesheet(sheet: *mut RawServoStyleSheet);
|
||||
pub fn Servo_AppendStyleSheet(sheet: *mut RawServoStyleSheet,
|
||||
set: *mut RawServoStyleSet);
|
||||
pub fn Servo_PrependStyleSheet(sheet: *mut RawServoStyleSheet,
|
||||
set: *mut RawServoStyleSet);
|
||||
pub fn Servo_RemoveStyleSheet(sheet: *mut RawServoStyleSheet,
|
||||
set: *mut RawServoStyleSet);
|
||||
pub fn Servo_StyleSheetHasRules(sheet: *mut RawServoStyleSheet) -> bool;
|
||||
pub fn Servo_InitStyleSet() -> *mut RawServoStyleSet;
|
||||
pub fn Servo_DropStyleSet(set: *mut RawServoStyleSet);
|
||||
pub fn Gecko_GetAttrAsUTF8(element: *mut RawGeckoElement,
|
||||
ns: *const uint8_t, name: *const uint8_t,
|
||||
length: *mut uint32_t)
|
||||
-> *const ::libc::c_char;
|
||||
pub fn Gecko_LocalName(element: *mut RawGeckoElement,
|
||||
length: *mut uint32_t) -> *const uint16_t;
|
||||
pub fn Gecko_Namespace(element: *mut RawGeckoElement,
|
||||
length: *mut uint32_t) -> *const uint16_t;
|
||||
pub fn Servo_RestyleDocument(doc: *mut RawGeckoDocument,
|
||||
set: *mut RawServoStyleSet);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use bindings::ServoStyleSetData;
|
||||
use bindings::RawServoStyleSet;
|
||||
use euclid::Size2D;
|
||||
use euclid::size::TypedSize2D;
|
||||
use num_cpus;
|
||||
|
@ -61,7 +61,7 @@ impl PerDocumentStyleData {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn borrow_mut_from_raw<'a>(data: *mut ServoStyleSetData) -> &'a mut Self {
|
||||
pub fn borrow_mut_from_raw<'a>(data: *mut RawServoStyleSet) -> &'a mut Self {
|
||||
unsafe { &mut *(data as *mut PerDocumentStyleData) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use app_units::Au;
|
||||
use bindings::RawGeckoDocument;
|
||||
use bindings::{ServoArcStyleSheet, ServoNodeData, ServoStyleSetData, uint8_t, uint32_t};
|
||||
use bindings::{ServoNodeData, RawServoStyleSet, RawServoStyleSheet, uint8_t, uint32_t};
|
||||
use data::PerDocumentStyleData;
|
||||
use euclid::Size2D;
|
||||
use selector_impl::{SharedStyleContext, Stylesheet};
|
||||
|
@ -22,7 +22,6 @@ use style::stylesheets::Origin;
|
|||
use traversal::RecalcStyleOnly;
|
||||
use url::Url;
|
||||
use util::arc_ptr_eq;
|
||||
use util::resource_files::set_resources_path;
|
||||
use wrapper::{GeckoDocument, GeckoNode, NonOpaqueStyleData};
|
||||
|
||||
/*
|
||||
|
@ -34,7 +33,7 @@ use wrapper::{GeckoDocument, GeckoNode, NonOpaqueStyleData};
|
|||
*/
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, raw_data: *mut ServoStyleSetData) -> () {
|
||||
pub extern "C" fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, raw_data: *mut RawServoStyleSet) -> () {
|
||||
let document = unsafe { GeckoDocument::from_raw(doc) };
|
||||
let node = match document.root_node() {
|
||||
Some(x) => x,
|
||||
|
@ -42,10 +41,6 @@ pub extern "C" fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, raw_data: *m
|
|||
};
|
||||
let data = unsafe { &mut *(raw_data as *mut PerDocumentStyleData) };
|
||||
|
||||
// FIXME(bholley): Don't hardcode resources path. We may want to use Gecko's UA stylesheets
|
||||
// anyway.
|
||||
set_resources_path(Some("/files/mozilla/stylo/servo/resources/".to_owned()));
|
||||
|
||||
let _needs_dirtying = data.stylist.update(&data.stylesheets, data.stylesheets_changed);
|
||||
data.stylesheets_changed = false;
|
||||
|
||||
|
@ -75,7 +70,7 @@ pub extern "C" fn Servo_DropNodeData(data: *mut ServoNodeData) -> () {
|
|||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StylesheetFromUTF8Bytes(bytes: *const uint8_t,
|
||||
length: uint32_t) -> *mut ServoArcStyleSheet {
|
||||
length: uint32_t) -> *mut RawServoStyleSheet {
|
||||
|
||||
let input = unsafe { from_utf8_unchecked(slice::from_raw_parts(bytes, length as usize)) };
|
||||
|
||||
|
@ -87,7 +82,7 @@ pub extern "C" fn Servo_StylesheetFromUTF8Bytes(bytes: *const uint8_t,
|
|||
}
|
||||
}
|
||||
|
||||
fn with_arc_stylesheet<F, Output>(raw: *mut ServoArcStyleSheet, cb: F) -> Output
|
||||
fn with_arc_stylesheet<F, Output>(raw: *mut RawServoStyleSheet, cb: F) -> Output
|
||||
where F: FnOnce(&Arc<Stylesheet>) -> Output {
|
||||
let owned = unsafe { consume_arc_stylesheet(raw) };
|
||||
let result = cb(&owned);
|
||||
|
@ -95,13 +90,13 @@ fn with_arc_stylesheet<F, Output>(raw: *mut ServoArcStyleSheet, cb: F) -> Output
|
|||
result
|
||||
}
|
||||
|
||||
unsafe fn consume_arc_stylesheet(raw: *mut ServoArcStyleSheet) -> Arc<Stylesheet> {
|
||||
unsafe fn consume_arc_stylesheet(raw: *mut RawServoStyleSheet) -> Arc<Stylesheet> {
|
||||
transmute(raw)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_AppendStyleSheet(raw_sheet: *mut ServoArcStyleSheet,
|
||||
raw_data: *mut ServoStyleSetData) {
|
||||
pub extern "C" fn Servo_AppendStyleSheet(raw_sheet: *mut RawServoStyleSheet,
|
||||
raw_data: *mut RawServoStyleSet) {
|
||||
let data = PerDocumentStyleData::borrow_mut_from_raw(raw_data);
|
||||
with_arc_stylesheet(raw_sheet, |sheet| {
|
||||
data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet));
|
||||
|
@ -111,8 +106,8 @@ pub extern "C" fn Servo_AppendStyleSheet(raw_sheet: *mut ServoArcStyleSheet,
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_PrependStyleSheet(raw_sheet: *mut ServoArcStyleSheet,
|
||||
raw_data: *mut ServoStyleSetData) {
|
||||
pub extern "C" fn Servo_PrependStyleSheet(raw_sheet: *mut RawServoStyleSheet,
|
||||
raw_data: *mut RawServoStyleSet) {
|
||||
let data = PerDocumentStyleData::borrow_mut_from_raw(raw_data);
|
||||
with_arc_stylesheet(raw_sheet, |sheet| {
|
||||
data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet));
|
||||
|
@ -122,8 +117,8 @@ pub extern "C" fn Servo_PrependStyleSheet(raw_sheet: *mut ServoArcStyleSheet,
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_RemoveStyleSheet(raw_sheet: *mut ServoArcStyleSheet,
|
||||
raw_data: *mut ServoStyleSetData) {
|
||||
pub extern "C" fn Servo_RemoveStyleSheet(raw_sheet: *mut RawServoStyleSheet,
|
||||
raw_data: *mut RawServoStyleSet) {
|
||||
let data = PerDocumentStyleData::borrow_mut_from_raw(raw_data);
|
||||
with_arc_stylesheet(raw_sheet, |sheet| {
|
||||
data.stylesheets.retain(|x| !arc_ptr_eq(x, sheet));
|
||||
|
@ -132,27 +127,27 @@ pub extern "C" fn Servo_RemoveStyleSheet(raw_sheet: *mut ServoArcStyleSheet,
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSheetHasRules(raw_sheet: *mut ServoArcStyleSheet) -> ::libc::c_int {
|
||||
with_arc_stylesheet(raw_sheet, |sheet| if sheet.rules.is_empty() { 0 } else { 1 })
|
||||
pub extern "C" fn Servo_StyleSheetHasRules(raw_sheet: *mut RawServoStyleSheet) -> bool {
|
||||
with_arc_stylesheet(raw_sheet, |sheet| !sheet.rules.is_empty())
|
||||
}
|
||||
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_DropStylesheet(sheet: *mut ServoArcStyleSheet) -> () {
|
||||
pub extern "C" fn Servo_ReleaseStylesheet(sheet: *mut RawServoStyleSheet) -> () {
|
||||
unsafe {
|
||||
let _ = consume_arc_stylesheet(sheet);
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_InitStyleSetData() -> *mut ServoStyleSetData {
|
||||
pub extern "C" fn Servo_InitStyleSet() -> *mut RawServoStyleSet {
|
||||
let data = Box::new(PerDocumentStyleData::new());
|
||||
Box::into_raw(data) as *mut ServoStyleSetData
|
||||
Box::into_raw(data) as *mut RawServoStyleSet
|
||||
}
|
||||
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_DropStyleSetData(data: *mut ServoStyleSetData) -> () {
|
||||
pub extern "C" fn Servo_DropStyleSet(data: *mut RawServoStyleSet) -> () {
|
||||
unsafe {
|
||||
let _ = Box::<PerDocumentStyleData>::from_raw(data as *mut PerDocumentStyleData);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ use style::error_reporting::StdoutErrorReporter;
|
|||
use style::selector_impl::SelectorImplExt;
|
||||
use style::stylesheets::Origin;
|
||||
use url::Url;
|
||||
use util::resource_files::read_resource_file;
|
||||
|
||||
pub type Stylist = style::selector_matching::Stylist<GeckoSelectorImpl>;
|
||||
pub type Stylesheet = style::stylesheets::Stylesheet<GeckoSelectorImpl>;
|
||||
|
@ -19,56 +18,6 @@ pub type PrivateStyleData = style::data::PrivateStyleData<GeckoSelectorImpl>;
|
|||
|
||||
pub struct GeckoSelectorImpl;
|
||||
|
||||
// TODO: Replace this with Gecko's stylesheets
|
||||
lazy_static! {
|
||||
static ref USER_OR_USER_AGENT_STYLESHEETS: Vec<Stylesheet> = {
|
||||
let mut stylesheets = vec!();
|
||||
// FIXME: presentational-hints.css should be at author origin with zero specificity.
|
||||
// (Does it make a difference?)
|
||||
for &filename in &["user-agent.css", "servo.css", "presentational-hints.css"] {
|
||||
match read_resource_file(&[filename]) {
|
||||
Ok(res) => {
|
||||
let ua_stylesheet = Stylesheet::from_bytes(
|
||||
&res,
|
||||
Url::parse(&format!("chrome:///{:?}", filename)).unwrap(),
|
||||
None,
|
||||
None,
|
||||
Origin::UserAgent,
|
||||
box StdoutErrorReporter);
|
||||
stylesheets.push(ua_stylesheet);
|
||||
}
|
||||
Err(..) => {
|
||||
error!("Failed to load UA stylesheet {}!", filename);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stylesheets
|
||||
};
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref QUIRKS_MODE_STYLESHEET: Stylesheet = {
|
||||
match read_resource_file(&["quirks-mode.css"]) {
|
||||
Ok(res) => {
|
||||
Stylesheet::from_bytes(
|
||||
&res,
|
||||
url!("chrome:///quirks-mode.css"),
|
||||
None,
|
||||
None,
|
||||
Origin::UserAgent,
|
||||
box StdoutErrorReporter)
|
||||
},
|
||||
Err(..) => {
|
||||
error!("Stylist failed to load 'quirks-mode.css'!");
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, HeapSizeOf, Hash)]
|
||||
pub enum PseudoElement {
|
||||
Before,
|
||||
|
@ -294,14 +243,13 @@ impl SelectorImplExt for GeckoSelectorImpl {
|
|||
pc.state_flag()
|
||||
}
|
||||
|
||||
// FIXME: Don't use Servo's UA stylesheets, use Gecko's instead
|
||||
#[inline]
|
||||
fn get_user_or_user_agent_stylesheets() -> &'static [Stylesheet] {
|
||||
&*USER_OR_USER_AGENT_STYLESHEETS
|
||||
&[]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_quirks_mode_stylesheet() -> &'static Stylesheet {
|
||||
&*QUIRKS_MODE_STYLESHEET
|
||||
fn get_quirks_mode_stylesheet() -> Option<&'static Stylesheet> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
26
ports/geckolib/tools/build_custom_clang.sh
Executable file
26
ports/geckolib/tools/build_custom_clang.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Run in the tools directory.
|
||||
cd `dirname $0`
|
||||
|
||||
# Don't run twice.
|
||||
if [ -d llvm ]; then
|
||||
echo "llvm directory already exists."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Download and build a custom llvm
|
||||
git clone https://github.com/llvm-mirror/llvm
|
||||
cd llvm
|
||||
git checkout release_37
|
||||
cd tools
|
||||
git clone https://github.com/llvm-mirror/clang
|
||||
cd clang
|
||||
git remote add mwu https://github.com/michaelwu/clang
|
||||
git fetch mwu
|
||||
git checkout release_37_smhacks
|
||||
cd ../.. # llvm root dir
|
||||
mkdir build
|
||||
cd build
|
||||
../configure --enable-optimized
|
||||
make
|
33
ports/geckolib/tools/regen_bindings.sh
Executable file
33
ports/geckolib/tools/regen_bindings.sh
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Run in the tools directory.
|
||||
cd `dirname $0`
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Usage: $0 /path/to/objdir/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for rust-bindgen
|
||||
if [ ! -d rust-bindgen ]; then
|
||||
echo "rust-bindgen not found. Run setup_bindgen.sh first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export RUST_BACKTRACE=1
|
||||
export LIBCLANG_PATH=`pwd`/llvm/build/Release+Asserts/lib
|
||||
export DYLD_LIBRARY_PATH=`pwd`/llvm/build/Release+Asserts/lib
|
||||
export DIST_INCLUDE=$1/dist/include
|
||||
|
||||
# Check for the include directory.
|
||||
if [ ! -d $DIST_INCLUDE ]; then
|
||||
echo "$DIST_INCLUDE: directory not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Uncomment the following line to run rust-bindgen in a debugger on mac.
|
||||
# The absolute path is required to allow launching lldb with an untrusted
|
||||
# library in DYLD_LIBRARY_PATH.
|
||||
#
|
||||
# /Applications/Xcode.app/Contents/Developer/usr/bin/lldb --
|
||||
./rust-bindgen/target/debug/bindgen -x c++ -std=gnu++0x -I$DIST_INCLUDE -o ../bindings.rs $DIST_INCLUDE/mozilla/ServoBindings.h
|
41
ports/geckolib/tools/regen_style_structs.sh
Executable file
41
ports/geckolib/tools/regen_style_structs.sh
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Run in the tools directory.
|
||||
cd `dirname $0`
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Usage: $0 /path/to/objdir/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for rust-bindgen
|
||||
if [ ! -d rust-bindgen ]; then
|
||||
echo "rust-bindgen not found. Run setup_bindgen.sh first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Need to find a way to avoid hardcoding these
|
||||
STD_LIB_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include
|
||||
STDXX_LIB_PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
|
||||
if [ ! -d $STD_LIB_PATH ] || [ ! -d $STDXX_LIB_PATH ]; then
|
||||
echo "Please update the above environmental variables to point to your standard library."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export RUST_BACKTRACE=1
|
||||
export LIBCLANG_PATH=`pwd`/llvm/build/Release+Asserts/lib
|
||||
export DYLD_LIBRARY_PATH=`pwd`/llvm/build/Release+Asserts/lib
|
||||
export DIST_INCLUDE=$1/dist/include
|
||||
|
||||
# Check for the include directory.
|
||||
if [ ! -d $DIST_INCLUDE ]; then
|
||||
echo "$DIST_INCLUDE: directory not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Uncomment the following line to run rust-bindgen in a debugger on mac.
|
||||
# The absolute path is required to allow launching lldb with an untrusted
|
||||
# library in DYLD_LIBRARY_PATH.
|
||||
#
|
||||
# /Applications/Xcode.app/Contents/Developer/usr/bin/lldb --
|
||||
./rust-bindgen/target/debug/bindgen -x c++ -std=gnu++0x -ignore-functions -allow-unknown-types -isystem $STDXX_LIB_PATH -isystem $STD_LIB_PATH -I$DIST_INCLUDE -I$DIST_INCLUDE/nspr -DDEBUG=1 -DTRACING=1 -DOS_POSIX=1 -DOS_MACOSX=1 -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -include $1/mozilla-config.h -o ../gecko_style_structs.rs $DIST_INCLUDE/nsStyleStruct.h
|
30
ports/geckolib/tools/setup_bindgen.sh
Executable file
30
ports/geckolib/tools/setup_bindgen.sh
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Run in the tools directory.
|
||||
cd `dirname $0`
|
||||
|
||||
# Make sure we have a custom clang set up.
|
||||
if [ ! -d llvm ]; then
|
||||
echo "Custom LLVM/Clang not found. Run build_custom_clang.sh first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Don't run twice.
|
||||
if [ -d rust-bindgen ]; then
|
||||
echo "rust-bindgen directory already exists."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for multirust
|
||||
if [ ! -x "$(command -v multirust)" ]; then
|
||||
echo 'multirust must be installed.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Setup and build bindgen.
|
||||
export LIBCLANG_PATH=`pwd`/llvm/build/Release+Asserts/lib
|
||||
git clone https://github.com/bholley/rust-bindgen.git
|
||||
cd rust-bindgen
|
||||
git checkout sm-hacks
|
||||
multirust override nightly
|
||||
cargo build
|
|
@ -103,13 +103,13 @@ impl<'ln> TNode<'ln> for GeckoNode<'ln> {
|
|||
|
||||
fn is_text_node(&self) -> bool {
|
||||
unsafe {
|
||||
Gecko_IsTextNode(self.node) != 0
|
||||
Gecko_IsTextNode(self.node)
|
||||
}
|
||||
}
|
||||
|
||||
fn is_element(&self) -> bool {
|
||||
unsafe {
|
||||
Gecko_NodeIsElement(self.node) != 0
|
||||
Gecko_NodeIsElement(self.node)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
|
||||
fn is_root(&self) -> bool {
|
||||
unsafe {
|
||||
Gecko_IsRootElement(self.element) != 0
|
||||
Gecko_IsRootElement(self.element)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,9 +425,9 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
fn match_non_ts_pseudo_class(&self, pseudo_class: NonTSPseudoClass) -> bool {
|
||||
match pseudo_class {
|
||||
// https://github.com/servo/servo/issues/8718
|
||||
NonTSPseudoClass::AnyLink => unsafe { Gecko_IsLink(self.element) != 0 },
|
||||
NonTSPseudoClass::Link => unsafe { Gecko_IsUnvisitedLink(self.element) != 0 },
|
||||
NonTSPseudoClass::Visited => unsafe { Gecko_IsVisitedLink(self.element) != 0 },
|
||||
NonTSPseudoClass::AnyLink => unsafe { Gecko_IsLink(self.element) },
|
||||
NonTSPseudoClass::Link => unsafe { Gecko_IsUnvisitedLink(self.element) },
|
||||
NonTSPseudoClass::Visited => unsafe { Gecko_IsVisitedLink(self.element) },
|
||||
NonTSPseudoClass::Active |
|
||||
NonTSPseudoClass::Focus |
|
||||
NonTSPseudoClass::Hover |
|
||||
|
@ -480,7 +480,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
|
||||
fn is_html_element_in_html_document(&self) -> bool {
|
||||
unsafe {
|
||||
Gecko_IsHTMLElementInHTMLDocument(self.element) != 0
|
||||
Gecko_IsHTMLElementInHTMLDocument(self.element)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue