2009-08-01 08:53:40 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-08-01 08:53:40 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* data structures passed to nsIStyleRuleProcessor methods (to pull loop
|
|
|
|
* invariant computations out of the loop)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsRuleProcessorData_h_
|
|
|
|
#define nsRuleProcessorData_h_
|
|
|
|
|
2011-09-06 17:20:35 -07:00
|
|
|
#include "nsPresContext.h" // for nsCompatibility
|
2009-08-01 08:53:40 -07:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsChangeHint.h"
|
|
|
|
#include "nsIContent.h"
|
2009-12-10 23:37:40 -08:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2010-04-02 18:58:27 -07:00
|
|
|
#include "nsRuleWalker.h"
|
2011-03-29 10:29:21 -07:00
|
|
|
#include "nsNthIndexCache.h"
|
2012-03-29 23:16:22 -07:00
|
|
|
#include "nsILoadContext.h"
|
2012-03-12 20:54:15 -07:00
|
|
|
#include "mozilla/BloomFilter.h"
|
|
|
|
#include "mozilla/GuardObjects.h"
|
2009-08-01 08:53:40 -07:00
|
|
|
|
|
|
|
class nsIStyleSheet;
|
|
|
|
class nsIAtom;
|
|
|
|
class nsICSSPseudoComparator;
|
|
|
|
class nsAttrValue;
|
2013-01-08 15:25:48 -08:00
|
|
|
struct TreeMatchContext;
|
2009-08-01 08:53:40 -07:00
|
|
|
|
2012-03-12 20:54:15 -07:00
|
|
|
/**
|
|
|
|
* An AncestorFilter is used to keep track of ancestors so that we can
|
|
|
|
* quickly tell that a particular selector is not relevant to a given
|
|
|
|
* element.
|
|
|
|
*/
|
|
|
|
class NS_STACK_CLASS AncestorFilter {
|
2013-01-08 15:25:48 -08:00
|
|
|
friend struct TreeMatchContext;
|
2012-03-12 20:54:15 -07:00
|
|
|
public:
|
|
|
|
/* Maintenance of our ancestor state */
|
|
|
|
void PushAncestor(mozilla::dom::Element *aElement);
|
|
|
|
void PopAncestor();
|
|
|
|
|
|
|
|
/* Check whether we might have an ancestor matching one of the given
|
|
|
|
atom hashes. |hashes| must have length hashListLength */
|
|
|
|
template<size_t hashListLength>
|
|
|
|
bool MightHaveMatchingAncestor(const uint32_t* aHashes) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mFilter);
|
|
|
|
for (size_t i = 0; i < hashListLength && aHashes[i]; ++i) {
|
|
|
|
if (!mFilter->mightContain(aHashes[i])) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HasFilter() const { return mFilter; }
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void AssertHasAllAncestors(mozilla::dom::Element *aElement) const;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Using 2^12 slots makes the Bloom filter a nice round page in
|
|
|
|
// size, so let's do that. We get a false positive rate of 1% or
|
|
|
|
// less even with several hundred things in the filter. Note that
|
|
|
|
// we allocate the filter lazily, because not all tree match
|
|
|
|
// contexts can use one effectively.
|
|
|
|
typedef mozilla::BloomFilter<12, nsIAtom> Filter;
|
|
|
|
nsAutoPtr<Filter> mFilter;
|
|
|
|
|
|
|
|
// Stack of indices to pop to. These are indices into mHashes.
|
2012-08-22 08:56:38 -07:00
|
|
|
nsTArray<uint32_t> mPopTargets;
|
2012-03-12 20:54:15 -07:00
|
|
|
|
|
|
|
// List of hashes; this is what we pop using mPopTargets. We store
|
|
|
|
// hashes of our ancestor element tag names, ids, and classes in
|
|
|
|
// here.
|
|
|
|
nsTArray<uint32_t> mHashes;
|
|
|
|
|
|
|
|
// A debug-only stack of Elements for use in assertions
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsTArray<mozilla::dom::Element*> mElements;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2011-03-29 10:29:20 -07:00
|
|
|
/**
|
|
|
|
* A |TreeMatchContext| has data about a matching operation. The
|
|
|
|
* data are not node-specific but are invariants of the DOM tree the
|
|
|
|
* nodes being matched against are in.
|
|
|
|
*
|
|
|
|
* Most of the members are in parameters to selector matching. The
|
|
|
|
* one out parameter is mHaveRelevantLink. Consumers that use a
|
2011-03-29 10:29:21 -07:00
|
|
|
* TreeMatchContext for more than one matching operation and care
|
|
|
|
* about :visited and mHaveRelevantLink need to
|
|
|
|
* ResetForVisitedMatching() and ResetForUnvisitedMatching() as
|
|
|
|
* needed.
|
2011-03-29 10:29:20 -07:00
|
|
|
*/
|
2011-03-29 10:29:21 -07:00
|
|
|
struct NS_STACK_CLASS TreeMatchContext {
|
2011-03-29 10:29:21 -07:00
|
|
|
// Reset this context for matching for the style-if-:visited.
|
|
|
|
void ResetForVisitedMatching() {
|
|
|
|
NS_PRECONDITION(mForStyling, "Why is this being called?");
|
2011-10-17 07:59:28 -07:00
|
|
|
mHaveRelevantLink = false;
|
2011-03-29 10:29:21 -07:00
|
|
|
mVisitedHandling = nsRuleWalker::eRelevantLinkVisited;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResetForUnvisitedMatching() {
|
|
|
|
NS_PRECONDITION(mForStyling, "Why is this being called?");
|
2011-10-17 07:59:28 -07:00
|
|
|
mHaveRelevantLink = false;
|
2011-03-29 10:29:21 -07:00
|
|
|
mVisitedHandling = nsRuleWalker::eRelevantLinkUnvisited;
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
void SetHaveRelevantLink() { mHaveRelevantLink = true; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HaveRelevantLink() const { return mHaveRelevantLink; }
|
2011-03-29 10:29:21 -07:00
|
|
|
|
|
|
|
nsRuleWalker::VisitedHandlingType VisitedHandling() const
|
|
|
|
{
|
|
|
|
return mVisitedHandling;
|
|
|
|
}
|
|
|
|
|
2012-12-04 20:15:47 -08:00
|
|
|
void AddScopeElement(mozilla::dom::Element* aElement) {
|
|
|
|
NS_PRECONDITION(mHaveSpecifiedScope,
|
|
|
|
"Should be set before calling AddScopeElement()");
|
|
|
|
mScopes.AppendElement(aElement);
|
|
|
|
}
|
|
|
|
bool IsScopeElement(mozilla::dom::Element* aElement) const {
|
|
|
|
return mScopes.Contains(aElement);
|
|
|
|
}
|
|
|
|
void SetHasSpecifiedScope() {
|
|
|
|
mHaveSpecifiedScope = true;
|
|
|
|
}
|
|
|
|
bool HasSpecifiedScope() const {
|
|
|
|
return mHaveSpecifiedScope;
|
|
|
|
}
|
|
|
|
|
2013-01-08 15:25:48 -08:00
|
|
|
/**
|
|
|
|
* Initialize the ancestor filter and list of style scopes. If aElement is
|
|
|
|
* not null, it and all its ancestors will be passed to
|
|
|
|
* mAncestorFilter.PushAncestor and PushStyleScope, starting from the root and
|
|
|
|
* going down the tree.
|
|
|
|
*/
|
|
|
|
void InitAncestors(mozilla::dom::Element *aElement);
|
|
|
|
|
|
|
|
void PushStyleScope(mozilla::dom::Element* aElement)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aElement, "aElement must not be null");
|
|
|
|
if (aElement->IsScopedStyleRoot()) {
|
|
|
|
mStyleScopes.AppendElement(aElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PopStyleScope(mozilla::dom::Element* aElement)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aElement, "aElement must not be null");
|
|
|
|
if (mStyleScopes.SafeLastElement(nullptr) == aElement) {
|
|
|
|
mStyleScopes.TruncateLength(mStyleScopes.Length() - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-08 00:09:23 -08:00
|
|
|
// Is this matching operation for the creation of a style context?
|
|
|
|
// (If it is, we need to set slow selector bits on nodes indicating
|
|
|
|
// that certain restyling needs to happen.)
|
|
|
|
const bool mForStyling;
|
|
|
|
|
2013-01-08 15:25:48 -08:00
|
|
|
/* Helper class for maintaining the ancestor state */
|
|
|
|
class NS_STACK_CLASS AutoAncestorPusher {
|
|
|
|
public:
|
|
|
|
AutoAncestorPusher(bool aDoPush,
|
|
|
|
TreeMatchContext &aTreeMatchContext,
|
|
|
|
mozilla::dom::Element *aElement
|
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
|
|
|
: mPushed(aDoPush && aElement),
|
|
|
|
mTreeMatchContext(aTreeMatchContext),
|
|
|
|
mElement(aElement)
|
|
|
|
{
|
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
|
|
|
if (mPushed) {
|
|
|
|
mTreeMatchContext.mAncestorFilter.PushAncestor(aElement);
|
|
|
|
mTreeMatchContext.PushStyleScope(aElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
~AutoAncestorPusher() {
|
|
|
|
if (mPushed) {
|
|
|
|
mTreeMatchContext.mAncestorFilter.PopAncestor();
|
|
|
|
mTreeMatchContext.PopStyleScope(mElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool mPushed;
|
|
|
|
TreeMatchContext& mTreeMatchContext;
|
|
|
|
mozilla::dom::Element* mElement;
|
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
|
|
|
};
|
|
|
|
|
2011-03-29 10:29:21 -07:00
|
|
|
private:
|
|
|
|
// When mVisitedHandling is eRelevantLinkUnvisited, this is set to true if a
|
|
|
|
// relevant link (see explanation in definition of VisitedHandling enum) was
|
|
|
|
// encountered during the matching process, which means that matching needs
|
|
|
|
// to be rerun with eRelevantLinkVisited. Otherwise, its behavior is
|
|
|
|
// undefined (it might get set appropriately, or might not).
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mHaveRelevantLink;
|
2011-03-29 10:29:20 -07:00
|
|
|
|
2012-12-04 20:15:47 -08:00
|
|
|
// If true, then our contextual reference element set is specified,
|
|
|
|
// and is given by mScopes.
|
|
|
|
bool mHaveSpecifiedScope;
|
|
|
|
|
2011-03-29 10:29:20 -07:00
|
|
|
// How matching should be performed. See the documentation for
|
|
|
|
// nsRuleWalker::VisitedHandlingType.
|
|
|
|
nsRuleWalker::VisitedHandlingType mVisitedHandling;
|
|
|
|
|
2012-12-04 20:15:47 -08:00
|
|
|
// For matching :scope
|
|
|
|
nsAutoTArray<mozilla::dom::Element*, 1> mScopes;
|
2011-03-29 10:29:21 -07:00
|
|
|
public:
|
2011-03-29 10:29:21 -07:00
|
|
|
// The document we're working with.
|
|
|
|
nsIDocument* const mDocument;
|
|
|
|
|
2011-03-29 10:29:20 -07:00
|
|
|
// Root of scoped stylesheet (set and unset by the supplier of the
|
|
|
|
// scoped stylesheet).
|
|
|
|
nsIContent* mScopedRoot;
|
|
|
|
|
2011-03-29 10:29:20 -07:00
|
|
|
// Whether our document is HTML (as opposed to XML of some sort,
|
|
|
|
// including XHTML).
|
2011-03-29 10:29:21 -07:00
|
|
|
// XXX XBL2 issue: Should we be caching this? What should it be for XBL2?
|
2011-09-28 23:19:26 -07:00
|
|
|
const bool mIsHTMLDocument;
|
2011-03-29 10:29:20 -07:00
|
|
|
|
2011-03-29 10:29:20 -07:00
|
|
|
// Possibly remove use of mCompatMode in SelectorMatches?
|
2011-03-29 10:29:21 -07:00
|
|
|
// XXX XBL2 issue: Should we be caching this? What should it be for XBL2?
|
2011-03-29 10:29:20 -07:00
|
|
|
const nsCompatibility mCompatMode;
|
|
|
|
|
2011-03-29 10:29:21 -07:00
|
|
|
// The nth-index cache we should use
|
|
|
|
nsNthIndexCache mNthIndexCache;
|
|
|
|
|
2012-03-12 20:54:15 -07:00
|
|
|
// An ancestor filter
|
|
|
|
AncestorFilter mAncestorFilter;
|
|
|
|
|
2012-03-29 23:16:22 -07:00
|
|
|
// Whether this document is using PB mode
|
|
|
|
bool mUsingPrivateBrowsing;
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
enum MatchVisited {
|
|
|
|
eNeverMatchVisited,
|
|
|
|
eMatchVisitedDefault
|
|
|
|
};
|
|
|
|
|
2013-01-08 15:25:48 -08:00
|
|
|
// List of ancestor elements that define a style scope (due to having a
|
|
|
|
// <style scoped> child).
|
|
|
|
nsAutoTArray<mozilla::dom::Element*, 1> mStyleScopes;
|
|
|
|
|
2011-03-29 10:29:21 -07:00
|
|
|
// Constructor to use when creating a tree match context for styling
|
2011-09-28 23:19:26 -07:00
|
|
|
TreeMatchContext(bool aForStyling,
|
2011-03-29 10:29:20 -07:00
|
|
|
nsRuleWalker::VisitedHandlingType aVisitedHandling,
|
2012-06-10 16:44:50 -07:00
|
|
|
nsIDocument* aDocument,
|
|
|
|
MatchVisited aMatchVisited = eMatchVisitedDefault)
|
2011-03-29 10:29:20 -07:00
|
|
|
: mForStyling(aForStyling)
|
2011-10-17 07:59:28 -07:00
|
|
|
, mHaveRelevantLink(false)
|
2012-12-04 20:15:47 -08:00
|
|
|
, mHaveSpecifiedScope(false)
|
2011-03-29 10:29:20 -07:00
|
|
|
, mVisitedHandling(aVisitedHandling)
|
2011-03-29 10:29:21 -07:00
|
|
|
, mDocument(aDocument)
|
2012-07-30 07:20:58 -07:00
|
|
|
, mScopedRoot(nullptr)
|
2011-03-29 10:29:20 -07:00
|
|
|
, mIsHTMLDocument(aDocument->IsHTML())
|
|
|
|
, mCompatMode(aDocument->GetCompatibilityMode())
|
2012-03-29 23:16:22 -07:00
|
|
|
, mUsingPrivateBrowsing(false)
|
2011-03-29 10:29:20 -07:00
|
|
|
{
|
2012-06-10 16:44:50 -07:00
|
|
|
if (aMatchVisited != eNeverMatchVisited) {
|
|
|
|
nsCOMPtr<nsISupports> container = mDocument->GetContainer();
|
|
|
|
if (container) {
|
|
|
|
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(container);
|
|
|
|
NS_ASSERTION(loadContext, "Couldn't get loadContext from container; assuming no private browsing.");
|
|
|
|
if (loadContext) {
|
|
|
|
mUsingPrivateBrowsing = loadContext->UsePrivateBrowsing();
|
|
|
|
}
|
2012-03-29 23:16:22 -07:00
|
|
|
}
|
|
|
|
}
|
2011-03-29 10:29:20 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-11-14 11:09:01 -08:00
|
|
|
struct NS_STACK_CLASS RuleProcessorData {
|
2009-08-01 08:53:40 -07:00
|
|
|
RuleProcessorData(nsPresContext* aPresContext,
|
2012-11-14 11:09:01 -08:00
|
|
|
nsRuleWalker* aRuleWalker)
|
|
|
|
: mPresContext(aPresContext),
|
2013-01-08 00:36:21 -08:00
|
|
|
mRuleWalker(aRuleWalker)
|
2012-11-14 11:09:01 -08:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(mPresContext, "Must have prescontext");
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPresContext* const mPresContext;
|
|
|
|
nsRuleWalker* const mRuleWalker; // Used to add rules to our results.
|
|
|
|
};
|
|
|
|
|
|
|
|
struct NS_STACK_CLASS ElementDependentRuleProcessorData :
|
|
|
|
public RuleProcessorData {
|
|
|
|
ElementDependentRuleProcessorData(nsPresContext* aPresContext,
|
|
|
|
mozilla::dom::Element* aElement,
|
|
|
|
nsRuleWalker* aRuleWalker,
|
|
|
|
TreeMatchContext& aTreeMatchContext)
|
|
|
|
: RuleProcessorData(aPresContext, aRuleWalker)
|
2011-03-29 10:29:21 -07:00
|
|
|
, mElement(aElement)
|
2011-03-29 10:29:21 -07:00
|
|
|
, mTreeMatchContext(aTreeMatchContext)
|
2009-08-01 08:53:40 -07:00
|
|
|
{
|
2011-03-29 10:29:21 -07:00
|
|
|
NS_ASSERTION(aElement, "null element leaked into SelectorMatches");
|
2011-10-18 03:53:36 -07:00
|
|
|
NS_ASSERTION(aElement->OwnerDoc(), "Document-less node here?");
|
2011-03-29 10:29:21 -07:00
|
|
|
NS_PRECONDITION(aTreeMatchContext.mForStyling == !!aRuleWalker,
|
|
|
|
"Should be styling if and only if we have a rule walker");
|
2011-03-29 10:29:20 -07:00
|
|
|
}
|
|
|
|
|
2011-03-29 10:29:21 -07:00
|
|
|
mozilla::dom::Element* const mElement; // weak ref, must not be null
|
2011-03-29 10:29:21 -07:00
|
|
|
TreeMatchContext& mTreeMatchContext;
|
2009-08-01 08:53:40 -07:00
|
|
|
};
|
|
|
|
|
2012-11-14 11:09:01 -08:00
|
|
|
struct NS_STACK_CLASS ElementRuleProcessorData :
|
|
|
|
public ElementDependentRuleProcessorData {
|
2009-08-01 08:53:40 -07:00
|
|
|
ElementRuleProcessorData(nsPresContext* aPresContext,
|
2010-04-30 06:12:06 -07:00
|
|
|
mozilla::dom::Element* aElement,
|
2011-03-29 10:29:21 -07:00
|
|
|
nsRuleWalker* aRuleWalker,
|
|
|
|
TreeMatchContext& aTreeMatchContext)
|
2012-11-14 11:09:01 -08:00
|
|
|
: ElementDependentRuleProcessorData(aPresContext, aElement, aRuleWalker,
|
|
|
|
aTreeMatchContext)
|
2009-08-01 08:53:40 -07:00
|
|
|
{
|
2011-03-29 10:29:21 -07:00
|
|
|
NS_PRECONDITION(aTreeMatchContext.mForStyling, "Styling here!");
|
2012-11-14 11:09:01 -08:00
|
|
|
NS_PRECONDITION(aRuleWalker, "Must have rule walker");
|
2009-08-01 08:53:40 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-11-14 11:09:01 -08:00
|
|
|
struct NS_STACK_CLASS PseudoElementRuleProcessorData :
|
|
|
|
public ElementDependentRuleProcessorData {
|
2009-12-10 23:37:40 -08:00
|
|
|
PseudoElementRuleProcessorData(nsPresContext* aPresContext,
|
2010-04-30 06:12:06 -07:00
|
|
|
mozilla::dom::Element* aParentElement,
|
2009-12-10 23:37:40 -08:00
|
|
|
nsRuleWalker* aRuleWalker,
|
2011-03-29 10:29:21 -07:00
|
|
|
nsCSSPseudoElements::Type aPseudoType,
|
|
|
|
TreeMatchContext& aTreeMatchContext)
|
2012-11-14 11:09:01 -08:00
|
|
|
: ElementDependentRuleProcessorData(aPresContext, aParentElement, aRuleWalker,
|
|
|
|
aTreeMatchContext),
|
2009-12-10 23:37:40 -08:00
|
|
|
mPseudoType(aPseudoType)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aPseudoType <
|
|
|
|
nsCSSPseudoElements::ePseudo_PseudoElementCount,
|
2012-11-14 11:09:01 -08:00
|
|
|
"invalid aPseudoType value");
|
2011-03-29 10:29:21 -07:00
|
|
|
NS_PRECONDITION(aTreeMatchContext.mForStyling, "Styling here!");
|
2012-11-14 11:09:01 -08:00
|
|
|
NS_PRECONDITION(aRuleWalker, "Must have rule walker");
|
2009-12-10 23:37:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSPseudoElements::Type mPseudoType;
|
|
|
|
};
|
|
|
|
|
2012-11-14 11:09:01 -08:00
|
|
|
struct NS_STACK_CLASS AnonBoxRuleProcessorData : public RuleProcessorData {
|
2009-12-10 23:37:40 -08:00
|
|
|
AnonBoxRuleProcessorData(nsPresContext* aPresContext,
|
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
nsRuleWalker* aRuleWalker)
|
2012-11-14 11:09:01 -08:00
|
|
|
: RuleProcessorData(aPresContext, aRuleWalker),
|
|
|
|
mPseudoTag(aPseudoTag)
|
2009-12-10 23:37:40 -08:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aPseudoTag, "Must have pseudo tag");
|
|
|
|
NS_PRECONDITION(aRuleWalker, "Must have rule walker");
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom* mPseudoTag;
|
|
|
|
};
|
|
|
|
|
2009-12-10 23:37:40 -08:00
|
|
|
#ifdef MOZ_XUL
|
2012-11-14 11:09:01 -08:00
|
|
|
struct NS_STACK_CLASS XULTreeRuleProcessorData :
|
|
|
|
public ElementDependentRuleProcessorData {
|
2009-12-10 23:37:40 -08:00
|
|
|
XULTreeRuleProcessorData(nsPresContext* aPresContext,
|
2010-04-30 06:12:06 -07:00
|
|
|
mozilla::dom::Element* aParentElement,
|
2009-12-10 23:37:40 -08:00
|
|
|
nsRuleWalker* aRuleWalker,
|
|
|
|
nsIAtom* aPseudoTag,
|
2011-03-29 10:29:21 -07:00
|
|
|
nsICSSPseudoComparator* aComparator,
|
|
|
|
TreeMatchContext& aTreeMatchContext)
|
2012-11-14 11:09:01 -08:00
|
|
|
: ElementDependentRuleProcessorData(aPresContext, aParentElement,
|
|
|
|
aRuleWalker, aTreeMatchContext),
|
2009-12-10 23:37:40 -08:00
|
|
|
mPseudoTag(aPseudoTag),
|
|
|
|
mComparator(aComparator)
|
2009-08-01 08:53:40 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aPseudoTag, "null pointer");
|
2012-11-14 11:09:01 -08:00
|
|
|
NS_PRECONDITION(aRuleWalker, "Must have rule walker");
|
2009-12-10 23:37:40 -08:00
|
|
|
NS_PRECONDITION(aComparator, "must have a comparator");
|
2011-03-29 10:29:21 -07:00
|
|
|
NS_PRECONDITION(aTreeMatchContext.mForStyling, "Styling here!");
|
2009-08-01 08:53:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom* mPseudoTag;
|
|
|
|
nsICSSPseudoComparator* mComparator;
|
|
|
|
};
|
2009-12-10 23:37:40 -08:00
|
|
|
#endif
|
2009-08-01 08:53:40 -07:00
|
|
|
|
2012-11-14 11:09:01 -08:00
|
|
|
struct NS_STACK_CLASS StateRuleProcessorData :
|
|
|
|
public ElementDependentRuleProcessorData {
|
2009-08-01 08:53:40 -07:00
|
|
|
StateRuleProcessorData(nsPresContext* aPresContext,
|
2010-04-30 06:12:06 -07:00
|
|
|
mozilla::dom::Element* aElement,
|
2011-03-29 10:29:21 -07:00
|
|
|
nsEventStates aStateMask,
|
|
|
|
TreeMatchContext& aTreeMatchContext)
|
2012-11-14 11:09:01 -08:00
|
|
|
: ElementDependentRuleProcessorData(aPresContext, aElement, nullptr,
|
|
|
|
aTreeMatchContext),
|
2009-08-01 08:53:40 -07:00
|
|
|
mStateMask(aStateMask)
|
|
|
|
{
|
2011-03-29 10:29:21 -07:00
|
|
|
NS_PRECONDITION(!aTreeMatchContext.mForStyling, "Not styling here!");
|
2009-08-01 08:53:40 -07:00
|
|
|
}
|
2010-10-20 04:26:32 -07:00
|
|
|
const nsEventStates mStateMask; // |HasStateDependentStyle| for which state(s)?
|
|
|
|
// Constants defined in nsEventStates.h .
|
2009-08-01 08:53:40 -07:00
|
|
|
};
|
|
|
|
|
2012-11-14 11:09:01 -08:00
|
|
|
struct NS_STACK_CLASS AttributeRuleProcessorData :
|
|
|
|
public ElementDependentRuleProcessorData {
|
2009-08-01 08:53:40 -07:00
|
|
|
AttributeRuleProcessorData(nsPresContext* aPresContext,
|
2010-04-30 06:12:06 -07:00
|
|
|
mozilla::dom::Element* aElement,
|
2009-08-01 08:53:40 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aAttrHasChanged,
|
2011-03-29 10:29:21 -07:00
|
|
|
TreeMatchContext& aTreeMatchContext)
|
2012-11-14 11:09:01 -08:00
|
|
|
: ElementDependentRuleProcessorData(aPresContext, aElement, nullptr,
|
|
|
|
aTreeMatchContext),
|
2009-08-01 08:53:40 -07:00
|
|
|
mAttribute(aAttribute),
|
|
|
|
mModType(aModType),
|
2009-12-10 14:36:03 -08:00
|
|
|
mAttrHasChanged(aAttrHasChanged)
|
2009-08-01 08:53:40 -07:00
|
|
|
{
|
2011-03-29 10:29:21 -07:00
|
|
|
NS_PRECONDITION(!aTreeMatchContext.mForStyling, "Not styling here!");
|
2009-08-01 08:53:40 -07:00
|
|
|
}
|
|
|
|
nsIAtom* mAttribute; // |HasAttributeDependentStyle| for which attribute?
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mModType; // The type of modification (see nsIDOMMutationEvent).
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mAttrHasChanged; // Whether the attribute has already changed.
|
2009-08-01 08:53:40 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !defined(nsRuleProcessorData_h_) */
|