| 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 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 9 * Copyright (C) 2013 Google Inc. All rights reserved. | 9 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 10 * | 10 * |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * You should have received a copy of the GNU Library General Public License | 21 * You should have received a copy of the GNU Library General Public License |
| 22 * along with this library; see the file COPYING.LIB. If not, write to | 22 * along with this library; see the file COPYING.LIB. If not, write to |
| 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 24 * Boston, MA 02110-1301, USA. | 24 * Boston, MA 02110-1301, USA. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "sky/engine/config.h" | 27 #include "sky/engine/config.h" |
| 28 #include "sky/engine/core/dom/StyleSheetCollection.h" | 28 #include "sky/engine/core/dom/StyleSheetCollection.h" |
| 29 | 29 |
| 30 #include "sky/engine/core/css/CSSStyleSheet.h" | 30 #include "sky/engine/core/css/CSSStyleSheet.h" |
| 31 #include "sky/engine/core/css/resolver/StyleResolver.h" |
| 32 #include "sky/engine/core/dom/Document.h" |
| 33 #include "sky/engine/core/dom/StyleEngine.h" |
| 34 #include "sky/engine/core/dom/shadow/ShadowRoot.h" |
| 35 #include "sky/engine/core/dom/TreeScope.h" |
| 36 #include "sky/engine/core/html/HTMLStyleElement.h" |
| 31 | 37 |
| 32 namespace blink { | 38 namespace blink { |
| 33 | 39 |
| 34 StyleSheetCollection::StyleSheetCollection() | 40 StyleSheetCollection::StyleSheetCollection(TreeScope& treeScope) |
| 41 : m_treeScope(treeScope) |
| 35 { | 42 { |
| 36 } | 43 } |
| 37 | 44 |
| 38 StyleSheetCollection::~StyleSheetCollection() | 45 StyleSheetCollection::~StyleSheetCollection() |
| 39 { | 46 { |
| 40 } | 47 } |
| 41 | 48 |
| 42 void StyleSheetCollection::swap(StyleSheetCollection& other) | 49 void StyleSheetCollection::addStyleSheetCandidateNode(Node* node, bool) |
| 43 { | 50 { |
| 44 m_activeAuthorStyleSheets.swap(other.m_activeAuthorStyleSheets); | 51 if (!node->inDocument()) |
| 52 return; |
| 53 |
| 54 // Until the <body> exists, we have no choice but to compare document positi
ons, |
| 55 // since styles outside of the body and head continue to be shunted into the
head |
| 56 // (and thus can shift to end up before dynamically added DOM content that i
s also |
| 57 // outside the body). |
| 58 m_styleSheetCandidateNodes.add(node); |
| 45 } | 59 } |
| 46 | 60 |
| 47 void StyleSheetCollection::appendActiveStyleSheets(const Vector<RefPtr<CSSStyleS
heet> >& sheets) | 61 void StyleSheetCollection::removeStyleSheetCandidateNode(Node* node, ContainerNo
de* scopingNode) |
| 48 { | 62 { |
| 49 m_activeAuthorStyleSheets.appendVector(sheets); | 63 m_styleSheetCandidateNodes.remove(node); |
| 50 } | 64 } |
| 51 | 65 |
| 52 void StyleSheetCollection::appendActiveStyleSheet(CSSStyleSheet* sheet) | 66 void StyleSheetCollection::collectStyleSheets(Vector<RefPtr<CSSStyleSheet>>& she
ets) |
| 53 { | 67 { |
| 54 m_activeAuthorStyleSheets.append(sheet); | 68 DocumentOrderedList::iterator begin = m_styleSheetCandidateNodes.begin(); |
| 69 DocumentOrderedList::iterator end = m_styleSheetCandidateNodes.end(); |
| 70 for (DocumentOrderedList::iterator it = begin; it != end; ++it) { |
| 71 Node* node = *it; |
| 72 if (!isHTMLStyleElement(*node)) |
| 73 continue; |
| 74 if (CSSStyleSheet* sheet = toHTMLStyleElement(node)->sheet()) |
| 75 sheets.append(sheet); |
| 76 } |
| 77 } |
| 78 |
| 79 void StyleSheetCollection::updateActiveStyleSheets(StyleEngine* engine) |
| 80 { |
| 81 Vector<RefPtr<CSSStyleSheet>> candidateSheets; |
| 82 collectStyleSheets(candidateSheets); |
| 83 |
| 84 Node& root = m_treeScope.rootNode(); |
| 85 |
| 86 // TODO(esprehn): Remove special casing for Document. |
| 87 if (root.isDocumentNode()) { |
| 88 engine->clearMasterResolver(); |
| 89 // FIMXE: The following depends on whether StyleRuleFontFace was modifie
d or not. |
| 90 // No need to always-clear font cache. |
| 91 engine->clearFontCache(); |
| 92 } else if (StyleResolver* styleResolver = engine->resolver()) { |
| 93 // We should not destroy StyleResolver when we find any stylesheet updat
e in a shadow tree. |
| 94 // In this case, we will reset rulesets created from style elements in t
he shadow tree. |
| 95 styleResolver->resetAuthorStyle(m_treeScope); |
| 96 styleResolver->removePendingAuthorStyleSheets(m_activeAuthorStyleSheets)
; |
| 97 styleResolver->lazyAppendAuthorStyleSheets(0, candidateSheets); |
| 98 } |
| 99 |
| 100 // TODO(esprehn): We should avoid subtree recalcs in sky when rules change |
| 101 // and only recalc specific tree scopes. |
| 102 root.setNeedsStyleRecalc(SubtreeStyleChange); |
| 103 |
| 104 // TODO(esprehn): We should use LocalStyleChange, :host rule changes |
| 105 // can only impact the host directly as Sky has no descendant selectors. |
| 106 if (root.isShadowRoot()) |
| 107 toShadowRoot(root).host()->setNeedsStyleRecalc(SubtreeStyleChange); |
| 108 |
| 109 m_activeAuthorStyleSheets.swap(candidateSheets); |
| 55 } | 110 } |
| 56 | 111 |
| 57 } | 112 } |
| OLD | NEW |