OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Nuanti Ltd. | 3 * Copyright (C) 2008 Nuanti Ltd. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 : nullptr; | 747 : nullptr; |
748 | 748 |
749 LocalFrame* new_frame = | 749 LocalFrame* new_frame = |
750 (frame && frame->IsLocalFrame()) ? ToLocalFrame(frame) : nullptr; | 750 (frame && frame->IsLocalFrame()) ? ToLocalFrame(frame) : nullptr; |
751 | 751 |
752 focused_frame_ = frame; | 752 focused_frame_ = frame; |
753 | 753 |
754 // Now that the frame is updated, fire events and update the selection focused | 754 // Now that the frame is updated, fire events and update the selection focused |
755 // states of both frames. | 755 // states of both frames. |
756 if (old_frame && old_frame->View()) { | 756 if (old_frame && old_frame->View()) { |
757 old_frame->Selection().SetFocused(false); | 757 old_frame->Selection().SetFrameIsFocused(false); |
758 old_frame->DomWindow()->DispatchEvent(Event::Create(EventTypeNames::blur)); | 758 old_frame->DomWindow()->DispatchEvent(Event::Create(EventTypeNames::blur)); |
759 } | 759 } |
760 | 760 |
761 if (new_frame && new_frame->View() && IsFocused()) { | 761 if (new_frame && new_frame->View() && IsFocused()) { |
762 new_frame->Selection().SetFocused(true); | 762 new_frame->Selection().SetFrameIsFocused(true); |
763 new_frame->DomWindow()->DispatchEvent(Event::Create(EventTypeNames::focus)); | 763 new_frame->DomWindow()->DispatchEvent(Event::Create(EventTypeNames::focus)); |
764 } | 764 } |
765 | 765 |
766 is_changing_focused_frame_ = false; | 766 is_changing_focused_frame_ = false; |
767 | 767 |
768 // Checking client() is necessary, as the frame might have been detached as | 768 // Checking client() is necessary, as the frame might have been detached as |
769 // part of dispatching the focus event above. See https://crbug.com/570874. | 769 // part of dispatching the focus event above. See https://crbug.com/570874. |
770 if (focused_frame_ && focused_frame_->Client() && notify_embedder) | 770 if (focused_frame_ && focused_frame_->Client() && notify_embedder) |
771 focused_frame_->Client()->FrameFocused(); | 771 focused_frame_->Client()->FrameFocused(); |
772 | 772 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 | 862 |
863 // Do not set a focused frame when being unfocused. This might reset | 863 // Do not set a focused frame when being unfocused. This might reset |
864 // m_isFocused to true. | 864 // m_isFocused to true. |
865 if (!focused_frame_ && is_focused_) | 865 if (!focused_frame_ && is_focused_) |
866 SetFocusedFrame(page_->MainFrame()); | 866 SetFocusedFrame(page_->MainFrame()); |
867 | 867 |
868 // setFocusedFrame above might reject to update m_focusedFrame, or | 868 // setFocusedFrame above might reject to update m_focusedFrame, or |
869 // m_focusedFrame might be changed by blur/focus event handlers. | 869 // m_focusedFrame might be changed by blur/focus event handlers. |
870 if (focused_frame_ && focused_frame_->IsLocalFrame() && | 870 if (focused_frame_ && focused_frame_->IsLocalFrame() && |
871 ToLocalFrame(focused_frame_.Get())->View()) { | 871 ToLocalFrame(focused_frame_.Get())->View()) { |
872 ToLocalFrame(focused_frame_.Get())->Selection().SetFocused(focused); | 872 ToLocalFrame(focused_frame_.Get())->Selection().SetFrameIsFocused(focused); |
873 DispatchEventsOnWindowAndFocusedElement( | 873 DispatchEventsOnWindowAndFocusedElement( |
874 ToLocalFrame(focused_frame_.Get())->GetDocument(), focused); | 874 ToLocalFrame(focused_frame_.Get())->GetDocument(), focused); |
875 } | 875 } |
876 | 876 |
877 NotifyFocusChangedObservers(); | 877 NotifyFocusChangedObservers(); |
878 } | 878 } |
879 | 879 |
880 bool FocusController::SetInitialFocus(WebFocusType type) { | 880 bool FocusController::SetInitialFocus(WebFocusType type) { |
881 bool did_advance_focus = AdvanceFocus(type, true); | 881 bool did_advance_focus = AdvanceFocus(type, true); |
882 | 882 |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 it->FocusedFrameChanged(); | 1410 it->FocusedFrameChanged(); |
1411 } | 1411 } |
1412 | 1412 |
1413 DEFINE_TRACE(FocusController) { | 1413 DEFINE_TRACE(FocusController) { |
1414 visitor->Trace(page_); | 1414 visitor->Trace(page_); |
1415 visitor->Trace(focused_frame_); | 1415 visitor->Trace(focused_frame_); |
1416 visitor->Trace(focus_changed_observers_); | 1416 visitor->Trace(focus_changed_observers_); |
1417 } | 1417 } |
1418 | 1418 |
1419 } // namespace blink | 1419 } // namespace blink |
OLD | NEW |