mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1717156 - part 5: Get rid of nsIEditor::eEditorNoCSSMask
r=m_kato
Now, `nsIEditor::eEditorNoCSSMask` is used only in the editor internally. And it's available and meaningful only with `HTMLEditor` instance. So, we can get rid of it from `EditorBase`. Fortunately, `HTMLEditor` always creates `CSSEditUtils` and it stores the raw value indicating whether the editor manager enabled or disabled CSS. Therefore, we don't need new member variable in `HTMLEditor` for storing the flag. And this allows us to remove `nsIEditor::SetFlags()` override of `HTMLEditor`. Differential Revision: https://phabricator.services.mozilla.com/D118265
This commit is contained in:
parent
148a74cbc3
commit
e178e6da17
@ -690,9 +690,6 @@ NS_IMETHODIMP EditorBase::SetFlags(uint32_t aFlags) {
|
||||
// eEditorMailMask specifies the editing rules of `HTMLEditor`. So, it's
|
||||
// available only with `HTMLEditor` instance.
|
||||
MOZ_ASSERT_IF(IsTextEditor(), !(aFlags & nsIEditor::eEditorMailMask));
|
||||
// eEditorNoCSSMask specifies the editing rules of `HTMLEditor`. So, it's
|
||||
// available only with `HTMLEditor` instance.
|
||||
MOZ_ASSERT_IF(IsTextEditor(), !(aFlags & nsIEditor::eEditorNoCSSMask));
|
||||
// eEditorAllowInteraction changes the behavior of `HTMLEditor`. So, it's
|
||||
// not available with `TextEditor` instance.
|
||||
MOZ_ASSERT_IF(IsTextEditor(), !(aFlags & nsIEditor::eEditorAllowInteraction));
|
||||
|
@ -594,12 +594,6 @@ class EditorBase : public nsIEditor,
|
||||
return (mFlags & nsIEditor::eEditorEnableWrapHackMask) != 0;
|
||||
}
|
||||
|
||||
bool NoCSS() const {
|
||||
const bool isNoCSS = (mFlags & nsIEditor::eEditorNoCSSMask) != 0;
|
||||
MOZ_ASSERT_IF(!isNoCSS, IsHTMLEditor());
|
||||
return isNoCSS;
|
||||
}
|
||||
|
||||
bool IsInteractionAllowed() const {
|
||||
const bool isInteractionAllowed =
|
||||
(mFlags & nsIEditor::eEditorAllowInteraction) != 0;
|
||||
|
@ -97,7 +97,6 @@ struct MOZ_STACK_CLASS SavedRange final {
|
||||
|
||||
HTMLEditor::HTMLEditor()
|
||||
: mCRInParagraphCreatesParagraph(false),
|
||||
mCSSAware(false),
|
||||
mIsObjectResizingEnabled(
|
||||
StaticPrefs::editor_resizing_enabled_by_default()),
|
||||
mIsResizing(false),
|
||||
@ -625,21 +624,6 @@ void HTMLEditor::RemoveEventListeners() {
|
||||
EditorBase::RemoveEventListeners();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP HTMLEditor::SetFlags(uint32_t aFlags) {
|
||||
nsresult rv = EditorBase::SetFlags(aFlags);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("EditorBase::SetFlags() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Sets mCSSAware to correspond to aFlags. This toggles whether CSS is
|
||||
// used to style elements in the editor. Note that the editor is only CSS
|
||||
// aware by default in Composer and in the mail editor.
|
||||
mCSSAware = !NoCSS() && !IsMailEditor();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP HTMLEditor::BeginningOfDocument() {
|
||||
AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);
|
||||
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
||||
@ -5104,20 +5088,7 @@ NS_IMETHODIMP HTMLEditor::SetIsCSSEnabled(bool aIsCSSPrefChecked) {
|
||||
}
|
||||
|
||||
mCSSEditUtils->SetCSSEnabled(aIsCSSPrefChecked);
|
||||
|
||||
// Disable the eEditorNoCSSMask flag if we're enabling StyleWithCSS.
|
||||
uint32_t flags = mFlags;
|
||||
if (aIsCSSPrefChecked) {
|
||||
// Turn off NoCSS as we're enabling CSS
|
||||
flags &= ~eEditorNoCSSMask;
|
||||
} else {
|
||||
// Turn on NoCSS, as we're disabling CSS.
|
||||
flags |= eEditorNoCSSMask;
|
||||
}
|
||||
|
||||
nsresult rv = SetFlags(flags);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "HTMLEditor::SetFlags() failed");
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Set the block background color
|
||||
|
@ -152,7 +152,6 @@ class HTMLEditor final : public EditorBase,
|
||||
uint32_t aFlags,
|
||||
const nsAString& aValue) final;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD BeginningOfDocument() final;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD SetFlags(uint32_t aFlags) final;
|
||||
|
||||
NS_IMETHOD GetDocumentCharacterSet(nsACString& aCharacterSet) final;
|
||||
MOZ_CAN_RUN_SCRIPT NS_IMETHOD
|
||||
@ -353,8 +352,8 @@ class HTMLEditor final : public EditorBase,
|
||||
* align attribute to align contents, returns false.
|
||||
*/
|
||||
bool IsCSSEnabled() const {
|
||||
// TODO: removal of mCSSAware and use only the presence of mCSSEditUtils
|
||||
return mCSSAware && mCSSEditUtils && mCSSEditUtils->IsCSSPrefChecked();
|
||||
return !IsMailEditor() && mCSSEditUtils &&
|
||||
mCSSEditUtils->IsCSSPrefChecked();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4319,7 +4318,6 @@ class HTMLEditor final : public EditorBase,
|
||||
|
||||
bool mCRInParagraphCreatesParagraph;
|
||||
|
||||
bool mCSSAware;
|
||||
UniquePtr<CSSEditUtils> mCSSEditUtils;
|
||||
|
||||
// resizing
|
||||
|
@ -69,9 +69,6 @@ interface nsIEditor : nsISupports
|
||||
const long eEditorMailMask = 0x0020;
|
||||
// allow the editor to set font: monospace on the root node
|
||||
const long eEditorEnableWrapHackMask = 0x0040;
|
||||
// If you want an HTML editor to set style of text with legacy HTML inline
|
||||
// elements, specify this flag. So, this is not available with text editors.
|
||||
const long eEditorNoCSSMask = 0x0100;
|
||||
// If you want to move focus from an HTML editor with tab navigation,
|
||||
// specify this flag. This is not available with text editors becase
|
||||
// it's always tabbable.
|
||||
|
Loading…
Reference in New Issue
Block a user