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