Bug 1415270 - Part 1: Move nsHTMLDocument editing APIs to Document; r=farre,masayuki

Differential Revision: https://phabricator.services.mozilla.com/D32911

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2019-05-31 01:37:26 +00:00
parent 601750a268
commit a9e9f5ccdb
17 changed files with 1331 additions and 1482 deletions

View File

@ -16,7 +16,7 @@ using namespace mozilla;
nsDocShellEditorData::nsDocShellEditorData(nsIDocShell* aOwningDocShell)
: mDocShell(aOwningDocShell),
mDetachedEditingState(nsIHTMLDocument::eOff),
mDetachedEditingState(Document::EditingState::eOff),
mMakeEditable(false),
mIsDetached(false),
mDetachedMakeEditable(false) {
@ -111,10 +111,7 @@ nsresult nsDocShellEditorData::DetachFromWindow() {
mMakeEditable = false;
nsCOMPtr<dom::Document> doc = domWindow->GetDoc();
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(doc);
if (htmlDoc) {
mDetachedEditingState = htmlDoc->GetEditingState();
}
mDetachedEditingState = doc->GetEditingState();
mDocShell = nullptr;
@ -133,10 +130,7 @@ nsresult nsDocShellEditorData::ReattachToWindow(nsIDocShell* aDocShell) {
mMakeEditable = mDetachedMakeEditable;
RefPtr<dom::Document> doc = domWindow->GetDoc();
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(doc);
if (htmlDoc) {
htmlDoc->SetEditingState(mDetachedEditingState);
}
doc->SetEditingState(mDetachedEditingState);
return NS_OK;
}

View File

@ -12,7 +12,7 @@
#include "mozilla/HTMLEditor.h"
#include "mozilla/RefPtr.h"
#include "nsIHTMLDocument.h"
#include "mozilla/dom/Document.h"
class nsIDocShell;
class nsEditingSession;
@ -47,7 +47,7 @@ class nsDocShellEditorData {
// Backup for the corresponding nsIHTMLDocument's editing state while
// the editor is detached.
nsIHTMLDocument::EditingState mDetachedEditingState;
mozilla::dom::Document::EditingState mDetachedEditingState;
// Indicates whether to make an editor after a url load.
bool mMakeEditable;

File diff suppressed because it is too large Load Diff

View File

@ -1550,6 +1550,68 @@ class Document : public nsINode,
// Sets the cache sizes for the current generation.
void SetCachedSizes(nsTabSizes* aSizes);
/**
* Should be called when an element's editable changes as a result of
* changing its contentEditable attribute/property.
*
* @param aElement the element for which the contentEditable
* attribute/property was changed
* @param aChange +1 if the contentEditable attribute/property was changed to
* true, -1 if it was changed to false
*/
nsresult ChangeContentEditableCount(nsIContent* aElement, int32_t aChange);
void DeferredContentEditableCountChange(nsIContent* aElement);
enum class EditingState : int8_t {
eTearingDown = -2,
eSettingUp = -1,
eOff = 0,
eDesignMode,
eContentEditable
};
/**
* Returns the editing state of the document (not editable, contentEditable or
* designMode).
*/
EditingState GetEditingState() const { return mEditingState; }
/**
* Returns whether the document is editable.
*/
bool IsEditingOn() const {
return GetEditingState() == EditingState::eDesignMode ||
GetEditingState() == EditingState::eContentEditable;
}
class MOZ_STACK_CLASS nsAutoEditingState {
public:
nsAutoEditingState(Document* aDoc, EditingState aState)
: mDoc(aDoc), mSavedState(aDoc->mEditingState) {
aDoc->mEditingState = aState;
}
~nsAutoEditingState() { mDoc->mEditingState = mSavedState; }
private:
RefPtr<Document> mDoc;
EditingState mSavedState;
};
friend class nsAutoEditingState;
/**
* Set the editing state of the document. Don't use this if you want
* to enable/disable editing, call EditingStateChanged() or
* SetDesignMode().
*/
nsresult SetEditingState(EditingState aState);
/**
* Called when this Document's editor is destroyed.
*/
void TearingDownEditor();
void SetKeyPressEventModel(uint16_t aKeyPressEventModel);
protected:
friend class nsUnblockOnloadEvent;
@ -1609,6 +1671,32 @@ class Document : public nsINode,
*/
void DisconnectNodeTree();
/**
* Like IsEditingOn(), but will flush as needed first.
*/
bool IsEditingOnAfterFlush();
/**
* MaybeDispatchCheckKeyPressEventModelEvent() dispatches
* "CheckKeyPressEventModel" event to check whether we should dispatch
* keypress events in confluent model or split model. This should be
* called only when mEditingState is changed to eDesignMode or
* eConentEditable at first time.
*/
void MaybeDispatchCheckKeyPressEventModelEvent();
/* Midas implementation */
nsCommandManager* GetMidasCommandManager();
nsresult TurnEditingOff();
// MOZ_CAN_RUN_SCRIPT_BOUNDARY because this is called from all sorts
// of places, and I'm pretty sure the exact ExecCommand call it
// makes cannot actually run script.
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult EditingStateChanged();
void MaybeEditingStateChanged();
private:
class SelectorCacheKey {
public:
@ -2040,10 +2128,10 @@ class Document : public nsINode,
// content model or of style data, EndUpdate must be called afterward.
// To make this easy and painless, use the mozAutoDocUpdate helper class.
void BeginUpdate();
virtual void EndUpdate();
void EndUpdate();
uint32_t UpdateNestingLevel() { return mUpdateNestLevel; }
virtual void BeginLoad();
void BeginLoad();
virtual void EndLoad();
enum ReadyState {
@ -2344,7 +2432,7 @@ class Document : public nsINode,
* be rendered in "zombie state" until the next document is ready.
* The document should save form control state.
*/
virtual void RemovedFromDocShell();
void RemovedFromDocShell();
/**
* Get the layout history state that should be used to save and restore state
@ -2539,7 +2627,7 @@ class Document : public nsINode,
bool MayStartLayout() { return mMayStartLayout; }
virtual void SetMayStartLayout(bool aMayStartLayout);
void SetMayStartLayout(bool aMayStartLayout);
already_AddRefed<nsIDocumentEncoder> GetCachedEncoder();
@ -2773,7 +2861,7 @@ class Document : public nsINode,
/**
* Test whether we should be firing a load event for this document after a
* document.close(). This is public and on Document, instead of being private
* to nsHTMLDocument, because we need to go through the normal docloader logic
* to Document, because we need to go through the normal docloader logic
* for the readystate change to READYSTATE_COMPLETE with the normal timing and
* semantics of firing the load event; we just don't want to fire the load
* event if this tests true. So we need the docloader to be able to access
@ -3333,6 +3421,27 @@ class Document : public nsINode,
Nullable<WindowProxyHolder> GetDefaultView() const;
Element* GetActiveElement();
bool HasFocus(ErrorResult& rv) const;
void GetDesignMode(nsAString& aDesignMode);
void SetDesignMode(const nsAString& aDesignMode,
nsIPrincipal& aSubjectPrincipal, mozilla::ErrorResult& rv);
void SetDesignMode(const nsAString& aDesignMode,
const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal,
mozilla::ErrorResult& rv);
MOZ_CAN_RUN_SCRIPT
bool ExecCommand(const nsAString& aCommandID, bool aDoShowUI,
const nsAString& aValue, nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& rv);
bool QueryCommandEnabled(const nsAString& aCommandID,
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& rv);
bool QueryCommandIndeterm(const nsAString& aCommandID,
mozilla::ErrorResult& rv);
bool QueryCommandState(const nsAString& aCommandID, mozilla::ErrorResult& rv);
bool QueryCommandSupported(const nsAString& aCommandID,
mozilla::dom::CallerType aCallerType);
MOZ_CAN_RUN_SCRIPT
void QueryCommandValue(const nsAString& aCommandID, nsAString& aValue,
mozilla::ErrorResult& rv);
nsIHTMLCollection* Applets();
nsIHTMLCollection* Anchors();
TimeStamp LastFocusTime() const;
@ -4444,6 +4553,16 @@ class Document : public nsINode,
// allowed?
bool mTooDeepWriteRecursion : 1;
/**
* Temporary flag that is set in EndUpdate() to ignore
* MaybeEditingStateChanged() script runners from a nested scope.
*/
bool mPendingMaybeEditingStateChanged : 1;
// mHasBeenEditable is set to true when mEditingState is firstly set to
// eDesignMode or eContentEditable.
bool mHasBeenEditable : 1;
uint8_t mPendingFullscreenRequests;
uint8_t mXMLDeclarationBits;
@ -4460,6 +4579,9 @@ class Document : public nsINode,
// finishes processing that script.
uint32_t mWriteLevel;
uint32_t mContentEditableCount;
EditingState mEditingState;
// Compatibility mode
nsCompatibility mCompatMode;
@ -4657,6 +4779,8 @@ class Document : public nsINode,
RefPtr<DocGroup> mDocGroup;
RefPtr<nsCommandManager> mMidasCommandManager;
// The set of all the tracking script URLs. URLs are added to this set by
// calling NoteScriptTrackingStatus(). Currently we assume that a URL not
// existing in the set means the corresponding script isn't a tracking script.

View File

@ -2241,10 +2241,11 @@ void nsFocusManager::UpdateCaret(bool aMoveCaretToFocus, bool aUpdateVisibility,
focusedDocShell->GetEditable(&isEditable);
if (isEditable) {
nsCOMPtr<nsIHTMLDocument> doc = do_QueryInterface(presShell->GetDocument());
Document* doc = presShell->GetDocument();
bool isContentEditableDoc =
doc && doc->GetEditingState() == nsIHTMLDocument::eContentEditable;
doc &&
doc->GetEditingState() == Document::EditingState::eContentEditable;
bool isFocusEditable = aContent && aContent->HasFlag(NODE_IS_EDITABLE);
if (!isContentEditableDoc || isFocusEditable) return;

View File

@ -434,10 +434,9 @@ nsresult nsGenericHTMLElement::BindToTree(Document* aDocument,
if (HasFlag(NODE_IS_EDITABLE) && GetContentEditableValue() == eTrue &&
IsInComposedDoc()) {
nsCOMPtr<nsIHTMLDocument> htmlDocument =
do_QueryInterface(GetComposedDoc());
if (htmlDocument) {
htmlDocument->ChangeContentEditableCount(this, +1);
Document* doc = GetComposedDoc();
if (doc) {
doc->ChangeContentEditableCount(this, +1);
}
}
@ -460,10 +459,9 @@ void nsGenericHTMLElement::UnbindFromTree(bool aNullParent) {
RemoveFromNameTable();
if (GetContentEditableValue() == eTrue) {
nsCOMPtr<nsIHTMLDocument> htmlDocument =
do_QueryInterface(GetComposedDoc());
if (htmlDocument) {
htmlDocument->ChangeContentEditableCount(this, -1);
Document* doc = GetComposedDoc();
if (doc) {
doc->ChangeContentEditableCount(this, -1);
}
}
@ -2459,9 +2457,7 @@ void nsGenericHTMLElement::ChangeEditableState(int32_t aChange) {
}
if (aChange != 0) {
if (nsCOMPtr<nsIHTMLDocument> htmlDocument = do_QueryInterface(document)) {
htmlDocument->ChangeContentEditableCount(this, aChange);
}
document->ChangeContentEditableCount(this, aChange);
}
if (document->HasFlag(NODE_IS_EDITABLE)) {

File diff suppressed because it is too large Load Diff

View File

@ -66,9 +66,6 @@ class nsHTMLDocument : public mozilla::dom::Document, public nsIHTMLDocument {
bool aReset = true,
nsIContentSink* aSink = nullptr) override;
virtual void BeginLoad() override;
virtual void EndLoad() override;
protected:
virtual bool UseWidthDeviceWidthFallbackViewport() const override;
@ -88,41 +85,13 @@ class nsHTMLDocument : public mozilla::dom::Document, public nsIHTMLDocument {
virtual void AddedForm() override;
virtual void RemovedForm() override;
virtual int32_t GetNumFormsSynchronous() override;
virtual void TearingDownEditor() override;
virtual void SetIsXHTML(bool aXHTML) override {
mType = (aXHTML ? eXHTML : eHTML);
}
nsresult ChangeContentEditableCount(nsIContent* aElement,
int32_t aChange) override;
void DeferredContentEditableCountChange(nsIContent* aElement);
virtual EditingState GetEditingState() override { return mEditingState; }
class nsAutoEditingState {
public:
nsAutoEditingState(nsHTMLDocument* aDoc, EditingState aState)
: mDoc(aDoc), mSavedState(aDoc->mEditingState) {
aDoc->mEditingState = aState;
}
~nsAutoEditingState() { mDoc->mEditingState = mSavedState; }
private:
nsHTMLDocument* mDoc;
EditingState mSavedState;
};
friend class nsAutoEditingState;
void EndUpdate() override;
virtual void SetMayStartLayout(bool aMayStartLayout) override;
virtual nsresult SetEditingState(EditingState aState) override;
virtual nsresult Clone(mozilla::dom::NodeInfo*,
nsINode** aResult) const override;
virtual void RemovedFromDocShell() override;
using mozilla::dom::DocumentOrShadowRoot::GetElementById;
virtual void DocAddSizeOfExcludingThis(
@ -145,27 +114,6 @@ class nsHTMLDocument : public mozilla::dom::Document, public nsIHTMLDocument {
}
}
void GetSupportedNames(nsTArray<nsString>& aNames);
void GetDesignMode(nsAString& aDesignMode);
void SetDesignMode(const nsAString& aDesignMode,
nsIPrincipal& aSubjectPrincipal, mozilla::ErrorResult& rv);
void SetDesignMode(const nsAString& aDesignMode,
const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal,
mozilla::ErrorResult& rv);
MOZ_CAN_RUN_SCRIPT
bool ExecCommand(const nsAString& aCommandID, bool aDoShowUI,
const nsAString& aValue, nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& rv);
bool QueryCommandEnabled(const nsAString& aCommandID,
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& rv);
bool QueryCommandIndeterm(const nsAString& aCommandID,
mozilla::ErrorResult& rv);
bool QueryCommandState(const nsAString& aCommandID, mozilla::ErrorResult& rv);
bool QueryCommandSupported(const nsAString& aCommandID,
mozilla::dom::CallerType aCallerType);
MOZ_CAN_RUN_SCRIPT
void QueryCommandValue(const nsAString& aCommandID, nsAString& aValue,
mozilla::ErrorResult& rv);
void GetFgColor(nsAString& aFgColor);
void SetFgColor(const nsAString& aFgColor);
void GetLinkColor(nsAString& aLinkColor);
@ -194,8 +142,6 @@ class nsHTMLDocument : public mozilla::dom::Document, public nsIHTMLDocument {
void UserInteractionForTesting();
void SetKeyPressEventModel(uint16_t aKeyPressEventModel);
protected:
~nsHTMLDocument();
@ -205,11 +151,6 @@ class nsHTMLDocument : public mozilla::dom::Document, public nsIHTMLDocument {
static void DocumentWriteTerminationFunc(nsISupports* aRef);
/**
* Like IsEditingOn(), but will flush as needed first.
*/
bool IsEditingOnAfterFlush();
// A helper class to keep nsContentList objects alive for a short period of
// time. Note, when the final Release is called on an nsContentList object, it
// removes itself from MutationObserver list.
@ -256,45 +197,11 @@ class nsHTMLDocument : public mozilla::dom::Document, public nsIHTMLDocument {
static void TryFallback(int32_t& aCharsetSource,
NotNull<const Encoding*>& aEncoding);
/**
* MaybeDispatchCheckKeyPressEventModelEvent() dispatches
* "CheckKeyPressEventModel" event to check whether we should dispatch
* keypress events in confluent model or split model. This should be
* called only when mEditingState is changed to eDesignMode or
* eConentEditable at first time.
*/
void MaybeDispatchCheckKeyPressEventModelEvent();
// Load flags of the document's channel
uint32_t mLoadFlags;
bool mWarnedWidthHeight;
/* Midas implementation */
nsCommandManager* GetMidasCommandManager();
RefPtr<nsCommandManager> mMidasCommandManager;
nsresult TurnEditingOff();
// MOZ_CAN_RUN_SCRIPT_BOUNDARY because this is called from all sorts
// of places, and I'm pretty sure the exact ExecCommand call it
// makes cannot actually run script.
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult EditingStateChanged();
void MaybeEditingStateChanged();
uint32_t mContentEditableCount;
EditingState mEditingState;
/**
* Temporary flag that is set in EndUpdate() to ignore
* MaybeEditingStateChanged() script runners from a nested scope.
*/
bool mPendingMaybeEditingStateChanged;
// mHasBeenEditable is set to true when mEditingState is firstly set to
// eDesignMode or eContentEditable.
bool mHasBeenEditable;
/**
* Set to true once we know that we are loading plain text content.
*/

View File

@ -45,52 +45,6 @@ class nsIHTMLDocument : public nsISupports {
// not the rest?
virtual int32_t GetNumFormsSynchronous() = 0;
/**
* Should be called when an element's editable changes as a result of
* changing its contentEditable attribute/property.
*
* @param aElement the element for which the contentEditable
* attribute/property was changed
* @param aChange +1 if the contentEditable attribute/property was changed to
* true, -1 if it was changed to false
*/
virtual nsresult ChangeContentEditableCount(nsIContent* aElement,
int32_t aChange) = 0;
enum EditingState {
eTearingDown = -2,
eSettingUp = -1,
eOff = 0,
eDesignMode,
eContentEditable
};
/**
* Returns whether the document is editable.
*/
bool IsEditingOn() {
return GetEditingState() == eDesignMode ||
GetEditingState() == eContentEditable;
}
/**
* Returns the editing state of the document (not editable, contentEditable or
* designMode).
*/
virtual EditingState GetEditingState() = 0;
/**
* Set the editing state of the document. Don't use this if you want
* to enable/disable editing, call EditingStateChanged() or
* SetDesignMode().
*/
virtual nsresult SetEditingState(EditingState aState) = 0;
/**
* Called when this nsIHTMLDocument's editor is destroyed.
*/
virtual void TearingDownEditor() = 0;
virtual void SetIsXHTML(bool aXHTML) = 0;
};

View File

@ -160,15 +160,21 @@ partial interface Document {
readonly attribute WindowProxy? defaultView;
[Throws]
boolean hasFocus();
//(HTML only) attribute DOMString designMode;
//(HTML only)boolean execCommand(DOMString commandId);
//(HTML only)boolean execCommand(DOMString commandId, boolean showUI);
//(HTML only)boolean execCommand(DOMString commandId, boolean showUI, DOMString value);
//(HTML only)boolean queryCommandEnabled(DOMString commandId);
//(HTML only)boolean queryCommandIndeterm(DOMString commandId);
//(HTML only)boolean queryCommandState(DOMString commandId);
//(HTML only)boolean queryCommandSupported(DOMString commandId);
//(HTML only)DOMString queryCommandValue(DOMString commandId);
[CEReactions, SetterThrows, SetterNeedsSubjectPrincipal]
attribute DOMString designMode;
[CEReactions, Throws, NeedsSubjectPrincipal]
boolean execCommand(DOMString commandId, optional boolean showUI = false,
optional DOMString value = "");
[Throws, NeedsSubjectPrincipal]
boolean queryCommandEnabled(DOMString commandId);
[Throws]
boolean queryCommandIndeterm(DOMString commandId);
[Throws]
boolean queryCommandState(DOMString commandId);
[NeedsCallerType]
boolean queryCommandSupported(DOMString commandId);
[Throws]
DOMString queryCommandValue(DOMString commandId);
//(Not implemented)readonly attribute HTMLCollection commands;
// special event handler IDL attributes that only apply to Document objects
@ -608,3 +614,32 @@ partial interface Document {
[ChromeOnly]
void setRDMPaneOrientation(OrientationType type, float rotationAngle);
};
// Extension to give chrome JS the ability to specify a non-default keypress
// event model.
partial interface Document {
/**
* setKeyPressEventModel() is called when we need to check whether the web
* app requires specific keypress event model or not.
*
* @param aKeyPressEventModel Proper keypress event model for the web app.
* KEYPRESS_EVENT_MODEL_DEFAULT:
* Use default keypress event model. I.e., depending on
* "dom.keyboardevent.keypress.set_keycode_and_charcode_to_same_value"
* pref.
* KEYPRESS_EVENT_MODEL_SPLIT:
* Use split model. I.e, if keypress event inputs a character,
* keyCode should be 0. Otherwise, charCode should be 0.
* KEYPRESS_EVENT_MODEL_CONFLATED:
* Use conflated model. I.e., keyCode and charCode values of each
* keypress event should be set to same value.
*/
[ChromeOnly]
const unsigned short KEYPRESS_EVENT_MODEL_DEFAULT = 0;
[ChromeOnly]
const unsigned short KEYPRESS_EVENT_MODEL_SPLIT = 1;
[ChromeOnly]
const unsigned short KEYPRESS_EVENT_MODEL_CONFLATED = 2;
[ChromeOnly]
void setKeyPressEventModel(unsigned short aKeyPressEventModel);
};

View File

@ -10,22 +10,6 @@ interface HTMLDocument : Document {
[Throws]
getter object (DOMString name);
[CEReactions, SetterThrows, SetterNeedsSubjectPrincipal]
attribute DOMString designMode;
[CEReactions, Throws, NeedsSubjectPrincipal]
boolean execCommand(DOMString commandId, optional boolean showUI = false,
optional DOMString value = "");
[Throws, NeedsSubjectPrincipal]
boolean queryCommandEnabled(DOMString commandId);
[Throws]
boolean queryCommandIndeterm(DOMString commandId);
[Throws]
boolean queryCommandState(DOMString commandId);
[NeedsCallerType]
boolean queryCommandSupported(DOMString commandId);
[Throws]
DOMString queryCommandValue(DOMString commandId);
[CEReactions] attribute [TreatNullAs=EmptyString] DOMString fgColor;
[CEReactions] attribute [TreatNullAs=EmptyString] DOMString linkColor;
[CEReactions] attribute [TreatNullAs=EmptyString] DOMString vlinkColor;
@ -61,29 +45,4 @@ partial interface HTMLDocument {
[ChromeOnly]
void userInteractionForTesting();
/**
* setKeyPressEventModel() is called when we need to check whether the web
* app requires specific keypress event model or not.
*
* @param aKeyPressEventModel Proper keypress event model for the web app.
* KEYPRESS_EVENT_MODEL_DEFAULT:
* Use default keypress event model. I.e., depending on
* "dom.keyboardevent.keypress.set_keycode_and_charcode_to_same_value"
* pref.
* KEYPRESS_EVENT_MODEL_SPLIT:
* Use split model. I.e, if keypress event inputs a character,
* keyCode should be 0. Otherwise, charCode should be 0.
* KEYPRESS_EVENT_MODEL_CONFLATED:
* Use conflated model. I.e., keyCode and charCode values of each
* keypress event should be set to same value.
*/
[ChromeOnly]
const unsigned short KEYPRESS_EVENT_MODEL_DEFAULT = 0;
[ChromeOnly]
const unsigned short KEYPRESS_EVENT_MODEL_SPLIT = 1;
[ChromeOnly]
const unsigned short KEYPRESS_EVENT_MODEL_CONFLATED = 2;
[ChromeOnly]
void setKeyPressEventModel(unsigned short aKeyPressEventModel);
};

View File

@ -312,11 +312,8 @@ nsEditingSession::SetupEditorOnWindow(mozIDOMWindowProxy* aWindow) {
doc->FlushPendingNotifications(mozilla::FlushType::Frames);
if (mMakeWholeDocumentEditable) {
doc->SetEditableFlag(true);
nsCOMPtr<nsIHTMLDocument> htmlDocument = do_QueryInterface(doc);
if (htmlDocument) {
// Enable usage of the execCommand API
htmlDocument->SetEditingState(nsIHTMLDocument::eDesignMode);
}
// Enable usage of the execCommand API
doc->SetEditingState(Document::EditingState::eDesignMode);
}
}
bool needHTMLController = false;
@ -504,8 +501,7 @@ nsEditingSession::TearDownEditorOnWindow(mozIDOMWindowProxy* aWindow) {
auto* window = nsPIDOMWindowOuter::From(aWindow);
RefPtr<Document> doc = window->GetDoc();
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(doc);
bool stopEditing = htmlDoc && htmlDoc->IsEditingOn();
bool stopEditing = doc && doc->IsEditingOn();
if (stopEditing) {
RemoveWebProgressListener(window);
}
@ -515,7 +511,7 @@ nsEditingSession::TearDownEditorOnWindow(mozIDOMWindowProxy* aWindow) {
RefPtr<HTMLEditor> htmlEditor = docShell->GetHTMLEditor();
if (stopEditing) {
htmlDoc->TearingDownEditor();
doc->TearingDownEditor();
}
if (mComposerCommandsUpdater && htmlEditor) {
@ -537,10 +533,7 @@ nsEditingSession::TearDownEditorOnWindow(mozIDOMWindowProxy* aWindow) {
if (mMakeWholeDocumentEditable) {
doc->SetEditableFlag(false);
nsCOMPtr<nsIHTMLDocument> htmlDocument = do_QueryInterface(doc);
if (htmlDocument) {
htmlDocument->SetEditingState(nsIHTMLDocument::eOff);
}
doc->SetEditingState(Document::EditingState::eOff);
}
}

View File

@ -448,8 +448,7 @@ bool EditorBase::GetDesiredSpellCheckState() {
// Some of the page content might be editable and some not, if spellcheck=
// is explicitly set anywhere, so if there's anything editable on the page,
// return true and let the spellchecker figure it out.
nsCOMPtr<nsIHTMLDocument> doc =
do_QueryInterface(content->GetComposedDoc());
Document* doc = content->GetComposedDoc();
return doc && doc->IsEditingOn();
}

View File

@ -383,12 +383,12 @@ nsresult HTMLEditRules::BeforeEdit(EditSubAction aEditSubAction,
}
// Stabilize the document against contenteditable count changes
nsHTMLDocument* htmlDoc = HTMLEditorRef().GetHTMLDocument();
if (NS_WARN_IF(!htmlDoc)) {
Document* doc = HTMLEditorRef().GetDocument();
if (NS_WARN_IF(!doc)) {
return NS_ERROR_FAILURE;
}
if (htmlDoc->GetEditingState() == nsIHTMLDocument::eContentEditable) {
htmlDoc->ChangeContentEditableCount(nullptr, +1);
if (doc->GetEditingState() == Document::EditingState::eContentEditable) {
doc->ChangeContentEditableCount(nullptr, +1);
mRestoreContentEditableCount = true;
}
@ -432,12 +432,12 @@ nsresult HTMLEditRules::AfterEdit(EditSubAction aEditSubAction,
// Reset the contenteditable count to its previous value
if (mRestoreContentEditableCount) {
nsHTMLDocument* htmlDoc = HTMLEditorRef().GetHTMLDocument();
if (NS_WARN_IF(!htmlDoc)) {
Document* doc = HTMLEditorRef().GetDocument();
if (NS_WARN_IF(!doc)) {
return NS_ERROR_FAILURE;
}
if (htmlDoc->GetEditingState() == nsIHTMLDocument::eContentEditable) {
htmlDoc->ChangeContentEditableCount(nullptr, -1);
if (doc->GetEditingState() == Document::EditingState::eContentEditable) {
doc->ChangeContentEditableCount(nullptr, -1);
}
mRestoreContentEditableCount = false;
}

View File

@ -1191,7 +1191,7 @@ class PresShell final : public nsStubDocumentObserver,
void SetKeyPressEventModel(uint16_t aKeyPressEventModel) {
mForceUseLegacyKeyCodeAndCharCodeValues |=
aKeyPressEventModel ==
dom::HTMLDocument_Binding::KEYPRESS_EVENT_MODEL_SPLIT;
dom::Document_Binding::KEYPRESS_EVENT_MODEL_SPLIT;
}
bool AddRefreshObserver(nsARefreshObserver* aObserver, FlushType aFlushType);

View File

@ -1,26 +1,5 @@
prefs: [dom.security.featurePolicy.enabled:true]
[interfaces.https.html?include=(Document|Window)]
[Document interface: attribute designMode]
expected: FAIL
[Document interface: operation execCommand(DOMString, boolean, DOMString)]
expected: FAIL
[Document interface: operation queryCommandEnabled(DOMString)]
expected: FAIL
[Document interface: operation queryCommandIndeterm(DOMString)]
expected: FAIL
[Document interface: operation queryCommandState(DOMString)]
expected: FAIL
[Document interface: operation queryCommandSupported(DOMString)]
expected: FAIL
[Document interface: operation queryCommandValue(DOMString)]
expected: FAIL
[Document interface: attribute fgColor]
expected: FAIL
@ -66,45 +45,6 @@ prefs: [dom.security.featurePolicy.enabled:true]
[Document interface: iframe.contentDocument must inherit property "onsecuritypolicyviolation" with the proper type]
expected: FAIL
[Document interface: new Document() must inherit property "designMode" with the proper type]
expected: FAIL
[Document interface: new Document() must inherit property "execCommand(DOMString, boolean, DOMString)" with the proper type]
expected: FAIL
[Document interface: calling execCommand(DOMString, boolean, DOMString) on new Document() with too few arguments must throw TypeError]
expected: FAIL
[Document interface: new Document() must inherit property "queryCommandEnabled(DOMString)" with the proper type]
expected: FAIL
[Document interface: calling queryCommandEnabled(DOMString) on new Document() with too few arguments must throw TypeError]
expected: FAIL
[Document interface: new Document() must inherit property "queryCommandIndeterm(DOMString)" with the proper type]
expected: FAIL
[Document interface: calling queryCommandIndeterm(DOMString) on new Document() with too few arguments must throw TypeError]
expected: FAIL
[Document interface: new Document() must inherit property "queryCommandState(DOMString)" with the proper type]
expected: FAIL
[Document interface: calling queryCommandState(DOMString) on new Document() with too few arguments must throw TypeError]
expected: FAIL
[Document interface: new Document() must inherit property "queryCommandSupported(DOMString)" with the proper type]
expected: FAIL
[Document interface: calling queryCommandSupported(DOMString) on new Document() with too few arguments must throw TypeError]
expected: FAIL
[Document interface: new Document() must inherit property "queryCommandValue(DOMString)" with the proper type]
expected: FAIL
[Document interface: calling queryCommandValue(DOMString) on new Document() with too few arguments must throw TypeError]
expected: FAIL
[Document interface: new Document() must inherit property "fgColor" with the proper type]
expected: FAIL
@ -138,45 +78,6 @@ prefs: [dom.security.featurePolicy.enabled:true]
[Document interface: new Document() must inherit property "onsecuritypolicyviolation" with the proper type]
expected: FAIL
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "designMode" with the proper type]
expected: FAIL
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "execCommand(DOMString, boolean, DOMString)" with the proper type]
expected: FAIL
[Document interface: calling execCommand(DOMString, boolean, DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError]
expected: FAIL
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "queryCommandEnabled(DOMString)" with the proper type]
expected: FAIL
[Document interface: calling queryCommandEnabled(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError]
expected: FAIL
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "queryCommandIndeterm(DOMString)" with the proper type]
expected: FAIL
[Document interface: calling queryCommandIndeterm(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError]
expected: FAIL
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "queryCommandState(DOMString)" with the proper type]
expected: FAIL
[Document interface: calling queryCommandState(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError]
expected: FAIL
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "queryCommandSupported(DOMString)" with the proper type]
expected: FAIL
[Document interface: calling queryCommandSupported(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError]
expected: FAIL
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "queryCommandValue(DOMString)" with the proper type]
expected: FAIL
[Document interface: calling queryCommandValue(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError]
expected: FAIL
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "fgColor" with the proper type]
expected: FAIL

View File

@ -16,7 +16,7 @@ class KeyPressEventModelCheckerChild extends ActorChild {
// Currently, the event is dispatched only when the document becomes editable
// because of contenteditable. If you need to add new editor which is in
// designMode, you need to change MaybeDispatchCheckKeyPressEventModelEvent()
// of nsHTMLDocument.
// of Document.
handleEvent(aEvent) {
if (!AppConstants.DEBUG) {
// Stop propagation in opt build to save the propagation cost.
@ -25,13 +25,13 @@ class KeyPressEventModelCheckerChild extends ActorChild {
aEvent.stopImmediatePropagation();
}
// Currently, even if we set HTMLDocument.KEYPRESS_EVENT_MODEL_CONFLATED
// Currently, even if we set Document.KEYPRESS_EVENT_MODEL_CONFLATED
// here, conflated model isn't used forcibly. If you need it, you need
// to change WidgetKeyboardEvent, dom::KeyboardEvent and PresShell.
let model = HTMLDocument.KEYPRESS_EVENT_MODEL_DEFAULT;
let model = Document.KEYPRESS_EVENT_MODEL_DEFAULT;
if (this._isOldOfficeOnlineServer(aEvent.target) ||
this._isOldConfluence(aEvent.target.ownerGlobal)) {
model = HTMLDocument.KEYPRESS_EVENT_MODEL_SPLIT;
model = Document.KEYPRESS_EVENT_MODEL_SPLIT;
}
aEvent.target.setKeyPressEventModel(model);
}