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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 continue; | 372 continue; |
373 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver()) { | 373 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver()) { |
374 collector.clearMatchedRules(); | 374 collector.clearMatchedRules(); |
375 resolver->collectMatchingShadowHostRules(collector, includeEmptyRule
s); | 375 resolver->collectMatchingShadowHostRules(collector, includeEmptyRule
s); |
376 collector.sortAndTransferMatchedRules(); | 376 collector.sortAndTransferMatchedRules(); |
377 collector.finishAddingAuthorRulesForTreeScope(); | 377 collector.finishAddingAuthorRulesForTreeScope(); |
378 } | 378 } |
379 } | 379 } |
380 } | 380 } |
381 | 381 |
382 void StyleResolver::matchElementScopeRules(ScopedStyleResolver& elementScopeReso
lver, ElementRuleCollector& collector, bool includeEmptyRules) | 382 void StyleResolver::matchElementScopeRules(const Element& element, ScopedStyleRe
solver* elementScopeResolver, ElementRuleCollector& collector, bool includeEmpty
Rules) |
383 { | 383 { |
384 collector.clearMatchedRules(); | 384 if (elementScopeResolver) { |
385 elementScopeResolver.collectMatchingAuthorRules(collector, includeEmptyRules
); | 385 collector.clearMatchedRules(); |
386 elementScopeResolver.collectMatchingTreeBoundaryCrossingRules(collector, inc
ludeEmptyRules); | 386 elementScopeResolver->collectMatchingAuthorRules(collector, includeEmpty
Rules); |
387 collector.sortAndTransferMatchedRules(); | 387 elementScopeResolver->collectMatchingTreeBoundaryCrossingRules(collector
, includeEmptyRules); |
| 388 collector.sortAndTransferMatchedRules(); |
| 389 } |
| 390 |
| 391 if (element.isStyledElement() && element.inlineStyle() && !collector.isColle
ctingForPseudoElement()) { |
| 392 // Inline style is immutable as long as there is no CSSOM wrapper. |
| 393 bool isInlineStyleCacheable = !element.inlineStyle()->isMutable(); |
| 394 collector.addElementStyleProperties(element.inlineStyle(), isInlineStyle
Cacheable); |
| 395 } |
| 396 |
388 collector.finishAddingAuthorRulesForTreeScope(); | 397 collector.finishAddingAuthorRulesForTreeScope(); |
389 } | 398 } |
390 | 399 |
391 void StyleResolver::matchScopedRules(const Element& element, ElementRuleCollecto
r& collector, bool includeEmptyRules) | 400 void StyleResolver::matchScopedRules(const Element& element, ElementRuleCollecto
r& collector, bool includeEmptyRules) |
392 { | 401 { |
393 // Match rules from treeScopes in the reverse tree-of-trees order, since the | 402 // Match rules from treeScopes in the reverse tree-of-trees order, since the |
394 // cascading order for normal rules is such that when comparing rules from | 403 // cascading order for normal rules is such that when comparing rules from |
395 // different shadow trees, the rule from the tree which comes first in the | 404 // different shadow trees, the rule from the tree which comes first in the |
396 // tree-of-trees order wins. From other treeScopes than the element's own | 405 // tree-of-trees order wins. From other treeScopes than the element's own |
397 // scope, only tree-boundary-crossing rules may match. | 406 // scope, only tree-boundary-crossing rules may match. |
398 | 407 |
399 ScopedStyleResolver* elementScopeResolver = scopedResolverFor(element); | 408 ScopedStyleResolver* elementScopeResolver = scopedResolverFor(element); |
400 bool matchElementScopeDone = !elementScopeResolver; | 409 bool matchElementScopeDone = !elementScopeResolver && !element.inlineStyle()
; |
401 | 410 |
402 for (auto it = m_treeBoundaryCrossingScopes.rbegin(); it != m_treeBoundaryCr
ossingScopes.rend(); ++it) { | 411 for (auto it = m_treeBoundaryCrossingScopes.rbegin(); it != m_treeBoundaryCr
ossingScopes.rend(); ++it) { |
403 const TreeScope& scope = (*it)->treeScope(); | 412 const TreeScope& scope = (*it)->treeScope(); |
404 ScopedStyleResolver* resolver = scope.scopedStyleResolver(); | 413 ScopedStyleResolver* resolver = scope.scopedStyleResolver(); |
405 ASSERT(resolver); | 414 ASSERT(resolver); |
406 | 415 |
407 if (!matchElementScopeDone && scope.isInclusiveAncestorOf(element.treeSc
ope())) { | 416 if (!matchElementScopeDone && scope.isInclusiveAncestorOf(element.treeSc
ope())) { |
408 | 417 |
409 matchElementScopeDone = true; | 418 matchElementScopeDone = true; |
410 | 419 |
411 // At this point, the iterator has either encountered the scope for
the element | 420 // At this point, the iterator has either encountered the scope for
the element |
412 // itself (if that scope has boundary-crossing rules), or the iterat
or has moved | 421 // itself (if that scope has boundary-crossing rules), or the iterat
or has moved |
413 // to a scope which appears before the element's scope in the tree-o
f-trees order. | 422 // to a scope which appears before the element's scope in the tree-o
f-trees order. |
414 // Try to match all rules from the element's scope. | 423 // Try to match all rules from the element's scope. |
415 | 424 |
416 matchElementScopeRules(*elementScopeResolver, collector, includeEmpt
yRules); | 425 matchElementScopeRules(element, elementScopeResolver, collector, inc
ludeEmptyRules); |
417 if (resolver == elementScopeResolver) { | 426 if (resolver == elementScopeResolver) { |
418 // Boundary-crossing rules already collected in matchElementScop
eRules. | 427 // Boundary-crossing rules already collected in matchElementScop
eRules. |
419 continue; | 428 continue; |
420 } | 429 } |
421 } | 430 } |
422 | 431 |
423 collector.clearMatchedRules(); | 432 collector.clearMatchedRules(); |
424 resolver->collectMatchingTreeBoundaryCrossingRules(collector, includeEmp
tyRules); | 433 resolver->collectMatchingTreeBoundaryCrossingRules(collector, includeEmp
tyRules); |
425 collector.sortAndTransferMatchedRules(); | 434 collector.sortAndTransferMatchedRules(); |
426 collector.finishAddingAuthorRulesForTreeScope(); | 435 collector.finishAddingAuthorRulesForTreeScope(); |
427 } | 436 } |
428 | 437 |
429 if (!matchElementScopeDone) | 438 if (!matchElementScopeDone) |
430 matchElementScopeRules(*elementScopeResolver, collector, includeEmptyRul
es); | 439 matchElementScopeRules(element, elementScopeResolver, collector, include
EmptyRules); |
431 } | 440 } |
432 | 441 |
433 void StyleResolver::matchAuthorRules(const Element& element, ElementRuleCollecto
r& collector, bool includeEmptyRules) | 442 void StyleResolver::matchAuthorRules(const Element& element, ElementRuleCollecto
r& collector, bool includeEmptyRules) |
434 { | 443 { |
435 matchHostRules(element, collector, includeEmptyRules); | 444 matchHostRules(element, collector, includeEmptyRules); |
436 matchScopedRules(element, collector, includeEmptyRules); | 445 matchScopedRules(element, collector, includeEmptyRules); |
437 } | 446 } |
438 | 447 |
439 void StyleResolver::matchUARules(ElementRuleCollector& collector) | 448 void StyleResolver::matchUARules(ElementRuleCollector& collector) |
440 { | 449 { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 if (isAuto) { | 491 if (isAuto) { |
483 state.setHasDirAutoAttribute(true); | 492 state.setHasDirAutoAttribute(true); |
484 collector.addElementStyleProperties(textDirection == LTR ? leftT
oRightDeclaration() : rightToLeftDeclaration()); | 493 collector.addElementStyleProperties(textDirection == LTR ? leftT
oRightDeclaration() : rightToLeftDeclaration()); |
485 } | 494 } |
486 } | 495 } |
487 } | 496 } |
488 | 497 |
489 matchAuthorRules(*state.element(), collector, false); | 498 matchAuthorRules(*state.element(), collector, false); |
490 | 499 |
491 if (state.element()->isStyledElement()) { | 500 if (state.element()->isStyledElement()) { |
492 // TODO(rune@opera.com): Adding style attribute rules here is probably t
oo late | |
493 // when you have shadow piercing combinators. When we don't have piercin
g combinators, | |
494 // the style attribute always belong to the outermost scope whose rules
apply to | |
495 // the element. Thus, applying inline style here is correct. Fixing this
for piercing | |
496 // combinators means moving the code below into matchElementScopeRules a
nd _not_ | |
497 // invoking it for pseudo style requests. | |
498 if (state.element()->inlineStyle()) { | |
499 // Inline style is immutable as long as there is no CSSOM wrapper. | |
500 bool isInlineStyleCacheable = !state.element()->inlineStyle()->isMut
able(); | |
501 collector.addElementStyleProperties(state.element()->inlineStyle(),
isInlineStyleCacheable); | |
502 } | |
503 | |
504 // Now check SMIL animation override style. | 501 // Now check SMIL animation override style. |
505 if (includeSMILProperties && state.element()->isSVGElement()) | 502 if (includeSMILProperties && state.element()->isSVGElement()) |
506 collector.addElementStyleProperties(toSVGElement(state.element())->a
nimatedSMILStyleProperties(), false /* isCacheable */); | 503 collector.addElementStyleProperties(toSVGElement(state.element())->a
nimatedSMILStyleProperties(), false /* isCacheable */); |
507 } | 504 } |
508 | 505 |
509 collector.finishAddingAuthorRulesForTreeScope(); | 506 collector.finishAddingAuthorRulesForTreeScope(); |
510 } | 507 } |
511 | 508 |
512 PassRefPtr<ComputedStyle> StyleResolver::styleForDocument(Document& document) | 509 PassRefPtr<ComputedStyle> StyleResolver::styleForDocument(Document& document) |
513 { | 510 { |
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 visitor->trace(m_watchedSelectorsRules); | 1537 visitor->trace(m_watchedSelectorsRules); |
1541 visitor->trace(m_treeBoundaryCrossingScopes); | 1538 visitor->trace(m_treeBoundaryCrossingScopes); |
1542 visitor->trace(m_styleResourceLoader); | 1539 visitor->trace(m_styleResourceLoader); |
1543 visitor->trace(m_styleSharingLists); | 1540 visitor->trace(m_styleSharingLists); |
1544 visitor->trace(m_pendingStyleSheets); | 1541 visitor->trace(m_pendingStyleSheets); |
1545 visitor->trace(m_document); | 1542 visitor->trace(m_document); |
1546 #endif | 1543 #endif |
1547 } | 1544 } |
1548 | 1545 |
1549 } // namespace blink | 1546 } // namespace blink |
OLD | NEW |