| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 namespace blink { | 87 namespace blink { |
| 88 | 88 |
| 89 using namespace HTMLNames; | 89 using namespace HTMLNames; |
| 90 | 90 |
| 91 static inline bool shouldAlwaysUseDirectionalSelection(LocalFrame* frame) { | 91 static inline bool shouldAlwaysUseDirectionalSelection(LocalFrame* frame) { |
| 92 return frame->editor().behavior().shouldConsiderSelectionAsDirectional(); | 92 return frame->editor().behavior().shouldConsiderSelectionAsDirectional(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 FrameSelection::FrameSelection(LocalFrame& frame) | 95 FrameSelection::FrameSelection(LocalFrame& frame) |
| 96 : m_frame(frame), | 96 : m_frame(frame), |
| 97 m_pendingSelection(LayoutSelection::create(*this)), | 97 m_layoutSelection(LayoutSelection::create(*this)), |
| 98 m_selectionEditor(SelectionEditor::create(frame)), | 98 m_selectionEditor(SelectionEditor::create(frame)), |
| 99 m_granularity(CharacterGranularity), | 99 m_granularity(CharacterGranularity), |
| 100 m_xPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation()), | 100 m_xPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation()), |
| 101 m_focused(frame.page() && | 101 m_focused(frame.page() && |
| 102 frame.page()->focusController().focusedFrame() == frame), | 102 frame.page()->focusController().focusedFrame() == frame), |
| 103 m_frameCaret(new FrameCaret(frame, *m_selectionEditor)) {} | 103 m_frameCaret(new FrameCaret(frame, *m_selectionEditor)) {} |
| 104 | 104 |
| 105 FrameSelection::~FrameSelection() {} | 105 FrameSelection::~FrameSelection() {} |
| 106 | 106 |
| 107 const DisplayItemClient& FrameSelection::caretDisplayItemClientForTesting() | 107 const DisplayItemClient& FrameSelection::caretDisplayItemClientForTesting() |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 | 752 |
| 753 focusedOrActiveStateChanged(); | 753 focusedOrActiveStateChanged(); |
| 754 } | 754 } |
| 755 | 755 |
| 756 bool FrameSelection::isFocusedAndActive() const { | 756 bool FrameSelection::isFocusedAndActive() const { |
| 757 return m_focused && m_frame->page() && | 757 return m_focused && m_frame->page() && |
| 758 m_frame->page()->focusController().isActive(); | 758 m_frame->page()->focusController().isActive(); |
| 759 } | 759 } |
| 760 | 760 |
| 761 bool FrameSelection::isAppearanceDirty() const { | 761 bool FrameSelection::isAppearanceDirty() const { |
| 762 return m_pendingSelection->hasPendingSelection(); | 762 return m_layoutSelection->hasPendingSelection(); |
| 763 } | 763 } |
| 764 | 764 |
| 765 void FrameSelection::commitAppearanceIfNeeded(LayoutView& layoutView) { | 765 void FrameSelection::commitAppearanceIfNeeded(LayoutView& layoutView) { |
| 766 return m_pendingSelection->commit(layoutView); | 766 return m_layoutSelection->commit(layoutView); |
| 767 } | 767 } |
| 768 | 768 |
| 769 void FrameSelection::didLayout() { | 769 void FrameSelection::didLayout() { |
| 770 updateAppearance(); | 770 updateAppearance(); |
| 771 } | 771 } |
| 772 | 772 |
| 773 void FrameSelection::updateAppearance() { | 773 void FrameSelection::updateAppearance() { |
| 774 DCHECK(!m_frame->contentLayoutItem().isNull()); | 774 DCHECK(!m_frame->contentLayoutItem().isNull()); |
| 775 m_frameCaret->scheduleVisualUpdateForPaintInvalidationIfNeeded(); | 775 m_frameCaret->scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
| 776 m_pendingSelection->setHasPendingSelection(); | 776 m_layoutSelection->setHasPendingSelection(); |
| 777 } | 777 } |
| 778 | 778 |
| 779 void FrameSelection::notifyLayoutObjectOfSelectionChange( | 779 void FrameSelection::notifyLayoutObjectOfSelectionChange( |
| 780 EUserTriggered userTriggered) { | 780 EUserTriggered userTriggered) { |
| 781 TextControlElement* textControl = | 781 TextControlElement* textControl = |
| 782 enclosingTextControl(selectionInDOMTree().base()); | 782 enclosingTextControl(selectionInDOMTree().base()); |
| 783 if (!textControl) | 783 if (!textControl) |
| 784 return; | 784 return; |
| 785 textControl->selectionChanged(userTriggered == UserTriggered); | 785 textControl->selectionChanged(userTriggered == UserTriggered); |
| 786 } | 786 } |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 #ifndef NDEBUG | 1007 #ifndef NDEBUG |
| 1008 | 1008 |
| 1009 void FrameSelection::showTreeForThis() const { | 1009 void FrameSelection::showTreeForThis() const { |
| 1010 computeVisibleSelectionInDOMTreeDeprecated().showTreeForThis(); | 1010 computeVisibleSelectionInDOMTreeDeprecated().showTreeForThis(); |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 #endif | 1013 #endif |
| 1014 | 1014 |
| 1015 DEFINE_TRACE(FrameSelection) { | 1015 DEFINE_TRACE(FrameSelection) { |
| 1016 visitor->trace(m_frame); | 1016 visitor->trace(m_frame); |
| 1017 visitor->trace(m_pendingSelection); | 1017 visitor->trace(m_layoutSelection); |
| 1018 visitor->trace(m_selectionEditor); | 1018 visitor->trace(m_selectionEditor); |
| 1019 visitor->trace(m_frameCaret); | 1019 visitor->trace(m_frameCaret); |
| 1020 SynchronousMutationObserver::trace(visitor); | 1020 SynchronousMutationObserver::trace(visitor); |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 void FrameSelection::scheduleVisualUpdate() const { | 1023 void FrameSelection::scheduleVisualUpdate() const { |
| 1024 if (Page* page = m_frame->page()) | 1024 if (Page* page = m_frame->page()) |
| 1025 page->animator().scheduleVisualUpdate(m_frame->localFrameRoot()); | 1025 page->animator().scheduleVisualUpdate(m_frame->localFrameRoot()); |
| 1026 } | 1026 } |
| 1027 | 1027 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 } | 1144 } |
| 1145 | 1145 |
| 1146 void showTree(const blink::FrameSelection* sel) { | 1146 void showTree(const blink::FrameSelection* sel) { |
| 1147 if (sel) | 1147 if (sel) |
| 1148 sel->showTreeForThis(); | 1148 sel->showTreeForThis(); |
| 1149 else | 1149 else |
| 1150 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1150 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
| 1151 } | 1151 } |
| 1152 | 1152 |
| 1153 #endif | 1153 #endif |
| OLD | NEW |