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

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 Clang linking problem. Created 6 years, 10 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 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 } 798 }
799 799
800 // This is used by FrameSelection to denote when the active-state of the page ha s changed 800 // This is used by FrameSelection to denote when the active-state of the page ha s changed
801 // independent of the focused element changing. 801 // independent of the focused element changing.
802 void ContainerNode::focusStateChanged() 802 void ContainerNode::focusStateChanged()
803 { 803 {
804 // If we're just changing the window's active state and the focused node has no 804 // If we're just changing the window's active state and the focused node has no
805 // renderer we can just ignore the state change. 805 // renderer we can just ignore the state change.
806 if (!renderer()) 806 if (!renderer())
807 return; 807 return;
808 // FIXME: This could probably setNeedsStyleRecalc(LocalStyleChange) in the a ffectedByFocus case 808
809 // and only setNeedsStyleRecalc(SubtreeStyleChange) in the childrenAffectedB yFocus case. 809 if (isElementNode() && toElement(this)->childrenAffectedByFocus())
810 if (renderStyle()->affectedByFocus() || (isElementNode() && toElement(this)- >childrenAffectedByFocus()))
811 setNeedsStyleRecalc(SubtreeStyleChange); 810 setNeedsStyleRecalc(SubtreeStyleChange);
811 else if (renderStyle()->affectedByFocus())
812 setNeedsStyleRecalc(LocalStyleChange);
813
812 if (renderer() && renderer()->style()->hasAppearance()) 814 if (renderer() && renderer()->style()->hasAppearance())
813 RenderTheme::theme().stateChanged(renderer(), FocusState); 815 RenderTheme::theme().stateChanged(renderer(), FocusState);
814 } 816 }
815 817
816 void ContainerNode::setFocus(bool received) 818 void ContainerNode::setFocus(bool received)
817 { 819 {
818 if (focused() == received) 820 if (focused() == received)
819 return; 821 return;
820 822
821 Node::setFocus(received); 823 Node::setFocus(received);
822 824
823 focusStateChanged(); 825 focusStateChanged();
826
827 if (renderer() || received)
828 return;
829
824 // 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.
825 if (!renderer() && !received) 831 if (isElementNode() && toElement(this)->childrenAffectedByFocus())
826 setNeedsStyleRecalc(SubtreeStyleChange); 832 setNeedsStyleRecalc(SubtreeStyleChange);
833 else
834 setNeedsStyleRecalc(LocalStyleChange);
827 } 835 }
828 836
829 void ContainerNode::setActive(bool down) 837 void ContainerNode::setActive(bool down)
830 { 838 {
831 if (down == active()) 839 if (down == active())
832 return; 840 return;
833 841
834 Node::setActive(down); 842 Node::setActive(down);
835 843
836 // 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 return true; 1067 return true;
1060 1068
1061 if (node->isElementNode() && toElement(node)->shadow()) 1069 if (node->isElementNode() && toElement(node)->shadow())
1062 return true; 1070 return true;
1063 1071
1064 return false; 1072 return false;
1065 } 1073 }
1066 #endif 1074 #endif
1067 1075
1068 } // namespace WebCore 1076 } // 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