Implement "resize" DOM Event.

* We cannot automate this feature.
* So this testcase is a manual test.
This commit is contained in:
Tetsuharu OHZEKI 2014-03-01 00:03:10 +09:00
parent 83ff59e5f1
commit b3536d1d97
2 changed files with 46 additions and 1 deletions

View file

@ -6,16 +6,18 @@
//! and layout tasks.
use dom::bindings::codegen::RegisterBindings;
use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, ElementCast};
use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, ElementCast, EventCast};
use dom::bindings::js::JS;
use dom::bindings::utils::{Reflectable, GlobalStaticData, with_gc_enabled};
use dom::document::{Document, HTMLDocument};
use dom::element::Element;
use dom::event::{Event_, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
use dom::event::Event;
use dom::uievent::UIEvent;
use dom::eventtarget::EventTarget;
use dom::node::{Node, NodeHelpers};
use dom::window::{TimerData, TimerHandle, Window};
use dom::windowproxy::WindowProxy;
use html::hubbub_html_parser::HtmlParserResult;
use html::hubbub_html_parser::{HtmlDiscoveredStyle, HtmlDiscoveredIFrame, HtmlDiscoveredScript};
use html::hubbub_html_parser;
@ -863,6 +865,23 @@ impl ScriptTask {
Some(node) => self.scroll_fragment_point(pipeline_id, page, node),
None => {}
}
match page.frame {
Some(ref frame) => {
// http://dev.w3.org/csswg/cssom-view/#resizing-viewports
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-resize
let window_proxy: JS<WindowProxy> = WindowProxy::new(frame.window.clone());
let mut uievent = UIEvent::new(&frame.window);
uievent.get_mut().InitUIEvent(~"resize", false, false, Some(window_proxy), 0i32);
let event: &mut JS<Event> = &mut EventCast::from(&uievent);
// 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);
}
None =>()
}
}
// FIXME(pcwalton): This reflows the entire document and is not incremental-y.

View file

@ -0,0 +1,26 @@
<html>
<head>
<title></title>
<script src="./content/harness.js"></script>
</head>
<body>
<script>
window.addEventListener("resize", function (aEvent) {
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-resize
is_a(aEvent, UIEvent, "event should be UIEvent.");
is(aEvent.bubbles, false, "Bubbles should be No.");
is(aEvent.cancelable, false, "Cancelable should be No.");
// FIXME:
// Target should be defaultView (WindowProxy) by D3E
// But we set Window instead of WindowProxy now. See: #1715
is(aEvent.target, window, "Target should be defaultView.");
is_a(aEvent.target, Window, "UIEvent.target should be instance of Window.");
//is(aEvent.view, document.defaultView, "UIEvent.view should be defaultView.");
is_a(aEvent.view, WindowProxy, "UIEvent.view should be instance of WindowProxy.");
is(aEvent.detail, 0, "UIEvent.view should be 0.");
}, false);
</script>
</body>
</html>