2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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/. */
|
2004-01-26 22:22:05 +03:00
|
|
|
|
2006-03-31 12:00:42 +04:00
|
|
|
/*
|
|
|
|
* A unique per-element set of attributes that is used as an
|
|
|
|
* nsIStyleRule; used to implement presentational attributes.
|
|
|
|
*/
|
|
|
|
|
2004-01-26 22:22:05 +03:00
|
|
|
#ifndef nsMappedAttributes_h___
|
|
|
|
#define nsMappedAttributes_h___
|
|
|
|
|
|
|
|
#include "nsAttrAndChildArray.h"
|
2008-01-09 12:38:28 +03:00
|
|
|
#include "nsMappedAttributeElement.h"
|
2004-01-26 22:22:05 +03:00
|
|
|
#include "nsIStyleRule.h"
|
2012-06-19 06:30:09 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2004-01-26 22:22:05 +03:00
|
|
|
|
|
|
|
class nsIAtom;
|
2004-04-13 01:56:09 +04:00
|
|
|
class nsHTMLStyleSheet;
|
2004-01-26 22:22:05 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsMappedAttributes final : public nsIStyleRule
|
2004-01-26 22:22:05 +03:00
|
|
|
{
|
|
|
|
public:
|
2004-04-13 01:56:09 +04:00
|
|
|
nsMappedAttributes(nsHTMLStyleSheet* aSheet,
|
2004-01-26 22:22:05 +03:00
|
|
|
nsMapRuleToAttributesFunc aMapRuleFunc);
|
2004-01-31 01:08:23 +03:00
|
|
|
|
2012-08-04 11:44:01 +04:00
|
|
|
// Do not return null.
|
2012-08-22 19:56:38 +04:00
|
|
|
void* operator new(size_t size, uint32_t aAttrCount = 1) CPP_THROW_NEW;
|
2011-09-29 10:19:26 +04:00
|
|
|
nsMappedAttributes* Clone(bool aWillAddAttr);
|
2004-01-26 22:22:05 +03:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2012-09-06 11:14:49 +04:00
|
|
|
void SetAndTakeAttr(nsIAtom* aAttrName, nsAttrValue& aValue);
|
2004-01-26 22:22:05 +03:00
|
|
|
const nsAttrValue* GetAttr(nsIAtom* aAttrName) const;
|
2012-07-14 03:29:14 +04:00
|
|
|
const nsAttrValue* GetAttr(const nsAString& aAttrName) const;
|
2004-01-26 22:22:05 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t Count() const
|
2004-01-26 22:22:05 +03:00
|
|
|
{
|
|
|
|
return mAttrCount;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool Equals(const nsMappedAttributes* aAttributes) const;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t HashValue() const;
|
2004-01-26 22:22:05 +03:00
|
|
|
|
|
|
|
void DropStyleSheetReference()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
mSheet = nullptr;
|
2004-01-26 22:22:05 +03:00
|
|
|
}
|
2004-04-13 01:56:09 +04:00
|
|
|
void SetStyleSheet(nsHTMLStyleSheet* aSheet);
|
|
|
|
nsHTMLStyleSheet* GetStyleSheet()
|
2004-01-26 22:22:05 +03:00
|
|
|
{
|
|
|
|
return mSheet;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
const nsAttrName* NameAt(uint32_t aPos) const
|
2004-01-26 22:22:05 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aPos < mAttrCount, "out-of-bounds");
|
2004-01-31 01:08:23 +03:00
|
|
|
return &Attrs()[aPos].mName;
|
2004-01-26 22:22:05 +03:00
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
const nsAttrValue* AttrAt(uint32_t aPos) const
|
2004-01-26 22:22:05 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aPos < mAttrCount, "out-of-bounds");
|
2004-01-31 01:08:23 +03:00
|
|
|
return &Attrs()[aPos].mValue;
|
2004-01-26 22:22:05 +03:00
|
|
|
}
|
2006-11-11 03:04:46 +03:00
|
|
|
// Remove the attr at position aPos. The value of the attr is placed in
|
|
|
|
// aValue; any value that was already in aValue is destroyed.
|
2012-08-22 19:56:38 +04:00
|
|
|
void RemoveAttrAt(uint32_t aPos, nsAttrValue& aValue);
|
2010-03-08 18:45:00 +03:00
|
|
|
const nsAttrName* GetExistingAttrNameFromQName(const nsAString& aName) const;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t IndexOfAttr(nsIAtom* aLocalName) const;
|
2004-01-26 22:22:05 +03:00
|
|
|
|
|
|
|
|
|
|
|
// nsIStyleRule
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData) override;
|
2015-11-17 07:09:55 +03:00
|
|
|
virtual bool MightMapInheritedStyleData() override;
|
2016-08-17 04:37:48 +03:00
|
|
|
virtual bool GetDiscretelyAnimatedCSSValue(nsCSSPropertyID aProperty,
|
2016-08-16 08:29:21 +03:00
|
|
|
nsCSSValue* aValue) override;
|
2004-01-26 22:22:05 +03:00
|
|
|
#ifdef DEBUG
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
|
2004-01-26 22:22:05 +03:00
|
|
|
#endif
|
|
|
|
|
2013-06-23 16:03:39 +04:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2011-07-19 20:42:14 +04:00
|
|
|
|
2004-01-26 22:22:05 +03:00
|
|
|
private:
|
2004-01-31 01:08:23 +03:00
|
|
|
nsMappedAttributes(const nsMappedAttributes& aCopy);
|
2004-01-26 22:22:05 +03:00
|
|
|
~nsMappedAttributes();
|
|
|
|
|
|
|
|
struct InternalAttr
|
|
|
|
{
|
|
|
|
nsAttrName mName;
|
|
|
|
nsAttrValue mValue;
|
|
|
|
};
|
|
|
|
|
2004-01-31 01:08:23 +03:00
|
|
|
/**
|
2016-07-22 06:10:23 +03:00
|
|
|
* Due to a compiler bug in VisualAge C++ for AIX, we need to return the
|
2004-01-31 01:08:23 +03:00
|
|
|
* address of the first index into mAttrs here, instead of simply
|
|
|
|
* returning mAttrs itself.
|
|
|
|
*
|
|
|
|
* See Bug 231104 for more information.
|
|
|
|
*/
|
|
|
|
const InternalAttr* Attrs() const
|
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
return reinterpret_cast<const InternalAttr*>(&(mAttrs[0]));
|
2004-01-31 01:08:23 +03:00
|
|
|
}
|
|
|
|
InternalAttr* Attrs()
|
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
return reinterpret_cast<InternalAttr*>(&(mAttrs[0]));
|
2004-01-31 01:08:23 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mAttrCount;
|
2004-01-31 01:08:23 +03:00
|
|
|
#ifdef DEBUG
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mBufferSize;
|
2004-01-31 01:08:23 +03:00
|
|
|
#endif
|
2004-04-13 01:56:09 +04:00
|
|
|
nsHTMLStyleSheet* mSheet; //weak
|
2004-01-26 22:22:05 +03:00
|
|
|
nsMapRuleToAttributesFunc mRuleMapper;
|
2004-01-31 01:08:23 +03:00
|
|
|
void* mAttrs[1];
|
2004-01-26 22:22:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsMappedAttributes_h___ */
|