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

Side by Side Diff: Source/core/dom/ContainerNode.cpp

Issue 1177673005: Implement ShadowRoot.delegatesFocus 4/4 (match CSS :focus for shadow host) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: split a layout test into 5 tests. Created 5 years, 6 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 | Annotate | Revision Log
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 reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 document().styleEngine().pseudoStateChangedForElement(CSSSelector::P seudoFocus, *toElement(this)); 1077 document().styleEngine().pseudoStateChangedForElement(CSSSelector::P seudoFocus, *toElement(this));
1078 else if (computedStyle()->affectedByFocus()) 1078 else if (computedStyle()->affectedByFocus())
1079 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::c reateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)) ; 1079 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::c reateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)) ;
1080 } 1080 }
1081 1081
1082 LayoutTheme::theme().controlStateChanged(*layoutObject(), FocusControlState) ; 1082 LayoutTheme::theme().controlStateChanged(*layoutObject(), FocusControlState) ;
1083 } 1083 }
1084 1084
1085 void ContainerNode::setFocus(bool received) 1085 void ContainerNode::setFocus(bool received)
1086 { 1086 {
1087 // Recurse up the shadow trees to mark shadow hosts if it matches :focus.
hayato 2015/06/12 04:37:57 Could you add a layout test which involves a dom m
kochi 2015/06/12 07:34:17 Added 'focus-with-dom-mutation.html' layout test w
1088 if (isInShadowTree() && shadowHost()->shadowRoot())
hayato 2015/06/12 04:37:57 Not intuitive to me. Is this checking that `this`
kochi 2015/06/12 07:34:17 Yes, it's author shadow only. Updated the comment
1089 shadowHost()->setFocus(received);
1090
1091 // If this is an author shadow host and indirectly focused (has focused elem ent within
1092 // its shadow root), update focus.
1093 // TODO(kochi): Handle UA shadow which marks multiple nodes as focused such as
1094 // <input type="date"> the same way as author shadow.
1095 if (document().focusedElement() && document().focusedElement() != this) {
1096 Element* host = toElement(this);
hayato 2015/06/12 04:37:57 1. Looks isElementNode() is used in L1112. `this`
kochi 2015/06/12 07:34:17 1. Good catch. I guess no one is calling setFocus
1097 if (host->shadowRoot())
1098 received = received && host->shadowRoot()->delegatesFocus();
1099 }
1100
1087 if (focused() == received) 1101 if (focused() == received)
1088 return; 1102 return;
1089 1103
1090 Node::setFocus(received); 1104 Node::setFocus(received);
1091 1105
1092 focusStateChanged(); 1106 focusStateChanged();
1093 1107
1094 if (layoutObject() || received) 1108 if (layoutObject() || received)
1095 return; 1109 return;
1096 1110
1097 // If :focus sets display: none, we lose focus but still need to recalc our style. 1111 // If :focus sets display: none, we lose focus but still need to recalc our style.
hayato 2015/06/12 04:37:57 Looks focusStateChanged() and the code around here
kochi 2015/06/12 07:34:17 I'm afraid their conditions are subtly different a
1098 if (isElementNode() && toElement(this)->childrenOrSiblingsAffectedByFocus() && styleChangeType() < SubtreeStyleChange) 1112 if (isElementNode() && toElement(this)->childrenOrSiblingsAffectedByFocus() && styleChangeType() < SubtreeStyleChange)
1099 document().styleEngine().pseudoStateChangedForElement(CSSSelector::Pseud oFocus, *toElement(this)); 1113 document().styleEngine().pseudoStateChangedForElement(CSSSelector::Pseud oFocus, *toElement(this));
1100 else 1114 else
1101 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::creat eWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)); 1115 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::creat eWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus));
1102 } 1116 }
1103 1117
1104 void ContainerNode::setActive(bool down) 1118 void ContainerNode::setActive(bool down)
1105 { 1119 {
1106 if (down == active()) 1120 if (down == active())
1107 return; 1121 return;
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 return true; 1521 return true;
1508 1522
1509 if (node->isElementNode() && toElement(node)->shadow()) 1523 if (node->isElementNode() && toElement(node)->shadow())
1510 return true; 1524 return true;
1511 1525
1512 return false; 1526 return false;
1513 } 1527 }
1514 #endif 1528 #endif
1515 1529
1516 } // namespace blink 1530 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/shadow/focus-shadowhost-display-none-expected.txt ('k') | Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698