| 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 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1781 const EphemeralRange activeMatchRange(activeMatch); | 1781 const EphemeralRange activeMatchRange(activeMatch); |
| 1782 if (node) { | 1782 if (node) { |
| 1783 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) { | 1783 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) { |
| 1784 if (!runner.isElementNode()) | 1784 if (!runner.isElementNode()) |
| 1785 continue; | 1785 continue; |
| 1786 Element& element = toElement(runner); | 1786 Element& element = toElement(runner); |
| 1787 if (element.isFocusable()) { | 1787 if (element.isFocusable()) { |
| 1788 // Found a focusable parent node. Set the active match as the | 1788 // Found a focusable parent node. Set the active match as the |
| 1789 // selection and focus to the focusable node. | 1789 // selection and focus to the focusable node. |
| 1790 frame()->selection().setSelection( | 1790 frame()->selection().setSelection( |
| 1791 createVisibleSelection(activeMatchRange)); | 1791 SelectionInDOMTree::Builder() |
| 1792 .setBaseAndExtent(activeMatchRange) |
| 1793 .build()); |
| 1792 frame()->document()->setFocusedElement( | 1794 frame()->document()->setFocusedElement( |
| 1793 &element, FocusParams(SelectionBehaviorOnFocus::None, | 1795 &element, FocusParams(SelectionBehaviorOnFocus::None, |
| 1794 WebFocusTypeNone, nullptr)); | 1796 WebFocusTypeNone, nullptr)); |
| 1795 return; | 1797 return; |
| 1796 } | 1798 } |
| 1797 } | 1799 } |
| 1798 } | 1800 } |
| 1799 | 1801 |
| 1800 // Iterate over all the nodes in the range until we find a focusable node. | 1802 // Iterate over all the nodes in the range until we find a focusable node. |
| 1801 // This, for example, sets focus to the first link if you search for | 1803 // This, for example, sets focus to the first link if you search for |
| 1802 // text and text that is within one or more links. | 1804 // text and text that is within one or more links. |
| 1803 for (Node& runner : activeMatchRange.nodes()) { | 1805 for (Node& runner : activeMatchRange.nodes()) { |
| 1804 if (!runner.isElementNode()) | 1806 if (!runner.isElementNode()) |
| 1805 continue; | 1807 continue; |
| 1806 Element& element = toElement(runner); | 1808 Element& element = toElement(runner); |
| 1807 if (element.isFocusable()) { | 1809 if (element.isFocusable()) { |
| 1808 frame()->document()->setFocusedElement( | 1810 frame()->document()->setFocusedElement( |
| 1809 &element, FocusParams(SelectionBehaviorOnFocus::None, | 1811 &element, FocusParams(SelectionBehaviorOnFocus::None, |
| 1810 WebFocusTypeNone, nullptr)); | 1812 WebFocusTypeNone, nullptr)); |
| 1811 return; | 1813 return; |
| 1812 } | 1814 } |
| 1813 } | 1815 } |
| 1814 | 1816 |
| 1815 // No node related to the active match was focusable, so set the | 1817 // No node related to the active match was focusable, so set the |
| 1816 // active match as the selection (so that when you end the Find session, | 1818 // active match as the selection (so that when you end the Find session, |
| 1817 // you'll have the last thing you found highlighted) and make sure that | 1819 // you'll have the last thing you found highlighted) and make sure that |
| 1818 // we have nothing focused (otherwise you might have text selected but | 1820 // we have nothing focused (otherwise you might have text selected but |
| 1819 // a link focused, which is weird). | 1821 // a link focused, which is weird). |
| 1820 frame()->selection().setSelection(createVisibleSelection(activeMatchRange)); | 1822 frame()->selection().setSelection(SelectionInDOMTree::Builder() |
| 1823 .setBaseAndExtent(activeMatchRange) |
| 1824 .build()); |
| 1821 frame()->document()->clearFocusedElement(); | 1825 frame()->document()->clearFocusedElement(); |
| 1822 | 1826 |
| 1823 // Finally clear the active match, for two reasons: | 1827 // Finally clear the active match, for two reasons: |
| 1824 // We just finished the find 'session' and we don't want future (potentially | 1828 // We just finished the find 'session' and we don't want future (potentially |
| 1825 // unrelated) find 'sessions' operations to start at the same place. | 1829 // unrelated) find 'sessions' operations to start at the same place. |
| 1826 // The WebLocalFrameImpl could get reused and the activeMatch could end up | 1830 // The WebLocalFrameImpl could get reused and the activeMatch could end up |
| 1827 // pointing to a document that is no longer valid. Keeping an invalid | 1831 // pointing to a document that is no longer valid. Keeping an invalid |
| 1828 // reference around is just asking for trouble. | 1832 // reference around is just asking for trouble. |
| 1829 m_textFinder->resetActiveMatch(); | 1833 m_textFinder->resetActiveMatch(); |
| 1830 } | 1834 } |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2380 feature = UseCounter::ChromeLoadTimesNpnNegotiatedProtocol; | 2384 feature = UseCounter::ChromeLoadTimesNpnNegotiatedProtocol; |
| 2381 } else if (metric == "wasAlternateProtocolAvailable") { | 2385 } else if (metric == "wasAlternateProtocolAvailable") { |
| 2382 feature = UseCounter::ChromeLoadTimesWasAlternateProtocolAvailable; | 2386 feature = UseCounter::ChromeLoadTimesWasAlternateProtocolAvailable; |
| 2383 } else if (metric == "connectionInfo") { | 2387 } else if (metric == "connectionInfo") { |
| 2384 feature = UseCounter::ChromeLoadTimesConnectionInfo; | 2388 feature = UseCounter::ChromeLoadTimesConnectionInfo; |
| 2385 } | 2389 } |
| 2386 UseCounter::count(frame(), feature); | 2390 UseCounter::count(frame(), feature); |
| 2387 } | 2391 } |
| 2388 | 2392 |
| 2389 } // namespace blink | 2393 } // namespace blink |
| OLD | NEW |