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