This source file includes following definitions.
- styleSheets
- detachFromDocument
- length
- item
- getNamedItem
- anonymousNamedGetter
- trace
#include "config.h"
#include "core/css/StyleSheetList.h"
#include "HTMLNames.h"
#include "core/dom/Document.h"
#include "core/dom/StyleEngine.h"
#include "core/html/HTMLStyleElement.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
using namespace HTMLNames;
StyleSheetList::StyleSheetList(TreeScope* treeScope)
: m_treeScope(treeScope)
{
}
StyleSheetList::~StyleSheetList()
{
}
inline const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >& StyleSheetList::styleSheets()
{
if (!m_treeScope)
return m_detachedStyleSheets;
return document()->styleEngine()->styleSheetsForStyleSheetList(*m_treeScope);
}
void StyleSheetList::detachFromDocument()
{
m_detachedStyleSheets = document()->styleEngine()->styleSheetsForStyleSheetList(*m_treeScope);
m_treeScope = 0;
}
unsigned StyleSheetList::length()
{
return styleSheets().size();
}
StyleSheet* StyleSheetList::item(unsigned index)
{
const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >& sheets = styleSheets();
return index < sheets.size() ? sheets[index].get() : 0;
}
HTMLStyleElement* StyleSheetList::getNamedItem(const AtomicString& name) const
{
if (!m_treeScope)
return 0;
Element* element = m_treeScope->getElementById(name);
return isHTMLStyleElement(element) ? toHTMLStyleElement(element) : 0;
}
CSSStyleSheet* StyleSheetList::anonymousNamedGetter(const AtomicString& name)
{
HTMLStyleElement* item = getNamedItem(name);
if (!item)
return 0;
return item->sheet();
}
void StyleSheetList::trace(Visitor* visitor)
{
visitor->trace(m_detachedStyleSheets);
}
}