mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Add onresize handler to GlobalEventHandlers
Refs: https://github.com/servo/servo/issues/7996 Rebased: https://github.com/servo/servo/pull/8006
This commit is contained in:
parent
5e1f0495a9
commit
d4fe40089b
7 changed files with 64 additions and 15 deletions
|
@ -162,6 +162,24 @@ impl HTMLElementMethods for HTMLElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#handler-onresize
|
||||||
|
fn GetOnresize(&self) -> Option<Rc<EventHandlerNonNull>> {
|
||||||
|
if self.is_body_or_frameset() {
|
||||||
|
window_from_node(self).GetOnload()
|
||||||
|
} else {
|
||||||
|
self.upcast::<EventTarget>().get_event_handler_common("resize")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#handler-onresize
|
||||||
|
fn SetOnresize(&self, listener: Option<Rc<EventHandlerNonNull>>) {
|
||||||
|
if self.is_body_or_frameset() {
|
||||||
|
window_from_node(self).SetOnresize(listener);
|
||||||
|
} else {
|
||||||
|
self.upcast::<EventTarget>().set_event_handler_common("resize", listener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-click
|
// https://html.spec.whatwg.org/multipage/#dom-click
|
||||||
fn Click(&self) {
|
fn Click(&self) {
|
||||||
if let Some(i) = self.downcast::<HTMLInputElement>() {
|
if let Some(i) = self.downcast::<HTMLInputElement>() {
|
||||||
|
|
|
@ -333,6 +333,7 @@ macro_rules! error_event_handler(
|
||||||
macro_rules! global_event_handlers(
|
macro_rules! global_event_handlers(
|
||||||
() => (
|
() => (
|
||||||
event_handler!(load, GetOnload, SetOnload);
|
event_handler!(load, GetOnload, SetOnload);
|
||||||
|
event_handler!(resize, GetOnresize, SetOnresize);
|
||||||
global_event_handlers!(NoOnload);
|
global_event_handlers!(NoOnload);
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
|
@ -34,6 +34,7 @@ interface GlobalEventHandlers {
|
||||||
attribute EventHandler onreset;
|
attribute EventHandler onreset;
|
||||||
attribute EventHandler onsubmit;
|
attribute EventHandler onsubmit;
|
||||||
attribute EventHandler ontoggle;
|
attribute EventHandler ontoggle;
|
||||||
|
attribute EventHandler onresize;
|
||||||
};
|
};
|
||||||
|
|
||||||
[NoInterfaceObject]
|
[NoInterfaceObject]
|
||||||
|
|
|
@ -33318,6 +33318,12 @@
|
||||||
"deleted": [],
|
"deleted": [],
|
||||||
"items": {
|
"items": {
|
||||||
"testharness": {
|
"testharness": {
|
||||||
|
"html/webappapis/scripting/events/event-handler-onresize.html": [
|
||||||
|
{
|
||||||
|
"path": "html/webappapis/scripting/events/event-handler-onresize.html",
|
||||||
|
"url": "/html/webappapis/scripting/events/event-handler-onresize.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"websockets/Create-asciiSep-protocol-string.htm": [
|
"websockets/Create-asciiSep-protocol-string.htm": [
|
||||||
{
|
{
|
||||||
"path": "websockets/Create-asciiSep-protocol-string.htm",
|
"path": "websockets/Create-asciiSep-protocol-string.htm",
|
||||||
|
|
|
@ -186,9 +186,6 @@
|
||||||
[Document interface: attribute onratechange]
|
[Document interface: attribute onratechange]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Document interface: attribute onresize]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Document interface: attribute onscroll]
|
[Document interface: attribute onscroll]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -1725,9 +1722,6 @@
|
||||||
[HTMLElement interface: attribute onratechange]
|
[HTMLElement interface: attribute onratechange]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLElement interface: attribute onresize]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLElement interface: attribute onscroll]
|
[HTMLElement interface: attribute onscroll]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -1956,9 +1950,6 @@
|
||||||
[HTMLElement interface: document.createElement("noscript") must inherit property "onratechange" with the proper type (79)]
|
[HTMLElement interface: document.createElement("noscript") must inherit property "onratechange" with the proper type (79)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLElement interface: document.createElement("noscript") must inherit property "onresize" with the proper type (81)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLElement interface: document.createElement("noscript") must inherit property "onscroll" with the proper type (82)]
|
[HTMLElement interface: document.createElement("noscript") must inherit property "onscroll" with the proper type (82)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -8730,9 +8721,6 @@
|
||||||
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "onratechange" with the proper type (141)]
|
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "onratechange" with the proper type (141)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "onresize" with the proper type (143)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "onscroll" with the proper type (144)]
|
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "onscroll" with the proper type (144)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,6 @@
|
||||||
[focus]
|
[focus]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[resize]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[scroll]
|
[scroll]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>HTMLBodyElement.onresize</title>
|
||||||
|
<link rel="author" title="His-Name-Is-Joof" href="mailto:jeffrharrison@gmail.com">
|
||||||
|
<link rel="help" href="https://html.spec.whatwg.org/multipage/#handler-window-onresize">
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<div id="log"></div>
|
||||||
|
<script>
|
||||||
|
var t = async_test("body.onresize should set the window.onload handler")
|
||||||
|
window.onresize = t.step_func(function() {
|
||||||
|
assert_unreached("This handler should be overwritten.")
|
||||||
|
})
|
||||||
|
|
||||||
|
var body = document.createElement("body")
|
||||||
|
body.onresize = t.step_func(function(e) {
|
||||||
|
assert_equals(e.currentTarget, window,
|
||||||
|
"The event should be fired at the window.")
|
||||||
|
t.done()
|
||||||
|
})
|
||||||
|
window.dispatchEvent(new Event('resize'));
|
||||||
|
|
||||||
|
t = async_test("document.onresize should set the document.onresize handler");
|
||||||
|
document.onresize = t.step_func(function(e) {
|
||||||
|
assert_equals(e.currentTarget, document,
|
||||||
|
"The event should be fired at the document")
|
||||||
|
t.done()
|
||||||
|
})
|
||||||
|
document.dispatchEvent(new Event('resize'));
|
||||||
|
|
||||||
|
t = async_test("meta.onresize should set the meta.onresize handler");
|
||||||
|
var meta = document.createElement("meta")
|
||||||
|
meta.onresize = t.step_func(function(e) {
|
||||||
|
assert_equals(e.currentTarget, meta,
|
||||||
|
"The event should be fired at the <meta> object")
|
||||||
|
t.done()
|
||||||
|
})
|
||||||
|
meta.dispatchEvent(new Event('resize'));
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue