bug 1155691 - Expose WindowRoot to chrome from window in webidl. r=smaug

This commit is contained in:
Ted Mielczarek 2015-04-17 16:17:26 -04:00
parent e4e891cb0c
commit dbfb883711
5 changed files with 36 additions and 0 deletions

View File

@ -13676,6 +13676,14 @@ nsGlobalWindow::BeginWindowMove(Event& aMouseDownEvent, Element* aPanel,
aError = widget->BeginMoveDrag(mouseEvent);
}
already_AddRefed<nsWindowRoot>
nsGlobalWindow::GetWindowRoot(mozilla::ErrorResult& aError)
{
FORWARD_TO_OUTER_OR_THROW(GetWindowRoot, (aError), aError, nullptr);
nsCOMPtr<nsPIWindowRoot> root = GetTopWindowRoot();
return root.forget().downcast<nsWindowRoot>();
}
//Note: This call will lock the cursor, it will not change as it moves.
//To unlock, the cursor must be set back to CURSOR_AUTO.
NS_IMETHODIMP

View File

@ -1098,6 +1098,8 @@ public:
JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aError);
already_AddRefed<nsWindowRoot> GetWindowRoot(mozilla::ErrorResult& aError);
protected:
// Web IDL helpers

View File

@ -70,3 +70,4 @@ skip-if = buildapp == 'mulet'
[test_fileconstructor_tempfile.xul]
[test_nsITextInputProcessor.xul]
[test_title.xul]
[test_windowroot.xul]

View File

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window title="Test window.windowRoot"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
</body>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
var root = window.windowRoot;
ok(root instanceof WindowRoot, "windowRoot should be a WindowRoot");
]]></script>
</window>

View File

@ -401,6 +401,12 @@ partial interface Window {
[ChromeOnly, Throws] readonly attribute object? __content;
[Throws, ChromeOnly] any getInterface(IID iid);
/**
* Same as nsIDOMWindow.windowRoot, useful for event listener targeting.
*/
[ChromeOnly, Throws]
readonly attribute WindowRoot? windowRoot;
};
Window implements TouchEventHandlers;