| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2010 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2010 Apple Inc. All rights reserved. |
| 6 * (C) 2007 Rob Buis (buis@kde.org) | 6 * (C) 2007 Rob Buis (buis@kde.org) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "sky/engine/core/dom/Element.h" | 31 #include "sky/engine/core/dom/Element.h" |
| 32 #include "sky/engine/core/dom/StyleEngine.h" | 32 #include "sky/engine/core/dom/StyleEngine.h" |
| 33 #include "sky/engine/core/dom/shadow/ShadowRoot.h" | 33 #include "sky/engine/core/dom/shadow/ShadowRoot.h" |
| 34 #include "sky/engine/core/frame/LocalFrame.h" | 34 #include "sky/engine/core/frame/LocalFrame.h" |
| 35 #include "sky/engine/platform/TraceEvent.h" | 35 #include "sky/engine/platform/TraceEvent.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 inline HTMLStyleElement::HTMLStyleElement(Document& document) | 39 inline HTMLStyleElement::HTMLStyleElement(Document& document) |
| 40 : HTMLElement(HTMLNames::styleTag, document) | 40 : HTMLElement(HTMLNames::styleTag, document) |
| 41 , m_loading(false) | |
| 42 , m_registeredAsCandidate(false) | |
| 43 { | 41 { |
| 44 } | 42 } |
| 45 | 43 |
| 46 HTMLStyleElement::~HTMLStyleElement() | 44 HTMLStyleElement::~HTMLStyleElement() |
| 47 { | 45 { |
| 48 clearDocumentData(); | 46 clearDocumentData(); |
| 49 if (m_sheet) | 47 if (m_sheet) |
| 50 clearSheet(); | 48 clearSheet(); |
| 51 } | 49 } |
| 52 | 50 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 82 if (!insertionPoint->inDocument()) | 80 if (!insertionPoint->inDocument()) |
| 83 return; | 81 return; |
| 84 | 82 |
| 85 ShadowRoot* scopingNode = containingShadowRoot(); | 83 ShadowRoot* scopingNode = containingShadowRoot(); |
| 86 if (!scopingNode) | 84 if (!scopingNode) |
| 87 scopingNode = insertionPoint->containingShadowRoot(); | 85 scopingNode = insertionPoint->containingShadowRoot(); |
| 88 | 86 |
| 89 TreeScope* containingScope = containingShadowRoot(); | 87 TreeScope* containingScope = containingShadowRoot(); |
| 90 TreeScope& scope = containingScope ? *containingScope : insertionPoint->tree
Scope(); | 88 TreeScope& scope = containingScope ? *containingScope : insertionPoint->tree
Scope(); |
| 91 | 89 |
| 92 if (m_registeredAsCandidate) { | 90 document().styleEngine()->removeStyleSheetCandidateNode(this, scopingNode, s
cope); |
| 93 document().styleEngine()->removeStyleSheetCandidateNode(this, scopingNod
e, scope); | |
| 94 m_registeredAsCandidate = false; | |
| 95 } | |
| 96 | 91 |
| 97 RefPtr<CSSStyleSheet> removedSheet = m_sheet.get(); | 92 RefPtr<CSSStyleSheet> removedSheet = m_sheet.get(); |
| 98 | 93 |
| 99 if (m_sheet) | 94 if (m_sheet) |
| 100 clearSheet(); | 95 clearSheet(); |
| 101 if (removedSheet) | 96 if (removedSheet) |
| 102 document().removedStyleSheet(removedSheet.get()); | 97 document().removedStyleSheet(removedSheet.get()); |
| 103 } | 98 } |
| 104 | 99 |
| 105 void HTMLStyleElement::childrenChanged(const ChildrenChange& change) | 100 void HTMLStyleElement::childrenChanged(const ChildrenChange& change) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 ASSERT(inDocument()); | 137 ASSERT(inDocument()); |
| 143 | 138 |
| 144 if (m_sheet) | 139 if (m_sheet) |
| 145 clearSheet(); | 140 clearSheet(); |
| 146 | 141 |
| 147 RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(media()); | 142 RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(media()); |
| 148 | 143 |
| 149 MediaQueryEvaluator screenEval("screen", true); | 144 MediaQueryEvaluator screenEval("screen", true); |
| 150 MediaQueryEvaluator printEval("print", true); | 145 MediaQueryEvaluator printEval("print", true); |
| 151 if (screenEval.eval(mediaQueries.get()) || printEval.eval(mediaQueries.get()
)) { | 146 if (screenEval.eval(mediaQueries.get()) || printEval.eval(mediaQueries.get()
)) { |
| 152 m_loading = true; | |
| 153 const String& text = textFromChildren(); | 147 const String& text = textFromChildren(); |
| 154 m_sheet = document().styleEngine()->createSheet(this, text); | 148 m_sheet = document().styleEngine()->createSheet(this, text); |
| 155 m_sheet->setMediaQueries(mediaQueries.release()); | 149 m_sheet->setMediaQueries(mediaQueries.release()); |
| 156 m_loading = false; | |
| 157 } | 150 } |
| 158 | 151 |
| 159 document().styleResolverChanged(); | 152 document().styleResolverChanged(); |
| 160 } | 153 } |
| 161 | 154 |
| 162 void HTMLStyleElement::clearDocumentData() | 155 void HTMLStyleElement::clearDocumentData() |
| 163 { | 156 { |
| 164 if (m_sheet) | 157 if (m_sheet) |
| 165 m_sheet->clearOwnerNode(); | 158 m_sheet->clearOwnerNode(); |
| 166 | 159 |
| 167 if (inDocument()) { | 160 if (inDocument()) { |
| 168 ContainerNode* scopingNode = this->scopingNode(); | 161 ContainerNode* scopingNode = this->scopingNode(); |
| 169 TreeScope& scope = scopingNode ? scopingNode->treeScope() : treeScope(); | 162 TreeScope& scope = scopingNode ? scopingNode->treeScope() : treeScope(); |
| 170 document().styleEngine()->removeStyleSheetCandidateNode(this, scopingNod
e, scope); | 163 document().styleEngine()->removeStyleSheetCandidateNode(this, scopingNod
e, scope); |
| 171 } | 164 } |
| 172 } | 165 } |
| 173 | 166 |
| 174 void HTMLStyleElement::processStyleSheet() | 167 void HTMLStyleElement::processStyleSheet() |
| 175 { | 168 { |
| 176 TRACE_EVENT0("blink", "StyleElement::processStyleSheet"); | 169 TRACE_EVENT0("blink", "StyleElement::processStyleSheet"); |
| 177 | 170 |
| 178 ASSERT(inDocument()); | 171 ASSERT(inDocument()); |
| 179 | 172 |
| 180 m_registeredAsCandidate = true; | |
| 181 document().styleEngine()->addStyleSheetCandidateNode(this, false); | 173 document().styleEngine()->addStyleSheetCandidateNode(this, false); |
| 182 process(); | 174 process(); |
| 183 } | 175 } |
| 184 | 176 |
| 185 } | 177 } |
| OLD | NEW |