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

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp

Issue 2610513003: Avoid unnecessary updateActiveStyle comparing shadow styles. (Closed)
Patch Set: Added documentation. Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * Copyright (C) 2012 Google Inc. All rights reserved. 5 * Copyright (C) 2012 Google Inc. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 if (!m_treeBoundaryCrossingRuleSet) { 291 if (!m_treeBoundaryCrossingRuleSet) {
292 m_treeBoundaryCrossingRuleSet = new CSSStyleSheetRuleSubSet(); 292 m_treeBoundaryCrossingRuleSet = new CSSStyleSheetRuleSubSet();
293 treeScope().document().styleEngine().addTreeBoundaryCrossingScope( 293 treeScope().document().styleEngine().addTreeBoundaryCrossingScope(
294 treeScope()); 294 treeScope());
295 } 295 }
296 296
297 m_treeBoundaryCrossingRuleSet->push_back( 297 m_treeBoundaryCrossingRuleSet->push_back(
298 RuleSubSet::create(parentStyleSheet, sheetIndex, ruleSetForScope)); 298 RuleSubSet::create(parentStyleSheet, sheetIndex, ruleSetForScope));
299 } 299 }
300 300
301 bool ScopedStyleResolver::haveSameStyles(const ScopedStyleResolver* first,
302 const ScopedStyleResolver* second) {
303 // This method will return true if the two resolvers are either both empty, or
304 // if they contain the same active stylesheets by sharing the same
305 // StyleSheetContents. It is used to check if we can share ComputedStyle
306 // between two shadow hosts. This typically works when we have multiple
307 // instantiations of the same web component where the style elements are in
308 // the same order and contain the exact same source string in which case we
309 // will get a cache hit for sharing StyleSheetContents.
310
311 size_t firstCount = first ? first->m_authorStyleSheets.size() : 0;
312 size_t secondCount = second ? second->m_authorStyleSheets.size() : 0;
313 if (firstCount != secondCount)
314 return false;
315 while (firstCount--) {
316 if (first->m_authorStyleSheets[firstCount]->contents() !=
317 second->m_authorStyleSheets[firstCount]->contents())
318 return false;
319 }
320 return true;
321 }
322
301 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) { 323 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) {
302 visitor->trace(m_parentStyleSheet); 324 visitor->trace(m_parentStyleSheet);
303 visitor->trace(m_ruleSet); 325 visitor->trace(m_ruleSet);
304 } 326 }
305 327
306 } // namespace blink 328 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698