OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef TextFinder_h | 31 #ifndef TextFinder_h |
32 #define TextFinder_h | 32 #define TextFinder_h |
33 | 33 |
34 #include "WebFrame.h" | 34 #include "WebFindOptions.h" |
35 | 35 #include "core/editing/FindOptions.h" |
36 #include "FrameLoaderClientImpl.h" | |
37 #include "core/frame/LocalFrame.h" | |
38 #include "platform/geometry/FloatRect.h" | 36 #include "platform/geometry/FloatRect.h" |
39 #include "public/platform/WebFileSystemType.h" | 37 #include "public/platform/WebFloatPoint.h" |
40 #include "wtf/Compiler.h" | 38 #include "public/platform/WebFloatRect.h" |
41 #include "wtf/HashSet.h" | 39 #include "public/platform/WebRect.h" |
42 #include "wtf/OwnPtr.h" | 40 #include "wtf/PassOwnPtr.h" |
43 #include "wtf/RefCounted.h" | 41 #include "wtf/PassRefPtr.h" |
| 42 #include "wtf/Vector.h" |
44 #include "wtf/text/WTFString.h" | 43 #include "wtf/text/WTFString.h" |
45 | 44 |
46 namespace WebCore { | 45 namespace WebCore { |
47 class GraphicsContext; | |
48 class HTMLInputElement; | |
49 class HistoryItem; | |
50 class IntSize; | |
51 class KURL; | |
52 class Node; | |
53 class Range; | 46 class Range; |
54 class SubstituteData; | |
55 struct FrameLoadRequest; | |
56 struct WindowFeatures; | |
57 } | 47 } |
58 | 48 |
59 namespace blink { | 49 namespace blink { |
60 class ChromePrintContext; | 50 class WebFrameImpl; |
61 class SharedWorkerRepositoryClientImpl; | |
62 class WebDataSourceImpl; | |
63 class WebInputElement; | |
64 class WebFrameClient; | |
65 class WebPerformance; | |
66 class WebPluginContainerImpl; | |
67 class WebView; | |
68 class WebViewImpl; | |
69 struct WebPrintParams; | |
70 | 51 |
71 template <typename T> class WebVector; | 52 template <typename T> class WebVector; |
72 | 53 |
73 // Implementation of WebFrame, note that this is a reference counted object. | 54 class TextFinder { |
74 class WebFrameImpl FINAL | |
75 : public WebFrame | |
76 , public RefCounted<WebFrameImpl> { | |
77 public: | 55 public: |
78 // WebFrame methods: | 56 static PassOwnPtr<TextFinder> create(WebFrameImpl& ownerFrame); |
79 virtual void close() OVERRIDE; | 57 |
80 virtual WebString uniqueName() const OVERRIDE; | 58 bool find( |
81 virtual WebString assignedName() const OVERRIDE; | |
82 virtual void setName(const WebString&) OVERRIDE; | |
83 virtual WebVector<WebIconURL> iconURLs(int iconTypesMask) const OVERRIDE; | |
84 virtual void setIsRemote(bool) OVERRIDE; | |
85 virtual void setRemoteWebLayer(WebLayer*) OVERRIDE; | |
86 virtual void setPermissionClient(WebPermissionClient*) OVERRIDE; | |
87 virtual void setSharedWorkerRepositoryClient(WebSharedWorkerRepositoryClient
*) OVERRIDE; | |
88 virtual WebSize scrollOffset() const OVERRIDE; | |
89 virtual void setScrollOffset(const WebSize&) OVERRIDE; | |
90 virtual WebSize minimumScrollOffset() const OVERRIDE; | |
91 virtual WebSize maximumScrollOffset() const OVERRIDE; | |
92 virtual WebSize contentsSize() const OVERRIDE; | |
93 virtual bool hasVisibleContent() const OVERRIDE; | |
94 virtual WebRect visibleContentRect() const OVERRIDE; | |
95 virtual bool hasHorizontalScrollbar() const OVERRIDE; | |
96 virtual bool hasVerticalScrollbar() const OVERRIDE; | |
97 virtual WebView* view() const OVERRIDE; | |
98 virtual WebFrame* opener() const OVERRIDE; | |
99 virtual void setOpener(WebFrame*) OVERRIDE; | |
100 virtual void appendChild(WebFrame*) OVERRIDE; | |
101 virtual void removeChild(WebFrame*) OVERRIDE; | |
102 virtual WebFrame* parent() const OVERRIDE; | |
103 virtual WebFrame* top() const OVERRIDE; | |
104 virtual WebFrame* previousSibling() const OVERRIDE; | |
105 virtual WebFrame* nextSibling() const OVERRIDE; | |
106 virtual WebFrame* firstChild() const OVERRIDE; | |
107 virtual WebFrame* lastChild() const OVERRIDE; | |
108 virtual WebFrame* traversePrevious(bool wrap) const OVERRIDE; | |
109 virtual WebFrame* traverseNext(bool wrap) const OVERRIDE; | |
110 virtual WebFrame* findChildByName(const WebString&) const OVERRIDE; | |
111 virtual WebFrame* findChildByExpression(const WebString&) const OVERRIDE; | |
112 virtual WebDocument document() const OVERRIDE; | |
113 virtual WebPerformance performance() const OVERRIDE; | |
114 virtual NPObject* windowObject() const OVERRIDE; | |
115 virtual void bindToWindowObject(const WebString& name, NPObject*) OVERRIDE; | |
116 virtual void bindToWindowObject(const WebString& name, NPObject*, void*) OVE
RRIDE; | |
117 virtual void executeScript(const WebScriptSource&) OVERRIDE; | |
118 virtual void executeScriptInIsolatedWorld( | |
119 int worldID, const WebScriptSource* sources, unsigned numSources, | |
120 int extensionGroup) OVERRIDE; | |
121 virtual void setIsolatedWorldSecurityOrigin(int worldID, const WebSecurityOr
igin&) OVERRIDE; | |
122 virtual void setIsolatedWorldContentSecurityPolicy(int worldID, const WebStr
ing&) OVERRIDE; | |
123 virtual void addMessageToConsole(const WebConsoleMessage&) OVERRIDE; | |
124 virtual void collectGarbage() OVERRIDE; | |
125 virtual bool checkIfRunInsecureContent(const WebURL&) const OVERRIDE; | |
126 virtual v8::Handle<v8::Value> executeScriptAndReturnValue( | |
127 const WebScriptSource&) OVERRIDE; | |
128 virtual void executeScriptInIsolatedWorld( | |
129 int worldID, const WebScriptSource* sourcesIn, unsigned numSources, | |
130 int extensionGroup, WebVector<v8::Local<v8::Value> >* results) OVERRIDE; | |
131 virtual v8::Handle<v8::Value> callFunctionEvenIfScriptDisabled( | |
132 v8::Handle<v8::Function>, | |
133 v8::Handle<v8::Value>, | |
134 int argc, | |
135 v8::Handle<v8::Value> argv[]) OVERRIDE; | |
136 virtual v8::Local<v8::Context> mainWorldScriptContext() const OVERRIDE; | |
137 virtual v8::Handle<v8::Value> createFileSystem(WebFileSystemType, | |
138 const WebString& name, | |
139 const WebString& path) OVERRIDE; | |
140 virtual v8::Handle<v8::Value> createSerializableFileSystem(WebFileSystemType
, | |
141 const WebString& name, | |
142 const WebString& path) OVERRIDE; | |
143 virtual v8::Handle<v8::Value> createFileEntry(WebFileSystemType, | |
144 const WebString& fileSystemName, | |
145 const WebString& fileSystemPath, | |
146 const WebString& filePath, | |
147 bool isDirectory) OVERRIDE; | |
148 virtual void reload(bool ignoreCache) OVERRIDE; | |
149 virtual void reloadWithOverrideURL(const WebURL& overrideUrl, bool ignoreCac
he) OVERRIDE; | |
150 virtual void loadRequest(const WebURLRequest&) OVERRIDE; | |
151 virtual void loadHistoryItem(const WebHistoryItem&, WebURLRequest::CachePoli
cy) OVERRIDE; | |
152 virtual void loadData( | |
153 const WebData&, const WebString& mimeType, const WebString& textEncoding
, | |
154 const WebURL& baseURL, const WebURL& unreachableURL, bool replace) OVERR
IDE; | |
155 virtual void loadHTMLString( | |
156 const WebData& html, const WebURL& baseURL, const WebURL& unreachableURL
, | |
157 bool replace) OVERRIDE; | |
158 virtual bool isLoading() const OVERRIDE; | |
159 virtual void stopLoading() OVERRIDE; | |
160 virtual WebDataSource* provisionalDataSource() const OVERRIDE; | |
161 virtual WebDataSource* dataSource() const OVERRIDE; | |
162 virtual WebHistoryItem previousHistoryItem() const OVERRIDE; | |
163 virtual WebHistoryItem currentHistoryItem() const OVERRIDE; | |
164 virtual void enableViewSourceMode(bool enable) OVERRIDE; | |
165 virtual bool isViewSourceModeEnabled() const OVERRIDE; | |
166 virtual void setReferrerForRequest(WebURLRequest&, const WebURL& referrer) O
VERRIDE; | |
167 virtual void dispatchWillSendRequest(WebURLRequest&) OVERRIDE; | |
168 virtual WebURLLoader* createAssociatedURLLoader(const WebURLLoaderOptions&)
OVERRIDE; | |
169 virtual unsigned unloadListenerCount() const OVERRIDE; | |
170 virtual void replaceSelection(const WebString&) OVERRIDE; | |
171 virtual void insertText(const WebString&) OVERRIDE; | |
172 virtual void setMarkedText(const WebString&, unsigned location, unsigned len
gth) OVERRIDE; | |
173 virtual void unmarkText() OVERRIDE; | |
174 virtual bool hasMarkedText() const OVERRIDE; | |
175 virtual WebRange markedRange() const OVERRIDE; | |
176 virtual bool firstRectForCharacterRange(unsigned location, unsigned length,
WebRect&) const OVERRIDE; | |
177 virtual size_t characterIndexForPoint(const WebPoint&) const OVERRIDE; | |
178 virtual bool executeCommand(const WebString&, const WebNode& = WebNode()) OV
ERRIDE; | |
179 virtual bool executeCommand(const WebString&, const WebString& value, const
WebNode& = WebNode()) OVERRIDE; | |
180 virtual bool isCommandEnabled(const WebString&) const OVERRIDE; | |
181 virtual void enableContinuousSpellChecking(bool) OVERRIDE; | |
182 virtual bool isContinuousSpellCheckingEnabled() const OVERRIDE; | |
183 virtual void requestTextChecking(const WebElement&) OVERRIDE; | |
184 virtual void replaceMisspelledRange(const WebString&) OVERRIDE; | |
185 virtual void removeSpellingMarkers() OVERRIDE; | |
186 virtual bool hasSelection() const OVERRIDE; | |
187 virtual WebRange selectionRange() const OVERRIDE; | |
188 virtual WebString selectionAsText() const OVERRIDE; | |
189 virtual WebString selectionAsMarkup() const OVERRIDE; | |
190 virtual bool selectWordAroundCaret() OVERRIDE; | |
191 virtual void selectRange(const WebPoint& base, const WebPoint& extent) OVERR
IDE; | |
192 virtual void selectRange(const WebRange&) OVERRIDE; | |
193 virtual void moveRangeSelection(const WebPoint& base, const WebPoint& extent
) OVERRIDE; | |
194 virtual void moveCaretSelection(const WebPoint&) OVERRIDE; | |
195 virtual void setCaretVisible(bool) OVERRIDE; | |
196 virtual int printBegin(const WebPrintParams&, const WebNode& constrainToNode
) OVERRIDE; | |
197 virtual float printPage(int pageToPrint, WebCanvas*) OVERRIDE; | |
198 virtual float getPrintPageShrink(int page) OVERRIDE; | |
199 virtual void printEnd() OVERRIDE; | |
200 virtual bool isPrintScalingDisabledForPlugin(const WebNode&) OVERRIDE; | |
201 virtual bool hasCustomPageSizeStyle(int pageIndex) OVERRIDE; | |
202 virtual bool isPageBoxVisible(int pageIndex) OVERRIDE; | |
203 virtual void pageSizeAndMarginsInPixels(int pageIndex, | |
204 WebSize& pageSize, | |
205 int& marginTop, | |
206 int& marginRight, | |
207 int& marginBottom, | |
208 int& marginLeft) OVERRIDE; | |
209 virtual WebString pageProperty(const WebString& propertyName, int pageIndex)
OVERRIDE; | |
210 virtual void printPagesWithBoundaries(WebCanvas*, const WebSize&) OVERRIDE; | |
211 virtual bool find( | |
212 int identifier, const WebString& searchText, const WebFindOptions&, | 59 int identifier, const WebString& searchText, const WebFindOptions&, |
213 bool wrapWithinFrame, WebRect* selectionRect) OVERRIDE; | 60 bool wrapWithinFrame, WebRect* selectionRect); |
214 virtual void stopFinding(bool clearSelection) OVERRIDE; | 61 void stopFindingAndClearSelection(); |
215 virtual void scopeStringMatches( | 62 void scopeStringMatches( |
216 int identifier, const WebString& searchText, const WebFindOptions&, | 63 int identifier, const WebString& searchText, const WebFindOptions&, |
217 bool reset) OVERRIDE; | 64 bool reset); |
218 virtual void cancelPendingScopingEffort() OVERRIDE; | 65 void cancelPendingScopingEffort(); |
219 virtual void increaseMatchCount(int count, int identifier) OVERRIDE; | 66 void increaseMatchCount(int identifier, int count); |
220 virtual void resetMatchCount() OVERRIDE; | 67 void resetMatchCount(); |
221 virtual int findMatchMarkersVersion() const OVERRIDE; | 68 int findMatchMarkersVersion() const { return m_findMatchMarkersVersion; } |
222 virtual WebFloatRect activeFindMatchRect() OVERRIDE; | 69 WebFloatRect activeFindMatchRect(); |
223 virtual void findMatchRects(WebVector<WebFloatRect>&) OVERRIDE; | 70 void findMatchRects(WebVector<WebFloatRect>&); |
224 virtual int selectNearestFindMatch(const WebFloatPoint&, WebRect* selectionR
ect) OVERRIDE; | 71 int selectNearestFindMatch(const WebFloatPoint&, WebRect* selectionRect); |
225 | |
226 virtual void sendOrientationChangeEvent(int orientation) OVERRIDE; | |
227 | |
228 virtual void dispatchMessageEventWithOriginCheck( | |
229 const WebSecurityOrigin& intendedTargetOrigin, | |
230 const WebDOMEvent&) OVERRIDE; | |
231 | |
232 virtual WebString contentAsText(size_t maxChars) const OVERRIDE; | |
233 virtual WebString contentAsMarkup() const OVERRIDE; | |
234 virtual WebString renderTreeAsText(RenderAsTextControls toShow = RenderAsTex
tNormal) const OVERRIDE; | |
235 virtual WebString markerTextForListItem(const WebElement&) const OVERRIDE; | |
236 virtual WebRect selectionBoundsRect() const OVERRIDE; | |
237 | |
238 virtual bool selectionStartHasSpellingMarkerFor(int from, int length) const
OVERRIDE; | |
239 virtual WebString layerTreeAsText(bool showDebugInfo = false) const OVERRIDE
; | |
240 | |
241 void willDetachParent(); | |
242 | |
243 static WebFrameImpl* create(WebFrameClient*); | |
244 virtual ~WebFrameImpl(); | |
245 | |
246 // Called by the WebViewImpl to initialize the main frame for the page. | |
247 void initializeAsMainFrame(WebCore::Page*); | |
248 | |
249 PassRefPtr<WebCore::LocalFrame> createChildFrame( | |
250 const WebCore::FrameLoadRequest&, WebCore::HTMLFrameOwnerElement*); | |
251 | |
252 void didChangeContentsSize(const WebCore::IntSize&); | |
253 | |
254 void createFrameView(); | |
255 | |
256 static WebFrameImpl* fromFrame(WebCore::LocalFrame* frame); | |
257 static WebFrameImpl* fromFrameOwnerElement(WebCore::Element* element); | |
258 | |
259 // If the frame hosts a PluginDocument, this method returns the WebPluginCon
tainerImpl | |
260 // that hosts the plugin. | |
261 static WebPluginContainerImpl* pluginContainerFromFrame(WebCore::LocalFrame*
); | |
262 | |
263 // If the frame hosts a PluginDocument, this method returns the WebPluginCon
tainerImpl | |
264 // that hosts the plugin. If the provided node is a plugin, then it runs its | |
265 // WebPluginContainerImpl. | |
266 static WebPluginContainerImpl* pluginContainerFromNode(WebCore::LocalFrame*,
const WebNode&); | |
267 | |
268 WebViewImpl* viewImpl() const; | |
269 | |
270 WebCore::FrameView* frameView() const { return frame() ? frame()->view() : 0
; } | |
271 | |
272 // Getters for the impls corresponding to Get(Provisional)DataSource. They | |
273 // may return 0 if there is no corresponding data source. | |
274 WebDataSourceImpl* dataSourceImpl() const; | |
275 WebDataSourceImpl* provisionalDataSourceImpl() const; | |
276 | 72 |
277 // Returns which frame has an active match. This function should only be | 73 // Returns which frame has an active match. This function should only be |
278 // called on the main frame, as it is the only frame keeping track. Returned | 74 // called on the main frame, as it is the only frame keeping track. Returned |
279 // value can be 0 if no frame has an active match. | 75 // value can be 0 if no frame has an active match. |
280 WebFrameImpl* activeMatchFrame() const { return m_currentActiveMatchFrame; } | 76 WebFrameImpl* activeMatchFrame() const { return m_currentActiveMatchFrame; } |
281 | 77 |
282 // Returns the active match in the current frame. Could be a null range if | 78 // Returns the active match in the current frame. Could be a null range if |
283 // the local frame has no active match. | 79 // the local frame has no active match. |
284 WebCore::Range* activeMatch() const { return m_activeMatch.get(); } | 80 WebCore::Range* activeMatch() const { return m_activeMatch.get(); } |
285 | 81 |
286 // When a Find operation ends, we want to set the selection to what was acti
ve | 82 void flushCurrentScoping(); |
287 // and set focus to the first focusable node we find (starting with the firs
t | |
288 // node in the matched range and going up the inheritance chain). If we find | |
289 // nothing to focus we focus the first focusable node in the range. This | |
290 // allows us to set focus to a link (when we find text inside a link), which | |
291 // allows us to navigate by pressing Enter after closing the Find box. | |
292 void setFindEndstateFocusAndSelection(); | |
293 | 83 |
294 void didFail(const WebCore::ResourceError&, bool wasProvisional); | 84 void resetActiveMatch() { m_activeMatch = nullptr; } |
295 | 85 |
296 // Sets whether the WebFrameImpl allows its document to be scrolled. | 86 int totalMatchCount() const { return m_totalMatchCount; } |
297 // If the parameter is true, allow the document to be scrolled. | 87 bool scopingInProgress() const { return m_scopingInProgress; } |
298 // Otherwise, disallow scrolling. | 88 void increaseMarkerVersion() { ++m_findMatchMarkersVersion; } |
299 virtual void setCanHaveScrollbars(bool) OVERRIDE; | |
300 | 89 |
301 WebCore::LocalFrame* frame() const { return m_frame.get(); } | 90 ~TextFinder(); |
302 WebFrameClient* client() const { return m_client; } | |
303 void setClient(WebFrameClient* client) { m_client = client; } | |
304 | |
305 WebPermissionClient* permissionClient() { return m_permissionClient; } | |
306 SharedWorkerRepositoryClientImpl* sharedWorkerRepositoryClient() const { ret
urn m_sharedWorkerRepositoryClient.get(); } | |
307 | |
308 void setInputEventsTransformForEmulation(const WebCore::IntSize&, float); | |
309 | |
310 static void selectWordAroundPosition(WebCore::LocalFrame*, WebCore::VisibleP
osition); | |
311 | 91 |
312 private: | 92 private: |
313 class DeferredScopeStringMatches; | 93 class DeferredScopeStringMatches; |
314 friend class DeferredScopeStringMatches; | 94 friend class DeferredScopeStringMatches; |
315 friend class FrameLoaderClientImpl; | |
316 | 95 |
317 struct FindMatch { | 96 struct FindMatch { |
318 RefPtr<WebCore::Range> m_range; | 97 RefPtr<WebCore::Range> m_range; |
319 | 98 |
320 // 1-based index within this frame. | 99 // 1-based index within this frame. |
321 int m_ordinal; | 100 int m_ordinal; |
322 | 101 |
323 // In find-in-page coordinates. | 102 // In find-in-page coordinates. |
324 // Lazily calculated by updateFindMatchRects. | 103 // Lazily calculated by updateFindMatchRects. |
325 WebCore::FloatRect m_rect; | 104 WebCore::FloatRect m_rect; |
326 | 105 |
327 FindMatch(PassRefPtr<WebCore::Range>, int ordinal); | 106 FindMatch(PassRefPtr<WebCore::Range>, int ordinal); |
328 }; | 107 }; |
329 | 108 |
330 // A bit mask specifying area of the frame to invalidate. | 109 // A bit mask specifying area of the frame to invalidate. |
331 enum AreaToInvalidate { | 110 enum AreaToInvalidate { |
332 InvalidateNothing, | 111 InvalidateNothing, |
333 InvalidateContentArea, | 112 InvalidateContentArea, |
334 InvalidateScrollbar, // Vertical scrollbar only. | 113 InvalidateScrollbar, // Vertical scrollbar only. |
335 InvalidateAll // Both content area and the scrollbar. | 114 InvalidateAll // Both content area and the scrollbar. |
336 }; | 115 }; |
337 | 116 |
338 explicit WebFrameImpl(WebFrameClient*); | 117 explicit TextFinder(WebFrameImpl& ownerFrame); |
339 | |
340 // Sets the local WebCore frame and registers destruction observers. | |
341 void setWebCoreFrame(PassRefPtr<WebCore::LocalFrame>); | |
342 | 118 |
343 // Notifies the delegate about a new selection rect. | 119 // Notifies the delegate about a new selection rect. |
344 void reportFindInPageSelection( | 120 void reportFindInPageSelection( |
345 const WebRect& selectionRect, int activeMatchOrdinal, int identifier); | 121 const WebRect& selectionRect, int activeMatchOrdinal, int identifier); |
346 | 122 |
347 // Clear the find-in-page matches cache forcing rects to be fully | 123 // Clear the find-in-page matches cache forcing rects to be fully |
348 // calculated again next time updateFindMatchRects is called. | 124 // calculated again next time updateFindMatchRects is called. |
349 void clearFindMatchesCache(); | 125 void clearFindMatchesCache(); |
350 | 126 |
351 // Check if the activeMatchFrame still exists in the frame tree. | 127 // Check if the activeMatchFrame still exists in the frame tree. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 bool reset); | 181 bool reset); |
406 | 182 |
407 // Called by a DeferredScopeStringMatches instance. | 183 // Called by a DeferredScopeStringMatches instance. |
408 void callScopeStringMatches( | 184 void callScopeStringMatches( |
409 DeferredScopeStringMatches*, int identifier, const WebString& searchText
, | 185 DeferredScopeStringMatches*, int identifier, const WebString& searchText
, |
410 const WebFindOptions&, bool reset); | 186 const WebFindOptions&, bool reset); |
411 | 187 |
412 // Determines whether to invalidate the content area and scrollbar. | 188 // Determines whether to invalidate the content area and scrollbar. |
413 void invalidateIfNecessary(); | 189 void invalidateIfNecessary(); |
414 | 190 |
415 void loadJavaScriptURL(const WebCore::KURL&); | 191 // Sets the markers within a current match range as active or inactive. |
| 192 void setMatchMarkerActive(bool); |
416 | 193 |
417 // Returns a hit-tested VisiblePosition for the given point | 194 void decrementFramesScopingCount(int identifier); |
418 WebCore::VisiblePosition visiblePositionForWindowPoint(const WebPoint&); | |
419 | 195 |
420 class WebFrameInit : public WebCore::FrameInit { | 196 // Returns the ordinal of the first match in the owner frame. |
421 public: | 197 int ordinalOfFirstMatch() const; |
422 static PassRefPtr<WebFrameInit> create(WebFrameImpl* webFrameImpl) | |
423 { | |
424 return adoptRef(new WebFrameInit(webFrameImpl)); | |
425 } | |
426 | 198 |
427 private: | 199 WebFrameImpl& m_ownerFrame; |
428 explicit WebFrameInit(WebFrameImpl* webFrameImpl) | |
429 : m_frameLoaderClientImpl(webFrameImpl) | |
430 { | |
431 setFrameLoaderClient(&m_frameLoaderClientImpl); | |
432 } | |
433 | |
434 FrameLoaderClientImpl m_frameLoaderClientImpl; | |
435 }; | |
436 RefPtr<WebFrameInit> m_frameInit; | |
437 | |
438 // The embedder retains a reference to the WebCore LocalFrame while it is ac
tive in the DOM. This | |
439 // reference is released when the frame is removed from the DOM or the entir
e page is closed. | |
440 // FIXME: These will need to change to WebFrame when we introduce WebFramePr
oxy. | |
441 RefPtr<WebCore::LocalFrame> m_frame; | |
442 WebFrameImpl* m_parent; | |
443 WebFrameImpl* m_previousSibling; | |
444 WebFrameImpl* m_nextSibling; | |
445 WebFrameImpl* m_firstChild; | |
446 WebFrameImpl* m_lastChild; | |
447 | |
448 WebFrameImpl* m_opener; | |
449 WTF::HashSet<WebFrameImpl*> m_openedFrames; | |
450 | |
451 // Indicate whether the current LocalFrame is local or remote. Remote frames
are | |
452 // rendered in a different process from their parent frames. | |
453 bool m_isRemote; | |
454 | |
455 WebFrameClient* m_client; | |
456 WebPermissionClient* m_permissionClient; | |
457 OwnPtr<SharedWorkerRepositoryClientImpl> m_sharedWorkerRepositoryClient; | |
458 | 200 |
459 // A way for the main frame to keep track of which frame has an active | 201 // A way for the main frame to keep track of which frame has an active |
460 // match. Should be 0 for all other frames. | 202 // match. Should be 0 for all other frames. |
461 WebFrameImpl* m_currentActiveMatchFrame; | 203 WebFrameImpl* m_currentActiveMatchFrame; |
462 | 204 |
463 // The range of the active match for the current frame. | 205 // The range of the active match for the current frame. |
464 RefPtr<WebCore::Range> m_activeMatch; | 206 RefPtr<WebCore::Range> m_activeMatch; |
465 | 207 |
466 // The index of the active match for the current frame. | 208 // The index of the active match for the current frame. |
467 int m_activeMatchIndexInCurrentFrame; | 209 int m_activeMatchIndexInCurrentFrame; |
468 | 210 |
469 // This flag is used by the scoping effort to determine if we need to figure | |
470 // out which rectangle is the active match. Once we find the active | |
471 // rectangle we clear this flag. | |
472 bool m_locatingActiveRect; | |
473 | |
474 // The scoping effort can time out and we need to keep track of where we | 211 // The scoping effort can time out and we need to keep track of where we |
475 // ended our last search so we can continue from where we left of. | 212 // ended our last search so we can continue from where we left of. |
476 RefPtr<WebCore::Range> m_resumeScopingFromRange; | 213 RefPtr<WebCore::Range> m_resumeScopingFromRange; |
477 | 214 |
478 // Keeps track of the last string this frame searched for. This is used for | 215 // Keeps track of the last string this frame searched for. This is used for |
479 // short-circuiting searches in the following scenarios: When a frame has | 216 // short-circuiting searches in the following scenarios: When a frame has |
480 // been searched and returned 0 results, we don't need to search that frame | 217 // been searched and returned 0 results, we don't need to search that frame |
481 // again if the user is just adding to the search (making it more specific). | 218 // again if the user is just adding to the search (making it more specific). |
482 WTF::String m_lastSearchString; | 219 WTF::String m_lastSearchString; |
483 | 220 |
484 // Keeps track of how many matches this frame has found so far, so that we | 221 // Keeps track of how many matches this frame has found so far, so that we |
485 // don't loose count between scoping efforts, and is also used (in conjuncti
on | 222 // don't loose count between scoping efforts, and is also used (in conjuncti
on |
486 // with m_lastSearchString) to figure out if we need to search the frame aga
in. | 223 // with m_lastSearchString) to figure out if we need to search the frame aga
in. |
487 int m_lastMatchCount; | 224 int m_lastMatchCount; |
488 | 225 |
489 // This variable keeps a cumulative total of matches found so far for ALL th
e | 226 // This variable keeps a cumulative total of matches found so far for ALL th
e |
490 // frames on the page, and is only incremented by calling IncreaseMatchCount | 227 // frames on the page, and is only incremented by calling IncreaseMatchCount |
491 // (on the main frame only). It should be -1 for all other frames. | 228 // (on the main frame only). It should be -1 for all other frames. |
492 int m_totalMatchCount; | 229 int m_totalMatchCount; |
493 | 230 |
494 // This variable keeps a cumulative total of how many frames are currently | 231 // This variable keeps a cumulative total of how many frames are currently |
495 // scoping, and is incremented/decremented on the main frame only. | 232 // scoping, and is incremented/decremented on the main frame only. |
496 // It should be -1 for all other frames. | 233 // It should be -1 for all other frames. |
497 int m_framesScopingCount; | 234 int m_framesScopingCount; |
498 | 235 |
499 // Identifier of the latest find-in-page request. Required to be stored in | 236 // Identifier of the latest find-in-page request. Required to be stored in |
500 // the frame in order to reply if required in case the frame is detached. | 237 // the frame in order to reply if required in case the frame is detached. |
501 int m_findRequestIdentifier; | 238 int m_findRequestIdentifier; |
502 | 239 |
503 // Keeps track of whether there is an scoping effort ongoing in the frame. | |
504 bool m_scopingInProgress; | |
505 | |
506 // Keeps track of whether the last find request completed its scoping effort | |
507 // without finding any matches in this frame. | |
508 bool m_lastFindRequestCompletedWithNoMatches; | |
509 | |
510 // Keeps track of when the scoping effort should next invalidate the scrollb
ar | 240 // Keeps track of when the scoping effort should next invalidate the scrollb
ar |
511 // and the frame area. | 241 // and the frame area. |
512 int m_nextInvalidateAfter; | 242 int m_nextInvalidateAfter; |
513 | 243 |
514 // A list of all of the pending calls to scopeStringMatches. | 244 // A list of all of the pending calls to scopeStringMatches. |
515 Vector<DeferredScopeStringMatches*> m_deferredScopingWork; | 245 Vector<DeferredScopeStringMatches*> m_deferredScopingWork; |
516 | 246 |
517 // Version number incremented on the main frame only whenever the document | 247 // Version number incremented on the main frame only whenever the document |
518 // find-in-page match markers change. It should be 0 for all other frames. | 248 // find-in-page match markers change. It should be 0 for all other frames. |
519 int m_findMatchMarkersVersion; | 249 int m_findMatchMarkersVersion; |
520 | 250 |
521 // Local cache of the find match markers currently displayed for this frame. | 251 // Local cache of the find match markers currently displayed for this frame. |
522 Vector<FindMatch> m_findMatchesCache; | 252 Vector<FindMatch> m_findMatchesCache; |
523 | 253 |
524 // Determines if the rects in the find-in-page matches cache of this frame | |
525 // are invalid and should be recomputed. | |
526 bool m_findMatchRectsAreValid; | |
527 | |
528 // Contents size when find-in-page match rects were last computed for this | 254 // Contents size when find-in-page match rects were last computed for this |
529 // frame's cache. | 255 // frame's cache. |
530 WebCore::IntSize m_contentsSizeForCurrentFindMatchRects; | 256 WebCore::IntSize m_contentsSizeForCurrentFindMatchRects; |
531 | 257 |
532 // Valid between calls to BeginPrint() and EndPrint(). Containts the print | 258 // This flag is used by the scoping effort to determine if we need to figure |
533 // information. Is used by PrintPage(). | 259 // out which rectangle is the active match. Once we find the active |
534 OwnPtr<ChromePrintContext> m_printContext; | 260 // rectangle we clear this flag. |
| 261 bool m_locatingActiveRect; |
535 | 262 |
536 // Stores the additional input events offset and scale when device metrics e
mulation is enabled. | 263 // Keeps track of whether there is an scoping effort ongoing in the frame. |
537 WebCore::IntSize m_inputEventsOffsetForEmulation; | 264 bool m_scopingInProgress; |
538 float m_inputEventsScaleFactorForEmulation; | 265 |
| 266 // Keeps track of whether the last find request completed its scoping effort |
| 267 // without finding any matches in this frame. |
| 268 bool m_lastFindRequestCompletedWithNoMatches; |
| 269 |
| 270 // Determines if the rects in the find-in-page matches cache of this frame |
| 271 // are invalid and should be recomputed. |
| 272 bool m_findMatchRectsAreValid; |
539 }; | 273 }; |
540 | 274 |
541 DEFINE_TYPE_CASTS(WebFrameImpl, WebFrame, frame, true, true); | |
542 | |
543 } // namespace blink | 275 } // namespace blink |
544 | 276 |
545 #endif | 277 #endif |
OLD | NEW |