| 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 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 node = host; | 1892 node = host; |
| 1893 } | 1893 } |
| 1894 } | 1894 } |
| 1895 for (; node; node = node->parentNode()) { | 1895 for (; node; node = node->parentNode()) { |
| 1896 if (!node->isElementNode()) | 1896 if (!node->isElementNode()) |
| 1897 continue; | 1897 continue; |
| 1898 Element* element = toElement(node); | 1898 Element* element = toElement(node); |
| 1899 if (element->isFocusable()) { | 1899 if (element->isFocusable()) { |
| 1900 // Found a focusable parent node. Set the active match as the | 1900 // Found a focusable parent node. Set the active match as the |
| 1901 // selection and focus to the focusable node. | 1901 // selection and focus to the focusable node. |
| 1902 frame()->selection().setSelection(VisibleSelection(activeMatch))
; | 1902 frame()->selection().setSelection(VisibleSelection(EphemeralRang
e(activeMatch))); |
| 1903 frame()->document()->setFocusedElement(element); | 1903 frame()->document()->setFocusedElement(element); |
| 1904 return; | 1904 return; |
| 1905 } | 1905 } |
| 1906 } | 1906 } |
| 1907 | 1907 |
| 1908 // Iterate over all the nodes in the range until we find a focusable nod
e. | 1908 // Iterate over all the nodes in the range until we find a focusable nod
e. |
| 1909 // This, for example, sets focus to the first link if you search for | 1909 // This, for example, sets focus to the first link if you search for |
| 1910 // text and text that is within one or more links. | 1910 // text and text that is within one or more links. |
| 1911 node = activeMatch->firstNode(); | 1911 node = activeMatch->firstNode(); |
| 1912 for (; node && node != activeMatch->pastLastNode(); node = NodeTraversal
::next(*node)) { | 1912 for (; node && node != activeMatch->pastLastNode(); node = NodeTraversal
::next(*node)) { |
| 1913 if (!node->isElementNode()) | 1913 if (!node->isElementNode()) |
| 1914 continue; | 1914 continue; |
| 1915 Element* element = toElement(node); | 1915 Element* element = toElement(node); |
| 1916 if (element->isFocusable()) { | 1916 if (element->isFocusable()) { |
| 1917 frame()->document()->setFocusedElement(element); | 1917 frame()->document()->setFocusedElement(element); |
| 1918 return; | 1918 return; |
| 1919 } | 1919 } |
| 1920 } | 1920 } |
| 1921 | 1921 |
| 1922 // No node related to the active match was focusable, so set the | 1922 // No node related to the active match was focusable, so set the |
| 1923 // active match as the selection (so that when you end the Find session, | 1923 // active match as the selection (so that when you end the Find session, |
| 1924 // you'll have the last thing you found highlighted) and make sure that | 1924 // you'll have the last thing you found highlighted) and make sure that |
| 1925 // we have nothing focused (otherwise you might have text selected but | 1925 // we have nothing focused (otherwise you might have text selected but |
| 1926 // a link focused, which is weird). | 1926 // a link focused, which is weird). |
| 1927 frame()->selection().setSelection(VisibleSelection(activeMatch)); | 1927 frame()->selection().setSelection(VisibleSelection(EphemeralRange(active
Match))); |
| 1928 frame()->document()->setFocusedElement(nullptr); | 1928 frame()->document()->setFocusedElement(nullptr); |
| 1929 | 1929 |
| 1930 // Finally clear the active match, for two reasons: | 1930 // Finally clear the active match, for two reasons: |
| 1931 // We just finished the find 'session' and we don't want future (potenti
ally | 1931 // We just finished the find 'session' and we don't want future (potenti
ally |
| 1932 // unrelated) find 'sessions' operations to start at the same place. | 1932 // unrelated) find 'sessions' operations to start at the same place. |
| 1933 // The WebLocalFrameImpl could get reused and the activeMatch could end
up pointing | 1933 // The WebLocalFrameImpl could get reused and the activeMatch could end
up pointing |
| 1934 // to a document that is no longer valid. Keeping an invalid reference a
round | 1934 // to a document that is no longer valid. Keeping an invalid reference a
round |
| 1935 // is just asking for trouble. | 1935 // is just asking for trouble. |
| 1936 m_textFinder->resetActiveMatch(); | 1936 m_textFinder->resetActiveMatch(); |
| 1937 } | 1937 } |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2211 } | 2211 } |
| 2212 | 2212 |
| 2213 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const | 2213 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const |
| 2214 { | 2214 { |
| 2215 if (!frame()) | 2215 if (!frame()) |
| 2216 return WebSandboxFlags::None; | 2216 return WebSandboxFlags::None; |
| 2217 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags(
)); | 2217 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags(
)); |
| 2218 } | 2218 } |
| 2219 | 2219 |
| 2220 } // namespace blink | 2220 } // namespace blink |
| OLD | NEW |