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