Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2810593002: Set plugin focus by implementing HTMLPlugInElement::SetFocused. (Closed)
Patch Set: fix comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 4038 matching lines...) Expand 10 before | Expand all | Expand 10 after
4049 4049
4050 if (focused_element_ == new_focused_element) 4050 if (focused_element_ == new_focused_element)
4051 return true; 4051 return true;
4052 4052
4053 bool focus_change_blocked = false; 4053 bool focus_change_blocked = false;
4054 Element* old_focused_element = focused_element_; 4054 Element* old_focused_element = focused_element_;
4055 focused_element_ = nullptr; 4055 focused_element_ = nullptr;
4056 4056
4057 // Remove focus from the existing focus node (if any) 4057 // Remove focus from the existing focus node (if any)
4058 if (old_focused_element) { 4058 if (old_focused_element) {
4059 old_focused_element->SetFocused(false); 4059 old_focused_element->SetFocused(false, params.type);
4060 4060
4061 // Dispatch the blur event and let the node do any other blur related 4061 // Dispatch the blur event and let the node do any other blur related
4062 // activities (important for text fields) 4062 // activities (important for text fields)
4063 // If page lost focus, blur event will have already been dispatched 4063 // If page lost focus, blur event will have already been dispatched
4064 if (GetPage() && (GetPage()->GetFocusController().IsFocused())) { 4064 if (GetPage() && (GetPage()->GetFocusController().IsFocused())) {
4065 old_focused_element->DispatchBlurEvent(new_focused_element, params.type, 4065 old_focused_element->DispatchBlurEvent(new_focused_element, params.type,
4066 params.source_capabilities); 4066 params.source_capabilities);
4067 if (focused_element_) { 4067 if (focused_element_) {
4068 // handler shifted focus 4068 // handler shifted focus
4069 focus_change_blocked = true; 4069 focus_change_blocked = true;
(...skipping 11 matching lines...) Expand all
4081 old_focused_element->DispatchFocusOutEvent(EventTypeNames::DOMFocusOut, 4081 old_focused_element->DispatchFocusOutEvent(EventTypeNames::DOMFocusOut,
4082 new_focused_element, 4082 new_focused_element,
4083 params.source_capabilities); 4083 params.source_capabilities);
4084 4084
4085 if (focused_element_) { 4085 if (focused_element_) {
4086 // handler shifted focus 4086 // handler shifted focus
4087 focus_change_blocked = true; 4087 focus_change_blocked = true;
4088 new_focused_element = nullptr; 4088 new_focused_element = nullptr;
4089 } 4089 }
4090 } 4090 }
4091
4092 if (IsHTMLPlugInElement(old_focused_element)) {
4093 if (PluginView* plugin =
4094 ToHTMLPlugInElement(old_focused_element)->Plugin())
4095 plugin->SetFocused(false, params.type);
4096 }
4097 } 4091 }
4098 4092
4099 if (new_focused_element) 4093 if (new_focused_element)
4100 UpdateStyleAndLayoutTreeForNode(new_focused_element); 4094 UpdateStyleAndLayoutTreeForNode(new_focused_element);
4101 if (new_focused_element && new_focused_element->IsFocusable()) { 4095 if (new_focused_element && new_focused_element->IsFocusable()) {
4102 if (IsRootEditableElement(*new_focused_element) && 4096 if (IsRootEditableElement(*new_focused_element) &&
4103 !AcceptsEditingFocus(*new_focused_element)) { 4097 !AcceptsEditingFocus(*new_focused_element)) {
4104 // delegate blocks focus change 4098 // delegate blocks focus change
4105 focus_change_blocked = true; 4099 focus_change_blocked = true;
4106 goto SetFocusedElementDone; 4100 goto SetFocusedElementDone;
4107 } 4101 }
4108 // Set focus on the new node 4102 // Set focus on the new node
4109 focused_element_ = new_focused_element; 4103 focused_element_ = new_focused_element;
4110 SetSequentialFocusNavigationStartingPoint(focused_element_.Get()); 4104 SetSequentialFocusNavigationStartingPoint(focused_element_.Get());
4111 4105
4112 focused_element_->SetFocused(true); 4106 focused_element_->SetFocused(true, params.type);
4113 // Element::setFocused for frames can dispatch events. 4107 // Element::setFocused for frames can dispatch events.
4114 if (focused_element_ != new_focused_element) { 4108 if (focused_element_ != new_focused_element) {
4115 focus_change_blocked = true; 4109 focus_change_blocked = true;
4116 goto SetFocusedElementDone; 4110 goto SetFocusedElementDone;
4117 } 4111 }
4118 CancelFocusAppearanceUpdate(); 4112 CancelFocusAppearanceUpdate();
4119 focused_element_->UpdateFocusAppearance(params.selection_behavior); 4113 focused_element_->UpdateFocusAppearance(params.selection_behavior);
4120 4114
4121 // Dispatch the focus event and let the node do any other focus related 4115 // Dispatch the focus event and let the node do any other focus related
4122 // activities (important for text fields) 4116 // activities (important for text fields)
(...skipping 28 matching lines...) Expand all
4151 4145
4152 if (focused_element_ != new_focused_element) { 4146 if (focused_element_ != new_focused_element) {
4153 // handler shifted focus 4147 // handler shifted focus
4154 focus_change_blocked = true; 4148 focus_change_blocked = true;
4155 goto SetFocusedElementDone; 4149 goto SetFocusedElementDone;
4156 } 4150 }
4157 } 4151 }
4158 4152
4159 if (IsRootEditableElement(*focused_element_)) 4153 if (IsRootEditableElement(*focused_element_))
4160 GetFrame()->GetSpellChecker().DidBeginEditing(focused_element_.Get()); 4154 GetFrame()->GetSpellChecker().DidBeginEditing(focused_element_.Get());
4161
4162 if (IsHTMLPlugInElement(focused_element_)) {
4163 if (PluginView* plugin = ToHTMLPlugInElement(focused_element_)->Plugin())
4164 plugin->SetFocused(true, params.type);
4165 }
4166 } 4155 }
4167 4156
4168 if (!focus_change_blocked && focused_element_) { 4157 if (!focus_change_blocked && focused_element_) {
4169 // Create the AXObject cache in a focus change because Chromium relies on 4158 // Create the AXObject cache in a focus change because Chromium relies on
4170 // it. 4159 // it.
4171 if (AXObjectCache* cache = AxObjectCache()) 4160 if (AXObjectCache* cache = AxObjectCache())
4172 cache->HandleFocusedUIElementChanged(old_focused_element, 4161 cache->HandleFocusedUIElementChanged(old_focused_element,
4173 new_focused_element); 4162 new_focused_element);
4174 } 4163 }
4175 4164
(...skipping 2487 matching lines...) Expand 10 before | Expand all | Expand 10 after
6663 } 6652 }
6664 6653
6665 void showLiveDocumentInstances() { 6654 void showLiveDocumentInstances() {
6666 WeakDocumentSet& set = liveDocumentSet(); 6655 WeakDocumentSet& set = liveDocumentSet();
6667 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6656 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6668 for (blink::Document* document : set) 6657 for (blink::Document* document : set)
6669 fprintf(stderr, "- Document %p URL: %s\n", document, 6658 fprintf(stderr, "- Document %p URL: %s\n", document,
6670 document->Url().GetString().Utf8().Data()); 6659 document->Url().GetString().Utf8().Data());
6671 } 6660 }
6672 #endif 6661 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ContainerNode.cpp ('k') | third_party/WebKit/Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698