forked from mirrors/gecko-dev
Bug 1485934 - Get rid of nsIHTMLEditor.getFontColorState() r=m_kato
Neither comm-central nor BlueGriffon uses nsIHTMLEditor.getFontColorSetate(). So, we can get rid of this from nsIHTMLEditor. However, we need to keep it as a non-virtual public method since it's used by FontColorStateCommand. Differential Revision: https://phabricator.services.mozilla.com/D4303 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
11a043ad55
commit
f4b10b4e0f
4 changed files with 40 additions and 13 deletions
|
|
@ -353,6 +353,33 @@ public:
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetFontColorState() returns foreground color information in first
|
||||
* range of Selection.
|
||||
* If first range of Selection is collapsed and there is a cache of style for
|
||||
* new text, aIsMixed is set to false and aColor is set to the cached color.
|
||||
* If first range of Selection is collapsed and there is no cached color,
|
||||
* this returns the color of the node, aIsMixed is set to false and aColor is
|
||||
* set to the color.
|
||||
* If first range of Selection is not collapsed, this collects colors of
|
||||
* each node in the range. If there are two or more colors, aIsMixed is set
|
||||
* to true and aColor is truncated. If only one color is set to all of the
|
||||
* range, aIsMixed is set to false and aColor is set to the color.
|
||||
* If there is no Selection ranges, aIsMixed is set to false and aColor is
|
||||
* truncated.
|
||||
*
|
||||
* @param aIsMixed Must not be nullptr. This is set to true
|
||||
* if there is two or more colors in first
|
||||
* range of Selection.
|
||||
* @param aColor Returns the color if only one color is set to
|
||||
* all of first range in Selection. Otherwise,
|
||||
* returns empty string.
|
||||
* @return Returns error only when illegal cases, e.g.,
|
||||
* Selection instance has gone, first range
|
||||
* Selection is broken.
|
||||
*/
|
||||
nsresult GetFontColorState(bool* aIsMixed, nsAString& aColor);
|
||||
|
||||
/**
|
||||
* SetComposerCommandsUpdater() sets or unsets mComposerCommandsUpdater.
|
||||
* This will crash in debug build if the editor already has an instance
|
||||
|
|
|
|||
|
|
@ -880,7 +880,9 @@ FontColorStateCommand::GetCurrentState(HTMLEditor* aHTMLEditor,
|
|||
bool outMixed;
|
||||
nsAutoString outStateString;
|
||||
nsresult rv = aHTMLEditor->GetFontColorState(&outMixed, outStateString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoCString tOutStateString;
|
||||
LossyCopyUTF16toASCII(outStateString, tOutStateString);
|
||||
|
|
|
|||
|
|
@ -1760,20 +1760,25 @@ HTMLEditor::GetFontFaceState(bool* aMixed,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
HTMLEditor::GetFontColorState(bool* aMixed,
|
||||
nsAString& aOutColor)
|
||||
{
|
||||
NS_ENSURE_TRUE(aMixed, NS_ERROR_NULL_POINTER);
|
||||
if (NS_WARN_IF(!aMixed)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*aMixed = true;
|
||||
aOutColor.Truncate();
|
||||
|
||||
bool first, any, all;
|
||||
|
||||
nsresult rv =
|
||||
GetInlinePropertyBase(*nsGkAtoms::font, nsGkAtoms::color, nullptr,
|
||||
&first, &any, &all, &aOutColor);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (any && !all) {
|
||||
return NS_OK; // mixed
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,14 +224,7 @@ interface nsIHTMLEditor : nsISupports
|
|||
AString getFontFaceState(out boolean aMixed);
|
||||
|
||||
/**
|
||||
* getFontColorState returns what font face is in the selection.
|
||||
* @param aMixed True if there is more than one font color
|
||||
* @return Color string. "" is returned for none.
|
||||
*/
|
||||
AString getFontColorState(out boolean aMixed);
|
||||
|
||||
/**
|
||||
* getFontColorState returns what font face is in the selection.
|
||||
* 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.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue