Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: sky/engine/core/dom/StyleSheetCollection.cpp

Issue 844133002: Simplify tree scope tracking in StyleEngine. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/dom/StyleSheetCollection.h ('k') | sky/engine/core/dom/shadow/ShadowRoot.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 28 matching lines...) Expand all
39 39
40 StyleSheetCollection::StyleSheetCollection(TreeScope& treeScope) 40 StyleSheetCollection::StyleSheetCollection(TreeScope& treeScope)
41 : m_treeScope(treeScope) 41 : m_treeScope(treeScope)
42 { 42 {
43 } 43 }
44 44
45 StyleSheetCollection::~StyleSheetCollection() 45 StyleSheetCollection::~StyleSheetCollection()
46 { 46 {
47 } 47 }
48 48
49 void StyleSheetCollection::addStyleSheetCandidateNode(Node* node, bool) 49 void StyleSheetCollection::addStyleSheetCandidateNode(HTMLStyleElement& element)
50 { 50 {
51 if (!node->inDocument()) 51 ASSERT(element.inActiveDocument());
52 return; 52 m_styleSheetCandidateNodes.add(&element);
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);
59 } 53 }
60 54
61 void StyleSheetCollection::removeStyleSheetCandidateNode(Node* node, ContainerNo de* scopingNode) 55 void StyleSheetCollection::removeStyleSheetCandidateNode(HTMLStyleElement& eleme nt)
62 { 56 {
63 m_styleSheetCandidateNodes.remove(node); 57 m_styleSheetCandidateNodes.remove(&element);
64 } 58 }
65 59
66 void StyleSheetCollection::collectStyleSheets(Vector<RefPtr<CSSStyleSheet>>& she ets) 60 void StyleSheetCollection::collectStyleSheets(Vector<RefPtr<CSSStyleSheet>>& she ets)
67 { 61 {
68 DocumentOrderedList::iterator begin = m_styleSheetCandidateNodes.begin(); 62 for (Node* node : m_styleSheetCandidateNodes) {
69 DocumentOrderedList::iterator end = m_styleSheetCandidateNodes.end(); 63 ASSERT(isHTMLStyleElement(*node));
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()) 64 if (CSSStyleSheet* sheet = toHTMLStyleElement(node)->sheet())
75 sheets.append(sheet); 65 sheets.append(sheet);
76 } 66 }
77 } 67 }
78 68
79 void StyleSheetCollection::updateActiveStyleSheets(StyleEngine* engine) 69 void StyleSheetCollection::updateActiveStyleSheets(StyleEngine* engine)
80 { 70 {
81 Vector<RefPtr<CSSStyleSheet>> candidateSheets; 71 Vector<RefPtr<CSSStyleSheet>> candidateSheets;
82 collectStyleSheets(candidateSheets); 72 collectStyleSheets(candidateSheets);
83 73
(...skipping 19 matching lines...) Expand all
103 93
104 // TODO(esprehn): We should use LocalStyleChange, :host rule changes 94 // TODO(esprehn): We should use LocalStyleChange, :host rule changes
105 // can only impact the host directly as Sky has no descendant selectors. 95 // can only impact the host directly as Sky has no descendant selectors.
106 if (root.isShadowRoot()) 96 if (root.isShadowRoot())
107 toShadowRoot(root).host()->setNeedsStyleRecalc(SubtreeStyleChange); 97 toShadowRoot(root).host()->setNeedsStyleRecalc(SubtreeStyleChange);
108 98
109 m_activeAuthorStyleSheets.swap(candidateSheets); 99 m_activeAuthorStyleSheets.swap(candidateSheets);
110 } 100 }
111 101
112 } 102 }
OLDNEW
« no previous file with comments | « sky/engine/core/dom/StyleSheetCollection.h ('k') | sky/engine/core/dom/shadow/ShadowRoot.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698