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

Side by Side Diff: sky/engine/core/css/StyleSheetList.cpp

Issue 803673003: Delete StyleSheetList and support code. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
OLDNEW
(Empty)
1 /**
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 #include "sky/engine/config.h"
22 #include "sky/engine/core/css/StyleSheetList.h"
23
24 #include "sky/engine/core/dom/Document.h"
25 #include "sky/engine/core/dom/StyleEngine.h"
26 #include "sky/engine/core/html/HTMLStyleElement.h"
27 #include "sky/engine/wtf/text/WTFString.h"
28
29 namespace blink {
30
31 StyleSheetList::StyleSheetList(TreeScope* treeScope)
32 : m_treeScope(treeScope)
33 {
34 }
35
36 StyleSheetList::~StyleSheetList()
37 {
38 }
39
40 inline const Vector<RefPtr<CSSStyleSheet> >& StyleSheetList::styleSheets()
41 {
42 #if !ENABLE(OILPAN)
43 if (!m_treeScope)
44 return m_detachedStyleSheets;
45 #endif
46 return document()->styleEngine()->styleSheetsForStyleSheetList(*m_treeScope) ;
47 }
48
49 void StyleSheetList::detachFromDocument()
50 {
51 m_detachedStyleSheets = document()->styleEngine()->styleSheetsForStyleSheetL ist(*m_treeScope);
52 m_treeScope = nullptr;
53 }
54
55 unsigned StyleSheetList::length()
56 {
57 return styleSheets().size();
58 }
59
60 CSSStyleSheet* StyleSheetList::item(unsigned index)
61 {
62 const Vector<RefPtr<CSSStyleSheet> >& sheets = styleSheets();
63 return index < sheets.size() ? sheets[index].get() : 0;
64 }
65
66 HTMLStyleElement* StyleSheetList::getNamedItem(const AtomicString& name) const
67 {
68 #if !ENABLE(OILPAN)
69 if (!m_treeScope)
70 return 0;
71 #endif
72
73 // IE also supports retrieving a stylesheet by name, using the name/id of th e <style> tag
74 // (this is consistent with all the other collections)
75 // ### Bad implementation because returns a single element (are IDs always u nique?)
76 // and doesn't look for name attribute.
77 // But unicity of stylesheet ids is good practice anyway ;)
78 // FIXME: We should figure out if we should change this or fix the spec.
79 Element* element = m_treeScope->getElementById(name);
80 return isHTMLStyleElement(element) ? toHTMLStyleElement(element) : 0;
81 }
82
83 CSSStyleSheet* StyleSheetList::anonymousNamedGetter(const AtomicString& name)
84 {
85 HTMLStyleElement* item = getNamedItem(name);
86 if (!item)
87 return 0;
88 return item->sheet();
89 }
90
91 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698