| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Rob Buis | 2 * Copyright (C) 2006, 2007 Rob Buis |
| 3 * Copyright (C) 2008 Apple, Inc. All rights reserved. | 3 * Copyright (C) 2008 Apple, Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #if !ENABLE(OILPAN) | 58 #if !ENABLE(OILPAN) |
| 59 if (m_sheet) | 59 if (m_sheet) |
| 60 clearSheet(); | 60 clearSheet(); |
| 61 #endif | 61 #endif |
| 62 } | 62 } |
| 63 | 63 |
| 64 StyleElement::ProcessingResult StyleElement::processStyleSheet(Document& documen
t, Element* element) | 64 StyleElement::ProcessingResult StyleElement::processStyleSheet(Document& documen
t, Element* element) |
| 65 { | 65 { |
| 66 TRACE_EVENT0("blink", "StyleElement::processStyleSheet"); | 66 TRACE_EVENT0("blink", "StyleElement::processStyleSheet"); |
| 67 ASSERT(element); | 67 ASSERT(element); |
| 68 ASSERT(element->inDocument()); | 68 ASSERT(element->inShadowIncludingDocument()); |
| 69 | 69 |
| 70 m_registeredAsCandidate = true; | 70 m_registeredAsCandidate = true; |
| 71 document.styleEngine().addStyleSheetCandidateNode(element); | 71 document.styleEngine().addStyleSheetCandidateNode(element); |
| 72 if (m_createdByParser) | 72 if (m_createdByParser) |
| 73 return ProcessingSuccessful; | 73 return ProcessingSuccessful; |
| 74 | 74 |
| 75 return process(element); | 75 return process(element); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void StyleElement::insertedInto(Element* element, ContainerNode* insertionPoint) | 78 void StyleElement::insertedInto(Element* element, ContainerNode* insertionPoint) |
| 79 { | 79 { |
| 80 if (!insertionPoint->inDocument() || !element->isInShadowTree()) | 80 if (!insertionPoint->inShadowIncludingDocument() || !element->isInShadowTree
()) |
| 81 return; | 81 return; |
| 82 if (ShadowRoot* scope = element->containingShadowRoot()) | 82 if (ShadowRoot* scope = element->containingShadowRoot()) |
| 83 scope->registerScopedHTMLStyleChild(); | 83 scope->registerScopedHTMLStyleChild(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void StyleElement::removedFrom(Element* element, ContainerNode* insertionPoint) | 86 void StyleElement::removedFrom(Element* element, ContainerNode* insertionPoint) |
| 87 { | 87 { |
| 88 if (!insertionPoint->inDocument()) | 88 if (!insertionPoint->inShadowIncludingDocument()) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 ShadowRoot* shadowRoot = element->containingShadowRoot(); | 91 ShadowRoot* shadowRoot = element->containingShadowRoot(); |
| 92 if (!shadowRoot) | 92 if (!shadowRoot) |
| 93 shadowRoot = insertionPoint->containingShadowRoot(); | 93 shadowRoot = insertionPoint->containingShadowRoot(); |
| 94 | 94 |
| 95 if (shadowRoot) | 95 if (shadowRoot) |
| 96 shadowRoot->unregisterScopedHTMLStyleChild(); | 96 shadowRoot->unregisterScopedHTMLStyleChild(); |
| 97 | 97 |
| 98 Document& document = element->document(); | 98 Document& document = element->document(); |
| 99 if (m_registeredAsCandidate) { | 99 if (m_registeredAsCandidate) { |
| 100 document.styleEngine().removeStyleSheetCandidateNode(element, shadowRoot
? *toTreeScope(shadowRoot) : toTreeScope(document)); | 100 document.styleEngine().removeStyleSheetCandidateNode(element, shadowRoot
? *toTreeScope(shadowRoot) : toTreeScope(document)); |
| 101 m_registeredAsCandidate = false; | 101 m_registeredAsCandidate = false; |
| 102 } | 102 } |
| 103 | 103 |
| 104 RawPtr<StyleSheet> removedSheet = m_sheet.get(); | 104 RawPtr<StyleSheet> removedSheet = m_sheet.get(); |
| 105 | 105 |
| 106 if (m_sheet) | 106 if (m_sheet) |
| 107 clearSheet(element); | 107 clearSheet(element); |
| 108 if (removedSheet) | 108 if (removedSheet) |
| 109 document.styleEngine().setNeedsActiveStyleUpdate(removedSheet.get(), Ana
lyzedStyleUpdate); | 109 document.styleEngine().setNeedsActiveStyleUpdate(removedSheet.get(), Ana
lyzedStyleUpdate); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void StyleElement::clearDocumentData(Document& document, Element* element) | 112 void StyleElement::clearDocumentData(Document& document, Element* element) |
| 113 { | 113 { |
| 114 if (m_sheet) | 114 if (m_sheet) |
| 115 m_sheet->clearOwnerNode(); | 115 m_sheet->clearOwnerNode(); |
| 116 | 116 |
| 117 if (m_registeredAsCandidate) { | 117 if (m_registeredAsCandidate) { |
| 118 ASSERT(element->inDocument()); | 118 ASSERT(element->inShadowIncludingDocument()); |
| 119 document.styleEngine().removeStyleSheetCandidateNode(element, element->t
reeScope()); | 119 document.styleEngine().removeStyleSheetCandidateNode(element, element->t
reeScope()); |
| 120 m_registeredAsCandidate = false; | 120 m_registeredAsCandidate = false; |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 StyleElement::ProcessingResult StyleElement::childrenChanged(Element* element) | 124 StyleElement::ProcessingResult StyleElement::childrenChanged(Element* element) |
| 125 { | 125 { |
| 126 ASSERT(element); | 126 ASSERT(element); |
| 127 if (m_createdByParser) | 127 if (m_createdByParser) |
| 128 return ProcessingSuccessful; | 128 return ProcessingSuccessful; |
| 129 | 129 |
| 130 return process(element); | 130 return process(element); |
| 131 } | 131 } |
| 132 | 132 |
| 133 StyleElement::ProcessingResult StyleElement::finishParsingChildren(Element* elem
ent) | 133 StyleElement::ProcessingResult StyleElement::finishParsingChildren(Element* elem
ent) |
| 134 { | 134 { |
| 135 ASSERT(element); | 135 ASSERT(element); |
| 136 ProcessingResult result = process(element); | 136 ProcessingResult result = process(element); |
| 137 m_createdByParser = false; | 137 m_createdByParser = false; |
| 138 return result; | 138 return result; |
| 139 } | 139 } |
| 140 | 140 |
| 141 StyleElement::ProcessingResult StyleElement::process(Element* element) | 141 StyleElement::ProcessingResult StyleElement::process(Element* element) |
| 142 { | 142 { |
| 143 if (!element || !element->inDocument()) | 143 if (!element || !element->inShadowIncludingDocument()) |
| 144 return ProcessingSuccessful; | 144 return ProcessingSuccessful; |
| 145 return createSheet(element, element->textFromChildren()); | 145 return createSheet(element, element->textFromChildren()); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void StyleElement::clearSheet(Element* ownerElement) | 148 void StyleElement::clearSheet(Element* ownerElement) |
| 149 { | 149 { |
| 150 ASSERT(m_sheet); | 150 ASSERT(m_sheet); |
| 151 | 151 |
| 152 if (ownerElement && m_sheet->isLoading()) | 152 if (ownerElement && m_sheet->isLoading()) |
| 153 ownerElement->document().styleEngine().removePendingSheet(ownerElement); | 153 ownerElement->document().styleEngine().removePendingSheet(ownerElement); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 166 ShadowRoot* root = element->containingShadowRoot(); | 166 ShadowRoot* root = element->containingShadowRoot(); |
| 167 if (root && root->type() == ShadowRootType::UserAgent) | 167 if (root && root->type() == ShadowRootType::UserAgent) |
| 168 return true; | 168 return true; |
| 169 | 169 |
| 170 return false; | 170 return false; |
| 171 } | 171 } |
| 172 | 172 |
| 173 StyleElement::ProcessingResult StyleElement::createSheet(Element* e, const Strin
g& text) | 173 StyleElement::ProcessingResult StyleElement::createSheet(Element* e, const Strin
g& text) |
| 174 { | 174 { |
| 175 ASSERT(e); | 175 ASSERT(e); |
| 176 ASSERT(e->inDocument()); | 176 ASSERT(e->inShadowIncludingDocument()); |
| 177 Document& document = e->document(); | 177 Document& document = e->document(); |
| 178 | 178 |
| 179 const ContentSecurityPolicy* csp = document.contentSecurityPolicy(); | 179 const ContentSecurityPolicy* csp = document.contentSecurityPolicy(); |
| 180 bool passesContentSecurityPolicyChecks = shouldBypassMainWorldCSP(e) | 180 bool passesContentSecurityPolicyChecks = shouldBypassMainWorldCSP(e) |
| 181 || csp->allowStyleWithHash(text) | 181 || csp->allowStyleWithHash(text) |
| 182 || csp->allowStyleWithNonce(e->fastGetAttribute(HTMLNames::nonceAttr)) | 182 || csp->allowStyleWithNonce(e->fastGetAttribute(HTMLNames::nonceAttr)) |
| 183 || csp->allowInlineStyle(e->document().url(), m_startPosition.m_line, te
xt); | 183 || csp->allowInlineStyle(e->document().url(), m_startPosition.m_line, te
xt); |
| 184 | 184 |
| 185 // Clearing the current sheet may remove the cache entry so create the new s
heet first | 185 // Clearing the current sheet may remove the cache entry so create the new s
heet first |
| 186 RawPtr<CSSStyleSheet> newSheet = nullptr; | 186 RawPtr<CSSStyleSheet> newSheet = nullptr; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 { | 231 { |
| 232 document.styleEngine().addPendingSheet(); | 232 document.styleEngine().addPendingSheet(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 DEFINE_TRACE(StyleElement) | 235 DEFINE_TRACE(StyleElement) |
| 236 { | 236 { |
| 237 visitor->trace(m_sheet); | 237 visitor->trace(m_sheet); |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace blink | 240 } // namespace blink |
| OLD | NEW |