This source file includes following definitions.
- m_customPseudoInvalid
- combine
- ensureClassSet
- ensureIdSet
- ensureTagNameSet
- ensureAttributeSet
- addClass
- addId
- addTagName
- addAttribute
- getClasses
- getAttributes
- getIds
- getTagNames
- setWholeSubtreeInvalid
#include "config.h"
#include "core/css/invalidation/DescendantInvalidationSet.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/Element.h"
namespace WebCore {
DescendantInvalidationSet::DescendantInvalidationSet()
: m_allDescendantsMightBeInvalid(false)
, m_customPseudoInvalid(false)
{
}
void DescendantInvalidationSet::combine(const DescendantInvalidationSet& other)
{
if (wholeSubtreeInvalid())
return;
if (other.wholeSubtreeInvalid()) {
setWholeSubtreeInvalid();
return;
}
if (other.customPseudoInvalid())
setCustomPseudoInvalid();
if (other.m_classes) {
HashSet<AtomicString>::const_iterator end = other.m_classes->end();
for (HashSet<AtomicString>::const_iterator it = other.m_classes->begin(); it != end; ++it)
addClass(*it);
}
if (other.m_ids) {
HashSet<AtomicString>::const_iterator end = other.m_ids->end();
for (HashSet<AtomicString>::const_iterator it = other.m_ids->begin(); it != end; ++it)
addId(*it);
}
if (other.m_tagNames) {
HashSet<AtomicString>::const_iterator end = other.m_tagNames->end();
for (HashSet<AtomicString>::const_iterator it = other.m_tagNames->begin(); it != end; ++it)
addTagName(*it);
}
if (other.m_attributes) {
HashSet<AtomicString>::const_iterator end = other.m_attributes->end();
for (HashSet<AtomicString>::const_iterator it = other.m_attributes->begin(); it != end; ++it)
addAttribute(*it);
}
}
HashSet<AtomicString>& DescendantInvalidationSet::ensureClassSet()
{
if (!m_classes)
m_classes = adoptPtr(new HashSet<AtomicString>);
return *m_classes;
}
HashSet<AtomicString>& DescendantInvalidationSet::ensureIdSet()
{
if (!m_ids)
m_ids = adoptPtr(new HashSet<AtomicString>);
return *m_ids;
}
HashSet<AtomicString>& DescendantInvalidationSet::ensureTagNameSet()
{
if (!m_tagNames)
m_tagNames = adoptPtr(new HashSet<AtomicString>);
return *m_tagNames;
}
HashSet<AtomicString>& DescendantInvalidationSet::ensureAttributeSet()
{
if (!m_attributes)
m_attributes = adoptPtr(new HashSet<AtomicString>);
return *m_attributes;
}
void DescendantInvalidationSet::addClass(const AtomicString& className)
{
if (wholeSubtreeInvalid())
return;
ensureClassSet().add(className);
}
void DescendantInvalidationSet::addId(const AtomicString& id)
{
if (wholeSubtreeInvalid())
return;
ensureIdSet().add(id);
}
void DescendantInvalidationSet::addTagName(const AtomicString& tagName)
{
if (wholeSubtreeInvalid())
return;
ensureTagNameSet().add(tagName);
}
void DescendantInvalidationSet::addAttribute(const AtomicString& attribute)
{
if (wholeSubtreeInvalid())
return;
ensureAttributeSet().add(attribute);
}
void DescendantInvalidationSet::getClasses(Vector<AtomicString>& classes) const
{
if (!m_classes)
return;
for (HashSet<AtomicString>::const_iterator it = m_classes->begin(); it != m_classes->end(); ++it)
classes.append(*it);
}
void DescendantInvalidationSet::getAttributes(Vector<AtomicString>& attributes) const
{
if (!m_attributes)
return;
for (HashSet<AtomicString>::const_iterator it = m_attributes->begin(); it != m_attributes->end(); ++it)
attributes.append(*it);
}
void DescendantInvalidationSet::getIds(Vector<AtomicString>& ids) const
{
if (!m_ids)
return;
for (HashSet<AtomicString>::const_iterator it = m_ids->begin(); it != m_ids->end(); ++it)
ids.append(*it);
}
void DescendantInvalidationSet::getTagNames(Vector<AtomicString>& tagNames) const
{
if (!m_tagNames)
return;
for (HashSet<AtomicString>::const_iterator it = m_tagNames->begin(); it != m_tagNames->end(); ++it)
tagNames.append(*it);
}
void DescendantInvalidationSet::setWholeSubtreeInvalid()
{
if (m_allDescendantsMightBeInvalid)
return;
m_allDescendantsMightBeInvalid = true;
m_classes = nullptr;
m_ids = nullptr;
m_tagNames = nullptr;
m_attributes = nullptr;
}
}