| 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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 ScrollableArea* WebLocalFrameImpl::layoutViewportScrollableArea() const { | 574 ScrollableArea* WebLocalFrameImpl::layoutViewportScrollableArea() const { |
| 575 if (FrameView* view = frameView()) | 575 if (FrameView* view = frameView()) |
| 576 return view->layoutViewportScrollableArea(); | 576 return view->layoutViewportScrollableArea(); |
| 577 return nullptr; | 577 return nullptr; |
| 578 } | 578 } |
| 579 | 579 |
| 580 bool WebLocalFrameImpl::isFocused() const { | 580 bool WebLocalFrameImpl::isFocused() const { |
| 581 if (!viewImpl() || !viewImpl()->page()) | 581 if (!viewImpl() || !viewImpl()->page()) |
| 582 return false; | 582 return false; |
| 583 | 583 |
| 584 return this == WebFrame::fromFrame( | 584 return this == |
| 585 viewImpl()->page()->focusController().focusedFrame()); | 585 WebFrame::fromFrame( |
| 586 viewImpl()->page()->focusController().focusedFrame()); |
| 586 } | 587 } |
| 587 | 588 |
| 588 WebSize WebLocalFrameImpl::getScrollOffset() const { | 589 WebSize WebLocalFrameImpl::getScrollOffset() const { |
| 589 if (ScrollableArea* scrollableArea = layoutViewportScrollableArea()) | 590 if (ScrollableArea* scrollableArea = layoutViewportScrollableArea()) |
| 590 return scrollableArea->scrollOffsetInt(); | 591 return scrollableArea->scrollOffsetInt(); |
| 591 return WebSize(); | 592 return WebSize(); |
| 592 } | 593 } |
| 593 | 594 |
| 594 void WebLocalFrameImpl::setScrollOffset(const WebSize& offset) { | 595 void WebLocalFrameImpl::setScrollOffset(const WebSize& offset) { |
| 595 if (ScrollableArea* scrollableArea = layoutViewportScrollableArea()) { | 596 if (ScrollableArea* scrollableArea = layoutViewportScrollableArea()) { |
| (...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 continue; | 1762 continue; |
| 1762 Element& element = toElement(runner); | 1763 Element& element = toElement(runner); |
| 1763 if (element.isFocusable()) { | 1764 if (element.isFocusable()) { |
| 1764 // Found a focusable parent node. Set the active match as the | 1765 // Found a focusable parent node. Set the active match as the |
| 1765 // selection and focus to the focusable node. | 1766 // selection and focus to the focusable node. |
| 1766 frame()->selection().setSelection( | 1767 frame()->selection().setSelection( |
| 1767 SelectionInDOMTree::Builder() | 1768 SelectionInDOMTree::Builder() |
| 1768 .setBaseAndExtent(activeMatchRange) | 1769 .setBaseAndExtent(activeMatchRange) |
| 1769 .build()); | 1770 .build()); |
| 1770 frame()->document()->setFocusedElement( | 1771 frame()->document()->setFocusedElement( |
| 1771 &element, FocusParams(SelectionBehaviorOnFocus::None, | 1772 &element, |
| 1772 WebFocusTypeNone, nullptr)); | 1773 FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, |
| 1774 nullptr)); |
| 1773 return; | 1775 return; |
| 1774 } | 1776 } |
| 1775 } | 1777 } |
| 1776 } | 1778 } |
| 1777 | 1779 |
| 1778 // Iterate over all the nodes in the range until we find a focusable node. | 1780 // Iterate over all the nodes in the range until we find a focusable node. |
| 1779 // This, for example, sets focus to the first link if you search for | 1781 // This, for example, sets focus to the first link if you search for |
| 1780 // text and text that is within one or more links. | 1782 // text and text that is within one or more links. |
| 1781 for (Node& runner : activeMatchRange.nodes()) { | 1783 for (Node& runner : activeMatchRange.nodes()) { |
| 1782 if (!runner.isElementNode()) | 1784 if (!runner.isElementNode()) |
| 1783 continue; | 1785 continue; |
| 1784 Element& element = toElement(runner); | 1786 Element& element = toElement(runner); |
| 1785 if (element.isFocusable()) { | 1787 if (element.isFocusable()) { |
| 1786 frame()->document()->setFocusedElement( | 1788 frame()->document()->setFocusedElement( |
| 1787 &element, FocusParams(SelectionBehaviorOnFocus::None, | 1789 &element, |
| 1788 WebFocusTypeNone, nullptr)); | 1790 FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, |
| 1791 nullptr)); |
| 1789 return; | 1792 return; |
| 1790 } | 1793 } |
| 1791 } | 1794 } |
| 1792 | 1795 |
| 1793 // No node related to the active match was focusable, so set the | 1796 // No node related to the active match was focusable, so set the |
| 1794 // active match as the selection (so that when you end the Find session, | 1797 // active match as the selection (so that when you end the Find session, |
| 1795 // you'll have the last thing you found highlighted) and make sure that | 1798 // you'll have the last thing you found highlighted) and make sure that |
| 1796 // we have nothing focused (otherwise you might have text selected but | 1799 // we have nothing focused (otherwise you might have text selected but |
| 1797 // a link focused, which is weird). | 1800 // a link focused, which is weird). |
| 1798 frame()->selection().setSelection(SelectionInDOMTree::Builder() | 1801 frame()->selection().setSelection(SelectionInDOMTree::Builder() |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2431 createMarkup(startPosition, endPosition, AnnotateForInterchange, | 2434 createMarkup(startPosition, endPosition, AnnotateForInterchange, |
| 2432 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); | 2435 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); |
| 2433 } else { | 2436 } else { |
| 2434 clipHtml = | 2437 clipHtml = |
| 2435 createMarkup(endPosition, startPosition, AnnotateForInterchange, | 2438 createMarkup(endPosition, startPosition, AnnotateForInterchange, |
| 2436 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); | 2439 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); |
| 2437 } | 2440 } |
| 2438 } | 2441 } |
| 2439 | 2442 |
| 2440 } // namespace blink | 2443 } // namespace blink |
| OLD | NEW |