| 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 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1869 } | 1869 } |
| 1870 } | 1870 } |
| 1871 for (; node; node = node->parentNode()) { | 1871 for (; node; node = node->parentNode()) { |
| 1872 if (!node->isElementNode()) | 1872 if (!node->isElementNode()) |
| 1873 continue; | 1873 continue; |
| 1874 Element* element = toElement(node); | 1874 Element* element = toElement(node); |
| 1875 if (element->isFocusable()) { | 1875 if (element->isFocusable()) { |
| 1876 // Found a focusable parent node. Set the active match as the | 1876 // Found a focusable parent node. Set the active match as the |
| 1877 // selection and focus to the focusable node. | 1877 // selection and focus to the focusable node. |
| 1878 frame()->selection().setSelection(VisibleSelection(EphemeralRang
e(activeMatch))); | 1878 frame()->selection().setSelection(VisibleSelection(EphemeralRang
e(activeMatch))); |
| 1879 frame()->document()->setFocusedElement(element); | 1879 frame()->document()->setFocusedElement(element, FocusParams(Sele
ctionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); |
| 1880 return; | 1880 return; |
| 1881 } | 1881 } |
| 1882 } | 1882 } |
| 1883 | 1883 |
| 1884 // Iterate over all the nodes in the range until we find a focusable nod
e. | 1884 // Iterate over all the nodes in the range until we find a focusable nod
e. |
| 1885 // This, for example, sets focus to the first link if you search for | 1885 // This, for example, sets focus to the first link if you search for |
| 1886 // text and text that is within one or more links. | 1886 // text and text that is within one or more links. |
| 1887 node = activeMatch->firstNode(); | 1887 node = activeMatch->firstNode(); |
| 1888 for (; node && node != activeMatch->pastLastNode(); node = NodeTraversal
::next(*node)) { | 1888 for (; node && node != activeMatch->pastLastNode(); node = NodeTraversal
::next(*node)) { |
| 1889 if (!node->isElementNode()) | 1889 if (!node->isElementNode()) |
| 1890 continue; | 1890 continue; |
| 1891 Element* element = toElement(node); | 1891 Element* element = toElement(node); |
| 1892 if (element->isFocusable()) { | 1892 if (element->isFocusable()) { |
| 1893 frame()->document()->setFocusedElement(element); | 1893 frame()->document()->setFocusedElement(element, FocusParams(Sele
ctionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); |
| 1894 return; | 1894 return; |
| 1895 } | 1895 } |
| 1896 } | 1896 } |
| 1897 | 1897 |
| 1898 // No node related to the active match was focusable, so set the | 1898 // No node related to the active match was focusable, so set the |
| 1899 // active match as the selection (so that when you end the Find session, | 1899 // active match as the selection (so that when you end the Find session, |
| 1900 // you'll have the last thing you found highlighted) and make sure that | 1900 // you'll have the last thing you found highlighted) and make sure that |
| 1901 // we have nothing focused (otherwise you might have text selected but | 1901 // we have nothing focused (otherwise you might have text selected but |
| 1902 // a link focused, which is weird). | 1902 // a link focused, which is weird). |
| 1903 frame()->selection().setSelection(VisibleSelection(EphemeralRange(active
Match))); | 1903 frame()->selection().setSelection(VisibleSelection(EphemeralRange(active
Match))); |
| 1904 frame()->document()->setFocusedElement(nullptr); | 1904 frame()->document()->clearFocusedElement(); |
| 1905 | 1905 |
| 1906 // Finally clear the active match, for two reasons: | 1906 // Finally clear the active match, for two reasons: |
| 1907 // We just finished the find 'session' and we don't want future (potenti
ally | 1907 // We just finished the find 'session' and we don't want future (potenti
ally |
| 1908 // unrelated) find 'sessions' operations to start at the same place. | 1908 // unrelated) find 'sessions' operations to start at the same place. |
| 1909 // The WebLocalFrameImpl could get reused and the activeMatch could end
up pointing | 1909 // The WebLocalFrameImpl could get reused and the activeMatch could end
up pointing |
| 1910 // to a document that is no longer valid. Keeping an invalid reference a
round | 1910 // to a document that is no longer valid. Keeping an invalid reference a
round |
| 1911 // is just asking for trouble. | 1911 // is just asking for trouble. |
| 1912 m_textFinder->resetActiveMatch(); | 1912 m_textFinder->resetActiveMatch(); |
| 1913 } | 1913 } |
| 1914 } | 1914 } |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2208 } | 2208 } |
| 2209 | 2209 |
| 2210 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const | 2210 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const |
| 2211 { | 2211 { |
| 2212 if (!frame()) | 2212 if (!frame()) |
| 2213 return WebSandboxFlags::None; | 2213 return WebSandboxFlags::None; |
| 2214 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags(
)); | 2214 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags(
)); |
| 2215 } | 2215 } |
| 2216 | 2216 |
| 2217 } // namespace blink | 2217 } // namespace blink |
| OLD | NEW |