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 if (!viewImpl() || !viewImpl()->page()) |
| 628 return false; |
| 629 |
| 630 return this == WebFrame::fromFrame(viewImpl()->page()->focusController().foc
usedFrame()); |
| 631 } |
| 632 |
625 WebSize WebLocalFrameImpl::scrollOffset() const | 633 WebSize WebLocalFrameImpl::scrollOffset() const |
626 { | 634 { |
627 if (ScrollableArea* scrollableArea = layoutViewportScrollableArea()) | 635 if (ScrollableArea* scrollableArea = layoutViewportScrollableArea()) |
628 return toIntSize(scrollableArea->scrollPosition()); | 636 return toIntSize(scrollableArea->scrollPosition()); |
629 return WebSize(); | 637 return WebSize(); |
630 } | 638 } |
631 | 639 |
632 void WebLocalFrameImpl::setScrollOffset(const WebSize& offset) | 640 void WebLocalFrameImpl::setScrollOffset(const WebSize& offset) |
633 { | 641 { |
634 if (ScrollableArea* scrollableArea = layoutViewportScrollableArea()) | 642 if (ScrollableArea* scrollableArea = layoutViewportScrollableArea()) |
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 // Note a synchronous navigation (about:blank) would have already processed | 1543 // Note a synchronous navigation (about:blank) would have already processed |
1536 // onload, so it is possible for the child frame to have already been | 1544 // onload, so it is possible for the child frame to have already been |
1537 // detached by script in the page. | 1545 // detached by script in the page. |
1538 if (!webframeChild->parent()) | 1546 if (!webframeChild->parent()) |
1539 return nullptr; | 1547 return nullptr; |
1540 return webframeChild->frame(); | 1548 return webframeChild->frame(); |
1541 } | 1549 } |
1542 | 1550 |
1543 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size) | 1551 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size) |
1544 { | 1552 { |
1545 // This is only possible on the main frame. | 1553 if (m_textFinder && m_textFinder->totalMatchCount() > 0) |
1546 if (m_textFinder && m_textFinder->totalMatchCount() > 0) { | |
1547 DCHECK(!parent()); | |
1548 m_textFinder->increaseMarkerVersion(); | 1554 m_textFinder->increaseMarkerVersion(); |
1549 } | |
1550 } | 1555 } |
1551 | 1556 |
1552 void WebLocalFrameImpl::createFrameView() | 1557 void WebLocalFrameImpl::createFrameView() |
1553 { | 1558 { |
1554 TRACE_EVENT0("blink", "WebLocalFrameImpl::createFrameView"); | 1559 TRACE_EVENT0("blink", "WebLocalFrameImpl::createFrameView"); |
1555 | 1560 |
1556 DCHECK(frame()); // If frame() doesn't exist, we probably didn't init proper
ly. | 1561 DCHECK(frame()); // If frame() doesn't exist, we probably didn't init proper
ly. |
1557 | 1562 |
1558 WebViewImpl* webView = viewImpl(); | 1563 WebViewImpl* webView = viewImpl(); |
1559 | 1564 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1607 return static_cast<WebDataSourceImpl*>(dataSource()); | 1612 return static_cast<WebDataSourceImpl*>(dataSource()); |
1608 } | 1613 } |
1609 | 1614 |
1610 WebDataSourceImpl* WebLocalFrameImpl::provisionalDataSourceImpl() const | 1615 WebDataSourceImpl* WebLocalFrameImpl::provisionalDataSourceImpl() const |
1611 { | 1616 { |
1612 return static_cast<WebDataSourceImpl*>(provisionalDataSource()); | 1617 return static_cast<WebDataSourceImpl*>(provisionalDataSource()); |
1613 } | 1618 } |
1614 | 1619 |
1615 void WebLocalFrameImpl::setFindEndstateFocusAndSelection() | 1620 void WebLocalFrameImpl::setFindEndstateFocusAndSelection() |
1616 { | 1621 { |
1617 WebLocalFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); | 1622 if (!m_textFinder || !m_textFinder->activeMatchFrame()) |
1618 | |
1619 // Main frame should already have a textFinder at this point of time. | |
1620 DCHECK(mainFrameImpl->textFinder()); | |
1621 | |
1622 if (this != mainFrameImpl->textFinder()->activeMatchFrame()) | |
1623 return; | 1623 return; |
1624 | 1624 |
1625 if (Range* activeMatch = m_textFinder->activeMatch()) { | 1625 if (Range* activeMatch = m_textFinder->activeMatch()) { |
1626 // If the user has set the selection since the match was found, we | 1626 // If the user has set the selection since the match was found, we |
1627 // don't focus anything. | 1627 // don't focus anything. |
1628 VisibleSelection selection(frame()->selection().selection()); | 1628 VisibleSelection selection(frame()->selection().selection()); |
1629 if (!selection.isNone()) | 1629 if (!selection.isNone()) |
1630 return; | 1630 return; |
1631 | 1631 |
1632 // Need to clean out style and layout state before querying Element::isF
ocusable(). | 1632 // Need to clean out style and layout state before querying Element::isF
ocusable(). |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1955 UseCounter::count(frame(), UseCounter::ExternalAddSearchProvider); | 1955 UseCounter::count(frame(), UseCounter::ExternalAddSearchProvider); |
1956 } | 1956 } |
1957 | 1957 |
1958 void WebLocalFrameImpl::didCallIsSearchProviderInstalled() | 1958 void WebLocalFrameImpl::didCallIsSearchProviderInstalled() |
1959 { | 1959 { |
1960 UseCounter::count(frame(), UseCounter::ExternalIsSearchProviderInstalled); | 1960 UseCounter::count(frame(), UseCounter::ExternalIsSearchProviderInstalled); |
1961 } | 1961 } |
1962 | 1962 |
1963 bool WebLocalFrameImpl::find(int identifier, const WebString& searchText, const
WebFindOptions& options, bool wrapWithinFrame, WebRect* selectionRect, bool* act
iveNow) | 1963 bool WebLocalFrameImpl::find(int identifier, const WebString& searchText, const
WebFindOptions& options, bool wrapWithinFrame, WebRect* selectionRect, bool* act
iveNow) |
1964 { | 1964 { |
1965 return ensureTextFinder().find(identifier, searchText, options, wrapWithinFr
ame, selectionRect, activeNow); | 1965 // Search for an active match only if this frame is focused or if this is a |
| 1966 // find next request. |
| 1967 if (isFocused() || options.findNext) |
| 1968 return ensureTextFinder().find(identifier, searchText, options, wrapWith
inFrame, selectionRect, activeNow); |
| 1969 |
| 1970 return false; |
1966 } | 1971 } |
1967 | 1972 |
1968 void WebLocalFrameImpl::stopFinding(bool clearSelection) | 1973 void WebLocalFrameImpl::stopFinding(StopFindAction action) |
1969 { | 1974 { |
| 1975 bool clearSelection = action == StopFindActionClearSelection; |
| 1976 if (clearSelection) |
| 1977 executeCommand(WebString::fromUTF8("Unselect")); |
| 1978 |
1970 if (m_textFinder) { | 1979 if (m_textFinder) { |
1971 if (!clearSelection) | 1980 if (!clearSelection) |
1972 setFindEndstateFocusAndSelection(); | 1981 setFindEndstateFocusAndSelection(); |
1973 m_textFinder->stopFindingAndClearSelection(); | 1982 m_textFinder->stopFindingAndClearSelection(); |
1974 } | 1983 } |
| 1984 |
| 1985 if (action == StopFindActionActivateSelection && isFocused()) { |
| 1986 WebDocument doc = document(); |
| 1987 if (!doc.isNull()) { |
| 1988 WebElement element = doc.focusedElement(); |
| 1989 if (!element.isNull()) |
| 1990 element.simulateClick(); |
| 1991 } |
| 1992 } |
1975 } | 1993 } |
1976 | 1994 |
1977 void WebLocalFrameImpl::scopeStringMatches(int identifier, const WebString& sear
chText, const WebFindOptions& options, bool reset) | 1995 void WebLocalFrameImpl::scopeStringMatches(int identifier, const WebString& sear
chText, const WebFindOptions& options, bool reset) |
1978 { | 1996 { |
1979 ensureTextFinder().scopeStringMatches(identifier, searchText, options, reset
); | 1997 ensureTextFinder().scopeStringMatches(identifier, searchText, options, reset
); |
1980 } | 1998 } |
1981 | 1999 |
1982 void WebLocalFrameImpl::cancelPendingScopingEffort() | 2000 void WebLocalFrameImpl::cancelPendingScopingEffort() |
1983 { | 2001 { |
1984 if (m_textFinder) | 2002 if (m_textFinder) |
1985 m_textFinder->cancelPendingScopingEffort(); | 2003 m_textFinder->cancelPendingScopingEffort(); |
1986 } | 2004 } |
1987 | 2005 |
1988 void WebLocalFrameImpl::increaseMatchCount(int count, int identifier) | 2006 void WebLocalFrameImpl::increaseMatchCount(int count, int identifier) |
1989 { | 2007 { |
1990 // This function should only be called on the mainframe. | |
1991 DCHECK(!parent()); | |
1992 ensureTextFinder().increaseMatchCount(identifier, count); | 2008 ensureTextFinder().increaseMatchCount(identifier, count); |
1993 } | 2009 } |
1994 | 2010 |
1995 void WebLocalFrameImpl::resetMatchCount() | 2011 void WebLocalFrameImpl::resetMatchCount() |
1996 { | 2012 { |
1997 ensureTextFinder().resetMatchCount(); | 2013 ensureTextFinder().resetMatchCount(); |
1998 } | 2014 } |
1999 | 2015 |
2000 void WebLocalFrameImpl::dispatchMessageEventWithOriginCheck(const WebSecurityOri
gin& intendedTargetOrigin, const WebDOMEvent& event) | 2016 void WebLocalFrameImpl::dispatchMessageEventWithOriginCheck(const WebSecurityOri
gin& intendedTargetOrigin, const WebDOMEvent& event) |
2001 { | 2017 { |
2002 DCHECK(!event.isNull()); | 2018 DCHECK(!event.isNull()); |
2003 frame()->localDOMWindow()->dispatchMessageEventWithOriginCheck(intendedTarge
tOrigin.get(), event, SourceLocation::create(String(), 0, 0, nullptr)); | 2019 frame()->localDOMWindow()->dispatchMessageEventWithOriginCheck(intendedTarge
tOrigin.get(), event, SourceLocation::create(String(), 0, 0, nullptr)); |
2004 } | 2020 } |
2005 | 2021 |
2006 int WebLocalFrameImpl::findMatchMarkersVersion() const | 2022 int WebLocalFrameImpl::findMatchMarkersVersion() const |
2007 { | 2023 { |
2008 DCHECK(!parent()); | |
2009 | |
2010 if (m_textFinder) | 2024 if (m_textFinder) |
2011 return m_textFinder->findMatchMarkersVersion(); | 2025 return m_textFinder->findMatchMarkersVersion(); |
2012 return 0; | 2026 return 0; |
2013 } | 2027 } |
2014 | 2028 |
2015 int WebLocalFrameImpl::selectNearestFindMatch(const WebFloatPoint& point, WebRec
t* selectionRect) | 2029 int WebLocalFrameImpl::selectNearestFindMatch(const WebFloatPoint& point, WebRec
t* selectionRect) |
2016 { | 2030 { |
2017 DCHECK(!parent()); | |
2018 return ensureTextFinder().selectNearestFindMatch(point, selectionRect); | 2031 return ensureTextFinder().selectNearestFindMatch(point, selectionRect); |
2019 } | 2032 } |
2020 | 2033 |
| 2034 float WebLocalFrameImpl::distanceToNearestFindMatch(const WebFloatPoint& point) |
| 2035 { |
| 2036 float nearestDistance; |
| 2037 ensureTextFinder().nearestFindMatch(point, &nearestDistance); |
| 2038 return nearestDistance; |
| 2039 } |
| 2040 |
2021 WebFloatRect WebLocalFrameImpl::activeFindMatchRect() | 2041 WebFloatRect WebLocalFrameImpl::activeFindMatchRect() |
2022 { | 2042 { |
2023 DCHECK(!parent()); | |
2024 | |
2025 if (m_textFinder) | 2043 if (m_textFinder) |
2026 return m_textFinder->activeFindMatchRect(); | 2044 return m_textFinder->activeFindMatchRect(); |
2027 return WebFloatRect(); | 2045 return WebFloatRect(); |
2028 } | 2046 } |
2029 | 2047 |
2030 void WebLocalFrameImpl::findMatchRects(WebVector<WebFloatRect>& outputRects) | 2048 void WebLocalFrameImpl::findMatchRects(WebVector<WebFloatRect>& outputRects) |
2031 { | 2049 { |
2032 DCHECK(!parent()); | |
2033 ensureTextFinder().findMatchRects(outputRects); | 2050 ensureTextFinder().findMatchRects(outputRects); |
2034 } | 2051 } |
2035 | 2052 |
2036 void WebLocalFrameImpl::setTickmarks(const WebVector<WebRect>& tickmarks) | 2053 void WebLocalFrameImpl::setTickmarks(const WebVector<WebRect>& tickmarks) |
2037 { | 2054 { |
2038 if (frameView()) { | 2055 if (frameView()) { |
2039 Vector<IntRect> tickmarksConverted(tickmarks.size()); | 2056 Vector<IntRect> tickmarksConverted(tickmarks.size()); |
2040 for (size_t i = 0; i < tickmarks.size(); ++i) | 2057 for (size_t i = 0; i < tickmarks.size(); ++i) |
2041 tickmarksConverted[i] = tickmarks[i]; | 2058 tickmarksConverted[i] = tickmarks[i]; |
2042 frameView()->setTickmarks(tickmarksConverted); | 2059 frameView()->setTickmarks(tickmarksConverted); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2091 if (!frame()) | 2108 if (!frame()) |
2092 return WebSandboxFlags::None; | 2109 return WebSandboxFlags::None; |
2093 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags(
)); | 2110 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags(
)); |
2094 } | 2111 } |
2095 | 2112 |
2096 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) | 2113 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) |
2097 { | 2114 { |
2098 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); | 2115 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); |
2099 } | 2116 } |
2100 | 2117 |
| 2118 void WebLocalFrameImpl::clearActiveFindMatch() |
| 2119 { |
| 2120 ensureTextFinder().clearActiveFindMatch(); |
| 2121 } |
| 2122 |
2101 } // namespace blink | 2123 } // namespace blink |
OLD | NEW |