mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Fix image width setter to use actual argument. Fix hasInstance checks to reflect the Handle changes in the JSAPI.
This commit is contained in:
parent
632bffd8f4
commit
b4934473a0
4 changed files with 19 additions and 16 deletions
|
@ -1 +1 @@
|
|||
Subproject commit de66662c301b2c00dacabdf0d82adf22d16232b4
|
||||
Subproject commit e2b17f323b0ab2d6a2d806d114bd1e61f3b1ba50
|
|
@ -97,8 +97,10 @@ extern fn HTMLImageElement_setWidth(cx: *JSContext, _argc: c_uint, vp: *mut jsva
|
|||
match nd.kind {
|
||||
~Element(ed) => {
|
||||
match ed.kind {
|
||||
~HTMLImageElement(img) =>
|
||||
img.size.width = px_to_au(RUST_JSVAL_TO_INT(*vp) as int),
|
||||
~HTMLImageElement(img) => {
|
||||
let arg = ptr::offset(JS_ARGV(cx, unsafe::reinterpret_cast(&vp)), 0);
|
||||
img.size.width = px_to_au(RUST_JSVAL_TO_INT(*arg) as int)
|
||||
},
|
||||
_ => fail ~"why is this not an image element?"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,13 +79,13 @@ fn get_compartment(cx: *JSContext) -> *bare_compartment {
|
|||
}
|
||||
}
|
||||
|
||||
extern fn has_instance(_cx: *JSContext, obj: *JSObject, v: *jsval, bp: *mut JSBool) -> JSBool {
|
||||
extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *jsval, bp: *mut JSBool) -> JSBool {
|
||||
//XXXjdm this is totally broken for non-object values
|
||||
let mut o = RUST_JSVAL_TO_OBJECT(unsafe {*v});
|
||||
let clasp = JS_GetClass(obj);
|
||||
let obj = unsafe {*obj};
|
||||
unsafe { *bp = 0; }
|
||||
while o.is_not_null() {
|
||||
if JS_GetClass(o) == clasp {
|
||||
if o == obj {
|
||||
unsafe { *bp = 1; }
|
||||
break;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ extern fn has_instance(_cx: *JSContext, obj: *JSObject, v: *jsval, bp: *mut JSBo
|
|||
}
|
||||
|
||||
fn prototype_jsclass(name: ~str) -> fn(bare_compartment) -> JSClass {
|
||||
return fn@(compartment: bare_compartment) -> JSClass {
|
||||
|compartment: bare_compartment, copy name| {
|
||||
{name: compartment.add_name(name),
|
||||
flags: 0,
|
||||
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
||||
|
@ -119,12 +119,12 @@ fn prototype_jsclass(name: ~str) -> fn(bare_compartment) -> JSClass {
|
|||
null(), null(), null(), null(), null(), // 30
|
||||
null(), null(), null(), null(), null(), // 35
|
||||
null(), null(), null(), null(), null())} // 40
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn instance_jsclass(name: ~str, finalize: *u8)
|
||||
-> fn(bare_compartment) -> JSClass {
|
||||
return fn@(compartment: bare_compartment) -> JSClass {
|
||||
|compartment: bare_compartment, copy name| {
|
||||
{name: compartment.add_name(name),
|
||||
flags: JSCLASS_HAS_RESERVED_SLOTS(1),
|
||||
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
||||
|
@ -148,7 +148,7 @@ fn instance_jsclass(name: ~str, finalize: *u8)
|
|||
null(), null(), null(), null(), null(), // 30
|
||||
null(), null(), null(), null(), null(), // 35
|
||||
null(), null(), null(), null(), null())} // 40
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: bare_compartment)
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
function setWidth(w, i) {
|
||||
var elem = document.documentElement.firstChild;
|
||||
elem.width = w;
|
||||
debug(elem.width);
|
||||
window.alert(elem.width);
|
||||
w += i;
|
||||
if (w == 0 || w == 1000)
|
||||
i *= -1;
|
||||
window.setTimeout(function() { setWidth(w, i); }, 50);
|
||||
}
|
||||
|
||||
var elem = document.documentElement.firstChild;
|
||||
debug(elem.tagName);
|
||||
debug(elem instanceof HTMLImageElement);
|
||||
debug(elem.width);
|
||||
var elem = document.documentElement.firstChild.firstChild.nextSibling.firstChild;
|
||||
window.alert(elem.tagName);
|
||||
window.alert(elem instanceof HTMLImageElement);
|
||||
window.alert(elem instanceof HTMLElement);
|
||||
window.alert(elem instanceof Element);
|
||||
window.alert(elem.width);
|
||||
setWidth(1000, -10);
|
Loading…
Add table
Add a link
Reference in a new issue