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

@ -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 ||
("xml" == prefix_str.as_slice() && namespace != namespace::XML) ||
("xmlns" == prefix_str.as_slice() && namespace != namespace::XMLNS)) {
if namespace == namespace::Null ||
("xml" == prefix_str.as_slice() && namespace != namespace::XML) ||
("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)),
}
}
});