| OLD | NEW |
| 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 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 received && ToElement(this)->AuthorShadowRoot()->delegatesFocus(); | 1062 received && ToElement(this)->AuthorShadowRoot()->delegatesFocus(); |
| 1063 } | 1063 } |
| 1064 | 1064 |
| 1065 if (IsFocused() == received) | 1065 if (IsFocused() == received) |
| 1066 return; | 1066 return; |
| 1067 | 1067 |
| 1068 Node::SetFocused(received, focus_type); | 1068 Node::SetFocused(received, focus_type); |
| 1069 | 1069 |
| 1070 FocusStateChanged(); | 1070 FocusStateChanged(); |
| 1071 | 1071 |
| 1072 UpdateDistribution(); | |
| 1073 for (ContainerNode* node = this; node; | |
| 1074 node = FlatTreeTraversal::Parent(*node)) { | |
| 1075 node->SetHasFocusWithin(received); | |
| 1076 node->FocusWithinStateChanged(); | |
| 1077 } | |
| 1078 | |
| 1079 if (GetLayoutObject() || received) | 1072 if (GetLayoutObject() || received) |
| 1080 return; | 1073 return; |
| 1081 | 1074 |
| 1082 // If :focus sets display: none, we lose focus but still need to recalc our | 1075 // If :focus sets display: none, we lose focus but still need to recalc our |
| 1083 // style. | 1076 // style. |
| 1084 if (IsElementNode() && ToElement(this)->ChildrenOrSiblingsAffectedByFocus()) | 1077 if (IsElementNode() && ToElement(this)->ChildrenOrSiblingsAffectedByFocus()) |
| 1085 ToElement(this)->PseudoStateChanged(CSSSelector::kPseudoFocus); | 1078 ToElement(this)->PseudoStateChanged(CSSSelector::kPseudoFocus); |
| 1086 else | 1079 else |
| 1087 SetNeedsStyleRecalc( | 1080 SetNeedsStyleRecalc( |
| 1088 kLocalStyleChange, | 1081 kLocalStyleChange, |
| 1089 StyleChangeReasonForTracing::CreateWithExtraData( | 1082 StyleChangeReasonForTracing::CreateWithExtraData( |
| 1090 StyleChangeReason::kPseudoClass, StyleChangeExtraData::g_focus)); | 1083 StyleChangeReason::kPseudoClass, StyleChangeExtraData::g_focus)); |
| 1091 | 1084 |
| 1092 if (IsElementNode() && | 1085 if (IsElementNode() && |
| 1093 ToElement(this)->ChildrenOrSiblingsAffectedByFocusWithin()) { | 1086 ToElement(this)->ChildrenOrSiblingsAffectedByFocusWithin()) { |
| 1094 ToElement(this)->PseudoStateChanged(CSSSelector::kPseudoFocusWithin); | 1087 ToElement(this)->PseudoStateChanged(CSSSelector::kPseudoFocusWithin); |
| 1095 } else { | 1088 } else { |
| 1096 SetNeedsStyleRecalc(kLocalStyleChange, | 1089 SetNeedsStyleRecalc(kLocalStyleChange, |
| 1097 StyleChangeReasonForTracing::CreateWithExtraData( | 1090 StyleChangeReasonForTracing::CreateWithExtraData( |
| 1098 StyleChangeReason::kPseudoClass, | 1091 StyleChangeReason::kPseudoClass, |
| 1099 StyleChangeExtraData::g_focus_within)); | 1092 StyleChangeExtraData::g_focus_within)); |
| 1100 } | 1093 } |
| 1101 } | 1094 } |
| 1102 | 1095 |
| 1096 void ContainerNode::SetHasFocusWithinUpToAncestor(bool flag, Node* ancestor) { |
| 1097 for (ContainerNode* node = this; node && node != ancestor; |
| 1098 node = FlatTreeTraversal::Parent(*node)) { |
| 1099 node->SetHasFocusWithin(flag); |
| 1100 node->FocusWithinStateChanged(); |
| 1101 } |
| 1102 } |
| 1103 |
| 1103 void ContainerNode::SetActive(bool down) { | 1104 void ContainerNode::SetActive(bool down) { |
| 1104 if (down == IsActive()) | 1105 if (down == IsActive()) |
| 1105 return; | 1106 return; |
| 1106 | 1107 |
| 1107 Node::SetActive(down); | 1108 Node::SetActive(down); |
| 1108 | 1109 |
| 1109 if (!GetLayoutObject()) { | 1110 if (!GetLayoutObject()) { |
| 1110 if (IsElementNode() && | 1111 if (IsElementNode() && |
| 1111 ToElement(this)->ChildrenOrSiblingsAffectedByActive()) | 1112 ToElement(this)->ChildrenOrSiblingsAffectedByActive()) |
| 1112 ToElement(this)->PseudoStateChanged(CSSSelector::kPseudoActive); | 1113 ToElement(this)->PseudoStateChanged(CSSSelector::kPseudoActive); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1519 return true; | 1520 return true; |
| 1520 | 1521 |
| 1521 if (node->IsElementNode() && ToElement(node)->Shadow()) | 1522 if (node->IsElementNode() && ToElement(node)->Shadow()) |
| 1522 return true; | 1523 return true; |
| 1523 | 1524 |
| 1524 return false; | 1525 return false; |
| 1525 } | 1526 } |
| 1526 #endif | 1527 #endif |
| 1527 | 1528 |
| 1528 } // namespace blink | 1529 } // namespace blink |
| OLD | NEW |