Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp

Issue 2374183004: Make non-null VisibleSelections creatable only by createVisibleSelection[Deprecated] (Closed)
Patch Set: Fix mac compile error Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 } 1666 }
1667 const EphemeralRange activeMatchRange(activeMatch); 1667 const EphemeralRange activeMatchRange(activeMatch);
1668 if (node) { 1668 if (node) {
1669 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) { 1669 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) {
1670 if (!runner.isElementNode()) 1670 if (!runner.isElementNode())
1671 continue; 1671 continue;
1672 Element& element = toElement(runner); 1672 Element& element = toElement(runner);
1673 if (element.isFocusable()) { 1673 if (element.isFocusable()) {
1674 // Found a focusable parent node. Set the active match as th e 1674 // Found a focusable parent node. Set the active match as th e
1675 // selection and focus to the focusable node. 1675 // selection and focus to the focusable node.
1676 frame()->selection().setSelection(VisibleSelection(activeMat chRange)); 1676 frame()->selection().setSelection(createVisibleSelectionDepr ecated(activeMatchRange));
1677 frame()->document()->setFocusedElement(&element, FocusParams (SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); 1677 frame()->document()->setFocusedElement(&element, FocusParams (SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr));
1678 return; 1678 return;
1679 } 1679 }
1680 } 1680 }
1681 } 1681 }
1682 1682
1683 // Iterate over all the nodes in the range until we find a focusable nod e. 1683 // Iterate over all the nodes in the range until we find a focusable nod e.
1684 // This, for example, sets focus to the first link if you search for 1684 // This, for example, sets focus to the first link if you search for
1685 // text and text that is within one or more links. 1685 // text and text that is within one or more links.
1686 for (Node& runner : activeMatchRange.nodes()) { 1686 for (Node& runner : activeMatchRange.nodes()) {
1687 if (!runner.isElementNode()) 1687 if (!runner.isElementNode())
1688 continue; 1688 continue;
1689 Element& element = toElement(runner); 1689 Element& element = toElement(runner);
1690 if (element.isFocusable()) { 1690 if (element.isFocusable()) {
1691 frame()->document()->setFocusedElement(&element, FocusParams(Sel ectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); 1691 frame()->document()->setFocusedElement(&element, FocusParams(Sel ectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr));
1692 return; 1692 return;
1693 } 1693 }
1694 } 1694 }
1695 1695
1696 // No node related to the active match was focusable, so set the 1696 // No node related to the active match was focusable, so set the
1697 // active match as the selection (so that when you end the Find session, 1697 // active match as the selection (so that when you end the Find session,
1698 // you'll have the last thing you found highlighted) and make sure that 1698 // you'll have the last thing you found highlighted) and make sure that
1699 // we have nothing focused (otherwise you might have text selected but 1699 // we have nothing focused (otherwise you might have text selected but
1700 // a link focused, which is weird). 1700 // a link focused, which is weird).
1701 frame()->selection().setSelection(VisibleSelection(activeMatchRange)); 1701 frame()->selection().setSelection(createVisibleSelectionDeprecated(activ eMatchRange));
1702 frame()->document()->clearFocusedElement(); 1702 frame()->document()->clearFocusedElement();
1703 1703
1704 // Finally clear the active match, for two reasons: 1704 // Finally clear the active match, for two reasons:
1705 // We just finished the find 'session' and we don't want future (potenti ally 1705 // We just finished the find 'session' and we don't want future (potenti ally
1706 // unrelated) find 'sessions' operations to start at the same place. 1706 // unrelated) find 'sessions' operations to start at the same place.
1707 // The WebLocalFrameImpl could get reused and the activeMatch could end up pointing 1707 // The WebLocalFrameImpl could get reused and the activeMatch could end up pointing
1708 // to a document that is no longer valid. Keeping an invalid reference a round 1708 // to a document that is no longer valid. Keeping an invalid reference a round
1709 // is just asking for trouble. 1709 // is just asking for trouble.
1710 m_textFinder->resetActiveMatch(); 1710 m_textFinder->resetActiveMatch();
1711 } 1711 }
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 feature = UseCounter::ChromeLoadTimesNpnNegotiatedProtocol; 2245 feature = UseCounter::ChromeLoadTimesNpnNegotiatedProtocol;
2246 } else if (metric == "wasAlternateProtocolAvailable") { 2246 } else if (metric == "wasAlternateProtocolAvailable") {
2247 feature = UseCounter::ChromeLoadTimesWasAlternateProtocolAvailable; 2247 feature = UseCounter::ChromeLoadTimesWasAlternateProtocolAvailable;
2248 } else if (metric == "connectionInfo") { 2248 } else if (metric == "connectionInfo") {
2249 feature = UseCounter::ChromeLoadTimesConnectionInfo; 2249 feature = UseCounter::ChromeLoadTimesConnectionInfo;
2250 } 2250 }
2251 UseCounter::count(frame(), feature); 2251 UseCounter::count(frame(), feature);
2252 } 2252 }
2253 2253
2254 } // namespace blink 2254 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698