mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #11672 - Ms2ger:dom, r=nox
Make the dom module private. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11672) <!-- Reviewable:end -->
This commit is contained in:
commit
8c0f31e9fd
35 changed files with 102 additions and 181 deletions
|
@ -31,7 +31,7 @@ impl<T: DomObject> SimpleWorkerErrorHandler<T> {
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct SharedRt {
|
pub struct SharedRt {
|
||||||
pub rt: *mut JSRuntime
|
rt: *mut JSRuntime
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SharedRt {
|
impl SharedRt {
|
||||||
|
@ -47,10 +47,6 @@ impl SharedRt {
|
||||||
JS_RequestInterruptCallback(self.rt);
|
JS_RequestInterruptCallback(self.rt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rt(&self) -> *mut JSRuntime {
|
|
||||||
self.rt
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe impl Send for SharedRt {}
|
unsafe impl Send for SharedRt {}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use dom::bindings::cell::DOMRefCell;
|
use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding;
|
use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding;
|
||||||
use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventMethods;
|
use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventMethods;
|
||||||
|
|
|
@ -20,6 +20,7 @@ pub struct ConstantSpec {
|
||||||
|
|
||||||
/// Representation of an IDL constant value.
|
/// Representation of an IDL constant value.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub enum ConstantVal {
|
pub enum ConstantVal {
|
||||||
/// `long` constant.
|
/// `long` constant.
|
||||||
IntVal(i32),
|
IntVal(i32),
|
||||||
|
|
|
@ -129,6 +129,10 @@
|
||||||
//! return `Err()` from the method with the appropriate [error value]
|
//! return `Err()` from the method with the appropriate [error value]
|
||||||
//! (error/enum.Error.html).
|
//! (error/enum.Error.html).
|
||||||
|
|
||||||
|
#![allow(unsafe_code)]
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
#![deny(non_snake_case)]
|
||||||
|
|
||||||
pub mod callback;
|
pub mod callback;
|
||||||
pub mod cell;
|
pub mod cell;
|
||||||
pub mod constant;
|
pub mod constant;
|
||||||
|
@ -153,7 +157,7 @@ pub mod weakref;
|
||||||
pub mod xmlname;
|
pub mod xmlname;
|
||||||
|
|
||||||
/// Generated JS-Rust bindings.
|
/// Generated JS-Rust bindings.
|
||||||
#[allow(missing_docs, non_snake_case)]
|
#[allow(dead_code, missing_docs, non_snake_case)]
|
||||||
pub mod codegen {
|
pub mod codegen {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub mod Bindings {
|
pub mod Bindings {
|
||||||
|
|
|
@ -2,17 +2,15 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::CSSGroupingRuleBinding;
|
|
||||||
use dom::bindings::codegen::Bindings::CSSGroupingRuleBinding::CSSGroupingRuleMethods;
|
use dom::bindings::codegen::Bindings::CSSGroupingRuleBinding::CSSGroupingRuleMethods;
|
||||||
use dom::bindings::error::{ErrorResult, Fallible};
|
use dom::bindings::error::{ErrorResult, Fallible};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{MutNullableJS, Root};
|
use dom::bindings::js::{MutNullableJS, Root};
|
||||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
use dom::bindings::reflector::DomObject;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssrule::CSSRule;
|
use dom::cssrule::CSSRule;
|
||||||
use dom::cssrulelist::{CSSRuleList, RulesSource};
|
use dom::cssrulelist::{CSSRuleList, RulesSource};
|
||||||
use dom::cssstylesheet::CSSStyleSheet;
|
use dom::cssstylesheet::CSSStyleSheet;
|
||||||
use dom::window::Window;
|
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style::stylesheets::CssRules as StyleCssRules;
|
use style::stylesheets::CssRules as StyleCssRules;
|
||||||
|
@ -35,14 +33,6 @@ impl CSSGroupingRule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet,
|
|
||||||
rules: Arc<RwLock<StyleCssRules>>) -> Root<CSSGroupingRule> {
|
|
||||||
reflect_dom_object(box CSSGroupingRule::new_inherited(parent_stylesheet, rules),
|
|
||||||
window,
|
|
||||||
CSSGroupingRuleBinding::Wrap)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rulelist(&self) -> Root<CSSRuleList> {
|
fn rulelist(&self) -> Root<CSSRuleList> {
|
||||||
let parent_stylesheet = self.upcast::<CSSRule>().parent_stylesheet();
|
let parent_stylesheet = self.upcast::<CSSRule>().parent_stylesheet();
|
||||||
self.rulelist.or_init(|| CSSRuleList::new(self.global().as_window(),
|
self.rulelist.or_init(|| CSSRuleList::new(self.global().as_window(),
|
||||||
|
|
|
@ -2,11 +2,10 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::CSSRuleBinding;
|
|
||||||
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods;
|
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, Root};
|
use dom::bindings::js::{JS, Root};
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::Reflector;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::cssfontfacerule::CSSFontFaceRule;
|
use dom::cssfontfacerule::CSSFontFaceRule;
|
||||||
use dom::cssimportrule::CSSImportRule;
|
use dom::cssimportrule::CSSImportRule;
|
||||||
|
@ -43,13 +42,6 @@ impl CSSRule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet) -> Root<CSSRule> {
|
|
||||||
reflect_dom_object(box CSSRule::new_inherited(parent_stylesheet),
|
|
||||||
window,
|
|
||||||
CSSRuleBinding::Wrap)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn as_specific(&self) -> &SpecificCSSRule {
|
pub fn as_specific(&self) -> &SpecificCSSRule {
|
||||||
if let Some(rule) = self.downcast::<CSSStyleRule>() {
|
if let Some(rule) = self.downcast::<CSSStyleRule>() {
|
||||||
rule as &SpecificCSSRule
|
rule as &SpecificCSSRule
|
||||||
|
|
|
@ -40,10 +40,6 @@ impl CSSStyleRule {
|
||||||
window,
|
window,
|
||||||
CSSStyleRuleBinding::Wrap)
|
CSSStyleRuleBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn style_rule(&self) -> Arc<RwLock<StyleRule>> {
|
|
||||||
self.stylerule.clone()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SpecificCSSRule for CSSStyleRule {
|
impl SpecificCSSRule for CSSStyleRule {
|
||||||
|
|
|
@ -29,13 +29,11 @@ pub enum DOMErrorName {
|
||||||
SecurityError = DOMExceptionConstants::SECURITY_ERR,
|
SecurityError = DOMExceptionConstants::SECURITY_ERR,
|
||||||
NetworkError = DOMExceptionConstants::NETWORK_ERR,
|
NetworkError = DOMExceptionConstants::NETWORK_ERR,
|
||||||
AbortError = DOMExceptionConstants::ABORT_ERR,
|
AbortError = DOMExceptionConstants::ABORT_ERR,
|
||||||
URLMismatchError = DOMExceptionConstants::URL_MISMATCH_ERR,
|
|
||||||
TypeMismatchError = DOMExceptionConstants::TYPE_MISMATCH_ERR,
|
TypeMismatchError = DOMExceptionConstants::TYPE_MISMATCH_ERR,
|
||||||
QuotaExceededError = DOMExceptionConstants::QUOTA_EXCEEDED_ERR,
|
QuotaExceededError = DOMExceptionConstants::QUOTA_EXCEEDED_ERR,
|
||||||
TimeoutError = DOMExceptionConstants::TIMEOUT_ERR,
|
TimeoutError = DOMExceptionConstants::TIMEOUT_ERR,
|
||||||
InvalidNodeTypeError = DOMExceptionConstants::INVALID_NODE_TYPE_ERR,
|
InvalidNodeTypeError = DOMExceptionConstants::INVALID_NODE_TYPE_ERR,
|
||||||
DataCloneError = DOMExceptionConstants::DATA_CLONE_ERR,
|
DataCloneError = DOMExceptionConstants::DATA_CLONE_ERR,
|
||||||
EncodingError,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -62,11 +60,7 @@ impl DOMException {
|
||||||
impl DOMExceptionMethods for DOMException {
|
impl DOMExceptionMethods for DOMException {
|
||||||
// https://heycam.github.io/webidl/#dfn-DOMException
|
// https://heycam.github.io/webidl/#dfn-DOMException
|
||||||
fn Code(&self) -> u16 {
|
fn Code(&self) -> u16 {
|
||||||
match self.code {
|
self.code as u16
|
||||||
// https://heycam.github.io/webidl/#dfn-throw
|
|
||||||
DOMErrorName::EncodingError => 0,
|
|
||||||
code => code as u16,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://heycam.github.io/webidl/#idl-DOMException-error-names
|
// https://heycam.github.io/webidl/#idl-DOMException-error-names
|
||||||
|
@ -93,14 +87,12 @@ impl DOMExceptionMethods for DOMException {
|
||||||
DOMErrorName::SecurityError => "The operation is insecure.",
|
DOMErrorName::SecurityError => "The operation is insecure.",
|
||||||
DOMErrorName::NetworkError => "A network error occurred.",
|
DOMErrorName::NetworkError => "A network error occurred.",
|
||||||
DOMErrorName::AbortError => "The operation was aborted.",
|
DOMErrorName::AbortError => "The operation was aborted.",
|
||||||
DOMErrorName::URLMismatchError => "The given URL does not match another URL.",
|
|
||||||
DOMErrorName::TypeMismatchError => "The given type does not match any expected type.",
|
DOMErrorName::TypeMismatchError => "The given type does not match any expected type.",
|
||||||
DOMErrorName::QuotaExceededError => "The quota has been exceeded.",
|
DOMErrorName::QuotaExceededError => "The quota has been exceeded.",
|
||||||
DOMErrorName::TimeoutError => "The operation timed out.",
|
DOMErrorName::TimeoutError => "The operation timed out.",
|
||||||
DOMErrorName::InvalidNodeTypeError =>
|
DOMErrorName::InvalidNodeTypeError =>
|
||||||
"The supplied node is incorrect or has an incorrect ancestor for this operation.",
|
"The supplied node is incorrect or has an incorrect ancestor for this operation.",
|
||||||
DOMErrorName::DataCloneError => "The object can not be cloned.",
|
DOMErrorName::DataCloneError => "The object can not be cloned.",
|
||||||
DOMErrorName::EncodingError => "The encoding operation (either encoded or decoding) failed."
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DOMString::from(message)
|
DOMString::from(message)
|
||||||
|
|
|
@ -85,10 +85,6 @@ impl HTMLFormElement {
|
||||||
document,
|
document,
|
||||||
HTMLFormElementBinding::Wrap)
|
HTMLFormElementBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generation_id(&self) -> GenerationId {
|
|
||||||
self.generation_id.get()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLFormElementMethods for HTMLFormElement {
|
impl HTMLFormElementMethods for HTMLFormElement {
|
||||||
|
@ -662,6 +658,7 @@ impl HTMLFormElement {
|
||||||
|
|
||||||
#[derive(JSTraceable, HeapSizeOf, Clone)]
|
#[derive(JSTraceable, HeapSizeOf, Clone)]
|
||||||
pub enum FormDatumValue {
|
pub enum FormDatumValue {
|
||||||
|
#[allow(dead_code)]
|
||||||
File(Root<File>),
|
File(Root<File>),
|
||||||
String(DOMString)
|
String(DOMString)
|
||||||
}
|
}
|
||||||
|
@ -701,6 +698,7 @@ pub enum FormMethod {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(HeapSizeOf)]
|
#[derive(HeapSizeOf)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub enum FormSubmittableElement {
|
pub enum FormSubmittableElement {
|
||||||
ButtonElement(Root<HTMLButtonElement>),
|
ButtonElement(Root<HTMLButtonElement>),
|
||||||
InputElement(Root<HTMLInputElement>),
|
InputElement(Root<HTMLInputElement>),
|
||||||
|
|
|
@ -77,10 +77,6 @@ impl HTMLLinkElement {
|
||||||
HTMLLinkElementBinding::Wrap)
|
HTMLLinkElementBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parser_inserted(&self) -> bool {
|
|
||||||
self.parser_inserted.get()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_stylesheet(&self, s: Arc<Stylesheet>) {
|
pub fn set_stylesheet(&self, s: Arc<Stylesheet>) {
|
||||||
assert!(self.stylesheet.borrow().is_none());
|
assert!(self.stylesheet.borrow().is_none());
|
||||||
*self.stylesheet.borrow_mut() = Some(s);
|
*self.stylesheet.borrow_mut() = Some(s);
|
||||||
|
|
|
@ -243,11 +243,6 @@ impl HTMLMediaElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn htmlelement(&self) -> &HTMLElement {
|
|
||||||
&self.htmlelement
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#internal-pause-steps
|
// https://html.spec.whatwg.org/multipage/#internal-pause-steps
|
||||||
fn internal_pause_steps(&self) {
|
fn internal_pause_steps(&self) {
|
||||||
// Step 1
|
// Step 1
|
||||||
|
|
|
@ -33,11 +33,6 @@ impl HTMLTableCellElement {
|
||||||
htmlelement: HTMLElement::new_inherited(tag_name, prefix, document),
|
htmlelement: HTMLElement::new_inherited(tag_name, prefix, document),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn htmlelement(&self) -> &HTMLElement {
|
|
||||||
&self.htmlelement
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLTableCellElementMethods for HTMLTableCellElement {
|
impl HTMLTableCellElementMethods for HTMLTableCellElement {
|
||||||
|
|
|
@ -285,11 +285,6 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement {
|
||||||
|
|
||||||
|
|
||||||
impl HTMLTextAreaElement {
|
impl HTMLTextAreaElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#concept-fe-mutable
|
|
||||||
pub fn mutable(&self) -> bool {
|
|
||||||
// https://html.spec.whatwg.org/multipage/#the-textarea-element:concept-fe-mutable
|
|
||||||
!(self.Disabled() || self.ReadOnly())
|
|
||||||
}
|
|
||||||
pub fn reset(&self) {
|
pub fn reset(&self) {
|
||||||
// https://html.spec.whatwg.org/multipage/#the-textarea-element:concept-form-reset-control
|
// https://html.spec.whatwg.org/multipage/#the-textarea-element:concept-form-reset-control
|
||||||
self.SetValue(self.DefaultValue());
|
self.SetValue(self.DefaultValue());
|
||||||
|
|
|
@ -26,12 +26,6 @@ pub struct MediaQueryListEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MediaQueryListEvent {
|
impl MediaQueryListEvent {
|
||||||
pub fn new_uninitialized(global: &GlobalScope) -> Root<MediaQueryListEvent> {
|
|
||||||
MediaQueryListEvent::new_initialized(global,
|
|
||||||
DOMString::new(),
|
|
||||||
false)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new_initialized(global: &GlobalScope,
|
pub fn new_initialized(global: &GlobalScope,
|
||||||
media: DOMString,
|
media: DOMString,
|
||||||
matches: bool) -> Root<MediaQueryListEvent> {
|
matches: bool) -> Root<MediaQueryListEvent> {
|
||||||
|
|
|
@ -217,9 +217,6 @@ pub mod abstractworkerglobalscope;
|
||||||
pub mod activation;
|
pub mod activation;
|
||||||
pub mod attr;
|
pub mod attr;
|
||||||
pub mod beforeunloadevent;
|
pub mod beforeunloadevent;
|
||||||
mod create;
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
#[deny(missing_docs, non_snake_case)]
|
|
||||||
pub mod bindings;
|
pub mod bindings;
|
||||||
pub mod blob;
|
pub mod blob;
|
||||||
pub mod bluetooth;
|
pub mod bluetooth;
|
||||||
|
@ -240,6 +237,7 @@ pub mod client;
|
||||||
pub mod closeevent;
|
pub mod closeevent;
|
||||||
pub mod comment;
|
pub mod comment;
|
||||||
pub mod console;
|
pub mod console;
|
||||||
|
mod create;
|
||||||
pub mod crypto;
|
pub mod crypto;
|
||||||
pub mod css;
|
pub mod css;
|
||||||
pub mod cssfontfacerule;
|
pub mod cssfontfacerule;
|
||||||
|
|
|
@ -79,7 +79,6 @@ impl NodeIteratorMethods for NodeIterator {
|
||||||
match self.filter {
|
match self.filter {
|
||||||
Filter::None => None,
|
Filter::None => None,
|
||||||
Filter::Callback(ref nf) => Some((*nf).clone()),
|
Filter::Callback(ref nf) => Some((*nf).clone()),
|
||||||
Filter::Native(_) => panic!("Cannot convert native node filter to DOM NodeFilter")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +199,6 @@ impl NodeIterator {
|
||||||
// Step 3-5.
|
// Step 3-5.
|
||||||
match self.filter {
|
match self.filter {
|
||||||
Filter::None => Ok(NodeFilterConstants::FILTER_ACCEPT),
|
Filter::None => Ok(NodeFilterConstants::FILTER_ACCEPT),
|
||||||
Filter::Native(f) => Ok((f)(node)),
|
|
||||||
Filter::Callback(ref callback) => callback.AcceptNode_(self, node, Rethrow)
|
Filter::Callback(ref callback) => callback.AcceptNode_(self, node, Rethrow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,6 +208,5 @@ impl NodeIterator {
|
||||||
#[derive(JSTraceable)]
|
#[derive(JSTraceable)]
|
||||||
pub enum Filter {
|
pub enum Filter {
|
||||||
None,
|
None,
|
||||||
Native(fn (node: &Node) -> u16),
|
|
||||||
Callback(Rc<NodeFilter>)
|
Callback(Rc<NodeFilter>)
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,6 @@ impl RadioNodeList {
|
||||||
RadioNodeList::new(window, NodeListType::Simple(iter.map(|r| JS::from_ref(&*r)).collect()))
|
RadioNodeList::new(window, NodeListType::Simple(iter.map(|r| JS::from_ref(&*r)).collect()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn empty(window: &Window) -> Root<RadioNodeList> {
|
|
||||||
RadioNodeList::new(window, NodeListType::Simple(vec![]))
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: This shouldn't need to be implemented here since NodeList (the parent of
|
// FIXME: This shouldn't need to be implemented here since NodeList (the parent of
|
||||||
// RadioNodeList) implements Length
|
// RadioNodeList) implements Length
|
||||||
// https://github.com/servo/servo/issues/5875
|
// https://github.com/servo/servo/issues/5875
|
||||||
|
|
|
@ -2,13 +2,10 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::SVGElementBinding;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
use dom::node::Node;
|
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
use html5ever_atoms::LocalName;
|
use html5ever_atoms::LocalName;
|
||||||
use style::element_state::ElementState;
|
use style::element_state::ElementState;
|
||||||
|
@ -19,11 +16,6 @@ pub struct SVGElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SVGElement {
|
impl SVGElement {
|
||||||
pub fn new_inherited(tag_name: LocalName, prefix: Option<DOMString>,
|
|
||||||
document: &Document) -> SVGElement {
|
|
||||||
SVGElement::new_inherited_with_state(ElementState::empty(), tag_name, prefix, document)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new_inherited_with_state(state: ElementState, tag_name: LocalName,
|
pub fn new_inherited_with_state(state: ElementState, tag_name: LocalName,
|
||||||
prefix: Option<DOMString>, document: &Document)
|
prefix: Option<DOMString>, document: &Document)
|
||||||
-> SVGElement {
|
-> SVGElement {
|
||||||
|
@ -32,13 +24,6 @@ impl SVGElement {
|
||||||
Element::new_inherited_with_state(state, tag_name, ns!(svg), prefix, document),
|
Element::new_inherited_with_state(state, tag_name, ns!(svg), prefix, document),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> Root<SVGElement> {
|
|
||||||
Node::reflect_node(box SVGElement::new_inherited(local_name, prefix, document),
|
|
||||||
document,
|
|
||||||
SVGElementBinding::Wrap)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VirtualMethods for SVGElement {
|
impl VirtualMethods for SVGElement {
|
||||||
|
|
|
@ -2,12 +2,9 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::SVGGraphicsElementBinding;
|
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::Root;
|
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::node::Node;
|
|
||||||
use dom::svgelement::SVGElement;
|
use dom::svgelement::SVGElement;
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
use html5ever_atoms::LocalName;
|
use html5ever_atoms::LocalName;
|
||||||
|
@ -32,13 +29,6 @@ impl SVGGraphicsElement {
|
||||||
SVGElement::new_inherited_with_state(state, tag_name, prefix, document),
|
SVGElement::new_inherited_with_state(state, tag_name, prefix, document),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> Root<SVGGraphicsElement> {
|
|
||||||
Node::reflect_node(box SVGGraphicsElement::new_inherited(local_name, prefix, document),
|
|
||||||
document,
|
|
||||||
SVGGraphicsElementBinding::Wrap)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VirtualMethods for SVGGraphicsElement {
|
impl VirtualMethods for SVGGraphicsElement {
|
||||||
|
|
|
@ -10,8 +10,8 @@ use dom::element::Element;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#validity-states
|
// https://html.spec.whatwg.org/multipage/#validity-states
|
||||||
#[derive(JSTraceable)]
|
#[derive(JSTraceable, HeapSizeOf)]
|
||||||
#[derive(HeapSizeOf)]
|
#[allow(dead_code)]
|
||||||
pub enum ValidityStatus {
|
pub enum ValidityStatus {
|
||||||
ValueMissing,
|
ValueMissing,
|
||||||
TypeMismatch,
|
TypeMismatch,
|
||||||
|
|
|
@ -3,10 +3,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
|
||||||
use dom::bindings::codegen::Bindings::WebGLObjectBinding;
|
use dom::bindings::reflector::Reflector;
|
||||||
use dom::bindings::js::Root;
|
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
|
||||||
use dom::window::Window;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct WebGLObject {
|
pub struct WebGLObject {
|
||||||
|
@ -19,8 +16,4 @@ impl WebGLObject {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(window: &Window) -> Root<WebGLObject> {
|
|
||||||
reflect_dom_object(box WebGLObject::new_inherited(), window, WebGLObjectBinding::Wrap)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2829,39 +2829,4 @@ impl UniformSetterType {
|
||||||
UniformSetterType::FloatMat4 => 16,
|
UniformSetterType::FloatMat4 => 16,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_compatible_with(&self, gl_type: u32) -> bool {
|
|
||||||
gl_type == self.as_gl_constant() || match *self {
|
|
||||||
// Sampler uniform variables have an index value (the index of the
|
|
||||||
// texture), and as such they have to be set as ints
|
|
||||||
UniformSetterType::Int => gl_type == constants::SAMPLER_2D ||
|
|
||||||
gl_type == constants::SAMPLER_CUBE,
|
|
||||||
// Don't ask me why, but it seems we must allow setting bool
|
|
||||||
// uniforms with uniform1f.
|
|
||||||
//
|
|
||||||
// See the WebGL conformance test
|
|
||||||
// conformance/uniforms/gl-uniform-bool.html
|
|
||||||
UniformSetterType::Float => gl_type == constants::BOOL,
|
|
||||||
UniformSetterType::FloatVec2 => gl_type == constants::BOOL_VEC2,
|
|
||||||
UniformSetterType::FloatVec3 => gl_type == constants::BOOL_VEC3,
|
|
||||||
UniformSetterType::FloatVec4 => gl_type == constants::BOOL_VEC4,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn as_gl_constant(&self) -> u32 {
|
|
||||||
match *self {
|
|
||||||
UniformSetterType::Int => constants::INT,
|
|
||||||
UniformSetterType::IntVec2 => constants::INT_VEC2,
|
|
||||||
UniformSetterType::IntVec3 => constants::INT_VEC3,
|
|
||||||
UniformSetterType::IntVec4 => constants::INT_VEC4,
|
|
||||||
UniformSetterType::Float => constants::FLOAT,
|
|
||||||
UniformSetterType::FloatVec2 => constants::FLOAT_VEC2,
|
|
||||||
UniformSetterType::FloatVec3 => constants::FLOAT_VEC3,
|
|
||||||
UniformSetterType::FloatVec4 => constants::FLOAT_VEC4,
|
|
||||||
UniformSetterType::FloatMat2 => constants::FLOAT_MAT2,
|
|
||||||
UniformSetterType::FloatMat3 => constants::FLOAT_MAT3,
|
|
||||||
UniformSetterType::FloatMat4 => constants::FLOAT_MAT4,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
|
||||||
use dom::bindings::codegen::Bindings::WebGLShaderPrecisionFormatBinding;
|
use dom::bindings::codegen::Bindings::WebGLShaderPrecisionFormatBinding;
|
||||||
use dom::bindings::codegen::Bindings::WebGLShaderPrecisionFormatBinding::WebGLShaderPrecisionFormatMethods;
|
use dom::bindings::codegen::Bindings::WebGLShaderPrecisionFormatBinding::WebGLShaderPrecisionFormatMethods;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom/#the-cssgroupingrule-interface
|
// https://drafts.csswg.org/cssom/#the-cssgroupingrule-interface
|
||||||
[Exposed=Window]
|
[Abstract, Exposed=Window]
|
||||||
interface CSSGroupingRule : CSSRule {
|
interface CSSGroupingRule : CSSRule {
|
||||||
[SameObject] readonly attribute CSSRuleList cssRules;
|
[SameObject] readonly attribute CSSRuleList cssRules;
|
||||||
[Throws] unsigned long insertRule(DOMString rule, unsigned long index);
|
[Throws] unsigned long insertRule(DOMString rule, unsigned long index);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom/#the-cssrule-interface
|
// https://drafts.csswg.org/cssom/#the-cssrule-interface
|
||||||
[Exposed=Window]
|
[Abstract, Exposed=Window]
|
||||||
interface CSSRule {
|
interface CSSRule {
|
||||||
const unsigned short STYLE_RULE = 1;
|
const unsigned short STYLE_RULE = 1;
|
||||||
const unsigned short CHARSET_RULE = 2; // historical
|
const unsigned short CHARSET_RULE = 2; // historical
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
// https://svgwg.org/svg2-draft/types.html#InterfaceSVGElement
|
// https://svgwg.org/svg2-draft/types.html#InterfaceSVGElement
|
||||||
[Pref="dom.svg.enabled"]
|
[Abstract, Pref="dom.svg.enabled"]
|
||||||
interface SVGElement : Element {
|
interface SVGElement : Element {
|
||||||
|
|
||||||
//[SameObject] readonly attribute SVGAnimatedString className;
|
//[SameObject] readonly attribute SVGAnimatedString className;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
// https://svgwg.org/svg2-draft/types.html#InterfaceSVGGraphicsElement
|
// https://svgwg.org/svg2-draft/types.html#InterfaceSVGGraphicsElement
|
||||||
[Pref="dom.svg.enabled"]
|
|
||||||
//dictionary SVGBoundingBoxOptions {
|
//dictionary SVGBoundingBoxOptions {
|
||||||
// boolean fill = true;
|
// boolean fill = true;
|
||||||
// boolean stroke = false;
|
// boolean stroke = false;
|
||||||
|
@ -11,6 +10,7 @@
|
||||||
// boolean clipped = false;
|
// boolean clipped = false;
|
||||||
//};
|
//};
|
||||||
|
|
||||||
|
[Abstract, Pref="dom.svg.enabled"]
|
||||||
interface SVGGraphicsElement : SVGElement {
|
interface SVGGraphicsElement : SVGElement {
|
||||||
//[SameObject] readonly attribute SVGAnimatedTransformList transform;
|
//[SameObject] readonly attribute SVGAnimatedTransformList transform;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.3
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.3
|
||||||
//
|
//
|
||||||
|
|
||||||
[Exposed=Window]
|
[Abstract, Exposed=Window]
|
||||||
interface WebGLObject {
|
interface WebGLObject {
|
||||||
};
|
};
|
||||||
|
|
|
@ -142,8 +142,6 @@ pub enum ReflowReason {
|
||||||
ElementStateChanged,
|
ElementStateChanged,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ScrollPoint = Point2D<Au>;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
globalscope: GlobalScope,
|
globalscope: GlobalScope,
|
||||||
|
|
|
@ -105,7 +105,7 @@ pub mod clipboard_provider;
|
||||||
mod devtools;
|
mod devtools;
|
||||||
pub mod document_loader;
|
pub mod document_loader;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod dom;
|
mod dom;
|
||||||
pub mod fetch;
|
pub mod fetch;
|
||||||
pub mod layout_wrapper;
|
pub mod layout_wrapper;
|
||||||
mod mem;
|
mod mem;
|
||||||
|
@ -118,6 +118,7 @@ mod serviceworker_manager;
|
||||||
mod serviceworkerjob;
|
mod serviceworkerjob;
|
||||||
mod stylesheet_loader;
|
mod stylesheet_loader;
|
||||||
mod task_source;
|
mod task_source;
|
||||||
|
pub mod test;
|
||||||
pub mod textinput;
|
pub mod textinput;
|
||||||
mod timers;
|
mod timers;
|
||||||
mod unpremultiplytable;
|
mod unpremultiplytable;
|
||||||
|
|
60
components/script/test.rs
Normal file
60
components/script/test.rs
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* 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/. */
|
||||||
|
|
||||||
|
pub use dom::bindings::str::{ByteString, DOMString};
|
||||||
|
pub use dom::headers::normalize_value;
|
||||||
|
|
||||||
|
// For compile-fail tests only.
|
||||||
|
pub use dom::bindings::cell::DOMRefCell;
|
||||||
|
pub use dom::bindings::js::JS;
|
||||||
|
pub use dom::node::Node;
|
||||||
|
|
||||||
|
pub mod size_of {
|
||||||
|
use dom::characterdata::CharacterData;
|
||||||
|
use dom::element::Element;
|
||||||
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::htmldivelement::HTMLDivElement;
|
||||||
|
use dom::htmlelement::HTMLElement;
|
||||||
|
use dom::htmlspanelement::HTMLSpanElement;
|
||||||
|
use dom::node::Node;
|
||||||
|
use dom::text::Text;
|
||||||
|
use layout_wrapper::ServoThreadSafeLayoutNode;
|
||||||
|
use std::mem::size_of;
|
||||||
|
|
||||||
|
pub fn CharacterData() -> usize {
|
||||||
|
size_of::<CharacterData>()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn Element() -> usize {
|
||||||
|
size_of::<Element>()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn EventTarget() -> usize {
|
||||||
|
size_of::<EventTarget>()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn HTMLDivElement() -> usize {
|
||||||
|
size_of::<HTMLDivElement>()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn HTMLElement() -> usize {
|
||||||
|
size_of::<HTMLElement>()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn HTMLSpanElement() -> usize {
|
||||||
|
size_of::<HTMLSpanElement>()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn Node() -> usize {
|
||||||
|
size_of::<Node>()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn ServoThreadSafeLayoutNode() -> usize {
|
||||||
|
size_of::<ServoThreadSafeLayoutNode>()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn Text() -> usize {
|
||||||
|
size_of::<Text>()
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
extern crate script;
|
extern crate script;
|
||||||
|
|
||||||
use script::dom::bindings::cell::DOMRefCell;
|
use script::test::DOMRefCell;
|
||||||
use script::dom::bindings::js::JS;
|
use script::test::JS;
|
||||||
use script::dom::node::Node;
|
use script::test::Node;
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
bar: DOMRefCell<JS<Node>>
|
bar: DOMRefCell<JS<Node>>
|
||||||
|
|
|
@ -2,14 +2,13 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use script::dom::bindings::str::ByteString;
|
use script::test::{ByteString, normalize_value};
|
||||||
use script::dom::headers;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_normalize_empty_bytestring() {
|
fn test_normalize_empty_bytestring() {
|
||||||
// empty ByteString test
|
// empty ByteString test
|
||||||
let empty_bytestring = ByteString::new(vec![]);
|
let empty_bytestring = ByteString::new(vec![]);
|
||||||
let actual = headers::normalize_value(empty_bytestring);
|
let actual = normalize_value(empty_bytestring);
|
||||||
let expected = ByteString::new(vec![]);
|
let expected = ByteString::new(vec![]);
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +17,7 @@ fn test_normalize_empty_bytestring() {
|
||||||
fn test_normalize_all_whitespace_bytestring() {
|
fn test_normalize_all_whitespace_bytestring() {
|
||||||
// All whitespace test. A horizontal tab, a line feed, a carriage return , and a space
|
// All whitespace test. A horizontal tab, a line feed, a carriage return , and a space
|
||||||
let all_whitespace_bytestring = ByteString::new(vec![b'\t', b'\n', b'\r', b' ']);
|
let all_whitespace_bytestring = ByteString::new(vec![b'\t', b'\n', b'\r', b' ']);
|
||||||
let actual = headers::normalize_value(all_whitespace_bytestring);
|
let actual = normalize_value(all_whitespace_bytestring);
|
||||||
let expected = ByteString::new(vec![]);
|
let expected = ByteString::new(vec![]);
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +26,7 @@ fn test_normalize_all_whitespace_bytestring() {
|
||||||
fn test_normalize_non_empty_no_whitespace_bytestring() {
|
fn test_normalize_non_empty_no_whitespace_bytestring() {
|
||||||
// Non-empty, no whitespace ByteString test
|
// Non-empty, no whitespace ByteString test
|
||||||
let no_whitespace_bytestring = ByteString::new(vec![b'S', b'!']);
|
let no_whitespace_bytestring = ByteString::new(vec![b'S', b'!']);
|
||||||
let actual = headers::normalize_value(no_whitespace_bytestring);
|
let actual = normalize_value(no_whitespace_bytestring);
|
||||||
let expected = ByteString::new(vec![b'S', b'!']);
|
let expected = ByteString::new(vec![b'S', b'!']);
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +35,7 @@ fn test_normalize_non_empty_no_whitespace_bytestring() {
|
||||||
fn test_normalize_non_empty_leading_whitespace_bytestring() {
|
fn test_normalize_non_empty_leading_whitespace_bytestring() {
|
||||||
// Non-empty, leading whitespace, no trailing whitespace ByteString test
|
// Non-empty, leading whitespace, no trailing whitespace ByteString test
|
||||||
let leading_whitespace_bytestring = ByteString::new(vec![b'\t', b'\n', b' ', b'\r', b'S', b'!']);
|
let leading_whitespace_bytestring = ByteString::new(vec![b'\t', b'\n', b' ', b'\r', b'S', b'!']);
|
||||||
let actual = headers::normalize_value(leading_whitespace_bytestring);
|
let actual = normalize_value(leading_whitespace_bytestring);
|
||||||
let expected = ByteString::new(vec![b'S', b'!']);
|
let expected = ByteString::new(vec![b'S', b'!']);
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +44,7 @@ fn test_normalize_non_empty_leading_whitespace_bytestring() {
|
||||||
fn test_normalize_non_empty_no_leading_whitespace_trailing_whitespace_bytestring() {
|
fn test_normalize_non_empty_no_leading_whitespace_trailing_whitespace_bytestring() {
|
||||||
// Non-empty, no leading whitespace, but with trailing whitespace ByteString test
|
// Non-empty, no leading whitespace, but with trailing whitespace ByteString test
|
||||||
let trailing_whitespace_bytestring = ByteString::new(vec![b'S', b'!', b'\t', b'\n', b' ', b'\r']);
|
let trailing_whitespace_bytestring = ByteString::new(vec![b'S', b'!', b'\t', b'\n', b' ', b'\r']);
|
||||||
let actual = headers::normalize_value(trailing_whitespace_bytestring);
|
let actual = normalize_value(trailing_whitespace_bytestring);
|
||||||
let expected = ByteString::new(vec![b'S', b'!']);
|
let expected = ByteString::new(vec![b'S', b'!']);
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +54,7 @@ fn test_normalize_non_empty_leading_and_trailing_whitespace_bytestring() {
|
||||||
// Non-empty, leading whitespace, and trailing whitespace ByteString test
|
// Non-empty, leading whitespace, and trailing whitespace ByteString test
|
||||||
let whitespace_sandwich_bytestring =
|
let whitespace_sandwich_bytestring =
|
||||||
ByteString::new(vec![b'\t', b'\n', b' ', b'\r', b'S', b'!', b'\t', b'\n', b' ', b'\r']);
|
ByteString::new(vec![b'\t', b'\n', b' ', b'\r', b'S', b'!', b'\t', b'\n', b' ', b'\r']);
|
||||||
let actual = headers::normalize_value(whitespace_sandwich_bytestring);
|
let actual = normalize_value(whitespace_sandwich_bytestring);
|
||||||
let expected = ByteString::new(vec![b'S', b'!']);
|
let expected = ByteString::new(vec![b'S', b'!']);
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +67,7 @@ fn test_normalize_non_empty_leading_trailing_and_internal_whitespace_bytestring(
|
||||||
ByteString::new(vec![b'\t', b'\n', b' ', b'\r', b'S',
|
ByteString::new(vec![b'\t', b'\n', b' ', b'\r', b'S',
|
||||||
b'\t', b'\n', b' ', b'\r', b'!',
|
b'\t', b'\n', b' ', b'\r', b'!',
|
||||||
b'\t', b'\n', b' ', b'\r']);
|
b'\t', b'\n', b' ', b'\r']);
|
||||||
let actual = headers::normalize_value(whitespace_bigmac_bytestring);
|
let actual = normalize_value(whitespace_bigmac_bytestring);
|
||||||
let expected = ByteString::new(vec![b'S', b'\t', b'\n', b' ', b'\r', b'!']);
|
let expected = ByteString::new(vec![b'S', b'\t', b'\n', b' ', b'\r', b'!']);
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,25 +2,16 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use script::dom::characterdata::CharacterData;
|
use script::test::size_of;
|
||||||
use script::dom::element::Element;
|
|
||||||
use script::dom::eventtarget::EventTarget;
|
|
||||||
use script::dom::htmldivelement::HTMLDivElement;
|
|
||||||
use script::dom::htmlelement::HTMLElement;
|
|
||||||
use script::dom::htmlspanelement::HTMLSpanElement;
|
|
||||||
use script::dom::node::Node;
|
|
||||||
use script::dom::text::Text;
|
|
||||||
use script::layout_wrapper::ServoThreadSafeLayoutNode;
|
|
||||||
use std::mem::size_of;
|
|
||||||
|
|
||||||
// Macro so that we can stringify type names
|
// Macro so that we can stringify type names
|
||||||
// I'd really prefer the tests themselves to be run at plugin time,
|
// I'd really prefer the tests themselves to be run at plugin time,
|
||||||
// however rustc::middle doesn't have access to the full type data
|
// however rustc::middle doesn't have access to the full type data
|
||||||
macro_rules! sizeof_checker (
|
macro_rules! sizeof_checker (
|
||||||
($testname: ident, $t:ty, $known_size:expr) => (
|
($testname: ident, $t: ident, $known_size: expr) => (
|
||||||
#[test]
|
#[test]
|
||||||
fn $testname() {
|
fn $testname() {
|
||||||
let new = size_of::<$t>();
|
let new = size_of::$t();
|
||||||
let old = $known_size;
|
let old = $known_size;
|
||||||
if new < old {
|
if new < old {
|
||||||
panic!("Your changes have decreased the stack size of commonly used DOM struct {} from {} to {}. \
|
panic!("Your changes have decreased the stack size of commonly used DOM struct {} from {} to {}. \
|
||||||
|
|
|
@ -13,7 +13,7 @@ use msg::constellation_msg::CONTROL;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use msg::constellation_msg::SUPER;
|
use msg::constellation_msg::SUPER;
|
||||||
use script::clipboard_provider::DummyClipboardContext;
|
use script::clipboard_provider::DummyClipboardContext;
|
||||||
use script::dom::bindings::str::DOMString;
|
use script::test::DOMString;
|
||||||
use script::textinput::{TextInput, TextPoint, Selection, Lines, Direction, SelectionDirection};
|
use script::textinput::{TextInput, TextPoint, Selection, Lines, Direction, SelectionDirection};
|
||||||
|
|
||||||
fn text_input(lines: Lines, s: &str) -> TextInput<DummyClipboardContext> {
|
fn text_input(lines: Lines, s: &str) -> TextInput<DummyClipboardContext> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue