Merge remote-tracking branch 'origin/master' into custom

This commit is contained in:
Roy Tam 2020-01-09 21:28:41 +08:00
commit 1a197351cd
42 changed files with 582 additions and 590 deletions

View file

@ -172,6 +172,10 @@ EVENT(click,
eMouseClick,
EventNameType_All,
eMouseEventClass)
EVENT(close,
eClose,
EventNameType_HTMLXUL,
eBasicEventClass)
EVENT(contextmenu,
eContextMenu,
EventNameType_HTMLXUL,
@ -773,10 +777,6 @@ NON_IDL_EVENT(command,
eXULCommand,
EventNameType_XUL,
eInputEventClass)
NON_IDL_EVENT(close,
eWindowClose,
EventNameType_XUL,
eBasicEventClass)
NON_IDL_EVENT(popupshowing,
eXULPopupShowing,
EventNameType_XUL,

View file

@ -297,7 +297,7 @@ IMEStateManager::OnDestroyPresContext(nsPresContext* aPresContext)
IMEState newState = GetNewIMEState(sPresContext, nullptr);
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::LOST_FOCUS);
SetIMEState(newState, nullptr, sWidget, action);
SetIMEState(newState, nullptr, nullptr, sWidget, action);
}
sWidget = nullptr;
sContent = nullptr;
@ -352,7 +352,7 @@ IMEStateManager::OnRemoveContent(nsPresContext* aPresContext,
IMEState newState = GetNewIMEState(sPresContext, nullptr);
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::LOST_FOCUS);
SetIMEState(newState, nullptr, sWidget, action);
SetIMEState(newState, aPresContext, nullptr, sWidget, action);
}
sWidget = nullptr;
@ -542,7 +542,7 @@ IMEStateManager::OnChangeFocusInternal(nsPresContext* aPresContext,
}
// Update IME state for new focus widget
SetIMEState(newState, aContent, newWidget, aAction);
SetIMEState(newState, aPresContext, aContent, newWidget, aAction);
}
sActiveTabParent = newTabParent;
@ -704,7 +704,7 @@ IMEStateManager::OnClickInEditor(nsPresContext* aPresContext,
InputContextAction action(cause, InputContextAction::FOCUS_NOT_CHANGED);
IMEState newState = GetNewIMEState(aPresContext, aContent);
SetIMEState(newState, aContent, widget, action);
SetIMEState(newState, aPresContext, aContent, widget, action);
}
// static
@ -912,7 +912,7 @@ IMEStateManager::UpdateIMEState(const IMEState& aNewIMEState,
if (updateIMEState) {
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::FOCUS_NOT_CHANGED);
SetIMEState(aNewIMEState, aContent, widget, action);
SetIMEState(aNewIMEState, sPresContext, aContent, widget, action);
if (NS_WARN_IF(widget->Destroyed())) {
MOZ_LOG(sISMLog, LogLevel::Error,
(" UpdateIMEState(), widget has gone during setting input context"));
@ -1022,8 +1022,8 @@ IMEStateManager::SetInputContextForChildProcess(
MOZ_LOG(sISMLog, LogLevel::Info,
("SetInputContextForChildProcess(aTabParent=0x%p, "
"aInputContext={ mIMEState={ mEnabled=%s, mOpen=%s }, "
"mHTMLInputType=\"%s\", mHTMLInputInputmode=\"%s\", mActionHint=\"%s\" }, "
"aAction={ mCause=%s, mAction=%s }), "
"mHTMLInputType=\"%s\", mHTMLInputInputmode=\"%s\", mActionHint=\"%s\", "
"mInPrivateBrowsing=%s }, aAction={ mCause=%s, mAction=%s }), "
"sPresContext=0x%p (available: %s), sWidget=0x%p (available: %s), "
"sActiveTabParent=0x%p",
aTabParent, GetIMEStateEnabledName(aInputContext.mIMEState.mEnabled),
@ -1031,6 +1031,7 @@ IMEStateManager::SetInputContextForChildProcess(
NS_ConvertUTF16toUTF8(aInputContext.mHTMLInputType).get(),
NS_ConvertUTF16toUTF8(aInputContext.mHTMLInputInputmode).get(),
NS_ConvertUTF16toUTF8(aInputContext.mActionHint).get(),
GetBoolName(aInputContext.mInPrivateBrowsing),
GetActionCauseName(aAction.mCause),
GetActionFocusChangeName(aAction.mFocusChange),
sPresContext.get(), GetBoolName(CanHandleWith(sPresContext)),
@ -1070,6 +1071,7 @@ IMEStateManager::SetInputContextForChildProcess(
// static
void
IMEStateManager::SetIMEState(const IMEState& aState,
nsPresContext* aPresContext,
nsIContent* aContent,
nsIWidget* aWidget,
InputContextAction aAction)
@ -1090,6 +1092,10 @@ IMEStateManager::SetIMEState(const IMEState& aState,
context.mIMEState = aState;
context.mMayBeIMEUnaware = context.mIMEState.IsEditable() &&
sCheckForIMEUnawareWebApps && MayBeIMEUnawareWebApp(aContent);
context.mInPrivateBrowsing =
aPresContext &&
nsContentUtils::IsInPrivateBrowsing(aPresContext->Document());
if (aContent &&
aContent->IsAnyOfHTMLElements(nsGkAtoms::input, nsGkAtoms::textarea)) {
@ -1175,7 +1181,8 @@ IMEStateManager::SetInputContext(nsIWidget* aWidget,
MOZ_LOG(sISMLog, LogLevel::Info,
("SetInputContext(aWidget=0x%p, aInputContext={ "
"mIMEState={ mEnabled=%s, mOpen=%s }, mHTMLInputType=\"%s\", "
"mHTMLInputInputmode=\"%s\", mActionHint=\"%s\" }, "
"mHTMLInputInputmode=\"%s\", mActionHint=\"%s\", "
"mInPrivateBrowsing=%s }, "
"aAction={ mCause=%s, mAction=%s }), sActiveTabParent=0x%p",
aWidget,
GetIMEStateEnabledName(aInputContext.mIMEState.mEnabled),
@ -1183,6 +1190,7 @@ IMEStateManager::SetInputContext(nsIWidget* aWidget,
NS_ConvertUTF16toUTF8(aInputContext.mHTMLInputType).get(),
NS_ConvertUTF16toUTF8(aInputContext.mHTMLInputInputmode).get(),
NS_ConvertUTF16toUTF8(aInputContext.mActionHint).get(),
GetBoolName(aInputContext.mInPrivateBrowsing),
GetActionCauseName(aAction.mCause),
GetActionFocusChangeName(aAction.mFocusChange),
sActiveTabParent.get()));

View file

@ -247,6 +247,7 @@ protected:
nsIContent* aContent,
InputContextAction aAction);
static void SetIMEState(const IMEState &aState,
nsPresContext* aPresContext,
nsIContent* aContent,
nsIWidget* aWidget,
InputContextAction aAction);

View file

@ -0,0 +1,95 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#include "mozilla/dom/HTMLDialogElement.h"
#include "mozilla/dom/HTMLDialogElementBinding.h"
#include "mozilla/dom/HTMLUnknownElement.h"
#include "mozilla/Preferences.h"
// Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Dialog) with pref check
nsGenericHTMLElement*
NS_NewHTMLDialogElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
mozilla::dom::FromParser aFromParser)
{
if (!mozilla::dom::HTMLDialogElement::IsDialogEnabled()) {
return new mozilla::dom::HTMLUnknownElement(aNodeInfo);
}
return new mozilla::dom::HTMLDialogElement(aNodeInfo);
}
namespace mozilla {
namespace dom {
HTMLDialogElement::~HTMLDialogElement()
{
}
NS_IMPL_ELEMENT_CLONE(HTMLDialogElement)
bool
HTMLDialogElement::IsDialogEnabled()
{
static bool isDialogEnabled = false;
static bool added = false;
if (!added) {
Preferences::AddBoolVarCache(&isDialogEnabled,
"dom.dialog_element.enabled");
added = true;
}
return isDialogEnabled;
}
void
HTMLDialogElement::Close(const mozilla::dom::Optional<nsAString>& aReturnValue)
{
if (!Open()) {
return;
}
if (aReturnValue.WasPassed()) {
SetReturnValue(aReturnValue.Value());
}
ErrorResult ignored;
SetOpen(false, ignored);
ignored.SuppressException();
RefPtr<AsyncEventDispatcher> eventDispatcher =
new AsyncEventDispatcher(this, NS_LITERAL_STRING("close"), false);
eventDispatcher->PostDOMEvent();
}
void
HTMLDialogElement::Show()
{
if (Open()) {
return;
}
ErrorResult ignored;
SetOpen(true, ignored);
ignored.SuppressException();
}
void
HTMLDialogElement::ShowModal(ErrorResult& aError)
{
if (!IsInComposedDoc() || Open()) {
aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
SetOpen(true, aError);
aError.SuppressException();
}
JSObject*
HTMLDialogElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return HTMLDialogElementBinding::Wrap(aCx, this, aGivenProto);
}
} // namespace dom
} // namespace mozilla

View file

@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef HTMLDialogElement_h
#define HTMLDialogElement_h
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/Attributes.h"
#include "nsGenericHTMLElement.h"
#include "nsGkAtoms.h"
namespace mozilla {
namespace dom {
class HTMLDialogElement final : public nsGenericHTMLElement
{
public:
explicit HTMLDialogElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo) : nsGenericHTMLElement(aNodeInfo)
{
}
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLDialogElement, dialog)
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const override;
static bool IsDialogEnabled();
bool Open() const { return GetBoolAttr(nsGkAtoms::open); }
void SetOpen(bool aOpen, ErrorResult& aError)
{
SetHTMLBoolAttr(nsGkAtoms::open, aOpen, aError);
}
void GetReturnValue(nsAString& aReturnValue)
{
aReturnValue = mReturnValue;
}
void SetReturnValue(const nsAString& aReturnValue)
{
mReturnValue = aReturnValue;
}
void Close(const mozilla::dom::Optional<nsAString>& aReturnValue);
void Show();
void ShowModal(ErrorResult& aError);
nsString mReturnValue;
protected:
virtual ~HTMLDialogElement();
JSObject* WrapNode(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
};
} // namespace dom
} // namespace mozilla
#endif

View file

@ -56,6 +56,7 @@ EXPORTS.mozilla.dom += [
'HTMLDataElement.h',
'HTMLDataListElement.h',
'HTMLDetailsElement.h',
'HTMLDialogElement.h',
'HTMLDivElement.h',
'HTMLFieldSetElement.h',
'HTMLFontElement.h',
@ -134,6 +135,7 @@ UNIFIED_SOURCES += [
'HTMLDataElement.cpp',
'HTMLDataListElement.cpp',
'HTMLDetailsElement.cpp',
'HTMLDialogElement.cpp',
'HTMLDivElement.cpp',
'HTMLElement.cpp',
'HTMLFieldSetElement.cpp',

View file

@ -1654,6 +1654,7 @@ NS_DECLARE_NS_NEW_HTML_ELEMENT(Mod)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Data)
NS_DECLARE_NS_NEW_HTML_ELEMENT(DataList)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Details)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Dialog)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Div)
NS_DECLARE_NS_NEW_HTML_ELEMENT(FieldSet)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Font)

View file

@ -442,6 +442,8 @@ var interfaceNamesInGlobalScope =
"HTMLDataListElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLDetailsElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "HTMLDialogElement", disabled: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLDirectoryElement",
// IMPORTANT: Do not change this list without review from a DOM peer!

View file

@ -26,4 +26,12 @@ interface CSSStyleSheet : StyleSheet {
unsigned long insertRule(DOMString rule, optional unsigned long index = 0);
[Throws, NeedsSubjectPrincipal]
void deleteRule(unsigned long index);
// Non-standard WebKit things, see https://github.com/w3c/csswg-drafts/pull/3900.
[Throws, NeedsSubjectPrincipal, BinaryName="cssRules"]
readonly attribute CSSRuleList rules;
[Throws, NeedsSubjectPrincipal, BinaryName="deleteRule"]
void removeRule(optional unsigned long index = 0);
[Throws, NeedsSubjectPrincipal]
long addRule(optional DOMString selector = "undefined", optional DOMString style = "undefined", optional unsigned long index);
};

View file

@ -38,7 +38,7 @@ interface GlobalEventHandlers {
attribute EventHandler oncanplaythrough;
attribute EventHandler onchange;
attribute EventHandler onclick;
//(Not implemented)attribute EventHandler onclose;
attribute EventHandler onclose;
attribute EventHandler oncontextmenu;
//(Not implemented)attribute EventHandler oncuechange;
attribute EventHandler ondblclick;

View file

@ -0,0 +1,23 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* https://html.spec.whatwg.org/multipage/forms.html#the-dialog-element
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
[Pref="dom.dialog_element.enabled"]
interface HTMLDialogElement : HTMLElement {
[SetterThrows] attribute boolean open;
attribute DOMString returnValue;
void show();
[Throws] void showModal();
void close(optional DOMString returnValue);
};

View file

@ -184,6 +184,7 @@ WEBIDL_FILES = [
'HTMLDataElement.webidl',
'HTMLDataListElement.webidl',
'HTMLDetailsElement.webidl',
'HTMLDialogElement.webidl',
'HTMLDirectoryElement.webidl',
'HTMLDivElement.webidl',
'HTMLDListElement.webidl',