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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
615 m_sharedWorkerRepositoryClient = SharedWorkerRepositoryClientImpl::create(cl ient); | 615 m_sharedWorkerRepositoryClient = SharedWorkerRepositoryClientImpl::create(cl ient); |
616 } | 616 } |
617 | 617 |
618 ScrollableArea* WebLocalFrameImpl::layoutViewportScrollableArea() const | 618 ScrollableArea* WebLocalFrameImpl::layoutViewportScrollableArea() const |
619 { | 619 { |
620 if (FrameView* view = frameView()) | 620 if (FrameView* view = frameView()) |
621 return view->layoutViewportScrollableArea(); | 621 return view->layoutViewportScrollableArea(); |
622 return nullptr; | 622 return nullptr; |
623 } | 623 } |
624 | 624 |
625 bool WebLocalFrameImpl::isFocused() const | |
626 { | |
627 return this == WebFrame::fromFrame(viewImpl()->page()->focusController().foc usedFrame()); | |
628 } | |
629 | |
625 WebSize WebLocalFrameImpl::scrollOffset() const | 630 WebSize WebLocalFrameImpl::scrollOffset() const |
626 { | 631 { |
627 if (ScrollableArea* scrollableArea = layoutViewportScrollableArea()) | 632 if (ScrollableArea* scrollableArea = layoutViewportScrollableArea()) |
628 return toIntSize(scrollableArea->scrollPosition()); | 633 return toIntSize(scrollableArea->scrollPosition()); |
629 return WebSize(); | 634 return WebSize(); |
630 } | 635 } |
631 | 636 |
632 void WebLocalFrameImpl::setScrollOffset(const WebSize& offset) | 637 void WebLocalFrameImpl::setScrollOffset(const WebSize& offset) |
633 { | 638 { |
634 if (ScrollableArea* scrollableArea = layoutViewportScrollableArea()) | 639 if (ScrollableArea* scrollableArea = layoutViewportScrollableArea()) |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1546 // Note a synchronous navigation (about:blank) would have already processed | 1551 // Note a synchronous navigation (about:blank) would have already processed |
1547 // onload, so it is possible for the child frame to have already been | 1552 // onload, so it is possible for the child frame to have already been |
1548 // detached by script in the page. | 1553 // detached by script in the page. |
1549 if (!webframeChild->parent()) | 1554 if (!webframeChild->parent()) |
1550 return nullptr; | 1555 return nullptr; |
1551 return webframeChild->frame(); | 1556 return webframeChild->frame(); |
1552 } | 1557 } |
1553 | 1558 |
1554 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size) | 1559 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size) |
1555 { | 1560 { |
1556 // This is only possible on the main frame. | 1561 if (m_textFinder && m_textFinder->totalMatchCount() > 0) |
1557 if (m_textFinder && m_textFinder->totalMatchCount() > 0) { | |
1558 DCHECK(!parent()); | |
1559 m_textFinder->increaseMarkerVersion(); | 1562 m_textFinder->increaseMarkerVersion(); |
1560 } | |
1561 } | 1563 } |
1562 | 1564 |
1563 void WebLocalFrameImpl::createFrameView() | 1565 void WebLocalFrameImpl::createFrameView() |
1564 { | 1566 { |
1565 TRACE_EVENT0("blink", "WebLocalFrameImpl::createFrameView"); | 1567 TRACE_EVENT0("blink", "WebLocalFrameImpl::createFrameView"); |
1566 | 1568 |
1567 DCHECK(frame()); // If frame() doesn't exist, we probably didn't init proper ly. | 1569 DCHECK(frame()); // If frame() doesn't exist, we probably didn't init proper ly. |
1568 | 1570 |
1569 WebViewImpl* webView = viewImpl(); | 1571 WebViewImpl* webView = viewImpl(); |
1570 | 1572 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1618 return static_cast<WebDataSourceImpl*>(dataSource()); | 1620 return static_cast<WebDataSourceImpl*>(dataSource()); |
1619 } | 1621 } |
1620 | 1622 |
1621 WebDataSourceImpl* WebLocalFrameImpl::provisionalDataSourceImpl() const | 1623 WebDataSourceImpl* WebLocalFrameImpl::provisionalDataSourceImpl() const |
1622 { | 1624 { |
1623 return static_cast<WebDataSourceImpl*>(provisionalDataSource()); | 1625 return static_cast<WebDataSourceImpl*>(provisionalDataSource()); |
1624 } | 1626 } |
1625 | 1627 |
1626 void WebLocalFrameImpl::setFindEndstateFocusAndSelection() | 1628 void WebLocalFrameImpl::setFindEndstateFocusAndSelection() |
1627 { | 1629 { |
1628 WebLocalFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); | 1630 if (!m_textFinder || !m_textFinder->activeMatchFrame()) |
1629 | |
1630 // Main frame should already have a textFinder at this point of time. | |
1631 DCHECK(mainFrameImpl->textFinder()); | |
1632 | |
1633 if (this != mainFrameImpl->textFinder()->activeMatchFrame()) | |
1634 return; | 1631 return; |
1635 | 1632 |
1636 if (Range* activeMatch = m_textFinder->activeMatch()) { | 1633 if (Range* activeMatch = m_textFinder->activeMatch()) { |
1637 // If the user has set the selection since the match was found, we | 1634 // If the user has set the selection since the match was found, we |
1638 // don't focus anything. | 1635 // don't focus anything. |
1639 VisibleSelection selection(frame()->selection().selection()); | 1636 VisibleSelection selection(frame()->selection().selection()); |
1640 if (!selection.isNone()) | 1637 if (!selection.isNone()) |
1641 return; | 1638 return; |
1642 | 1639 |
1643 // Need to clean out style and layout state before querying Element::isF ocusable(). | 1640 // Need to clean out style and layout state before querying Element::isF ocusable(). |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1969 UseCounter::count(frame(), UseCounter::ExternalAddSearchProvider); | 1966 UseCounter::count(frame(), UseCounter::ExternalAddSearchProvider); |
1970 } | 1967 } |
1971 | 1968 |
1972 void WebLocalFrameImpl::didCallIsSearchProviderInstalled() | 1969 void WebLocalFrameImpl::didCallIsSearchProviderInstalled() |
1973 { | 1970 { |
1974 UseCounter::count(frame(), UseCounter::ExternalIsSearchProviderInstalled); | 1971 UseCounter::count(frame(), UseCounter::ExternalIsSearchProviderInstalled); |
1975 } | 1972 } |
1976 | 1973 |
1977 bool WebLocalFrameImpl::find(int identifier, const WebString& searchText, const WebFindOptions& options, bool wrapWithinFrame, WebRect* selectionRect, bool* act iveNow) | 1974 bool WebLocalFrameImpl::find(int identifier, const WebString& searchText, const WebFindOptions& options, bool wrapWithinFrame, WebRect* selectionRect, bool* act iveNow) |
1978 { | 1975 { |
1979 return ensureTextFinder().find(identifier, searchText, options, wrapWithinFr ame, selectionRect, activeNow); | 1976 // Search for an active match only if this frame is focused or if this is a |
1977 // find next request. | |
1978 if (isFocused() || options.findNext) | |
1979 return ensureTextFinder().find(identifier, searchText, options, wrapWith inFrame, selectionRect, activeNow); | |
1980 | |
1981 return false; | |
1980 } | 1982 } |
1981 | 1983 |
1982 void WebLocalFrameImpl::stopFinding(bool clearSelection) | 1984 void WebLocalFrameImpl::stopFinding(StopFindAction action) |
1983 { | 1985 { |
1986 bool clearSelection = action == StopFindActionClearSelection; | |
1987 if (clearSelection) | |
1988 executeCommand(WebString::fromUTF8("Unselect")); | |
dglazkov
2016/06/02 01:08:42
Curious -- why is this necessary now? Why wasn't i
paulmeyer
2016/06/02 17:36:37
I saw that you said I could disregard these commen
| |
1989 | |
1984 if (m_textFinder) { | 1990 if (m_textFinder) { |
1985 if (!clearSelection) | 1991 if (!clearSelection) |
1986 setFindEndstateFocusAndSelection(); | 1992 setFindEndstateFocusAndSelection(); |
1987 m_textFinder->stopFindingAndClearSelection(); | 1993 m_textFinder->stopFindingAndClearSelection(); |
1988 } | 1994 } |
1995 | |
1996 if (action == StopFindActionActivateSelection && isFocused()) { | |
1997 WebDocument doc = document(); | |
1998 if (!doc.isNull()) { | |
dglazkov
2016/06/02 01:08:42
It's not possible for a frame to be focused and no
paulmeyer
2016/06/02 17:36:36
I'm actually not sure. It was checked before, so I
| |
1999 WebElement element = doc.focusedElement(); | |
2000 if (!element.isNull()) | |
2001 element.simulateClick(); | |
dglazkov
2016/06/02 01:08:42
Huh. This is also new code? Why do we need to do t
paulmeyer
2016/06/02 17:36:37
This is the functionality of the "activate" action
| |
2002 } | |
2003 } | |
1989 } | 2004 } |
1990 | 2005 |
1991 void WebLocalFrameImpl::scopeStringMatches(int identifier, const WebString& sear chText, const WebFindOptions& options, bool reset) | 2006 void WebLocalFrameImpl::scopeStringMatches(int identifier, const WebString& sear chText, const WebFindOptions& options, bool reset) |
1992 { | 2007 { |
1993 ensureTextFinder().scopeStringMatches(identifier, searchText, options, reset ); | 2008 ensureTextFinder().scopeStringMatches(identifier, searchText, options, reset ); |
1994 } | 2009 } |
1995 | 2010 |
1996 void WebLocalFrameImpl::cancelPendingScopingEffort() | 2011 void WebLocalFrameImpl::cancelPendingScopingEffort() |
1997 { | 2012 { |
1998 if (m_textFinder) | 2013 if (m_textFinder) |
1999 m_textFinder->cancelPendingScopingEffort(); | 2014 m_textFinder->cancelPendingScopingEffort(); |
2000 } | 2015 } |
2001 | 2016 |
2002 void WebLocalFrameImpl::increaseMatchCount(int count, int identifier) | 2017 void WebLocalFrameImpl::increaseMatchCount(int count, int identifier) |
2003 { | 2018 { |
2004 // This function should only be called on the mainframe. | |
2005 DCHECK(!parent()); | |
2006 ensureTextFinder().increaseMatchCount(identifier, count); | 2019 ensureTextFinder().increaseMatchCount(identifier, count); |
2007 } | 2020 } |
2008 | 2021 |
2009 void WebLocalFrameImpl::resetMatchCount() | 2022 void WebLocalFrameImpl::resetMatchCount() |
2010 { | 2023 { |
2011 ensureTextFinder().resetMatchCount(); | 2024 ensureTextFinder().resetMatchCount(); |
2012 } | 2025 } |
2013 | 2026 |
2014 void WebLocalFrameImpl::dispatchMessageEventWithOriginCheck(const WebSecurityOri gin& intendedTargetOrigin, const WebDOMEvent& event) | 2027 void WebLocalFrameImpl::dispatchMessageEventWithOriginCheck(const WebSecurityOri gin& intendedTargetOrigin, const WebDOMEvent& event) |
2015 { | 2028 { |
2016 DCHECK(!event.isNull()); | 2029 DCHECK(!event.isNull()); |
2017 frame()->localDOMWindow()->dispatchMessageEventWithOriginCheck(intendedTarge tOrigin.get(), event, nullptr); | 2030 frame()->localDOMWindow()->dispatchMessageEventWithOriginCheck(intendedTarge tOrigin.get(), event, nullptr); |
2018 } | 2031 } |
2019 | 2032 |
2020 int WebLocalFrameImpl::findMatchMarkersVersion() const | 2033 int WebLocalFrameImpl::findMatchMarkersVersion() const |
2021 { | 2034 { |
2022 DCHECK(!parent()); | |
2023 | |
2024 if (m_textFinder) | 2035 if (m_textFinder) |
2025 return m_textFinder->findMatchMarkersVersion(); | 2036 return m_textFinder->findMatchMarkersVersion(); |
2026 return 0; | 2037 return 0; |
2027 } | 2038 } |
2028 | 2039 |
2029 int WebLocalFrameImpl::selectNearestFindMatch(const WebFloatPoint& point, WebRec t* selectionRect) | 2040 int WebLocalFrameImpl::selectNearestFindMatch(const WebFloatPoint& point, WebRec t* selectionRect) |
2030 { | 2041 { |
2031 DCHECK(!parent()); | |
2032 return ensureTextFinder().selectNearestFindMatch(point, selectionRect); | 2042 return ensureTextFinder().selectNearestFindMatch(point, selectionRect); |
2033 } | 2043 } |
2034 | 2044 |
2045 float WebLocalFrameImpl::distanceToNearestFindMatch(const WebFloatPoint& point) | |
2046 { | |
2047 float nearestDistance; | |
2048 ensureTextFinder().nearestFindMatch(point, &nearestDistance); | |
2049 return nearestDistance; | |
2050 } | |
2051 | |
2035 WebFloatRect WebLocalFrameImpl::activeFindMatchRect() | 2052 WebFloatRect WebLocalFrameImpl::activeFindMatchRect() |
2036 { | 2053 { |
2037 DCHECK(!parent()); | |
2038 | |
2039 if (m_textFinder) | 2054 if (m_textFinder) |
2040 return m_textFinder->activeFindMatchRect(); | 2055 return m_textFinder->activeFindMatchRect(); |
2041 return WebFloatRect(); | 2056 return WebFloatRect(); |
2042 } | 2057 } |
2043 | 2058 |
2044 void WebLocalFrameImpl::findMatchRects(WebVector<WebFloatRect>& outputRects) | 2059 void WebLocalFrameImpl::findMatchRects(WebVector<WebFloatRect>& outputRects) |
2045 { | 2060 { |
2046 DCHECK(!parent()); | |
2047 ensureTextFinder().findMatchRects(outputRects); | 2061 ensureTextFinder().findMatchRects(outputRects); |
2048 } | 2062 } |
2049 | 2063 |
2050 void WebLocalFrameImpl::setTickmarks(const WebVector<WebRect>& tickmarks) | 2064 void WebLocalFrameImpl::setTickmarks(const WebVector<WebRect>& tickmarks) |
2051 { | 2065 { |
2052 if (frameView()) { | 2066 if (frameView()) { |
2053 Vector<IntRect> tickmarksConverted(tickmarks.size()); | 2067 Vector<IntRect> tickmarksConverted(tickmarks.size()); |
2054 for (size_t i = 0; i < tickmarks.size(); ++i) | 2068 for (size_t i = 0; i < tickmarks.size(); ++i) |
2055 tickmarksConverted[i] = tickmarks[i]; | 2069 tickmarksConverted[i] = tickmarks[i]; |
2056 frameView()->setTickmarks(tickmarksConverted); | 2070 frameView()->setTickmarks(tickmarksConverted); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2105 if (!frame()) | 2119 if (!frame()) |
2106 return WebSandboxFlags::None; | 2120 return WebSandboxFlags::None; |
2107 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( )); | 2121 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( )); |
2108 } | 2122 } |
2109 | 2123 |
2110 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) | 2124 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) |
2111 { | 2125 { |
2112 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); | 2126 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); |
2113 } | 2127 } |
2114 | 2128 |
2129 void WebLocalFrameImpl::clearActiveFindMatch() | |
2130 { | |
2131 ensureTextFinder().clearActiveFindMatch(); | |
2132 } | |
2133 | |
2115 } // namespace blink | 2134 } // namespace blink |
OLD | NEW |