mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1119049 - Keyboard shortcuts should work in MediaDocuments without explicitly focusing the media element. r=bz
This commit is contained in:
parent
ff83916a03
commit
77fb9fa11a
@ -344,6 +344,26 @@ MediaDocument::LinkStylesheet(const nsAString& aStylesheet)
|
||||
return head->AppendChildTo(link, false);
|
||||
}
|
||||
|
||||
nsresult
|
||||
MediaDocument::LinkScript(const nsAString& aScript)
|
||||
{
|
||||
nsRefPtr<mozilla::dom::NodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::script, nullptr,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
|
||||
nsRefPtr<nsGenericHTMLElement> script = NS_NewHTMLScriptElement(nodeInfo.forget());
|
||||
NS_ENSURE_TRUE(script, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
script->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
|
||||
NS_LITERAL_STRING("text/javascript;version=1.8"), true);
|
||||
|
||||
script->SetAttr(kNameSpaceID_None, nsGkAtoms::src, aScript, true);
|
||||
|
||||
Element* head = GetHeadElement();
|
||||
return head->AppendChildTo(script, false);
|
||||
}
|
||||
|
||||
void
|
||||
MediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
|
||||
nsIChannel* aChannel,
|
||||
|
@ -52,6 +52,7 @@ protected:
|
||||
void GetFileName(nsAString& aResult, nsIChannel* aChannel);
|
||||
|
||||
nsresult LinkStylesheet(const nsAString& aStylesheet);
|
||||
nsresult LinkScript(const nsAString& aScript);
|
||||
|
||||
// |aFormatNames[]| needs to have four elements in the following order:
|
||||
// a format name with neither dimension nor file, a format name with
|
||||
|
@ -76,6 +76,7 @@ VideoDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject)
|
||||
GetReadyStateEnum() != nsIDocument::READYSTATE_COMPLETE) {
|
||||
LinkStylesheet(NS_LITERAL_STRING("resource://gre/res/TopLevelVideoDocument.css"));
|
||||
LinkStylesheet(NS_LITERAL_STRING("chrome://global/skin/media/TopLevelVideoDocument.css"));
|
||||
LinkScript(NS_LITERAL_STRING("chrome://global/content/TopLevelVideoDocument.js"));
|
||||
}
|
||||
BecomeInteractive();
|
||||
}
|
||||
|
28
toolkit/content/TopLevelVideoDocument.js
Normal file
28
toolkit/content/TopLevelVideoDocument.js
Normal file
@ -0,0 +1,28 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
window.addEventListener("load", () => {
|
||||
// <video> is used for top-level audio documents as well
|
||||
let videoElement = document.getElementsByTagName("video")[0];
|
||||
if (!videoElement)
|
||||
return;
|
||||
|
||||
// Send keystrokes to the video element when the body element is focused,
|
||||
// to be received by the event listener in videocontrols.xml.
|
||||
document.addEventListener("keypress", ev => {
|
||||
if (ev.synthetic) // prevent recursion
|
||||
return;
|
||||
|
||||
// Check if the video element is focused, so it already receives
|
||||
// keystrokes, and don't send it another one from here.
|
||||
if (document.activeElement == videoElement)
|
||||
return;
|
||||
|
||||
let newEvent = new KeyboardEvent("keypress", ev);
|
||||
newEvent.synthetic = true;
|
||||
videoElement.dispatchEvent(newEvent);
|
||||
});
|
||||
});
|
@ -59,6 +59,7 @@ toolkit.jar:
|
||||
content/global/resetProfile.xul
|
||||
content/global/resetProfileProgress.xul
|
||||
content/global/select-child.js
|
||||
content/global/TopLevelVideoDocument.js
|
||||
content/global/treeUtils.js
|
||||
content/global/viewZoomOverlay.js
|
||||
*+ content/global/bindings/autocomplete.xml (widgets/autocomplete.xml)
|
||||
|
Loading…
Reference in New Issue
Block a user