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/css/resolver/SharedStyleFinder.cpp

Issue 30453002: Should not allow style sharing if grandparents matches different rule chain (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@build_hack
Patch Set: same as patchset 2, rebased. Created 7 years, 2 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
« no previous file with comments | « LayoutTests/fast/css/style-sharing-grand-parent-invalidate-expected.txt ('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) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // that sharing the style makes sense. Instead we should just not support st yle sharing 150 // that sharing the style makes sense. Instead we should just not support st yle sharing
151 // for them. 151 // for them.
152 if (element().hasTagName(progressTag)) { 152 if (element().hasTagName(progressTag)) {
153 if (element().shouldAppearIndeterminate() != candidate.shouldAppearIndet erminate()) 153 if (element().shouldAppearIndeterminate() != candidate.shouldAppearIndet erminate())
154 return false; 154 return false;
155 } 155 }
156 156
157 return true; 157 return true;
158 } 158 }
159 159
160 static bool ancestorChainAllShareStyle(Element* parentA, Element* parentB)
161 {
162 while (parentA != parentB) {
163 ASSERT(parentA && parentB);
164 if (parentA->renderStyle() != parentB->renderStyle())
165 return false;
166
167 parentA = parentA->parentElement();
168 parentB = parentB->parentElement();
esprehn 2013/10/19 09:10:09 I don't think this is safe. If parentA has a null
169 }
170 return true;
171 }
172
160 bool SharedStyleFinder::canShareStyleWithElement(Element& candidate) const 173 bool SharedStyleFinder::canShareStyleWithElement(Element& candidate) const
161 { 174 {
162 if (element() == candidate) 175 if (element() == candidate)
163 return false; 176 return false;
164 Element* parent = candidate.parentElement(); 177 Element* parent = candidate.parentElement();
165 RenderStyle* style = candidate.renderStyle(); 178 RenderStyle* style = candidate.renderStyle();
166 if (!style) 179 if (!style)
167 return false; 180 return false;
168 if (!parent) 181 if (!parent)
169 return false; 182 return false;
170 if (element().parentElement()->renderStyle() != parent->renderStyle()) 183 if (!ancestorChainAllShareStyle(element().parentElement(), parent))
171 return false; 184 return false;
172 if (style->unique()) 185 if (style->unique())
173 return false; 186 return false;
174 if (style->hasUniquePseudoStyle()) 187 if (style->hasUniquePseudoStyle())
175 return false; 188 return false;
176 if (candidate.tagQName() != element().tagQName()) 189 if (candidate.tagQName() != element().tagQName())
177 return false; 190 return false;
178 if (candidate.inlineStyle()) 191 if (candidate.inlineStyle())
179 return false; 192 return false;
180 if (candidate.needsStyleRecalc()) 193 if (candidate.needsStyleRecalc())
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 if (matchesRuleSet(m_siblingRuleSet) || matchesRuleSet(m_uncommonAttributeRu leSet)) 345 if (matchesRuleSet(m_siblingRuleSet) || matchesRuleSet(m_uncommonAttributeRu leSet))
333 return 0; 346 return 0;
334 // Tracking child index requires unique style for each node. This may get se t by the sibling rule match above. 347 // Tracking child index requires unique style for each node. This may get se t by the sibling rule match above.
335 if (element().parentElement()->childrenSupportStyleSharing()) 348 if (element().parentElement()->childrenSupportStyleSharing())
336 return 0; 349 return 0;
337 STYLE_STATS_ADD_STYLE_SHARED(); 350 STYLE_STATS_ADD_STYLE_SHARED();
338 return shareElement->renderStyle(); 351 return shareElement->renderStyle();
339 } 352 }
340 353
341 } 354 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/css/style-sharing-grand-parent-invalidate-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698