Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsITextServicesDocument_h__
7 #define nsITextServicesDocument_h__
9 #include "nsISupports.h"
11 class nsIDOMDocument;
12 class nsIDOMRange;
13 class nsIEditor;
14 class nsString;
15 class nsITextServicesFilter;
17 /*
18 TextServicesDocument interface to outside world
19 */
21 #define NS_ITEXTSERVICESDOCUMENT_IID \
22 { /* 019718E1-CDB5-11d2-8D3C-000000000000 */ \
23 0x019718e1, 0xcdb5, 0x11d2, \
24 { 0x8d, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
27 /**
28 * The nsITextServicesDocument presents the document in as a
29 * bunch of flattened text blocks. Each text block can be retrieved
30 * as an nsString (array of characters).
31 */
32 class nsITextServicesDocument : public nsISupports{
33 public:
35 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITEXTSERVICESDOCUMENT_IID)
37 typedef enum { eDSNormal=0, eDSUndlerline } TSDDisplayStyle;
39 typedef enum { eBlockNotFound=0, // There is no text block (TB) in or before the selection (S).
40 eBlockOutside, // No TB in S, but found one before/after S.
41 eBlockInside, // S extends beyond the start and end of TB.
42 eBlockContains, // TB contains entire S.
43 eBlockPartial // S begins or ends in TB but extends outside of TB.
44 } TSDBlockSelectionStatus;
46 /**
47 * Get the DOM document for the document in use.
48 * @return aDocument the dom document [OUT]
49 */
50 NS_IMETHOD GetDocument(nsIDOMDocument **aDocument) = 0;
52 /**
53 * Initializes the text services document to use a particular
54 * editor. The text services document will use the DOM document
55 * and presentation shell used by the editor.
56 * @param aEditor is the editor to use. The editor is AddRef'd
57 * by this method.
58 */
59 NS_IMETHOD InitWithEditor(nsIEditor *aEditor) = 0;
61 /**
62 * Sets the range/extent over which the text services document
63 * will iterate. Note that InitWithEditor() should have been called prior to
64 * calling this method. If this method is never called, the text services
65 * defaults to iterating over the entire document.
66 *
67 * @param aDOMRange is the range to use. aDOMRange must point to a
68 * valid range object.
69 */
70 NS_IMETHOD SetExtent(nsIDOMRange* aDOMRange) = 0;
72 /**
73 * Expands the end points of the range so that it spans complete words.
74 * This call does not change any internal state of the text services document.
75 *
76 * @param aDOMRange the range to be expanded/adjusted.
77 */
78 NS_IMETHOD ExpandRangeToWordBoundaries(nsIDOMRange *aRange) = 0;
80 /**
81 * Sets the filter to be used while iterating over content.
82 * @param aFilter filter to be used while iterating over content.
83 */
84 NS_IMETHOD SetFilter(nsITextServicesFilter *aFilter) = 0;
86 /**
87 * Returns the text in the current text block.
88 * @param aStr will contain the text.
89 */
91 NS_IMETHOD GetCurrentTextBlock(nsString *aStr) = 0;
93 /**
94 * Tells the document to point to the first text block
95 * in the document. This method does not adjust the current
96 * cursor position or selection.
97 */
99 NS_IMETHOD FirstBlock() = 0;
101 /**
102 * Tells the document to point to the last text block that
103 * contains the current selection or caret.
104 * @param aSelectionStatus will contain the text block selection status
105 * @param aSelectionOffset will contain the offset into the
106 * string returned by GetCurrentTextBlock() where the selection
107 * begins.
108 * @param aLength will contain the number of characters that are
109 * selected in the string.
110 */
112 NS_IMETHOD LastSelectedBlock(TSDBlockSelectionStatus *aSelectionStatus, int32_t *aSelectionOffset, int32_t *aSelectionLength) = 0;
114 /**
115 * Tells the document to point to the text block before
116 * the current one. This method will return NS_OK, even
117 * if there is no previous block. Callers should call IsDone()
118 * to check if we have gone beyond the first text block in
119 * the document.
120 */
122 NS_IMETHOD PrevBlock() = 0;
124 /**
125 * Tells the document to point to the text block after
126 * the current one. This method will return NS_OK, even
127 * if there is no next block. Callers should call IsDone()
128 * to check if we have gone beyond the last text block
129 * in the document.
130 */
132 NS_IMETHOD NextBlock() = 0;
134 /**
135 * IsDone() will always set aIsDone == false unless
136 * the document contains no text, PrevBlock() was called
137 * while the document was already pointing to the first
138 * text block in the document, or NextBlock() was called
139 * while the document was already pointing to the last
140 * text block in the document.
141 * @param aIsDone will contain the result.
142 */
144 NS_IMETHOD IsDone(bool *aIsDone) = 0;
146 /**
147 * SetSelection() allows the caller to set the selection
148 * based on an offset into the string returned by
149 * GetCurrentTextBlock(). A length of zero places the cursor
150 * at that offset. A positive non-zero length "n" selects
151 * n characters in the string.
152 * @param aOffset offset into string returned by GetCurrentTextBlock().
153 * @param aLength number characters selected.
154 */
156 NS_IMETHOD SetSelection(int32_t aOffset, int32_t aLength) = 0;
158 /**
159 * Scrolls the document so that the current selection is visible.
160 */
162 NS_IMETHOD ScrollSelectionIntoView() = 0;
164 /**
165 * Deletes the text selected by SetSelection(). Calling
166 * DeleteSelection with nothing selected, or with a collapsed
167 * selection (cursor) does nothing and returns NS_OK.
168 */
170 NS_IMETHOD DeleteSelection() = 0;
172 /**
173 * Inserts the given text at the current cursor position.
174 * If there is a selection, it will be deleted before the
175 * text is inserted.
176 */
178 NS_IMETHOD InsertText(const nsString *aText) = 0;
179 };
181 NS_DEFINE_STATIC_IID_ACCESSOR(nsITextServicesDocument,
182 NS_ITEXTSERVICESDOCUMENT_IID)
184 #endif // nsITextServicesDocument_h__