| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 void StyleElement::process(Element* element) | 105 void StyleElement::process(Element* element) |
| 106 { | 106 { |
| 107 if (!element || !element->inDocument()) | 107 if (!element || !element->inDocument()) |
| 108 return; | 108 return; |
| 109 createSheet(element, element->textFromChildren()); | 109 createSheet(element, element->textFromChildren()); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void StyleElement::clearSheet() | 112 void StyleElement::clearSheet() |
| 113 { | 113 { |
| 114 ASSERT(m_sheet); | 114 ASSERT(m_sheet); |
| 115 |
| 115 m_sheet.release()->clearOwnerNode(); | 116 m_sheet.release()->clearOwnerNode(); |
| 116 } | 117 } |
| 117 | 118 |
| 118 void StyleElement::createSheet(Element* e, const String& text) | 119 void StyleElement::createSheet(Element* e, const String& text) |
| 119 { | 120 { |
| 120 ASSERT(e); | 121 ASSERT(e); |
| 121 ASSERT(e->inDocument()); | 122 ASSERT(e->inDocument()); |
| 122 Document& document = e->document(); | 123 Document& document = e->document(); |
| 123 if (m_sheet) { | 124 if (m_sheet) { |
| 124 if (m_sheet->isLoading()) | 125 if (m_sheet->isLoading()) |
| 125 document.styleEngine()->removePendingSheet(e); | 126 document.styleEngine()->removePendingSheet(e); |
| 126 clearSheet(); | 127 clearSheet(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 // If type is empty or CSS, this is a CSS style sheet. | 130 // If type is empty or CSS, this is a CSS style sheet. |
| 130 const AtomicString& type = this->type(); | 131 const AtomicString& type = this->type(); |
| 131 bool passesContentSecurityPolicyChecks = document.contentSecurityPolicy()->a
llowStyleNonce(e->fastGetAttribute(HTMLNames::nonceAttr)) || document.contentSec
urityPolicy()->allowInlineStyle(e->document().url(), m_startPosition.m_line); | 132 bool passesContentSecurityPolicyChecks = document.contentSecurityPolicy()->a
llowStyleNonce(e->fastGetAttribute(HTMLNames::nonceAttr)) || document.contentSec
urityPolicy()->allowInlineStyle(e->document().url(), m_startPosition.m_line); |
| 132 if (isCSS(e, type) && passesContentSecurityPolicyChecks) { | 133 if (isCSS(e, type) && passesContentSecurityPolicyChecks) { |
| 133 RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(media()); | 134 RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(media()); |
| 134 | 135 |
| 135 MediaQueryEvaluator screenEval("screen", true); | 136 MediaQueryEvaluator screenEval("screen", true); |
| 136 MediaQueryEvaluator printEval("print", true); | 137 MediaQueryEvaluator printEval("print", true); |
| 137 if (screenEval.eval(mediaQueries.get()) || printEval.eval(mediaQueries.g
et())) { | 138 if (screenEval.eval(mediaQueries.get()) || printEval.eval(mediaQueries.g
et())) { |
| 138 document.styleEngine()->addPendingSheet(); | |
| 139 m_loading = true; | 139 m_loading = true; |
| 140 | |
| 141 TextPosition startPosition = m_startPosition == TextPosition::belowR
angePosition() ? TextPosition::minimumPosition() : m_startPosition; | 140 TextPosition startPosition = m_startPosition == TextPosition::belowR
angePosition() ? TextPosition::minimumPosition() : m_startPosition; |
| 142 m_sheet = CSSStyleSheet::createInline(e, KURL(), startPosition, docu
ment.inputEncoding()); | 141 m_sheet = StyleEngine::createSheet(e, text, startPosition, m_created
ByParser); |
| 143 m_sheet->setMediaQueries(mediaQueries.release()); | 142 m_sheet->setMediaQueries(mediaQueries.release()); |
| 144 m_sheet->setTitle(e->title()); | |
| 145 m_sheet->contents()->parseStringAtPosition(text, startPosition, m_cr
eatedByParser); | |
| 146 | |
| 147 m_loading = false; | 143 m_loading = false; |
| 148 } | 144 } |
| 149 } | 145 } |
| 150 | 146 |
| 151 if (m_sheet) | 147 if (m_sheet) |
| 152 m_sheet->contents()->checkLoaded(); | 148 m_sheet->contents()->checkLoaded(); |
| 153 } | 149 } |
| 154 | 150 |
| 155 bool StyleElement::isLoading() const | 151 bool StyleElement::isLoading() const |
| 156 { | 152 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 167 document.styleEngine()->removePendingSheet(m_sheet->ownerNode()); | 163 document.styleEngine()->removePendingSheet(m_sheet->ownerNode()); |
| 168 return true; | 164 return true; |
| 169 } | 165 } |
| 170 | 166 |
| 171 void StyleElement::startLoadingDynamicSheet(Document& document) | 167 void StyleElement::startLoadingDynamicSheet(Document& document) |
| 172 { | 168 { |
| 173 document.styleEngine()->addPendingSheet(); | 169 document.styleEngine()->addPendingSheet(); |
| 174 } | 170 } |
| 175 | 171 |
| 176 } | 172 } |
| OLD | NEW |