| 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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 return; | 743 return; |
| 744 | 744 |
| 745 ScheduleVisualUpdate(); | 745 ScheduleVisualUpdate(); |
| 746 } | 746 } |
| 747 | 747 |
| 748 void FrameSelection::NotifyEventHandlerForSelectionChange() { | 748 void FrameSelection::NotifyEventHandlerForSelectionChange() { |
| 749 frame_->GetEventHandler().GetSelectionController().NotifySelectionChanged(); | 749 frame_->GetEventHandler().GetSelectionController().NotifySelectionChanged(); |
| 750 } | 750 } |
| 751 | 751 |
| 752 void FrameSelection::FocusedOrActiveStateChanged() { | 752 void FrameSelection::FocusedOrActiveStateChanged() { |
| 753 bool active_and_focused = IsFocusedAndActive(); | 753 bool active_and_focused = FrameIsFocusedAndActive(); |
| 754 | 754 |
| 755 // Trigger style invalidation from the focused element. Even though | 755 // Trigger style invalidation from the focused element. Even though |
| 756 // the focused element hasn't changed, the evaluation of focus pseudo | 756 // the focused element hasn't changed, the evaluation of focus pseudo |
| 757 // selectors are dependent on whether the frame is focused and active. | 757 // selectors are dependent on whether the frame is focused and active. |
| 758 if (Element* element = GetDocument().FocusedElement()) | 758 if (Element* element = GetDocument().FocusedElement()) |
| 759 element->FocusStateChanged(); | 759 element->FocusStateChanged(); |
| 760 | 760 |
| 761 GetDocument().UpdateStyleAndLayoutTree(); | 761 GetDocument().UpdateStyleAndLayoutTree(); |
| 762 | 762 |
| 763 // Because LayoutObject::selectionBackgroundColor() and | 763 // Because LayoutObject::selectionBackgroundColor() and |
| (...skipping 18 matching lines...) Expand all Loading... |
| 782 // Secure keyboard entry is set by the active frame. | 782 // Secure keyboard entry is set by the active frame. |
| 783 if (use_secure_keyboard_entry_when_active_) | 783 if (use_secure_keyboard_entry_when_active_) |
| 784 SetUseSecureKeyboardEntry(active_and_focused); | 784 SetUseSecureKeyboardEntry(active_and_focused); |
| 785 } | 785 } |
| 786 | 786 |
| 787 void FrameSelection::PageActivationChanged() { | 787 void FrameSelection::PageActivationChanged() { |
| 788 FocusedOrActiveStateChanged(); | 788 FocusedOrActiveStateChanged(); |
| 789 } | 789 } |
| 790 | 790 |
| 791 void FrameSelection::UpdateSecureKeyboardEntryIfActive() { | 791 void FrameSelection::UpdateSecureKeyboardEntryIfActive() { |
| 792 if (!IsFocusedAndActive()) | 792 if (!FrameIsFocusedAndActive()) |
| 793 return; | 793 return; |
| 794 SetUseSecureKeyboardEntry(use_secure_keyboard_entry_when_active_); | 794 SetUseSecureKeyboardEntry(use_secure_keyboard_entry_when_active_); |
| 795 } | 795 } |
| 796 | 796 |
| 797 void FrameSelection::SetUseSecureKeyboardEntryWhenActive( | 797 void FrameSelection::SetUseSecureKeyboardEntryWhenActive( |
| 798 bool uses_secure_keyboard) { | 798 bool uses_secure_keyboard) { |
| 799 if (use_secure_keyboard_entry_when_active_ == uses_secure_keyboard) | 799 if (use_secure_keyboard_entry_when_active_ == uses_secure_keyboard) |
| 800 return; | 800 return; |
| 801 use_secure_keyboard_entry_when_active_ = uses_secure_keyboard; | 801 use_secure_keyboard_entry_when_active_ = uses_secure_keyboard; |
| 802 UpdateSecureKeyboardEntryIfActive(); | 802 UpdateSecureKeyboardEntryIfActive(); |
| 803 } | 803 } |
| 804 | 804 |
| 805 void FrameSelection::SetUseSecureKeyboardEntry(bool enable) { | 805 void FrameSelection::SetUseSecureKeyboardEntry(bool enable) { |
| 806 if (enable) | 806 if (enable) |
| 807 EnableSecureTextInput(); | 807 EnableSecureTextInput(); |
| 808 else | 808 else |
| 809 DisableSecureTextInput(); | 809 DisableSecureTextInput(); |
| 810 } | 810 } |
| 811 | 811 |
| 812 void FrameSelection::SetFocused(bool flag) { | 812 void FrameSelection::SetFrameIsFocused(bool flag) { |
| 813 if (focused_ == flag) | 813 if (focused_ == flag) |
| 814 return; | 814 return; |
| 815 focused_ = flag; | 815 focused_ = flag; |
| 816 | 816 |
| 817 FocusedOrActiveStateChanged(); | 817 FocusedOrActiveStateChanged(); |
| 818 } | 818 } |
| 819 | 819 |
| 820 bool FrameSelection::IsFocusedAndActive() const { | 820 bool FrameSelection::FrameIsFocusedAndActive() const { |
| 821 return focused_ && frame_->GetPage() && | 821 return focused_ && frame_->GetPage() && |
| 822 frame_->GetPage()->GetFocusController().IsActive(); | 822 frame_->GetPage()->GetFocusController().IsActive(); |
| 823 } | 823 } |
| 824 | 824 |
| 825 bool FrameSelection::NeedsLayoutSelectionUpdate() const { | 825 bool FrameSelection::NeedsLayoutSelectionUpdate() const { |
| 826 return layout_selection_->HasPendingSelection(); | 826 return layout_selection_->HasPendingSelection(); |
| 827 } | 827 } |
| 828 | 828 |
| 829 void FrameSelection::CommitAppearanceIfNeeded() { | 829 void FrameSelection::CommitAppearanceIfNeeded() { |
| 830 return layout_selection_->Commit(); | 830 return layout_selection_->Commit(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 854 static bool IsFrameElement(const Node* n) { | 854 static bool IsFrameElement(const Node* n) { |
| 855 if (!n) | 855 if (!n) |
| 856 return false; | 856 return false; |
| 857 LayoutObject* layout_object = n->GetLayoutObject(); | 857 LayoutObject* layout_object = n->GetLayoutObject(); |
| 858 if (!layout_object || !layout_object->IsLayoutPart()) | 858 if (!layout_object || !layout_object->IsLayoutPart()) |
| 859 return false; | 859 return false; |
| 860 return ToLayoutPart(layout_object)->ChildFrameView(); | 860 return ToLayoutPart(layout_object)->ChildFrameView(); |
| 861 } | 861 } |
| 862 | 862 |
| 863 void FrameSelection::SetFocusedNodeIfNeeded() { | 863 void FrameSelection::SetFocusedNodeIfNeeded() { |
| 864 if (ComputeVisibleSelectionInDOMTreeDeprecated().IsNone() || !IsFocused()) | 864 if (ComputeVisibleSelectionInDOMTreeDeprecated().IsNone() || |
| 865 !FrameIsFocused()) |
| 865 return; | 866 return; |
| 866 | 867 |
| 867 if (Element* target = | 868 if (Element* target = |
| 868 ComputeVisibleSelectionInDOMTreeDeprecated().RootEditableElement()) { | 869 ComputeVisibleSelectionInDOMTreeDeprecated().RootEditableElement()) { |
| 869 // Walk up the DOM tree to search for a node to focus. | 870 // Walk up the DOM tree to search for a node to focus. |
| 870 GetDocument().UpdateStyleAndLayoutTreeIgnorePendingStylesheets(); | 871 GetDocument().UpdateStyleAndLayoutTreeIgnorePendingStylesheets(); |
| 871 while (target) { | 872 while (target) { |
| 872 // We don't want to set focus on a subframe when selecting in a parent | 873 // We don't want to set focus on a subframe when selecting in a parent |
| 873 // frame, so add the !isFrameElement check here. There's probably a better | 874 // frame, so add the !isFrameElement check here. There's probably a better |
| 874 // way to make this work in the long term, but this is the safest fix at | 875 // way to make this work in the long term, but this is the safest fix at |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 } | 1219 } |
| 1219 | 1220 |
| 1220 void showTree(const blink::FrameSelection* sel) { | 1221 void showTree(const blink::FrameSelection* sel) { |
| 1221 if (sel) | 1222 if (sel) |
| 1222 sel->ShowTreeForThis(); | 1223 sel->ShowTreeForThis(); |
| 1223 else | 1224 else |
| 1224 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1225 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
| 1225 } | 1226 } |
| 1226 | 1227 |
| 1227 #endif | 1228 #endif |
| OLD | NEW |