Bug 1430982 - part 2: Rename nsTextServicesDocument to mozilla::TextServicesDocument and expose its header r=m_kato

For making nsTextServicesDocument accessible from anywhere directly, we need to
expose its header.  Then, it should be in mozilla namespace.

This patch renames nsTextServicesDocument to mozilla::TextServicesDocument
and expose the header file as "mozilla/TextServicesDocument.h".

MozReview-Commit-ID: 9PmP73PXSJu

--HG--
rename : editor/txtsvc/nsTextServicesDocument.cpp => editor/txtsvc/TextServicesDocument.cpp
rename : editor/txtsvc/nsTextServicesDocument.h => editor/txtsvc/TextServicesDocument.h
extra : rebase_source : a12081434d0bc002e3675178486cc7f8eaaa3256
This commit is contained in:
Masayuki Nakano 2018-01-18 16:57:01 +09:00
Родитель 88c945974e
Коммит fa1d8d7c3f
8 изменённых файлов: 411 добавлений и 376 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,186 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_TextServicesDocument_h
#define mozilla_TextServicesDocument_h
#include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIEditActionListener.h"
#include "nsISupportsImpl.h"
#include "nsITextServicesDocument.h"
#include "nsStringFwd.h"
#include "nsTArray.h"
#include "nscore.h"
class nsIContent;
class nsIContentIterator;
class nsIDOMCharacterData;
class nsIDOMDocument;
class nsIDOMNode;
class nsIEditor;
class nsINode;
class nsISelection;
class nsISelectionController;
class nsITextServicesFilter;
// 019718E3-CDB5-11d2-8D3C-000000000000
#define NS_TEXTSERVICESDOCUMENT_CID \
{ 0x019718e3, 0xcdb5, 0x11d2, \
{ 0x8d, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
namespace mozilla {
class OffsetEntry;
class TextEditor;
/**
* TODO: Explain what this class manages and rename it to better name.
*/
class TextServicesDocument final : public nsITextServicesDocument
, public nsIEditActionListener
{
private:
enum class IteratorStatus : uint8_t
{
// No iterator (I), or iterator doesn't point to anything valid.
eDone = 0,
// I points to first text node (TN) in current block (CB).
eValid,
// No TN in CB, I points to first TN in prev block.
ePrev,
// No TN in CB, I points to first TN in next block.
eNext,
};
nsCOMPtr<nsIDOMDocument> mDOMDocument;
nsCOMPtr<nsISelectionController> mSelCon;
RefPtr<TextEditor> mTextEditor;
nsCOMPtr<nsIContentIterator> mIterator;
nsCOMPtr<nsIContent> mPrevTextBlock;
nsCOMPtr<nsIContent> mNextTextBlock;
nsTArray<OffsetEntry*> mOffsetTable;
RefPtr<nsRange> mExtent;
nsCOMPtr<nsITextServicesFilter> mTxtSvcFilter;
int32_t mSelStartIndex;
int32_t mSelStartOffset;
int32_t mSelEndIndex;
int32_t mSelEndOffset;
IteratorStatus mIteratorStatus;
protected:
virtual ~TextServicesDocument();
public:
TextServicesDocument();
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(TextServicesDocument,
nsITextServicesDocument)
/* nsITextServicesDocument method implementations. */
NS_IMETHOD InitWithEditor(nsIEditor* aEditor) override;
NS_IMETHOD GetDocument(nsIDOMDocument** aDoc) override;
NS_IMETHOD SetExtent(nsRange* aRange) override;
NS_IMETHOD ExpandRangeToWordBoundaries(nsRange* aRange) override;
NS_IMETHOD SetFilter(nsITextServicesFilter* aFilter) override;
NS_IMETHOD GetCurrentTextBlock(nsString* aStr) override;
NS_IMETHOD FirstBlock() override;
NS_IMETHOD LastSelectedBlock(TSDBlockSelectionStatus* aSelStatus,
int32_t* aSelOffset,
int32_t* aSelLength) override;
NS_IMETHOD PrevBlock() override;
NS_IMETHOD NextBlock() override;
NS_IMETHOD IsDone(bool* aIsDone) override;
NS_IMETHOD SetSelection(int32_t aOffset, int32_t aLength) override;
NS_IMETHOD ScrollSelectionIntoView() override;
NS_IMETHOD DeleteSelection() override;
NS_IMETHOD InsertText(const nsString* aText) override;
/* nsIEditActionListener method implementations. */
NS_DECL_NSIEDITACTIONLISTENER
static nsresult GetRangeEndPoints(nsRange* aRange,
nsINode** aStartContainer,
int32_t* aStartOffset,
nsINode** aEndContainer,
int32_t* aEndOffset);
private:
nsresult CreateContentIterator(nsRange* aRange,
nsIContentIterator** aIterator);
already_AddRefed<nsINode> GetDocumentContentRootNode();
already_AddRefed<nsRange> CreateDocumentContentRange();
already_AddRefed<nsRange> CreateDocumentContentRootToNodeOffsetRange(
nsINode* aParent,
uint32_t aOffset,
bool aToStart);
nsresult CreateDocumentContentIterator(nsIContentIterator** aIterator);
nsresult AdjustContentIterator();
static nsresult FirstTextNode(nsIContentIterator* aIterator,
IteratorStatus* aIteratorStatus);
static nsresult LastTextNode(nsIContentIterator* aIterator,
IteratorStatus* aIteratorStatus);
static nsresult FirstTextNodeInCurrentBlock(nsIContentIterator* aIterator);
static nsresult FirstTextNodeInPrevBlock(nsIContentIterator* aIterator);
static nsresult FirstTextNodeInNextBlock(nsIContentIterator* aIterator);
nsresult GetFirstTextNodeInPrevBlock(nsIContent** aContent);
nsresult GetFirstTextNodeInNextBlock(nsIContent** aContent);
static bool IsBlockNode(nsIContent* aContent);
static bool IsTextNode(nsIContent* aContent);
static bool IsTextNode(nsIDOMNode* aNode);
static bool DidSkip(nsIContentIterator* aFilteredIter);
static void ClearDidSkip(nsIContentIterator* aFilteredIter);
static bool HasSameBlockNodeParent(nsIContent* aContent1,
nsIContent* aContent2);
nsresult SetSelectionInternal(int32_t aOffset, int32_t aLength,
bool aDoUpdate);
nsresult GetSelection(TSDBlockSelectionStatus* aSelStatus,
int32_t* aSelOffset, int32_t* aSelLength);
nsresult GetCollapsedSelection(TSDBlockSelectionStatus* aSelStatus,
int32_t* aSelOffset, int32_t* aSelLength);
nsresult GetUncollapsedSelection(TSDBlockSelectionStatus* aSelStatus,
int32_t* aSelOffset, int32_t* aSelLength);
bool SelectionIsCollapsed();
bool SelectionIsValid();
static nsresult CreateOffsetTable(nsTArray<OffsetEntry*>* aOffsetTable,
nsIContentIterator* aIterator,
IteratorStatus* aIteratorStatus,
nsRange* aIterRange, nsString* aStr);
static nsresult ClearOffsetTable(nsTArray<OffsetEntry*>* aOffsetTable);
static nsresult NodeHasOffsetEntry(nsTArray<OffsetEntry*>* aOffsetTable,
nsINode* aNode,
bool* aHasEntry,
int32_t* aEntryIndex);
nsresult RemoveInvalidOffsetEntries();
nsresult SplitOffsetEntry(int32_t aTableIndex, int32_t aOffsetIntoEntry);
static nsresult FindWordBounds(nsTArray<OffsetEntry*>* aOffsetTable,
nsString* aBlockStr,
nsINode* aNode, int32_t aNodeOffset,
nsINode** aWordStartNode,
int32_t* aWordStartOffset,
nsINode** aWordEndNode,
int32_t* aWordEndOffset);
};
} // namespace mozilla
#endif // #ifndef mozilla_TextServicesDocument_h

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

@ -15,12 +15,15 @@ EXPORTS += [
'nsISpellChecker.h',
'nsITextService.h',
'nsITextServicesDocument.h',
'nsTextServicesCID.h',
]
EXPORTS.mozilla += [
'TextServicesDocument.h',
]
UNIFIED_SOURCES += [
'nsFilteredContentIterator.cpp',
'nsTextServicesDocument.cpp',
'TextServicesDocument.cpp',
]
FINAL_LIBRARY = 'xul'

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

@ -1,19 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsTextServicesCID_h__
#define nsTextServicesCID_h__
#define NS_TEXTSERVICESDOCUMENTINTERNAL_CID \
{ /* 019718E2-CDB5-11d2-8D3C-000000000000 */ \
0x019718e2, 0xcdb5, 0x11d2, \
{ 0x8d, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
#define NS_TEXTSERVICESDOCUMENT_CID \
{ /* 019718E3-CDB5-11d2-8D3C-000000000000 */ \
0x019718e3, 0xcdb5, 0x11d2, \
{ 0x8d, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
#endif /* nsTextServicesCID_h__ */

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

@ -1,172 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsTextServicesDocument_h__
#define nsTextServicesDocument_h__
#include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIEditActionListener.h"
#include "nsISupportsImpl.h"
#include "nsITextServicesDocument.h"
#include "nsStringFwd.h"
#include "nsTArray.h"
#include "nscore.h"
class OffsetEntry;
class nsIContent;
class nsIContentIterator;
class nsIDOMCharacterData;
class nsIDOMDocument;
class nsIDOMNode;
class nsIEditor;
class nsISelection;
class nsISelectionController;
class nsITextServicesFilter;
namespace mozilla {
class TextEditor;
} // namespace mozilla
/** implementation of a text services object.
*
*/
class nsTextServicesDocument final : public nsITextServicesDocument,
public nsIEditActionListener
{
private:
typedef enum { eIsDone=0, // No iterator (I), or iterator doesn't point to anything valid.
eValid, // I points to first text node (TN) in current block (CB).
ePrev, // No TN in CB, I points to first TN in prev block.
eNext // No TN in CB, I points to first TN in next block.
} TSDIteratorStatus;
nsCOMPtr<nsIDOMDocument> mDOMDocument;
nsCOMPtr<nsISelectionController>mSelCon;
RefPtr<mozilla::TextEditor> mTextEditor;
nsCOMPtr<nsIContentIterator> mIterator;
TSDIteratorStatus mIteratorStatus;
nsCOMPtr<nsIContent> mPrevTextBlock;
nsCOMPtr<nsIContent> mNextTextBlock;
nsTArray<OffsetEntry*> mOffsetTable;
int32_t mSelStartIndex;
int32_t mSelStartOffset;
int32_t mSelEndIndex;
int32_t mSelEndOffset;
RefPtr<nsRange> mExtent;
nsCOMPtr<nsITextServicesFilter> mTxtSvcFilter;
protected:
/** The default destructor.
*/
virtual ~nsTextServicesDocument();
public:
/** The default constructor.
*/
nsTextServicesDocument();
/* Macro for AddRef(), Release(), and QueryInterface() */
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsTextServicesDocument, nsITextServicesDocument)
/* nsITextServicesDocument method implementations. */
NS_IMETHOD InitWithEditor(nsIEditor *aEditor) override;
NS_IMETHOD GetDocument(nsIDOMDocument **aDoc) override;
NS_IMETHOD SetExtent(nsRange* aRange) override;
NS_IMETHOD ExpandRangeToWordBoundaries(nsRange* aRange) override;
NS_IMETHOD SetFilter(nsITextServicesFilter *aFilter) override;
NS_IMETHOD GetCurrentTextBlock(nsString *aStr) override;
NS_IMETHOD FirstBlock() override;
NS_IMETHOD LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, int32_t *aSelOffset, int32_t *aSelLength) override;
NS_IMETHOD PrevBlock() override;
NS_IMETHOD NextBlock() override;
NS_IMETHOD IsDone(bool *aIsDone) override;
NS_IMETHOD SetSelection(int32_t aOffset, int32_t aLength) override;
NS_IMETHOD ScrollSelectionIntoView() override;
NS_IMETHOD DeleteSelection() override;
NS_IMETHOD InsertText(const nsString *aText) override;
/* nsIEditActionListener method implementations. */
NS_DECL_NSIEDITACTIONLISTENER
/* Helper functions */
static nsresult GetRangeEndPoints(nsRange* aRange,
nsINode** aStartContainer,
int32_t* aStartOffset,
nsINode** aEndContainer,
int32_t* aEndOffset);
private:
/* nsTextServicesDocument private methods. */
nsresult CreateContentIterator(nsRange* aRange,
nsIContentIterator** aIterator);
already_AddRefed<nsINode> GetDocumentContentRootNode();
already_AddRefed<nsRange> CreateDocumentContentRange();
already_AddRefed<nsRange> CreateDocumentContentRootToNodeOffsetRange(
nsINode* aParent,
uint32_t aOffset,
bool aToStart);
nsresult CreateDocumentContentIterator(nsIContentIterator **aIterator);
nsresult AdjustContentIterator();
static nsresult FirstTextNode(nsIContentIterator *aIterator, TSDIteratorStatus *IteratorStatus);
static nsresult LastTextNode(nsIContentIterator *aIterator, TSDIteratorStatus *IteratorStatus);
static nsresult FirstTextNodeInCurrentBlock(nsIContentIterator *aIterator);
static nsresult FirstTextNodeInPrevBlock(nsIContentIterator *aIterator);
static nsresult FirstTextNodeInNextBlock(nsIContentIterator *aIterator);
nsresult GetFirstTextNodeInPrevBlock(nsIContent **aContent);
nsresult GetFirstTextNodeInNextBlock(nsIContent **aContent);
static bool IsBlockNode(nsIContent *aContent);
static bool IsTextNode(nsIContent *aContent);
static bool IsTextNode(nsIDOMNode *aNode);
static bool DidSkip(nsIContentIterator* aFilteredIter);
static void ClearDidSkip(nsIContentIterator* aFilteredIter);
static bool HasSameBlockNodeParent(nsIContent *aContent1, nsIContent *aContent2);
nsresult SetSelectionInternal(int32_t aOffset, int32_t aLength, bool aDoUpdate);
nsresult GetSelection(TSDBlockSelectionStatus *aSelStatus, int32_t *aSelOffset, int32_t *aSelLength);
nsresult GetCollapsedSelection(TSDBlockSelectionStatus *aSelStatus, int32_t *aSelOffset, int32_t *aSelLength);
nsresult GetUncollapsedSelection(TSDBlockSelectionStatus *aSelStatus, int32_t *aSelOffset, int32_t *aSelLength);
bool SelectionIsCollapsed();
bool SelectionIsValid();
static nsresult CreateOffsetTable(nsTArray<OffsetEntry*> *aOffsetTable,
nsIContentIterator *aIterator,
TSDIteratorStatus *aIteratorStatus,
nsRange* aIterRange, nsString* aStr);
static nsresult ClearOffsetTable(nsTArray<OffsetEntry*> *aOffsetTable);
static nsresult NodeHasOffsetEntry(nsTArray<OffsetEntry*> *aOffsetTable,
nsINode *aNode,
bool *aHasEntry,
int32_t *aEntryIndex);
nsresult RemoveInvalidOffsetEntries();
nsresult SplitOffsetEntry(int32_t aTableIndex, int32_t aOffsetIntoEntry);
static nsresult FindWordBounds(nsTArray<OffsetEntry*> *offsetTable,
nsString *blockStr,
nsINode* aNode, int32_t aNodeOffset,
nsINode** aWordStartNode,
int32_t *aWordStartOffset,
nsINode** aWordEndNode,
int32_t *aWordEndOffset);
};
#endif // nsTextServicesDocument_h__

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

@ -9,7 +9,6 @@
#include "mozHunspellDirProvider.h"
#include "mozSpellChecker.h"
#include "mozInlineSpellChecker.h"
#include "nsTextServicesCID.h"
#include "mozPersonalDictionary.h"
#include "mozSpellI18NManager.h"
#include "nsIFile.h"

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

@ -50,7 +50,6 @@ LOCAL_INCLUDES += [
'/dom/xul',
'/editor/composer',
'/editor/txmgr',
'/editor/txtsvc',
'/extensions/cookie',
'/js/xpconnect/loader',
'/js/xpconnect/src',

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

@ -109,8 +109,7 @@ using mozilla::dom::AudioChannelAgent;
#include "mozilla/EditorController.h" //CID
#include "mozilla/HTMLEditor.h"
#include "nsTextServicesDocument.h"
#include "nsTextServicesCID.h"
#include "mozilla/TextServicesDocument.h"
#include "nsScriptSecurityManager.h"
#include "ContentPrincipal.h"
@ -208,7 +207,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(TextEditor)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserUtils)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextServicesDocument)
NS_GENERIC_FACTORY_CONSTRUCTOR(TextServicesDocument)
NS_GENERIC_FACTORY_CONSTRUCTOR(HTMLEditor)
@ -883,7 +882,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kNS_EDITINGCONTROLLER_CID, false, nullptr, nsEditingControllerConstructor },
{ &kNS_EDITORCOMMANDTABLE_CID, false, nullptr, nsEditorCommandTableConstructor },
{ &kNS_EDITINGCOMMANDTABLE_CID, false, nullptr, nsEditingCommandTableConstructor },
{ &kNS_TEXTSERVICESDOCUMENT_CID, false, nullptr, nsTextServicesDocumentConstructor },
{ &kNS_TEXTSERVICESDOCUMENT_CID, false, nullptr, TextServicesDocumentConstructor },
{ &kNS_GEOLOCATION_SERVICE_CID, false, nullptr, nsGeolocationServiceConstructor },
{ &kNS_GEOLOCATION_CID, false, nullptr, GeolocationConstructor },
{ &kNS_AUDIOCHANNEL_SERVICE_CID, false, nullptr, AudioChannelServiceConstructor },