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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 class Node; | 52 class Node; |
53 class Range; | 53 class Range; |
54 class SubstituteData; | 54 class SubstituteData; |
55 struct FrameLoadRequest; | 55 struct FrameLoadRequest; |
56 struct WindowFeatures; | 56 struct WindowFeatures; |
57 } | 57 } |
58 | 58 |
59 namespace blink { | 59 namespace blink { |
60 class ChromePrintContext; | 60 class ChromePrintContext; |
61 class SharedWorkerRepositoryClientImpl; | 61 class SharedWorkerRepositoryClientImpl; |
| 62 class TextFinder; |
62 class WebDataSourceImpl; | 63 class WebDataSourceImpl; |
63 class WebInputElement; | 64 class WebInputElement; |
64 class WebFrameClient; | 65 class WebFrameClient; |
65 class WebPerformance; | 66 class WebPerformance; |
66 class WebPlugin; | 67 class WebPlugin; |
67 class WebPluginContainerImpl; | 68 class WebPluginContainerImpl; |
68 class WebView; | 69 class WebView; |
69 class WebViewImpl; | 70 class WebViewImpl; |
70 struct WebPrintParams; | 71 struct WebPrintParams; |
71 | 72 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 WebCore::FrameView* frameView() const { return frame() ? frame()->view() : 0
; } | 266 WebCore::FrameView* frameView() const { return frame() ? frame()->view() : 0
; } |
266 | 267 |
267 // Getters for the impls corresponding to Get(Provisional)DataSource. They | 268 // Getters for the impls corresponding to Get(Provisional)DataSource. They |
268 // may return 0 if there is no corresponding data source. | 269 // may return 0 if there is no corresponding data source. |
269 WebDataSourceImpl* dataSourceImpl() const; | 270 WebDataSourceImpl* dataSourceImpl() const; |
270 WebDataSourceImpl* provisionalDataSourceImpl() const; | 271 WebDataSourceImpl* provisionalDataSourceImpl() const; |
271 | 272 |
272 // Returns which frame has an active match. This function should only be | 273 // Returns which frame has an active match. This function should only be |
273 // called on the main frame, as it is the only frame keeping track. Returned | 274 // called on the main frame, as it is the only frame keeping track. Returned |
274 // value can be 0 if no frame has an active match. | 275 // value can be 0 if no frame has an active match. |
275 WebFrameImpl* activeMatchFrame() const { return m_currentActiveMatchFrame; } | 276 WebFrameImpl* activeMatchFrame() const; |
276 | 277 |
277 // Returns the active match in the current frame. Could be a null range if | 278 // Returns the active match in the current frame. Could be a null range if |
278 // the local frame has no active match. | 279 // the local frame has no active match. |
279 WebCore::Range* activeMatch() const { return m_activeMatch.get(); } | 280 WebCore::Range* activeMatch() const; |
280 | 281 |
281 // When a Find operation ends, we want to set the selection to what was acti
ve | 282 // When a Find operation ends, we want to set the selection to what was acti
ve |
282 // and set focus to the first focusable node we find (starting with the firs
t | 283 // and set focus to the first focusable node we find (starting with the firs
t |
283 // node in the matched range and going up the inheritance chain). If we find | 284 // node in the matched range and going up the inheritance chain). If we find |
284 // nothing to focus we focus the first focusable node in the range. This | 285 // nothing to focus we focus the first focusable node in the range. This |
285 // allows us to set focus to a link (when we find text inside a link), which | 286 // allows us to set focus to a link (when we find text inside a link), which |
286 // allows us to navigate by pressing Enter after closing the Find box. | 287 // allows us to navigate by pressing Enter after closing the Find box. |
287 void setFindEndstateFocusAndSelection(); | 288 void setFindEndstateFocusAndSelection(); |
288 | 289 |
289 void didFail(const WebCore::ResourceError&, bool wasProvisional); | 290 void didFail(const WebCore::ResourceError&, bool wasProvisional); |
290 | 291 |
291 // Sets whether the WebFrameImpl allows its document to be scrolled. | 292 // Sets whether the WebFrameImpl allows its document to be scrolled. |
292 // If the parameter is true, allow the document to be scrolled. | 293 // If the parameter is true, allow the document to be scrolled. |
293 // Otherwise, disallow scrolling. | 294 // Otherwise, disallow scrolling. |
294 virtual void setCanHaveScrollbars(bool) OVERRIDE; | 295 virtual void setCanHaveScrollbars(bool) OVERRIDE; |
295 | 296 |
296 WebCore::LocalFrame* frame() const { return m_frame.get(); } | 297 WebCore::LocalFrame* frame() const { return m_frame.get(); } |
297 WebFrameClient* client() const { return m_client; } | 298 WebFrameClient* client() const { return m_client; } |
298 void setClient(WebFrameClient* client) { m_client = client; } | 299 void setClient(WebFrameClient* client) { m_client = client; } |
299 | 300 |
300 WebPermissionClient* permissionClient() { return m_permissionClient; } | 301 WebPermissionClient* permissionClient() { return m_permissionClient; } |
301 SharedWorkerRepositoryClientImpl* sharedWorkerRepositoryClient() const { ret
urn m_sharedWorkerRepositoryClient.get(); } | 302 SharedWorkerRepositoryClientImpl* sharedWorkerRepositoryClient() const { ret
urn m_sharedWorkerRepositoryClient.get(); } |
302 | 303 |
303 void setInputEventsTransformForEmulation(const WebCore::IntSize&, float); | 304 void setInputEventsTransformForEmulation(const WebCore::IntSize&, float); |
304 | 305 |
305 static void selectWordAroundPosition(WebCore::LocalFrame*, WebCore::VisibleP
osition); | 306 static void selectWordAroundPosition(WebCore::LocalFrame*, WebCore::VisibleP
osition); |
306 | 307 |
| 308 // Returns the text finder object if it already exists. |
| 309 // Otherwise creates it and then returns. |
| 310 TextFinder& ensureTextFinder(); |
| 311 |
| 312 // Invalidates vertical scrollbar only. |
| 313 void invalidateScrollbar() const; |
| 314 |
| 315 // Invalidates both content area and the scrollbar. |
| 316 void invalidateAll() const; |
| 317 |
307 private: | 318 private: |
308 class DeferredScopeStringMatches; | |
309 friend class DeferredScopeStringMatches; | |
310 friend class FrameLoaderClientImpl; | 319 friend class FrameLoaderClientImpl; |
311 | 320 |
312 struct FindMatch { | |
313 RefPtr<WebCore::Range> m_range; | |
314 | |
315 // 1-based index within this frame. | |
316 int m_ordinal; | |
317 | |
318 // In find-in-page coordinates. | |
319 // Lazily calculated by updateFindMatchRects. | |
320 WebCore::FloatRect m_rect; | |
321 | |
322 FindMatch(PassRefPtr<WebCore::Range>, int ordinal); | |
323 }; | |
324 | |
325 // A bit mask specifying area of the frame to invalidate. | |
326 enum AreaToInvalidate { | |
327 InvalidateNothing, | |
328 InvalidateContentArea, | |
329 InvalidateScrollbar, // Vertical scrollbar only. | |
330 InvalidateAll // Both content area and the scrollbar. | |
331 }; | |
332 | |
333 explicit WebFrameImpl(WebFrameClient*); | 321 explicit WebFrameImpl(WebFrameClient*); |
334 | 322 |
335 // Sets the local WebCore frame and registers destruction observers. | 323 // Sets the local WebCore frame and registers destruction observers. |
336 void setWebCoreFrame(PassRefPtr<WebCore::LocalFrame>); | 324 void setWebCoreFrame(PassRefPtr<WebCore::LocalFrame>); |
337 | 325 |
338 // Notifies the delegate about a new selection rect. | |
339 void reportFindInPageSelection( | |
340 const WebRect& selectionRect, int activeMatchOrdinal, int identifier); | |
341 | |
342 // Clear the find-in-page matches cache forcing rects to be fully | |
343 // calculated again next time updateFindMatchRects is called. | |
344 void clearFindMatchesCache(); | |
345 | |
346 // Check if the activeMatchFrame still exists in the frame tree. | |
347 bool isActiveMatchFrameValid() const; | |
348 | |
349 // Return the index in the find-in-page cache of the match closest to the | |
350 // provided point in find-in-page coordinates, or -1 in case of error. | |
351 // The squared distance to the closest match is returned in the distanceSqua
red parameter. | |
352 int nearestFindMatch(const WebCore::FloatPoint&, float& distanceSquared); | |
353 | |
354 // Select a find-in-page match marker in the current frame using a cache | |
355 // match index returned by nearestFindMatch. Returns the ordinal of the new | |
356 // selected match or -1 in case of error. Also provides the bounding box of | |
357 // the marker in window coordinates if selectionRect is not null. | |
358 int selectFindMatch(unsigned index, WebRect* selectionRect); | |
359 | |
360 // Compute and cache the rects for FindMatches if required. | |
361 // Rects are automatically invalidated in case of content size changes, | |
362 // propagating the invalidation to child frames. | |
363 void updateFindMatchRects(); | |
364 | |
365 // Append the find-in-page match rects of the current frame to the provided
vector. | |
366 void appendFindMatchRects(Vector<WebFloatRect>& frameRects); | |
367 | |
368 // Invalidates a certain area within the frame. | |
369 void invalidateArea(AreaToInvalidate); | |
370 | |
371 // Add a WebKit TextMatch-highlight marker to nodes in a range. | |
372 void addMarker(WebCore::Range*, bool activeMatch); | |
373 | |
374 // Sets the markers within a range as active or inactive. | |
375 void setMarkerActive(WebCore::Range*, bool active); | |
376 | |
377 // Returns the ordinal of the first match in the frame specified. This | |
378 // function enumerates the frames, starting with the main frame and up to (b
ut | |
379 // not including) the frame passed in as a parameter and counts how many | |
380 // matches have been found. | |
381 int ordinalOfFirstMatchForFrame(WebFrameImpl*) const; | |
382 | |
383 // Determines whether the scoping effort is required for a particular frame. | |
384 // It is not necessary if the frame is invisible, for example, or if this | |
385 // is a repeat search that already returned nothing last time the same prefi
x | |
386 // was searched. | |
387 bool shouldScopeMatches(const WTF::String& searchText); | |
388 | |
389 // Removes the current frame from the global scoping effort and triggers any | |
390 // updates if appropriate. This method does not mark the scoping operation | |
391 // as finished. | |
392 void flushCurrentScopingEffort(int identifier); | |
393 | |
394 // Finishes the current scoping effort and triggers any updates if appropria
te. | |
395 void finishCurrentScopingEffort(int identifier); | |
396 | |
397 // Queue up a deferred call to scopeStringMatches. | |
398 void scopeStringMatchesSoon( | |
399 int identifier, const WebString& searchText, const WebFindOptions&, | |
400 bool reset); | |
401 | |
402 // Called by a DeferredScopeStringMatches instance. | |
403 void callScopeStringMatches( | |
404 DeferredScopeStringMatches*, int identifier, const WebString& searchText
, | |
405 const WebFindOptions&, bool reset); | |
406 | |
407 // Determines whether to invalidate the content area and scrollbar. | |
408 void invalidateIfNecessary(); | |
409 | |
410 void loadJavaScriptURL(const WebCore::KURL&); | 326 void loadJavaScriptURL(const WebCore::KURL&); |
411 | 327 |
412 // Returns a hit-tested VisiblePosition for the given point | 328 // Returns a hit-tested VisiblePosition for the given point |
413 WebCore::VisiblePosition visiblePositionForWindowPoint(const WebPoint&); | 329 WebCore::VisiblePosition visiblePositionForWindowPoint(const WebPoint&); |
414 | 330 |
415 WebPlugin* focusedPluginIfInputMethodSupported(); | 331 WebPlugin* focusedPluginIfInputMethodSupported(); |
416 | 332 |
417 FrameLoaderClientImpl m_frameLoaderClientImpl; | 333 FrameLoaderClientImpl m_frameLoaderClientImpl; |
418 | 334 |
419 // The embedder retains a reference to the WebCore LocalFrame while it is ac
tive in the DOM. This | 335 // The embedder retains a reference to the WebCore LocalFrame while it is ac
tive in the DOM. This |
(...skipping 10 matching lines...) Expand all Loading... |
430 WTF::HashSet<WebFrameImpl*> m_openedFrames; | 346 WTF::HashSet<WebFrameImpl*> m_openedFrames; |
431 | 347 |
432 // Indicate whether the current LocalFrame is local or remote. Remote frames
are | 348 // Indicate whether the current LocalFrame is local or remote. Remote frames
are |
433 // rendered in a different process from their parent frames. | 349 // rendered in a different process from their parent frames. |
434 bool m_isRemote; | 350 bool m_isRemote; |
435 | 351 |
436 WebFrameClient* m_client; | 352 WebFrameClient* m_client; |
437 WebPermissionClient* m_permissionClient; | 353 WebPermissionClient* m_permissionClient; |
438 OwnPtr<SharedWorkerRepositoryClientImpl> m_sharedWorkerRepositoryClient; | 354 OwnPtr<SharedWorkerRepositoryClientImpl> m_sharedWorkerRepositoryClient; |
439 | 355 |
440 // A way for the main frame to keep track of which frame has an active | 356 // Will be initialized after first call to find() or scopeStringMatches(). |
441 // match. Should be 0 for all other frames. | 357 OwnPtr<TextFinder> m_textFinder; |
442 WebFrameImpl* m_currentActiveMatchFrame; | |
443 | |
444 // The range of the active match for the current frame. | |
445 RefPtr<WebCore::Range> m_activeMatch; | |
446 | |
447 // The index of the active match for the current frame. | |
448 int m_activeMatchIndexInCurrentFrame; | |
449 | |
450 // This flag is used by the scoping effort to determine if we need to figure | |
451 // out which rectangle is the active match. Once we find the active | |
452 // rectangle we clear this flag. | |
453 bool m_locatingActiveRect; | |
454 | |
455 // The scoping effort can time out and we need to keep track of where we | |
456 // ended our last search so we can continue from where we left of. | |
457 RefPtr<WebCore::Range> m_resumeScopingFromRange; | |
458 | |
459 // Keeps track of the last string this frame searched for. This is used for | |
460 // short-circuiting searches in the following scenarios: When a frame has | |
461 // been searched and returned 0 results, we don't need to search that frame | |
462 // again if the user is just adding to the search (making it more specific). | |
463 WTF::String m_lastSearchString; | |
464 | |
465 // Keeps track of how many matches this frame has found so far, so that we | |
466 // don't loose count between scoping efforts, and is also used (in conjuncti
on | |
467 // with m_lastSearchString) to figure out if we need to search the frame aga
in. | |
468 int m_lastMatchCount; | |
469 | |
470 // This variable keeps a cumulative total of matches found so far for ALL th
e | |
471 // frames on the page, and is only incremented by calling IncreaseMatchCount | |
472 // (on the main frame only). It should be -1 for all other frames. | |
473 int m_totalMatchCount; | |
474 | |
475 // This variable keeps a cumulative total of how many frames are currently | |
476 // scoping, and is incremented/decremented on the main frame only. | |
477 // It should be -1 for all other frames. | |
478 int m_framesScopingCount; | |
479 | |
480 // Identifier of the latest find-in-page request. Required to be stored in | |
481 // the frame in order to reply if required in case the frame is detached. | |
482 int m_findRequestIdentifier; | |
483 | |
484 // Keeps track of whether there is an scoping effort ongoing in the frame. | |
485 bool m_scopingInProgress; | |
486 | |
487 // Keeps track of whether the last find request completed its scoping effort | |
488 // without finding any matches in this frame. | |
489 bool m_lastFindRequestCompletedWithNoMatches; | |
490 | |
491 // Keeps track of when the scoping effort should next invalidate the scrollb
ar | |
492 // and the frame area. | |
493 int m_nextInvalidateAfter; | |
494 | |
495 // A list of all of the pending calls to scopeStringMatches. | |
496 Vector<DeferredScopeStringMatches*> m_deferredScopingWork; | |
497 | |
498 // Version number incremented on the main frame only whenever the document | |
499 // find-in-page match markers change. It should be 0 for all other frames. | |
500 int m_findMatchMarkersVersion; | |
501 | |
502 // Local cache of the find match markers currently displayed for this frame. | |
503 Vector<FindMatch> m_findMatchesCache; | |
504 | |
505 // Determines if the rects in the find-in-page matches cache of this frame | |
506 // are invalid and should be recomputed. | |
507 bool m_findMatchRectsAreValid; | |
508 | |
509 // Contents size when find-in-page match rects were last computed for this | |
510 // frame's cache. | |
511 WebCore::IntSize m_contentsSizeForCurrentFindMatchRects; | |
512 | 358 |
513 // Valid between calls to BeginPrint() and EndPrint(). Containts the print | 359 // Valid between calls to BeginPrint() and EndPrint(). Containts the print |
514 // information. Is used by PrintPage(). | 360 // information. Is used by PrintPage(). |
515 OwnPtr<ChromePrintContext> m_printContext; | 361 OwnPtr<ChromePrintContext> m_printContext; |
516 | 362 |
517 // Stores the additional input events offset and scale when device metrics e
mulation is enabled. | 363 // Stores the additional input events offset and scale when device metrics e
mulation is enabled. |
518 WebCore::IntSize m_inputEventsOffsetForEmulation; | 364 WebCore::IntSize m_inputEventsOffsetForEmulation; |
519 float m_inputEventsScaleFactorForEmulation; | 365 float m_inputEventsScaleFactorForEmulation; |
520 }; | 366 }; |
521 | 367 |
522 DEFINE_TYPE_CASTS(WebFrameImpl, WebFrame, frame, true, true); | 368 DEFINE_TYPE_CASTS(WebFrameImpl, WebFrame, frame, true, true); |
523 | 369 |
524 } // namespace blink | 370 } // namespace blink |
525 | 371 |
526 #endif | 372 #endif |
OLD | NEW |