| Index: Source/web/WebFrameImpl.h
|
| diff --git a/Source/web/WebFrameImpl.h b/Source/web/WebFrameImpl.h
|
| index 5d00126bf014623e2b0c4a55c5d48571f12ccce3..ab2fb86e9b76c36ce8705175efaa3ea20260c38b 100644
|
| --- a/Source/web/WebFrameImpl.h
|
| +++ b/Source/web/WebFrameImpl.h
|
| @@ -58,7 +58,6 @@
|
| namespace blink {
|
| class ChromePrintContext;
|
| class SharedWorkerRepositoryClientImpl;
|
| -class TextFinder;
|
| class WebDataSourceImpl;
|
| class WebInputElement;
|
| class WebFrameClient;
|
| @@ -278,11 +277,11 @@
|
| // Returns which frame has an active match. This function should only be
|
| // called on the main frame, as it is the only frame keeping track. Returned
|
| // value can be 0 if no frame has an active match.
|
| - WebFrameImpl* activeMatchFrame() const;
|
| + WebFrameImpl* activeMatchFrame() const { return m_currentActiveMatchFrame; }
|
|
|
| // Returns the active match in the current frame. Could be a null range if
|
| // the local frame has no active match.
|
| - WebCore::Range* activeMatch() const;
|
| + WebCore::Range* activeMatch() const { return m_activeMatch.get(); }
|
|
|
| // When a Find operation ends, we want to set the selection to what was active
|
| // and set focus to the first focusable node we find (starting with the first
|
| @@ -310,17 +309,108 @@
|
|
|
| static void selectWordAroundPosition(WebCore::Frame*, WebCore::VisiblePosition);
|
|
|
| - // Returns the text finder object if it already exists.
|
| - // Otherwise creates it and then returns.
|
| - TextFinder& getOrCreateTextFinder();
|
| -
|
| private:
|
| + class DeferredScopeStringMatches;
|
| + friend class DeferredScopeStringMatches;
|
| friend class FrameLoaderClientImpl;
|
| +
|
| + struct FindMatch {
|
| + RefPtr<WebCore::Range> m_range;
|
| +
|
| + // 1-based index within this frame.
|
| + int m_ordinal;
|
| +
|
| + // In find-in-page coordinates.
|
| + // Lazily calculated by updateFindMatchRects.
|
| + WebCore::FloatRect m_rect;
|
| +
|
| + FindMatch(PassRefPtr<WebCore::Range>, int ordinal);
|
| + };
|
| +
|
| + // A bit mask specifying area of the frame to invalidate.
|
| + enum AreaToInvalidate {
|
| + InvalidateNothing,
|
| + InvalidateContentArea,
|
| + InvalidateScrollbar, // Vertical scrollbar only.
|
| + InvalidateAll // Both content area and the scrollbar.
|
| + };
|
|
|
| WebFrameImpl(WebFrameClient*, long long frame_identifier);
|
|
|
| // Sets the local WebCore frame and registers destruction observers.
|
| void setWebCoreFrame(PassRefPtr<WebCore::Frame>);
|
| +
|
| + // Notifies the delegate about a new selection rect.
|
| + void reportFindInPageSelection(
|
| + const WebRect& selectionRect, int activeMatchOrdinal, int identifier);
|
| +
|
| + // Clear the find-in-page matches cache forcing rects to be fully
|
| + // calculated again next time updateFindMatchRects is called.
|
| + void clearFindMatchesCache();
|
| +
|
| + // Check if the activeMatchFrame still exists in the frame tree.
|
| + bool isActiveMatchFrameValid() const;
|
| +
|
| + // Return the index in the find-in-page cache of the match closest to the
|
| + // provided point in find-in-page coordinates, or -1 in case of error.
|
| + // The squared distance to the closest match is returned in the distanceSquared parameter.
|
| + int nearestFindMatch(const WebCore::FloatPoint&, float& distanceSquared);
|
| +
|
| + // Select a find-in-page match marker in the current frame using a cache
|
| + // match index returned by nearestFindMatch. Returns the ordinal of the new
|
| + // selected match or -1 in case of error. Also provides the bounding box of
|
| + // the marker in window coordinates if selectionRect is not null.
|
| + int selectFindMatch(unsigned index, WebRect* selectionRect);
|
| +
|
| + // Compute and cache the rects for FindMatches if required.
|
| + // Rects are automatically invalidated in case of content size changes,
|
| + // propagating the invalidation to child frames.
|
| + void updateFindMatchRects();
|
| +
|
| + // Append the find-in-page match rects of the current frame to the provided vector.
|
| + void appendFindMatchRects(Vector<WebFloatRect>& frameRects);
|
| +
|
| + // Invalidates a certain area within the frame.
|
| + void invalidateArea(AreaToInvalidate);
|
| +
|
| + // Add a WebKit TextMatch-highlight marker to nodes in a range.
|
| + void addMarker(WebCore::Range*, bool activeMatch);
|
| +
|
| + // Sets the markers within a range as active or inactive.
|
| + void setMarkerActive(WebCore::Range*, bool active);
|
| +
|
| + // Returns the ordinal of the first match in the frame specified. This
|
| + // function enumerates the frames, starting with the main frame and up to (but
|
| + // not including) the frame passed in as a parameter and counts how many
|
| + // matches have been found.
|
| + int ordinalOfFirstMatchForFrame(WebFrameImpl*) const;
|
| +
|
| + // Determines whether the scoping effort is required for a particular frame.
|
| + // It is not necessary if the frame is invisible, for example, or if this
|
| + // is a repeat search that already returned nothing last time the same prefix
|
| + // was searched.
|
| + bool shouldScopeMatches(const WTF::String& searchText);
|
| +
|
| + // Removes the current frame from the global scoping effort and triggers any
|
| + // updates if appropriate. This method does not mark the scoping operation
|
| + // as finished.
|
| + void flushCurrentScopingEffort(int identifier);
|
| +
|
| + // Finishes the current scoping effort and triggers any updates if appropriate.
|
| + void finishCurrentScopingEffort(int identifier);
|
| +
|
| + // Queue up a deferred call to scopeStringMatches.
|
| + void scopeStringMatchesSoon(
|
| + int identifier, const WebString& searchText, const WebFindOptions&,
|
| + bool reset);
|
| +
|
| + // Called by a DeferredScopeStringMatches instance.
|
| + void callScopeStringMatches(
|
| + DeferredScopeStringMatches*, int identifier, const WebString& searchText,
|
| + const WebFindOptions&, bool reset);
|
| +
|
| + // Determines whether to invalidate the content area and scrollbar.
|
| + void invalidateIfNecessary();
|
|
|
| void loadJavaScriptURL(const WebCore::KURL&);
|
|
|
| @@ -354,8 +444,78 @@
|
| WebPermissionClient* m_permissionClient;
|
| OwnPtr<SharedWorkerRepositoryClientImpl> m_sharedWorkerRepositoryClient;
|
|
|
| - // Will be initialized after first call to find() or scopeStringMatches().
|
| - OwnPtr<TextFinder> m_textFinder;
|
| + // A way for the main frame to keep track of which frame has an active
|
| + // match. Should be 0 for all other frames.
|
| + WebFrameImpl* m_currentActiveMatchFrame;
|
| +
|
| + // The range of the active match for the current frame.
|
| + RefPtr<WebCore::Range> m_activeMatch;
|
| +
|
| + // The index of the active match for the current frame.
|
| + int m_activeMatchIndexInCurrentFrame;
|
| +
|
| + // This flag is used by the scoping effort to determine if we need to figure
|
| + // out which rectangle is the active match. Once we find the active
|
| + // rectangle we clear this flag.
|
| + bool m_locatingActiveRect;
|
| +
|
| + // The scoping effort can time out and we need to keep track of where we
|
| + // ended our last search so we can continue from where we left of.
|
| + RefPtr<WebCore::Range> m_resumeScopingFromRange;
|
| +
|
| + // Keeps track of the last string this frame searched for. This is used for
|
| + // short-circuiting searches in the following scenarios: When a frame has
|
| + // been searched and returned 0 results, we don't need to search that frame
|
| + // again if the user is just adding to the search (making it more specific).
|
| + WTF::String m_lastSearchString;
|
| +
|
| + // Keeps track of how many matches this frame has found so far, so that we
|
| + // don't loose count between scoping efforts, and is also used (in conjunction
|
| + // with m_lastSearchString) to figure out if we need to search the frame again.
|
| + int m_lastMatchCount;
|
| +
|
| + // This variable keeps a cumulative total of matches found so far for ALL the
|
| + // frames on the page, and is only incremented by calling IncreaseMatchCount
|
| + // (on the main frame only). It should be -1 for all other frames.
|
| + int m_totalMatchCount;
|
| +
|
| + // This variable keeps a cumulative total of how many frames are currently
|
| + // scoping, and is incremented/decremented on the main frame only.
|
| + // It should be -1 for all other frames.
|
| + int m_framesScopingCount;
|
| +
|
| + // Identifier of the latest find-in-page request. Required to be stored in
|
| + // the frame in order to reply if required in case the frame is detached.
|
| + int m_findRequestIdentifier;
|
| +
|
| + // Keeps track of whether there is an scoping effort ongoing in the frame.
|
| + bool m_scopingInProgress;
|
| +
|
| + // Keeps track of whether the last find request completed its scoping effort
|
| + // without finding any matches in this frame.
|
| + bool m_lastFindRequestCompletedWithNoMatches;
|
| +
|
| + // Keeps track of when the scoping effort should next invalidate the scrollbar
|
| + // and the frame area.
|
| + int m_nextInvalidateAfter;
|
| +
|
| + // A list of all of the pending calls to scopeStringMatches.
|
| + Vector<DeferredScopeStringMatches*> m_deferredScopingWork;
|
| +
|
| + // Version number incremented on the main frame only whenever the document
|
| + // find-in-page match markers change. It should be 0 for all other frames.
|
| + int m_findMatchMarkersVersion;
|
| +
|
| + // Local cache of the find match markers currently displayed for this frame.
|
| + Vector<FindMatch> m_findMatchesCache;
|
| +
|
| + // Determines if the rects in the find-in-page matches cache of this frame
|
| + // are invalid and should be recomputed.
|
| + bool m_findMatchRectsAreValid;
|
| +
|
| + // Contents size when find-in-page match rects were last computed for this
|
| + // frame's cache.
|
| + WebCore::IntSize m_contentsSizeForCurrentFindMatchRects;
|
|
|
| // Valid between calls to BeginPrint() and EndPrint(). Containts the print
|
| // information. Is used by PrintPage().
|
|
|