StyleSheetList.cpp [plain text]
#include "config.h"
#include "StyleSheetList.h"
#include "CSSStyleSheet.h"
namespace WebCore {
StyleSheetList::~StyleSheetList()
{
for (DeprecatedPtrListIterator<StyleSheet> it (styleSheets); it.current(); ++it)
it.current()->deref();
}
void StyleSheetList::add(StyleSheet* s)
{
if (!styleSheets.containsRef(s)) {
s->ref();
styleSheets.append(s);
}
}
void StyleSheetList::remove(StyleSheet* s)
{
if (styleSheets.removeRef(s))
s->deref();
}
unsigned StyleSheetList::length() const
{
unsigned l = 0;
DeprecatedPtrListIterator<StyleSheet> it(styleSheets);
for (; it.current(); ++it) {
if (!it.current()->isCSSStyleSheet() || !static_cast<CSSStyleSheet*>(it.current())->implicit())
l++;
}
return l;
}
StyleSheet *StyleSheetList::item (unsigned index)
{
unsigned l = 0;
DeprecatedPtrListIterator<StyleSheet> it(styleSheets);
for (; it.current(); ++it) {
if (!it.current()->isCSSStyleSheet() || !static_cast<CSSStyleSheet*>(it.current())->implicit()) {
if (l == index)
return it.current();
l++;
}
}
return 0;
}
}