mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +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 {
|
match nd.kind {
|
||||||
~Element(ed) => {
|
~Element(ed) => {
|
||||||
match ed.kind {
|
match ed.kind {
|
||||||
~HTMLImageElement(img) =>
|
~HTMLImageElement(img) => {
|
||||||
img.size.width = px_to_au(RUST_JSVAL_TO_INT(*vp) as int),
|
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?"
|
_ => 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
|
//XXXjdm this is totally broken for non-object values
|
||||||
let mut o = RUST_JSVAL_TO_OBJECT(unsafe {*v});
|
let mut o = RUST_JSVAL_TO_OBJECT(unsafe {*v});
|
||||||
let clasp = JS_GetClass(obj);
|
let obj = unsafe {*obj};
|
||||||
unsafe { *bp = 0; }
|
unsafe { *bp = 0; }
|
||||||
while o.is_not_null() {
|
while o.is_not_null() {
|
||||||
if JS_GetClass(o) == clasp {
|
if o == obj {
|
||||||
unsafe { *bp = 1; }
|
unsafe { *bp = 1; }
|
||||||
break;
|
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 {
|
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),
|
{name: compartment.add_name(name),
|
||||||
flags: 0,
|
flags: 0,
|
||||||
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
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(), // 30
|
||||||
null(), null(), null(), null(), null(), // 35
|
null(), null(), null(), null(), null(), // 35
|
||||||
null(), null(), null(), null(), null())} // 40
|
null(), null(), null(), null(), null())} // 40
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn instance_jsclass(name: ~str, finalize: *u8)
|
fn instance_jsclass(name: ~str, finalize: *u8)
|
||||||
-> fn(bare_compartment) -> JSClass {
|
-> fn(bare_compartment) -> JSClass {
|
||||||
return fn@(compartment: bare_compartment) -> JSClass {
|
|compartment: bare_compartment, copy name| {
|
||||||
{name: compartment.add_name(name),
|
{name: compartment.add_name(name),
|
||||||
flags: JSCLASS_HAS_RESERVED_SLOTS(1),
|
flags: JSCLASS_HAS_RESERVED_SLOTS(1),
|
||||||
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
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(), // 30
|
||||||
null(), null(), null(), null(), null(), // 35
|
null(), null(), null(), null(), null(), // 35
|
||||||
null(), null(), null(), null(), null())} // 40
|
null(), null(), null(), null(), null())} // 40
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: bare_compartment)
|
fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: bare_compartment)
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
function setWidth(w, i) {
|
function setWidth(w, i) {
|
||||||
var elem = document.documentElement.firstChild;
|
|
||||||
elem.width = w;
|
elem.width = w;
|
||||||
debug(elem.width);
|
window.alert(elem.width);
|
||||||
w += i;
|
w += i;
|
||||||
if (w == 0 || w == 1000)
|
if (w == 0 || w == 1000)
|
||||||
i *= -1;
|
i *= -1;
|
||||||
window.setTimeout(function() { setWidth(w, i); }, 50);
|
window.setTimeout(function() { setWidth(w, i); }, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
var elem = document.documentElement.firstChild;
|
var elem = document.documentElement.firstChild.firstChild.nextSibling.firstChild;
|
||||||
debug(elem.tagName);
|
window.alert(elem.tagName);
|
||||||
debug(elem instanceof HTMLImageElement);
|
window.alert(elem instanceof HTMLImageElement);
|
||||||
debug(elem.width);
|
window.alert(elem instanceof HTMLElement);
|
||||||
|
window.alert(elem instanceof Element);
|
||||||
|
window.alert(elem.width);
|
||||||
setWidth(1000, -10);
|
setWidth(1000, -10);
|
Loading…
Add table
Add a link
Reference in a new issue