| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 { | 278 { |
| 279 for (Element& element : ElementTraversal::startsAt(document().documentElemen
t())) { | 279 for (Element& element : ElementTraversal::startsAt(document().documentElemen
t())) { |
| 280 if (element.supportsStyleSharing() && canShareStyleWithElement(element)) | 280 if (element.supportsStyleSharing() && canShareStyleWithElement(element)) |
| 281 return true; | 281 return true; |
| 282 } | 282 } |
| 283 return false; | 283 return false; |
| 284 } | 284 } |
| 285 | 285 |
| 286 inline Element* SharedStyleFinder::findElementForStyleSharing() const | 286 inline Element* SharedStyleFinder::findElementForStyleSharing() const |
| 287 { | 287 { |
| 288 StyleSharingList& styleSharingList = m_styleResolver.styleSharingList(); | 288 StyleSharingList& styleSharingList = m_styleResolver->styleSharingList(); |
| 289 for (StyleSharingList::iterator it = styleSharingList.begin(); it != styleSh
aringList.end(); ++it) { | 289 for (StyleSharingList::iterator it = styleSharingList.begin(); it != styleSh
aringList.end(); ++it) { |
| 290 Element& candidate = **it; | 290 Element& candidate = **it; |
| 291 if (!canShareStyleWithElement(candidate)) | 291 if (!canShareStyleWithElement(candidate)) |
| 292 continue; | 292 continue; |
| 293 if (it != styleSharingList.begin()) { | 293 if (it != styleSharingList.begin()) { |
| 294 // Move the element to the front of the LRU | 294 // Move the element to the front of the LRU |
| 295 styleSharingList.remove(it); | 295 styleSharingList.remove(it); |
| 296 styleSharingList.prepend(&candidate); | 296 styleSharingList.prepend(&candidate); |
| 297 } | 297 } |
| 298 return &candidate; | 298 return &candidate; |
| 299 } | 299 } |
| 300 m_styleResolver.addToStyleSharingList(element()); | 300 m_styleResolver->addToStyleSharingList(element()); |
| 301 return 0; | 301 return 0; |
| 302 } | 302 } |
| 303 | 303 |
| 304 bool SharedStyleFinder::matchesRuleSet(RuleSet* ruleSet) | 304 bool SharedStyleFinder::matchesRuleSet(RuleSet* ruleSet) |
| 305 { | 305 { |
| 306 if (!ruleSet) | 306 if (!ruleSet) |
| 307 return false; | 307 return false; |
| 308 ElementRuleCollector collector(m_context, m_styleResolver.selectorFilter()); | 308 ElementRuleCollector collector(m_context, m_styleResolver->selectorFilter())
; |
| 309 return collector.hasAnyMatchingRules(ruleSet); | 309 return collector.hasAnyMatchingRules(ruleSet); |
| 310 } | 310 } |
| 311 | 311 |
| 312 ComputedStyle* SharedStyleFinder::findSharedStyle() | 312 ComputedStyle* SharedStyleFinder::findSharedStyle() |
| 313 { | 313 { |
| 314 INCREMENT_STYLE_STATS_COUNTER(m_styleResolver, sharedStyleLookups, 1); | 314 INCREMENT_STYLE_STATS_COUNTER(*m_styleResolver, sharedStyleLookups, 1); |
| 315 | 315 |
| 316 if (!element().supportsStyleSharing()) | 316 if (!element().supportsStyleSharing()) |
| 317 return 0; | 317 return 0; |
| 318 | 318 |
| 319 // Cache whether context.element() is affected by any known class selectors. | 319 // Cache whether context.element() is affected by any known class selectors. |
| 320 m_elementAffectedByClassRules = element().hasClass() && classNamesAffectedBy
Rules(element().classNames()); | 320 m_elementAffectedByClassRules = element().hasClass() && classNamesAffectedBy
Rules(element().classNames()); |
| 321 | 321 |
| 322 Element* shareElement = findElementForStyleSharing(); | 322 Element* shareElement = findElementForStyleSharing(); |
| 323 | 323 |
| 324 if (!shareElement) { | 324 if (!shareElement) { |
| 325 if (m_styleResolver.stats() && m_styleResolver.stats()->allCountersEnabl
ed() && documentContainsValidCandidate()) | 325 if (m_styleResolver->stats() && m_styleResolver->stats()->allCountersEna
bled() && documentContainsValidCandidate()) |
| 326 INCREMENT_STYLE_STATS_COUNTER(m_styleResolver, sharedStyleMissed, 1)
; | 326 INCREMENT_STYLE_STATS_COUNTER(*m_styleResolver, sharedStyleMissed, 1
); |
| 327 return 0; | 327 return 0; |
| 328 } | 328 } |
| 329 | 329 |
| 330 INCREMENT_STYLE_STATS_COUNTER(m_styleResolver, sharedStyleFound, 1); | 330 INCREMENT_STYLE_STATS_COUNTER(*m_styleResolver, sharedStyleFound, 1); |
| 331 | 331 |
| 332 if (matchesRuleSet(m_siblingRuleSet)) { | 332 if (matchesRuleSet(m_siblingRuleSet)) { |
| 333 INCREMENT_STYLE_STATS_COUNTER(m_styleResolver, sharedStyleRejectedBySibl
ingRules, 1); | 333 INCREMENT_STYLE_STATS_COUNTER(*m_styleResolver, sharedStyleRejectedBySib
lingRules, 1); |
| 334 return 0; | 334 return 0; |
| 335 } | 335 } |
| 336 | 336 |
| 337 if (matchesRuleSet(m_uncommonAttributeRuleSet)) { | 337 if (matchesRuleSet(m_uncommonAttributeRuleSet)) { |
| 338 INCREMENT_STYLE_STATS_COUNTER(m_styleResolver, sharedStyleRejectedByUnco
mmonAttributeRules, 1); | 338 INCREMENT_STYLE_STATS_COUNTER(*m_styleResolver, sharedStyleRejectedByUnc
ommonAttributeRules, 1); |
| 339 return 0; | 339 return 0; |
| 340 } | 340 } |
| 341 | 341 |
| 342 // Tracking child index requires unique style for each node. This may get se
t by the sibling rule match above. | 342 // Tracking child index requires unique style for each node. This may get se
t by the sibling rule match above. |
| 343 if (!element().parentElementOrShadowRoot()->childrenSupportStyleSharing()) { | 343 if (!element().parentElementOrShadowRoot()->childrenSupportStyleSharing()) { |
| 344 INCREMENT_STYLE_STATS_COUNTER(m_styleResolver, sharedStyleRejectedByPare
nt, 1); | 344 INCREMENT_STYLE_STATS_COUNTER(*m_styleResolver, sharedStyleRejectedByPar
ent, 1); |
| 345 return 0; | 345 return 0; |
| 346 } | 346 } |
| 347 | 347 |
| 348 return shareElement->mutableComputedStyle(); | 348 return shareElement->mutableComputedStyle(); |
| 349 } | 349 } |
| 350 | 350 |
| 351 } | 351 } |
| OLD | NEW |