| OLD | NEW |
| 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.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
| 4 * Copyright (C) 2012 Google Inc. All rights reserved. | 4 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "sky/engine/core/css/StyleRule.h" | 32 #include "sky/engine/core/css/StyleRule.h" |
| 33 #include "sky/engine/core/css/StyleSheetContents.h" | 33 #include "sky/engine/core/css/StyleSheetContents.h" |
| 34 #include "sky/engine/core/css/resolver/StyleResolver.h" | 34 #include "sky/engine/core/css/resolver/StyleResolver.h" |
| 35 #include "sky/engine/core/dom/Document.h" | 35 #include "sky/engine/core/dom/Document.h" |
| 36 #include "sky/engine/core/dom/shadow/ElementShadow.h" | 36 #include "sky/engine/core/dom/shadow/ElementShadow.h" |
| 37 #include "sky/engine/core/dom/shadow/ShadowRoot.h" | 37 #include "sky/engine/core/dom/shadow/ShadowRoot.h" |
| 38 #include "sky/engine/core/html/HTMLStyleElement.h" | 38 #include "sky/engine/core/html/HTMLStyleElement.h" |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 TreeScope* ScopedStyleResolver::treeScopeFor(Document& document, const CSSStyleS
heet* sheet) | |
| 43 { | |
| 44 ASSERT(sheet); | |
| 45 | |
| 46 if (!sheet->ownerDocument()) | |
| 47 return 0; | |
| 48 | |
| 49 Node* ownerNode = sheet->ownerNode(); | |
| 50 if (!isHTMLStyleElement(ownerNode)) | |
| 51 return &document; | |
| 52 | |
| 53 HTMLStyleElement& styleElement = toHTMLStyleElement(*ownerNode); | |
| 54 if (styleElement.isInShadowTree()) | |
| 55 return styleElement.containingShadowRoot(); | |
| 56 return &document; | |
| 57 } | |
| 58 | |
| 59 void ScopedStyleResolver::addRulesFromSheet(CSSStyleSheet* cssSheet, const Media
QueryEvaluator& medium, StyleResolver* resolver) | 42 void ScopedStyleResolver::addRulesFromSheet(CSSStyleSheet* cssSheet, const Media
QueryEvaluator& medium, StyleResolver* resolver) |
| 60 { | 43 { |
| 61 m_authorStyleSheets.append(cssSheet); | 44 m_authorStyleSheets.append(cssSheet); |
| 62 unsigned index = m_authorStyleSheets.size() - 1; | 45 unsigned index = m_authorStyleSheets.size() - 1; |
| 63 StyleSheetContents* sheet = cssSheet->contents(); | 46 StyleSheetContents* sheet = cssSheet->contents(); |
| 64 | 47 |
| 65 AddRuleFlags addRuleFlags = RuleHasNoSpecialState; | 48 AddRuleFlags addRuleFlags = RuleHasNoSpecialState; |
| 66 const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags); | 49 const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags); |
| 67 resolver->addMediaQueryResults(ruleSet.viewportDependentMediaQueryResults())
; | 50 resolver->addMediaQueryResults(ruleSet.viewportDependentMediaQueryResults())
; |
| 68 resolver->processScopedRules(ruleSet, cssSheet, index, treeScope().rootNode(
)); | 51 resolver->processScopedRules(ruleSet, cssSheet, index, treeScope().rootNode(
)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 contextFlags |= SelectorChecker::ScopeContainsLastMatchedElement; | 100 contextFlags |= SelectorChecker::ScopeContainsLastMatchedElement; |
| 118 | 101 |
| 119 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange(); | 102 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange(); |
| 120 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { | 103 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { |
| 121 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet()
, includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], applyAuthorSt
yles, i); | 104 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet()
, includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], applyAuthorSt
yles, i); |
| 122 collector.collectMatchingRules(matchRequest, ruleRange, static_cast<Sele
ctorChecker::ContextFlags>(contextFlags), cascadeScope, cascadeOrder); | 105 collector.collectMatchingRules(matchRequest, ruleRange, static_cast<Sele
ctorChecker::ContextFlags>(contextFlags), cascadeScope, cascadeOrder); |
| 123 } | 106 } |
| 124 } | 107 } |
| 125 | 108 |
| 126 } // namespace blink | 109 } // namespace blink |
| OLD | NEW |