aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py225
-rw-r--r--components/script/dom/bindings/codegen/Configuration.py13
-rw-r--r--components/script/dom/document.rs15
-rw-r--r--components/script/dom/element.rs5
-rw-r--r--components/script/dom/workerglobalscope.rs2
-rw-r--r--components/script/lib.rs4
-rw-r--r--components/script/script_task.rs57
7 files changed, 77 insertions, 244 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 9bfaa0c9cfd..d6ca15dd546 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -5,7 +5,6 @@
# Common codegen classes.
import operator
-import os
import re
import string
import textwrap
@@ -24,7 +23,6 @@ from Configuration import getTypesFromDescriptor, getTypesFromDictionary, getTyp
AUTOGENERATED_WARNING_COMMENT = \
"/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n"
-ADDPROPERTY_HOOK_NAME = '_addProperty'
FINALIZE_HOOK_NAME = '_finalize'
TRACE_HOOK_NAME = '_trace'
CONSTRUCT_HOOK_NAME = '_constructor'
@@ -528,17 +526,6 @@ class CGMethodCall(CGThing):
return self.cgRoot.define()
-class FakeCastableDescriptor():
- def __init__(self, descriptor):
- self.nativeType = "*const %s" % descriptor.concreteType
- self.name = descriptor.name
-
- class FakeInterface:
- def inheritanceDepth(self):
- return descriptor.interface.inheritanceDepth()
- self.interface = FakeInterface()
-
-
def dictionaryHasSequenceMember(dictionary):
return (any(typeIsSequenceOrHasSequenceMember(m.type) for m in
dictionary.members) or
@@ -695,15 +682,6 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
'%s' % (firstCap(sourceDescription), exceptionCode))),
post="\n")
- def onFailureBadType(failureCode, typeName):
- return CGWrapper(
- CGGeneric(
- failureCode or
- ('throw_type_error(cx, \"%s does not implement interface %s.\");\n'
- '%s' % (firstCap(sourceDescription), typeName,
- exceptionCode))),
- post="\n")
-
def onFailureNotCallable(failureCode):
return CGWrapper(
CGGeneric(
@@ -1267,18 +1245,6 @@ def typeNeedsCx(type, retVal=False):
return type.isAny() or type.isObject()
-def typeRetValNeedsRooting(type):
- if type is None:
- return False
- if type.nullable():
- type = type.inner
- return type.isGeckoInterface() and not type.isCallback() and not type.isCallbackInterface()
-
-
-def memberIsCreator(member):
- return member.getExtendedAttribute("Creator") is not None
-
-
# Returns a CGThing containing the type of the return value.
def getRetvalDeclarationForType(returnType, descriptorProvider):
if returnType is None or returnType.isVoid():
@@ -1726,13 +1692,6 @@ class CGImports(CGWrapper):
CGWrapper.__init__(self, child,
pre='\n'.join(statements) + '\n\n')
- @staticmethod
- def getDeclarationFilename(decl):
- # Use our local version of the header, not the exported one, so that
- # test bindings, which don't export, will work correctly.
- basename = os.path.basename(decl.filename())
- return basename.replace('.webidl', 'Binding.rs')
-
class CGIfWrapper(CGWrapper):
def __init__(self, child, condition):
@@ -2649,11 +2608,6 @@ class CGCallGenerator(CGThing):
return self.cgRoot.define()
-class MethodNotCreatorError(Exception):
- def __init__(self, typename):
- self.typename = typename
-
-
class CGPerSignatureCall(CGThing):
"""
This class handles the guts of generating code for a particular
@@ -2826,10 +2780,6 @@ class CGSetterCall(CGPerSignatureCall):
def getArgc(self):
return "1"
- def getArgvDecl(self):
- # We just get our stuff from our last arg no matter what
- return ""
-
class CGAbstractStaticBindingMethod(CGAbstractMethod):
"""
@@ -3695,31 +3645,6 @@ class ClassMethod(ClassItem):
pass
-class ClassUsingDeclaration(ClassItem):
- """"
- Used for importing a name from a base class into a CGClass
-
- baseClass is the name of the base class to import the name from
-
- name is the name to import
-
- visibility determines the visibility of the name (public,
- protected, private), defaults to public.
- """
- def __init__(self, baseClass, name, visibility='public'):
- self.baseClass = baseClass
- ClassItem.__init__(self, name, visibility)
-
- def declare(self, cgClass):
- return string.Template("""\
-using ${baseClass}::${name};
-""").substitute({'baseClass': self.baseClass,
- 'name': self.name})
-
- def define(self, cgClass):
- return ''
-
-
class ClassConstructor(ClassItem):
"""
Used for adding a constructor to a CGClass.
@@ -3825,77 +3750,6 @@ ${className}::${className}(${args})${initializationList}
'body': body})
-class ClassDestructor(ClassItem):
- """
- Used for adding a destructor to a CGClass.
-
- inline should be True if the destructor should be marked inline.
-
- bodyInHeader should be True if the body should be placed in the class
- declaration in the header.
-
- visibility determines the visibility of the destructor (public,
- protected, private), defaults to private.
-
- body contains a string with the code for the destructor, defaults to empty.
-
- virtual determines whether the destructor is virtual, defaults to False.
- """
- def __init__(self, inline=False, bodyInHeader=False,
- visibility="private", body='', virtual=False):
- self.inline = inline or bodyInHeader
- self.bodyInHeader = bodyInHeader
- self.body = body
- self.virtual = virtual
- ClassItem.__init__(self, None, visibility)
-
- def getDecorators(self, declaring):
- decorators = []
- if self.virtual and declaring:
- decorators.append('virtual')
- if self.inline and declaring:
- decorators.append('inline')
- if decorators:
- return ' '.join(decorators) + ' '
- return ''
-
- def getBody(self):
- return self.body
-
- def declare(self, cgClass):
- if self.bodyInHeader:
- body = ' ' + self.getBody()
- body = stripTrailingWhitespace(body.replace('\n', '\n '))
- if len(body) > 0:
- body += '\n'
- body = '\n{\n' + body + '}'
- else:
- body = ';'
-
- return string.Template("""\
-${decorators}~${className}()${body}
-""").substitute({'decorators': self.getDecorators(True),
- 'className': cgClass.getNameString(),
- 'body': body})
-
- def define(self, cgClass):
- if self.bodyInHeader:
- return ''
-
- body = ' ' + self.getBody()
- body = '\n' + stripTrailingWhitespace(body.replace('\n', '\n '))
- if len(body) > 0:
- body += '\n'
-
- return string.Template("""\
-${decorators}
-${className}::~${className}()
-{${body}}
-""").substitute({'decorators': self.getDecorators(False),
- 'className': cgClass.getNameString(),
- 'body': body})
-
-
class ClassMember(ClassItem):
def __init__(self, name, type, visibility="priv", static=False,
body=None):
@@ -3918,63 +3772,14 @@ class ClassMember(ClassItem):
self.name, body)
-class ClassTypedef(ClassItem):
- def __init__(self, name, type, visibility="public"):
- self.type = type
- ClassItem.__init__(self, name, visibility)
-
- def declare(self, cgClass):
- return 'typedef %s %s;\n' % (self.type, self.name)
-
- def define(self, cgClass):
- # Only goes in the header
- return ''
-
-
-class ClassEnum(ClassItem):
- def __init__(self, name, entries, values=None, visibility="public"):
- self.entries = entries
- self.values = values
- ClassItem.__init__(self, name, visibility)
-
- def declare(self, cgClass):
- entries = []
- for i in range(0, len(self.entries)):
- if not self.values or i >= len(self.values):
- entry = '%s' % self.entries[i]
- else:
- entry = '%s = %s' % (self.entries[i], self.values[i])
- entries.append(entry)
- name = '' if not self.name else ' ' + self.name
- return 'enum%s\n{\n%s\n};\n' % (name, ',\n '.join(entries))
-
- def define(self, cgClass):
- # Only goes in the header
- return ''
-
-
-class ClassUnion(ClassItem):
- def __init__(self, name, entries, visibility="public"):
- self.entries = [entry + ";" for entry in entries]
- ClassItem.__init__(self, name, visibility)
-
- def declare(self, cgClass):
- return 'union %s\n{\n%s\n};\n' % (self.name, '\n '.join(self.entries))
-
- def define(self, cgClass):
- # Only goes in the header
- return ''
-
-
class CGClass(CGThing):
def __init__(self, name, bases=[], members=[], constructors=[],
destructor=None, methods=[],
typedefs=[], enums=[], unions=[], templateArgs=[],
- templateSpecialization=[], isStruct=False,
+ templateSpecialization=[],
disallowCopyConstruction=False, indent='',
decorators='',
- extradeclarations='',
- extradefinitions=''):
+ extradeclarations=''):
CGThing.__init__(self)
self.name = name
self.bases = bases
@@ -3989,12 +3794,10 @@ class CGClass(CGThing):
self.unions = unions
self.templateArgs = templateArgs
self.templateSpecialization = templateSpecialization
- self.isStruct = isStruct
self.disallowCopyConstruction = disallowCopyConstruction
self.indent = indent
self.decorators = decorators
self.extradeclarations = extradeclarations
- self.extradefinitions = extradefinitions
def getNameString(self):
className = self.name
@@ -4170,15 +3973,6 @@ class CGProxyNamedGetter(CGProxySpecialOperation):
CGProxySpecialOperation.__init__(self, descriptor, 'NamedGetter')
-class CGProxyNamedPresenceChecker(CGProxyNamedGetter):
- """
- Class to generate a call that checks whether a named property exists.
- For now, we just delegate to CGProxyNamedGetter
- """
- def __init__(self, descriptor):
- CGProxyNamedGetter.__init__(self, descriptor)
-
-
class CGProxyNamedSetter(CGProxySpecialOperation):
"""
Class to generate a call to a named setter.
@@ -5041,10 +4835,6 @@ class CGDictionary(CGThing):
return CGGeneric(conversion)
@staticmethod
- def makeIdName(name):
- return name + "_id"
-
- @staticmethod
def makeMemberName(name):
# Can't use Rust keywords as member names.
if name == "type":
@@ -5297,12 +5087,8 @@ def return_type(descriptorProvider, rettype, infallible):
class CGNativeMember(ClassMethod):
def __init__(self, descriptorProvider, member, name, signature, extendedAttrs,
- breakAfter=True, passJSBitsAsNeeded=True, visibility="public",
- jsObjectsArePtr=False, variadicIsSequence=False):
+ breakAfter=True, passJSBitsAsNeeded=True, visibility="public"):
"""
- If jsObjectsArePtr is true, typed arrays and "object" will be
- passed as JSObject*.
-
If passJSBitsAsNeeded is false, we don't automatically pass in a
JSContext* or a JSObject* based on the return and argument types.
"""
@@ -5310,8 +5096,6 @@ class CGNativeMember(ClassMethod):
self.member = member
self.extendedAttrs = extendedAttrs
self.passJSBitsAsNeeded = passJSBitsAsNeeded
- self.jsObjectsArePtr = jsObjectsArePtr
- self.variadicIsSequence = variadicIsSequence
breakAfterSelf = "\n" if breakAfter else ""
ClassMethod.__init__(self, name,
self.getReturnType(signature[0]),
@@ -5543,8 +5327,7 @@ class CallbackMember(CGNativeMember):
name, (self.retvalType, args),
extendedAttrs={},
passJSBitsAsNeeded=False,
- visibility=visibility,
- jsObjectsArePtr=True)
+ visibility=visibility)
# We have to do all the generation of our body now, because
# the caller relies on us throwing if we can't manage it.
self.exceptionCode = "return Err(JSFailed);"
diff --git a/components/script/dom/bindings/codegen/Configuration.py b/components/script/dom/bindings/codegen/Configuration.py
index 436823a9329..4e740f83a16 100644
--- a/components/script/dom/bindings/codegen/Configuration.py
+++ b/components/script/dom/bindings/codegen/Configuration.py
@@ -4,8 +4,6 @@
from WebIDL import IDLInterface
-autogenerated_comment = "/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n"
-
class Configuration:
"""
@@ -344,17 +342,6 @@ def getTypesFromDescriptor(descriptor):
return types
-def getFlatTypes(types):
- retval = set()
- for type in types:
- type = type.unroll()
- if type.isUnion():
- retval |= set(type.flatMemberTypes)
- else:
- retval.add(type)
- return retval
-
-
def getTypesFromDictionary(dictionary):
"""
Get all member types for this dictionary
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 4f4b43437e7..d60545e159b 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -289,6 +289,7 @@ pub trait DocumentHelpers<'a> {
fn load_async(self, load: LoadType, listener: AsyncResponseTarget);
fn load_sync(self, load: LoadType) -> Result<(Metadata, Vec<u8>), String>;
fn finish_load(self, load: LoadType);
+ fn notify_constellation_load(self);
fn set_current_parser(self, script: Option<&ServoHTMLParser>);
fn get_current_parser(self) -> Option<Root<ServoHTMLParser>>;
fn find_iframe(self, subpage_id: SubpageId) -> Option<Root<HTMLIFrameElement>>;
@@ -956,9 +957,10 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
let window = window.r();
let performance = window.Performance();
let performance = performance.r();
+ let timing = performance.Now();
for (_, callback) in animation_frame_list {
- callback(*performance.Now());
+ callback(*timing);
}
window.reflow(ReflowGoal::ForDisplay,
@@ -986,6 +988,15 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
loader.finish_load(load);
}
+ fn notify_constellation_load(self) {
+ let window = self.window.root();
+ let pipeline_id = window.r().pipeline();
+ let ConstellationChan(ref chan) = window.r().constellation_chan();
+ let event = ConstellationMsg::DOMLoad(pipeline_id);
+ chan.send(event).unwrap();
+
+ }
+
fn set_current_parser(self, script: Option<&ServoHTMLParser>) {
self.current_parser.set(script.map(JS::from_ref));
}
@@ -1904,6 +1915,8 @@ impl DocumentProgressHandler {
event.r().fire(target);
});
+ document.r().notify_constellation_load();
+
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadend
document.r().trigger_mozbrowser_event(MozBrowserEvent::LoadEnd);
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 8ebcfc3f3dc..34309eee29a 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -26,7 +26,6 @@ use dom::bindings::codegen::InheritTypes::{HTMLTableElementDerived, HTMLTableCel
use dom::bindings::codegen::InheritTypes::{HTMLTableRowElementDerived, HTMLTextAreaElementDerived};
use dom::bindings::codegen::InheritTypes::{HTMLTableSectionElementDerived, NodeCast};
use dom::bindings::codegen::InheritTypes::HTMLAnchorElementCast;
-use dom::bindings::codegen::InheritTypes::HTMLTableDataCellElementDerived;
use dom::bindings::codegen::InheritTypes::TextCast;
use dom::bindings::codegen::UnionTypes::NodeOrString;
use dom::bindings::error::{ErrorResult, Fallible};
@@ -259,7 +258,7 @@ impl RawLayoutElementHelpers for Element {
} else if self.is_htmltableelement() {
let this: &HTMLTableElement = mem::transmute(self);
this.get_background_color()
- } else if self.is_htmltabledatacellelement() {
+ } else if self.is_htmltablecellelement() {
let this: &HTMLTableCellElement = mem::transmute(self);
this.get_background_color()
} else if self.is_htmltablerowelement() {
@@ -357,7 +356,7 @@ impl RawLayoutElementHelpers for Element {
} else if self.is_htmltableelement() {
let this: &HTMLTableElement = mem::transmute(self);
this.get_width()
- } else if self.is_htmltabledatacellelement() {
+ } else if self.is_htmltablecellelement() {
let this: &HTMLTableCellElement = mem::transmute(self);
this.get_width()
} else {
diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs
index 1338ca49522..9a56676eb03 100644
--- a/components/script/dom/workerglobalscope.rs
+++ b/components/script/dom/workerglobalscope.rs
@@ -136,7 +136,7 @@ impl WorkerGlobalScope {
}
pub fn resource_task<'a>(&'a self) -> &'a ResourceTask {
- & self.resource_task
+ &self.resource_task
}
pub fn get_url<'a>(&'a self) -> &'a Url {
diff --git a/components/script/lib.rs b/components/script/lib.rs
index 8fc23dc78b4..81a1a62b189 100644
--- a/components/script/lib.rs
+++ b/components/script/lib.rs
@@ -95,7 +95,7 @@ mod devtools;
mod horribly_inefficient_timers;
mod webdriver_handlers;
-#[cfg(any(target_os="linux", target_os="android"))]
+#[cfg(target_os="linux")]
#[allow(unsafe_code)]
fn perform_platform_specific_initialization() {
use std::mem;
@@ -111,7 +111,7 @@ fn perform_platform_specific_initialization() {
}
}
-#[cfg(not(any(target_os="linux", target_os="android")))]
+#[cfg(not(target_os="linux"))]
fn perform_platform_specific_initialization() {}
#[allow(unsafe_code)]
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index 9b57e9283b5..efbad39dc86 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -53,7 +53,7 @@ use timers::TimerId;
use devtools;
use webdriver_handlers;
-use devtools_traits::{DevtoolsControlPort, DevtoolsPageInfo, DevtoolScriptControlMsg};
+use devtools_traits::{DevtoolsPageInfo, DevtoolScriptControlMsg};
use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType};
use devtools_traits::{TracingMetadata};
use script_traits::CompositorEvent::{MouseDownEvent, MouseUpEvent};
@@ -78,6 +78,7 @@ use string_cache::Atom;
use util::str::DOMString;
use util::task::spawn_named_with_send_on_failure;
use util::task_state;
+use util::opts;
use euclid::Rect;
use euclid::point::Point2D;
@@ -89,6 +90,7 @@ use js::jsapi::{JS_SetWrapObjectCallbacks, JS_AddExtraGCRootsTracer, DisableIncr
use js::jsapi::{JSContext, JSRuntime, JSTracer};
use js::jsapi::{JS_GetRuntime, JS_SetGCCallback, JSGCStatus, JSAutoRequest, SetDOMCallbacks};
use js::jsapi::{SetDOMProxyInformation, DOMProxyShadowsResult, HandleObject, HandleId, RootedValue};
+use js::jsapi::{JSGCInvocationKind, GCDescription, SetGCSliceCallback, GCProgress};
use js::jsval::UndefinedValue;
use js::rust::Runtime;
use url::{Url, UrlParser};
@@ -98,6 +100,7 @@ use std::any::Any;
use std::borrow::ToOwned;
use std::cell::{Cell, RefCell};
use std::collections::HashSet;
+use std::io::{stdout, Write};
use std::mem as std_mem;
use std::option::Option;
use std::ptr;
@@ -105,7 +108,7 @@ use std::rc::Rc;
use std::result::Result;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{channel, Sender, Receiver, Select};
-use time::Tm;
+use time::{self, Tm};
use hyper::header::{ContentType, HttpDate};
use hyper::mime::{Mime, TopLevel, SubLevel};
@@ -333,7 +336,7 @@ pub struct ScriptTask {
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
/// For receiving commands from an optional devtools server. Will be ignored if
/// no such server exists.
- devtools_port: DevtoolsControlPort,
+ devtools_port: Receiver<DevtoolScriptControlMsg>,
devtools_sender: IpcSender<DevtoolScriptControlMsg>,
/// For sending timeline markers. Will be ignored if
/// no devtools server
@@ -454,6 +457,49 @@ impl ScriptTaskFactory for ScriptTask {
}
}
+thread_local!(static GC_CYCLE_START: Cell<Option<Tm>> = Cell::new(None));
+thread_local!(static GC_SLICE_START: Cell<Option<Tm>> = Cell::new(None));
+
+unsafe extern "C" fn gc_slice_callback(_rt: *mut JSRuntime, progress: GCProgress, desc: *const GCDescription) {
+ match progress {
+ GCProgress::GC_CYCLE_BEGIN => {
+ GC_CYCLE_START.with(|start| {
+ start.set(Some(time::now()));
+ println!("GC cycle began");
+ })
+ },
+ GCProgress::GC_SLICE_BEGIN => {
+ GC_SLICE_START.with(|start| {
+ start.set(Some(time::now()));
+ println!("GC slice began");
+ })
+ },
+ GCProgress::GC_SLICE_END => {
+ GC_SLICE_START.with(|start| {
+ let dur = time::now() - start.get().unwrap();
+ start.set(None);
+ println!("GC slice ended: duration={}", dur);
+ })
+ },
+ GCProgress::GC_CYCLE_END => {
+ GC_CYCLE_START.with(|start| {
+ let dur = time::now() - start.get().unwrap();
+ start.set(None);
+ println!("GC cycle ended: duration={}", dur);
+ })
+ },
+ };
+ if !desc.is_null() {
+ let desc: &GCDescription = &*desc;
+ let invocationKind = match desc.invocationKind_ {
+ JSGCInvocationKind::GC_NORMAL => "GC_NORMAL",
+ JSGCInvocationKind::GC_SHRINK => "GC_SHRINK",
+ };
+ println!(" isCompartment={}, invocationKind={}", desc.isCompartment_, invocationKind);
+ }
+ let _ = stdout().flush();
+}
+
unsafe extern "C" fn debug_gc_callback(_rt: *mut JSRuntime, status: JSGCStatus, _data: *mut libc::c_void) {
match status {
JSGCStatus::JSGC_BEGIN => task_state::enter(task_state::IN_GC),
@@ -567,6 +613,11 @@ impl ScriptTask {
JS_SetGCCallback(runtime.rt(), Some(debug_gc_callback), ptr::null_mut());
}
}
+ if opts::get().gc_profile {
+ unsafe {
+ SetGCSliceCallback(runtime.rt(), Some(gc_slice_callback));
+ }
+ }
unsafe {
SetDOMProxyInformation(ptr::null(), 0, Some(shadow_check_callback));