mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 11:57:32 +09:00
Merge remote-tracking branch 'origin/master' into custom
This commit is contained in:
commit
ab4f78f4b7
46 changed files with 1004 additions and 604 deletions
|
|
@ -5,7 +5,11 @@
|
||||||
|
|
||||||
<menubar id="main-menubar"
|
<menubar id="main-menubar"
|
||||||
onpopupshowing="if (event.target.parentNode.parentNode == this &&
|
onpopupshowing="if (event.target.parentNode.parentNode == this &&
|
||||||
|
#ifdef MOZ_WIDGET_GTK
|
||||||
|
document.documentElement.getAttribute('shellshowingmenubar') != 'true')
|
||||||
|
#else
|
||||||
!('@mozilla.org/widget/nativemenuservice;1' in Cc))
|
!('@mozilla.org/widget/nativemenuservice;1' in Cc))
|
||||||
|
#endif
|
||||||
this.setAttribute('openedwithkey',
|
this.setAttribute('openedwithkey',
|
||||||
event.target.parentNode.openedWithKey);"
|
event.target.parentNode.openedWithKey);"
|
||||||
style="border:0px;padding:0px;margin:0px;-moz-appearance:none">
|
style="border:0px;padding:0px;margin:0px;-moz-appearance:none">
|
||||||
|
|
|
||||||
|
|
@ -226,6 +226,10 @@ splitmenu {
|
||||||
#appmenu-toolbar-button > .toolbarbutton-text {
|
#appmenu-toolbar-button > .toolbarbutton-text {
|
||||||
display: -moz-box;
|
display: -moz-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window[shellshowingmenubar="true"] #appmenu-toolbar-button {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
#appmenu_offlineModeRecovery:not([checked=true]) {
|
#appmenu_offlineModeRecovery:not([checked=true]) {
|
||||||
|
|
|
||||||
|
|
@ -4600,6 +4600,12 @@ function onViewToolbarsPopupShowing(aEvent, aInsertPoint) {
|
||||||
toolbarNodes.push(document.getElementById("addon-bar"));
|
toolbarNodes.push(document.getElementById("addon-bar"));
|
||||||
|
|
||||||
for (let toolbar of toolbarNodes) {
|
for (let toolbar of toolbarNodes) {
|
||||||
|
#ifdef MOZ_WIDGET_GTK
|
||||||
|
if (toolbar.id == "toolbar-menubar" &&
|
||||||
|
document.documentElement.getAttribute("shellshowingmenubar") == "true") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
let toolbarName = toolbar.getAttribute("toolbarname");
|
let toolbarName = toolbar.getAttribute("toolbarname");
|
||||||
if (toolbarName) {
|
if (toolbarName) {
|
||||||
let menuItem = document.createElement("menuitem");
|
let menuItem = document.createElement("menuitem");
|
||||||
|
|
|
||||||
|
|
@ -153,8 +153,12 @@
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
<toolbarbutton type="menu" class="tabbable"
|
<toolbarbutton type="menu" class="tabbable"
|
||||||
onpopupshowing="document.getElementById('placeContent').focus()"
|
onpopupshowing="document.getElementById('placeContent').focus()"
|
||||||
|
#else
|
||||||
|
#ifdef MOZ_WIDGET_GTK
|
||||||
|
<menubar id="placesMenu" _moz-menubarkeeplocal="true">
|
||||||
#else
|
#else
|
||||||
<menubar id="placesMenu">
|
<menubar id="placesMenu">
|
||||||
|
#endif
|
||||||
<menu accesskey="&organize.accesskey;" class="menu-iconic"
|
<menu accesskey="&organize.accesskey;" class="menu-iconic"
|
||||||
#endif
|
#endif
|
||||||
id="organizeButton" label="&organize.label;"
|
id="organizeButton" label="&organize.label;"
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "mozilla/dom/ChromeNodeList.h"
|
#include "mozilla/dom/ChromeNodeList.h"
|
||||||
#include "mozilla/dom/ChromeNodeListBinding.h"
|
#include "mozilla/dom/ChromeNodeListBinding.h"
|
||||||
|
#include "nsPIDOMWindow.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "nsCOMArray.h"
|
#include "nsCOMArray.h"
|
||||||
#include "nsContentList.h"
|
#include "nsContentList.h"
|
||||||
|
#include "nsIDocument.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
class ErrorResult;
|
class ErrorResult;
|
||||||
|
|
|
||||||
149
dom/base/DocumentOrShadowRoot.cpp
Normal file
149
dom/base/DocumentOrShadowRoot.cpp
Normal file
|
|
@ -0,0 +1,149 @@
|
||||||
|
/* -*- 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 "DocumentOrShadowRoot.h"
|
||||||
|
#include "mozilla/dom/StyleSheetList.h"
|
||||||
|
#include "nsDocument.h"
|
||||||
|
#include "nsFocusManager.h"
|
||||||
|
#include "ShadowRoot.h"
|
||||||
|
#include "XULDocument.h"
|
||||||
|
|
||||||
|
class nsINode;
|
||||||
|
class nsIDocument;
|
||||||
|
class ShadowRoot;
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
|
||||||
|
DocumentOrShadowRoot::DocumentOrShadowRoot(mozilla::dom::ShadowRoot* aShadowRoot)
|
||||||
|
: mAsNode(aShadowRoot)
|
||||||
|
, mKind(Kind::ShadowRoot)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(mAsNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
DocumentOrShadowRoot::DocumentOrShadowRoot(nsIDocument* aDoc)
|
||||||
|
: mAsNode(aDoc)
|
||||||
|
, mKind(Kind::Document)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(mAsNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
StyleSheetList&
|
||||||
|
DocumentOrShadowRoot::EnsureDOMStyleSheets()
|
||||||
|
{
|
||||||
|
if (!mDOMStyleSheets) {
|
||||||
|
mDOMStyleSheets = new StyleSheetList(*this);
|
||||||
|
}
|
||||||
|
return *mDOMStyleSheets;
|
||||||
|
}
|
||||||
|
|
||||||
|
Element*
|
||||||
|
DocumentOrShadowRoot::GetElementById(const nsAString& aElementId)
|
||||||
|
{
|
||||||
|
if (MOZ_UNLIKELY(aElementId.IsEmpty())) {
|
||||||
|
nsContentUtils::ReportEmptyGetElementByIdArg(AsNode().OwnerDoc());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aElementId)) {
|
||||||
|
if (Element* el = entry->GetIdElement()) {
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MOZ_UNLIKELY(mKind == Kind::Document &&
|
||||||
|
static_cast<nsIDocument&>(AsNode()).IsXULDocument())) {
|
||||||
|
return static_cast<XULDocument&>(AsNode()).GetRefById(aElementId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
already_AddRefed<nsContentList>
|
||||||
|
DocumentOrShadowRoot::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
||||||
|
const nsAString& aLocalName)
|
||||||
|
{
|
||||||
|
ErrorResult rv;
|
||||||
|
RefPtr<nsContentList> list =
|
||||||
|
GetElementsByTagNameNS(aNamespaceURI, aLocalName, rv);
|
||||||
|
if (rv.Failed()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return list.forget();
|
||||||
|
}
|
||||||
|
|
||||||
|
already_AddRefed<nsContentList>
|
||||||
|
DocumentOrShadowRoot::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
||||||
|
const nsAString& aLocalName,
|
||||||
|
mozilla::ErrorResult& aResult)
|
||||||
|
{
|
||||||
|
int32_t nameSpaceId = kNameSpaceID_Wildcard;
|
||||||
|
|
||||||
|
if (!aNamespaceURI.EqualsLiteral("*")) {
|
||||||
|
aResult =
|
||||||
|
nsContentUtils::NameSpaceManager()->RegisterNameSpace(aNamespaceURI,
|
||||||
|
nameSpaceId);
|
||||||
|
if (aResult.Failed()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_ASSERTION(nameSpaceId != kNameSpaceID_Unknown, "Unexpected namespace ID!");
|
||||||
|
return NS_GetContentList(&AsNode(), nameSpaceId, aLocalName);
|
||||||
|
}
|
||||||
|
|
||||||
|
already_AddRefed<nsContentList>
|
||||||
|
DocumentOrShadowRoot::GetElementsByClassName(const nsAString& aClasses)
|
||||||
|
{
|
||||||
|
return nsContentUtils::GetElementsByClassName(&AsNode(), aClasses);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsIContent*
|
||||||
|
DocumentOrShadowRoot::Retarget(nsIContent* aContent) const
|
||||||
|
{
|
||||||
|
for (nsIContent* cur = aContent;
|
||||||
|
cur;
|
||||||
|
cur = cur->GetContainingShadowHost()) {
|
||||||
|
if (cur->SubtreeRoot() == &AsNode()) {
|
||||||
|
return cur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Element*
|
||||||
|
DocumentOrShadowRoot::GetRetargetedFocusedElement()
|
||||||
|
{
|
||||||
|
if (nsCOMPtr<nsPIDOMWindowOuter> window = AsNode().OwnerDoc()->GetWindow()) {
|
||||||
|
nsCOMPtr<nsPIDOMWindowOuter> focusedWindow;
|
||||||
|
nsIContent* focusedContent =
|
||||||
|
nsFocusManager::GetFocusedDescendant(window,
|
||||||
|
false,
|
||||||
|
getter_AddRefs(focusedWindow));
|
||||||
|
// be safe and make sure the element is from this document
|
||||||
|
if (focusedContent && focusedContent->OwnerDoc() == AsNode().OwnerDoc()) {
|
||||||
|
if (focusedContent->ChromeOnlyAccess()) {
|
||||||
|
focusedContent = focusedContent->FindFirstNonChromeOnlyAccessContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (focusedContent) {
|
||||||
|
if (!nsDocument::IsWebComponentsEnabled(focusedContent)) {
|
||||||
|
return focusedContent->AsElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nsIContent* retarget = Retarget(focusedContent)) {
|
||||||
|
return retarget->AsElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
160
dom/base/DocumentOrShadowRoot.h
Normal file
160
dom/base/DocumentOrShadowRoot.h
Normal file
|
|
@ -0,0 +1,160 @@
|
||||||
|
/* -*- 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 mozilla_dom_DocumentOrShadowRoot_h__
|
||||||
|
#define mozilla_dom_DocumentOrShadowRoot_h__
|
||||||
|
|
||||||
|
#include "nsTArray.h"
|
||||||
|
#include "nsIdentifierMapEntry.h"
|
||||||
|
#include "nsContentListDeclarations.h"
|
||||||
|
#include "nsNameSpaceManager.h"
|
||||||
|
#include "mozilla/dom/NameSpaceConstants.h"
|
||||||
|
|
||||||
|
class nsContentList;
|
||||||
|
class nsINode;
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
class StyleSheet;
|
||||||
|
|
||||||
|
namespace dom {
|
||||||
|
|
||||||
|
class StyleSheetList;
|
||||||
|
class ShadowRoot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class meant to be shared by ShadowRoot and Document, that holds a list of
|
||||||
|
* stylesheets.
|
||||||
|
*
|
||||||
|
* TODO(emilio, bug 1418159): In the future this should hold most of the
|
||||||
|
* relevant style state, this should allow us to fix bug 548397.
|
||||||
|
*/
|
||||||
|
class DocumentOrShadowRoot
|
||||||
|
{
|
||||||
|
enum class Kind {
|
||||||
|
Document,
|
||||||
|
ShadowRoot,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DocumentOrShadowRoot(nsIDocument*);
|
||||||
|
explicit DocumentOrShadowRoot(mozilla::dom::ShadowRoot*);
|
||||||
|
|
||||||
|
nsINode& AsNode()
|
||||||
|
{
|
||||||
|
return *mAsNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
const nsINode& AsNode() const
|
||||||
|
{
|
||||||
|
return *mAsNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
StyleSheet* SheetAt(size_t aIndex) const
|
||||||
|
{
|
||||||
|
return mStyleSheets.SafeElementAt(aIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t SheetCount() const
|
||||||
|
{
|
||||||
|
return mStyleSheets.Length();
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t IndexOfSheet(const StyleSheet& aSheet) const
|
||||||
|
{
|
||||||
|
return mStyleSheets.IndexOf(&aSheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InsertSheetAt(size_t aIndex, StyleSheet& aSheet)
|
||||||
|
{
|
||||||
|
mStyleSheets.InsertElementAt(aIndex, &aSheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoveSheet(StyleSheet& aSheet)
|
||||||
|
{
|
||||||
|
mStyleSheets.RemoveElement(&aSheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppendStyleSheet(StyleSheet& aSheet)
|
||||||
|
{
|
||||||
|
mStyleSheets.AppendElement(&aSheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
StyleSheetList& EnsureDOMStyleSheets();
|
||||||
|
|
||||||
|
Element* GetElementById(const nsAString& aElementId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns _all_ the elements in this scope which have id
|
||||||
|
* aElementId, if there are any. Otherwise it returns null.
|
||||||
|
*
|
||||||
|
* This is useful for stuff like QuerySelector optimization and such.
|
||||||
|
*/
|
||||||
|
inline const nsTArray<Element*>*
|
||||||
|
GetAllElementsForId(const nsAString& aElementId) const;
|
||||||
|
|
||||||
|
already_AddRefed<nsContentList>
|
||||||
|
GetElementsByTagName(const nsAString& aTagName)
|
||||||
|
{
|
||||||
|
return NS_GetContentList(&AsNode(), kNameSpaceID_Unknown, aTagName);
|
||||||
|
}
|
||||||
|
|
||||||
|
already_AddRefed<nsContentList>
|
||||||
|
GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
||||||
|
const nsAString& aLocalName);
|
||||||
|
|
||||||
|
already_AddRefed<nsContentList>
|
||||||
|
GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
||||||
|
const nsAString& aLocalName,
|
||||||
|
mozilla::ErrorResult&);
|
||||||
|
|
||||||
|
already_AddRefed<nsContentList>
|
||||||
|
GetElementsByClassName(const nsAString& aClasses);
|
||||||
|
|
||||||
|
~DocumentOrShadowRoot() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
nsIContent* Retarget(nsIContent* aContent) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If focused element's subtree root is this document or shadow root, return
|
||||||
|
* focused element, otherwise, get the shadow host recursively until the
|
||||||
|
* shadow host's subtree root is this document or shadow root.
|
||||||
|
*/
|
||||||
|
Element* GetRetargetedFocusedElement();
|
||||||
|
|
||||||
|
nsTArray<RefPtr<mozilla::StyleSheet>> mStyleSheets;
|
||||||
|
RefPtr<mozilla::dom::StyleSheetList> mDOMStyleSheets;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* mIdentifierMap works as follows for IDs:
|
||||||
|
* 1) Attribute changes affect the table immediately (removing and adding
|
||||||
|
* entries as needed).
|
||||||
|
* 2) Removals from the DOM affect the table immediately
|
||||||
|
* 3) Additions to the DOM always update existing entries for names, and add
|
||||||
|
* new ones for IDs.
|
||||||
|
*/
|
||||||
|
nsTHashtable<nsIdentifierMapEntry> mIdentifierMap;
|
||||||
|
|
||||||
|
nsINode* mAsNode;
|
||||||
|
const Kind mKind;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline const nsTArray<Element*>*
|
||||||
|
DocumentOrShadowRoot::GetAllElementsForId(const nsAString& aElementId) const
|
||||||
|
{
|
||||||
|
if (aElementId.IsEmpty()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aElementId);
|
||||||
|
return entry ? &entry->GetIdElements() : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -139,6 +139,7 @@ class EventStateManager;
|
||||||
|
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
|
struct CustomElementDefinition;
|
||||||
class Animation;
|
class Animation;
|
||||||
class CustomElementRegistry;
|
class CustomElementRegistry;
|
||||||
class Link;
|
class Link;
|
||||||
|
|
|
||||||
|
|
@ -1138,6 +1138,15 @@ FragmentOrElement::GetAssignedSlot() const
|
||||||
return slots ? slots->mAssignedSlot.get() : nullptr;
|
return slots ? slots->mAssignedSlot.get() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsIContent*
|
||||||
|
nsIContent::GetContainingShadowHost() const
|
||||||
|
{
|
||||||
|
if (mozilla::dom::ShadowRoot* shadow = GetContainingShadow()) {
|
||||||
|
return shadow->GetHost();
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FragmentOrElement::SetAssignedSlot(HTMLSlotElement* aSlot)
|
FragmentOrElement::SetAssignedSlot(HTMLSlotElement* aSlot)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ ShadowRoot::ShadowRoot(Element* aElement, bool aClosed,
|
||||||
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
||||||
nsXBLPrototypeBinding* aProtoBinding)
|
nsXBLPrototypeBinding* aProtoBinding)
|
||||||
: DocumentFragment(aNodeInfo)
|
: DocumentFragment(aNodeInfo)
|
||||||
|
, DocumentOrShadowRoot(this)
|
||||||
, mProtoBinding(aProtoBinding)
|
, mProtoBinding(aProtoBinding)
|
||||||
, mInsertionPointChanged(false)
|
, mInsertionPointChanged(false)
|
||||||
, mIsComposedDocParticipant(false)
|
, mIsComposedDocParticipant(false)
|
||||||
|
|
@ -240,7 +241,7 @@ ShadowRoot::InsertSheet(StyleSheet* aSheet,
|
||||||
|
|
||||||
linkingElement->SetStyleSheet(aSheet); // This sets the ownerNode on the sheet
|
linkingElement->SetStyleSheet(aSheet); // This sets the ownerNode on the sheet
|
||||||
|
|
||||||
MOZ_DIAGNOSTIC_ASSERT(mProtoBinding->SheetCount() == StyleScope::SheetCount());
|
MOZ_DIAGNOSTIC_ASSERT(mProtoBinding->SheetCount() == DocumentOrShadowRoot::SheetCount());
|
||||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||||
// FIXME(emilio, bug 1425759): For now we keep them duplicated, the proto
|
// FIXME(emilio, bug 1425759): For now we keep them duplicated, the proto
|
||||||
// binding will disappear soon (tm).
|
// binding will disappear soon (tm).
|
||||||
|
|
@ -278,49 +279,17 @@ void
|
||||||
ShadowRoot::RemoveSheet(StyleSheet* aSheet)
|
ShadowRoot::RemoveSheet(StyleSheet* aSheet)
|
||||||
{
|
{
|
||||||
mProtoBinding->RemoveStyleSheet(aSheet);
|
mProtoBinding->RemoveStyleSheet(aSheet);
|
||||||
StyleScope::RemoveSheet(*aSheet);
|
DocumentOrShadowRoot::RemoveSheet(*aSheet);
|
||||||
|
|
||||||
if (aSheet->IsApplicable()) {
|
if (aSheet->IsApplicable()) {
|
||||||
StyleSheetChanged();
|
StyleSheetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Element*
|
|
||||||
ShadowRoot::GetElementById(const nsAString& aElementId)
|
|
||||||
{
|
|
||||||
nsIdentifierMapEntry *entry = mIdentifierMap.GetEntry(aElementId);
|
|
||||||
return entry ? entry->GetIdElement() : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
already_AddRefed<nsContentList>
|
|
||||||
ShadowRoot::GetElementsByTagName(const nsAString& aTagName)
|
|
||||||
{
|
|
||||||
return NS_GetContentList(this, kNameSpaceID_Unknown, aTagName);
|
|
||||||
}
|
|
||||||
|
|
||||||
already_AddRefed<nsContentList>
|
|
||||||
ShadowRoot::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
|
||||||
const nsAString& aLocalName)
|
|
||||||
{
|
|
||||||
int32_t nameSpaceId = kNameSpaceID_Wildcard;
|
|
||||||
|
|
||||||
if (!aNamespaceURI.EqualsLiteral("*")) {
|
|
||||||
nsresult rv =
|
|
||||||
nsContentUtils::NameSpaceManager()->RegisterNameSpace(aNamespaceURI,
|
|
||||||
nameSpaceId);
|
|
||||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_ASSERTION(nameSpaceId != kNameSpaceID_Unknown, "Unexpected namespace ID!");
|
|
||||||
|
|
||||||
return NS_GetContentList(this, nameSpaceId, aLocalName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShadowRoot::AddToIdTable(Element* aElement, nsIAtom* aId)
|
ShadowRoot::AddToIdTable(Element* aElement, nsIAtom* aId)
|
||||||
{
|
{
|
||||||
nsIdentifierMapEntry *entry =
|
nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aId);
|
||||||
mIdentifierMap.PutEntry(nsDependentAtomString(aId));
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
entry->AddIdElement(aElement);
|
entry->AddIdElement(aElement);
|
||||||
}
|
}
|
||||||
|
|
@ -329,8 +298,7 @@ ShadowRoot::AddToIdTable(Element* aElement, nsIAtom* aId)
|
||||||
void
|
void
|
||||||
ShadowRoot::RemoveFromIdTable(Element* aElement, nsIAtom* aId)
|
ShadowRoot::RemoveFromIdTable(Element* aElement, nsIAtom* aId)
|
||||||
{
|
{
|
||||||
nsIdentifierMapEntry *entry =
|
nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aId);
|
||||||
mIdentifierMap.GetEntry(nsDependentAtomString(aId));
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
entry->RemoveIdElement(aElement);
|
entry->RemoveIdElement(aElement);
|
||||||
if (entry->IsEmpty()) {
|
if (entry->IsEmpty()) {
|
||||||
|
|
@ -339,12 +307,6 @@ ShadowRoot::RemoveFromIdTable(Element* aElement, nsIAtom* aId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsContentList>
|
|
||||||
ShadowRoot::GetElementsByClassName(const nsAString& aClasses)
|
|
||||||
{
|
|
||||||
return nsContentUtils::GetElementsByClassName(this, aClasses);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
ShadowRoot::GetEventTargetParent(EventChainPreVisitor& aVisitor)
|
ShadowRoot::GetEventTargetParent(EventChainPreVisitor& aVisitor)
|
||||||
{
|
{
|
||||||
|
|
@ -499,6 +461,12 @@ ShadowRoot::DistributeAllNodes()
|
||||||
DistributionChanged();
|
DistributionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Element*
|
||||||
|
ShadowRoot::GetActiveElement()
|
||||||
|
{
|
||||||
|
return GetRetargetedFocusedElement();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShadowRoot::GetInnerHTML(nsAString& aInnerHTML)
|
ShadowRoot::GetInnerHTML(nsAString& aInnerHTML)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#define mozilla_dom_shadowroot_h__
|
#define mozilla_dom_shadowroot_h__
|
||||||
|
|
||||||
#include "mozilla/dom/DocumentFragment.h"
|
#include "mozilla/dom/DocumentFragment.h"
|
||||||
#include "mozilla/dom/StyleScope.h"
|
#include "mozilla/dom/DocumentOrShadowRoot.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsCycleCollectionParticipant.h"
|
#include "nsCycleCollectionParticipant.h"
|
||||||
#include "nsIContentInlines.h"
|
#include "nsIContentInlines.h"
|
||||||
|
|
@ -29,7 +29,7 @@ namespace dom {
|
||||||
class Element;
|
class Element;
|
||||||
|
|
||||||
class ShadowRoot final : public DocumentFragment,
|
class ShadowRoot final : public DocumentFragment,
|
||||||
public StyleScope,
|
public DocumentOrShadowRoot,
|
||||||
public nsStubMutationObserver
|
public nsStubMutationObserver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -57,22 +57,14 @@ public:
|
||||||
return mMode == ShadowRootMode::Closed;
|
return mMode == ShadowRootMode::Closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// StyleScope.
|
|
||||||
nsINode& AsNode() final
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// [deprecated] Shadow DOM v0
|
// [deprecated] Shadow DOM v0
|
||||||
void AddToIdTable(Element* aElement, nsIAtom* aId);
|
|
||||||
void RemoveFromIdTable(Element* aElement, nsIAtom* aId);
|
|
||||||
void InsertSheet(StyleSheet* aSheet, nsIContent* aLinkingContent);
|
void InsertSheet(StyleSheet* aSheet, nsIContent* aLinkingContent);
|
||||||
void RemoveSheet(StyleSheet* aSheet);
|
void RemoveSheet(StyleSheet* aSheet);
|
||||||
bool ApplyAuthorStyles();
|
bool ApplyAuthorStyles();
|
||||||
void SetApplyAuthorStyles(bool aApplyAuthorStyles);
|
void SetApplyAuthorStyles(bool aApplyAuthorStyles);
|
||||||
StyleSheetList* StyleSheets()
|
StyleSheetList* StyleSheets()
|
||||||
{
|
{
|
||||||
return &StyleScope::EnsureDOMStyleSheets();
|
return &DocumentOrShadowRoot::EnsureDOMStyleSheets();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -123,15 +115,13 @@ public:
|
||||||
|
|
||||||
static ShadowRoot* FromNode(nsINode* aNode);
|
static ShadowRoot* FromNode(nsINode* aNode);
|
||||||
|
|
||||||
|
void AddToIdTable(Element* aElement, nsIAtom* aId);
|
||||||
|
void RemoveFromIdTable(Element* aElement, nsIAtom* aId);
|
||||||
|
|
||||||
// WebIDL methods.
|
// WebIDL methods.
|
||||||
Element* GetElementById(const nsAString& aElementId);
|
using mozilla::dom::DocumentOrShadowRoot::GetElementById;
|
||||||
already_AddRefed<nsContentList>
|
|
||||||
GetElementsByTagName(const nsAString& aNamespaceURI);
|
Element* GetActiveElement();
|
||||||
already_AddRefed<nsContentList>
|
|
||||||
GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
|
||||||
const nsAString& aLocalName);
|
|
||||||
already_AddRefed<nsContentList>
|
|
||||||
GetElementsByClassName(const nsAString& aClasses);
|
|
||||||
void GetInnerHTML(nsAString& aInnerHTML);
|
void GetInnerHTML(nsAString& aInnerHTML);
|
||||||
void SetInnerHTML(const nsAString& aInnerHTML, ErrorResult& aError);
|
void SetInnerHTML(const nsAString& aInnerHTML, ErrorResult& aError);
|
||||||
void StyleSheetChanged();
|
void StyleSheetChanged();
|
||||||
|
|
@ -154,7 +144,6 @@ protected:
|
||||||
// are in the shadow tree and should be kept alive by its parent.
|
// are in the shadow tree and should be kept alive by its parent.
|
||||||
nsClassHashtable<nsStringHashKey, nsTArray<mozilla::dom::HTMLSlotElement*>> mSlotMap;
|
nsClassHashtable<nsStringHashKey, nsTArray<mozilla::dom::HTMLSlotElement*>> mSlotMap;
|
||||||
|
|
||||||
nsTHashtable<nsIdentifierMapEntry> mIdentifierMap;
|
|
||||||
nsXBLPrototypeBinding* mProtoBinding;
|
nsXBLPrototypeBinding* mProtoBinding;
|
||||||
|
|
||||||
// It is necessary to hold a reference to the associated nsXBLBinding
|
// It is necessary to hold a reference to the associated nsXBLBinding
|
||||||
|
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
/* -*- 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 "StyleScope.h"
|
|
||||||
#include "mozilla/dom/StyleSheetList.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
namespace dom {
|
|
||||||
|
|
||||||
StyleScope::~StyleScope()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
StyleSheetList&
|
|
||||||
StyleScope::EnsureDOMStyleSheets()
|
|
||||||
{
|
|
||||||
if (!mDOMStyleSheets) {
|
|
||||||
mDOMStyleSheets = new StyleSheetList(*this);
|
|
||||||
}
|
|
||||||
return *mDOMStyleSheets;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,81 +0,0 @@
|
||||||
/* -*- 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 mozilla_dom_StyleScope_h__
|
|
||||||
#define mozilla_dom_StyleScope_h__
|
|
||||||
|
|
||||||
#include "nsTArray.h"
|
|
||||||
|
|
||||||
class nsINode;
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
class StyleSheet;
|
|
||||||
|
|
||||||
namespace dom {
|
|
||||||
|
|
||||||
class StyleSheetList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A class meant to be shared by ShadowRoot and Document, that holds a list of
|
|
||||||
* stylesheets.
|
|
||||||
*
|
|
||||||
* TODO(emilio, bug 1418159): In the future this should hold most of the
|
|
||||||
* relevant style state, this should allow us to fix bug 548397.
|
|
||||||
*/
|
|
||||||
class StyleScope
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual nsINode& AsNode() = 0;
|
|
||||||
|
|
||||||
const nsINode& AsNode() const
|
|
||||||
{
|
|
||||||
return const_cast<StyleScope&>(*this).AsNode();
|
|
||||||
}
|
|
||||||
|
|
||||||
StyleSheet* SheetAt(size_t aIndex) const
|
|
||||||
{
|
|
||||||
return mStyleSheets.SafeElementAt(aIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t SheetCount() const
|
|
||||||
{
|
|
||||||
return mStyleSheets.Length();
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t IndexOfSheet(const StyleSheet& aSheet) const
|
|
||||||
{
|
|
||||||
return mStyleSheets.IndexOf(&aSheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InsertSheetAt(size_t aIndex, StyleSheet& aSheet)
|
|
||||||
{
|
|
||||||
mStyleSheets.InsertElementAt(aIndex, &aSheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemoveSheet(StyleSheet& aSheet)
|
|
||||||
{
|
|
||||||
mStyleSheets.RemoveElement(&aSheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppendStyleSheet(StyleSheet& aSheet)
|
|
||||||
{
|
|
||||||
mStyleSheets.AppendElement(&aSheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
StyleSheetList& EnsureDOMStyleSheets();
|
|
||||||
|
|
||||||
~StyleScope();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
nsTArray<RefPtr<mozilla::StyleSheet>> mStyleSheets;
|
|
||||||
RefPtr<mozilla::dom::StyleSheetList> mDOMStyleSheets;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -48,19 +48,19 @@ StyleSheetList::SlowItem(uint32_t aIndex, nsIDOMStyleSheet** aItem)
|
||||||
void
|
void
|
||||||
StyleSheetList::NodeWillBeDestroyed(const nsINode* aNode)
|
StyleSheetList::NodeWillBeDestroyed(const nsINode* aNode)
|
||||||
{
|
{
|
||||||
mStyleScope = nullptr;
|
mDocumentOrShadowRoot = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
StyleSheetList::StyleSheetList(StyleScope& aScope)
|
StyleSheetList::StyleSheetList(DocumentOrShadowRoot& aScope)
|
||||||
: mStyleScope(&aScope)
|
: mDocumentOrShadowRoot(&aScope)
|
||||||
{
|
{
|
||||||
mStyleScope->AsNode().AddMutationObserver(this);
|
mDocumentOrShadowRoot->AsNode().AddMutationObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
StyleSheetList::~StyleSheetList()
|
StyleSheetList::~StyleSheetList()
|
||||||
{
|
{
|
||||||
if (mStyleScope) {
|
if (mDocumentOrShadowRoot) {
|
||||||
mStyleScope->AsNode().RemoveMutationObserver(this);
|
mDocumentOrShadowRoot->AsNode().RemoveMutationObserver(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#ifndef mozilla_dom_StyleSheetList_h
|
#ifndef mozilla_dom_StyleSheetList_h
|
||||||
#define mozilla_dom_StyleSheetList_h
|
#define mozilla_dom_StyleSheetList_h
|
||||||
|
|
||||||
#include "mozilla/dom/StyleScope.h"
|
#include "mozilla/dom/DocumentOrShadowRoot.h"
|
||||||
#include "nsIDOMStyleSheetList.h"
|
#include "nsIDOMStyleSheetList.h"
|
||||||
#include "nsWrapperCache.h"
|
#include "nsWrapperCache.h"
|
||||||
#include "nsStubDocumentObserver.h"
|
#include "nsStubDocumentObserver.h"
|
||||||
|
|
@ -31,28 +31,28 @@ public:
|
||||||
|
|
||||||
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
|
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
|
||||||
|
|
||||||
explicit StyleSheetList(StyleScope& aScope);
|
explicit StyleSheetList(DocumentOrShadowRoot& aScope);
|
||||||
|
|
||||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override final;
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override final;
|
||||||
|
|
||||||
nsINode* GetParentObject() const
|
nsINode* GetParentObject() const
|
||||||
{
|
{
|
||||||
return mStyleScope ? &mStyleScope->AsNode() : nullptr;
|
return mDocumentOrShadowRoot ? &mDocumentOrShadowRoot->AsNode() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Length() const
|
uint32_t Length() const
|
||||||
{
|
{
|
||||||
return mStyleScope ? mStyleScope->SheetCount() : 0;
|
return mDocumentOrShadowRoot ? mDocumentOrShadowRoot->SheetCount() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
StyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) const
|
StyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) const
|
||||||
{
|
{
|
||||||
if (!mStyleScope) {
|
if (!mDocumentOrShadowRoot) {
|
||||||
aFound = false;
|
aFound = false;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
StyleSheet* sheet = mStyleScope->SheetAt(aIndex);
|
StyleSheet* sheet = mDocumentOrShadowRoot->SheetAt(aIndex);
|
||||||
aFound = !!sheet;
|
aFound = !!sheet;
|
||||||
return sheet;
|
return sheet;
|
||||||
}
|
}
|
||||||
|
|
@ -66,7 +66,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual ~StyleSheetList();
|
virtual ~StyleSheetList();
|
||||||
|
|
||||||
StyleScope* mStyleScope; // Weak, cleared on "NodeWillBeDestroyed".
|
DocumentOrShadowRoot* mDocumentOrShadowRoot; // Weak, cleared on "NodeWillBeDestroyed".
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,7 @@ EXPORTS.mozilla.dom += [
|
||||||
'DirectionalityUtils.h',
|
'DirectionalityUtils.h',
|
||||||
'DocGroup.h',
|
'DocGroup.h',
|
||||||
'DocumentFragment.h',
|
'DocumentFragment.h',
|
||||||
|
'DocumentOrShadowRoot.h',
|
||||||
'DocumentType.h',
|
'DocumentType.h',
|
||||||
'DOMCursor.h',
|
'DOMCursor.h',
|
||||||
'DOMError.h',
|
'DOMError.h',
|
||||||
|
|
@ -214,7 +215,6 @@ EXPORTS.mozilla.dom += [
|
||||||
'SimpleTreeIterator.h',
|
'SimpleTreeIterator.h',
|
||||||
'StructuredCloneHolder.h',
|
'StructuredCloneHolder.h',
|
||||||
'StructuredCloneTags.h',
|
'StructuredCloneTags.h',
|
||||||
'StyleScope.h',
|
|
||||||
'StyleSheetList.h',
|
'StyleSheetList.h',
|
||||||
'SubtleCrypto.h',
|
'SubtleCrypto.h',
|
||||||
'TabGroup.h',
|
'TabGroup.h',
|
||||||
|
|
@ -243,6 +243,7 @@ SOURCES += [
|
||||||
'DirectionalityUtils.cpp',
|
'DirectionalityUtils.cpp',
|
||||||
'DocGroup.cpp',
|
'DocGroup.cpp',
|
||||||
'DocumentFragment.cpp',
|
'DocumentFragment.cpp',
|
||||||
|
'DocumentOrShadowRoot.cpp',
|
||||||
'DocumentType.cpp',
|
'DocumentType.cpp',
|
||||||
'DOMCursor.cpp',
|
'DOMCursor.cpp',
|
||||||
'DOMError.cpp',
|
'DOMError.cpp',
|
||||||
|
|
@ -361,7 +362,6 @@ SOURCES += [
|
||||||
'ScriptSettings.cpp',
|
'ScriptSettings.cpp',
|
||||||
'ShadowRoot.cpp',
|
'ShadowRoot.cpp',
|
||||||
'StructuredCloneHolder.cpp',
|
'StructuredCloneHolder.cpp',
|
||||||
'StyleScope.cpp',
|
|
||||||
'StyleSheetList.cpp',
|
'StyleSheetList.cpp',
|
||||||
'SubtleCrypto.cpp',
|
'SubtleCrypto.cpp',
|
||||||
'TabGroup.cpp',
|
'TabGroup.cpp',
|
||||||
|
|
|
||||||
|
|
@ -3658,6 +3658,14 @@ nsContentUtils::ReportToConsole(uint32_t aErrorFlags,
|
||||||
aLineNumber, aColumnNumber);
|
aLineNumber, aColumnNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ void
|
||||||
|
nsContentUtils::ReportEmptyGetElementByIdArg(const nsIDocument* aDoc)
|
||||||
|
{
|
||||||
|
ReportToConsole(nsIScriptError::warningFlag,
|
||||||
|
NS_LITERAL_CSTRING("DOM"), aDoc,
|
||||||
|
nsContentUtils::eDOM_PROPERTIES,
|
||||||
|
"EmptyGetElementByIdParam");
|
||||||
|
}
|
||||||
|
|
||||||
/* static */ nsresult
|
/* static */ nsresult
|
||||||
nsContentUtils::ReportToConsoleNonLocalized(const nsAString& aErrorText,
|
nsContentUtils::ReportToConsoleNonLocalized(const nsAString& aErrorText,
|
||||||
|
|
|
||||||
|
|
@ -941,6 +941,8 @@ public:
|
||||||
uint32_t aLineNumber = 0,
|
uint32_t aLineNumber = 0,
|
||||||
uint32_t aColumnNumber = 0);
|
uint32_t aColumnNumber = 0);
|
||||||
|
|
||||||
|
static void ReportEmptyGetElementByIdArg(const nsIDocument* aDoc);
|
||||||
|
|
||||||
static void LogMessageToConsole(const char* aMsg);
|
static void LogMessageToConsole(const char* aMsg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -300,9 +300,24 @@ GetHttpChannelHelper(nsIChannel* aChannel, nsIHttpChannel** aHttpChannel)
|
||||||
|
|
||||||
#define NAME_NOT_VALID ((nsSimpleContentList*)1)
|
#define NAME_NOT_VALID ((nsSimpleContentList*)1)
|
||||||
|
|
||||||
|
nsIdentifierMapEntry::nsIdentifierMapEntry(const nsIdentifierMapEntry::AtomOrString& aKey)
|
||||||
|
: mKey(aKey)
|
||||||
|
{}
|
||||||
|
|
||||||
|
nsIdentifierMapEntry::nsIdentifierMapEntry(const nsIdentifierMapEntry::AtomOrString* aKey)
|
||||||
|
: mKey(aKey ? *aKey : nullptr)
|
||||||
|
{}
|
||||||
|
|
||||||
nsIdentifierMapEntry::~nsIdentifierMapEntry()
|
nsIdentifierMapEntry::~nsIdentifierMapEntry()
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
nsIdentifierMapEntry::nsIdentifierMapEntry(nsIdentifierMapEntry&& aOther)
|
||||||
|
: mKey(mozilla::Move(aOther.mKey))
|
||||||
|
, mIdContentList(mozilla::Move(aOther.mIdContentList))
|
||||||
|
, mNameContentList(mozilla::Move(aOther.mNameContentList))
|
||||||
|
, mChangeCallbacks(mozilla::Move(aOther.mChangeCallbacks))
|
||||||
|
, mImageElement(mozilla::Move(aOther.mImageElement))
|
||||||
|
{}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsIdentifierMapEntry::Traverse(nsCycleCollectionTraversalCallback* aCallback)
|
nsIdentifierMapEntry::Traverse(nsCycleCollectionTraversalCallback* aCallback)
|
||||||
|
|
@ -326,6 +341,12 @@ nsIdentifierMapEntry::IsEmpty()
|
||||||
!mChangeCallbacks && !mImageElement;
|
!mChangeCallbacks && !mImageElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
nsIdentifierMapEntry::HasNameElement() const
|
||||||
|
{
|
||||||
|
return mNameContentList && mNameContentList->Length() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
Element*
|
Element*
|
||||||
nsIdentifierMapEntry::GetIdElement()
|
nsIdentifierMapEntry::GetIdElement()
|
||||||
{
|
{
|
||||||
|
|
@ -537,7 +558,7 @@ nsIdentifierMapEntry::HasIdElementExposedAsHTMLDocumentProperty()
|
||||||
size_t
|
size_t
|
||||||
nsIdentifierMapEntry::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
nsIdentifierMapEntry::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
||||||
{
|
{
|
||||||
return nsStringHashKey::SizeOfExcludingThis(aMallocSizeOf);
|
return mKey.mString.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper structs for the content->subdoc map
|
// Helper structs for the content->subdoc map
|
||||||
|
|
@ -1226,6 +1247,7 @@ static already_AddRefed<mozilla::dom::NodeInfo> nullNodeInfo;
|
||||||
// ==================================================================
|
// ==================================================================
|
||||||
nsIDocument::nsIDocument()
|
nsIDocument::nsIDocument()
|
||||||
: nsINode(nullNodeInfo),
|
: nsINode(nullNodeInfo),
|
||||||
|
DocumentOrShadowRoot(this),
|
||||||
mReferrerPolicySet(false),
|
mReferrerPolicySet(false),
|
||||||
mReferrerPolicy(mozilla::net::RP_Default),
|
mReferrerPolicy(mozilla::net::RP_Default),
|
||||||
mBlockAllMixedContent(false),
|
mBlockAllMixedContent(false),
|
||||||
|
|
@ -2704,8 +2726,7 @@ nsDocument::AddToNameTable(Element *aElement, nsIAtom* aName)
|
||||||
"Only put elements that need to be exposed as document['name'] in "
|
"Only put elements that need to be exposed as document['name'] in "
|
||||||
"the named table.");
|
"the named table.");
|
||||||
|
|
||||||
nsIdentifierMapEntry *entry =
|
nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aName);
|
||||||
mIdentifierMap.PutEntry(nsDependentAtomString(aName));
|
|
||||||
|
|
||||||
// Null for out-of-memory
|
// Null for out-of-memory
|
||||||
if (entry) {
|
if (entry) {
|
||||||
|
|
@ -2724,8 +2745,7 @@ nsDocument::RemoveFromNameTable(Element *aElement, nsIAtom* aName)
|
||||||
if (mIdentifierMap.Count() == 0)
|
if (mIdentifierMap.Count() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nsIdentifierMapEntry *entry =
|
nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aName);
|
||||||
mIdentifierMap.GetEntry(nsDependentAtomString(aName));
|
|
||||||
if (!entry) // Could be false if the element was anonymous, hence never added
|
if (!entry) // Could be false if the element was anonymous, hence never added
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -2739,8 +2759,7 @@ nsDocument::RemoveFromNameTable(Element *aElement, nsIAtom* aName)
|
||||||
void
|
void
|
||||||
nsDocument::AddToIdTable(Element *aElement, nsIAtom* aId)
|
nsDocument::AddToIdTable(Element *aElement, nsIAtom* aId)
|
||||||
{
|
{
|
||||||
nsIdentifierMapEntry *entry =
|
nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aId);
|
||||||
mIdentifierMap.PutEntry(nsDependentAtomString(aId));
|
|
||||||
|
|
||||||
if (entry) { /* True except on OOM */
|
if (entry) { /* True except on OOM */
|
||||||
if (nsGenericHTMLElement::ShouldExposeIdAsHTMLDocumentProperty(aElement) &&
|
if (nsGenericHTMLElement::ShouldExposeIdAsHTMLDocumentProperty(aElement) &&
|
||||||
|
|
@ -2762,8 +2781,7 @@ nsDocument::RemoveFromIdTable(Element *aElement, nsIAtom* aId)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIdentifierMapEntry *entry =
|
nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aId);
|
||||||
mIdentifierMap.GetEntry(nsDependentAtomString(aId));
|
|
||||||
if (!entry) // Can be null for XML elements with changing ids.
|
if (!entry) // Can be null for XML elements with changing ids.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -3013,20 +3031,9 @@ Element*
|
||||||
nsIDocument::GetActiveElement()
|
nsIDocument::GetActiveElement()
|
||||||
{
|
{
|
||||||
// Get the focused element.
|
// Get the focused element.
|
||||||
if (nsCOMPtr<nsPIDOMWindowOuter> window = GetWindow()) {
|
Element* focusedElement = GetRetargetedFocusedElement();
|
||||||
nsCOMPtr<nsPIDOMWindowOuter> focusedWindow;
|
if (focusedElement) {
|
||||||
nsIContent* focusedContent =
|
return focusedElement;
|
||||||
nsFocusManager::GetFocusedDescendant(window, false,
|
|
||||||
getter_AddRefs(focusedWindow));
|
|
||||||
// be safe and make sure the element is from this document
|
|
||||||
if (focusedContent && focusedContent->OwnerDoc() == this) {
|
|
||||||
if (focusedContent->ChromeOnlyAccess()) {
|
|
||||||
focusedContent = focusedContent->FindFirstNonChromeOnlyAccessContent();
|
|
||||||
}
|
|
||||||
if (focusedContent) {
|
|
||||||
return focusedContent->AsElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// No focused element anywhere in this document. Try to get the BODY.
|
// No focused element anywhere in this document. Try to get the BODY.
|
||||||
|
|
@ -3238,12 +3245,6 @@ nsDocument::GetElementsByClassName(const nsAString& aClasses,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsContentList>
|
|
||||||
nsIDocument::GetElementsByClassName(const nsAString& aClasses)
|
|
||||||
{
|
|
||||||
return nsContentUtils::GetElementsByClassName(this, aClasses);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocument::ReleaseCapture()
|
nsDocument::ReleaseCapture()
|
||||||
{
|
{
|
||||||
|
|
@ -4733,32 +4734,7 @@ nsDocument::BeginLoad()
|
||||||
void
|
void
|
||||||
nsDocument::ReportEmptyGetElementByIdArg()
|
nsDocument::ReportEmptyGetElementByIdArg()
|
||||||
{
|
{
|
||||||
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
|
nsContentUtils::ReportEmptyGetElementByIdArg(this);
|
||||||
NS_LITERAL_CSTRING("DOM"), this,
|
|
||||||
nsContentUtils::eDOM_PROPERTIES,
|
|
||||||
"EmptyGetElementByIdParam");
|
|
||||||
}
|
|
||||||
|
|
||||||
Element*
|
|
||||||
nsDocument::GetElementById(const nsAString& aElementId)
|
|
||||||
{
|
|
||||||
if (!CheckGetElementByIdArg(aElementId)) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIdentifierMapEntry *entry = mIdentifierMap.GetEntry(aElementId);
|
|
||||||
return entry ? entry->GetIdElement() : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const nsTArray<Element*>*
|
|
||||||
nsDocument::GetAllElementsForId(const nsAString& aElementId) const
|
|
||||||
{
|
|
||||||
if (aElementId.IsEmpty()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIdentifierMapEntry *entry = mIdentifierMap.GetEntry(aElementId);
|
|
||||||
return entry ? &entry->GetIdElements() : nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
@ -4783,7 +4759,7 @@ nsDocument::AddIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver,
|
||||||
if (!CheckGetElementByIdArg(id))
|
if (!CheckGetElementByIdArg(id))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
nsIdentifierMapEntry *entry = mIdentifierMap.PutEntry(id);
|
nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aID);
|
||||||
NS_ENSURE_TRUE(entry, nullptr);
|
NS_ENSURE_TRUE(entry, nullptr);
|
||||||
|
|
||||||
entry->AddContentChangeCallback(aObserver, aData, aForImage);
|
entry->AddContentChangeCallback(aObserver, aData, aForImage);
|
||||||
|
|
@ -4799,7 +4775,7 @@ nsDocument::RemoveIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver,
|
||||||
if (!CheckGetElementByIdArg(id))
|
if (!CheckGetElementByIdArg(id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nsIdentifierMapEntry *entry = mIdentifierMap.GetEntry(id);
|
nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aID);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -5650,27 +5626,6 @@ nsDocument::BlockedTrackingNodes() const
|
||||||
return list.forget();
|
return list.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsContentList>
|
|
||||||
nsIDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
|
||||||
const nsAString& aLocalName,
|
|
||||||
ErrorResult& aResult)
|
|
||||||
{
|
|
||||||
int32_t nameSpaceId = kNameSpaceID_Wildcard;
|
|
||||||
|
|
||||||
if (!aNamespaceURI.EqualsLiteral("*")) {
|
|
||||||
aResult =
|
|
||||||
nsContentUtils::NameSpaceManager()->RegisterNameSpace(aNamespaceURI,
|
|
||||||
nameSpaceId);
|
|
||||||
if (aResult.Failed()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_ASSERTION(nameSpaceId != kNameSpaceID_Unknown, "Unexpected namespace ID!");
|
|
||||||
|
|
||||||
return NS_GetContentList(this, nameSpaceId, aLocalName);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
||||||
const nsAString& aLocalName,
|
const nsAString& aLocalName,
|
||||||
|
|
@ -5678,7 +5633,7 @@ nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
||||||
{
|
{
|
||||||
ErrorResult rv;
|
ErrorResult rv;
|
||||||
RefPtr<nsContentList> list =
|
RefPtr<nsContentList> list =
|
||||||
nsIDocument::GetElementsByTagNameNS(aNamespaceURI, aLocalName, rv);
|
GetElementsByTagNameNS(aNamespaceURI, aLocalName, rv);
|
||||||
if (rv.Failed()) {
|
if (rv.Failed()) {
|
||||||
return rv.StealNSResult();
|
return rv.StealNSResult();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -333,7 +333,6 @@ class nsDocument : public nsIDocument,
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef mozilla::dom::Element Element;
|
typedef mozilla::dom::Element Element;
|
||||||
using nsIDocument::GetElementsByTagName;
|
|
||||||
typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
|
typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
|
||||||
|
|
||||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||||
|
|
@ -631,6 +630,11 @@ public:
|
||||||
// nsIDOMDocumentXBL
|
// nsIDOMDocumentXBL
|
||||||
NS_DECL_NSIDOMDOCUMENTXBL
|
NS_DECL_NSIDOMDOCUMENTXBL
|
||||||
|
|
||||||
|
using mozilla::dom::DocumentOrShadowRoot::GetElementById;
|
||||||
|
using mozilla::dom::DocumentOrShadowRoot::GetElementsByTagName;
|
||||||
|
using mozilla::dom::DocumentOrShadowRoot::GetElementsByTagNameNS;
|
||||||
|
using mozilla::dom::DocumentOrShadowRoot::GetElementsByClassName;
|
||||||
|
|
||||||
// nsIDOMEventTarget
|
// nsIDOMEventTarget
|
||||||
virtual nsresult GetEventTargetParent(
|
virtual nsresult GetEventTargetParent(
|
||||||
mozilla::EventChainPreVisitor& aVisitor) override;
|
mozilla::EventChainPreVisitor& aVisitor) override;
|
||||||
|
|
@ -819,10 +823,7 @@ public:
|
||||||
virtual void ResetScrolledToRefAlready() override;
|
virtual void ResetScrolledToRefAlready() override;
|
||||||
virtual void SetChangeScrollPosWhenScrollingToRef(bool aValue) override;
|
virtual void SetChangeScrollPosWhenScrollingToRef(bool aValue) override;
|
||||||
|
|
||||||
virtual Element *GetElementById(const nsAString& aElementId) override;
|
virtual Element* LookupImageElement(const nsAString& aElementId) override;
|
||||||
virtual const nsTArray<Element*>* GetAllElementsForId(const nsAString& aElementId) const override;
|
|
||||||
|
|
||||||
virtual Element *LookupImageElement(const nsAString& aElementId) override;
|
|
||||||
virtual void MozSetImageElement(const nsAString& aImageElementId,
|
virtual void MozSetImageElement(const nsAString& aImageElementId,
|
||||||
Element* aElement) override;
|
Element* aElement) override;
|
||||||
|
|
||||||
|
|
@ -1206,14 +1207,6 @@ public:
|
||||||
RefPtr<nsDOMStyleSheetSetList> mStyleSheetSetList;
|
RefPtr<nsDOMStyleSheetSetList> mStyleSheetSetList;
|
||||||
RefPtr<nsScriptLoader> mScriptLoader;
|
RefPtr<nsScriptLoader> mScriptLoader;
|
||||||
nsDocHeaderData* mHeaderData;
|
nsDocHeaderData* mHeaderData;
|
||||||
/* mIdentifierMap works as follows for IDs:
|
|
||||||
* 1) Attribute changes affect the table immediately (removing and adding
|
|
||||||
* entries as needed).
|
|
||||||
* 2) Removals from the DOM affect the table immediately
|
|
||||||
* 3) Additions to the DOM always update existing entries for names, and add
|
|
||||||
* new ones for IDs.
|
|
||||||
*/
|
|
||||||
nsTHashtable<nsIdentifierMapEntry> mIdentifierMap;
|
|
||||||
|
|
||||||
nsClassHashtable<nsStringHashKey, nsRadioGroupStruct> mRadioGroups;
|
nsClassHashtable<nsStringHashKey, nsRadioGroupStruct> mRadioGroups;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -813,10 +813,11 @@ nsFocusManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent)
|
||||||
if (!window)
|
if (!window)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
// if the content is currently focused in the window, or is an ancestor
|
// if the content is currently focused in the window, or is an
|
||||||
// of the currently focused element, reset the focus within that window.
|
// shadow-including inclusive ancestor of the currently focused element,
|
||||||
|
// reset the focus within that window.
|
||||||
nsIContent* content = window->GetFocusedNode();
|
nsIContent* content = window->GetFocusedNode();
|
||||||
if (content && nsContentUtils::ContentIsDescendantOf(content, aContent)) {
|
if (content && nsContentUtils::ContentIsHostIncludingDescendantOf(content, aContent)) {
|
||||||
bool shouldShowFocusRing = window->ShouldShowFocusRing();
|
bool shouldShowFocusRing = window->ShouldShowFocusRing();
|
||||||
window->SetFocusedNode(nullptr);
|
window->SetFocusedNode(nullptr);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -696,6 +696,14 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual mozilla::dom::ShadowRoot *GetContainingShadow() const = 0;
|
virtual mozilla::dom::ShadowRoot *GetContainingShadow() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the shadow host if this content is in a shadow tree. That is, the host
|
||||||
|
* of |GetContainingShadow|, if its not null.
|
||||||
|
*
|
||||||
|
* @return The shadow host, if this is in shadow tree, or null.
|
||||||
|
*/
|
||||||
|
nsIContent* GetContainingShadowHost() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the assigned slot associated with this content.
|
* Gets the assigned slot associated with this content.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
#include "prclist.h"
|
#include "prclist.h"
|
||||||
#include "mozilla/UniquePtr.h"
|
#include "mozilla/UniquePtr.h"
|
||||||
#include "mozilla/CORSMode.h"
|
#include "mozilla/CORSMode.h"
|
||||||
#include "mozilla/dom/StyleScope.h"
|
#include "mozilla/dom/DocumentOrShadowRoot.h"
|
||||||
#include "mozilla/LinkedList.h"
|
#include "mozilla/LinkedList.h"
|
||||||
#include "mozilla/StyleBackendType.h"
|
#include "mozilla/StyleBackendType.h"
|
||||||
#include "mozilla/StyleSheet.h"
|
#include "mozilla/StyleSheet.h"
|
||||||
|
|
@ -198,7 +198,7 @@ class nsContentList;
|
||||||
// Document interface. This is implemented by all document objects in
|
// Document interface. This is implemented by all document objects in
|
||||||
// Gecko.
|
// Gecko.
|
||||||
class nsIDocument : public nsINode,
|
class nsIDocument : public nsINode,
|
||||||
public mozilla::dom::StyleScope
|
public mozilla::dom::DocumentOrShadowRoot
|
||||||
{
|
{
|
||||||
typedef mozilla::dom::GlobalObject GlobalObject;
|
typedef mozilla::dom::GlobalObject GlobalObject;
|
||||||
|
|
||||||
|
|
@ -499,7 +499,7 @@ public:
|
||||||
* to remove it.
|
* to remove it.
|
||||||
*/
|
*/
|
||||||
typedef bool (* IDTargetObserver)(Element* aOldElement,
|
typedef bool (* IDTargetObserver)(Element* aOldElement,
|
||||||
Element* aNewelement, void* aData);
|
Element* aNewelement, void* aData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an IDTargetObserver for a specific ID. The IDTargetObserver
|
* Add an IDTargetObserver for a specific ID. The IDTargetObserver
|
||||||
|
|
@ -1071,14 +1071,9 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void EnsureOnDemandBuiltInUASheet(mozilla::StyleSheet* aSheet) = 0;
|
virtual void EnsureOnDemandBuiltInUASheet(mozilla::StyleSheet* aSheet) = 0;
|
||||||
|
|
||||||
nsINode& AsNode() final
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
mozilla::dom::StyleSheetList* StyleSheets()
|
mozilla::dom::StyleSheetList* StyleSheets()
|
||||||
{
|
{
|
||||||
return &StyleScope::EnsureDOMStyleSheets();
|
return &DocumentOrShadowRoot::EnsureDOMStyleSheets();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2362,19 +2357,10 @@ public:
|
||||||
virtual void ResetScrolledToRefAlready() = 0;
|
virtual void ResetScrolledToRefAlready() = 0;
|
||||||
virtual void SetChangeScrollPosWhenScrollingToRef(bool aValue) = 0;
|
virtual void SetChangeScrollPosWhenScrollingToRef(bool aValue) = 0;
|
||||||
|
|
||||||
/**
|
using mozilla::dom::DocumentOrShadowRoot::GetElementById;
|
||||||
* This method is similar to GetElementById() from nsIDOMDocument but it
|
using mozilla::dom::DocumentOrShadowRoot::GetElementsByTagName;
|
||||||
* returns a mozilla::dom::Element instead of a nsIDOMElement.
|
using mozilla::dom::DocumentOrShadowRoot::GetElementsByTagNameNS;
|
||||||
* It prevents converting nsIDOMElement to mozilla::dom::Element which is
|
using mozilla::dom::DocumentOrShadowRoot::GetElementsByClassName;
|
||||||
* already converted from mozilla::dom::Element.
|
|
||||||
*/
|
|
||||||
virtual Element* GetElementById(const nsAString& aElementId) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns _all_ the elements in this document which
|
|
||||||
* have id aElementId, if there are any. Otherwise it returns null.
|
|
||||||
*/
|
|
||||||
virtual const nsTArray<Element*>* GetAllElementsForId(const nsAString& aElementId) const = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lookup an image element using its associated ID, which is usually provided
|
* Lookup an image element using its associated ID, which is usually provided
|
||||||
|
|
@ -2574,18 +2560,6 @@ public:
|
||||||
|
|
||||||
nsIDocument* GetTopLevelContentDocument();
|
nsIDocument* GetTopLevelContentDocument();
|
||||||
|
|
||||||
already_AddRefed<nsContentList>
|
|
||||||
GetElementsByTagName(const nsAString& aTagName)
|
|
||||||
{
|
|
||||||
return NS_GetContentList(this, kNameSpaceID_Unknown, aTagName);
|
|
||||||
}
|
|
||||||
already_AddRefed<nsContentList>
|
|
||||||
GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
|
||||||
const nsAString& aLocalName,
|
|
||||||
mozilla::ErrorResult& aResult);
|
|
||||||
already_AddRefed<nsContentList>
|
|
||||||
GetElementsByClassName(const nsAString& aClasses);
|
|
||||||
// GetElementById defined above
|
|
||||||
virtual already_AddRefed<Element>
|
virtual already_AddRefed<Element>
|
||||||
CreateElement(const nsAString& aTagName,
|
CreateElement(const nsAString& aTagName,
|
||||||
const mozilla::dom::ElementCreationOptionsOrString& aOptions,
|
const mozilla::dom::ElementCreationOptionsOrString& aOptions,
|
||||||
|
|
|
||||||
|
|
@ -15,18 +15,24 @@
|
||||||
|
|
||||||
#include "mozilla/MemoryReporting.h"
|
#include "mozilla/MemoryReporting.h"
|
||||||
#include "mozilla/Move.h"
|
#include "mozilla/Move.h"
|
||||||
#include "mozilla/dom/Element.h"
|
|
||||||
#include "mozilla/net/ReferrerPolicy.h"
|
#include "mozilla/net/ReferrerPolicy.h"
|
||||||
|
|
||||||
#include "nsCOMArray.h"
|
#include "nsCOMArray.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsContentList.h"
|
|
||||||
#include "nsIAtom.h"
|
#include "nsIAtom.h"
|
||||||
#include "nsIDocument.h"
|
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include "nsTHashtable.h"
|
#include "nsTHashtable.h"
|
||||||
|
#include "nsHashKeys.h"
|
||||||
|
|
||||||
class nsIContent;
|
class nsIContent;
|
||||||
|
class nsContentList;
|
||||||
|
class nsBaseContentList;
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
class Element;
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Right now our identifier map entries contain information for 'name'
|
* Right now our identifier map entries contain information for 'name'
|
||||||
|
|
@ -40,36 +46,92 @@ class nsIContent;
|
||||||
* Perhaps the document.all results should have their own hashtable
|
* Perhaps the document.all results should have their own hashtable
|
||||||
* in nsHTMLDocument.
|
* in nsHTMLDocument.
|
||||||
*/
|
*/
|
||||||
class nsIdentifierMapEntry : public nsStringHashKey
|
class nsIdentifierMapEntry : public PLDHashEntryHdr
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
typedef mozilla::dom::Element Element;
|
typedef mozilla::dom::Element Element;
|
||||||
typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
|
typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
|
||||||
|
|
||||||
explicit nsIdentifierMapEntry(const nsAString& aKey) :
|
/**
|
||||||
nsStringHashKey(&aKey), mNameContentList(nullptr)
|
* @see nsIDocument::IDTargetObserver, this is just here to avoid include
|
||||||
|
* hell.
|
||||||
|
*/
|
||||||
|
typedef bool (* IDTargetObserver)(Element* aOldElement,
|
||||||
|
Element* aNewelement, void* aData);
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct AtomOrString
|
||||||
{
|
{
|
||||||
}
|
MOZ_IMPLICIT AtomOrString(nsIAtom* aAtom) : mAtom(aAtom) {}
|
||||||
explicit nsIdentifierMapEntry(const nsAString* aKey) :
|
MOZ_IMPLICIT AtomOrString(const nsAString& aString) : mString(aString) {}
|
||||||
nsStringHashKey(aKey), mNameContentList(nullptr)
|
AtomOrString(const AtomOrString& aOther)
|
||||||
{
|
: mAtom(aOther.mAtom)
|
||||||
}
|
, mString(aOther.mString)
|
||||||
nsIdentifierMapEntry(const nsIdentifierMapEntry& aOther) :
|
{
|
||||||
nsStringHashKey(&aOther.GetKey())
|
}
|
||||||
{
|
|
||||||
NS_ERROR("Should never be called");
|
AtomOrString(AtomOrString&& aOther)
|
||||||
}
|
: mAtom(aOther.mAtom.forget())
|
||||||
|
, mString(aOther.mString)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIAtom> mAtom;
|
||||||
|
const nsString mString;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef const AtomOrString& KeyType;
|
||||||
|
typedef const AtomOrString* KeyTypePointer;
|
||||||
|
|
||||||
|
explicit nsIdentifierMapEntry(const AtomOrString& aKey);
|
||||||
|
explicit nsIdentifierMapEntry(const AtomOrString* aKey);
|
||||||
|
nsIdentifierMapEntry(nsIdentifierMapEntry&& aOther);
|
||||||
~nsIdentifierMapEntry();
|
~nsIdentifierMapEntry();
|
||||||
|
|
||||||
|
KeyType GetKey() const { return mKey; }
|
||||||
|
|
||||||
|
nsString GetKeyAsString() const
|
||||||
|
{
|
||||||
|
if (mKey.mAtom) {
|
||||||
|
return nsAtomString(mKey.mAtom);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mKey.mString;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KeyEquals(const KeyTypePointer aOtherKey) const
|
||||||
|
{
|
||||||
|
if (mKey.mAtom) {
|
||||||
|
if (aOtherKey->mAtom) {
|
||||||
|
return mKey.mAtom == aOtherKey->mAtom;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mKey.mAtom->Equals(aOtherKey->mString);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aOtherKey->mAtom) {
|
||||||
|
return aOtherKey->mAtom->Equals(mKey.mString);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mKey.mString.Equals(aOtherKey->mString);
|
||||||
|
}
|
||||||
|
|
||||||
|
static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
|
||||||
|
|
||||||
|
static PLDHashNumber HashKey(const KeyTypePointer aKey)
|
||||||
|
{
|
||||||
|
return aKey->mAtom ?
|
||||||
|
aKey->mAtom->hash() : mozilla::HashString(aKey->mString);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum { ALLOW_MEMMOVE = false };
|
||||||
|
|
||||||
void AddNameElement(nsINode* aDocument, Element* aElement);
|
void AddNameElement(nsINode* aDocument, Element* aElement);
|
||||||
void RemoveNameElement(Element* aElement);
|
void RemoveNameElement(Element* aElement);
|
||||||
bool IsEmpty();
|
bool IsEmpty();
|
||||||
nsBaseContentList* GetNameContentList() {
|
nsBaseContentList* GetNameContentList() {
|
||||||
return mNameContentList;
|
return mNameContentList;
|
||||||
}
|
}
|
||||||
bool HasNameElement() const {
|
bool HasNameElement() const;
|
||||||
return mNameContentList && mNameContentList->Length() != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the element if we know the element associated with this
|
* Returns the element if we know the element associated with this
|
||||||
|
|
@ -109,9 +171,9 @@ public:
|
||||||
bool HasIdElementExposedAsHTMLDocumentProperty();
|
bool HasIdElementExposedAsHTMLDocumentProperty();
|
||||||
|
|
||||||
bool HasContentChangeCallback() { return mChangeCallbacks != nullptr; }
|
bool HasContentChangeCallback() { return mChangeCallbacks != nullptr; }
|
||||||
void AddContentChangeCallback(nsIDocument::IDTargetObserver aCallback,
|
void AddContentChangeCallback(IDTargetObserver aCallback,
|
||||||
void* aData, bool aForImage);
|
void* aData, bool aForImage);
|
||||||
void RemoveContentChangeCallback(nsIDocument::IDTargetObserver aCallback,
|
void RemoveContentChangeCallback(IDTargetObserver aCallback,
|
||||||
void* aData, bool aForImage);
|
void* aData, bool aForImage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -122,7 +184,7 @@ public:
|
||||||
void Traverse(nsCycleCollectionTraversalCallback* aCallback);
|
void Traverse(nsCycleCollectionTraversalCallback* aCallback);
|
||||||
|
|
||||||
struct ChangeCallback {
|
struct ChangeCallback {
|
||||||
nsIDocument::IDTargetObserver mCallback;
|
IDTargetObserver mCallback;
|
||||||
void* mData;
|
void* mData;
|
||||||
bool mForImage;
|
bool mForImage;
|
||||||
};
|
};
|
||||||
|
|
@ -156,12 +218,16 @@ public:
|
||||||
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
nsIdentifierMapEntry(const nsIdentifierMapEntry& aOther) = delete;
|
||||||
|
nsIdentifierMapEntry& operator=(const nsIdentifierMapEntry& aOther) = delete;
|
||||||
|
|
||||||
void FireChangeCallbacks(Element* aOldElement, Element* aNewElement,
|
void FireChangeCallbacks(Element* aOldElement, Element* aNewElement,
|
||||||
bool aImageOnly = false);
|
bool aImageOnly = false);
|
||||||
|
|
||||||
|
AtomOrString mKey;
|
||||||
// empty if there are no elements with this ID.
|
// empty if there are no elements with this ID.
|
||||||
// The elements are stored as weak pointers.
|
// The elements are stored as weak pointers.
|
||||||
nsTArray<Element*> mIdContentList;
|
AutoTArray<Element*, 1> mIdContentList;
|
||||||
RefPtr<nsBaseContentList> mNameContentList;
|
RefPtr<nsBaseContentList> mNameContentList;
|
||||||
nsAutoPtr<nsTHashtable<ChangeCallbackEntry> > mChangeCallbacks;
|
nsAutoPtr<nsTHashtable<ChangeCallbackEntry> > mChangeCallbacks;
|
||||||
RefPtr<Element> mImageElement;
|
RefPtr<Element> mImageElement;
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,13 @@
|
||||||
#include "nsDataHashtable.h"
|
#include "nsDataHashtable.h"
|
||||||
#include "nsHashKeys.h"
|
#include "nsHashKeys.h"
|
||||||
#include "nsIAtom.h"
|
#include "nsIAtom.h"
|
||||||
#include "nsIDocument.h"
|
|
||||||
#include "nsIObserver.h"
|
#include "nsIObserver.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
|
|
||||||
#include "mozilla/StaticPtr.h"
|
#include "mozilla/StaticPtr.h"
|
||||||
|
|
||||||
class nsAString;
|
class nsAString;
|
||||||
|
class nsIDocument;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Name Space Manager tracks the association between a NameSpace
|
* The Name Space Manager tracks the association between a NameSpace
|
||||||
|
|
|
||||||
|
|
@ -2094,7 +2094,7 @@ nsHTMLDocument::GetSupportedNames(nsTArray<nsString>& aNames)
|
||||||
nsIdentifierMapEntry* entry = iter.Get();
|
nsIdentifierMapEntry* entry = iter.Get();
|
||||||
if (entry->HasNameElement() ||
|
if (entry->HasNameElement() ||
|
||||||
entry->HasIdElementExposedAsHTMLDocumentProperty()) {
|
entry->HasIdElementExposedAsHTMLDocumentProperty()) {
|
||||||
aNames.AppendElement(entry->GetKey());
|
aNames.AppendElement(entry->GetKeyAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -155,10 +155,7 @@ public:
|
||||||
|
|
||||||
virtual void RemovedFromDocShell() override;
|
virtual void RemovedFromDocShell() override;
|
||||||
|
|
||||||
virtual mozilla::dom::Element *GetElementById(const nsAString& aElementId) override
|
using mozilla::dom::DocumentOrShadowRoot::GetElementById;
|
||||||
{
|
|
||||||
return nsDocument::GetElementById(aElementId);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const override;
|
virtual void DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const override;
|
||||||
// DocAddSizeOfIncludingThis is inherited from nsIDocument.
|
// DocAddSizeOfIncludingThis is inherited from nsIDocument.
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,6 @@ partial interface Document {
|
||||||
// user interaction
|
// user interaction
|
||||||
[Pure]
|
[Pure]
|
||||||
readonly attribute WindowProxy? defaultView;
|
readonly attribute WindowProxy? defaultView;
|
||||||
readonly attribute Element? activeElement;
|
|
||||||
[Throws]
|
[Throws]
|
||||||
boolean hasFocus();
|
boolean hasFocus();
|
||||||
//(HTML only) attribute DOMString designMode;
|
//(HTML only) attribute DOMString designMode;
|
||||||
|
|
@ -283,8 +282,6 @@ partial interface Document {
|
||||||
|
|
||||||
// http://dev.w3.org/csswg/cssom/#extensions-to-the-document-interface
|
// http://dev.w3.org/csswg/cssom/#extensions-to-the-document-interface
|
||||||
partial interface Document {
|
partial interface Document {
|
||||||
[Constant]
|
|
||||||
readonly attribute StyleSheetList styleSheets;
|
|
||||||
attribute DOMString? selectedStyleSheetSet;
|
attribute DOMString? selectedStyleSheetSet;
|
||||||
readonly attribute DOMString? lastStyleSheetSet;
|
readonly attribute DOMString? lastStyleSheetSet;
|
||||||
readonly attribute DOMString? preferredStyleSheetSet;
|
readonly attribute DOMString? preferredStyleSheetSet;
|
||||||
|
|
@ -456,3 +453,4 @@ Document implements ParentNode;
|
||||||
Document implements OnErrorEventHandlerForNodes;
|
Document implements OnErrorEventHandlerForNodes;
|
||||||
Document implements GeometryUtils;
|
Document implements GeometryUtils;
|
||||||
Document implements FontFaceSource;
|
Document implements FontFaceSource;
|
||||||
|
Document implements DocumentOrShadowRoot;
|
||||||
|
|
|
||||||
29
dom/webidl/DocumentOrShadowRoot.webidl
Normal file
29
dom/webidl/DocumentOrShadowRoot.webidl
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
/* -*- 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://dom.spec.whatwg.org/#documentorshadowroot
|
||||||
|
* http://w3c.github.io/webcomponents/spec/shadow/#extensions-to-the-documentorshadowroot-mixin
|
||||||
|
*/
|
||||||
|
|
||||||
|
[NoInterfaceObject]
|
||||||
|
interface DocumentOrShadowRoot {
|
||||||
|
// Not implemented yet: bug 1430308.
|
||||||
|
// Selection? getSelection();
|
||||||
|
// Not implemented yet: bug 1430301.
|
||||||
|
// Element? elementFromPoint (float x, float y);
|
||||||
|
// Not implemented yet: bug 1430301.
|
||||||
|
// sequence<Element> elementsFromPoint (float x, float y);
|
||||||
|
// Not implemented yet: bug 1430307.
|
||||||
|
// CaretPosition? caretPositionFromPoint (float x, float y);
|
||||||
|
|
||||||
|
readonly attribute Element? activeElement;
|
||||||
|
readonly attribute StyleSheetList styleSheets;
|
||||||
|
|
||||||
|
// Not implemented yet: bug 1430303.
|
||||||
|
// readonly attribute Element? pointerLockElement;
|
||||||
|
// Not implemented yet: bug 1430305.
|
||||||
|
// readonly attribute Element? fullscreenElement;
|
||||||
|
};
|
||||||
|
|
@ -32,6 +32,5 @@ interface ShadowRoot : DocumentFragment
|
||||||
[CEReactions, SetterThrows, TreatNullAs=EmptyString]
|
[CEReactions, SetterThrows, TreatNullAs=EmptyString]
|
||||||
attribute DOMString innerHTML;
|
attribute DOMString innerHTML;
|
||||||
attribute boolean applyAuthorStyles;
|
attribute boolean applyAuthorStyles;
|
||||||
readonly attribute StyleSheetList styleSheets;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ WEBIDL_FILES = [
|
||||||
'Directory.webidl',
|
'Directory.webidl',
|
||||||
'Document.webidl',
|
'Document.webidl',
|
||||||
'DocumentFragment.webidl',
|
'DocumentFragment.webidl',
|
||||||
|
'DocumentOrShadowRoot.webidl',
|
||||||
'DocumentTimeline.webidl',
|
'DocumentTimeline.webidl',
|
||||||
'DocumentType.webidl',
|
'DocumentType.webidl',
|
||||||
'DOMCursor.webidl',
|
'DOMCursor.webidl',
|
||||||
|
|
|
||||||
|
|
@ -1578,24 +1578,13 @@ XULDocument::GetCommandDispatcher(nsIDOMXULCommandDispatcher** aTracker)
|
||||||
}
|
}
|
||||||
|
|
||||||
Element*
|
Element*
|
||||||
XULDocument::GetElementById(const nsAString& aId)
|
XULDocument::GetRefById(const nsAString& aID)
|
||||||
{
|
{
|
||||||
if (!CheckGetElementByIdArg(aId))
|
if (nsRefMapEntry* refEntry = mRefMap.GetEntry(aID)) {
|
||||||
return nullptr;
|
MOZ_ASSERT(refEntry->GetFirstElement());
|
||||||
|
|
||||||
nsIdentifierMapEntry *entry = mIdentifierMap.GetEntry(aId);
|
|
||||||
if (entry) {
|
|
||||||
Element* element = entry->GetIdElement();
|
|
||||||
if (element)
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsRefMapEntry* refEntry = mRefMap.GetEntry(aId);
|
|
||||||
if (refEntry) {
|
|
||||||
NS_ASSERTION(refEntry->GetFirstElement(),
|
|
||||||
"nsRefMapEntries should have nonempty content lists");
|
|
||||||
return refEntry->GetFirstElement();
|
return refEntry->GetFirstElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,7 @@ public:
|
||||||
using nsDocument::CreateElementNS;
|
using nsDocument::CreateElementNS;
|
||||||
NS_FORWARD_NSIDOMDOCUMENT(XMLDocument::)
|
NS_FORWARD_NSIDOMDOCUMENT(XMLDocument::)
|
||||||
// And explicitly import the things from nsDocument that we just shadowed
|
// And explicitly import the things from nsDocument that we just shadowed
|
||||||
|
using mozilla::dom::DocumentOrShadowRoot::GetElementById;
|
||||||
using nsDocument::GetImplementation;
|
using nsDocument::GetImplementation;
|
||||||
using nsDocument::GetTitle;
|
using nsDocument::GetTitle;
|
||||||
using nsDocument::SetTitle;
|
using nsDocument::SetTitle;
|
||||||
|
|
@ -156,8 +157,8 @@ public:
|
||||||
using nsDocument::GetMozFullScreenElement;
|
using nsDocument::GetMozFullScreenElement;
|
||||||
using nsIDocument::GetLocation;
|
using nsIDocument::GetLocation;
|
||||||
|
|
||||||
// nsDocument interface overrides
|
// Helper for StyleScope::GetElementById.
|
||||||
virtual Element* GetElementById(const nsAString & elementId) override;
|
Element* GetRefById(const nsAString & elementId);
|
||||||
|
|
||||||
// nsIDOMXULDocument interface
|
// nsIDOMXULDocument interface
|
||||||
NS_DECL_NSIDOMXULDOCUMENT
|
NS_DECL_NSIDOMXULDOCUMENT
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,119 @@ namespace dom {
|
||||||
class Selection;
|
class Selection;
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* EditActionResult is useful to return multiple results of an editor
|
||||||
|
* action handler without out params.
|
||||||
|
* Note that when you return an anonymous instance from a method, you should
|
||||||
|
* use EditActionIgnored(), EditActionHandled() or EditActionCanceled() for
|
||||||
|
* easier to read. In other words, EditActionResult should be used when
|
||||||
|
* declaring return type of a method, being an argument or defined as a local
|
||||||
|
* variable.
|
||||||
|
*/
|
||||||
|
class MOZ_STACK_CLASS EditActionResult final
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool Succeeded() const { return NS_SUCCEEDED(mRv); }
|
||||||
|
bool Failed() const { return NS_FAILED(mRv); }
|
||||||
|
nsresult Rv() const { return mRv; }
|
||||||
|
bool Canceled() const { return mCanceled; }
|
||||||
|
bool Handled() const { return mHandled; }
|
||||||
|
|
||||||
|
EditActionResult SetResult(nsresult aRv)
|
||||||
|
{
|
||||||
|
mRv = aRv;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
EditActionResult MarkAsCanceled()
|
||||||
|
{
|
||||||
|
mCanceled = true;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
EditActionResult MarkAsHandled()
|
||||||
|
{
|
||||||
|
mHandled = true;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit EditActionResult(nsresult aRv)
|
||||||
|
: mRv(aRv)
|
||||||
|
, mCanceled(false)
|
||||||
|
, mHandled(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
EditActionResult& operator|=(const EditActionResult& aOther)
|
||||||
|
{
|
||||||
|
mCanceled |= aOther.mCanceled;
|
||||||
|
mHandled |= aOther.mHandled;
|
||||||
|
// When both result are same, keep the result.
|
||||||
|
if (mRv == aOther.mRv) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
// If one of the results is error, use NS_ERROR_FAILURE.
|
||||||
|
if (Failed() || aOther.Failed()) {
|
||||||
|
mRv = NS_ERROR_FAILURE;
|
||||||
|
} else {
|
||||||
|
// Otherwise, use generic success code, NS_OK.
|
||||||
|
mRv = NS_OK;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
nsresult mRv;
|
||||||
|
bool mCanceled;
|
||||||
|
bool mHandled;
|
||||||
|
|
||||||
|
EditActionResult(nsresult aRv, bool aCanceled, bool aHandled)
|
||||||
|
: mRv(aRv)
|
||||||
|
, mCanceled(aCanceled)
|
||||||
|
, mHandled(aHandled)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
EditActionResult()
|
||||||
|
: mRv(NS_ERROR_NOT_INITIALIZED)
|
||||||
|
, mCanceled(false)
|
||||||
|
, mHandled(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
friend EditActionResult EditActionIgnored(nsresult aRv);
|
||||||
|
friend EditActionResult EditActionHandled(nsresult aRv);
|
||||||
|
friend EditActionResult EditActionCanceled(nsresult aRv);
|
||||||
|
};
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* When an edit action handler (or its helper) does nothing,
|
||||||
|
* EditActionIgnored should be returned.
|
||||||
|
*/
|
||||||
|
inline EditActionResult
|
||||||
|
EditActionIgnored(nsresult aRv = NS_OK)
|
||||||
|
{
|
||||||
|
return EditActionResult(aRv, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* When an edit action handler (or its helper) handled and not canceled,
|
||||||
|
* EditActionHandled should be returned.
|
||||||
|
*/
|
||||||
|
inline EditActionResult
|
||||||
|
EditActionHandled(nsresult aRv = NS_OK)
|
||||||
|
{
|
||||||
|
return EditActionResult(aRv, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* When an edit action handler (or its helper) handled and canceled,
|
||||||
|
* EditActionHandled should be returned.
|
||||||
|
*/
|
||||||
|
inline EditActionResult
|
||||||
|
EditActionCanceled(nsresult aRv = NS_OK)
|
||||||
|
{
|
||||||
|
return EditActionResult(aRv, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* stack based helper class for batching a collection of txns inside a
|
* stack based helper class for batching a collection of txns inside a
|
||||||
* placeholder txn.
|
* placeholder txn.
|
||||||
|
|
|
||||||
|
|
@ -1844,10 +1844,10 @@ HTMLEditRules::WillDeleteSelection(Selection* aSelection,
|
||||||
|
|
||||||
// origCollapsed is used later to determine whether we should join blocks. We
|
// origCollapsed is used later to determine whether we should join blocks. We
|
||||||
// don't really care about bCollapsed because it will be modified by
|
// don't really care about bCollapsed because it will be modified by
|
||||||
// ExtendSelectionForDelete later. JoinBlocks should happen if the original
|
// ExtendSelectionForDelete later. TryToJoinBlocks() should happen if the
|
||||||
// selection is collapsed and the cursor is at the end of a block element, in
|
// original selection is collapsed and the cursor is at the end of a block
|
||||||
// which case ExtendSelectionForDelete would always make the selection not
|
// element, in which case ExtendSelectionForDelete would always make the
|
||||||
// collapsed.
|
// selection not collapsed.
|
||||||
bool bCollapsed = aSelection->Collapsed();
|
bool bCollapsed = aSelection->Collapsed();
|
||||||
bool join = false;
|
bool join = false;
|
||||||
bool origCollapsed = bCollapsed;
|
bool origCollapsed = bCollapsed;
|
||||||
|
|
@ -2196,11 +2196,28 @@ HTMLEditRules::WillDeleteSelection(Selection* aSelection,
|
||||||
address_of(selPointNode), &selPointOffset);
|
address_of(selPointNode), &selPointOffset);
|
||||||
NS_ENSURE_STATE(leftNode && leftNode->IsContent() &&
|
NS_ENSURE_STATE(leftNode && leftNode->IsContent() &&
|
||||||
rightNode && rightNode->IsContent());
|
rightNode && rightNode->IsContent());
|
||||||
*aHandled = true;
|
EditActionResult ret =
|
||||||
rv = JoinBlocks(*leftNode->AsContent(), *rightNode->AsContent(),
|
TryToJoinBlocks(*leftNode->AsContent(), *rightNode->AsContent());
|
||||||
aCancel);
|
*aHandled |= ret.Handled();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
*aCancel |= ret.Canceled();
|
||||||
|
if (NS_WARN_IF(ret.Failed())) {
|
||||||
|
return ret.Rv();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If TryToJoinBlocks() didn't handle it and it's not canceled,
|
||||||
|
// user may want to modify the start leaf node or the last leaf node
|
||||||
|
// of the block.
|
||||||
|
if (!*aHandled && !*aCancel && leafNode != startNode) {
|
||||||
|
int32_t offset =
|
||||||
|
aAction == nsIEditor::ePrevious ?
|
||||||
|
static_cast<int32_t>(leafNode->Length()) : 0;
|
||||||
|
aSelection->Collapse(leafNode, offset);
|
||||||
|
return WillDeleteSelection(aSelection, aAction, aStripWrappers,
|
||||||
|
aCancel, aHandled);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, we must have deleted the selection as user expected.
|
||||||
aSelection->Collapse(selPointNode, selPointOffset);
|
aSelection->Collapse(selPointNode, selPointOffset);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -2247,10 +2264,16 @@ HTMLEditRules::WillDeleteSelection(Selection* aSelection,
|
||||||
AutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater,
|
AutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater,
|
||||||
address_of(selPointNode), &selPointOffset);
|
address_of(selPointNode), &selPointOffset);
|
||||||
NS_ENSURE_STATE(leftNode->IsContent() && rightNode->IsContent());
|
NS_ENSURE_STATE(leftNode->IsContent() && rightNode->IsContent());
|
||||||
|
EditActionResult ret =
|
||||||
|
TryToJoinBlocks(*leftNode->AsContent(), *rightNode->AsContent());
|
||||||
|
// This should claim that trying to join the block means that
|
||||||
|
// this handles the action because the caller shouldn't do anything
|
||||||
|
// anymore in this case.
|
||||||
*aHandled = true;
|
*aHandled = true;
|
||||||
rv = JoinBlocks(*leftNode->AsContent(), *rightNode->AsContent(),
|
*aCancel |= ret.Canceled();
|
||||||
aCancel);
|
if (NS_WARN_IF(ret.Failed())) {
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
return ret.Rv();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
aSelection->Collapse(selPointNode, selPointOffset);
|
aSelection->Collapse(selPointNode, selPointOffset);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
@ -2421,8 +2444,12 @@ HTMLEditRules::WillDeleteSelection(Selection* aSelection,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (join) {
|
if (join) {
|
||||||
rv = JoinBlocks(*leftParent, *rightParent, aCancel);
|
EditActionResult ret = TryToJoinBlocks(*leftParent, *rightParent);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
MOZ_ASSERT(*aHandled);
|
||||||
|
*aCancel |= ret.Canceled();
|
||||||
|
if (NS_WARN_IF(ret.Failed())) {
|
||||||
|
return ret.Rv();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2571,60 +2598,58 @@ HTMLEditRules::GetGoodSelPointForNode(nsINode& aNode,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditActionResult
|
||||||
/**
|
HTMLEditRules::TryToJoinBlocks(nsIContent& aLeftNode,
|
||||||
* This method is used to join two block elements. The right element is always
|
nsIContent& aRightNode)
|
||||||
* joined to the left element. If the elements are the same type and not
|
|
||||||
* nested within each other, JoinNodesSmart is called (example, joining two
|
|
||||||
* list items together into one). If the elements are not the same type, or
|
|
||||||
* one is a descendant of the other, we instead destroy the right block placing
|
|
||||||
* its children into leftblock. DTD containment rules are followed throughout.
|
|
||||||
*/
|
|
||||||
nsresult
|
|
||||||
HTMLEditRules::JoinBlocks(nsIContent& aLeftNode,
|
|
||||||
nsIContent& aRightNode,
|
|
||||||
bool* aCanceled)
|
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aCanceled);
|
if (NS_WARN_IF(!mHTMLEditor)) {
|
||||||
|
return EditActionIgnored(NS_ERROR_UNEXPECTED);
|
||||||
|
}
|
||||||
|
|
||||||
NS_ENSURE_STATE(mHTMLEditor);
|
|
||||||
RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
|
RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
|
||||||
|
|
||||||
nsCOMPtr<Element> leftBlock = htmlEditor->GetBlock(aLeftNode);
|
nsCOMPtr<Element> leftBlock = htmlEditor->GetBlock(aLeftNode);
|
||||||
nsCOMPtr<Element> rightBlock = htmlEditor->GetBlock(aRightNode);
|
nsCOMPtr<Element> rightBlock = htmlEditor->GetBlock(aRightNode);
|
||||||
|
|
||||||
// Sanity checks
|
// Sanity checks
|
||||||
NS_ENSURE_TRUE(leftBlock && rightBlock, NS_ERROR_NULL_POINTER);
|
if (NS_WARN_IF(!leftBlock) || NS_WARN_IF(!rightBlock)) {
|
||||||
NS_ENSURE_STATE(leftBlock != rightBlock);
|
return EditActionIgnored(NS_ERROR_NULL_POINTER);
|
||||||
|
}
|
||||||
|
if (NS_WARN_IF(leftBlock == rightBlock)) {
|
||||||
|
return EditActionIgnored(NS_ERROR_UNEXPECTED);
|
||||||
|
}
|
||||||
|
|
||||||
if (HTMLEditUtils::IsTableElement(leftBlock) ||
|
if (HTMLEditUtils::IsTableElement(leftBlock) ||
|
||||||
HTMLEditUtils::IsTableElement(rightBlock)) {
|
HTMLEditUtils::IsTableElement(rightBlock)) {
|
||||||
// Do not try to merge table elements
|
// Do not try to merge table elements
|
||||||
*aCanceled = true;
|
return EditActionCanceled();
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we don't try to move things into HR's, which look like blocks
|
// Make sure we don't try to move things into HR's, which look like blocks
|
||||||
// but aren't containers
|
// but aren't containers
|
||||||
if (leftBlock->IsHTMLElement(nsGkAtoms::hr)) {
|
if (leftBlock->IsHTMLElement(nsGkAtoms::hr)) {
|
||||||
leftBlock = htmlEditor->GetBlockNodeParent(leftBlock);
|
leftBlock = htmlEditor->GetBlockNodeParent(leftBlock);
|
||||||
|
if (NS_WARN_IF(!leftBlock)) {
|
||||||
|
return EditActionIgnored(NS_ERROR_UNEXPECTED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (rightBlock->IsHTMLElement(nsGkAtoms::hr)) {
|
if (rightBlock->IsHTMLElement(nsGkAtoms::hr)) {
|
||||||
rightBlock = htmlEditor->GetBlockNodeParent(rightBlock);
|
rightBlock = htmlEditor->GetBlockNodeParent(rightBlock);
|
||||||
|
if (NS_WARN_IF(!rightBlock)) {
|
||||||
|
return EditActionIgnored(NS_ERROR_UNEXPECTED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
NS_ENSURE_STATE(leftBlock && rightBlock);
|
|
||||||
|
|
||||||
// Bail if both blocks the same
|
// Bail if both blocks the same
|
||||||
if (leftBlock == rightBlock) {
|
if (leftBlock == rightBlock) {
|
||||||
*aCanceled = true;
|
return EditActionIgnored();
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Joining a list item to its parent is a NOP.
|
// Joining a list item to its parent is a NOP.
|
||||||
if (HTMLEditUtils::IsList(leftBlock) &&
|
if (HTMLEditUtils::IsList(leftBlock) &&
|
||||||
HTMLEditUtils::IsListItem(rightBlock) &&
|
HTMLEditUtils::IsListItem(rightBlock) &&
|
||||||
rightBlock->GetParentNode() == leftBlock) {
|
rightBlock->GetParentNode() == leftBlock) {
|
||||||
return NS_OK;
|
return EditActionHandled();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special rule here: if we are trying to join list items, and they are in
|
// Special rule here: if we are trying to join list items, and they are in
|
||||||
|
|
@ -2665,7 +2690,9 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode,
|
||||||
nsresult rv = WSRunObject::ScrubBlockBoundary(htmlEditor,
|
nsresult rv = WSRunObject::ScrubBlockBoundary(htmlEditor,
|
||||||
WSRunObject::kBlockEnd,
|
WSRunObject::kBlockEnd,
|
||||||
leftBlock);
|
leftBlock);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return EditActionIgnored(rv);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// We can't just track rightBlock because it's an Element.
|
// We can't just track rightBlock because it's an Element.
|
||||||
|
|
@ -2675,40 +2702,61 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode,
|
||||||
rv = WSRunObject::ScrubBlockBoundary(htmlEditor,
|
rv = WSRunObject::ScrubBlockBoundary(htmlEditor,
|
||||||
WSRunObject::kAfterBlock,
|
WSRunObject::kAfterBlock,
|
||||||
rightBlock, rightOffset);
|
rightBlock, rightOffset);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return EditActionIgnored(rv);
|
||||||
|
}
|
||||||
|
|
||||||
if (trackingRightBlock->IsElement()) {
|
if (trackingRightBlock->IsElement()) {
|
||||||
rightBlock = trackingRightBlock->AsElement();
|
rightBlock = trackingRightBlock->AsElement();
|
||||||
} else {
|
} else {
|
||||||
NS_ENSURE_STATE(trackingRightBlock->GetParentElement());
|
if (NS_WARN_IF(!trackingRightBlock->GetParentElement())) {
|
||||||
|
return EditActionIgnored(NS_ERROR_UNEXPECTED);
|
||||||
|
}
|
||||||
rightBlock = trackingRightBlock->GetParentElement();
|
rightBlock = trackingRightBlock->GetParentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Do br adjustment.
|
// Do br adjustment.
|
||||||
nsCOMPtr<Element> brNode =
|
nsCOMPtr<Element> brNode =
|
||||||
CheckForInvisibleBR(*leftBlock, BRLocation::blockEnd);
|
CheckForInvisibleBR(*leftBlock, BRLocation::blockEnd);
|
||||||
|
EditActionResult ret(NS_OK);
|
||||||
if (mergeLists) {
|
if (mergeLists) {
|
||||||
// The idea here is to take all children in rightList that are past
|
// The idea here is to take all children in rightList that are past
|
||||||
// offset, and pull them into leftlist.
|
// offset, and pull them into leftlist.
|
||||||
for (nsCOMPtr<nsIContent> child = rightList->GetChildAt(offset);
|
for (nsCOMPtr<nsIContent> child = rightList->GetChildAt(offset);
|
||||||
child; child = rightList->GetChildAt(rightOffset)) {
|
child; child = rightList->GetChildAt(rightOffset)) {
|
||||||
rv = htmlEditor->MoveNode(child, leftList, -1);
|
rv = htmlEditor->MoveNode(child, leftList, -1);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return EditActionIgnored(rv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// XXX Should this set to true only when above for loop moves the node?
|
||||||
|
ret.MarkAsHandled();
|
||||||
} else {
|
} else {
|
||||||
MoveBlock(*leftBlock, *rightBlock, leftOffset, rightOffset);
|
// XXX Why do we ignore the result of MoveBlock()?
|
||||||
|
EditActionResult retMoveBlock =
|
||||||
|
MoveBlock(*leftBlock, *rightBlock, leftOffset, rightOffset);
|
||||||
|
if (retMoveBlock.Handled()) {
|
||||||
|
ret.MarkAsHandled();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (brNode) {
|
if (brNode && NS_SUCCEEDED(htmlEditor->DeleteNode(brNode))) {
|
||||||
htmlEditor->DeleteNode(brNode);
|
ret.MarkAsHandled();
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// Offset below is where you find yourself in leftBlock when you traverse
|
// Offset below is where you find yourself in leftBlock when you traverse
|
||||||
// upwards from rightBlock
|
// upwards from rightBlock
|
||||||
} else if (EditorUtils::IsDescendantOf(rightBlock, leftBlock, &leftOffset)) {
|
if (EditorUtils::IsDescendantOf(rightBlock, leftBlock, &leftOffset)) {
|
||||||
// Tricky case. Right block is inside left block. Do ws adjustment. This
|
// Tricky case. Right block is inside left block. Do ws adjustment. This
|
||||||
// just destroys non-visible ws at boundaries we will be joining.
|
// just destroys non-visible ws at boundaries we will be joining.
|
||||||
nsresult rv = WSRunObject::ScrubBlockBoundary(htmlEditor,
|
nsresult rv = WSRunObject::ScrubBlockBoundary(htmlEditor,
|
||||||
WSRunObject::kBlockStart,
|
WSRunObject::kBlockStart,
|
||||||
rightBlock);
|
rightBlock);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return EditActionIgnored(rv);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// We can't just track leftBlock because it's an Element, so track
|
// We can't just track leftBlock because it's an Element, so track
|
||||||
// something else.
|
// something else.
|
||||||
|
|
@ -2718,19 +2766,30 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode,
|
||||||
rv = WSRunObject::ScrubBlockBoundary(htmlEditor,
|
rv = WSRunObject::ScrubBlockBoundary(htmlEditor,
|
||||||
WSRunObject::kBeforeBlock,
|
WSRunObject::kBeforeBlock,
|
||||||
leftBlock, leftOffset);
|
leftBlock, leftOffset);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return EditActionIgnored(rv);
|
||||||
|
}
|
||||||
|
|
||||||
if (trackingLeftBlock->IsElement()) {
|
if (trackingLeftBlock->IsElement()) {
|
||||||
leftBlock = trackingLeftBlock->AsElement();
|
leftBlock = trackingLeftBlock->AsElement();
|
||||||
} else {
|
} else {
|
||||||
NS_ENSURE_STATE(trackingLeftBlock->GetParentElement());
|
if (NS_WARN_IF(!trackingLeftBlock->GetParentElement())) {
|
||||||
|
return EditActionIgnored(NS_ERROR_UNEXPECTED);
|
||||||
|
}
|
||||||
leftBlock = trackingLeftBlock->GetParentElement();
|
leftBlock = trackingLeftBlock->GetParentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Do br adjustment.
|
// Do br adjustment.
|
||||||
nsCOMPtr<Element> brNode =
|
nsCOMPtr<Element> brNode =
|
||||||
CheckForInvisibleBR(*leftBlock, BRLocation::beforeBlock, leftOffset);
|
CheckForInvisibleBR(*leftBlock, BRLocation::beforeBlock, leftOffset);
|
||||||
|
EditActionResult ret(NS_OK);
|
||||||
if (mergeLists) {
|
if (mergeLists) {
|
||||||
MoveContents(*rightList, *leftList, &leftOffset);
|
// XXX Why do we ignore the result of MoveContents()?
|
||||||
|
EditActionResult retMoveContents =
|
||||||
|
MoveContents(*rightList, *leftList, &leftOffset);
|
||||||
|
if (retMoveContents.Handled()) {
|
||||||
|
ret.MarkAsHandled();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Left block is a parent of right block, and the parent of the previous
|
// Left block is a parent of right block, and the parent of the previous
|
||||||
// visible content. Right block is a child and contains the contents we
|
// visible content. Right block is a child and contains the contents we
|
||||||
|
|
@ -2775,7 +2834,9 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode,
|
||||||
&previousContentOffset,
|
&previousContentOffset,
|
||||||
nullptr, nullptr, nullptr,
|
nullptr, nullptr, nullptr,
|
||||||
getter_AddRefs(splittedPreviousContent));
|
getter_AddRefs(splittedPreviousContent));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return EditActionIgnored(rv);
|
||||||
|
}
|
||||||
|
|
||||||
if (splittedPreviousContent) {
|
if (splittedPreviousContent) {
|
||||||
previousContentParent = splittedPreviousContent->GetParentNode();
|
previousContentParent = splittedPreviousContent->GetParentNode();
|
||||||
|
|
@ -2784,58 +2845,67 @@ HTMLEditRules::JoinBlocks(nsIContent& aLeftNode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ENSURE_TRUE(previousContentParent, NS_ERROR_NULL_POINTER);
|
if (NS_WARN_IF(!previousContentParent)) {
|
||||||
|
return EditActionIgnored(NS_ERROR_NULL_POINTER);
|
||||||
rv = MoveBlock(*previousContentParent->AsElement(), *rightBlock,
|
}
|
||||||
previousContentOffset, rightOffset);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
ret |= MoveBlock(*previousContentParent->AsElement(), *rightBlock,
|
||||||
}
|
previousContentOffset, rightOffset);
|
||||||
if (brNode) {
|
if (NS_WARN_IF(ret.Failed())) {
|
||||||
htmlEditor->DeleteNode(brNode);
|
return ret;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Normal case. Blocks are siblings, or at least close enough. An example
|
|
||||||
// of the latter is <p>paragraph</p><ul><li>one<li>two<li>three</ul>. The
|
|
||||||
// first li and the p are not true siblings, but we still want to join them
|
|
||||||
// if you backspace from li into p.
|
|
||||||
|
|
||||||
// Adjust whitespace at block boundaries
|
|
||||||
nsresult rv =
|
|
||||||
WSRunObject::PrepareToJoinBlocks(htmlEditor, leftBlock, rightBlock);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
// Do br adjustment.
|
|
||||||
nsCOMPtr<Element> brNode =
|
|
||||||
CheckForInvisibleBR(*leftBlock, BRLocation::blockEnd);
|
|
||||||
if (mergeLists || leftBlock->NodeInfo()->NameAtom() ==
|
|
||||||
rightBlock->NodeInfo()->NameAtom()) {
|
|
||||||
// Nodes are same type. merge them.
|
|
||||||
EditorDOMPoint pt = JoinNodesSmart(*leftBlock, *rightBlock);
|
|
||||||
if (pt.node && mergeLists) {
|
|
||||||
nsCOMPtr<Element> newBlock;
|
|
||||||
ConvertListType(rightBlock, getter_AddRefs(newBlock),
|
|
||||||
existingList, nsGkAtoms::li);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Nodes are dissimilar types.
|
|
||||||
rv = MoveBlock(*leftBlock, *rightBlock, leftOffset, rightOffset);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
}
|
||||||
if (brNode) {
|
if (brNode && NS_SUCCEEDED(htmlEditor->DeleteNode(brNode))) {
|
||||||
rv = htmlEditor->DeleteNode(brNode);
|
ret.MarkAsHandled();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normal case. Blocks are siblings, or at least close enough. An example
|
||||||
|
// of the latter is <p>paragraph</p><ul><li>one<li>two<li>three</ul>. The
|
||||||
|
// first li and the p are not true siblings, but we still want to join them
|
||||||
|
// if you backspace from li into p.
|
||||||
|
|
||||||
|
// Adjust whitespace at block boundaries
|
||||||
|
nsresult rv =
|
||||||
|
WSRunObject::PrepareToJoinBlocks(htmlEditor, leftBlock, rightBlock);
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return EditActionIgnored(rv);
|
||||||
|
}
|
||||||
|
// Do br adjustment.
|
||||||
|
nsCOMPtr<Element> brNode =
|
||||||
|
CheckForInvisibleBR(*leftBlock, BRLocation::blockEnd);
|
||||||
|
EditActionResult ret(NS_OK);
|
||||||
|
if (mergeLists || leftBlock->NodeInfo()->NameAtom() ==
|
||||||
|
rightBlock->NodeInfo()->NameAtom()) {
|
||||||
|
// Nodes are same type. merge them.
|
||||||
|
EditorDOMPoint pt = JoinNodesSmart(*leftBlock, *rightBlock);
|
||||||
|
if (pt.node && mergeLists) {
|
||||||
|
nsCOMPtr<Element> newBlock;
|
||||||
|
ConvertListType(rightBlock, getter_AddRefs(newBlock),
|
||||||
|
existingList, nsGkAtoms::li);
|
||||||
|
}
|
||||||
|
ret.MarkAsHandled();
|
||||||
|
} else {
|
||||||
|
// Nodes are dissimilar types.
|
||||||
|
ret |= MoveBlock(*leftBlock, *rightBlock, leftOffset, rightOffset);
|
||||||
|
if (NS_WARN_IF(ret.Failed())) {
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NS_OK;
|
if (brNode) {
|
||||||
|
rv = htmlEditor->DeleteNode(brNode);
|
||||||
|
// XXX In other top level if blocks, the result of DeleteNode()
|
||||||
|
// is ignored. Why does only this result is respected?
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return ret.SetResult(rv);
|
||||||
|
}
|
||||||
|
ret.MarkAsHandled();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditActionResult
|
||||||
/**
|
|
||||||
* Moves the content from aRightBlock starting from aRightOffset into
|
|
||||||
* aLeftBlock at aLeftOffset. Note that the "block" might merely be inline
|
|
||||||
* nodes between <br>s, or between blocks, etc. DTD containment rules are
|
|
||||||
* followed throughout.
|
|
||||||
*/
|
|
||||||
nsresult
|
|
||||||
HTMLEditRules::MoveBlock(Element& aLeftBlock,
|
HTMLEditRules::MoveBlock(Element& aLeftBlock,
|
||||||
Element& aRightBlock,
|
Element& aRightBlock,
|
||||||
int32_t aLeftOffset,
|
int32_t aLeftOffset,
|
||||||
|
|
@ -2846,41 +2916,51 @@ HTMLEditRules::MoveBlock(Element& aLeftBlock,
|
||||||
nsresult rv = GetNodesFromPoint(EditorDOMPoint(&aRightBlock, aRightOffset),
|
nsresult rv = GetNodesFromPoint(EditorDOMPoint(&aRightBlock, aRightOffset),
|
||||||
EditAction::makeList, arrayOfNodes,
|
EditAction::makeList, arrayOfNodes,
|
||||||
TouchContent::yes);
|
TouchContent::yes);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return EditActionIgnored(rv);
|
||||||
|
}
|
||||||
|
|
||||||
|
EditActionResult ret(NS_OK);
|
||||||
for (uint32_t i = 0; i < arrayOfNodes.Length(); i++) {
|
for (uint32_t i = 0; i < arrayOfNodes.Length(); i++) {
|
||||||
// get the node to act on
|
// get the node to act on
|
||||||
if (IsBlockNode(arrayOfNodes[i])) {
|
if (IsBlockNode(arrayOfNodes[i])) {
|
||||||
// For block nodes, move their contents only, then delete block.
|
// For block nodes, move their contents only, then delete block.
|
||||||
rv = MoveContents(*arrayOfNodes[i]->AsElement(), aLeftBlock,
|
ret |=
|
||||||
&aLeftOffset);
|
MoveContents(*arrayOfNodes[i]->AsElement(), aLeftBlock, &aLeftOffset);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(ret.Failed())) {
|
||||||
NS_ENSURE_STATE(mHTMLEditor);
|
return ret;
|
||||||
|
}
|
||||||
|
if (NS_WARN_IF(!mHTMLEditor)) {
|
||||||
|
return ret.SetResult(NS_ERROR_UNEXPECTED);
|
||||||
|
}
|
||||||
rv = mHTMLEditor->DeleteNode(arrayOfNodes[i]);
|
rv = mHTMLEditor->DeleteNode(arrayOfNodes[i]);
|
||||||
|
ret.MarkAsHandled();
|
||||||
} else {
|
} else {
|
||||||
// Otherwise move the content as is, checking against the DTD.
|
// Otherwise move the content as is, checking against the DTD.
|
||||||
rv = MoveNodeSmart(*arrayOfNodes[i]->AsContent(), aLeftBlock,
|
ret |=
|
||||||
&aLeftOffset);
|
MoveNodeSmart(*arrayOfNodes[i]->AsContent(), aLeftBlock, &aLeftOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX We're only checking return value of the last iteration
|
// XXX We're only checking return value of the last iteration
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(ret.Failed())) {
|
||||||
return NS_OK;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
EditActionResult
|
||||||
* This method is used to move node aNode to (aDestElement, aInOutDestOffset).
|
|
||||||
* DTD containment rules are followed throughout. aInOutDestOffset is updated
|
|
||||||
* to point _after_ inserted content.
|
|
||||||
*/
|
|
||||||
nsresult
|
|
||||||
HTMLEditRules::MoveNodeSmart(nsIContent& aNode,
|
HTMLEditRules::MoveNodeSmart(nsIContent& aNode,
|
||||||
Element& aDestElement,
|
Element& aDestElement,
|
||||||
int32_t* aInOutDestOffset)
|
int32_t* aInOutDestOffset)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aInOutDestOffset);
|
MOZ_ASSERT(aInOutDestOffset);
|
||||||
|
|
||||||
NS_ENSURE_STATE(mHTMLEditor);
|
if (NS_WARN_IF(!mHTMLEditor)) {
|
||||||
|
return EditActionIgnored(NS_ERROR_UNEXPECTED);
|
||||||
|
}
|
||||||
|
|
||||||
RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
|
RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
|
||||||
|
|
||||||
// Check if this node can go into the destination node
|
// Check if this node can go into the destination node
|
||||||
|
|
@ -2888,44 +2968,52 @@ HTMLEditRules::MoveNodeSmart(nsIContent& aNode,
|
||||||
// If it can, move it there
|
// If it can, move it there
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
htmlEditor->MoveNode(&aNode, &aDestElement, *aInOutDestOffset);
|
htmlEditor->MoveNode(&aNode, &aDestElement, *aInOutDestOffset);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return EditActionIgnored(rv);
|
||||||
|
}
|
||||||
if (*aInOutDestOffset != -1) {
|
if (*aInOutDestOffset != -1) {
|
||||||
(*aInOutDestOffset)++;
|
(*aInOutDestOffset)++;
|
||||||
}
|
}
|
||||||
} else {
|
// XXX Should we check if the node is actually moved in this case?
|
||||||
// If it can't, move its children (if any), and then delete it.
|
return EditActionHandled();
|
||||||
if (aNode.IsElement()) {
|
|
||||||
nsresult rv =
|
|
||||||
MoveContents(*aNode.AsElement(), aDestElement, aInOutDestOffset);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult rv = htmlEditor->DeleteNode(&aNode);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
}
|
||||||
return NS_OK;
|
|
||||||
|
// If it can't, move its children (if any), and then delete it.
|
||||||
|
EditActionResult ret(NS_OK);
|
||||||
|
if (aNode.IsElement()) {
|
||||||
|
ret = MoveContents(*aNode.AsElement(), aDestElement, aInOutDestOffset);
|
||||||
|
if (NS_WARN_IF(ret.Failed())) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult rv = htmlEditor->DeleteNode(&aNode);
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return ret.SetResult(rv);
|
||||||
|
}
|
||||||
|
return ret.MarkAsHandled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
EditActionResult
|
||||||
* Moves the _contents_ of aElement to (aDestElement, aInOutDestOffset). DTD
|
|
||||||
* containment rules are followed throughout. aInOutDestOffset is updated to
|
|
||||||
* point _after_ inserted content.
|
|
||||||
*/
|
|
||||||
nsresult
|
|
||||||
HTMLEditRules::MoveContents(Element& aElement,
|
HTMLEditRules::MoveContents(Element& aElement,
|
||||||
Element& aDestElement,
|
Element& aDestElement,
|
||||||
int32_t* aInOutDestOffset)
|
int32_t* aInOutDestOffset)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aInOutDestOffset);
|
MOZ_ASSERT(aInOutDestOffset);
|
||||||
|
|
||||||
NS_ENSURE_TRUE(&aElement != &aDestElement, NS_ERROR_ILLEGAL_VALUE);
|
if (NS_WARN_IF(&aElement == &aDestElement)) {
|
||||||
|
return EditActionIgnored(NS_ERROR_ILLEGAL_VALUE);
|
||||||
while (aElement.GetFirstChild()) {
|
|
||||||
nsresult rv = MoveNodeSmart(*aElement.GetFirstChild(), aDestElement,
|
|
||||||
aInOutDestOffset);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
}
|
||||||
return NS_OK;
|
|
||||||
|
EditActionResult ret(NS_OK);
|
||||||
|
while (aElement.GetFirstChild()) {
|
||||||
|
ret |=
|
||||||
|
MoveNodeSmart(*aElement.GetFirstChild(), aDestElement, aInOutDestOffset);
|
||||||
|
if (NS_WARN_IF(ret.Failed())) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ class nsRange;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
|
class EditActionResult;
|
||||||
class HTMLEditor;
|
class HTMLEditor;
|
||||||
class RulesInfo;
|
class RulesInfo;
|
||||||
class TextEditor;
|
class TextEditor;
|
||||||
|
|
@ -163,14 +164,63 @@ protected:
|
||||||
nsresult InsertBRIfNeeded(Selection* aSelection);
|
nsresult InsertBRIfNeeded(Selection* aSelection);
|
||||||
mozilla::EditorDOMPoint GetGoodSelPointForNode(nsINode& aNode,
|
mozilla::EditorDOMPoint GetGoodSelPointForNode(nsINode& aNode,
|
||||||
nsIEditor::EDirection aAction);
|
nsIEditor::EDirection aAction);
|
||||||
nsresult JoinBlocks(nsIContent& aLeftNode, nsIContent& aRightNode,
|
|
||||||
bool* aCanceled);
|
/**
|
||||||
nsresult MoveBlock(Element& aLeftBlock, Element& aRightBlock,
|
* TryToJoinBlocks() tries to join two block elements. The right element is
|
||||||
int32_t aLeftOffset, int32_t aRightOffset);
|
* always joined to the left element. If the elements are the same type and
|
||||||
nsresult MoveNodeSmart(nsIContent& aNode, Element& aDestElement,
|
* not nested within each other, JoinNodesSmart() is called (example, joining
|
||||||
int32_t* aOffset);
|
* two list items together into one). If the elements are not the same type,
|
||||||
nsresult MoveContents(Element& aElement, Element& aDestElement,
|
* or one is a descendant of the other, we instead destroy the right block
|
||||||
int32_t* aOffset);
|
* placing its children into leftblock. DTD containment rules are followed
|
||||||
|
* throughout.
|
||||||
|
*
|
||||||
|
* @return Sets canceled to true if the operation should do
|
||||||
|
* nothing anymore even if this doesn't join the blocks.
|
||||||
|
* Sets handled to true if this actually handles the
|
||||||
|
* request. Note that this may set it to true even if this
|
||||||
|
* does not join the block. E.g., if the blocks shouldn't
|
||||||
|
* be joined or it's impossible to join them but it's not
|
||||||
|
* unexpected case, this returns true with this.
|
||||||
|
*/
|
||||||
|
EditActionResult TryToJoinBlocks(nsIContent& aLeftNode,
|
||||||
|
nsIContent& aRightNode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MoveBlock() moves the content from aRightBlock starting from aRightOffset
|
||||||
|
* into aLeftBlock at aLeftOffset. Note that the "block" can be inline nodes
|
||||||
|
* between <br>s, or between blocks, etc. DTD containment rules are followed
|
||||||
|
* throughout.
|
||||||
|
*
|
||||||
|
* @return Sets handled to true if this actually joins the nodes.
|
||||||
|
* canceled is always false.
|
||||||
|
*/
|
||||||
|
EditActionResult MoveBlock(Element& aLeftBlock, Element& aRightBlock,
|
||||||
|
int32_t aLeftOffset, int32_t aRightOffset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MoveNodeSmart() moves aNode to (aDestElement, aInOutDestOffset).
|
||||||
|
* DTD containment rules are followed throughout.
|
||||||
|
*
|
||||||
|
* @param aOffset returns the point after inserted content.
|
||||||
|
* @return Sets true to handled if this actually moves
|
||||||
|
* the nodes.
|
||||||
|
* canceled is always false.
|
||||||
|
*/
|
||||||
|
EditActionResult MoveNodeSmart(nsIContent& aNode, Element& aDestElement,
|
||||||
|
int32_t* aInOutDestOffset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MoveContents() moves the contents of aElement to (aDestElement,
|
||||||
|
* aInOutDestOffset). DTD containment rules are followed throughout.
|
||||||
|
*
|
||||||
|
* @param aInOutDestOffset updated to point after inserted content.
|
||||||
|
* @return Sets true to handled if this actually moves
|
||||||
|
* the nodes.
|
||||||
|
* canceled is always false.
|
||||||
|
*/
|
||||||
|
EditActionResult MoveContents(Element& aElement, Element& aDestElement,
|
||||||
|
int32_t* aInOutDestOffset);
|
||||||
|
|
||||||
nsresult DeleteNonTableElements(nsINode* aNode);
|
nsresult DeleteNonTableElements(nsINode* aNode);
|
||||||
nsresult WillMakeList(Selection* aSelection,
|
nsresult WillMakeList(Selection* aSelection,
|
||||||
const nsAString* aListType,
|
const nsAString* aListType,
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include "nsCharTraits.h"
|
#include "nsCharTraits.h"
|
||||||
#include "nsComponentManagerUtils.h"
|
#include "nsComponentManagerUtils.h"
|
||||||
#include "nsContentCID.h"
|
#include "nsContentCID.h"
|
||||||
|
#include "nsContentList.h"
|
||||||
#include "nsCopySupport.h"
|
#include "nsCopySupport.h"
|
||||||
#include "nsDebug.h"
|
#include "nsDebug.h"
|
||||||
#include "nsDependentSubstring.h"
|
#include "nsDependentSubstring.h"
|
||||||
|
|
|
||||||
|
|
@ -1526,28 +1526,44 @@ void nsImapProtocol::EstablishServerConnection()
|
||||||
}
|
}
|
||||||
else if (!PL_strncasecmp(serverResponse, ESC_PREAUTH, ESC_PREAUTH_LEN))
|
else if (!PL_strncasecmp(serverResponse, ESC_PREAUTH, ESC_PREAUTH_LEN))
|
||||||
{
|
{
|
||||||
// we've been pre-authenticated.
|
// PREAUTH greeting received. We've been pre-authenticated by the server.
|
||||||
// we can skip the whole password step, right into the
|
// We can skip sending a password and transition right into the
|
||||||
// kAuthenticated state
|
// kAuthenticated state; but we won't if the user has configured STARTTLS.
|
||||||
GetServerStateParser().PreauthSetAuthenticatedState();
|
// (STARTTLS can only occur with the server in non-authenticated state.)
|
||||||
|
if (!(m_socketType == nsMsgSocketType::alwaysSTARTTLS ||
|
||||||
|
m_socketType == nsMsgSocketType::trySTARTTLS)) {
|
||||||
|
GetServerStateParser().PreauthSetAuthenticatedState();
|
||||||
|
|
||||||
if (GetServerStateParser().GetCapabilityFlag() == kCapabilityUndefined)
|
if (GetServerStateParser().GetCapabilityFlag() == kCapabilityUndefined)
|
||||||
Capability();
|
Capability();
|
||||||
|
|
||||||
if ( !(GetServerStateParser().GetCapabilityFlag() &
|
if (!(GetServerStateParser().GetCapabilityFlag() &
|
||||||
(kIMAP4Capability | kIMAP4rev1Capability | kIMAP4other) ) )
|
(kIMAP4Capability | kIMAP4rev1Capability | kIMAP4other))) {
|
||||||
{
|
// AlertUserEventUsingId(MK_MSG_IMAP_SERVER_NOT_IMAP4);
|
||||||
// AlertUserEvent_UsingId(MK_MSG_IMAP_SERVER_NOT_IMAP4);
|
SetConnectionStatus(NS_ERROR_FAILURE); // stop netlib
|
||||||
|
} else {
|
||||||
|
// let's record the user as authenticated.
|
||||||
|
m_imapServerSink->SetUserAuthenticated(true);
|
||||||
|
|
||||||
|
ProcessAfterAuthenticated();
|
||||||
|
// the connection was a success
|
||||||
|
SetConnectionStatus(NS_OK);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// STARTTLS is configured so don't transition to authenticated state. Just
|
||||||
|
// alert the user, log the error and drop the connection. This may
|
||||||
|
// indicate a man-in-the middle attack if the user is not expecting
|
||||||
|
// PREAUTH. The user must change the connection security setting to other
|
||||||
|
// than STARTTLS to allow PREAUTH to be accepted on subsequent IMAP
|
||||||
|
// connections.
|
||||||
|
AlertUserEventUsingName("imapServerDisconnected");
|
||||||
|
const nsCString &hostName = GetImapHostName();
|
||||||
|
MOZ_LOG(
|
||||||
|
IMAP, LogLevel::Error,
|
||||||
|
("PREAUTH received from IMAP server %s because STARTTLS selected. "
|
||||||
|
"Connection dropped",
|
||||||
|
hostName.get()));
|
||||||
SetConnectionStatus(NS_ERROR_FAILURE); // stop netlib
|
SetConnectionStatus(NS_ERROR_FAILURE); // stop netlib
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// let's record the user as authenticated.
|
|
||||||
m_imapServerSink->SetUserAuthenticated(true);
|
|
||||||
|
|
||||||
ProcessAfterAuthenticated();
|
|
||||||
// the connection was a success
|
|
||||||
SetConnectionStatus(NS_OK);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
[ShadowRoot-interface.html]
|
|
||||||
type: testharness
|
|
||||||
[ShadowRoot.activeElement must return the focused element of the context object when shadow root is open.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[ShadowRoot.activeElement must return the focused element of the context object when shadow root is closed.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[ShadowRoot.host must return the shadow host of the context object.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is open.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is closed.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is open.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is closed.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is open.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is closed.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
[activeElement-confirm-return-null.html]
|
|
||||||
type: testharness
|
|
||||||
[confirm activeElement return null]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[confirm activeElement return null when there is other element in body]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[confirm activeElement return null when focus on the element in the outer shadow tree]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
[test-007.html]
|
|
||||||
type: testharness
|
|
||||||
[A_10_01_01_03_01_T01]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
[test-001.html]
|
|
||||||
type: testharness
|
|
||||||
[A_07_03_01_T01]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
[test-002.html]
|
|
||||||
type: testharness
|
|
||||||
[A_07_03_02_T01]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
@ -5151,6 +5151,9 @@
|
||||||
|
|
||||||
${GetParameters} $R8
|
${GetParameters} $R8
|
||||||
|
|
||||||
|
; Require elevation if the user can elevate
|
||||||
|
${ElevateUAC}
|
||||||
|
|
||||||
${If} $R8 != ""
|
${If} $R8 != ""
|
||||||
; Default install type
|
; Default install type
|
||||||
StrCpy $InstallType ${INSTALLTYPE_BASIC}
|
StrCpy $InstallType ${INSTALLTYPE_BASIC}
|
||||||
|
|
@ -5203,28 +5206,14 @@
|
||||||
FileClose $R5
|
FileClose $R5
|
||||||
Delete $R6
|
Delete $R6
|
||||||
${If} ${Errors}
|
${If} ${Errors}
|
||||||
; Attempt to elevate and then try again.
|
; Nothing initialized so no need to call OnEndCommon
|
||||||
${ElevateUAC}
|
Quit
|
||||||
GetTempFileName $R6 "$INSTDIR"
|
|
||||||
FileOpen $R5 "$R6" w
|
|
||||||
FileWrite $R5 "Write Access Test"
|
|
||||||
FileClose $R5
|
|
||||||
Delete $R6
|
|
||||||
${If} ${Errors}
|
|
||||||
; Nothing initialized so no need to call OnEndCommon
|
|
||||||
Quit
|
|
||||||
${EndIf}
|
|
||||||
${EndIf}
|
${EndIf}
|
||||||
${Else}
|
${Else}
|
||||||
CreateDirectory "$INSTDIR"
|
CreateDirectory "$INSTDIR"
|
||||||
${If} ${Errors}
|
${If} ${Errors}
|
||||||
; Attempt to elevate and then try again.
|
; Nothing initialized so no need to call OnEndCommon
|
||||||
${ElevateUAC}
|
Quit
|
||||||
CreateDirectory "$INSTDIR"
|
|
||||||
${If} ${Errors}
|
|
||||||
; Nothing initialized so no need to call OnEndCommon
|
|
||||||
Quit
|
|
||||||
${EndIf}
|
|
||||||
${EndIf}
|
${EndIf}
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
|
|
@ -5256,20 +5245,10 @@
|
||||||
${EndIf}
|
${EndIf}
|
||||||
!endif
|
!endif
|
||||||
${EndIf}
|
${EndIf}
|
||||||
${Else}
|
|
||||||
; If this isn't an INI install, we need to try to elevate now.
|
|
||||||
; We'll check the user's permission level later on to determine the
|
|
||||||
; default install path (which will be the real install path for /S).
|
|
||||||
; If an INI file is used, we try to elevate down that path when needed.
|
|
||||||
${ElevateUAC}
|
|
||||||
${EndUnless}
|
${EndUnless}
|
||||||
${EndIf}
|
${EndIf}
|
||||||
ClearErrors
|
ClearErrors
|
||||||
|
|
||||||
${IfNot} ${Silent}
|
|
||||||
${ElevateUAC}
|
|
||||||
${EndIf}
|
|
||||||
|
|
||||||
Pop $R5
|
Pop $R5
|
||||||
Pop $R6
|
Pop $R6
|
||||||
Pop $R7
|
Pop $R7
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,6 @@ nsNativeMenuService::~nsNativeMenuService() {
|
||||||
gPangoLayout = nullptr;
|
gPangoLayout = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(sService == this);
|
|
||||||
sService = nullptr;
|
sService = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue