| Index: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
|
| diff --git a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
|
| index 5d633b5ab2b9b3bdb66b7ed4b2e09d5a25a8d31c..9fd72e83384c6bef4023ad529825db9b44ea0bc5 100644
|
| --- a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
|
| +++ b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
|
| @@ -622,6 +622,11 @@ ScrollableArea* WebLocalFrameImpl::layoutViewportScrollableArea() const
|
| return nullptr;
|
| }
|
|
|
| +bool WebLocalFrameImpl::isFocused() const
|
| +{
|
| + return this == WebFrame::fromFrame(viewImpl()->page()->focusController().focusedFrame());
|
| +}
|
| +
|
| WebSize WebLocalFrameImpl::scrollOffset() const
|
| {
|
| if (ScrollableArea* scrollableArea = layoutViewportScrollableArea())
|
| @@ -1553,11 +1558,8 @@ LocalFrame* WebLocalFrameImpl::createChildFrame(const FrameLoadRequest& request,
|
|
|
| void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size)
|
| {
|
| - // This is only possible on the main frame.
|
| - if (m_textFinder && m_textFinder->totalMatchCount() > 0) {
|
| - DCHECK(!parent());
|
| + if (m_textFinder && m_textFinder->totalMatchCount() > 0)
|
| m_textFinder->increaseMarkerVersion();
|
| - }
|
| }
|
|
|
| void WebLocalFrameImpl::createFrameView()
|
| @@ -1625,12 +1627,7 @@ WebDataSourceImpl* WebLocalFrameImpl::provisionalDataSourceImpl() const
|
|
|
| void WebLocalFrameImpl::setFindEndstateFocusAndSelection()
|
| {
|
| - WebLocalFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
|
| -
|
| - // Main frame should already have a textFinder at this point of time.
|
| - DCHECK(mainFrameImpl->textFinder());
|
| -
|
| - if (this != mainFrameImpl->textFinder()->activeMatchFrame())
|
| + if (!m_textFinder || !m_textFinder->activeMatchFrame())
|
| return;
|
|
|
| if (Range* activeMatch = m_textFinder->activeMatch()) {
|
| @@ -1976,16 +1973,36 @@ void WebLocalFrameImpl::didCallIsSearchProviderInstalled()
|
|
|
| bool WebLocalFrameImpl::find(int identifier, const WebString& searchText, const WebFindOptions& options, bool wrapWithinFrame, WebRect* selectionRect, bool* activeNow)
|
| {
|
| - return ensureTextFinder().find(identifier, searchText, options, wrapWithinFrame, selectionRect, activeNow);
|
| + // Search for an active match only if this frame is focused or if this is a
|
| + // find next request.
|
| + if (isFocused() || options.findNext)
|
| + return ensureTextFinder().find(identifier, searchText, options, wrapWithinFrame, selectionRect, activeNow);
|
| +
|
| + return false;
|
| }
|
|
|
| -void WebLocalFrameImpl::stopFinding(bool clearSelection)
|
| +void WebLocalFrameImpl::stopFinding(bool clearSelection, bool activateSelection)
|
| {
|
| + // The selection cannot be both cleared and activated.
|
| + DCHECK(!(clearSelection && activateSelection));
|
| +
|
| + if (clearSelection)
|
| + executeCommand(WebString::fromUTF8("Unselect"));
|
| +
|
| if (m_textFinder) {
|
| if (!clearSelection)
|
| setFindEndstateFocusAndSelection();
|
| m_textFinder->stopFindingAndClearSelection();
|
| }
|
| +
|
| + if (activateSelection && isFocused()) {
|
| + WebDocument doc = document();
|
| + if (!doc.isNull()) {
|
| + WebElement element = doc.focusedElement();
|
| + if (!element.isNull())
|
| + element.simulateClick();
|
| + }
|
| + }
|
| }
|
|
|
| void WebLocalFrameImpl::scopeStringMatches(int identifier, const WebString& searchText, const WebFindOptions& options, bool reset)
|
| @@ -2001,8 +2018,6 @@ void WebLocalFrameImpl::cancelPendingScopingEffort()
|
|
|
| void WebLocalFrameImpl::increaseMatchCount(int count, int identifier)
|
| {
|
| - // This function should only be called on the mainframe.
|
| - DCHECK(!parent());
|
| ensureTextFinder().increaseMatchCount(identifier, count);
|
| }
|
|
|
| @@ -2019,8 +2034,6 @@ void WebLocalFrameImpl::dispatchMessageEventWithOriginCheck(const WebSecurityOri
|
|
|
| int WebLocalFrameImpl::findMatchMarkersVersion() const
|
| {
|
| - DCHECK(!parent());
|
| -
|
| if (m_textFinder)
|
| return m_textFinder->findMatchMarkersVersion();
|
| return 0;
|
| @@ -2028,14 +2041,18 @@ int WebLocalFrameImpl::findMatchMarkersVersion() const
|
|
|
| int WebLocalFrameImpl::selectNearestFindMatch(const WebFloatPoint& point, WebRect* selectionRect)
|
| {
|
| - DCHECK(!parent());
|
| return ensureTextFinder().selectNearestFindMatch(point, selectionRect);
|
| }
|
|
|
| -WebFloatRect WebLocalFrameImpl::activeFindMatchRect()
|
| +float WebLocalFrameImpl::nearestFindMatch(const WebFloatPoint& point)
|
| {
|
| - DCHECK(!parent());
|
| + float nearestDistance;
|
| + ensureTextFinder().nearestFindMatch(point, &nearestDistance);
|
| + return nearestDistance;
|
| +}
|
|
|
| +WebFloatRect WebLocalFrameImpl::activeFindMatchRect()
|
| +{
|
| if (m_textFinder)
|
| return m_textFinder->activeFindMatchRect();
|
| return WebFloatRect();
|
| @@ -2043,7 +2060,6 @@ WebFloatRect WebLocalFrameImpl::activeFindMatchRect()
|
|
|
| void WebLocalFrameImpl::findMatchRects(WebVector<WebFloatRect>& outputRects)
|
| {
|
| - DCHECK(!parent());
|
| ensureTextFinder().findMatchRects(outputRects);
|
| }
|
|
|
| @@ -2112,4 +2128,9 @@ void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags)
|
| frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags));
|
| }
|
|
|
| +void WebLocalFrameImpl::clearActiveFindMatch()
|
| +{
|
| + ensureTextFinder().clearActiveFindMatch();
|
| +}
|
| +
|
| } // namespace blink
|
|
|