Bug 1611751 - Remove unused scriptable methods of `nsIHTMLEditor`, `nsIEditorStyleSheets` and `nsITableEditor` r=m_kato

* `nsIHTMLEditor.removeAllInlineProperties`
* `nsIHTMLEditor.increaseFontSize`
* `nsIHTMLEditor.decreaseFontSize`
* `nsIHTMLEditor.setParagraphFormat`
* `nsIHTMLEditor.getBackgroundColorState`
* `nsIHTMLEditor.indent`
* `nsIHTMLEditor.align`
* `nsIEditorStyleSheets.replaceOverrideStyleSheet`
* `nsITableEditor.selectBlockOfCells`

These methods are not used by any Gecko products including comm-central and
BlueGriffon so that we should remove them.  Note that only
`HTMLEditor::GetBackgroundColorState()` is used internally so that we need to
keep it as a public method of `HTMLEditor`.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2020-01-30 08:50:41 +00:00
Родитель f071c7231c
Коммит f506f1f653
9 изменённых файлов: 13 добавлений и 284 удалений

Просмотреть файл

@ -306,10 +306,6 @@ enum class EditAction {
// eRemoveOverrideStyleSheet indicates to remove override style sheet. // eRemoveOverrideStyleSheet indicates to remove override style sheet.
eRemoveOverrideStyleSheet, eRemoveOverrideStyleSheet,
// eReplaceOverrideStyleSheet indicates to replace added override style
// sheet with new override style sheet.
eReplaceOverrideStyleSheet,
// eEnableStyleSheet indicates to apply a style sheet. // eEnableStyleSheet indicates to apply a style sheet.
eEnableStyleSheet, eEnableStyleSheet,

Просмотреть файл

@ -1062,7 +1062,6 @@ class EditorBase : public nsIPlaintextEditor,
// We don't need to let web apps know changing UA stylesheet. // We don't need to let web apps know changing UA stylesheet.
case EditAction::eAddOverrideStyleSheet: case EditAction::eAddOverrideStyleSheet:
case EditAction::eRemoveOverrideStyleSheet: case EditAction::eRemoveOverrideStyleSheet:
case EditAction::eReplaceOverrideStyleSheet:
// We don't need to let web apps know the mode change. // We don't need to let web apps know the mode change.
case EditAction::eEnableStyleSheet: case EditAction::eEnableStyleSheet:
case EditAction::eEnableOrDisableCSS: case EditAction::eEnableOrDisableCSS:

Просмотреть файл

@ -1824,13 +1824,6 @@ nsresult HTMLEditor::CollapseSelectionAfter(Element& aElement) {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
HTMLEditor::SetParagraphFormat(const nsAString& aParagraphFormat) {
nsresult rv = SetParagraphFormatAsAction(aParagraphFormat);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to set paragraph format");
return rv;
}
nsresult HTMLEditor::SetParagraphFormatAsAction( nsresult HTMLEditor::SetParagraphFormatAsAction(
const nsAString& aParagraphFormat, nsIPrincipal* aPrincipal) { const nsAString& aParagraphFormat, nsIPrincipal* aPrincipal) {
AutoEditActionDataSetter editActionData( AutoEditActionDataSetter editActionData(
@ -1882,8 +1875,8 @@ HTMLEditor::GetParagraphState(bool* aMixed, nsAString& aFirstParagraphState) {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsresult HTMLEditor::GetBackgroundColorState(bool* aMixed,
HTMLEditor::GetBackgroundColorState(bool* aMixed, nsAString& aOutColor) { nsAString& aOutColor) {
if (NS_WARN_IF(!aMixed)) { if (NS_WARN_IF(!aMixed)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -2278,21 +2271,6 @@ nsresult HTMLEditor::FormatBlockContainerAsSubAction(nsAtom& aTagName) {
return rv; return rv;
} }
NS_IMETHODIMP
HTMLEditor::Indent(const nsAString& aIndent) {
if (aIndent.LowerCaseEqualsLiteral("indent")) {
nsresult rv = IndentAsAction();
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to indent");
return rv;
}
if (aIndent.LowerCaseEqualsLiteral("outdent")) {
nsresult rv = OutdentAsAction();
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to outdent");
return rv;
}
return NS_ERROR_INVALID_ARG;
}
nsresult HTMLEditor::IndentAsAction(nsIPrincipal* aPrincipal) { nsresult HTMLEditor::IndentAsAction(nsIPrincipal* aPrincipal) {
if (NS_WARN_IF(!mInitSucceeded)) { if (NS_WARN_IF(!mInitSucceeded)) {
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
@ -2329,13 +2307,6 @@ nsresult HTMLEditor::OutdentAsAction(nsIPrincipal* aPrincipal) {
// TODO: IMPLEMENT ALIGNMENT! // TODO: IMPLEMENT ALIGNMENT!
NS_IMETHODIMP
HTMLEditor::Align(const nsAString& aAlignType) {
nsresult rv = AlignAsAction(aAlignType);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to align content");
return EditorBase::ToGenericNSResult(rv);
}
nsresult HTMLEditor::AlignAsAction(const nsAString& aAlignType, nsresult HTMLEditor::AlignAsAction(const nsAString& aAlignType,
nsIPrincipal* aPrincipal) { nsIPrincipal* aPrincipal) {
AutoEditActionDataSetter editActionData( AutoEditActionDataSetter editActionData(
@ -2918,9 +2889,6 @@ nsresult HTMLEditor::AddOverrideStyleSheetInternal(const nsAString& aURL) {
presShell->AddOverrideStyleSheet(sheet); presShell->AddOverrideStyleSheet(sheet);
presShell->GetDocument()->ApplicableStylesChanged(); presShell->GetDocument()->ApplicableStylesChanged();
// Save as the last-loaded sheet
mLastOverrideStyleSheetURL = aURL;
// Add URL and style sheet to our lists // Add URL and style sheet to our lists
rv = AddNewStyleSheetToList(aURL, sheet); rv = AddNewStyleSheetToList(aURL, sheet);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
@ -2929,37 +2897,6 @@ nsresult HTMLEditor::AddOverrideStyleSheetInternal(const nsAString& aURL) {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
HTMLEditor::ReplaceOverrideStyleSheet(const nsAString& aURL) {
AutoEditActionDataSetter editActionData(
*this, EditAction::eReplaceOverrideStyleSheet);
if (NS_WARN_IF(!editActionData.CanHandle())) {
return NS_ERROR_NOT_INITIALIZED;
}
// Enable existing sheet if already loaded.
if (EnableExistingStyleSheet(aURL)) {
// Disable last sheet if not the same as new one
if (!mLastOverrideStyleSheetURL.IsEmpty() &&
!mLastOverrideStyleSheetURL.Equals(aURL)) {
EnableStyleSheetInternal(mLastOverrideStyleSheetURL, false);
}
return NS_OK;
}
// Remove the previous sheet
if (!mLastOverrideStyleSheetURL.IsEmpty()) {
DebugOnly<nsresult> rv =
RemoveOverrideStyleSheetInternal(mLastOverrideStyleSheetURL);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"Failed to remove the last override style sheet");
}
nsresult rv = AddOverrideStyleSheetInternal(aURL);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
return NS_OK;
}
// Do NOT use transaction system for override style sheets // Do NOT use transaction system for override style sheets
NS_IMETHODIMP NS_IMETHODIMP
HTMLEditor::RemoveOverrideStyleSheet(const nsAString& aURL) { HTMLEditor::RemoveOverrideStyleSheet(const nsAString& aURL) {

Просмотреть файл

@ -174,6 +174,15 @@ class HTMLEditor final : public TextEditor,
virtual bool IsAcceptableInputEvent(WidgetGUIEvent* aGUIEvent) override; virtual bool IsAcceptableInputEvent(WidgetGUIEvent* aGUIEvent) override;
virtual nsresult GetPreferredIMEState(widget::IMEState* aState) override; virtual nsresult GetPreferredIMEState(widget::IMEState* aState) override;
/**
* GetBackgroundColorState() returns what the background color of the
* selection.
*
* @param aMixed true if there is more than one font color
* @param aOutColor Color string. "" is returned for none.
*/
nsresult GetBackgroundColorState(bool* aMixed, nsAString& aOutColor);
/** /**
* PasteNoFormatting() pastes content in clipboard without any style * PasteNoFormatting() pastes content in clipboard without any style
* information. * information.
@ -4370,9 +4379,6 @@ class HTMLEditor final : public TextEditor,
// GetNextSelectedTableCellElement(). // GetNextSelectedTableCellElement().
mutable uint32_t mSelectedCellIndex; mutable uint32_t mSelectedCellIndex;
nsString mLastStyleSheetURL;
nsString mLastOverrideStyleSheetURL;
// Maintain a list of associated style sheets and their urls. // Maintain a list of associated style sheets and their urls.
nsTArray<nsString> mStyleSheetURLs; nsTArray<nsString> mStyleSheetURLs;
nsTArray<RefPtr<StyleSheet>> mStyleSheets; nsTArray<RefPtr<StyleSheet>> mStyleSheets;

Просмотреть файл

@ -1420,13 +1420,6 @@ nsresult HTMLEditor::GetInlinePropertyWithAttrValue(
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
HTMLEditor::RemoveAllInlineProperties() {
nsresult rv = RemoveAllInlinePropertiesAsAction();
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to remove all inline styles");
return rv;
}
nsresult HTMLEditor::RemoveAllInlinePropertiesAsAction( nsresult HTMLEditor::RemoveAllInlinePropertiesAsAction(
nsIPrincipal* aPrincipal) { nsIPrincipal* aPrincipal) {
AutoEditActionDataSetter editActionData( AutoEditActionDataSetter editActionData(
@ -1850,13 +1843,6 @@ void HTMLEditor::CollectEditableLeafTextNodes(
} }
} }
NS_IMETHODIMP
HTMLEditor::IncreaseFontSize() {
nsresult rv = IncreaseFontSizeAsAction();
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to increase font size");
return rv;
}
nsresult HTMLEditor::IncreaseFontSizeAsAction(nsIPrincipal* aPrincipal) { nsresult HTMLEditor::IncreaseFontSizeAsAction(nsIPrincipal* aPrincipal) {
AutoEditActionDataSetter editActionData(*this, EditAction::eIncrementFontSize, AutoEditActionDataSetter editActionData(*this, EditAction::eIncrementFontSize,
aPrincipal); aPrincipal);
@ -1871,13 +1857,6 @@ nsresult HTMLEditor::IncreaseFontSizeAsAction(nsIPrincipal* aPrincipal) {
return EditorBase::ToGenericNSResult(rv); return EditorBase::ToGenericNSResult(rv);
} }
NS_IMETHODIMP
HTMLEditor::DecreaseFontSize() {
nsresult rv = DecreaseFontSizeAsAction();
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to decrease font size");
return rv;
}
nsresult HTMLEditor::DecreaseFontSizeAsAction(nsIPrincipal* aPrincipal) { nsresult HTMLEditor::DecreaseFontSizeAsAction(nsIPrincipal* aPrincipal) {
AutoEditActionDataSetter editActionData(*this, EditAction::eDecrementFontSize, AutoEditActionDataSetter editActionData(*this, EditAction::eDecrementFontSize,
aPrincipal); aPrincipal);

Просмотреть файл

@ -1787,121 +1787,6 @@ HTMLEditor::SelectTableCell() {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
HTMLEditor::SelectBlockOfCells(Element* aStartCell, Element* aEndCell) {
if (NS_WARN_IF(!aStartCell) || NS_WARN_IF(!aEndCell)) {
return NS_ERROR_INVALID_ARG;
}
AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);
if (NS_WARN_IF(!editActionData.CanHandle())) {
return NS_ERROR_NOT_INITIALIZED;
}
RefPtr<Element> table =
GetElementOrParentByTagNameInternal(*nsGkAtoms::table, *aStartCell);
if (NS_WARN_IF(!table)) {
return NS_ERROR_FAILURE;
}
RefPtr<Element> endTable =
GetElementOrParentByTagNameInternal(*nsGkAtoms::table, *aEndCell);
if (NS_WARN_IF(!endTable)) {
return NS_ERROR_FAILURE;
}
// We can only select a block if within the same table,
// so do nothing if not within one table
if (table != endTable) {
return NS_OK;
}
ErrorResult error;
CellIndexes startCellIndexes(*aStartCell, error);
if (NS_WARN_IF(error.Failed())) {
return EditorBase::ToGenericNSResult(error.StealNSResult());
}
CellIndexes endCellIndexes(*aEndCell, error);
if (NS_WARN_IF(error.Failed())) {
return EditorBase::ToGenericNSResult(error.StealNSResult());
}
// Suppress nsISelectionListener notification
// until all selection changes are finished
SelectionBatcher selectionBatcher(SelectionRefPtr());
// Examine all cell nodes in current selection and
// remove those outside the new block cell region
int32_t minColumn =
std::min(startCellIndexes.mColumn, endCellIndexes.mColumn);
int32_t minRow = std::min(startCellIndexes.mRow, endCellIndexes.mRow);
int32_t maxColumn =
std::max(startCellIndexes.mColumn, endCellIndexes.mColumn);
int32_t maxRow = std::max(startCellIndexes.mRow, endCellIndexes.mRow);
RefPtr<Element> cell = GetFirstSelectedTableCellElement(error);
if (NS_WARN_IF(error.Failed())) {
return EditorBase::ToGenericNSResult(error.StealNSResult());
}
if (!cell) {
return NS_OK;
}
RefPtr<nsRange> range = SelectionRefPtr()->GetRangeAt(0);
MOZ_ASSERT(range);
while (cell) {
CellIndexes currentCellIndexes(*cell, error);
if (NS_WARN_IF(error.Failed())) {
return EditorBase::ToGenericNSResult(error.StealNSResult());
}
if (currentCellIndexes.mRow < maxRow || currentCellIndexes.mRow > maxRow ||
currentCellIndexes.mColumn < maxColumn ||
currentCellIndexes.mColumn > maxColumn) {
SelectionRefPtr()->RemoveRangeAndUnselectFramesAndNotifyListeners(
*range, IgnoreErrors());
// Since we've removed the range, decrement pointer to next range
MOZ_ASSERT(mSelectedCellIndex > 0);
mSelectedCellIndex--;
}
cell = GetNextSelectedTableCellElement(error);
if (NS_WARN_IF(error.Failed())) {
return EditorBase::ToGenericNSResult(error.StealNSResult());
}
if (cell) {
MOZ_ASSERT(mSelectedCellIndex > 0);
range = SelectionRefPtr()->GetRangeAt(mSelectedCellIndex - 1);
}
}
nsresult rv = NS_OK;
IgnoredErrorResult ignoredError;
for (int32_t row = minRow; row <= maxRow; row++) {
CellData cellData;
for (int32_t col = minColumn; col <= maxColumn;
col = cellData.NextColumnIndex()) {
cellData.Update(*this, *table, row, col, ignoredError);
if (cellData.FailedOrNotFound()) {
return NS_ERROR_FAILURE;
}
// Skip cells that already selected or are spanned from previous locations
// XXX So, we should distinguish whether CellData returns error or just
// not found later.
if (!cellData.mIsSelected && cellData.mElement &&
!cellData.IsSpannedFromOtherRowOrColumn()) {
rv = AppendNodeToSelectionAsRange(cellData.mElement);
if (NS_FAILED(rv)) {
break;
}
}
MOZ_ASSERT(col < cellData.NextColumnIndex());
}
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return EditorBase::ToGenericNSResult(rv);
}
return rv;
}
NS_IMETHODIMP NS_IMETHODIMP
HTMLEditor::SelectAllTableCells() { HTMLEditor::SelectAllTableCells() {
AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing); AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);

Просмотреть файл

@ -8,8 +8,8 @@
[scriptable, builtinclass, uuid(4805e682-49b9-11d3-9ce4-ed60bd6cb5bc)] [scriptable, builtinclass, uuid(4805e682-49b9-11d3-9ce4-ed60bd6cb5bc)]
interface nsIEditorStyleSheets : nsISupports interface nsIEditorStyleSheets : nsISupports
{ {
/** Load and apply the override style sheet, specified by aURL, to the /** Load and apply an override style sheet, specified by aURL, to
* editor's document, replacing the last override style sheet added (if any). * the editor's document, on top of any that are already there.
* This is always synchronous, so aURL should be a local file with only * This is always synchronous, so aURL should be a local file with only
* local @imports. This action is not undoable. It is not intended for * local @imports. This action is not undoable. It is not intended for
* "user" style sheets, only for editor developers to add sheets to change * "user" style sheets, only for editor developers to add sheets to change
@ -19,15 +19,6 @@ interface nsIEditorStyleSheets : nsISupports
* *
* @param aURL The style sheet to be loaded and applied. * @param aURL The style sheet to be loaded and applied.
*/ */
void replaceOverrideStyleSheet(in AString aURL);
/** Load and apply an override style sheet, specified by aURL, to
* the editor's document, on top of any that are already there.
* This is always synchronous, so the same caveats about local files and no
* non-local @import as replaceOverrideStyleSheet apply here, too.
*
* @param aURL The style sheet to be loaded and applied.
*/
void addOverrideStyleSheet(in AString aURL); void addOverrideStyleSheet(in AString aURL);
/** Remove the given override style sheet from the editor's document /** Remove the given override style sheet from the editor's document

Просмотреть файл

@ -80,14 +80,6 @@ interface nsIHTMLEditor : nsISupports
out boolean aAny, out boolean aAny,
out boolean aAll); out boolean aAll);
/**
* removeAllInlineProperties() deletes all the inline properties from all
* text in the current selection.
*/
[can_run_script]
void removeAllInlineProperties();
/** /**
* removeInlineProperty() removes a property which changes inline style of * removeInlineProperty() removes a property which changes inline style of
* text. E.g., bold, italic, super and sub. * text. E.g., bold, italic, super and sub.
@ -104,22 +96,6 @@ interface nsIHTMLEditor : nsISupports
[can_run_script] [can_run_script]
void removeInlineProperty(in AString aProperty, in AString aAttribute); void removeInlineProperty(in AString aProperty, in AString aAttribute);
/**
* Increase font size for text in selection by 1 HTML unit
* All existing text is scanned for existing <FONT SIZE> attributes
* so they will be incremented instead of inserting new <FONT> tag
*/
[can_run_script]
void increaseFontSize();
/**
* Decrease font size for text in selection by 1 HTML unit
* All existing text is scanned for existing <FONT SIZE> attributes
* so they will be decreased instead of inserting new <FONT> tag
*/
[can_run_script]
void decreaseFontSize();
/* ------------ HTML content methods -------------- */ /* ------------ HTML content methods -------------- */
/** /**
@ -206,13 +182,6 @@ interface nsIHTMLEditor : nsISupports
*/ */
void setCaretAfterElement(in Element aElement); void setCaretAfterElement(in Element aElement);
/**
* SetParagraphFormat Insert a block paragraph tag around selection
* @param aParagraphFormat "p", "h1" to "h6", "address", "pre", or "blockquote"
*/
[can_run_script]
void setParagraphFormat(in AString aParagraphFormat);
/** /**
* getParagraphState returns what block tag paragraph format is in * getParagraphState returns what block tag paragraph format is in
* the selection. * the selection.
@ -229,13 +198,6 @@ interface nsIHTMLEditor : nsISupports
*/ */
AString getFontFaceState(out boolean aMixed); AString getFontFaceState(out boolean aMixed);
/**
* getBackgroundColorState returns what the background color of the selection.
* @param aMixed True if there is more than one font color
* @return Color string. "" is returned for none.
*/
AString getBackgroundColorState(out boolean aMixed);
/** /**
* getHighlightColorState returns what the highlight color of the selection. * getHighlightColorState returns what the highlight color of the selection.
* @param aMixed True if there is more than one font color * @param aMixed True if there is more than one font color
@ -294,20 +256,6 @@ interface nsIHTMLEditor : nsISupports
[can_run_script] [can_run_script]
void removeList(in AString aListType); void removeList(in AString aListType);
/**
* Document me!
*
*/
[can_run_script]
void indent(in AString aIndent);
/**
* Document me!
*
*/
[can_run_script]
void align(in AString aAlign);
/** /**
* GetElementOrParentByTagName() looks for an element node whose name matches * GetElementOrParentByTagName() looks for an element node whose name matches
* aTagName from aNode or anchor node of Selection to <body> element. * aTagName from aNode or anchor node of Selection to <body> element.

Просмотреть файл

@ -158,18 +158,6 @@ interface nsITableEditor : nsISupports
[can_run_script] [can_run_script]
void selectTableCell(); void selectTableCell();
/** Select a rectangular block of cells:
* all cells falling within the row/column index of aStartCell
* to through the row/column index of the aEndCell
* aStartCell can be any location relative to aEndCell,
* as long as they are in the same table
* @param aStartCell starting cell in block
* @param aEndCell ending cell in block
*/
[can_run_script]
void selectBlockOfCells(in Element aStartCell,
in Element aEndCell);
[can_run_script] [can_run_script]
void selectTableRow(); void selectTableRow();
[can_run_script] [can_run_script]