2009-08-01 19:53:40 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 19:53:40 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* data structures passed to nsIStyleRuleProcessor methods (to pull loop
|
|
|
|
* invariant computations out of the loop)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsRuleProcessorData_h_
|
|
|
|
#define nsRuleProcessorData_h_
|
|
|
|
|
2011-09-07 04:20:35 +04:00
|
|
|
#include "nsPresContext.h" // for nsCompatibility
|
2009-08-01 19:53:40 +04:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsChangeHint.h"
|
2009-12-11 10:37:40 +03:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2010-04-03 05:58:27 +04:00
|
|
|
#include "nsRuleWalker.h"
|
2011-03-29 21:29:21 +04:00
|
|
|
#include "nsNthIndexCache.h"
|
2012-03-30 10:16:22 +04:00
|
|
|
#include "nsILoadContext.h"
|
2013-02-21 11:35:03 +04:00
|
|
|
#include "mozilla/AutoRestore.h"
|
2012-03-13 07:54:15 +04:00
|
|
|
#include "mozilla/BloomFilter.h"
|
|
|
|
#include "mozilla/GuardObjects.h"
|
2009-08-01 19:53:40 +04:00
|
|
|
|
2013-03-22 04:05:20 +04:00
|
|
|
class nsAttrValue;
|
2009-08-01 19:53:40 +04:00
|
|
|
class nsIAtom;
|
2013-03-22 04:05:20 +04:00
|
|
|
class nsIContent;
|
2009-08-01 19:53:40 +04:00
|
|
|
class nsICSSPseudoComparator;
|
2013-03-22 04:05:20 +04:00
|
|
|
class nsIStyleSheet;
|
2013-01-09 03:25:48 +04:00
|
|
|
struct TreeMatchContext;
|
2009-08-01 19:53:40 +04:00
|
|
|
|
2012-03-13 07:54:15 +04: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.
|
|
|
|
*/
|
2013-04-12 07:20:45 +04:00
|
|
|
class MOZ_STACK_CLASS AncestorFilter {
|
2013-01-09 03:25:48 +04:00
|
|
|
friend struct TreeMatchContext;
|
2012-03-13 07:54:15 +04: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 19:56:38 +04:00
|
|
|
nsTArray<uint32_t> mPopTargets;
|
2012-03-13 07:54:15 +04: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 21:29:20 +04: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 21:29:21 +04:00
|
|
|
* TreeMatchContext for more than one matching operation and care
|
|
|
|
* about :visited and mHaveRelevantLink need to
|
|
|
|
* ResetForVisitedMatching() and ResetForUnvisitedMatching() as
|
|
|
|
* needed.
|
2011-03-29 21:29:20 +04:00
|
|
|
*/
|
2013-04-12 07:20:45 +04:00
|
|
|
struct MOZ_STACK_CLASS TreeMatchContext {
|
2011-03-29 21:29:21 +04:00
|
|
|
// Reset this context for matching for the style-if-:visited.
|
|
|
|
void ResetForVisitedMatching() {
|
|
|
|
NS_PRECONDITION(mForStyling, "Why is this being called?");
|
2011-10-17 18:59:28 +04:00
|
|
|
mHaveRelevantLink = false;
|
2011-03-29 21:29:21 +04:00
|
|
|
mVisitedHandling = nsRuleWalker::eRelevantLinkVisited;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResetForUnvisitedMatching() {
|
|
|
|
NS_PRECONDITION(mForStyling, "Why is this being called?");
|
2011-10-17 18:59:28 +04:00
|
|
|
mHaveRelevantLink = false;
|
2011-03-29 21:29:21 +04:00
|
|
|
mVisitedHandling = nsRuleWalker::eRelevantLinkUnvisited;
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
void SetHaveRelevantLink() { mHaveRelevantLink = true; }
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HaveRelevantLink() const { return mHaveRelevantLink; }
|
2011-03-29 21:29:21 +04:00
|
|
|
|
|
|
|
nsRuleWalker::VisitedHandlingType VisitedHandling() const
|
|
|
|
{
|
|
|
|
return mVisitedHandling;
|
|
|
|
}
|
|
|
|
|
2012-12-05 08:15:47 +04: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-09 03:25:48 +04: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-09 03:25:48 +04:00
|
|
|
bool PopStyleScopeForSelectorMatching(mozilla::dom::Element* aElement)
|
|
|
|
{
|
2013-01-16 08:48:29 +04:00
|
|
|
NS_ASSERTION(mForScopedStyle, "only call PopStyleScopeForSelectorMatching "
|
|
|
|
"when mForScopedStyle is true");
|
2013-01-09 03:25:48 +04:00
|
|
|
|
|
|
|
if (!mCurrentStyleScope) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (mCurrentStyleScope == aElement) {
|
|
|
|
mCurrentStyleScope = nullptr;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SetStyleScopeForSelectorMatching(mozilla::dom::Element* aSubject,
|
|
|
|
mozilla::dom::Element* aScope)
|
|
|
|
{
|
|
|
|
mForScopedStyle = !!aScope;
|
|
|
|
if (!aScope) {
|
|
|
|
// This is not for a scoped style sheet; return true, as we want
|
|
|
|
// selector matching to proceed.
|
|
|
|
mCurrentStyleScope = nullptr;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (aScope == aSubject) {
|
|
|
|
// Although the subject is the same element as the scope, as soon
|
|
|
|
// as we continue with selector matching up the tree we don't want
|
|
|
|
// to match any more elements. So we return true to indicate that
|
|
|
|
// we want to do the initial selector matching, but set
|
|
|
|
// mCurrentStyleScope to null so that no ancestor elements will match.
|
|
|
|
mCurrentStyleScope = nullptr;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (mStyleScopes.Contains(aScope)) {
|
|
|
|
// mStyleScopes contains all of the scope elements that are ancestors of
|
|
|
|
// aSubject, so if aScope is in mStyleScopes, then we do want selector
|
|
|
|
// matching to proceed.
|
|
|
|
mCurrentStyleScope = aScope;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// Otherwise, we're not in the scope, and we don't want to proceed
|
|
|
|
// with selector matching.
|
|
|
|
mCurrentStyleScope = nullptr;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsWithinStyleScopeForSelectorMatching() const
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mForScopedStyle, "only call IsWithinScopeForSelectorMatching "
|
|
|
|
"when mForScopedStyle is true");
|
|
|
|
return mCurrentStyleScope;
|
|
|
|
}
|
2013-01-08 12:09:23 +04:00
|
|
|
|
2013-01-09 03:25:48 +04:00
|
|
|
/* Helper class for maintaining the ancestor state */
|
2013-04-12 07:20:45 +04:00
|
|
|
class MOZ_STACK_CLASS AutoAncestorPusher {
|
2013-01-09 03:25:48 +04:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2013-02-21 11:35:03 +04:00
|
|
|
/* Helper class for tracking whether we're skipping the ApplyStyleFixups
|
2013-03-14 00:54:05 +04:00
|
|
|
* code for flex items.
|
|
|
|
*
|
|
|
|
* The optional second parameter aSkipFlexItemStyleFixup allows this
|
|
|
|
* class to be instantiated but only conditionally activated (e.g.
|
|
|
|
* in cases where we may or may not want to be skipping flex-item
|
|
|
|
* style fixup for a particular chunk of code).
|
|
|
|
*/
|
2013-04-12 07:20:45 +04:00
|
|
|
class MOZ_STACK_CLASS AutoFlexItemStyleFixupSkipper {
|
2013-02-21 11:35:03 +04:00
|
|
|
public:
|
2013-03-14 00:54:05 +04:00
|
|
|
AutoFlexItemStyleFixupSkipper(TreeMatchContext& aTreeMatchContext,
|
|
|
|
bool aSkipFlexItemStyleFixup = true
|
2013-02-21 11:35:03 +04:00
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
|
|
|
: mAutoRestorer(aTreeMatchContext.mSkippingFlexItemStyleFixup)
|
|
|
|
{
|
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
2013-03-14 00:54:05 +04:00
|
|
|
if (aSkipFlexItemStyleFixup) {
|
|
|
|
aTreeMatchContext.mSkippingFlexItemStyleFixup = true;
|
|
|
|
}
|
2013-02-21 11:35:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
mozilla::AutoRestore<bool> mAutoRestorer;
|
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
|
|
|
};
|
|
|
|
|
2013-01-09 03:25:48 +04: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;
|
|
|
|
|
2011-03-29 21:29:21 +04: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-29 10:19:26 +04:00
|
|
|
bool mHaveRelevantLink;
|
2011-03-29 21:29:20 +04:00
|
|
|
|
2012-12-05 08:15:47 +04:00
|
|
|
// If true, then our contextual reference element set is specified,
|
|
|
|
// and is given by mScopes.
|
|
|
|
bool mHaveSpecifiedScope;
|
|
|
|
|
2011-03-29 21:29:20 +04:00
|
|
|
// How matching should be performed. See the documentation for
|
|
|
|
// nsRuleWalker::VisitedHandlingType.
|
|
|
|
nsRuleWalker::VisitedHandlingType mVisitedHandling;
|
|
|
|
|
2012-12-05 08:15:47 +04:00
|
|
|
// For matching :scope
|
|
|
|
nsAutoTArray<mozilla::dom::Element*, 1> mScopes;
|
2011-03-29 21:29:21 +04:00
|
|
|
public:
|
2011-03-29 21:29:21 +04:00
|
|
|
// The document we're working with.
|
|
|
|
nsIDocument* const mDocument;
|
|
|
|
|
2011-03-29 21:29:20 +04:00
|
|
|
// Root of scoped stylesheet (set and unset by the supplier of the
|
|
|
|
// scoped stylesheet).
|
|
|
|
nsIContent* mScopedRoot;
|
|
|
|
|
2011-03-29 21:29:20 +04:00
|
|
|
// Whether our document is HTML (as opposed to XML of some sort,
|
|
|
|
// including XHTML).
|
2011-03-29 21:29:21 +04:00
|
|
|
// XXX XBL2 issue: Should we be caching this? What should it be for XBL2?
|
2011-09-29 10:19:26 +04:00
|
|
|
const bool mIsHTMLDocument;
|
2011-03-29 21:29:20 +04:00
|
|
|
|
2011-03-29 21:29:20 +04:00
|
|
|
// Possibly remove use of mCompatMode in SelectorMatches?
|
2011-03-29 21:29:21 +04:00
|
|
|
// XXX XBL2 issue: Should we be caching this? What should it be for XBL2?
|
2011-03-29 21:29:20 +04:00
|
|
|
const nsCompatibility mCompatMode;
|
|
|
|
|
2011-03-29 21:29:21 +04:00
|
|
|
// The nth-index cache we should use
|
|
|
|
nsNthIndexCache mNthIndexCache;
|
|
|
|
|
2012-03-13 07:54:15 +04:00
|
|
|
// An ancestor filter
|
|
|
|
AncestorFilter mAncestorFilter;
|
|
|
|
|
2012-03-30 10:16:22 +04:00
|
|
|
// Whether this document is using PB mode
|
|
|
|
bool mUsingPrivateBrowsing;
|
|
|
|
|
2013-02-21 11:35:03 +04:00
|
|
|
// Whether we're currently skipping the flex item chunk of ApplyStyleFixups
|
|
|
|
// when resolving style (e.g. for children of elements that have a mandatory
|
|
|
|
// frame-type and can't be flex containers despite having "display:flex").
|
|
|
|
bool mSkippingFlexItemStyleFixup;
|
|
|
|
|
2013-01-09 03:25:48 +04:00
|
|
|
// Whether this TreeMatchContext is being used with an nsCSSRuleProcessor
|
|
|
|
// for an HTML5 scoped style sheet.
|
|
|
|
bool mForScopedStyle;
|
|
|
|
|
2012-06-11 03:44:50 +04:00
|
|
|
enum MatchVisited {
|
|
|
|
eNeverMatchVisited,
|
|
|
|
eMatchVisitedDefault
|
|
|
|
};
|
|
|
|
|
2013-01-09 03:25:48 +04:00
|
|
|
// List of ancestor elements that define a style scope (due to having a
|
|
|
|
// <style scoped> child).
|
|
|
|
nsAutoTArray<mozilla::dom::Element*, 1> mStyleScopes;
|
|
|
|
|
2013-01-09 03:25:48 +04:00
|
|
|
// The current style scope element for selector matching.
|
|
|
|
mozilla::dom::Element* mCurrentStyleScope;
|
|
|
|
|
2011-03-29 21:29:21 +04:00
|
|
|
// Constructor to use when creating a tree match context for styling
|
2011-09-29 10:19:26 +04:00
|
|
|
TreeMatchContext(bool aForStyling,
|
2011-03-29 21:29:20 +04:00
|
|
|
nsRuleWalker::VisitedHandlingType aVisitedHandling,
|
2012-06-11 03:44:50 +04:00
|
|
|
nsIDocument* aDocument,
|
|
|
|
MatchVisited aMatchVisited = eMatchVisitedDefault)
|
2011-03-29 21:29:20 +04:00
|
|
|
: mForStyling(aForStyling)
|
2011-10-17 18:59:28 +04:00
|
|
|
, mHaveRelevantLink(false)
|
2012-12-05 08:15:47 +04:00
|
|
|
, mHaveSpecifiedScope(false)
|
2011-03-29 21:29:20 +04:00
|
|
|
, mVisitedHandling(aVisitedHandling)
|
2011-03-29 21:29:21 +04:00
|
|
|
, mDocument(aDocument)
|
2012-07-30 18:20:58 +04:00
|
|
|
, mScopedRoot(nullptr)
|
2011-03-29 21:29:20 +04:00
|
|
|
, mIsHTMLDocument(aDocument->IsHTML())
|
|
|
|
, mCompatMode(aDocument->GetCompatibilityMode())
|
2012-03-30 10:16:22 +04:00
|
|
|
, mUsingPrivateBrowsing(false)
|
2013-02-21 11:35:03 +04:00
|
|
|
, mSkippingFlexItemStyleFixup(false)
|
2013-01-09 03:25:48 +04:00
|
|
|
, mForScopedStyle(false)
|
|
|
|
, mCurrentStyleScope(nullptr)
|
2011-03-29 21:29:20 +04:00
|
|
|
{
|
2012-06-11 03:44:50 +04: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-30 10:16:22 +04:00
|
|
|
}
|
|
|
|
}
|
2011-03-29 21:29:20 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-04-12 07:20:45 +04:00
|
|
|
struct MOZ_STACK_CLASS RuleProcessorData {
|
2009-08-01 19:53:40 +04:00
|
|
|
RuleProcessorData(nsPresContext* aPresContext,
|
2012-11-14 23:09:01 +04:00
|
|
|
nsRuleWalker* aRuleWalker)
|
|
|
|
: mPresContext(aPresContext),
|
2013-01-09 03:25:48 +04:00
|
|
|
mRuleWalker(aRuleWalker),
|
|
|
|
mScope(nullptr)
|
2012-11-14 23:09:01 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(mPresContext, "Must have prescontext");
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPresContext* const mPresContext;
|
|
|
|
nsRuleWalker* const mRuleWalker; // Used to add rules to our results.
|
2013-01-09 03:25:48 +04:00
|
|
|
mozilla::dom::Element* mScope;
|
2012-11-14 23:09:01 +04:00
|
|
|
};
|
|
|
|
|
2013-04-12 07:20:45 +04:00
|
|
|
struct MOZ_STACK_CLASS ElementDependentRuleProcessorData :
|
2012-11-14 23:09:01 +04:00
|
|
|
public RuleProcessorData {
|
|
|
|
ElementDependentRuleProcessorData(nsPresContext* aPresContext,
|
|
|
|
mozilla::dom::Element* aElement,
|
|
|
|
nsRuleWalker* aRuleWalker,
|
|
|
|
TreeMatchContext& aTreeMatchContext)
|
|
|
|
: RuleProcessorData(aPresContext, aRuleWalker)
|
2011-03-29 21:29:21 +04:00
|
|
|
, mElement(aElement)
|
2011-03-29 21:29:21 +04:00
|
|
|
, mTreeMatchContext(aTreeMatchContext)
|
2009-08-01 19:53:40 +04:00
|
|
|
{
|
2011-03-29 21:29:21 +04:00
|
|
|
NS_ASSERTION(aElement, "null element leaked into SelectorMatches");
|
2011-10-18 14:53:36 +04:00
|
|
|
NS_ASSERTION(aElement->OwnerDoc(), "Document-less node here?");
|
2011-03-29 21:29:21 +04:00
|
|
|
NS_PRECONDITION(aTreeMatchContext.mForStyling == !!aRuleWalker,
|
|
|
|
"Should be styling if and only if we have a rule walker");
|
2011-03-29 21:29:20 +04:00
|
|
|
}
|
|
|
|
|
2011-03-29 21:29:21 +04:00
|
|
|
mozilla::dom::Element* const mElement; // weak ref, must not be null
|
2011-03-29 21:29:21 +04:00
|
|
|
TreeMatchContext& mTreeMatchContext;
|
2009-08-01 19:53:40 +04:00
|
|
|
};
|
|
|
|
|
2013-04-12 07:20:45 +04:00
|
|
|
struct MOZ_STACK_CLASS ElementRuleProcessorData :
|
2012-11-14 23:09:01 +04:00
|
|
|
public ElementDependentRuleProcessorData {
|
2009-08-01 19:53:40 +04:00
|
|
|
ElementRuleProcessorData(nsPresContext* aPresContext,
|
2010-04-30 17:12:06 +04:00
|
|
|
mozilla::dom::Element* aElement,
|
2011-03-29 21:29:21 +04:00
|
|
|
nsRuleWalker* aRuleWalker,
|
|
|
|
TreeMatchContext& aTreeMatchContext)
|
2012-11-14 23:09:01 +04:00
|
|
|
: ElementDependentRuleProcessorData(aPresContext, aElement, aRuleWalker,
|
|
|
|
aTreeMatchContext)
|
2009-08-01 19:53:40 +04:00
|
|
|
{
|
2011-03-29 21:29:21 +04:00
|
|
|
NS_PRECONDITION(aTreeMatchContext.mForStyling, "Styling here!");
|
2012-11-14 23:09:01 +04:00
|
|
|
NS_PRECONDITION(aRuleWalker, "Must have rule walker");
|
2009-08-01 19:53:40 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-04-12 07:20:45 +04:00
|
|
|
struct MOZ_STACK_CLASS PseudoElementRuleProcessorData :
|
2012-11-14 23:09:01 +04:00
|
|
|
public ElementDependentRuleProcessorData {
|
2009-12-11 10:37:40 +03:00
|
|
|
PseudoElementRuleProcessorData(nsPresContext* aPresContext,
|
2010-04-30 17:12:06 +04:00
|
|
|
mozilla::dom::Element* aParentElement,
|
2009-12-11 10:37:40 +03:00
|
|
|
nsRuleWalker* aRuleWalker,
|
2011-03-29 21:29:21 +04:00
|
|
|
nsCSSPseudoElements::Type aPseudoType,
|
|
|
|
TreeMatchContext& aTreeMatchContext)
|
2012-11-14 23:09:01 +04:00
|
|
|
: ElementDependentRuleProcessorData(aPresContext, aParentElement, aRuleWalker,
|
|
|
|
aTreeMatchContext),
|
2009-12-11 10:37:40 +03:00
|
|
|
mPseudoType(aPseudoType)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aPseudoType <
|
|
|
|
nsCSSPseudoElements::ePseudo_PseudoElementCount,
|
2012-11-14 23:09:01 +04:00
|
|
|
"invalid aPseudoType value");
|
2011-03-29 21:29:21 +04:00
|
|
|
NS_PRECONDITION(aTreeMatchContext.mForStyling, "Styling here!");
|
2012-11-14 23:09:01 +04:00
|
|
|
NS_PRECONDITION(aRuleWalker, "Must have rule walker");
|
2009-12-11 10:37:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSPseudoElements::Type mPseudoType;
|
|
|
|
};
|
|
|
|
|
2013-04-12 07:20:45 +04:00
|
|
|
struct MOZ_STACK_CLASS AnonBoxRuleProcessorData : public RuleProcessorData {
|
2009-12-11 10:37:40 +03:00
|
|
|
AnonBoxRuleProcessorData(nsPresContext* aPresContext,
|
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
nsRuleWalker* aRuleWalker)
|
2012-11-14 23:09:01 +04:00
|
|
|
: RuleProcessorData(aPresContext, aRuleWalker),
|
|
|
|
mPseudoTag(aPseudoTag)
|
2009-12-11 10:37:40 +03:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aPseudoTag, "Must have pseudo tag");
|
|
|
|
NS_PRECONDITION(aRuleWalker, "Must have rule walker");
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom* mPseudoTag;
|
|
|
|
};
|
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
#ifdef MOZ_XUL
|
2013-04-12 07:20:45 +04:00
|
|
|
struct MOZ_STACK_CLASS XULTreeRuleProcessorData :
|
2012-11-14 23:09:01 +04:00
|
|
|
public ElementDependentRuleProcessorData {
|
2009-12-11 10:37:40 +03:00
|
|
|
XULTreeRuleProcessorData(nsPresContext* aPresContext,
|
2010-04-30 17:12:06 +04:00
|
|
|
mozilla::dom::Element* aParentElement,
|
2009-12-11 10:37:40 +03:00
|
|
|
nsRuleWalker* aRuleWalker,
|
|
|
|
nsIAtom* aPseudoTag,
|
2011-03-29 21:29:21 +04:00
|
|
|
nsICSSPseudoComparator* aComparator,
|
|
|
|
TreeMatchContext& aTreeMatchContext)
|
2012-11-14 23:09:01 +04:00
|
|
|
: ElementDependentRuleProcessorData(aPresContext, aParentElement,
|
|
|
|
aRuleWalker, aTreeMatchContext),
|
2009-12-11 10:37:40 +03:00
|
|
|
mPseudoTag(aPseudoTag),
|
|
|
|
mComparator(aComparator)
|
2009-08-01 19:53:40 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aPseudoTag, "null pointer");
|
2012-11-14 23:09:01 +04:00
|
|
|
NS_PRECONDITION(aRuleWalker, "Must have rule walker");
|
2009-12-11 10:37:40 +03:00
|
|
|
NS_PRECONDITION(aComparator, "must have a comparator");
|
2011-03-29 21:29:21 +04:00
|
|
|
NS_PRECONDITION(aTreeMatchContext.mForStyling, "Styling here!");
|
2009-08-01 19:53:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom* mPseudoTag;
|
|
|
|
nsICSSPseudoComparator* mComparator;
|
|
|
|
};
|
2009-12-11 10:37:40 +03:00
|
|
|
#endif
|
2009-08-01 19:53:40 +04:00
|
|
|
|
2013-04-12 07:20:45 +04:00
|
|
|
struct MOZ_STACK_CLASS StateRuleProcessorData :
|
2012-11-14 23:09:01 +04:00
|
|
|
public ElementDependentRuleProcessorData {
|
2009-08-01 19:53:40 +04:00
|
|
|
StateRuleProcessorData(nsPresContext* aPresContext,
|
2010-04-30 17:12:06 +04:00
|
|
|
mozilla::dom::Element* aElement,
|
2011-03-29 21:29:21 +04:00
|
|
|
nsEventStates aStateMask,
|
|
|
|
TreeMatchContext& aTreeMatchContext)
|
2012-11-14 23:09:01 +04:00
|
|
|
: ElementDependentRuleProcessorData(aPresContext, aElement, nullptr,
|
|
|
|
aTreeMatchContext),
|
2009-08-01 19:53:40 +04:00
|
|
|
mStateMask(aStateMask)
|
|
|
|
{
|
2011-03-29 21:29:21 +04:00
|
|
|
NS_PRECONDITION(!aTreeMatchContext.mForStyling, "Not styling here!");
|
2009-08-01 19:53:40 +04:00
|
|
|
}
|
2010-10-20 15:26:32 +04:00
|
|
|
const nsEventStates mStateMask; // |HasStateDependentStyle| for which state(s)?
|
|
|
|
// Constants defined in nsEventStates.h .
|
2009-08-01 19:53:40 +04:00
|
|
|
};
|
|
|
|
|
2013-04-12 07:20:45 +04:00
|
|
|
struct MOZ_STACK_CLASS AttributeRuleProcessorData :
|
2012-11-14 23:09:01 +04:00
|
|
|
public ElementDependentRuleProcessorData {
|
2009-08-01 19:53:40 +04:00
|
|
|
AttributeRuleProcessorData(nsPresContext* aPresContext,
|
2010-04-30 17:12:06 +04:00
|
|
|
mozilla::dom::Element* aElement,
|
2009-08-01 19:53:40 +04:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aAttrHasChanged,
|
2011-03-29 21:29:21 +04:00
|
|
|
TreeMatchContext& aTreeMatchContext)
|
2012-11-14 23:09:01 +04:00
|
|
|
: ElementDependentRuleProcessorData(aPresContext, aElement, nullptr,
|
|
|
|
aTreeMatchContext),
|
2009-08-01 19:53:40 +04:00
|
|
|
mAttribute(aAttribute),
|
|
|
|
mModType(aModType),
|
2009-12-11 01:36:03 +03:00
|
|
|
mAttrHasChanged(aAttrHasChanged)
|
2009-08-01 19:53:40 +04:00
|
|
|
{
|
2011-03-29 21:29:21 +04:00
|
|
|
NS_PRECONDITION(!aTreeMatchContext.mForStyling, "Not styling here!");
|
2009-08-01 19:53:40 +04:00
|
|
|
}
|
|
|
|
nsIAtom* mAttribute; // |HasAttributeDependentStyle| for which attribute?
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mModType; // The type of modification (see nsIDOMMutationEvent).
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mAttrHasChanged; // Whether the attribute has already changed.
|
2009-08-01 19:53:40 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !defined(nsRuleProcessorData_h_) */
|