Bug 1485935 - Use NS_IMETHODIMP for implementation of HTMLEditor::GetIsCSSEnabled() r=m_kato

Even though HTMLEditor::GetIsCSSEnabled() is an implementation of an XPCOM
method, it uses nsresult as its return type.  We should change it to
NS_IMETHODIMP.

Additionally, SetDocumentStateCommand::GetCommandStateParams() calls this,
but HTMLEditor can expose non-virtual method, HTMLEditor::IsCSSEnabled().
Therefore, this patch makes it public and makes SetDocumentStateCommand use
HTMLEditor::IsCSSEnabled().

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2018-08-28 09:46:53 +00:00
parent a5108564dc
commit 9440d9e3e5
3 changed files with 15 additions and 10 deletions

View File

@ -221,6 +221,19 @@ public:
*/
nsresult OnMouseMove(dom::MouseEvent* aMouseEvent);
/**
* IsCSSEnabled() returns true if this editor treats styles with style
* attribute of HTML elements. Otherwise, if this editor treats all styles
* with "font style elements" like <b>, <i>, etc, and <blockquote> to indent,
* 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();
}
/**
* Enable/disable object resizers for <img> elements, <table> elements,
* absolute positioned elements (required absolute position editor enabled).
@ -690,12 +703,6 @@ protected: // May be called by friends.
bool aSafeToAskFrames,
bool* aSeenBR);
bool IsCSSEnabled() const
{
// TODO: removal of mCSSAware and use only the presence of mCSSEditUtils
return mCSSAware && mCSSEditUtils && mCSSEditUtils->IsCSSPrefChecked();
}
static bool HasAttributes(Element* aElement)
{
MOZ_ASSERT(aElement);

View File

@ -444,9 +444,7 @@ SetDocumentStateCommand::GetCommandStateParams(const char* aCommandName,
if (NS_WARN_IF(!htmlEditor)) {
return NS_ERROR_INVALID_ARG;
}
bool isCSS;
htmlEditor->GetIsCSSEnabled(&isCSS);
rv = params->SetBool(STATE_ALL, isCSS);
rv = params->SetBool(STATE_ALL, htmlEditor->IsCSSEnabled());
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

View File

@ -1798,7 +1798,7 @@ HTMLEditor::GetFontColorState(bool* aMixed,
// the return value is true only if the instance of the HTML editor we created
// can handle CSS styles (for instance, Composer can, Messenger can't) and if
// the CSS preference is checked
nsresult
NS_IMETHODIMP
HTMLEditor::GetIsCSSEnabled(bool* aIsCSSEnabled)
{
*aIsCSSEnabled = IsCSSEnabled();