зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1467802 - part 2: Mark TextEditor::GetAndInitDocEncoder() as const r=m_kato
TextEditor::GetAndInitDocEncoder() modifies only mCachedDocumentEncoder and mCachedDocumentEncoderType which are cache of the method to save recreation cost of document encoder when same type document encoder is requested. So, with marking them mutable, we can change the method to a const method. MozReview-Commit-ID: 80W0NtQhJOR --HG-- extra : rebase_source : 84f4b49fe3a3124c0de99b39a2141a8cee553e54
This commit is contained in:
Родитель
9da3ea2d22
Коммит
85b94e287c
|
@ -713,7 +713,7 @@ EditorBase::GetSelection(Selection** aSelection)
|
|||
|
||||
nsresult
|
||||
EditorBase::GetSelection(SelectionType aSelectionType,
|
||||
Selection** aSelection)
|
||||
Selection** aSelection) const
|
||||
{
|
||||
NS_ENSURE_TRUE(aSelection, NS_ERROR_NULL_POINTER);
|
||||
*aSelection = nullptr;
|
||||
|
|
|
@ -291,10 +291,10 @@ public:
|
|||
}
|
||||
|
||||
nsresult GetSelection(SelectionType aSelectionType,
|
||||
Selection** aSelection);
|
||||
Selection** aSelection) const;
|
||||
|
||||
Selection* GetSelection(SelectionType aSelectionType =
|
||||
SelectionType::eNormal)
|
||||
SelectionType::eNormal) const
|
||||
{
|
||||
nsISelectionController* sc = GetSelectionController();
|
||||
if (!sc) {
|
||||
|
|
|
@ -1712,11 +1712,10 @@ TextEditor::CanDelete(bool* aCanDelete)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Used by OutputToString
|
||||
already_AddRefed<nsIDocumentEncoder>
|
||||
TextEditor::GetAndInitDocEncoder(const nsAString& aFormatType,
|
||||
uint32_t aFlags,
|
||||
const nsACString& aCharset)
|
||||
uint32_t aDocumentEncoderFlags,
|
||||
const nsACString& aCharset) const
|
||||
{
|
||||
nsCOMPtr<nsIDocumentEncoder> docEncoder;
|
||||
if (!mCachedDocumentEncoder ||
|
||||
|
@ -1739,7 +1738,8 @@ TextEditor::GetAndInitDocEncoder(const nsAString& aFormatType,
|
|||
nsresult rv =
|
||||
docEncoder->NativeInit(
|
||||
doc, aFormatType,
|
||||
aFlags | nsIDocumentEncoder::RequiresReinitAfterOutput);
|
||||
aDocumentEncoderFlags |
|
||||
nsIDocumentEncoder::RequiresReinitAfterOutput);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1756,7 +1756,7 @@ TextEditor::GetAndInitDocEncoder(const nsAString& aFormatType,
|
|||
// Set the selection, if appropriate.
|
||||
// We do this either if the OutputSelectionOnly flag is set,
|
||||
// in which case we use our existing selection ...
|
||||
if (aFlags & nsIDocumentEncoder::OutputSelectionOnly) {
|
||||
if (aDocumentEncoderFlags & nsIDocumentEncoder::OutputSelectionOnly) {
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return nullptr;
|
||||
|
@ -1784,7 +1784,6 @@ TextEditor::GetAndInitDocEncoder(const nsAString& aFormatType,
|
|||
return docEncoder.forget();
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
TextEditor::OutputToString(const nsAString& aFormatType,
|
||||
uint32_t aFlags,
|
||||
|
|
|
@ -327,10 +327,19 @@ protected: // Shouldn't be used by friend classes
|
|||
|
||||
virtual nsresult InitRules();
|
||||
|
||||
already_AddRefed<nsIDocumentEncoder> GetAndInitDocEncoder(
|
||||
const nsAString& aFormatType,
|
||||
uint32_t aFlags,
|
||||
const nsACString& aCharset);
|
||||
/**
|
||||
* GetAndInitDocEncoder() returns a document encoder instance for aFormatType
|
||||
* after initializing it. The result may be cached for saving recreation
|
||||
* cost.
|
||||
*
|
||||
* @param aFormatType MIME type like "text/plain".
|
||||
* @param aDocumentEncoderFlags Flags of nsIDocumentEncoder.
|
||||
* @param aCharset Encoding of the document.
|
||||
*/
|
||||
already_AddRefed<nsIDocumentEncoder>
|
||||
GetAndInitDocEncoder(const nsAString& aFormatType,
|
||||
uint32_t aDocumentEncoderFlags,
|
||||
const nsACString& aCharset) const;
|
||||
|
||||
/**
|
||||
* Factored methods for handling insertion of data from transferables
|
||||
|
@ -393,8 +402,8 @@ protected: // Shouldn't be used by friend classes
|
|||
virtual already_AddRefed<nsIContent> GetInputEventTargetContent() override;
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDocumentEncoder> mCachedDocumentEncoder;
|
||||
nsString mCachedDocumentEncoderType;
|
||||
mutable nsCOMPtr<nsIDocumentEncoder> mCachedDocumentEncoder;
|
||||
mutable nsString mCachedDocumentEncoderType;
|
||||
int32_t mWrapColumn;
|
||||
int32_t mMaxTextLength;
|
||||
int32_t mInitTriggerCounter;
|
||||
|
|
Загрузка…
Ссылка в новой задаче