Warning police.

This commit is contained in:
Josh Matthews 2014-03-14 14:46:30 -04:00 committed by Lars Bergstrom
parent f279abbf9f
commit 64c0de9fe7
44 changed files with 146 additions and 160 deletions

View file

@ -148,7 +148,7 @@ impl FontContext {
Some(ref result) => {
found = true;
let instance = self.get_font_by_descriptor(result);
instance.map(|font| fonts.push(font.clone()));
let _ = instance.map(|font| fonts.push(font.clone()));
},
_ => {}
}
@ -186,7 +186,7 @@ impl FontContext {
match font_desc {
Some(ref fd) => {
let instance = self.get_font_by_descriptor(fd);
instance.map(|font| fonts.push(font.clone()));
let _ = instance.map(|font| fonts.push(font.clone()));
},
None => { }
};

View file

@ -273,16 +273,6 @@ impl<'a> RenderContext<'a> {
}
}
trait to_float {
fn to_float(&self) -> f64;
}
impl to_float for u8 {
fn to_float(&self) -> f64 {
(*self as f64) / 255f64
}
}
trait ToAzureRect {
fn to_azure_rect(&self) -> Rect<AzFloat>;
}

View file

@ -22,7 +22,7 @@ use servo_util::time::{ProfilerChan, profile};
use servo_util::time;
use servo_util::task::send_on_failure;
use std::comm::{Chan, Port, Chan};
use std::comm::{Chan, Port};
use std::task;
use sync::Arc;

View file

@ -10,7 +10,6 @@ use servo_util::geometry;
use std::cmp::{Ord, Eq};
use std::num::NumCast;
use std::mem;
use std::u16;
use std::uint;
use std::vec;
use std::iter;

View file

@ -42,7 +42,6 @@ use std::char;
use std::cmp;
use std::libc::{c_uint, c_int, c_void, c_char};
use std::ptr::null;
use std::ptr;
use std::vec;
static NO_GLYPH: i32 = -1;

View file

