Skip to content

Commit

Permalink
Bug 1717178 - part 4: Get rid of nsIHTMLEditor.getInlineProperty()
Browse files Browse the repository at this point in the history
…because of unused r=m_kato

Only `test_bug1140105.html` is its user, but it can be replaced with
`getInlinePropertyWithAttrValue()` since they do exactly same things:
https://searchfox.org/mozilla-central/rev/fc95c6ad297d9d257f05599d01741503f3f57326/editor/libeditor/HTMLStyleEditor.cpp#1685-1687,1719-1721

Depends on D118799

Differential Revision: https://phabricator.services.mozilla.com/D118800
  • Loading branch information
masayuki-nakano committed Jun 28, 2021
1 parent fd9224d commit f45ac00
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
24 changes: 24 additions & 0 deletions editor/libeditor/HTMLEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,33 @@ class HTMLEditor final : public EditorBase,
nsAtom& aProperty, nsAtom* aAttribute, const nsAString& aValue,
nsIPrincipal* aPrincipal = nullptr);

/**
* GetInlineProperty() gets aggregate properties of the current selection.
* All object in the current selection are scanned and their attributes are
* represented in a list of Property object.
* TODO: Make this return Result<Something> instead of bool out arguments.
*
* @param aHTMLProperty the property to get on the selection
* @param aAttribute the attribute of the property, if applicable.
* May be null.
* Example: aHTMLProperty=nsGkAtoms::font,
* aAttribute=nsGkAtoms::color
* @param aValue if aAttribute is not null, the value of the
* attribute. May be null.
* Example: aHTMLProperty=nsGkAtoms::font,
* aAttribute=nsGkAtoms::color,
* aValue="0x00FFFF"
* @param aFirst [OUT] true if the first text node in the
* selection has the property
* @param aAny [OUT] true if any of the text nodes in the
* selection have the property
* @param aAll [OUT] true if all of the text nodes in the
* selection have the property
*/
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult GetInlineProperty(
nsAtom* aHTMLProperty, nsAtom* aAttribute, const nsAString& aValue,
bool* aFirst, bool* aAny, bool* aAll) const;

[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult GetInlinePropertyWithAttrValue(
nsAtom* aHTMLProperty, nsAtom* aAttribute, const nsAString& aValue,
bool* aFirst, bool* aAny, bool* aAll, nsAString& outValue);
Expand Down
14 changes: 0 additions & 14 deletions editor/libeditor/HTMLStyleEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1654,20 +1654,6 @@ nsresult HTMLEditor::GetInlinePropertyBase(nsAtom& aHTMLProperty,
return NS_OK;
}

NS_IMETHODIMP HTMLEditor::GetInlineProperty(const nsAString& aHTMLProperty,
const nsAString& aAttribute,
const nsAString& aValue,
bool* aFirst, bool* aAny,
bool* aAll) {
RefPtr<nsAtom> property = NS_Atomize(aHTMLProperty);
nsStaticAtom* attribute = EditorUtils::GetAttributeAtom(aAttribute);
nsresult rv = GetInlineProperty(property, MOZ_KnownLive(attribute), aValue,
aFirst, aAny, aAll);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"HTMLEditor::GetInlineProperty() failed");
return rv;
}

nsresult HTMLEditor::GetInlineProperty(nsAtom* aHTMLProperty,
nsAtom* aAttribute,
const nsAString& aValue, bool* aFirst,
Expand Down
4 changes: 2 additions & 2 deletions editor/libeditor/tests/test_bug1140105.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
var allHas = {};
var editor = getEditor();

editor.getInlineProperty("font", "face", "Arial", firstHas, anyHas, allHas);
editor.getInlinePropertyWithAttrValue("font", "face", "Arial", firstHas, anyHas, allHas);
is(firstHas.value, true, "Test for Arial: firstHas: true expected");
is(anyHas.value, true, "Test for Arial: anyHas: true expected");
is(allHas.value, true, "Test for Arial: allHas: true expected");
editor.getInlineProperty("font", "face", "Courier", firstHas, anyHas, allHas);
editor.getInlinePropertyWithAttrValue("font", "face", "Courier", firstHas, anyHas, allHas);
is(firstHas.value, false, "Test for Courier: firstHas: false expected");
is(anyHas.value, false, "Test for Courier: anyHas: false expected");
is(allHas.value, false, "Test for Courier: allHas: false expected");
Expand Down
14 changes: 3 additions & 11 deletions editor/nsIHTMLEditor.idl
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ interface nsIHTMLEditor : nsISupports
in AString aValue);

/**
* getInlineProperty() gets aggregate properties of the current selection.
* All object in the current selection are scanned and their attributes are
* represented in a list of Property object.
* getInlinePropertyWithAttrValue() gets aggregate properties of the current
* selection. All object in the current selection are scanned and their
* attributes are represented in a list of Property object.
*
* @param aProperty the property to get on the selection
* @param aAttribute the attribute of the property, if applicable.
Expand All @@ -67,14 +67,6 @@ interface nsIHTMLEditor : nsISupports
* selection have the property
*/
[can_run_script]
void getInlineProperty(in AString aProperty,
in AString aAttribute,
in AString aValue,
out boolean aFirst,
out boolean aAny,
out boolean aAll);

[can_run_script]
AString getInlinePropertyWithAttrValue(in AString aProperty,
in AString aAttribute,
in AString aValue,
Expand Down

0 comments on commit f45ac00

Please sign in to comment.