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

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

Issue 135183002: Avoid unnecessary style recalc for subtree of focused element. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed contenteditable shadow dom regression. Created 6 years, 11 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
« no previous file with comments | « Source/core/css/AffectedByFocusTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 if (foundUpperLeft != foundLowerRight) { 784 if (foundUpperLeft != foundLowerRight) {
785 if (foundUpperLeft) 785 if (foundUpperLeft)
786 lowerRight = upperLeft; 786 lowerRight = upperLeft;
787 else 787 else
788 upperLeft = lowerRight; 788 upperLeft = lowerRight;
789 } 789 }
790 790
791 return enclosingLayoutRect(FloatRect(upperLeft, lowerRight.expandedTo(upperL eft) - upperLeft)); 791 return enclosingLayoutRect(FloatRect(upperLeft, lowerRight.expandedTo(upperL eft) - upperLeft));
792 } 792 }
793 793
794 static inline StyleChangeType focusStyleChange(const ContainerNode* node)
esprehn 2014/01/22 20:58:52 This should be a private method, you always pass |
rune 2014/01/30 23:24:36 Done. That is, the method is now gone.
795 {
796 // -webkit-user-modify (from contenteditable) needs special propagation (see StyleResolver)
797 // into the shadow dom. Do SubtreeStyleChange even if children are not affec ted by focus to
798 // cover that.
799 if (node->isElementNode() && (toElement(node)->childrenAffectedByFocus() || toElement(node)->shadow()))
esprehn 2014/01/22 20:58:52 This shadow check doesn't seem right, why do you n
rune 2014/01/30 17:24:40 It's about the propagation of -webkit-user-modify
rune 2014/01/30 23:24:36 Done.
800 return SubtreeStyleChange;
801 if (!node->renderer() || node->renderStyle()->affectedByFocus())
802 return LocalStyleChange;
803 return NoStyleChange;
804 }
805
794 // This is used by FrameSelection to denote when the active-state of the page ha s changed 806 // This is used by FrameSelection to denote when the active-state of the page ha s changed
795 // independent of the focused element changing. 807 // independent of the focused element changing.
796 void ContainerNode::focusStateChanged() 808 void ContainerNode::focusStateChanged()
797 { 809 {
798 // If we're just changing the window's active state and the focused node has no 810 // If we're just changing the window's active state and the focused node has no
799 // renderer we can just ignore the state change. 811 // renderer we can just ignore the state change.
800 if (!renderer()) 812 if (!renderer())
801 return; 813 return;
802 // FIXME: This could probably setNeedsStyleRecalc(LocalStyleChange) in the a ffectedByFocus case 814
803 // and only setNeedsStyleRecalc(SubtreeStyleChange) in the childrenAffectedB yFocus case. 815 StyleChangeType change = focusStyleChange(this);
804 if (renderStyle()->affectedByFocus() || (isElementNode() && toElement(this)- >childrenAffectedByFocus())) 816 if (change != NoStyleChange)
805 setNeedsStyleRecalc(); 817 setNeedsStyleRecalc(change);
806 if (renderer() && renderer()->style()->hasAppearance()) 818 if (renderer() && renderer()->style()->hasAppearance())
807 RenderTheme::theme().stateChanged(renderer(), FocusState); 819 RenderTheme::theme().stateChanged(renderer(), FocusState);
808 } 820 }
809 821
810 void ContainerNode::setFocus(bool received) 822 void ContainerNode::setFocus(bool received)
811 { 823 {
812 if (focused() == received) 824 if (focused() == received)
813 return; 825 return;
814 826
815 Node::setFocus(received); 827 Node::setFocus(received);
816 828
817 focusStateChanged(); 829 focusStateChanged();
818 // If :focus sets display: none, we lose focus but still need to recalc our style. 830 // If :focus sets display: none, we lose focus but still need to recalc our style.
819 if (!renderer() && !received) 831 if (!renderer() && !received) {
820 setNeedsStyleRecalc(); 832 ASSERT(focusStyleChange(this) != NoStyleChange);
833 setNeedsStyleRecalc(focusStyleChange(this));
834 }
821 } 835 }
822 836
823 void ContainerNode::setActive(bool down) 837 void ContainerNode::setActive(bool down)
824 { 838 {
825 if (down == active()) 839 if (down == active())
826 return; 840 return;
827 841
828 Node::setActive(down); 842 Node::setActive(down);
829 843
830 // FIXME: Why does this not need to handle the display: none transition like :hover does? 844 // FIXME: Why does this not need to handle the display: none transition like :hover does?
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 return true; 991 return true;
978 992
979 if (node->isElementNode() && toElement(node)->shadow()) 993 if (node->isElementNode() && toElement(node)->shadow())
980 return true; 994 return true;
981 995
982 return false; 996 return false;
983 } 997 }
984 #endif 998 #endif
985 999
986 } // namespace WebCore 1000 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/AffectedByFocusTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698