@ -177,7 +177,7 @@ impl IOCompositor {
// Check for new messages coming from the rendering task.
self.handle_message();
if (self.done) {
if self.done {
// We have exited the compositor and passing window
// messages to script may crash.
debug!("Exiting the compositor due to a request from script.");
@ -212,7 +212,7 @@ impl IOCompositor {
// Drain compositor port, sometimes messages contain channels that are blocking
// another task from finishing (i.e. SetIds)
while true {
loop {
match self.port.try_recv() {
Empty | Disconnected => break,
Data(_) => {},

View file

@ -14,7 +14,7 @@ use geom::rect::Rect;
use geom::size::Size2D;
use layers::platform::surface::{NativeCompositingGraphicsContext, NativeGraphicsMetadata};
use servo_msg::compositor_msg::{Epoch, RenderListener, LayerBufferSet, RenderState, ReadyState};
use servo_msg::compositor_msg::{ScriptListener, Tile};
use servo_msg::compositor_msg::ScriptListener;
use servo_msg::constellation_msg::{ConstellationChan, PipelineId};
use servo_util::opts::Opts;
use servo_util::time::ProfilerChan;

View file

@ -40,14 +40,13 @@ impl NullCompositor {
// Drain compositor port, sometimes messages contain channels that are blocking
// another task from finishing (i.e. SetIds)
while true {
loop {
match compositor.port.try_recv() {
Empty | Disconnected => break,
Data(_) => {},
}
}
let ProfilerChan(ref chan) = profiler_chan;
profiler_chan.send(time::ExitMsg);
}

View file

@ -428,8 +428,8 @@ impl Constellation {
// It's quite difficult to make Servo exit cleanly if some tasks have failed.
// Hard fail exists for test runners so we crash and that's good enough.
let mut stderr = io::stderr();
stderr.write_str("Pipeline failed in hard-fail mode. Crashing!\n");
stderr.flush();
stderr.write_str("Pipeline failed in hard-fail mode. Crashing!\n").unwrap();
stderr.flush().unwrap();
unsafe { libc::exit(1); }
}

View file

@ -119,7 +119,7 @@ impl HeightConstraintSolution {
(Specified(top), Specified(bottom), Specified(height)) => {
match (top_margin, bottom_margin) {
(Auto, Auto) => {
let total_margin_val = (available_height - top - bottom - height);
let total_margin_val = available_height - top - bottom - height;
(top, bottom, height,
total_margin_val.scale_by(0.5),
total_margin_val.scale_by(0.5))
@ -226,7 +226,7 @@ impl HeightConstraintSolution {
(Specified(top), Specified(bottom)) => {
match (top_margin, bottom_margin) {
(Auto, Auto) => {
let total_margin_val = (available_height - top - bottom - height);
let total_margin_val = available_height - top - bottom - height;
(top, bottom, height,
total_margin_val.scale_by(0.5),
total_margin_val.scale_by(0.5))
@ -1733,7 +1733,7 @@ trait WidthAndMarginsComputer {
let left = left_margin.specified_or_zero();
let right = right_margin.specified_or_zero();
if((left + right + width) > available_width) {
if (left + right + width) > available_width {
(Specified(left), Specified(right))
} else {
(left_margin, right_margin)
@ -1840,7 +1840,7 @@ impl WidthAndMarginsComputer for AbsoluteNonReplaced {
(Specified(left), Specified(right), Specified(width)) => {
match (left_margin, right_margin) {
(Auto, Auto) => {
let total_margin_val = (available_width - left - right - width);
let total_margin_val = available_width - left - right - width;
if total_margin_val < Au(0) {
// margin-left becomes 0 because direction is 'ltr'.
// TODO: Handle 'rtl' when it is implemented.
@ -2003,7 +2003,7 @@ impl WidthAndMarginsComputer for AbsoluteReplaced {
(Specified(left), Specified(right)) => {
match (left_margin, right_margin) {
(Auto, Auto) => {
let total_margin_val = (available_width - left - right - width);
let total_margin_val = available_width - left - right - width;
if total_margin_val < Au(0) {
// margin-left becomes 0 because direction is 'ltr'.
(left, right, width, Au(0), total_margin_val)

View file

@ -28,7 +28,6 @@ use servo_util::str::is_whitespace;
use std::cast;
use std::cell::RefCell;
use std::cmp::ApproxEq;
use std::num::Zero;
use style::{ComputedValues, TElement, TNode};
use style::computed_values::{LengthOrPercentage, LengthOrPercentageOrAuto, overflow, LPA_Auto};

View file

@ -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 servo_util::task::spawn_named;
//use servo_util::task::spawn_named;
/*
pub fn spawn_listener<'a, A: Send, S: IntoMaybeOwned<'a>>(name: S, f: proc(Port<A>)) -> Chan<A> {
let (setup_po, setup_ch) = Chan::new();

View file

@ -14,7 +14,7 @@ fn read_all(reader: &mut io::Stream, progress_chan: &Chan<ProgressMsg>)
-> Result<(), ()> {
loop {
let mut buf = ~[];
match (reader.push_bytes(&mut buf, READ_SIZE)) {
match reader.push_bytes(&mut buf, READ_SIZE) {
Ok(_) => progress_chan.send(Payload(buf)),
Err(e) => match e.kind {
io::EndOfFile => return Ok(()),

View file

@ -57,7 +57,7 @@ fn load(mut url: Url, start_chan: Chan<LoadResponse>) {
info!("requesting {:s}", url.to_str());
let request = RequestWriter::<TcpStream>::new(Get, url.clone());
let mut writer = match request {
let writer = match request {
Ok(w) => ~w,
Err(_) => {
send_error(url, start_chan);

View file

@ -9,7 +9,6 @@ use http_loader;
use data_loader;
use std::comm::{Chan, Port};
use std::cast;
use std::task;
use extra::url::Url;
use http::headers::content_type::MediaType;
@ -137,7 +136,7 @@ pub fn ResourceTask() -> ResourceTask {
fn create_resource_task_with_loaders(loaders: ~[(~str, LoaderTaskFactory)]) -> ResourceTask {
let (setup_port, setup_chan) = Chan::new();
let mut builder = task::task().named("ResourceManager");
let builder = task::task().named("ResourceManager");
builder.spawn(proc() {
let (port, chan) = Chan::new();
setup_chan.send(chan);

View file

@ -2,8 +2,8 @@
* 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 std::comm::{Chan, Port};
use servo_util::task::spawn_named;
/*use std::comm::{Chan, Port};
use servo_util::task::spawn_named;*/
// FIXME: code cloned from spawn_listener due to:

View file

@ -16,13 +16,13 @@ use serialize::{Encodable, Encoder};
pub enum ExceptionHandling {
// Report any exception and don't throw it to the caller code.
eReportExceptions,
ReportExceptions,
// Throw an exception to the caller code if the thrown exception is a
// binding object for a DOMError from the caller's scope, otherwise report
// it.
eRethrowContentExceptions,
RethrowContentExceptions,
// Throw any exception to the caller code.
eRethrowExceptions
RethrowExceptions
}
#[deriving(Clone,Eq)]

View file

@ -184,7 +184,7 @@ class CGMethodCall(CGThing):
if requiredArgs > 0:
code = (
"if (argc < %d) {\n"
"if argc < %d {\n"
" return 0; //XXXjdm throw exception\n"
" //return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, %s);\n"
"}" % (requiredArgs, methodName))
@ -993,7 +993,7 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements,
conversion = CGList(
[CGGeneric(
string.Template("if (${index} < ${argc}) {").substitute(
string.Template("if ${index} < ${argc} {").substitute(
argcAndIndex
)),
declConstruct,
@ -1641,7 +1641,9 @@ class CGImports(CGWrapper):
# sometimes produces two 'break's in a row. See for example
# CallbackMember.getArgConversions.
'unreachable_code',
'non_camel_case_types',
'non_uppercase_statics',
'unnecessary_parens',
'unused_imports',
'unused_variable',
'unused_unsafe',
@ -1688,11 +1690,11 @@ class CGNamespace(CGWrapper):
def DOMClass(descriptor):
protoList = ['PrototypeList::id::' + proto for proto in descriptor.prototypeChain]
# Pad out the list to the right length with _ID_Count so we
# guarantee that all the lists are the same length. _ID_Count
# Pad out the list to the right length with IDCount so we
# guarantee that all the lists are the same length. IDCount
# is never the ID of any prototype, so it's safe to use as
# padding.
protoList.extend(['PrototypeList::id::_ID_Count'] * (descriptor.config.maxProtoChainLength - len(protoList)))
protoList.extend(['PrototypeList::id::IDCount'] * (descriptor.config.maxProtoChainLength - len(protoList)))
prototypeChainString = ', '.join(protoList)
return """DOMClass {
interface_chain: [ %s ],
@ -2469,7 +2471,7 @@ class CGCallGenerator(CGThing):
self.cgRoot.append(call)
if isFallible:
self.cgRoot.append(CGGeneric("if (result_fallible.is_err()) {"))
self.cgRoot.append(CGGeneric("if result_fallible.is_err() {"))
self.cgRoot.append(CGIndenter(errorReport))
self.cgRoot.append(CGGeneric("}"))
if result is not None:
@ -2737,7 +2739,7 @@ class CGSpecializedMethod(CGAbstractExternMethod):
return CGWrapper(CGMethodCall(argsPre, nativeName, self.method.isStatic(),
self.descriptor, self.method),
pre=extraPre +
" let obj = (*obj.unnamed);\n" +
" let obj = *obj.unnamed;\n" +
" let this = &mut *this;\n").define()
class CGGenericGetter(CGAbstractBindingMethod):
@ -2797,7 +2799,7 @@ class CGSpecializedGetter(CGAbstractExternMethod):
return CGWrapper(CGIndenter(CGGetterCall(argsPre, self.attr.type, nativeName,
self.descriptor, self.attr)),
pre=extraPre +
" let obj = (*obj.unnamed);\n" +
" let obj = *obj.unnamed;\n" +
" let this = &mut *this;\n").define()
class CGGenericSetter(CGAbstractBindingMethod):
@ -2858,7 +2860,7 @@ class CGSpecializedSetter(CGAbstractExternMethod):
return CGWrapper(CGIndenter(CGSetterCall(argsPre, self.attr.type, nativeName,
self.descriptor, self.attr)),
pre=extraPre +
" let obj = (*obj.unnamed);\n" +
" let obj = *obj.unnamed;\n" +
" let this = &mut *this;\n").define()
def infallibleForMember(member, type, descriptorProvider):
@ -4407,7 +4409,7 @@ class CGNamespacedEnum(CGThing):
entries.append(entry)
# Append a Count.
entries.append('_' + enumName + '_Count = ' + str(len(entries)))
entries.append(enumName + 'Count = ' + str(len(entries)))
# Indent.
entries = [' ' + e for e in entries]
@ -4537,7 +4539,7 @@ class CGDictionary(CGThing):
"\n"
" pub fn Init(&mut self, cx: *JSContext, val: JSVal) -> JSBool {\n"
" unsafe {\n"
" if (!initedIds && !self.InitIds(cx)) {\n"
" if !initedIds && !self.InitIds(cx) {\n"
" return 0;\n"
" }\n"
"${initParent}"
@ -5224,7 +5226,7 @@ class CGCallback(CGClass):
# method, insert our optional argument for deciding whether the
# CallSetup should re-throw exceptions on aRv.
args.append(Argument("ExceptionHandling", "aExceptionHandling",
"eReportExceptions"))
"ReportExceptions"))
args[0] = Argument('&' + args[0].argType, args[0].name, args[0].default)
method.args[2] = args[0]
@ -5516,7 +5518,7 @@ class CallbackMember(CGNativeMember):
args.append(Argument("JSCompartment*", "aCompartment", "nullptr"))
else:
args.append(Argument("ExceptionHandling", "aExceptionHandling",
"eReportExceptions"))
"ReportExceptions"))
return args
# We want to allow the caller to pass in a "this" object, as
# well as a JSContext.
@ -5531,7 +5533,7 @@ class CallbackMember(CGNativeMember):
if self.rethrowContentException:
# getArgs doesn't add the aExceptionHandling argument but does add
# aCompartment for us.
callSetup += ", eRethrowContentExceptions, aCompartment"
callSetup += ", RethrowContentExceptions, aCompartment"
else:
callSetup += ", aExceptionHandling"
callSetup += ");"

View file

@ -19,12 +19,10 @@ use std::ptr;
use std::str;
use std::mem::size_of;
type c_bool = libc::c_int;
static JSPROXYSLOT_EXPANDO: u32 = 0;
pub extern fn getPropertyDescriptor(cx: *JSContext, proxy: *JSObject, id: jsid,
set: c_bool, desc: *mut JSPropertyDescriptor) -> c_bool {
set: libc::c_int, desc: *mut JSPropertyDescriptor) -> libc::c_int {
unsafe {
let handler = GetProxyHandler(proxy);
if InvokeGetOwnPropertyDescriptor(handler, cx, proxy, id, set, desc) == 0 {

View file

@ -407,7 +407,7 @@ pub extern fn ThrowingConstructor(_cx: *JSContext, _argc: c_uint, _vp: *mut JSVa
}
pub fn initialize_global(global: *JSObject) {
let protoArray = ~([0 as *JSObject, ..PrototypeList::id::_ID_Count as uint]);
let protoArray = ~([0 as *JSObject, ..PrototypeList::id::IDCount as uint]);
unsafe {
let box_ = squirrel_away_unboxed(protoArray);
JS_SetReservedSlot(global,

View file

@ -341,17 +341,17 @@ impl Document {
match title_node {
Some(ref mut title_node) => {
for mut title_child in title_node.children() {
title_node.RemoveChild(&mut title_child);
assert!(title_node.RemoveChild(&mut title_child).is_ok());
}
let new_text = self.CreateTextNode(abstract_self, title.clone());
title_node.AppendChild(&mut NodeCast::from(&new_text));
assert!(title_node.AppendChild(&mut NodeCast::from(&new_text)).is_ok());
},
None => {
let mut new_title: JS<Node> =
NodeCast::from(&HTMLTitleElement::new(~"title", abstract_self));
let new_text = self.CreateTextNode(abstract_self, title.clone());
new_title.AppendChild(&mut NodeCast::from(&new_text));
head.AppendChild(&mut new_title);
assert!(new_title.AppendChild(&mut NodeCast::from(&new_text)).is_ok());
assert!(head.AppendChild(&mut new_title).is_ok());
},
}
});
@ -418,9 +418,9 @@ impl Document {
match old_body {
Some(child) => {
let mut child: JS<Node> = NodeCast::from(&child);
root.ReplaceChild(&mut new_body, &mut child)
assert!(root.ReplaceChild(&mut new_body, &mut child).is_ok())
}
None => root.AppendChild(&mut new_body)
None => assert!(root.AppendChild(&mut new_body).is_ok())
};
}
}

View file

@ -72,18 +72,18 @@ impl DOMImplementation {
{
// Step 3.
let doc_type = DocumentType::new(~"html", None, None, &doc);
doc_node.AppendChild(&mut NodeCast::from(&doc_type));
assert!(doc_node.AppendChild(&mut NodeCast::from(&doc_type)).is_ok());
}
{
// Step 4.
let mut doc_html = NodeCast::from(&HTMLHtmlElement::new(~"html", &doc));
doc_node.AppendChild(&mut doc_html);
assert!(doc_node.AppendChild(&mut doc_html).is_ok());
{
// Step 5.
let mut doc_head = NodeCast::from(&HTMLHeadElement::new(~"head", &doc));
doc_html.AppendChild(&mut doc_head);
assert!(doc_html.AppendChild(&mut doc_head).is_ok());
// Step 6.
match title {
@ -91,18 +91,18 @@ impl DOMImplementation {
Some(title_str) => {
// Step 6.1.
let mut doc_title = NodeCast::from(&HTMLTitleElement::new(~"title", &doc));
doc_head.AppendChild(&mut doc_title);
assert!(doc_head.AppendChild(&mut doc_title).is_ok());
// Step 6.2.
let title_text = Text::new(title_str, &doc);
doc_title.AppendChild(&mut NodeCast::from(&title_text));
assert!(doc_title.AppendChild(&mut NodeCast::from(&title_text)).is_ok());
}
}
}
// Step 7.
let doc_body = HTMLBodyElement::new(~"body", &doc);
doc_html.AppendChild(&mut NodeCast::from(&doc_body));
assert!(doc_html.AppendChild(&mut NodeCast::from(&doc_body)).is_ok());
}
// Step 8.

View file

@ -203,9 +203,9 @@ impl Element {
let (prefix, local_name) = get_attribute_parts(name.clone());
match prefix {
Some(ref prefix_str) => {
if (namespace == namespace::Null ||
if namespace == namespace::Null ||
("xml" == prefix_str.as_slice() && namespace != namespace::XML) ||
("xmlns" == prefix_str.as_slice() && namespace != namespace::XMLNS)) {
("xmlns" == prefix_str.as_slice() && namespace != namespace::XMLNS) {
return Err(NamespaceError);
}
},
@ -410,7 +410,7 @@ impl Element {
pub fn set_string_attribute(&mut self, abstract_self: &JS<Element>,
name: &str, value: DOMString) {
assert!(name == name.to_ascii_lower());
self.set_attribute(abstract_self, Null, name.to_owned(), value);
assert!(self.set_attribute(abstract_self, Null, name.to_owned(), value).is_ok());
}
}

View file

@ -6,7 +6,7 @@ use dom::bindings::codegen::EventBinding;
use dom::bindings::codegen::EventBinding::EventConstants;
use dom::bindings::js::JS;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::error::{Fallible, ErrorResult};
use dom::bindings::error::Fallible;
use dom::eventtarget::EventTarget;
use dom::window::Window;
use servo_util::str::DOMString;
@ -24,10 +24,10 @@ pub enum Event_ {
#[deriving(Encodable)]
pub enum EventPhase {
Phase_None = EventConstants::NONE,
Phase_Capturing = EventConstants::CAPTURING_PHASE,
Phase_At_Target = EventConstants::AT_TARGET,
Phase_Bubbling = EventConstants::BUBBLING_PHASE,
PhaseNone = EventConstants::NONE,
PhaseCapturing = EventConstants::CAPTURING_PHASE,
PhaseAtTarget = EventConstants::AT_TARGET,
PhaseBubbling = EventConstants::BUBBLING_PHASE,
}
#[deriving(Eq, Encodable)]
@ -63,7 +63,7 @@ impl Event {
reflector_: Reflector::new(),
current_target: None,
target: None,
phase: Phase_None,
phase: PhaseNone,
type_: ~"",
default_prevented: false,
cancelable: true,
@ -132,12 +132,11 @@ impl Event {
pub fn InitEvent(&mut self,
type_: DOMString,
bubbles: bool,
cancelable: bool) -> ErrorResult {
cancelable: bool) {
self.type_ = type_;
self.cancelable = cancelable;
self.bubbles = bubbles;
self.initialized = true;
Ok(())
}
pub fn IsTrusted(&self) -> bool {

View file

@ -2,11 +2,11 @@
* 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 dom::bindings::callback::eReportExceptions;
use dom::bindings::callback::ReportExceptions;
use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, NodeDerived};
use dom::bindings::js::JS;
use dom::eventtarget::{Capturing, Bubbling, EventTarget};
use dom::event::{Event, Phase_At_Target, Phase_None, Phase_Bubbling, Phase_Capturing};
use dom::event::{Event, PhaseAtTarget, PhaseNone, PhaseBubbling, PhaseCapturing};
use dom::node::{Node, NodeHelpers};
// See http://dom.spec.whatwg.org/#concept-event-dispatch for the full dispatch algorithm
@ -35,7 +35,7 @@ pub fn dispatch_event(target: &JS<EventTarget>,
}
}
event.get_mut().phase = Phase_Capturing;
event.get_mut().phase = PhaseCapturing;
//FIXME: The "callback this value" should be currentTarget
@ -45,7 +45,9 @@ pub fn dispatch_event(target: &JS<EventTarget>,
Some(listeners) => {
event.get_mut().current_target = Some(cur_target.clone());
for listener in listeners.iter() {
listener.HandleEvent__(event, eReportExceptions);
//FIXME: this should have proper error handling, or explicitly
// drop the exception on the floor
assert!(listener.HandleEvent__(event, ReportExceptions).is_ok());
if event.get().stop_immediate {
break;
@ -66,14 +68,16 @@ pub fn dispatch_event(target: &JS<EventTarget>,
if !event.get().stop_propagation {
{
let event = event.get_mut();
event.phase = Phase_At_Target;
event.phase = PhaseAtTarget;
event.current_target = Some(target.clone());
}
let opt_listeners = target.get().get_listeners(type_);
for listeners in opt_listeners.iter() {
for listener in listeners.iter() {
listener.HandleEvent__(event, eReportExceptions);
//FIXME: this should have proper error handling, or explicitly drop the
// exception on the floor.
assert!(listener.HandleEvent__(event, ReportExceptions).is_ok());
if event.get().stop_immediate {
break;
}
@ -83,14 +87,16 @@ pub fn dispatch_event(target: &JS<EventTarget>,
/* bubbling */
if event.get().bubbles && !event.get().stop_propagation {
event.get_mut().phase = Phase_Bubbling;
event.get_mut().phase = PhaseBubbling;
for cur_target in chain.iter() {
let stopped = match cur_target.get().get_listeners_for(type_, Bubbling) {
Some(listeners) => {
event.get_mut().current_target = Some(cur_target.clone());
for listener in listeners.iter() {
listener.HandleEvent__(event, eReportExceptions);
//FIXME: this should have proper error handling or explicitly
// drop exceptions on the floor.
assert!(listener.HandleEvent__(event, ReportExceptions).is_ok());
if event.get().stop_immediate {
break;
@ -109,7 +115,7 @@ pub fn dispatch_event(target: &JS<EventTarget>,
let event = event.get_mut();
event.dispatching = false;
event.phase = Phase_None;
event.phase = PhaseNone;
event.current_target = None;
!event.DefaultPrevented()

View file

@ -120,8 +120,7 @@ impl HTMLImageElement {
pub fn SetSrc(&mut self, abstract_self: &JS<HTMLImageElement>, src: DOMString) -> ErrorResult {
let node = &mut self.htmlelement.element;
node.set_attr(&ElementCast::from(abstract_self), ~"src", src.clone());
Ok(())
node.set_attr(&ElementCast::from(abstract_self), ~"src", src.clone())
}
pub fn CrossOrigin(&self) -> DOMString {
@ -164,8 +163,7 @@ impl HTMLImageElement {
pub fn SetWidth(&mut self, abstract_self: &JS<HTMLImageElement>, width: u32) -> ErrorResult {
let mut elem: JS<Element> = ElementCast::from(abstract_self);
let mut elem_clone = elem.clone();
elem.get_mut().set_attr(&mut elem_clone, ~"width", width.to_str());
Ok(())
elem.get_mut().set_attr(&mut elem_clone, ~"width", width.to_str())
}
pub fn Height(&self, abstract_self: &JS<HTMLImageElement>) -> u32 {
@ -184,8 +182,7 @@ impl HTMLImageElement {
pub fn SetHeight(&mut self, abstract_self: &JS<HTMLImageElement>, height: u32) -> ErrorResult {
let node = &mut self.htmlelement.element;
node.set_attr(&ElementCast::from(abstract_self), ~"height", height.to_str());
Ok(())
node.set_attr(&ElementCast::from(abstract_self), ~"height", height.to_str())
}
pub fn NaturalWidth(&self) -> u32 {

View file

@ -5,7 +5,7 @@
use dom::bindings::codegen::MouseEventBinding;
use dom::bindings::codegen::InheritTypes::MouseEventDerived;
use dom::bindings::js::JS;
use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::error::Fallible;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::event::{Event, MouseEventTypeId};
use dom::eventtarget::EventTarget;
@ -135,7 +135,7 @@ impl MouseEvent {
shiftKeyArg: bool,
metaKeyArg: bool,
buttonArg: u16,
relatedTargetArg: Option<JS<EventTarget>>) -> ErrorResult {
relatedTargetArg: Option<JS<EventTarget>>) {
self.mouseevent.InitUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg);
self.screen_x = screenXArg;
self.screen_y = screenYArg;
@ -147,7 +147,6 @@ impl MouseEvent {
self.meta_key = metaKeyArg;
self.button = buttonArg;
self.related_target = relatedTargetArg;
Ok(())
}
}

View file

@ -36,9 +36,8 @@ use std::cast::transmute;
use std::cast;
use std::cell::{RefCell, Ref, RefMut};
use std::iter::{Map, Filter};
use std::libc::{c_void, uintptr_t};
use std::libc::uintptr_t;
use std::mem;
use std::raw::Box;
use serialize::{Encoder, Encodable};
@ -945,11 +944,10 @@ impl Node {
CommentNodeTypeId |
TextNodeTypeId |
ProcessingInstructionNodeTypeId => {
self.SetTextContent(abstract_self, val);
self.SetTextContent(abstract_self, val)
}
_ => {}
_ => Ok(())
}
Ok(())
}
// http://dom.spec.whatwg.org/#dom-node-textcontent
@ -1691,7 +1689,7 @@ impl Node {
let abstract_uint: uintptr_t = cast::transmute(abstract_self.get());
let other_uint: uintptr_t = cast::transmute(other.get());
let random = if (abstract_uint < other_uint) {
let random = if abstract_uint < other_uint {
NodeConstants::DOCUMENT_POSITION_FOLLOWING
} else {
NodeConstants::DOCUMENT_POSITION_PRECEDING

View file

@ -44,6 +44,7 @@ interface Document : Node {
partial interface Document {
[SetterThrows]
attribute DOMString title;
[SetterThrows]
attribute HTMLElement? body;
readonly attribute HTMLHeadElement? head;
NodeList getElementsByName(DOMString elementName);

View file

@ -33,7 +33,6 @@ interface Event {
readonly attribute boolean isTrusted;
readonly attribute DOMTimeStamp timeStamp;
[Throws]
void initEvent(DOMString type, boolean bubbles, boolean cancelable);
};

View file

@ -23,7 +23,6 @@ interface MouseEvent : UIEvent {
readonly attribute unsigned short buttons;
readonly attribute EventTarget? relatedTarget;
// Deprecated in DOM Level 3:
[Throws]
void initMouseEvent(DOMString typeArg,
boolean canBubbleArg,
boolean cancelableArg,

View file

@ -38,9 +38,9 @@ use serialize::{Encoder, Encodable};
use extra::url::{Url};
pub enum TimerControlMsg {
TimerMessage_Fire(~TimerData),
TimerMessage_Close,
TimerMessage_TriggerExit //XXXjdm this is just a quick hack to talk to the script task
TimerMessageFire(~TimerData),
TimerMessageClose,
TimerMessageTriggerExit //XXXjdm this is just a quick hack to talk to the script task
}
pub struct TimerHandle {
@ -115,7 +115,7 @@ impl Window {
#[unsafe_destructor]
impl Drop for Window {
fn drop(&mut self) {
self.extra.timer_chan.send(TimerMessage_Close);
self.extra.timer_chan.send(TimerMessageClose);
for handle in self.active_timers.iter() {
handle.cancel();
}
@ -138,7 +138,7 @@ impl Window {
}
pub fn Close(&self) {
self.extra.timer_chan.send(TimerMessage_TriggerExit);
self.extra.timer_chan.send(TimerMessageTriggerExit);
}
pub fn Document(&self) -> JS<Document> {
@ -237,17 +237,17 @@ impl Window {
let chan = self.extra.timer_chan.clone();
spawn_named("Window:SetTimeout", proc() {
let mut tm = tm;
let mut timeout_port = tm.oneshot(timeout);
let mut cancel_port = cancel_port;
let timeout_port = tm.oneshot(timeout);
let cancel_port = cancel_port;
let select = Select::new();
let mut timeout_handle = select.handle(&timeout_port);
unsafe { timeout_handle.add() };
let mut _cancel_handle = select.handle(&cancel_port);
unsafe { _cancel_handle.add() };
let mut cancel_handle = select.handle(&cancel_port);
unsafe { cancel_handle.add() };
let id = select.wait();
if id == timeout_handle.id() {
chan.send(TimerMessage_Fire(~TimerData {
chan.send(TimerMessageFire(~TimerData {
handle: handle,
funval: callback,
args: ~[],
@ -298,9 +298,9 @@ impl Window {
let ScriptChan(script_chan) = script_chan;
loop {
match timer_port.recv() {
TimerMessage_Close => break,
TimerMessage_Fire(td) => script_chan.send(FireTimerMsg(id, td)),
TimerMessage_TriggerExit => script_chan.send(ExitWindowMsg(id)),
TimerMessageClose => break,
TimerMessageFire(td) => script_chan.send(FireTimerMsg(id, td)),
TimerMessageTriggerExit => script_chan.send(ExitWindowMsg(id)),
}
}
});

View file

@ -338,9 +338,11 @@ pub fn parse_html(page: &Page,
debug!("-- attach attrs");
for attr in tag.attributes.iter() {
let elem = element.clone();
element.get_mut().set_attr(&elem,
//FIXME: this should have proper error handling or explicitly drop
// exceptions on the ground
assert!(element.get_mut().set_attr(&elem,
attr.name.clone(),
attr.value.clone());
attr.value.clone()).is_ok());
}
// Spawn additional parsing, network loads, etc. from tag and attrs
@ -409,7 +411,7 @@ pub fn parse_html(page: &Page,
debug!("append child {:x} {:x}", parent, child);
let mut parent: JS<Node> = NodeWrapping::from_hubbub_node(parent);
let mut child: JS<Node> = NodeWrapping::from_hubbub_node(child);
parent.AppendChild(&mut child);
assert!(parent.AppendChild(&mut child).is_ok());
}
child
},
@ -448,14 +450,14 @@ pub fn parse_html(page: &Page,
debug!("set quirks mode");
// NOTE: tmp vars are workaround for lifetime issues. Both required.
let mut tmp_borrow = doc_cell.borrow_mut();
let mut tmp = tmp_borrow.get();
let tmp = tmp_borrow.get();
tmp.get_mut().set_quirks_mode(mode);
},
encoding_change: |encname| {
debug!("encoding change");
// NOTE: tmp vars are workaround for lifetime issues. Both required.
let mut tmp_borrow = doc_cell.borrow_mut();
let mut tmp = tmp_borrow.get();
let tmp = tmp_borrow.get();
tmp.get_mut().set_encoding_name(encname);
},
complete_script: |script| {

View file

@ -164,7 +164,7 @@ pub struct PageTreeIterator<'a> {
impl PageTree {
fn new(id: PipelineId, layout_chan: LayoutChan, window_size: Size2D<uint>) -> PageTree {
PageTree {
page: unsafe { Rc::new(Page {
page: Rc::new(Page {
id: id,
frame: RefCell::new(None),
layout_chan: layout_chan,
@ -177,7 +177,7 @@ impl PageTree {
resize_event: RefCell::new(None),
fragment_node: RefCell::new(None),
last_reflow_id: RefCell::new(0)
}) },
}),
inner: ~[],
}
}
@ -237,7 +237,7 @@ impl PageTree {
impl<'a> Iterator<Rc<Page>> for PageTreeIterator<'a> {
fn next(&mut self) -> Option<Rc<Page>> {
if !self.stack.is_empty() {
let mut next = self.stack.pop().unwrap();
let next = self.stack.pop().unwrap();
for child in next.inner.mut_iter() {
self.stack.push(child);
}
@ -496,7 +496,6 @@ impl ScriptTask {
-> Rc<ScriptTask> {
let js_runtime = js::rust::rt();
unsafe {
Rc::new(ScriptTask {
page_tree: RefCell::new(PageTree::new(id, layout_chan, window_size)),
@ -512,7 +511,6 @@ impl ScriptTask {
mouse_over_targets: RefCell::new(None)
})
}
}
/// Starts the script task. After calling this method, the script task will loop receiving
/// messages on its port.
@ -869,7 +867,7 @@ impl ScriptTask {
let js_info = page.js_info();
let js_info = js_info.get().get_ref();
let compartment = js_info.js_compartment.borrow();
compartment.define_functions(DEBUG_FNS);
assert!(compartment.define_functions(DEBUG_FNS).is_ok());
js_info.js_context.borrow().ptr
};
@ -882,10 +880,12 @@ impl ScriptTask {
(js_info.get().get_ref().js_context.clone(),
js_info.get().get_ref().js_compartment.borrow().global_obj)
};
cx.borrow().evaluate_script(global_obj,
//FIXME: this should have some kind of error handling, or explicitly
// drop an exception on the floor.
assert!(cx.borrow().evaluate_script(global_obj,
file.data.clone(),
file.url.to_str(),
1);
1).is_ok());
});
}
@ -893,11 +893,11 @@ impl ScriptTask {
// "load" event as soon as we've finished executing all scripts parsed during
// the initial load.
let mut event = Event::new(&window);
event.get_mut().InitEvent(~"load", false, false);
let _ = event.get_mut().InitEvent(~"load", false, false);
let doctarget = EventTargetCast::from(&document);
let mut wintarget: JS<EventTarget> = EventTargetCast::from(&window);
let winclone = wintarget.clone();
wintarget.get_mut().dispatch_event_with_target(&winclone, Some(doctarget), &mut event);
let _ = wintarget.get_mut().dispatch_event_with_target(&winclone, Some(doctarget), &mut event);
let mut fragment_node = page.fragment_node.borrow_mut();
*fragment_node.get() = fragment.map_or(None, |fragid| self.find_fragment_node(page, fragid));
@ -981,7 +981,7 @@ impl ScriptTask {
// FIXME: this event should be dispatch on WindowProxy. See #1715
let mut wintarget: JS<EventTarget> = EventTargetCast::from(&frame.window);
let winclone = wintarget.clone();
wintarget.get_mut().dispatch_event_with_target(&winclone, None, event);
let _ = wintarget.get_mut().dispatch_event_with_target(&winclone, None, event);
}
None =>()
}

View file

@ -2,6 +2,8 @@
* 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/. */
#[allow(non_camel_case_types)];
pub use servo_util::geometry::Au;
pub type CSSFloat = f64;

View file

@ -11,14 +11,13 @@ pub struct ErrorLoggerIterator<I>(I);
impl<T, I: Iterator<Result<T, SyntaxError>>> Iterator<T> for ErrorLoggerIterator<I> {
fn next(&mut self) -> Option<T> {
let ErrorLoggerIterator(ref mut this) = *self;
while true {
loop {
match this.next() {
Some(Ok(v)) => return Some(v),
Some(Err(error)) => log_css_error(error.location, format!("{:?}", error.reason)),
None => return None,
}
}
None
}
}

View file

@ -4,7 +4,8 @@
// This file is a Mako template: http://www.makotemplates.org/
use std::ascii;
#[allow(non_camel_case_types)];
use std::ascii::StrAsciiExt;
pub use servo_util::url::parse_url;
use sync::Arc;
@ -1062,7 +1063,7 @@ pub fn parse_property_declaration_list<I: Iterator<Node>>(input: I, base_url: &U
let mut normal = ~[];
for item in ErrorLoggerIterator(parse_declaration_list(input)) {
match item {
Decl_AtRule(rule) => log_css_error(
DeclAtRule(rule) => log_css_error(
rule.location, format!("Unsupported at-rule in declaration list: @{:s}", rule.name)),
Declaration(Declaration{ location: l, name: n, value: v, important: i}) => {
// TODO: only keep the last valid declaration for a given name.

View file

@ -49,12 +49,12 @@ impl<'a> Hash for LowercaseAsciiString<'a> {
// `Ascii` type's invariants by using `to_ascii_nocheck`, but it's OK as we simply
// convert to a byte afterward.
unsafe {
state.write_u8(b.to_ascii_nocheck().to_lower().to_byte())
state.write_u8(b.to_ascii_nocheck().to_lower().to_byte()).unwrap()
};
}
// Terminate the string with a non-UTF-8 character, to match what the built-in string
// `ToBytes` implementation does. (See `libstd/to_bytes.rs`.)
state.write_u8(0xff);
state.write_u8(0xff).unwrap();
}
}

View file

@ -10,18 +10,18 @@ use std::mem::size_of;
fn hexdump_slice(buf: &[u8]) {
let mut stderr = io::stderr();
stderr.write(bytes!(" "));
stderr.write(bytes!(" ")).unwrap();
for (i, &v) in buf.iter().enumerate() {
let output = format!("{:02X} ", v as uint);
stderr.write(output.as_bytes());
stderr.write(output.as_bytes()).unwrap();
match i % 16 {
15 => { stderr.write(bytes!("\n ")); },
7 => { stderr.write(bytes!(" ")); },
15 => { stderr.write(bytes!("\n ")).unwrap(); },
7 => { stderr.write(bytes!(" ")).unwrap(); },
_ => ()
}
stderr.flush();
stderr.flush().unwrap();
}
stderr.write(bytes!("\n"));
stderr.write(bytes!("\n")).unwrap();
}
pub fn hexdump<T>(obj: &T) {

View file

@ -62,7 +62,7 @@ fn print_usage(app: &str, opts: &[getopts::OptGroup]) {
}
fn args_fail(msg: &str) {
io::stderr().write_line(msg);
io::stderr().write_line(msg).unwrap();
os::set_exit_status(1);
}

View file

@ -9,7 +9,6 @@ use i = std::mem::init;
use std::cast;
use std::cmp;
use std::intrinsics;
use std::libc::c_char;
use std::mem;
use std::ptr;
use std::rt::global_heap;

View file

@ -8,7 +8,7 @@ use std::comm::Chan;
use std::task::TaskBuilder;
pub fn spawn_named<S: IntoMaybeOwned<'static>>(name: S, f: proc()) {
let mut builder = task::task().named(name);
let builder = task::task().named(name);
builder.spawn(f);
}

View file

@ -232,7 +232,7 @@ pub fn profile<T>(category: ProfilerCategory,
let start_time = precise_time_ns();
let val = callback();
let end_time = precise_time_ns();
let ms = ((end_time - start_time) as f64 / 1000000f64);
let ms = (end_time - start_time) as f64 / 1000000f64;
profiler_chan.send(TimeMsg(category, ms));
return val;
}
@ -241,7 +241,7 @@ pub fn time<T>(msg: &str, callback: || -> T) -> T{
let start_time = precise_time_ns();
let val = callback();
let end_time = precise_time_ns();
let ms = ((end_time - start_time) as f64 / 1000000f64);
let ms = (end_time - start_time) as f64 / 1000000f64;
if ms >= 5f64 {
debug!("{:s} took {} ms", msg, ms);
}

View file

@ -22,14 +22,14 @@ impl<'a, T: Ord + Eq> BinarySearchMethods<'a, T> for &'a [T] {
let mut low : int = 0;
let mut high : int = (self.len() as int) - 1;
while (low <= high) {
while low <= high {
// http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html
let mid : int = (((low as uint) + (high as uint)) >> 1) as int;
let midv = &self[mid];
if (midv < key) {
if midv < key {
low = mid + 1;
} else if (midv > key) {
} else if midv > key {
high = mid - 1;
} else {
return Some(mid as uint);