OLD | NEW |
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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 void StyleResolver::collectFeatures() | 234 void StyleResolver::collectFeatures() |
235 { | 235 { |
236 m_features.clear(); | 236 m_features.clear(); |
237 m_ruleSets.collectFeaturesTo(m_features, document().isViewSource()); | 237 m_ruleSets.collectFeaturesTo(m_features, document().isViewSource()); |
238 m_styleTree.collectFeaturesTo(m_features); | 238 m_styleTree.collectFeaturesTo(m_features); |
239 | 239 |
240 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); | 240 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); |
241 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); | 241 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); |
242 } | 242 } |
243 | 243 |
| 244 bool StyleResolver::supportsStyleSharing(Element* element) |
| 245 { |
| 246 if (!element || !element->isStyledElement() || !element->parentElement()) |
| 247 return false; |
| 248 |
| 249 // If the element has inline style it is probably unique. |
| 250 if (element->inlineStyle()) |
| 251 return false; |
| 252 if (element->isSVGElement() && toSVGElement(element)->animatedSMILStylePrope
rties()) |
| 253 return false; |
| 254 // Ids stop style sharing if they show up in the stylesheets. |
| 255 if (element->hasID() && m_features.idsInRules.contains(element->idForStyleRe
solution().impl())) |
| 256 return false; |
| 257 // Active and hovered elements always make a chain towards the document node |
| 258 // and no siblings or cousins will have the same state. |
| 259 if (element->hovered()) |
| 260 return false; |
| 261 if (element->active()) |
| 262 return false; |
| 263 // There is always only one focused element. |
| 264 if (element->focused()) |
| 265 return false; |
| 266 if (element->parentElement()->hasFlagsSetDuringStylingOfChildren()) |
| 267 return false; |
| 268 if (element->hasScopedHTMLStyleChild()) |
| 269 return false; |
| 270 if (element == m_document.cssTarget()) |
| 271 return false; |
| 272 if (element->isHTMLElement() && toHTMLElement(element)->hasDirectionAuto()) |
| 273 return false; |
| 274 if (element->hasActiveAnimations()) |
| 275 return false; |
| 276 // When a dialog is first shown, its style is mutated to center it in the |
| 277 // viewport. So the styles can't be shared since the viewport position and |
| 278 // size may be different each time a dialog is opened. |
| 279 if (element->hasTagName(dialogTag)) |
| 280 return false; |
| 281 if (isShadowHost(element) && element->shadow()->containsActiveStyles()) |
| 282 return false; |
| 283 return true; |
| 284 } |
| 285 |
| 286 void StyleResolver::addToStyleSharingList(Element* element) |
| 287 { |
| 288 if (m_styleSharingList.size() >= styleSharingListSize) |
| 289 m_styleSharingList.remove(--m_styleSharingList.end()); |
| 290 m_styleSharingList.prepend(element); |
| 291 } |
| 292 |
| 293 void StyleResolver::clearStyleSharingList() |
| 294 { |
| 295 m_styleSharingList.clear(); |
| 296 } |
| 297 |
244 void StyleResolver::pushParentElement(Element* parent) | 298 void StyleResolver::pushParentElement(Element* parent) |
245 { | 299 { |
246 ASSERT(parent); | 300 ASSERT(parent); |
247 const ContainerNode* parentsParent = parent->parentOrShadowHostElement(); | 301 const ContainerNode* parentsParent = parent->parentOrShadowHostElement(); |
248 | 302 |
249 // We are not always invoked consistently. For example, script execution can
cause us to enter | 303 // We are not always invoked consistently. For example, script execution can
cause us to enter |
250 // style recalc in the middle of tree building. We may also be invoked from
somewhere within the tree. | 304 // style recalc in the middle of tree building. We may also be invoked from
somewhere within the tree. |
251 // Reset the stack in this case, or if we see a new root element. | 305 // Reset the stack in this case, or if we see a new root element. |
252 // Otherwise just push the new parent. | 306 // Otherwise just push the new parent. |
253 if (!parentsParent || m_selectorFilter.parentStackIsEmpty()) | 307 if (!parentsParent || m_selectorFilter.parentStackIsEmpty()) |
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties
SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa
che); | 1566 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties
SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa
che); |
1513 | 1567 |
1514 fprintf(stderr, "Total:\n"); | 1568 fprintf(stderr, "Total:\n"); |
1515 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS
tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, | 1569 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS
tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, |
1516 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa
tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch
edPropertiesEnteredIntoCache); | 1570 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa
tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch
edPropertiesEnteredIntoCache); |
1517 fprintf(stderr, "-----------------------------------------------------------
---------------------\n"); | 1571 fprintf(stderr, "-----------------------------------------------------------
---------------------\n"); |
1518 } | 1572 } |
1519 #endif | 1573 #endif |
1520 | 1574 |
1521 } // namespace WebCore | 1575 } // namespace WebCore |
OLD | NEW |