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

Side by Side Diff: third_party/WebKit/Source/core/dom/ContainerNode.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 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights
6 * reserved. 6 * reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 StyleChangeReasonForTracing::CreateWithExtraData( 1020 StyleChangeReasonForTracing::CreateWithExtraData(
1021 StyleChangeReason::kPseudoClass, StyleChangeExtraData::g_focus)); 1021 StyleChangeReason::kPseudoClass, StyleChangeExtraData::g_focus));
1022 } 1022 }
1023 if (IsElementNode() && ToElement(this)->ChildrenOrSiblingsAffectedByFocus()) 1023 if (IsElementNode() && ToElement(this)->ChildrenOrSiblingsAffectedByFocus())
1024 ToElement(this)->PseudoStateChanged(CSSSelector::kPseudoFocus); 1024 ToElement(this)->PseudoStateChanged(CSSSelector::kPseudoFocus);
1025 1025
1026 LayoutTheme::GetTheme().ControlStateChanged(*GetLayoutObject(), 1026 LayoutTheme::GetTheme().ControlStateChanged(*GetLayoutObject(),
1027 kFocusControlState); 1027 kFocusControlState);
1028 } 1028 }
1029 1029
1030 void ContainerNode::SetFocused(bool received) { 1030 void ContainerNode::SetFocused(bool received, WebFocusType focus_type) {
1031 // Recurse up author shadow trees to mark shadow hosts if it matches :focus. 1031 // Recurse up author shadow trees to mark shadow hosts if it matches :focus.
1032 // TODO(kochi): Handle UA shadows which marks multiple nodes as focused such 1032 // TODO(kochi): Handle UA shadows which marks multiple nodes as focused such
1033 // as <input type="date"> the same way as author shadow. 1033 // as <input type="date"> the same way as author shadow.
1034 if (ShadowRoot* root = ContainingShadowRoot()) { 1034 if (ShadowRoot* root = ContainingShadowRoot()) {
1035 if (root->GetType() != ShadowRootType::kUserAgent) 1035 if (root->GetType() != ShadowRootType::kUserAgent)
1036 OwnerShadowHost()->SetFocused(received); 1036 OwnerShadowHost()->SetFocused(received, focus_type);
1037 } 1037 }
1038 1038
1039 // If this is an author shadow host and indirectly focused (has focused 1039 // If this is an author shadow host and indirectly focused (has focused
1040 // element within its shadow root), update focus. 1040 // element within its shadow root), update focus.
1041 if (IsElementNode() && GetDocument().FocusedElement() && 1041 if (IsElementNode() && GetDocument().FocusedElement() &&
1042 GetDocument().FocusedElement() != this) { 1042 GetDocument().FocusedElement() != this) {
1043 if (ToElement(this)->AuthorShadowRoot()) 1043 if (ToElement(this)->AuthorShadowRoot())
1044 received = 1044 received =
1045 received && ToElement(this)->AuthorShadowRoot()->delegatesFocus(); 1045 received && ToElement(this)->AuthorShadowRoot()->delegatesFocus();
1046 } 1046 }
1047 1047
1048 if (IsFocused() == received) 1048 if (IsFocused() == received)
1049 return; 1049 return;
1050 1050
1051 Node::SetFocused(received); 1051 Node::SetFocused(received, focus_type);
1052 1052
1053 FocusStateChanged(); 1053 FocusStateChanged();
1054 1054
1055 if (GetLayoutObject() || received) 1055 if (GetLayoutObject() || received)
1056 return; 1056 return;
1057 1057
1058 // If :focus sets display: none, we lose focus but still need to recalc our 1058 // If :focus sets display: none, we lose focus but still need to recalc our
1059 // style. 1059 // style.
1060 if (IsElementNode() && ToElement(this)->ChildrenOrSiblingsAffectedByFocus()) 1060 if (IsElementNode() && ToElement(this)->ChildrenOrSiblingsAffectedByFocus())
1061 ToElement(this)->PseudoStateChanged(CSSSelector::kPseudoFocus); 1061 ToElement(this)->PseudoStateChanged(CSSSelector::kPseudoFocus);
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 return true; 1485 return true;
1486 1486
1487 if (node->IsElementNode() && ToElement(node)->Shadow()) 1487 if (node->IsElementNode() && ToElement(node)->Shadow())
1488 return true; 1488 return true;
1489 1489
1490 return false; 1490 return false;
1491 } 1491 }
1492 #endif 1492 #endif
1493 1493
1494 } // namespace blink 1494 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ContainerNode.h ('k') | third_party/WebKit/Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698