2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2006-03-25 05:47:31 +00:00
|
|
|
|
|
|
|
/* rules in a CSS stylesheet other than style rules (e.g., @import rules) */
|
|
|
|
|
2011-12-19 18:48:15 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
|
2004-08-05 18:26:14 +00:00
|
|
|
#include "nsCSSRules.h"
|
2008-08-07 23:15:40 +00:00
|
|
|
#include "nsCSSValue.h"
|
2014-06-20 10:32:49 +00:00
|
|
|
#include "mozilla/CSSStyleSheet.h"
|
2013-06-23 12:03:39 +00:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2011-03-17 17:41:52 +00:00
|
|
|
#include "mozilla/css/ImportRule.h"
|
2011-03-17 17:41:52 +00:00
|
|
|
#include "mozilla/css/NameSpaceRule.h"
|
1999-06-10 05:32:38 +00:00
|
|
|
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
|
2008-08-07 23:15:40 +00:00
|
|
|
#include "nsCSSProps.h"
|
1999-06-10 05:32:38 +00:00
|
|
|
|
2000-03-31 07:08:36 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2001-05-15 08:26:13 +00:00
|
|
|
#include "nsIDOMCSSStyleSheet.h"
|
2001-08-04 21:19:53 +00:00
|
|
|
#include "nsIMediaList.h"
|
2014-06-10 02:11:00 +00:00
|
|
|
#include "mozilla/dom/CSSRuleList.h"
|
2001-09-05 00:00:18 +00:00
|
|
|
#include "nsIDocument.h"
|
2004-08-05 18:26:14 +00:00
|
|
|
#include "nsPresContext.h"
|
2001-05-15 08:26:13 +00:00
|
|
|
|
|
|
|
#include "nsContentUtils.h"
|
2012-07-27 14:03:27 +00:00
|
|
|
#include "nsError.h"
|
2008-08-07 23:15:40 +00:00
|
|
|
#include "nsStyleUtil.h"
|
2010-06-28 22:49:35 +00:00
|
|
|
#include "mozilla/css/Declaration.h"
|
2011-04-12 06:18:43 +00:00
|
|
|
#include "nsCSSParser.h"
|
2012-07-20 16:42:08 +00:00
|
|
|
#include "nsDOMClassInfoID.h"
|
2012-08-24 04:08:09 +00:00
|
|
|
#include "mozilla/dom/CSSStyleDeclarationBinding.h"
|
2012-08-31 21:21:28 +00:00
|
|
|
#include "StyleRule.h"
|
2013-05-20 02:59:20 +00:00
|
|
|
#include "nsFont.h"
|
2013-09-07 13:01:08 +00:00
|
|
|
#include "nsIURI.h"
|
2014-03-05 04:13:20 +00:00
|
|
|
#include "mozAutoDocUpdate.h"
|
1999-06-10 05:32:38 +00:00
|
|
|
|
2012-10-01 16:49:41 +00:00
|
|
|
using namespace mozilla;
|
2014-10-02 02:32:06 +00:00
|
|
|
using namespace mozilla::dom;
|
2011-03-17 17:41:52 +00:00
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
#define IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(class_, super_) \
|
2012-10-08 02:39:08 +00:00
|
|
|
/* virtual */ nsIDOMCSSRule* class_::GetDOMRule() \
|
|
|
|
{ return this; } \
|
|
|
|
/* virtual */ nsIDOMCSSRule* class_::GetExistingDOMRule() \
|
2011-04-08 06:36:09 +00:00
|
|
|
{ return this; }
|
2011-04-12 06:18:43 +00:00
|
|
|
#define IMPL_STYLE_RULE_INHERIT_MAP_RULE_INFO_INTO(class_, super_) \
|
|
|
|
/* virtual */ void class_::MapRuleInfoInto(nsRuleData* aRuleData) \
|
2015-02-09 22:34:50 +00:00
|
|
|
{ MOZ_ASSERT(false, "should not be called"); }
|
1999-06-10 05:32:38 +00:00
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
#define IMPL_STYLE_RULE_INHERIT(class_, super_) \
|
|
|
|
IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(class_, super_) \
|
|
|
|
IMPL_STYLE_RULE_INHERIT_MAP_RULE_INFO_INTO(class_, super_)
|
2011-03-29 03:21:20 +00:00
|
|
|
|
|
|
|
// base class for all rule types in a CSS style sheet
|
|
|
|
|
2011-03-07 03:59:03 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace css {
|
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet*
|
2012-09-30 16:40:24 +00:00
|
|
|
Rule::GetStyleSheet() const
|
|
|
|
{
|
|
|
|
if (!(mSheet & 0x1)) {
|
2014-06-20 10:32:49 +00:00
|
|
|
return reinterpret_cast<CSSStyleSheet*>(mSheet);
|
2012-09-30 16:40:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsHTMLCSSStyleSheet*
|
|
|
|
Rule::GetHTMLCSSStyleSheet() const
|
|
|
|
{
|
|
|
|
if (mSheet & 0x1) {
|
|
|
|
return reinterpret_cast<nsHTMLCSSStyleSheet*>(mSheet & ~uintptr_t(0x1));
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2011-03-29 03:21:20 +00:00
|
|
|
/* virtual */ void
|
2014-06-20 10:32:49 +00:00
|
|
|
Rule::SetStyleSheet(CSSStyleSheet* aSheet)
|
2011-03-29 03:21:20 +00:00
|
|
|
{
|
|
|
|
// We don't reference count this up reference. The style sheet
|
|
|
|
// will tell us when it's going away or when we're detached from
|
|
|
|
// it.
|
2012-09-30 16:40:24 +00:00
|
|
|
mSheet = reinterpret_cast<uintptr_t>(aSheet);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Rule::SetHTMLCSSStyleSheet(nsHTMLCSSStyleSheet* aSheet)
|
|
|
|
{
|
|
|
|
// We don't reference count this up reference. The style sheet
|
|
|
|
// will tell us when it's going away or when we're detached from
|
|
|
|
// it.
|
|
|
|
mSheet = reinterpret_cast<uintptr_t>(aSheet);
|
|
|
|
mSheet |= 0x1;
|
2011-03-29 03:21:20 +00:00
|
|
|
}
|
|
|
|
|
2011-04-12 02:46:35 +00:00
|
|
|
nsresult
|
|
|
|
Rule::GetParentRule(nsIDOMCSSRule** aParentRule)
|
|
|
|
{
|
|
|
|
if (mParentRule) {
|
2011-04-08 06:36:09 +00:00
|
|
|
NS_IF_ADDREF(*aParentRule = mParentRule->GetDOMRule());
|
|
|
|
} else {
|
2012-07-30 14:20:58 +00:00
|
|
|
*aParentRule = nullptr;
|
2011-04-12 02:46:35 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
Rule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSheet);
|
|
|
|
|
2012-09-30 16:40:24 +00:00
|
|
|
NS_IF_ADDREF(*aSheet = GetStyleSheet());
|
2011-04-12 02:46:35 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-07-14 22:57:46 +00:00
|
|
|
css::Rule*
|
|
|
|
Rule::GetCSSRule()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-01-03 02:19:14 +00:00
|
|
|
size_t
|
|
|
|
Rule::SizeOfCOMArrayElementIncludingThis(css::Rule* aElement,
|
2013-06-23 12:03:39 +00:00
|
|
|
MallocSizeOf aMallocSizeOf,
|
2012-01-03 02:19:14 +00:00
|
|
|
void* aData)
|
|
|
|
{
|
|
|
|
return aElement->SizeOfIncludingThis(aMallocSizeOf);
|
|
|
|
}
|
2011-03-29 03:21:20 +00:00
|
|
|
|
2001-09-05 00:00:18 +00:00
|
|
|
// -------------------------------
|
|
|
|
// Style Rule List for group rules
|
|
|
|
//
|
2010-08-08 05:23:17 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class GroupRuleRuleList final : public dom::CSSRuleList
|
2001-09-05 00:00:18 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 03:36:37 +00:00
|
|
|
explicit GroupRuleRuleList(GroupRule *aGroupRule);
|
2001-09-05 00:00:18 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual CSSStyleSheet* GetParentObject() override;
|
2001-09-05 00:00:18 +00:00
|
|
|
|
2013-07-24 07:27:17 +00:00
|
|
|
virtual nsIDOMCSSRule*
|
2015-03-21 16:28:04 +00:00
|
|
|
IndexedGetter(uint32_t aIndex, bool& aFound) override;
|
2013-07-24 07:27:17 +00:00
|
|
|
virtual uint32_t
|
2015-03-21 16:28:04 +00:00
|
|
|
Length() override;
|
2008-10-22 14:31:14 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
void DropReference() { mGroupRule = nullptr; }
|
2001-09-05 00:00:18 +00:00
|
|
|
|
2010-08-08 05:23:17 +00:00
|
|
|
private:
|
|
|
|
~GroupRuleRuleList();
|
2001-09-05 00:00:18 +00:00
|
|
|
|
|
|
|
private:
|
2010-08-08 05:28:33 +00:00
|
|
|
GroupRule* mGroupRule;
|
2001-09-05 00:00:18 +00:00
|
|
|
};
|
|
|
|
|
2010-08-08 05:28:33 +00:00
|
|
|
GroupRuleRuleList::GroupRuleRuleList(GroupRule *aGroupRule)
|
2001-09-05 00:00:18 +00:00
|
|
|
{
|
|
|
|
// Not reference counted to avoid circular references.
|
|
|
|
// The rule will tell us when its going away.
|
|
|
|
mGroupRule = aGroupRule;
|
|
|
|
}
|
|
|
|
|
2010-08-08 05:23:17 +00:00
|
|
|
GroupRuleRuleList::~GroupRuleRuleList()
|
2001-09-05 00:00:18 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet*
|
2014-05-03 07:32:54 +00:00
|
|
|
GroupRuleRuleList::GetParentObject()
|
|
|
|
{
|
|
|
|
if (!mGroupRule) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2001-09-05 00:00:18 +00:00
|
|
|
|
2014-05-03 07:32:54 +00:00
|
|
|
return mGroupRule->GetStyleSheet();
|
|
|
|
}
|
2001-09-05 00:00:18 +00:00
|
|
|
|
2013-07-24 07:27:17 +00:00
|
|
|
uint32_t
|
|
|
|
GroupRuleRuleList::Length()
|
2001-09-05 00:00:18 +00:00
|
|
|
{
|
2013-07-24 07:27:17 +00:00
|
|
|
if (!mGroupRule) {
|
|
|
|
return 0;
|
2001-09-05 00:00:18 +00:00
|
|
|
}
|
|
|
|
|
2014-08-25 19:17:32 +00:00
|
|
|
return AssertedCast<uint32_t>(mGroupRule->StyleRuleCount());
|
2001-09-05 00:00:18 +00:00
|
|
|
}
|
|
|
|
|
2010-08-08 05:23:17 +00:00
|
|
|
nsIDOMCSSRule*
|
2013-07-24 07:27:17 +00:00
|
|
|
GroupRuleRuleList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
2001-09-05 00:00:18 +00:00
|
|
|
{
|
2013-07-24 07:27:17 +00:00
|
|
|
aFound = false;
|
2001-09-05 00:00:18 +00:00
|
|
|
|
|
|
|
if (mGroupRule) {
|
2011-04-08 01:23:46 +00:00
|
|
|
nsRefPtr<Rule> rule = mGroupRule->GetStyleRuleAt(aIndex);
|
2001-09-05 00:00:18 +00:00
|
|
|
if (rule) {
|
2013-07-24 07:27:17 +00:00
|
|
|
aFound = true;
|
2011-04-08 06:36:09 +00:00
|
|
|
return rule->GetDOMRule();
|
2008-10-22 14:31:14 +00:00
|
|
|
}
|
2001-09-05 00:00:18 +00:00
|
|
|
}
|
2008-10-22 14:31:14 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2008-10-22 14:31:14 +00:00
|
|
|
}
|
|
|
|
|
1999-06-10 05:32:38 +00:00
|
|
|
// -------------------------------------------
|
2011-03-17 17:41:52 +00:00
|
|
|
// ImportRule
|
1999-06-10 05:32:38 +00:00
|
|
|
//
|
2011-03-17 17:41:52 +00:00
|
|
|
|
2014-07-14 22:57:54 +00:00
|
|
|
ImportRule::ImportRule(nsMediaList* aMedia, const nsString& aURLSpec,
|
|
|
|
uint32_t aLineNumber, uint32_t aColumnNumber)
|
|
|
|
: Rule(aLineNumber, aColumnNumber)
|
2011-03-23 05:22:59 +00:00
|
|
|
, mURLSpec(aURLSpec)
|
2005-03-30 00:36:57 +00:00
|
|
|
, mMedia(aMedia)
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2005-03-30 00:36:57 +00:00
|
|
|
// XXXbz This is really silly.... the mMedia here will be replaced
|
|
|
|
// with itself if we manage to load a sheet. Which should really
|
2004-01-10 02:27:41 +00:00
|
|
|
// never fail nowadays, in sane cases.
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2011-03-17 17:41:52 +00:00
|
|
|
ImportRule::ImportRule(const ImportRule& aCopy)
|
2011-03-07 03:59:03 +00:00
|
|
|
: Rule(aCopy),
|
2001-08-04 21:19:53 +00:00
|
|
|
mURLSpec(aCopy.mURLSpec)
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2011-03-30 03:46:12 +00:00
|
|
|
// Whether or not an @import rule has a null sheet is a permanent
|
|
|
|
// property of that @import rule, since it is null only if the target
|
|
|
|
// sheet failed security checks.
|
2001-08-04 21:19:53 +00:00
|
|
|
if (aCopy.mChildSheet) {
|
2014-06-20 10:32:49 +00:00
|
|
|
nsRefPtr<CSSStyleSheet> sheet =
|
2012-07-30 14:20:58 +00:00
|
|
|
aCopy.mChildSheet->Clone(nullptr, this, nullptr, nullptr);
|
2011-03-30 03:46:12 +00:00
|
|
|
SetSheet(sheet);
|
|
|
|
// SetSheet sets mMedia appropriately
|
2001-08-04 21:19:53 +00:00
|
|
|
}
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2011-03-17 17:41:52 +00:00
|
|
|
ImportRule::~ImportRule()
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2002-08-06 05:08:47 +00:00
|
|
|
if (mChildSheet) {
|
2012-07-30 14:20:58 +00:00
|
|
|
mChildSheet->SetOwnerRule(nullptr);
|
2002-08-06 05:08:47 +00:00
|
|
|
}
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 01:12:31 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(ImportRule)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(ImportRule)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION(ImportRule, mMedia, mChildSheet)
|
2010-01-12 13:08:43 +00:00
|
|
|
|
2011-03-17 17:41:52 +00:00
|
|
|
// QueryInterface implementation for ImportRule
|
2014-09-19 01:12:31 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ImportRule)
|
2001-05-15 08:26:13 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
|
2001-08-04 21:19:53 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSImportRule)
|
2011-04-08 01:23:46 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
|
2010-03-17 15:09:05 +00:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSImportRule)
|
2001-05-15 08:26:13 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
1999-06-10 05:32:38 +00:00
|
|
|
|
2011-03-07 03:59:03 +00:00
|
|
|
IMPL_STYLE_RULE_INHERIT(ImportRule, Rule)
|
1999-06-10 05:32:38 +00:00
|
|
|
|
2001-10-16 05:31:36 +00:00
|
|
|
#ifdef DEBUG
|
2010-05-20 02:28:00 +00:00
|
|
|
/* virtual */ void
|
2012-08-22 15:56:38 +00:00
|
|
|
ImportRule::List(FILE* out, int32_t aIndent) const
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2014-11-27 06:29:44 +00:00
|
|
|
nsAutoCString str;
|
1999-06-10 05:32:38 +00:00
|
|
|
// Indent
|
2014-11-27 06:29:44 +00:00
|
|
|
for (int32_t indent = aIndent; --indent >= 0; ) {
|
2014-11-27 06:29:44 +00:00
|
|
|
str.AppendLiteral(" ");
|
2014-11-27 06:29:44 +00:00
|
|
|
}
|
1999-06-10 05:32:38 +00:00
|
|
|
|
2014-11-27 06:29:44 +00:00
|
|
|
str.AppendLiteral("@import \"");
|
|
|
|
AppendUTF16toUTF8(mURLSpec, str);
|
|
|
|
str.AppendLiteral("\" ");
|
1999-06-10 05:32:38 +00:00
|
|
|
|
2001-08-04 21:19:53 +00:00
|
|
|
nsAutoString mediaText;
|
2001-09-05 00:00:18 +00:00
|
|
|
mMedia->GetText(mediaText);
|
2014-11-27 06:29:44 +00:00
|
|
|
AppendUTF16toUTF8(mediaText, str);
|
|
|
|
str.AppendLiteral("\n");
|
|
|
|
fprintf_stderr(out, "%s", str.get());
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
2001-10-16 05:31:36 +00:00
|
|
|
#endif
|
2000-03-31 07:08:36 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
/* virtual */ int32_t
|
2011-03-17 17:41:52 +00:00
|
|
|
ImportRule::GetType() const
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2011-04-08 01:23:46 +00:00
|
|
|
return Rule::IMPORT_RULE;
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2011-04-08 01:23:46 +00:00
|
|
|
/* virtual */ already_AddRefed<Rule>
|
2011-03-17 17:41:52 +00:00
|
|
|
ImportRule::Clone() const
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2011-04-08 01:23:46 +00:00
|
|
|
nsRefPtr<Rule> clone = new ImportRule(*this);
|
2010-08-15 15:19:34 +00:00
|
|
|
return clone.forget();
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2011-03-17 17:41:52 +00:00
|
|
|
void
|
2014-06-20 10:32:49 +00:00
|
|
|
ImportRule::SetSheet(CSSStyleSheet* aSheet)
|
2001-08-04 21:19:53 +00:00
|
|
|
{
|
2011-03-17 17:41:52 +00:00
|
|
|
NS_PRECONDITION(aSheet, "null arg");
|
|
|
|
|
2001-08-04 21:19:53 +00:00
|
|
|
// set the new sheet
|
|
|
|
mChildSheet = aSheet;
|
2002-08-06 05:08:47 +00:00
|
|
|
aSheet->SetOwnerRule(this);
|
2001-08-04 21:19:53 +00:00
|
|
|
|
|
|
|
// set our medialist to be the same as the sheet's medialist
|
2013-11-11 08:03:17 +00:00
|
|
|
mMedia = mChildSheet->Media();
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2001-05-15 08:26:13 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
ImportRule::GetType(uint16_t* aType)
|
2001-05-15 08:26:13 +00:00
|
|
|
{
|
2001-08-04 21:19:53 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aType);
|
2001-05-15 08:26:13 +00:00
|
|
|
*aType = nsIDOMCSSRule::IMPORT_RULE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-17 17:41:52 +00:00
|
|
|
ImportRule::GetCssText(nsAString& aCssText)
|
2001-05-15 08:26:13 +00:00
|
|
|
{
|
2004-06-17 00:13:25 +00:00
|
|
|
aCssText.AssignLiteral("@import url(");
|
2009-03-06 04:05:01 +00:00
|
|
|
nsStyleUtil::AppendEscapedCSSString(mURLSpec, aCssText);
|
2014-05-22 03:48:50 +00:00
|
|
|
aCssText.Append(')');
|
2001-08-04 21:19:53 +00:00
|
|
|
if (mMedia) {
|
|
|
|
nsAutoString mediaText;
|
2001-09-05 00:00:18 +00:00
|
|
|
mMedia->GetText(mediaText);
|
2001-08-04 21:19:53 +00:00
|
|
|
if (!mediaText.IsEmpty()) {
|
2014-05-22 03:48:51 +00:00
|
|
|
aCssText.Append(' ');
|
2001-08-04 21:19:53 +00:00
|
|
|
aCssText.Append(mediaText);
|
|
|
|
}
|
|
|
|
}
|
2014-05-22 03:48:51 +00:00
|
|
|
aCssText.Append(';');
|
2001-05-15 08:26:13 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-17 17:41:52 +00:00
|
|
|
ImportRule::SetCssText(const nsAString& aCssText)
|
2001-05-15 08:26:13 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-17 17:41:52 +00:00
|
|
|
ImportRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
|
2001-05-15 08:26:13 +00:00
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return Rule::GetParentStyleSheet(aSheet);
|
2001-05-15 08:26:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-17 17:41:52 +00:00
|
|
|
ImportRule::GetParentRule(nsIDOMCSSRule** aParentRule)
|
2001-05-15 08:26:13 +00:00
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return Rule::GetParentRule(aParentRule);
|
2001-05-15 08:26:13 +00:00
|
|
|
}
|
|
|
|
|
2014-07-14 22:57:46 +00:00
|
|
|
css::Rule*
|
|
|
|
ImportRule::GetCSSRule()
|
|
|
|
{
|
|
|
|
return Rule::GetCSSRule();
|
|
|
|
}
|
|
|
|
|
2001-08-04 21:19:53 +00:00
|
|
|
NS_IMETHODIMP
|
2011-03-17 17:41:52 +00:00
|
|
|
ImportRule::GetHref(nsAString & aHref)
|
2001-08-04 21:19:53 +00:00
|
|
|
{
|
|
|
|
aHref = mURLSpec;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-17 17:41:52 +00:00
|
|
|
ImportRule::GetMedia(nsIDOMMediaList * *aMedia)
|
2001-08-04 21:19:53 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aMedia);
|
|
|
|
|
2010-07-18 20:23:12 +00:00
|
|
|
NS_IF_ADDREF(*aMedia = mMedia);
|
|
|
|
return NS_OK;
|
2001-08-04 21:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-17 17:41:52 +00:00
|
|
|
ImportRule::GetStyleSheet(nsIDOMCSSStyleSheet * *aStyleSheet)
|
2001-08-04 21:19:53 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aStyleSheet);
|
|
|
|
|
2010-05-31 23:51:40 +00:00
|
|
|
NS_IF_ADDREF(*aStyleSheet = mChildSheet);
|
|
|
|
return NS_OK;
|
2001-08-04 21:19:53 +00:00
|
|
|
}
|
2001-05-15 08:26:13 +00:00
|
|
|
|
2012-01-03 02:19:14 +00:00
|
|
|
/* virtual */ size_t
|
2013-06-23 12:03:39 +00:00
|
|
|
ImportRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
2012-01-03 02:19:14 +00:00
|
|
|
{
|
|
|
|
return aMallocSizeOf(this);
|
|
|
|
|
|
|
|
// Measurement of the following members may be added later if DMD finds it is
|
|
|
|
// worthwhile:
|
|
|
|
// - mURLSpec
|
|
|
|
//
|
|
|
|
// The following members are not measured:
|
2014-06-20 10:32:49 +00:00
|
|
|
// - mMedia, because it is measured via CSSStyleSheet::mMedia
|
|
|
|
// - mChildSheet, because it is measured via CSSStyleSheetInner::mSheets
|
2012-01-03 02:19:14 +00:00
|
|
|
}
|
|
|
|
|
2014-07-14 22:57:54 +00:00
|
|
|
GroupRule::GroupRule(uint32_t aLineNumber, uint32_t aColumnNumber)
|
|
|
|
: Rule(aLineNumber, aColumnNumber)
|
2010-08-08 05:28:33 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool
|
2011-04-08 01:23:46 +00:00
|
|
|
SetParentRuleReference(Rule* aRule, void* aParentRule)
|
2001-09-19 14:16:34 +00:00
|
|
|
{
|
2010-08-08 05:28:33 +00:00
|
|
|
GroupRule* parentRule = static_cast<GroupRule*>(aParentRule);
|
2005-10-15 20:21:20 +00:00
|
|
|
aRule->SetParentRule(parentRule);
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-09-19 14:16:34 +00:00
|
|
|
}
|
|
|
|
|
2010-08-08 05:28:33 +00:00
|
|
|
GroupRule::GroupRule(const GroupRule& aCopy)
|
2011-03-07 03:59:03 +00:00
|
|
|
: Rule(aCopy)
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2013-11-15 02:42:57 +00:00
|
|
|
const_cast<GroupRule&>(aCopy).mRules.EnumerateForwards(GroupRule::CloneRuleInto, &mRules);
|
2005-10-15 20:21:20 +00:00
|
|
|
mRules.EnumerateForwards(SetParentRuleReference, this);
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2010-08-08 05:28:33 +00:00
|
|
|
GroupRule::~GroupRule()
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(!mSheet, "SetStyleSheet should have been called");
|
2012-07-30 14:20:58 +00:00
|
|
|
mRules.EnumerateForwards(SetParentRuleReference, nullptr);
|
2001-09-05 00:00:18 +00:00
|
|
|
if (mRuleCollection) {
|
|
|
|
mRuleCollection->DropReference();
|
|
|
|
}
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2012-10-08 02:39:09 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(GroupRule)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(GroupRule)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(GroupRule)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
IMPL_STYLE_RULE_INHERIT_MAP_RULE_INFO_INTO(GroupRule, Rule)
|
1999-06-10 05:32:38 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool
|
2011-04-08 01:23:46 +00:00
|
|
|
SetStyleSheetReference(Rule* aRule, void* aSheet)
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* sheet = (CSSStyleSheet*)aSheet;
|
2005-10-15 20:21:20 +00:00
|
|
|
aRule->SetStyleSheet(sheet);
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2013-08-02 01:29:05 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(GroupRule)
|
|
|
|
|
2012-10-08 02:39:09 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(GroupRule)
|
|
|
|
tmp->mRules.EnumerateForwards(SetParentRuleReference, nullptr);
|
|
|
|
// If tmp does not have a stylesheet, neither do its descendants. In that
|
|
|
|
// case, don't try to null out their stylesheet, to avoid O(N^2) behavior in
|
|
|
|
// depth of group rule nesting. But if tmp _does_ have a stylesheet (which
|
|
|
|
// can happen if it gets unlinked earlier than its owning stylesheet), then we
|
|
|
|
// need to null out the stylesheet pointer on descendants now, before we clear
|
|
|
|
// tmp->mRules.
|
|
|
|
if (tmp->GetStyleSheet()) {
|
|
|
|
tmp->mRules.EnumerateForwards(SetStyleSheetReference, nullptr);
|
|
|
|
}
|
|
|
|
tmp->mRules.Clear();
|
|
|
|
if (tmp->mRuleCollection) {
|
|
|
|
tmp->mRuleCollection->DropReference();
|
|
|
|
tmp->mRuleCollection = nullptr;
|
|
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(GroupRule)
|
|
|
|
const nsCOMArray<Rule>& rules = tmp->mRules;
|
|
|
|
for (int32_t i = 0, count = rules.Count(); i < count; ++i) {
|
|
|
|
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mRules[i]");
|
|
|
|
cb.NoteXPCOMChild(rules[i]->GetExistingDOMRule());
|
|
|
|
}
|
2012-11-15 07:32:40 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRuleCollection)
|
2012-10-08 02:39:09 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2010-07-18 14:39:20 +00:00
|
|
|
/* virtual */ void
|
2014-06-20 10:32:49 +00:00
|
|
|
GroupRule::SetStyleSheet(CSSStyleSheet* aSheet)
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2012-10-08 02:39:09 +00:00
|
|
|
// Don't set the sheet on the kids if it's already the same as the sheet we
|
|
|
|
// already have. This is needed to avoid O(N^2) behavior in group nesting
|
|
|
|
// depth when seting the sheet to null during unlink, if we happen to unlin in
|
|
|
|
// order from most nested rule up to least nested rule.
|
|
|
|
if (aSheet != GetStyleSheet()) {
|
|
|
|
mRules.EnumerateForwards(SetStyleSheetReference, aSheet);
|
|
|
|
Rule::SetStyleSheet(aSheet);
|
|
|
|
}
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2001-10-16 05:31:36 +00:00
|
|
|
#ifdef DEBUG
|
2010-05-20 02:28:00 +00:00
|
|
|
/* virtual */ void
|
2012-08-22 15:56:38 +00:00
|
|
|
GroupRule::List(FILE* out, int32_t aIndent) const
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t index = 0, count = mRules.Count(); index < count; ++index) {
|
2005-10-15 20:21:20 +00:00
|
|
|
mRules.ObjectAt(index)->List(out, aIndent + 1);
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
}
|
2001-10-16 05:31:36 +00:00
|
|
|
#endif
|
2000-03-31 07:08:36 +00:00
|
|
|
|
2010-08-08 05:29:28 +00:00
|
|
|
void
|
2011-04-08 01:23:46 +00:00
|
|
|
GroupRule::AppendStyleRule(Rule* aRule)
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2005-10-15 20:21:20 +00:00
|
|
|
mRules.AppendObject(aRule);
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* sheet = GetStyleSheet();
|
2012-09-30 16:40:24 +00:00
|
|
|
aRule->SetStyleSheet(sheet);
|
2005-10-15 20:21:20 +00:00
|
|
|
aRule->SetParentRule(this);
|
2012-09-30 16:40:24 +00:00
|
|
|
if (sheet) {
|
|
|
|
sheet->SetModifiedByChildRule();
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-08 01:23:46 +00:00
|
|
|
Rule*
|
2012-08-22 15:56:38 +00:00
|
|
|
GroupRule::GetStyleRuleAt(int32_t aIndex) const
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2010-08-08 05:29:28 +00:00
|
|
|
return mRules.SafeObjectAt(aIndex);
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2010-08-08 05:28:33 +00:00
|
|
|
GroupRule::EnumerateRulesForwards(RuleEnumFunc aFunc, void * aData) const
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2007-12-14 22:59:20 +00:00
|
|
|
return
|
2010-08-08 05:28:33 +00:00
|
|
|
const_cast<GroupRule*>(this)->mRules.EnumerateForwards(aFunc, aData);
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2001-09-05 00:00:18 +00:00
|
|
|
/*
|
2013-02-10 06:56:49 +00:00
|
|
|
* The next two methods (DeleteStyleRuleAt and InsertStyleRuleAt)
|
2001-09-05 00:00:18 +00:00
|
|
|
* should never be called unless you have first called WillDirty() on
|
2012-11-27 05:30:31 +00:00
|
|
|
* the parents stylesheet. After they are called, DidDirty() needs to
|
2001-09-05 00:00:18 +00:00
|
|
|
* be called on the sheet
|
|
|
|
*/
|
2010-08-08 05:29:28 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
GroupRule::DeleteStyleRuleAt(uint32_t aIndex)
|
2001-09-05 00:00:18 +00:00
|
|
|
{
|
2011-04-08 01:23:46 +00:00
|
|
|
Rule* rule = mRules.SafeObjectAt(aIndex);
|
2001-09-06 13:14:35 +00:00
|
|
|
if (rule) {
|
2012-07-30 14:20:58 +00:00
|
|
|
rule->SetStyleSheet(nullptr);
|
|
|
|
rule->SetParentRule(nullptr);
|
2001-09-06 13:14:35 +00:00
|
|
|
}
|
2005-10-15 20:21:20 +00:00
|
|
|
return mRules.RemoveObjectAt(aIndex) ? NS_OK : NS_ERROR_ILLEGAL_VALUE;
|
2001-09-05 00:00:18 +00:00
|
|
|
}
|
|
|
|
|
2010-08-08 05:29:28 +00:00
|
|
|
nsresult
|
2013-02-10 06:56:49 +00:00
|
|
|
GroupRule::InsertStyleRuleAt(uint32_t aIndex, Rule* aRule)
|
2001-09-05 00:00:18 +00:00
|
|
|
{
|
2013-02-10 06:56:49 +00:00
|
|
|
aRule->SetStyleSheet(GetStyleSheet());
|
|
|
|
aRule->SetParentRule(this);
|
|
|
|
if (! mRules.InsertObjectAt(aRule, aIndex)) {
|
2001-09-05 00:00:18 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-08 05:29:28 +00:00
|
|
|
nsresult
|
2011-04-08 01:23:46 +00:00
|
|
|
GroupRule::ReplaceStyleRule(Rule* aOld, Rule* aNew)
|
2003-06-18 01:59:57 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t index = mRules.IndexOf(aOld);
|
2003-06-18 01:59:57 +00:00
|
|
|
NS_ENSURE_TRUE(index != -1, NS_ERROR_UNEXPECTED);
|
2005-10-15 20:21:20 +00:00
|
|
|
mRules.ReplaceObjectAt(aNew, index);
|
2012-09-30 16:40:24 +00:00
|
|
|
aNew->SetStyleSheet(GetStyleSheet());
|
2003-06-18 01:59:57 +00:00
|
|
|
aNew->SetParentRule(this);
|
2012-07-30 14:20:58 +00:00
|
|
|
aOld->SetStyleSheet(nullptr);
|
|
|
|
aOld->SetParentRule(nullptr);
|
2003-06-18 01:59:57 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-06-10 05:32:38 +00:00
|
|
|
|
2013-08-02 07:04:31 +00:00
|
|
|
void
|
2010-08-08 05:28:33 +00:00
|
|
|
GroupRule::AppendRulesToCssText(nsAString& aCssText)
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2004-06-17 00:13:25 +00:00
|
|
|
aCssText.AppendLiteral(" {\n");
|
2001-05-15 08:26:13 +00:00
|
|
|
|
|
|
|
// get all the rules
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t index = 0, count = mRules.Count(); index < count; ++index) {
|
2011-04-08 01:23:46 +00:00
|
|
|
Rule* rule = mRules.ObjectAt(index);
|
2011-04-08 06:36:09 +00:00
|
|
|
nsIDOMCSSRule* domRule = rule->GetDOMRule();
|
2005-10-15 20:21:20 +00:00
|
|
|
if (domRule) {
|
|
|
|
nsAutoString cssText;
|
|
|
|
domRule->GetCssText(cssText);
|
2014-05-22 03:48:50 +00:00
|
|
|
aCssText.AppendLiteral(" ");
|
|
|
|
aCssText.Append(cssText);
|
|
|
|
aCssText.Append('\n');
|
2001-05-15 08:26:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-22 03:48:51 +00:00
|
|
|
aCssText.Append('}');
|
2001-05-15 08:26:13 +00:00
|
|
|
}
|
|
|
|
|
2004-08-05 18:26:14 +00:00
|
|
|
// nsIDOMCSSMediaRule or nsIDOMCSSMozDocumentRule methods
|
2011-04-12 02:46:35 +00:00
|
|
|
nsresult
|
|
|
|
GroupRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
|
2001-09-05 00:00:18 +00:00
|
|
|
{
|
|
|
|
if (!mRuleCollection) {
|
2010-08-08 05:23:17 +00:00
|
|
|
mRuleCollection = new css::GroupRuleRuleList(this);
|
2001-09-05 00:00:18 +00:00
|
|
|
}
|
|
|
|
|
2011-04-12 02:46:35 +00:00
|
|
|
NS_ADDREF(*aRuleList = mRuleCollection);
|
|
|
|
return NS_OK;
|
2001-09-05 00:00:18 +00:00
|
|
|
}
|
|
|
|
|
2004-08-05 18:26:14 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
GroupRule::InsertRule(const nsAString & aRule, uint32_t aIndex, uint32_t* _retval)
|
2001-09-05 00:00:18 +00:00
|
|
|
{
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* sheet = GetStyleSheet();
|
2012-09-30 16:40:24 +00:00
|
|
|
NS_ENSURE_TRUE(sheet, NS_ERROR_FAILURE);
|
2001-09-05 00:00:18 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
if (aIndex > uint32_t(mRules.Count()))
|
2001-09-05 00:00:18 +00:00
|
|
|
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
2005-10-15 20:21:20 +00:00
|
|
|
|
2012-09-28 06:57:33 +00:00
|
|
|
NS_ASSERTION(uint32_t(mRules.Count()) <= INT32_MAX,
|
2005-10-15 20:21:20 +00:00
|
|
|
"Too many style rules!");
|
|
|
|
|
2012-09-30 16:40:24 +00:00
|
|
|
return sheet->InsertRuleIntoGroup(aRule, this, aIndex, _retval);
|
2001-09-05 00:00:18 +00:00
|
|
|
}
|
|
|
|
|
2004-08-05 18:26:14 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
GroupRule::DeleteRule(uint32_t aIndex)
|
2001-09-05 00:00:18 +00:00
|
|
|
{
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* sheet = GetStyleSheet();
|
2012-09-30 16:40:24 +00:00
|
|
|
NS_ENSURE_TRUE(sheet, NS_ERROR_FAILURE);
|
2005-10-15 20:21:20 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
if (aIndex >= uint32_t(mRules.Count()))
|
2001-09-05 00:00:18 +00:00
|
|
|
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
|
|
|
|
2012-09-28 06:57:33 +00:00
|
|
|
NS_ASSERTION(uint32_t(mRules.Count()) <= INT32_MAX,
|
2005-10-15 20:21:20 +00:00
|
|
|
"Too many style rules!");
|
|
|
|
|
2012-09-30 16:40:24 +00:00
|
|
|
return sheet->DeleteRuleFromGroup(this, aIndex);
|
2001-09-05 00:00:18 +00:00
|
|
|
}
|
1999-06-10 05:32:38 +00:00
|
|
|
|
2012-01-03 02:19:14 +00:00
|
|
|
/* virtual */ size_t
|
2013-06-23 12:03:39 +00:00
|
|
|
GroupRule::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
2012-01-03 02:19:14 +00:00
|
|
|
{
|
|
|
|
return mRules.SizeOfExcludingThis(Rule::SizeOfCOMArrayElementIncludingThis,
|
|
|
|
aMallocSizeOf);
|
|
|
|
|
|
|
|
// Measurement of the following members may be added later if DMD finds it is
|
|
|
|
// worthwhile:
|
|
|
|
// - mRuleCollection
|
|
|
|
}
|
|
|
|
|
2010-08-08 05:28:33 +00:00
|
|
|
|
2004-08-05 18:26:14 +00:00
|
|
|
// -------------------------------------------
|
|
|
|
// nsICSSMediaRule
|
|
|
|
//
|
2014-07-14 22:57:54 +00:00
|
|
|
MediaRule::MediaRule(uint32_t aLineNumber, uint32_t aColumnNumber)
|
|
|
|
: GroupRule(aLineNumber, aColumnNumber)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-03-18 05:18:08 +00:00
|
|
|
MediaRule::MediaRule(const MediaRule& aCopy)
|
2010-08-08 05:28:33 +00:00
|
|
|
: GroupRule(aCopy)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
|
|
|
if (aCopy.mMedia) {
|
2013-11-11 08:00:55 +00:00
|
|
|
mMedia = aCopy.mMedia->Clone();
|
|
|
|
// XXXldb This doesn't really make sense.
|
|
|
|
mMedia->SetStyleSheet(aCopy.GetStyleSheet());
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-18 05:18:08 +00:00
|
|
|
MediaRule::~MediaRule()
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
|
|
|
if (mMedia) {
|
2012-07-30 14:20:58 +00:00
|
|
|
mMedia->SetStyleSheet(nullptr);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-06 07:33:57 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(MediaRule, GroupRule)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(MediaRule, GroupRule)
|
2004-08-05 18:26:14 +00:00
|
|
|
|
2011-03-18 05:18:08 +00:00
|
|
|
// QueryInterface implementation for MediaRule
|
|
|
|
NS_INTERFACE_MAP_BEGIN(MediaRule)
|
2004-08-05 18:26:14 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
|
2012-11-27 05:30:30 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSGroupingRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSConditionRule)
|
2004-08-05 18:26:14 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSMediaRule)
|
2011-04-08 01:23:46 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
|
2010-03-17 15:09:05 +00:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSMediaRule)
|
2012-10-08 02:39:09 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(GroupRule)
|
2004-08-05 18:26:14 +00:00
|
|
|
|
2010-07-18 14:39:20 +00:00
|
|
|
/* virtual */ void
|
2014-06-20 10:32:49 +00:00
|
|
|
MediaRule::SetStyleSheet(CSSStyleSheet* aSheet)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
|
|
|
if (mMedia) {
|
2005-03-30 00:36:57 +00:00
|
|
|
// Set to null so it knows it's leaving one sheet and joining another.
|
2012-07-30 14:20:58 +00:00
|
|
|
mMedia->SetStyleSheet(nullptr);
|
2005-03-30 00:36:57 +00:00
|
|
|
mMedia->SetStyleSheet(aSheet);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
2010-08-08 05:28:33 +00:00
|
|
|
GroupRule::SetStyleSheet(aSheet);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2010-05-20 02:28:00 +00:00
|
|
|
/* virtual */ void
|
2012-08-22 15:56:38 +00:00
|
|
|
MediaRule::List(FILE* out, int32_t aIndent) const
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2014-11-27 06:29:44 +00:00
|
|
|
nsAutoCString indentStr;
|
2014-11-27 06:29:44 +00:00
|
|
|
for (int32_t indent = aIndent; --indent >= 0; ) {
|
2014-11-27 06:29:44 +00:00
|
|
|
indentStr.AppendLiteral(" ");
|
2014-11-27 06:29:44 +00:00
|
|
|
}
|
2004-08-05 18:26:14 +00:00
|
|
|
|
2014-11-27 06:29:44 +00:00
|
|
|
nsAutoCString str(indentStr);
|
|
|
|
str.AppendLiteral("@media ");
|
2004-08-05 18:26:14 +00:00
|
|
|
|
|
|
|
if (mMedia) {
|
2005-03-30 00:36:57 +00:00
|
|
|
nsAutoString mediaText;
|
|
|
|
mMedia->GetText(mediaText);
|
2014-11-27 06:29:44 +00:00
|
|
|
AppendUTF16toUTF8(mediaText, str);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
2014-11-27 06:29:44 +00:00
|
|
|
str.AppendLiteral(" {\n");
|
|
|
|
fprintf_stderr(out, "%s", str.get());
|
|
|
|
|
2010-08-08 05:28:33 +00:00
|
|
|
GroupRule::List(out, aIndent);
|
2014-11-27 06:29:44 +00:00
|
|
|
|
|
|
|
fprintf_stderr(out, "%s}\n", indentStr.get());
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
/* virtual */ int32_t
|
2011-03-18 05:18:08 +00:00
|
|
|
MediaRule::GetType() const
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2011-04-08 01:23:46 +00:00
|
|
|
return Rule::MEDIA_RULE;
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
2011-04-08 01:23:46 +00:00
|
|
|
/* virtual */ already_AddRefed<Rule>
|
2011-03-18 05:18:08 +00:00
|
|
|
MediaRule::Clone() const
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2011-04-08 01:23:46 +00:00
|
|
|
nsRefPtr<Rule> clone = new MediaRule(*this);
|
2010-08-15 15:19:34 +00:00
|
|
|
return clone.forget();
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2011-03-18 05:18:08 +00:00
|
|
|
MediaRule::SetMedia(nsMediaList* aMedia)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2005-03-30 00:36:57 +00:00
|
|
|
mMedia = aMedia;
|
|
|
|
if (aMedia)
|
2012-09-30 16:40:24 +00:00
|
|
|
mMedia->SetStyleSheet(GetStyleSheet());
|
2005-03-30 00:36:57 +00:00
|
|
|
return NS_OK;
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// nsIDOMCSSRule methods
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
MediaRule::GetType(uint16_t* aType)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
|
|
|
*aType = nsIDOMCSSRule::MEDIA_RULE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-18 05:18:08 +00:00
|
|
|
MediaRule::GetCssText(nsAString& aCssText)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
|
|
|
aCssText.AssignLiteral("@media ");
|
2012-11-27 05:30:30 +00:00
|
|
|
AppendConditionText(aCssText);
|
2013-08-02 07:04:31 +00:00
|
|
|
GroupRule::AppendRulesToCssText(aCssText);
|
|
|
|
return NS_OK;
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-18 05:18:08 +00:00
|
|
|
MediaRule::SetCssText(const nsAString& aCssText)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-18 05:18:08 +00:00
|
|
|
MediaRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return GroupRule::GetParentStyleSheet(aSheet);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-18 05:18:08 +00:00
|
|
|
MediaRule::GetParentRule(nsIDOMCSSRule** aParentRule)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2010-08-08 05:28:33 +00:00
|
|
|
return GroupRule::GetParentRule(aParentRule);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
2014-07-14 22:57:46 +00:00
|
|
|
css::Rule*
|
|
|
|
MediaRule::GetCSSRule()
|
|
|
|
{
|
|
|
|
return Rule::GetCSSRule();
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:30:30 +00:00
|
|
|
// nsIDOMCSSGroupingRule methods
|
2004-08-05 18:26:14 +00:00
|
|
|
NS_IMETHODIMP
|
2011-03-18 05:18:08 +00:00
|
|
|
MediaRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return GroupRule::GetCssRules(aRuleList);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
MediaRule::InsertRule(const nsAString & aRule, uint32_t aIndex, uint32_t* _retval)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2010-08-08 05:28:33 +00:00
|
|
|
return GroupRule::InsertRule(aRule, aIndex, _retval);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
MediaRule::DeleteRule(uint32_t aIndex)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2010-08-08 05:28:33 +00:00
|
|
|
return GroupRule::DeleteRule(aIndex);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
2012-11-27 05:30:30 +00:00
|
|
|
// nsIDOMCSSConditionRule methods
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MediaRule::GetConditionText(nsAString& aConditionText)
|
|
|
|
{
|
|
|
|
aConditionText.Truncate(0);
|
|
|
|
AppendConditionText(aConditionText);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MediaRule::SetConditionText(const nsAString& aConditionText)
|
|
|
|
{
|
2012-11-27 05:30:31 +00:00
|
|
|
if (!mMedia) {
|
|
|
|
nsRefPtr<nsMediaList> media = new nsMediaList();
|
|
|
|
media->SetStyleSheet(GetStyleSheet());
|
|
|
|
nsresult rv = media->SetMediaText(aConditionText);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mMedia = media;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mMedia->SetMediaText(aConditionText);
|
2012-11-27 05:30:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// nsIDOMCSSMediaRule methods
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MediaRule::GetMedia(nsIDOMMediaList* *aMedia)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aMedia);
|
|
|
|
NS_IF_ADDREF(*aMedia = mMedia);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-08 05:28:33 +00:00
|
|
|
// GroupRule interface
|
2011-09-29 06:19:26 +00:00
|
|
|
/* virtual */ bool
|
2011-03-18 05:18:08 +00:00
|
|
|
MediaRule::UseForPresentation(nsPresContext* aPresContext,
|
2008-07-26 16:14:48 +00:00
|
|
|
nsMediaQueryResultCacheKey& aKey)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
|
|
|
if (mMedia) {
|
2011-04-22 03:17:31 +00:00
|
|
|
return mMedia->Matches(aPresContext, &aKey);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
2012-01-03 02:19:14 +00:00
|
|
|
/* virtual */ size_t
|
2013-06-23 12:03:39 +00:00
|
|
|
MediaRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
2012-01-03 02:19:14 +00:00
|
|
|
{
|
|
|
|
size_t n = aMallocSizeOf(this);
|
|
|
|
n += GroupRule::SizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
|
|
|
|
// Measurement of the following members may be added later if DMD finds it is
|
|
|
|
// worthwhile:
|
|
|
|
// - mMedia
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:30:30 +00:00
|
|
|
void
|
|
|
|
MediaRule::AppendConditionText(nsAString& aOutput)
|
|
|
|
{
|
|
|
|
if (mMedia) {
|
|
|
|
nsAutoString mediaText;
|
|
|
|
mMedia->GetText(mediaText);
|
|
|
|
aOutput.Append(mediaText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-14 22:57:54 +00:00
|
|
|
DocumentRule::DocumentRule(uint32_t aLineNumber, uint32_t aColumnNumber)
|
|
|
|
: GroupRule(aLineNumber, aColumnNumber)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-03-18 05:18:08 +00:00
|
|
|
DocumentRule::DocumentRule(const DocumentRule& aCopy)
|
2010-08-08 05:28:33 +00:00
|
|
|
: GroupRule(aCopy)
|
2004-08-05 18:26:14 +00:00
|
|
|
, mURLs(new URL(*aCopy.mURLs))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-03-18 05:18:08 +00:00
|
|
|
DocumentRule::~DocumentRule()
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-05-06 07:33:57 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(DocumentRule, GroupRule)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(DocumentRule, GroupRule)
|
2004-08-05 18:26:14 +00:00
|
|
|
|
2011-03-18 05:18:08 +00:00
|
|
|
// QueryInterface implementation for DocumentRule
|
|
|
|
NS_INTERFACE_MAP_BEGIN(DocumentRule)
|
2004-08-05 18:26:14 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
|
2012-11-27 05:30:30 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSGroupingRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSConditionRule)
|
2004-08-05 18:26:14 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSMozDocumentRule)
|
2011-04-08 01:23:46 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
|
2010-03-17 15:09:05 +00:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSMozDocumentRule)
|
2012-10-08 02:39:09 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(GroupRule)
|
2004-08-05 18:26:14 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2010-05-20 02:28:00 +00:00
|
|
|
/* virtual */ void
|
2012-08-22 15:56:38 +00:00
|
|
|
DocumentRule::List(FILE* out, int32_t aIndent) const
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2014-11-27 06:29:44 +00:00
|
|
|
nsAutoCString indentStr;
|
2014-11-27 06:29:44 +00:00
|
|
|
for (int32_t indent = aIndent; --indent >= 0; ) {
|
2014-11-27 06:29:44 +00:00
|
|
|
indentStr.AppendLiteral(" ");
|
2014-11-27 06:29:44 +00:00
|
|
|
}
|
2004-08-05 18:26:14 +00:00
|
|
|
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString str;
|
2014-11-27 06:29:44 +00:00
|
|
|
str.AppendLiteral("@-moz-document ");
|
2004-08-05 18:26:14 +00:00
|
|
|
for (URL *url = mURLs; url; url = url->next) {
|
|
|
|
switch (url->func) {
|
|
|
|
case eURL:
|
|
|
|
str.AppendLiteral("url(\"");
|
|
|
|
break;
|
|
|
|
case eURLPrefix:
|
|
|
|
str.AppendLiteral("url-prefix(\"");
|
|
|
|
break;
|
|
|
|
case eDomain:
|
|
|
|
str.AppendLiteral("domain(\"");
|
2011-06-13 01:52:32 +00:00
|
|
|
break;
|
2011-04-28 17:21:37 +00:00
|
|
|
case eRegExp:
|
|
|
|
str.AppendLiteral("regexp(\"");
|
2004-08-05 18:26:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString escapedURL(url->url);
|
2004-08-05 18:26:14 +00:00
|
|
|
escapedURL.ReplaceSubstring("\"", "\\\""); // escape quotes
|
|
|
|
str.Append(escapedURL);
|
|
|
|
str.AppendLiteral("\"), ");
|
|
|
|
}
|
|
|
|
str.Cut(str.Length() - 2, 1); // remove last ,
|
2014-11-27 06:29:44 +00:00
|
|
|
fprintf_stderr(out, "%s%s {\n", indentStr.get(), str.get());
|
2004-08-05 18:26:14 +00:00
|
|
|
|
2010-08-08 05:28:33 +00:00
|
|
|
GroupRule::List(out, aIndent);
|
2014-11-27 06:29:44 +00:00
|
|
|
|
|
|
|
fprintf_stderr(out, "%s}\n", indentStr.get());
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
/* virtual */ int32_t
|
2011-03-18 05:18:08 +00:00
|
|
|
DocumentRule::GetType() const
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2011-04-08 01:23:46 +00:00
|
|
|
return Rule::DOCUMENT_RULE;
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
2011-04-08 01:23:46 +00:00
|
|
|
/* virtual */ already_AddRefed<Rule>
|
2011-03-18 05:18:08 +00:00
|
|
|
DocumentRule::Clone() const
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2011-04-08 01:23:46 +00:00
|
|
|
nsRefPtr<Rule> clone = new DocumentRule(*this);
|
2010-08-15 15:19:34 +00:00
|
|
|
return clone.forget();
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// nsIDOMCSSRule methods
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
DocumentRule::GetType(uint16_t* aType)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
|
|
|
// XXX What should really happen here?
|
|
|
|
*aType = nsIDOMCSSRule::UNKNOWN_RULE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-18 05:18:08 +00:00
|
|
|
DocumentRule::GetCssText(nsAString& aCssText)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
|
|
|
aCssText.AssignLiteral("@-moz-document ");
|
2012-11-27 05:30:30 +00:00
|
|
|
AppendConditionText(aCssText);
|
2013-08-02 07:04:31 +00:00
|
|
|
GroupRule::AppendRulesToCssText(aCssText);
|
|
|
|
return NS_OK;
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-18 05:18:08 +00:00
|
|
|
DocumentRule::SetCssText(const nsAString& aCssText)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-18 05:18:08 +00:00
|
|
|
DocumentRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return GroupRule::GetParentStyleSheet(aSheet);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-18 05:18:08 +00:00
|
|
|
DocumentRule::GetParentRule(nsIDOMCSSRule** aParentRule)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2010-08-08 05:28:33 +00:00
|
|
|
return GroupRule::GetParentRule(aParentRule);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
2014-07-14 22:57:46 +00:00
|
|
|
css::Rule*
|
|
|
|
DocumentRule::GetCSSRule()
|
|
|
|
{
|
|
|
|
return Rule::GetCSSRule();
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:30:30 +00:00
|
|
|
// nsIDOMCSSGroupingRule methods
|
2004-08-05 18:26:14 +00:00
|
|
|
NS_IMETHODIMP
|
2011-03-18 05:18:08 +00:00
|
|
|
DocumentRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return GroupRule::GetCssRules(aRuleList);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
DocumentRule::InsertRule(const nsAString & aRule, uint32_t aIndex, uint32_t* _retval)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2010-08-08 05:28:33 +00:00
|
|
|
return GroupRule::InsertRule(aRule, aIndex, _retval);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
DocumentRule::DeleteRule(uint32_t aIndex)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2010-08-08 05:28:33 +00:00
|
|
|
return GroupRule::DeleteRule(aIndex);
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
2012-11-27 05:30:30 +00:00
|
|
|
// nsIDOMCSSConditionRule methods
|
|
|
|
NS_IMETHODIMP
|
|
|
|
DocumentRule::GetConditionText(nsAString& aConditionText)
|
|
|
|
{
|
|
|
|
aConditionText.Truncate(0);
|
|
|
|
AppendConditionText(aConditionText);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
DocumentRule::SetConditionText(const nsAString& aConditionText)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-08-08 05:28:33 +00:00
|
|
|
// GroupRule interface
|
2011-09-29 06:19:26 +00:00
|
|
|
/* virtual */ bool
|
2011-03-18 05:18:08 +00:00
|
|
|
DocumentRule::UseForPresentation(nsPresContext* aPresContext,
|
2011-04-28 17:21:37 +00:00
|
|
|
nsMediaQueryResultCacheKey& aKey)
|
2015-06-26 03:52:47 +00:00
|
|
|
{
|
|
|
|
return UseForPresentation(aPresContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
DocumentRule::UseForPresentation(nsPresContext* aPresContext)
|
2004-08-05 18:26:14 +00:00
|
|
|
{
|
2011-04-28 17:21:37 +00:00
|
|
|
nsIDocument *doc = aPresContext->Document();
|
|
|
|
nsIURI *docURI = doc->GetDocumentURI();
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString docURISpec;
|
2004-08-05 18:26:14 +00:00
|
|
|
if (docURI)
|
|
|
|
docURI->GetSpec(docURISpec);
|
|
|
|
|
|
|
|
for (URL *url = mURLs; url; url = url->next) {
|
|
|
|
switch (url->func) {
|
|
|
|
case eURL: {
|
|
|
|
if (docURISpec == url->url)
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2004-08-05 18:26:14 +00:00
|
|
|
} break;
|
|
|
|
case eURLPrefix: {
|
|
|
|
if (StringBeginsWith(docURISpec, url->url))
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2004-08-05 18:26:14 +00:00
|
|
|
} break;
|
|
|
|
case eDomain: {
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString host;
|
2004-08-05 18:26:14 +00:00
|
|
|
if (docURI)
|
|
|
|
docURI->GetHost(host);
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t lenDiff = host.Length() - url->url.Length();
|
2004-08-05 18:26:14 +00:00
|
|
|
if (lenDiff == 0) {
|
|
|
|
if (host == url->url)
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2004-08-05 18:26:14 +00:00
|
|
|
} else {
|
|
|
|
if (StringEndsWith(host, url->url) &&
|
|
|
|
host.CharAt(lenDiff - 1) == '.')
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
} break;
|
2011-04-28 17:21:37 +00:00
|
|
|
case eRegExp: {
|
|
|
|
NS_ConvertUTF8toUTF16 spec(docURISpec);
|
|
|
|
NS_ConvertUTF8toUTF16 regex(url->url);
|
|
|
|
if (nsContentUtils::IsPatternMatching(spec, regex, doc)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2011-04-28 17:21:37 +00:00
|
|
|
}
|
|
|
|
} break;
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2004-08-05 18:26:14 +00:00
|
|
|
}
|
|
|
|
|
2011-03-18 05:18:08 +00:00
|
|
|
DocumentRule::URL::~URL()
|
2009-01-16 23:33:57 +00:00
|
|
|
{
|
2011-03-18 05:18:08 +00:00
|
|
|
NS_CSS_DELETE_LIST_MEMBER(DocumentRule::URL, this, next);
|
2009-01-16 23:33:57 +00:00
|
|
|
}
|
2004-08-05 18:26:14 +00:00
|
|
|
|
2012-01-03 02:19:14 +00:00
|
|
|
/* virtual */ size_t
|
2013-06-23 12:03:39 +00:00
|
|
|
DocumentRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
2012-01-03 02:19:14 +00:00
|
|
|
{
|
|
|
|
size_t n = aMallocSizeOf(this);
|
|
|
|
n += GroupRule::SizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
|
|
|
|
// Measurement of the following members may be added later if DMD finds it is
|
|
|
|
// worthwhile:
|
|
|
|
// - mURLs
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:30:30 +00:00
|
|
|
void
|
|
|
|
DocumentRule::AppendConditionText(nsAString& aCssText)
|
|
|
|
{
|
|
|
|
for (URL *url = mURLs; url; url = url->next) {
|
|
|
|
switch (url->func) {
|
|
|
|
case eURL:
|
|
|
|
aCssText.AppendLiteral("url(");
|
|
|
|
break;
|
|
|
|
case eURLPrefix:
|
|
|
|
aCssText.AppendLiteral("url-prefix(");
|
|
|
|
break;
|
|
|
|
case eDomain:
|
|
|
|
aCssText.AppendLiteral("domain(");
|
|
|
|
break;
|
|
|
|
case eRegExp:
|
|
|
|
aCssText.AppendLiteral("regexp(");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nsStyleUtil::AppendEscapedCSSString(NS_ConvertUTF8toUTF16(url->url),
|
|
|
|
aCssText);
|
|
|
|
aCssText.AppendLiteral("), ");
|
|
|
|
}
|
|
|
|
aCssText.Truncate(aCssText.Length() - 2); // remove last ", "
|
|
|
|
}
|
|
|
|
|
1999-06-10 05:32:38 +00:00
|
|
|
// -------------------------------------------
|
2011-03-17 17:41:52 +00:00
|
|
|
// NameSpaceRule
|
1999-06-10 05:32:38 +00:00
|
|
|
//
|
2011-03-17 17:41:52 +00:00
|
|
|
|
2014-07-14 22:57:54 +00:00
|
|
|
NameSpaceRule::NameSpaceRule(nsIAtom* aPrefix, const nsString& aURLSpec,
|
|
|
|
uint32_t aLineNumber, uint32_t aColumnNumber)
|
|
|
|
: Rule(aLineNumber, aColumnNumber),
|
2011-03-23 05:23:04 +00:00
|
|
|
mPrefix(aPrefix),
|
|
|
|
mURLSpec(aURLSpec)
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-03-17 17:41:52 +00:00
|
|
|
NameSpaceRule::NameSpaceRule(const NameSpaceRule& aCopy)
|
2011-03-07 03:59:03 +00:00
|
|
|
: Rule(aCopy),
|
1999-06-10 05:32:38 +00:00
|
|
|
mPrefix(aCopy.mPrefix),
|
|
|
|
mURLSpec(aCopy.mURLSpec)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-03-17 17:41:52 +00:00
|
|
|
NameSpaceRule::~NameSpaceRule()
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-10-08 02:39:09 +00:00
|
|
|
NS_IMPL_ADDREF(NameSpaceRule)
|
|
|
|
NS_IMPL_RELEASE(NameSpaceRule)
|
1999-06-10 05:32:38 +00:00
|
|
|
|
2011-03-17 17:41:52 +00:00
|
|
|
// QueryInterface implementation for NameSpaceRule
|
|
|
|
NS_INTERFACE_MAP_BEGIN(NameSpaceRule)
|
2011-03-17 17:41:52 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(css::NameSpaceRule))) {
|
|
|
|
*aInstancePtr = this;
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else
|
2001-05-15 08:26:13 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
|
2011-04-08 01:23:46 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
|
2010-03-17 15:09:05 +00:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSNameSpaceRule)
|
2001-05-15 08:26:13 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
1999-06-10 05:32:38 +00:00
|
|
|
|
2011-03-07 03:59:03 +00:00
|
|
|
IMPL_STYLE_RULE_INHERIT(NameSpaceRule, Rule)
|
1999-06-10 05:32:38 +00:00
|
|
|
|
2001-10-16 05:31:36 +00:00
|
|
|
#ifdef DEBUG
|
2010-05-20 02:28:00 +00:00
|
|
|
/* virtual */ void
|
2012-08-22 15:56:38 +00:00
|
|
|
NameSpaceRule::List(FILE* out, int32_t aIndent) const
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2014-11-27 06:29:44 +00:00
|
|
|
nsAutoCString str;
|
2014-11-27 06:29:44 +00:00
|
|
|
for (int32_t indent = aIndent; --indent >= 0; ) {
|
2014-11-27 06:29:44 +00:00
|
|
|
str.AppendLiteral(" ");
|
2014-11-27 06:29:44 +00:00
|
|
|
}
|
1999-06-10 05:32:38 +00:00
|
|
|
|
|
|
|
nsAutoString buffer;
|
|
|
|
|
2014-11-27 06:29:44 +00:00
|
|
|
str.AppendLiteral("@namespace ");
|
1999-06-10 05:32:38 +00:00
|
|
|
|
|
|
|
if (mPrefix) {
|
|
|
|
mPrefix->ToString(buffer);
|
2014-11-27 06:29:44 +00:00
|
|
|
AppendUTF16toUTF8(buffer, str);
|
|
|
|
str.Append(' ');
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2014-11-27 06:29:44 +00:00
|
|
|
str.AppendLiteral("url(\"");
|
|
|
|
AppendUTF16toUTF8(mURLSpec, str);
|
|
|
|
str.AppendLiteral("\")\n");
|
|
|
|
fprintf_stderr(out, "%s", str.get());
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
2001-10-16 05:31:36 +00:00
|
|
|
#endif
|
2000-03-31 07:08:36 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
/* virtual */ int32_t
|
2011-03-17 17:41:52 +00:00
|
|
|
NameSpaceRule::GetType() const
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2011-04-08 01:23:46 +00:00
|
|
|
return Rule::NAMESPACE_RULE;
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2011-04-08 01:23:46 +00:00
|
|
|
/* virtual */ already_AddRefed<Rule>
|
2011-03-17 17:41:52 +00:00
|
|
|
NameSpaceRule::Clone() const
|
1999-06-10 05:32:38 +00:00
|
|
|
{
|
2011-04-08 01:23:46 +00:00
|
|
|
nsRefPtr<Rule> clone = new NameSpaceRule(*this);
|
2010-08-15 15:19:34 +00:00
|
|
|
return clone.forget();
|
1999-06-10 05:32:38 +00:00
|
|
|
}
|
|
|
|
|
2001-05-15 08:26:13 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
NameSpaceRule::GetType(uint16_t* aType)
|
2001-05-15 08:26:13 +00:00
|
|
|
{
|
2012-06-21 19:58:19 +00:00
|
|
|
*aType = nsIDOMCSSRule::NAMESPACE_RULE;
|
2001-05-15 08:26:13 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-17 17:41:52 +00:00
|
|
|
NameSpaceRule::GetCssText(nsAString& aCssText)
|
2001-05-15 08:26:13 +00:00
|
|
|
{
|
2004-06-17 00:13:25 +00:00
|
|
|
aCssText.AssignLiteral("@namespace ");
|
2001-05-15 08:26:13 +00:00
|
|
|
if (mPrefix) {
|
2010-03-08 15:45:00 +00:00
|
|
|
aCssText.Append(nsDependentAtomString(mPrefix) + NS_LITERAL_STRING(" "));
|
2001-05-15 08:26:13 +00:00
|
|
|
}
|
2004-06-17 00:13:25 +00:00
|
|
|
aCssText.AppendLiteral("url(");
|
2009-03-06 04:05:01 +00:00
|
|
|
nsStyleUtil::AppendEscapedCSSString(mURLSpec, aCssText);
|
2014-05-22 03:48:50 +00:00
|
|
|
aCssText.AppendLiteral(");");
|
2001-05-15 08:26:13 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-17 17:41:52 +00:00
|
|
|
NameSpaceRule::SetCssText(const nsAString& aCssText)
|
2001-05-15 08:26:13 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-17 17:41:52 +00:00
|
|
|
NameSpaceRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
|
2001-05-15 08:26:13 +00:00
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return Rule::GetParentStyleSheet(aSheet);
|
2001-05-15 08:26:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-03-17 17:41:52 +00:00
|
|
|
NameSpaceRule::GetParentRule(nsIDOMCSSRule** aParentRule)
|
2001-05-15 08:26:13 +00:00
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return Rule::GetParentRule(aParentRule);
|
2001-05-15 08:26:13 +00:00
|
|
|
}
|
2008-08-07 23:15:40 +00:00
|
|
|
|
2014-07-14 22:57:46 +00:00
|
|
|
css::Rule*
|
|
|
|
NameSpaceRule::GetCSSRule()
|
|
|
|
{
|
|
|
|
return Rule::GetCSSRule();
|
|
|
|
}
|
|
|
|
|
2012-01-03 02:19:14 +00:00
|
|
|
/* virtual */ size_t
|
2013-06-23 12:03:39 +00:00
|
|
|
NameSpaceRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
2012-01-03 02:19:14 +00:00
|
|
|
{
|
|
|
|
return aMallocSizeOf(this);
|
|
|
|
|
|
|
|
// Measurement of the following members may be added later if DMD finds it is
|
|
|
|
// worthwhile:
|
|
|
|
// - mPrefix
|
|
|
|
// - mURLSpec
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-17 17:41:52 +00:00
|
|
|
} // namespace css
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2008-08-07 23:15:40 +00:00
|
|
|
// -------------------------------------------
|
|
|
|
// nsCSSFontFaceStyleDecl and related routines
|
|
|
|
//
|
|
|
|
|
2014-09-24 23:25:40 +00:00
|
|
|
// Mapping from nsCSSFontDesc codes to CSSFontFaceDescriptors fields.
|
|
|
|
nsCSSValue CSSFontFaceDescriptors::* const
|
|
|
|
CSSFontFaceDescriptors::Fields[] = {
|
|
|
|
#define CSS_FONT_DESC(name_, method_) &CSSFontFaceDescriptors::m##method_,
|
2011-12-20 16:49:16 +00:00
|
|
|
#include "nsCSSFontDescList.h"
|
|
|
|
#undef CSS_FONT_DESC
|
2008-08-07 23:15:40 +00:00
|
|
|
};
|
|
|
|
|
2014-09-24 23:25:40 +00:00
|
|
|
const nsCSSValue&
|
|
|
|
CSSFontFaceDescriptors::Get(nsCSSFontDesc aFontDescID) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aFontDescID > eCSSFontDesc_UNKNOWN &&
|
|
|
|
aFontDescID < eCSSFontDesc_COUNT);
|
|
|
|
return this->*CSSFontFaceDescriptors::Fields[aFontDescID];
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSValue&
|
|
|
|
CSSFontFaceDescriptors::Get(nsCSSFontDesc aFontDescID)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aFontDescID > eCSSFontDesc_UNKNOWN &&
|
|
|
|
aFontDescID < eCSSFontDesc_COUNT);
|
|
|
|
return this->*CSSFontFaceDescriptors::Fields[aFontDescID];
|
|
|
|
}
|
|
|
|
|
2008-08-07 23:15:40 +00:00
|
|
|
// QueryInterface implementation for nsCSSFontFaceStyleDecl
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsCSSFontFaceStyleDecl)
|
2012-08-06 02:16:30 +00:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2008-08-07 23:15:40 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
|
2012-08-06 02:14:47 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsICSSDeclaration)
|
2008-08-07 23:15:40 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
2012-08-06 02:16:30 +00:00
|
|
|
// We forward the cycle collection interfaces to ContainingRule(), which is
|
|
|
|
// never null (in fact, we're part of that object!)
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsCycleCollectionISupports)) ||
|
|
|
|
aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant))) {
|
|
|
|
return ContainingRule()->QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
2012-08-06 05:24:43 +00:00
|
|
|
else
|
2008-08-07 23:15:40 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_USING_AGGREGATOR(nsCSSFontFaceStyleDecl, ContainingRule())
|
|
|
|
NS_IMPL_RELEASE_USING_AGGREGATOR(nsCSSFontFaceStyleDecl, ContainingRule())
|
|
|
|
|
|
|
|
// helper for string GetPropertyValue and RemovePropertyValue
|
|
|
|
nsresult
|
|
|
|
nsCSSFontFaceStyleDecl::GetPropertyValue(nsCSSFontDesc aFontDescID,
|
2012-07-06 20:14:07 +00:00
|
|
|
nsAString & aResult) const
|
2008-08-07 23:15:40 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_RANGE(aFontDescID, eCSSFontDesc_UNKNOWN,
|
|
|
|
eCSSFontDesc_COUNT - 1);
|
|
|
|
|
|
|
|
aResult.Truncate();
|
|
|
|
if (aFontDescID == eCSSFontDesc_UNKNOWN)
|
|
|
|
return NS_OK;
|
|
|
|
|
2014-09-24 23:25:40 +00:00
|
|
|
const nsCSSValue& val = mDescriptors.Get(aFontDescID);
|
2008-08-07 23:15:40 +00:00
|
|
|
|
2009-03-09 23:14:34 +00:00
|
|
|
if (val.GetUnit() == eCSSUnit_Null) {
|
|
|
|
// Avoid having to check no-value in the Family and Src cases below.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-08-07 23:15:40 +00:00
|
|
|
switch (aFontDescID) {
|
|
|
|
case eCSSFontDesc_Family: {
|
2010-07-23 18:00:27 +00:00
|
|
|
// we don't use nsCSSValue::AppendToString here because it doesn't
|
2008-08-07 23:15:40 +00:00
|
|
|
// canonicalize the way we want, and anyway it's overkill when
|
|
|
|
// we know we have eCSSUnit_String
|
2009-03-06 04:05:01 +00:00
|
|
|
NS_ASSERTION(val.GetUnit() == eCSSUnit_String, "unexpected unit");
|
2008-08-07 23:15:40 +00:00
|
|
|
nsDependentString family(val.GetStringBufferValue());
|
2009-03-06 04:05:00 +00:00
|
|
|
nsStyleUtil::AppendEscapedCSSString(family, aResult);
|
2008-08-07 23:15:40 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
case eCSSFontDesc_Style:
|
2013-09-15 23:35:49 +00:00
|
|
|
val.AppendToString(eCSSProperty_font_style, aResult,
|
|
|
|
nsCSSValue::eNormalized);
|
2008-08-07 23:15:40 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
case eCSSFontDesc_Weight:
|
2013-09-15 23:35:49 +00:00
|
|
|
val.AppendToString(eCSSProperty_font_weight, aResult,
|
|
|
|
nsCSSValue::eNormalized);
|
2008-08-07 23:15:40 +00:00
|
|
|
return NS_OK;
|
2010-07-23 18:00:27 +00:00
|
|
|
|
2008-08-07 23:15:40 +00:00
|
|
|
case eCSSFontDesc_Stretch:
|
2013-09-15 23:35:49 +00:00
|
|
|
val.AppendToString(eCSSProperty_font_stretch, aResult,
|
|
|
|
nsCSSValue::eNormalized);
|
2008-08-07 23:15:40 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2010-08-23 10:32:03 +00:00
|
|
|
case eCSSFontDesc_FontFeatureSettings:
|
2012-04-26 06:24:26 +00:00
|
|
|
nsStyleUtil::AppendFontFeatureSettings(val, aResult);
|
2010-08-23 10:32:03 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
case eCSSFontDesc_FontLanguageOverride:
|
2013-09-15 23:35:49 +00:00
|
|
|
val.AppendToString(eCSSProperty_font_language_override, aResult,
|
|
|
|
nsCSSValue::eNormalized);
|
2010-08-23 10:32:03 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2008-08-07 23:15:40 +00:00
|
|
|
case eCSSFontDesc_Src:
|
2014-09-22 00:32:58 +00:00
|
|
|
nsStyleUtil::AppendSerializedFontSrc(val, aResult);
|
2008-08-07 23:15:40 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
case eCSSFontDesc_UnicodeRange:
|
2014-07-04 01:19:33 +00:00
|
|
|
nsStyleUtil::AppendUnicodeRange(val, aResult);
|
2008-08-07 23:15:40 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
case eCSSFontDesc_UNKNOWN:
|
|
|
|
case eCSSFontDesc_COUNT:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
NS_NOTREACHED("nsCSSFontFaceStyleDecl::GetPropertyValue: "
|
|
|
|
"out-of-range value got to the switch");
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// attribute DOMString cssText;
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceStyleDecl::GetCssText(nsAString & aCssText)
|
|
|
|
{
|
|
|
|
nsAutoString descStr;
|
|
|
|
|
|
|
|
aCssText.Truncate();
|
|
|
|
for (nsCSSFontDesc id = nsCSSFontDesc(eCSSFontDesc_UNKNOWN + 1);
|
|
|
|
id < eCSSFontDesc_COUNT;
|
|
|
|
id = nsCSSFontDesc(id + 1)) {
|
2014-09-24 23:25:40 +00:00
|
|
|
if (mDescriptors.Get(id).GetUnit() != eCSSUnit_Null &&
|
2008-08-07 23:15:40 +00:00
|
|
|
NS_SUCCEEDED(GetPropertyValue(id, descStr))) {
|
|
|
|
NS_ASSERTION(descStr.Length() > 0,
|
|
|
|
"GetCssText: non-null unit, empty property value");
|
|
|
|
aCssText.AppendLiteral(" ");
|
|
|
|
aCssText.AppendASCII(nsCSSProps::GetStringValue(id).get());
|
|
|
|
aCssText.AppendLiteral(": ");
|
|
|
|
aCssText.Append(descStr);
|
|
|
|
aCssText.AppendLiteral(";\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceStyleDecl::SetCssText(const nsAString & aCssText)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED; // bug 443978
|
|
|
|
}
|
|
|
|
|
|
|
|
// DOMString getPropertyValue (in DOMString propertyName);
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceStyleDecl::GetPropertyValue(const nsAString & propertyName,
|
2012-07-06 20:14:07 +00:00
|
|
|
nsAString & aResult)
|
2008-08-07 23:15:40 +00:00
|
|
|
{
|
|
|
|
return GetPropertyValue(nsCSSProps::LookupFontDesc(propertyName), aResult);
|
|
|
|
}
|
|
|
|
|
2013-09-15 23:35:49 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceStyleDecl::GetAuthoredPropertyValue(const nsAString& propertyName,
|
|
|
|
nsAString& aResult)
|
|
|
|
{
|
|
|
|
// We don't return any authored property values different from
|
|
|
|
// GetPropertyValue, currently.
|
|
|
|
return GetPropertyValue(nsCSSProps::LookupFontDesc(propertyName), aResult);
|
|
|
|
}
|
|
|
|
|
2008-08-07 23:15:40 +00:00
|
|
|
// nsIDOMCSSValue getPropertyCSSValue (in DOMString propertyName);
|
2012-10-01 16:49:41 +00:00
|
|
|
already_AddRefed<dom::CSSValue>
|
2008-08-07 23:15:40 +00:00
|
|
|
nsCSSFontFaceStyleDecl::GetPropertyCSSValue(const nsAString & propertyName,
|
2012-10-01 16:49:41 +00:00
|
|
|
ErrorResult& aRv)
|
2008-08-07 23:15:40 +00:00
|
|
|
{
|
|
|
|
// ??? nsDOMCSSDeclaration returns null/NS_OK, but that seems wrong.
|
2012-10-01 16:49:41 +00:00
|
|
|
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
|
|
|
return nullptr;
|
2008-08-07 23:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DOMString removeProperty (in DOMString propertyName) raises (DOMException);
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceStyleDecl::RemoveProperty(const nsAString & propertyName,
|
2012-07-06 20:14:07 +00:00
|
|
|
nsAString & aResult)
|
2008-08-07 23:15:40 +00:00
|
|
|
{
|
|
|
|
nsCSSFontDesc descID = nsCSSProps::LookupFontDesc(propertyName);
|
|
|
|
NS_ASSERTION(descID >= eCSSFontDesc_UNKNOWN &&
|
|
|
|
descID < eCSSFontDesc_COUNT,
|
|
|
|
"LookupFontDesc returned value out of range");
|
|
|
|
|
|
|
|
if (descID == eCSSFontDesc_UNKNOWN) {
|
|
|
|
aResult.Truncate();
|
|
|
|
} else {
|
|
|
|
nsresult rv = GetPropertyValue(descID, aResult);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2014-09-24 23:25:40 +00:00
|
|
|
mDescriptors.Get(descID).Reset();
|
2008-08-07 23:15:40 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// DOMString getPropertyPriority (in DOMString propertyName);
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceStyleDecl::GetPropertyPriority(const nsAString & propertyName,
|
2012-07-06 20:14:07 +00:00
|
|
|
nsAString & aResult)
|
2008-08-07 23:15:40 +00:00
|
|
|
{
|
|
|
|
// font descriptors do not have priorities at present
|
|
|
|
aResult.Truncate();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// void setProperty (in DOMString propertyName, in DOMString value,
|
|
|
|
// in DOMString priority) raises (DOMException);
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceStyleDecl::SetProperty(const nsAString & propertyName,
|
|
|
|
const nsAString & value,
|
|
|
|
const nsAString & priority)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED; // bug 443978
|
|
|
|
}
|
|
|
|
|
|
|
|
// readonly attribute unsigned long length;
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsCSSFontFaceStyleDecl::GetLength(uint32_t *aLength)
|
2008-08-07 23:15:40 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t len = 0;
|
2008-08-07 23:15:40 +00:00
|
|
|
for (nsCSSFontDesc id = nsCSSFontDesc(eCSSFontDesc_UNKNOWN + 1);
|
|
|
|
id < eCSSFontDesc_COUNT;
|
|
|
|
id = nsCSSFontDesc(id + 1))
|
2014-09-24 23:25:40 +00:00
|
|
|
if (mDescriptors.Get(id).GetUnit() != eCSSUnit_Null)
|
2008-08-07 23:15:40 +00:00
|
|
|
len++;
|
|
|
|
|
|
|
|
*aLength = len;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// DOMString item (in unsigned long index);
|
|
|
|
NS_IMETHODIMP
|
2012-08-24 04:08:08 +00:00
|
|
|
nsCSSFontFaceStyleDecl::Item(uint32_t aIndex, nsAString& aReturn)
|
|
|
|
{
|
|
|
|
bool found;
|
|
|
|
IndexedGetter(aIndex, found, aReturn);
|
|
|
|
if (!found) {
|
|
|
|
aReturn.Truncate();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsCSSFontFaceStyleDecl::IndexedGetter(uint32_t index, bool& aFound, nsAString & aResult)
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t nset = -1;
|
2008-08-07 23:15:40 +00:00
|
|
|
for (nsCSSFontDesc id = nsCSSFontDesc(eCSSFontDesc_UNKNOWN + 1);
|
|
|
|
id < eCSSFontDesc_COUNT;
|
|
|
|
id = nsCSSFontDesc(id + 1)) {
|
2014-09-24 23:25:40 +00:00
|
|
|
if (mDescriptors.Get(id).GetUnit() != eCSSUnit_Null) {
|
2008-08-07 23:15:40 +00:00
|
|
|
nset++;
|
2012-08-22 15:56:38 +00:00
|
|
|
if (nset == int32_t(index)) {
|
2012-08-24 04:08:08 +00:00
|
|
|
aFound = true;
|
2008-08-07 23:15:40 +00:00
|
|
|
aResult.AssignASCII(nsCSSProps::GetStringValue(id).get());
|
2012-08-24 04:08:08 +00:00
|
|
|
return;
|
2008-08-07 23:15:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-24 04:08:08 +00:00
|
|
|
aFound = false;
|
2008-08-07 23:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// readonly attribute nsIDOMCSSRule parentRule;
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceStyleDecl::GetParentRule(nsIDOMCSSRule** aParentRule)
|
|
|
|
{
|
2011-04-08 06:36:09 +00:00
|
|
|
NS_IF_ADDREF(*aParentRule = ContainingRule()->GetDOMRule());
|
|
|
|
return NS_OK;
|
2008-08-07 23:15:40 +00:00
|
|
|
}
|
|
|
|
|
2012-08-06 02:14:47 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceStyleDecl::GetPropertyValue(const nsCSSProperty aPropID,
|
|
|
|
nsAString& aValue)
|
|
|
|
{
|
|
|
|
return
|
|
|
|
GetPropertyValue(NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(aPropID)),
|
|
|
|
aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceStyleDecl::SetPropertyValue(const nsCSSProperty aPropID,
|
|
|
|
const nsAString& aValue)
|
|
|
|
{
|
|
|
|
return SetProperty(NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(aPropID)),
|
|
|
|
aValue, EmptyString());
|
|
|
|
}
|
|
|
|
|
|
|
|
nsINode*
|
|
|
|
nsCSSFontFaceStyleDecl::GetParentObject()
|
|
|
|
{
|
2012-08-06 02:14:52 +00:00
|
|
|
return ContainingRule()->GetDocument();
|
2012-08-06 02:14:47 +00:00
|
|
|
}
|
2008-08-07 23:15:40 +00:00
|
|
|
|
2012-08-24 04:08:09 +00:00
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
nsCSSFontFaceStyleDecl::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
|
2012-08-24 04:08:09 +00:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
return mozilla::dom::CSSStyleDeclarationBinding::Wrap(cx, this, aGivenProto);
|
2012-08-24 04:08:09 +00:00
|
|
|
}
|
|
|
|
|
2008-08-07 23:15:40 +00:00
|
|
|
// -------------------------------------------
|
|
|
|
// nsCSSFontFaceRule
|
|
|
|
//
|
|
|
|
|
2011-04-08 01:23:46 +00:00
|
|
|
/* virtual */ already_AddRefed<css::Rule>
|
2010-08-15 15:19:34 +00:00
|
|
|
nsCSSFontFaceRule::Clone() const
|
2008-08-07 23:15:40 +00:00
|
|
|
{
|
2011-04-08 01:23:46 +00:00
|
|
|
nsRefPtr<css::Rule> clone = new nsCSSFontFaceRule(*this);
|
2010-08-15 15:19:34 +00:00
|
|
|
return clone.forget();
|
2008-08-07 23:15:40 +00:00
|
|
|
}
|
|
|
|
|
2012-08-06 02:16:30 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsCSSFontFaceRule)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsCSSFontFaceRule)
|
|
|
|
|
2013-08-02 01:29:05 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsCSSFontFaceRule)
|
|
|
|
|
2012-08-06 02:16:30 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsCSSFontFaceRule)
|
|
|
|
// Trace the wrapper for our declaration. This just expands out
|
|
|
|
// NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER which we can't use
|
|
|
|
// directly because the wrapper is on the declaration, not on us.
|
2013-05-27 11:50:49 +00:00
|
|
|
tmp->mDecl.TraceWrapper(aCallbacks, aClosure);
|
2012-08-06 02:16:30 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsCSSFontFaceRule)
|
|
|
|
// Unlink the wrapper for our declaraton. This just expands out
|
|
|
|
// NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER which we can't use
|
|
|
|
// directly because the wrapper is on the declaration, not on us.
|
2013-08-02 07:04:01 +00:00
|
|
|
tmp->mDecl.ReleaseWrapper(static_cast<nsISupports*>(p));
|
2012-08-06 02:16:30 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCSSFontFaceRule)
|
2014-10-02 02:32:06 +00:00
|
|
|
// NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS will call into our
|
|
|
|
// Trace hook, where we do the right thing with declarations already.
|
2012-08-06 02:16:30 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
2008-08-07 23:15:40 +00:00
|
|
|
|
|
|
|
// QueryInterface implementation for nsCSSFontFaceRule
|
2012-08-06 02:16:30 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSFontFaceRule)
|
2008-08-07 23:15:40 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSFontFaceRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
|
2011-04-08 01:23:46 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
|
2010-03-17 15:09:05 +00:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSFontFaceRule)
|
2008-08-07 23:15:40 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2011-03-07 03:59:03 +00:00
|
|
|
IMPL_STYLE_RULE_INHERIT(nsCSSFontFaceRule, Rule)
|
2008-08-07 23:15:40 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2010-05-20 02:28:00 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsCSSFontFaceRule::List(FILE* out, int32_t aIndent) const
|
2008-08-07 23:15:40 +00:00
|
|
|
{
|
|
|
|
nsCString baseInd, descInd;
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t indent = aIndent; --indent >= 0; ) {
|
2008-08-07 23:15:40 +00:00
|
|
|
baseInd.AppendLiteral(" ");
|
|
|
|
descInd.AppendLiteral(" ");
|
|
|
|
}
|
|
|
|
descInd.AppendLiteral(" ");
|
|
|
|
|
|
|
|
nsString descStr;
|
|
|
|
|
2014-11-27 06:29:44 +00:00
|
|
|
fprintf_stderr(out, "%s@font-face {\n", baseInd.get());
|
2008-08-07 23:15:40 +00:00
|
|
|
for (nsCSSFontDesc id = nsCSSFontDesc(eCSSFontDesc_UNKNOWN + 1);
|
|
|
|
id < eCSSFontDesc_COUNT;
|
|
|
|
id = nsCSSFontDesc(id + 1))
|
2014-09-24 23:25:40 +00:00
|
|
|
if (mDecl.mDescriptors.Get(id).GetUnit() != eCSSUnit_Null) {
|
2008-08-07 23:15:40 +00:00
|
|
|
if (NS_FAILED(mDecl.GetPropertyValue(id, descStr)))
|
|
|
|
descStr.AssignLiteral("#<serialization error>");
|
|
|
|
else if (descStr.Length() == 0)
|
|
|
|
descStr.AssignLiteral("#<serialization missing>");
|
2014-11-27 06:29:44 +00:00
|
|
|
fprintf_stderr(out, "%s%s: %s\n",
|
|
|
|
descInd.get(), nsCSSProps::GetStringValue(id).get(),
|
|
|
|
NS_ConvertUTF16toUTF8(descStr).get());
|
2008-08-07 23:15:40 +00:00
|
|
|
}
|
2014-11-27 06:29:44 +00:00
|
|
|
fprintf_stderr(out, "%s}\n", baseInd.get());
|
2008-08-07 23:15:40 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
/* virtual */ int32_t
|
2010-07-18 14:39:20 +00:00
|
|
|
nsCSSFontFaceRule::GetType() const
|
2008-08-07 23:15:40 +00:00
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return Rule::FONT_FACE_RULE;
|
2008-08-07 23:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsCSSFontFaceRule::GetType(uint16_t* aType)
|
2008-08-07 23:15:40 +00:00
|
|
|
{
|
|
|
|
*aType = nsIDOMCSSRule::FONT_FACE_RULE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceRule::GetCssText(nsAString& aCssText)
|
|
|
|
{
|
|
|
|
nsAutoString propText;
|
|
|
|
mDecl.GetCssText(propText);
|
|
|
|
|
|
|
|
aCssText.AssignLiteral("@font-face {\n");
|
|
|
|
aCssText.Append(propText);
|
|
|
|
aCssText.Append('}');
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceRule::SetCssText(const nsAString& aCssText)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED; // bug 443978
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
|
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return Rule::GetParentStyleSheet(aSheet);
|
2008-08-07 23:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceRule::GetParentRule(nsIDOMCSSRule** aParentRule)
|
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return Rule::GetParentRule(aParentRule);
|
2008-08-07 23:15:40 +00:00
|
|
|
}
|
|
|
|
|
2014-07-14 22:57:46 +00:00
|
|
|
css::Rule*
|
|
|
|
nsCSSFontFaceRule::GetCSSRule()
|
|
|
|
{
|
|
|
|
return Rule::GetCSSRule();
|
|
|
|
}
|
|
|
|
|
2008-08-07 23:15:40 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFaceRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
|
|
|
|
{
|
2010-07-18 20:23:12 +00:00
|
|
|
NS_IF_ADDREF(*aStyle = &mDecl);
|
|
|
|
return NS_OK;
|
2008-08-07 23:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Arguably these should forward to nsCSSFontFaceStyleDecl methods.
|
|
|
|
void
|
|
|
|
nsCSSFontFaceRule::SetDesc(nsCSSFontDesc aDescID, nsCSSValue const & aValue)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aDescID > eCSSFontDesc_UNKNOWN &&
|
|
|
|
aDescID < eCSSFontDesc_COUNT,
|
|
|
|
"aDescID out of range in nsCSSFontFaceRule::SetDesc");
|
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
// FIXME: handle dynamic changes
|
|
|
|
|
2014-09-24 23:25:40 +00:00
|
|
|
mDecl.mDescriptors.Get(aDescID) = aValue;
|
2008-08-07 23:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsCSSFontFaceRule::GetDesc(nsCSSFontDesc aDescID, nsCSSValue & aValue)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aDescID > eCSSFontDesc_UNKNOWN &&
|
|
|
|
aDescID < eCSSFontDesc_COUNT,
|
|
|
|
"aDescID out of range in nsCSSFontFaceRule::GetDesc");
|
|
|
|
|
2014-09-24 23:25:40 +00:00
|
|
|
aValue = mDecl.mDescriptors.Get(aDescID);
|
2008-08-07 23:15:40 +00:00
|
|
|
}
|
2011-04-12 06:18:43 +00:00
|
|
|
|
2012-01-03 02:19:14 +00:00
|
|
|
/* virtual */ size_t
|
2013-06-23 12:03:39 +00:00
|
|
|
nsCSSFontFaceRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
2012-01-03 02:19:14 +00:00
|
|
|
{
|
|
|
|
return aMallocSizeOf(this);
|
|
|
|
|
|
|
|
// Measurement of the following members may be added later if DMD finds it is
|
|
|
|
// worthwhile:
|
|
|
|
// - mDecl
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-20 02:59:20 +00:00
|
|
|
// -----------------------------------
|
|
|
|
// nsCSSFontFeatureValuesRule
|
|
|
|
//
|
|
|
|
|
|
|
|
/* virtual */ already_AddRefed<css::Rule>
|
|
|
|
nsCSSFontFeatureValuesRule::Clone() const
|
|
|
|
{
|
|
|
|
nsRefPtr<css::Rule> clone = new nsCSSFontFeatureValuesRule(*this);
|
|
|
|
return clone.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(nsCSSFontFeatureValuesRule)
|
|
|
|
NS_IMPL_RELEASE(nsCSSFontFeatureValuesRule)
|
|
|
|
|
|
|
|
// QueryInterface implementation for nsCSSFontFeatureValuesRule
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsCSSFontFeatureValuesRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSFontFeatureValuesRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSFontFeatureValuesRule)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
IMPL_STYLE_RULE_INHERIT(nsCSSFontFeatureValuesRule, Rule)
|
|
|
|
|
|
|
|
static void
|
|
|
|
FeatureValuesToString(
|
|
|
|
const nsTArray<gfxFontFeatureValueSet::FeatureValues>& aFeatureValues,
|
|
|
|
nsAString& aOutStr)
|
|
|
|
{
|
|
|
|
uint32_t i, n;
|
|
|
|
|
|
|
|
// append values
|
|
|
|
n = aFeatureValues.Length();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
const gfxFontFeatureValueSet::FeatureValues& fv = aFeatureValues[i];
|
|
|
|
|
|
|
|
// @alternate
|
|
|
|
aOutStr.AppendLiteral(" @");
|
|
|
|
nsAutoString functAlt;
|
|
|
|
nsStyleUtil::GetFunctionalAlternatesName(fv.alternate, functAlt);
|
|
|
|
aOutStr.Append(functAlt);
|
|
|
|
aOutStr.AppendLiteral(" {");
|
|
|
|
|
|
|
|
// for each ident-values tuple
|
|
|
|
uint32_t j, numValues = fv.valuelist.Length();
|
|
|
|
for (j = 0; j < numValues; j++) {
|
2014-05-22 03:48:51 +00:00
|
|
|
aOutStr.Append(' ');
|
2013-05-20 02:59:20 +00:00
|
|
|
const gfxFontFeatureValueSet::ValueList& vlist = fv.valuelist[j];
|
|
|
|
nsStyleUtil::AppendEscapedCSSIdent(vlist.name, aOutStr);
|
2014-05-22 03:48:51 +00:00
|
|
|
aOutStr.Append(':');
|
2013-05-20 02:59:20 +00:00
|
|
|
|
|
|
|
uint32_t k, numSelectors = vlist.featureSelectors.Length();
|
|
|
|
for (k = 0; k < numSelectors; k++) {
|
2014-05-22 03:48:51 +00:00
|
|
|
aOutStr.Append(' ');
|
2013-05-20 02:59:20 +00:00
|
|
|
aOutStr.AppendInt(vlist.featureSelectors[k]);
|
|
|
|
}
|
|
|
|
|
2014-05-22 03:48:51 +00:00
|
|
|
aOutStr.Append(';');
|
2013-05-20 02:59:20 +00:00
|
|
|
}
|
|
|
|
aOutStr.AppendLiteral(" }\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
FontFeatureValuesRuleToString(
|
2014-06-06 06:09:23 +00:00
|
|
|
const mozilla::FontFamilyList& aFamilyList,
|
2013-05-20 02:59:20 +00:00
|
|
|
const nsTArray<gfxFontFeatureValueSet::FeatureValues>& aFeatureValues,
|
|
|
|
nsAString& aOutStr)
|
|
|
|
{
|
|
|
|
aOutStr.AssignLiteral("@font-feature-values ");
|
|
|
|
nsAutoString familyListStr, valueTextStr;
|
2014-06-06 06:09:23 +00:00
|
|
|
nsStyleUtil::AppendEscapedCSSFontFamilyList(aFamilyList, familyListStr);
|
2013-05-20 02:59:20 +00:00
|
|
|
aOutStr.Append(familyListStr);
|
|
|
|
aOutStr.AppendLiteral(" {\n");
|
|
|
|
FeatureValuesToString(aFeatureValues, valueTextStr);
|
|
|
|
aOutStr.Append(valueTextStr);
|
2014-05-22 03:48:51 +00:00
|
|
|
aOutStr.Append('}');
|
2013-05-20 02:59:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
nsCSSFontFeatureValuesRule::List(FILE* out, int32_t aIndent) const
|
|
|
|
{
|
|
|
|
nsAutoString text;
|
|
|
|
FontFeatureValuesRuleToString(mFamilyList, mFeatureValues, text);
|
|
|
|
NS_ConvertUTF16toUTF8 utf8(text);
|
|
|
|
|
|
|
|
// replace newlines with newlines plus indent spaces
|
|
|
|
char* indent = new char[(aIndent + 1) * 2];
|
|
|
|
int32_t i;
|
|
|
|
for (i = 1; i < (aIndent + 1) * 2 - 1; i++) {
|
|
|
|
indent[i] = 0x20;
|
|
|
|
}
|
|
|
|
indent[0] = 0xa;
|
|
|
|
indent[aIndent * 2 + 1] = 0;
|
|
|
|
utf8.ReplaceSubstring("\n", indent);
|
|
|
|
delete [] indent;
|
|
|
|
|
2014-11-27 06:29:44 +00:00
|
|
|
nsAutoCString indentStr;
|
2014-11-27 06:29:44 +00:00
|
|
|
for (i = aIndent; --i >= 0; ) {
|
2014-11-27 06:29:44 +00:00
|
|
|
indentStr.AppendLiteral(" ");
|
2014-11-27 06:29:44 +00:00
|
|
|
}
|
2014-11-27 06:29:44 +00:00
|
|
|
fprintf_stderr(out, "%s%s\n", indentStr.get(), utf8.get());
|
2013-05-20 02:59:20 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* virtual */ int32_t
|
|
|
|
nsCSSFontFeatureValuesRule::GetType() const
|
|
|
|
{
|
|
|
|
return Rule::FONT_FEATURE_VALUES_RULE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFeatureValuesRule::GetType(uint16_t* aType)
|
|
|
|
{
|
|
|
|
*aType = nsIDOMCSSRule::FONT_FEATURE_VALUES_RULE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFeatureValuesRule::GetCssText(nsAString& aCssText)
|
|
|
|
{
|
|
|
|
FontFeatureValuesRuleToString(mFamilyList, mFeatureValues, aCssText);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFeatureValuesRule::SetCssText(const nsAString& aCssText)
|
|
|
|
{
|
|
|
|
// FIXME: implement???
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFeatureValuesRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
|
|
|
|
{
|
|
|
|
return Rule::GetParentStyleSheet(aSheet);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFeatureValuesRule::GetParentRule(nsIDOMCSSRule** aParentRule)
|
|
|
|
{
|
|
|
|
return Rule::GetParentRule(aParentRule);
|
|
|
|
}
|
|
|
|
|
2014-07-14 22:57:46 +00:00
|
|
|
css::Rule*
|
|
|
|
nsCSSFontFeatureValuesRule::GetCSSRule()
|
|
|
|
{
|
|
|
|
return Rule::GetCSSRule();
|
|
|
|
}
|
|
|
|
|
2013-05-20 02:59:20 +00:00
|
|
|
NS_IMETHODIMP
|
2014-06-06 06:09:23 +00:00
|
|
|
nsCSSFontFeatureValuesRule::GetFontFamily(nsAString& aFamilyListStr)
|
2013-05-20 02:59:20 +00:00
|
|
|
{
|
2014-06-06 06:09:23 +00:00
|
|
|
nsStyleUtil::AppendEscapedCSSFontFamilyList(mFamilyList, aFamilyListStr);
|
2013-05-20 02:59:20 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFeatureValuesRule::SetFontFamily(const nsAString& aFontFamily)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFeatureValuesRule::GetValueText(nsAString& aValueText)
|
|
|
|
{
|
|
|
|
FeatureValuesToString(mFeatureValues, aValueText);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSFontFeatureValuesRule::SetValueText(const nsAString& aValueText)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct MakeFamilyArray {
|
2014-09-01 03:36:37 +00:00
|
|
|
explicit MakeFamilyArray(nsTArray<nsString>& aFamilyArray)
|
2013-05-20 02:59:20 +00:00
|
|
|
: familyArray(aFamilyArray), hasGeneric(false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
AddFamily(const nsString& aFamily, bool aGeneric, void* aData)
|
|
|
|
{
|
|
|
|
MakeFamilyArray *familyArr = reinterpret_cast<MakeFamilyArray*> (aData);
|
|
|
|
if (!aGeneric && !aFamily.IsEmpty()) {
|
|
|
|
familyArr->familyArray.AppendElement(aFamily);
|
|
|
|
}
|
|
|
|
if (aGeneric) {
|
|
|
|
familyArr->hasGeneric = true;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<nsString>& familyArray;
|
|
|
|
bool hasGeneric;
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2014-06-06 06:09:23 +00:00
|
|
|
nsCSSFontFeatureValuesRule::SetFamilyList(
|
|
|
|
const mozilla::FontFamilyList& aFamilyList)
|
2013-05-20 02:59:20 +00:00
|
|
|
{
|
2014-06-06 06:09:23 +00:00
|
|
|
mFamilyList = aFamilyList;
|
2013-05-20 02:59:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsCSSFontFeatureValuesRule::AddValueList(int32_t aVariantAlternate,
|
|
|
|
nsTArray<gfxFontFeatureValueSet::ValueList>& aValueList)
|
|
|
|
{
|
|
|
|
uint32_t i, len = mFeatureValues.Length();
|
|
|
|
bool foundAlternate = false;
|
|
|
|
|
|
|
|
// add to an existing list for a given property value
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
gfxFontFeatureValueSet::FeatureValues& f = mFeatureValues.ElementAt(i);
|
|
|
|
|
|
|
|
if (f.alternate == uint32_t(aVariantAlternate)) {
|
|
|
|
f.valuelist.AppendElements(aValueList);
|
|
|
|
foundAlternate = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// create a new list for a given property value
|
|
|
|
if (!foundAlternate) {
|
|
|
|
gfxFontFeatureValueSet::FeatureValues &f = *mFeatureValues.AppendElement();
|
|
|
|
f.alternate = aVariantAlternate;
|
|
|
|
f.valuelist.AppendElements(aValueList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
nsCSSFontFeatureValuesRule::SizeOfIncludingThis(
|
2013-06-23 12:03:39 +00:00
|
|
|
MallocSizeOf aMallocSizeOf) const
|
2013-05-20 02:59:20 +00:00
|
|
|
{
|
|
|
|
return aMallocSizeOf(this);
|
|
|
|
}
|
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
// -------------------------------------------
|
|
|
|
// nsCSSKeyframeStyleDeclaration
|
|
|
|
//
|
|
|
|
|
|
|
|
nsCSSKeyframeStyleDeclaration::nsCSSKeyframeStyleDeclaration(nsCSSKeyframeRule *aRule)
|
|
|
|
: mRule(aRule)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSKeyframeStyleDeclaration::~nsCSSKeyframeStyleDeclaration()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!mRule, "DropReference not called.");
|
|
|
|
}
|
|
|
|
|
2012-08-06 02:16:30 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsCSSKeyframeStyleDeclaration)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsCSSKeyframeStyleDeclaration)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(nsCSSKeyframeStyleDeclaration)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSKeyframeStyleDeclaration)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsDOMCSSDeclaration)
|
2011-04-12 06:18:43 +00:00
|
|
|
|
|
|
|
css::Declaration*
|
2015-04-10 00:41:35 +00:00
|
|
|
nsCSSKeyframeStyleDeclaration::GetCSSDeclaration(Operation aOperation)
|
2011-04-12 06:18:43 +00:00
|
|
|
{
|
|
|
|
if (mRule) {
|
|
|
|
return mRule->Declaration();
|
|
|
|
} else {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-27 20:53:49 +00:00
|
|
|
void
|
|
|
|
nsCSSKeyframeStyleDeclaration::GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv)
|
2011-04-12 06:18:43 +00:00
|
|
|
{
|
2011-04-27 20:53:49 +00:00
|
|
|
GetCSSParsingEnvironmentForRule(mRule, aCSSParseEnv);
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframeStyleDeclaration::GetParentRule(nsIDOMCSSRule **aParent)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aParent);
|
|
|
|
|
|
|
|
NS_IF_ADDREF(*aParent = mRule);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsCSSKeyframeStyleDeclaration::SetCSSDeclaration(css::Declaration* aDecl)
|
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(aDecl, "must be non-null");
|
2011-04-12 06:18:43 +00:00
|
|
|
mRule->ChangeDeclaration(aDecl);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDocument*
|
|
|
|
nsCSSKeyframeStyleDeclaration::DocToUpdate()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
|
2012-08-06 02:14:52 +00:00
|
|
|
nsINode*
|
|
|
|
nsCSSKeyframeStyleDeclaration::GetParentObject()
|
|
|
|
{
|
|
|
|
return mRule ? mRule->GetDocument() : nullptr;
|
|
|
|
}
|
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
// -------------------------------------------
|
|
|
|
// nsCSSKeyframeRule
|
|
|
|
//
|
|
|
|
|
|
|
|
nsCSSKeyframeRule::nsCSSKeyframeRule(const nsCSSKeyframeRule& aCopy)
|
|
|
|
// copy everything except our reference count and mDOMDeclaration
|
|
|
|
: Rule(aCopy)
|
|
|
|
, mKeys(aCopy.mKeys)
|
2011-04-12 02:46:35 +00:00
|
|
|
, mDeclaration(new css::Declaration(*aCopy.mDeclaration))
|
2011-04-12 06:18:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSKeyframeRule::~nsCSSKeyframeRule()
|
|
|
|
{
|
|
|
|
if (mDOMDeclaration) {
|
|
|
|
mDOMDeclaration->DropReference();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-08 01:23:46 +00:00
|
|
|
/* virtual */ already_AddRefed<css::Rule>
|
2011-04-12 06:18:43 +00:00
|
|
|
nsCSSKeyframeRule::Clone() const
|
|
|
|
{
|
2011-04-08 01:23:46 +00:00
|
|
|
nsRefPtr<css::Rule> clone = new nsCSSKeyframeRule(*this);
|
2011-04-12 06:18:43 +00:00
|
|
|
return clone.forget();
|
|
|
|
}
|
|
|
|
|
2013-01-19 04:32:12 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsCSSKeyframeRule)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsCSSKeyframeRule)
|
|
|
|
|
2013-08-02 01:29:05 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsCSSKeyframeRule)
|
2013-02-06 14:24:04 +00:00
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsCSSKeyframeRule)
|
|
|
|
if (tmp->mDOMDeclaration) {
|
|
|
|
tmp->mDOMDeclaration->DropReference();
|
2013-06-13 22:13:13 +00:00
|
|
|
tmp->mDOMDeclaration = nullptr;
|
2013-02-06 14:24:04 +00:00
|
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCSSKeyframeRule)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDOMDeclaration)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
2011-04-12 06:18:43 +00:00
|
|
|
|
|
|
|
// QueryInterface implementation for nsCSSKeyframeRule
|
2013-01-19 04:32:12 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSKeyframeRule)
|
2011-04-12 06:18:43 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMMozCSSKeyframeRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
|
2011-04-08 01:23:46 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
|
2011-04-12 06:18:43 +00:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozCSSKeyframeRule)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(nsCSSKeyframeRule, Rule)
|
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsCSSKeyframeRule::MapRuleInfoInto(nsRuleData* aRuleData)
|
|
|
|
{
|
|
|
|
// We need to implement MapRuleInfoInto because the animation manager
|
|
|
|
// constructs a rule node pointing to us in order to compute the
|
|
|
|
// styles it needs to animate.
|
|
|
|
|
2012-10-16 16:21:35 +00:00
|
|
|
// The spec says that !important declarations should just be ignored
|
|
|
|
NS_ASSERTION(!mDeclaration->HasImportantData(),
|
|
|
|
"Keyframe rules has !important data");
|
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
mDeclaration->MapNormalRuleInfoInto(aRuleData);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsCSSKeyframeRule::List(FILE* out, int32_t aIndent) const
|
2011-04-12 06:18:43 +00:00
|
|
|
{
|
2014-11-27 06:29:44 +00:00
|
|
|
nsAutoCString str;
|
2014-11-27 06:29:44 +00:00
|
|
|
for (int32_t index = aIndent; --index >= 0; ) {
|
2014-11-27 06:29:44 +00:00
|
|
|
str.AppendLiteral(" ");
|
2014-11-27 06:29:44 +00:00
|
|
|
}
|
2012-11-20 19:55:14 +00:00
|
|
|
|
|
|
|
nsAutoString tmp;
|
|
|
|
DoGetKeyText(tmp);
|
2014-11-27 06:29:44 +00:00
|
|
|
AppendUTF16toUTF8(tmp, str);
|
|
|
|
str.AppendLiteral(" { ");
|
|
|
|
mDeclaration->ToString(tmp);
|
|
|
|
AppendUTF16toUTF8(tmp, str);
|
|
|
|
str.AppendLiteral("}\n");
|
|
|
|
fprintf_stderr(out, "%s", str.get());
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
/* virtual */ int32_t
|
2011-04-12 06:18:43 +00:00
|
|
|
nsCSSKeyframeRule::GetType() const
|
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return Rule::KEYFRAME_RULE;
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsCSSKeyframeRule::GetType(uint16_t* aType)
|
2011-04-12 06:18:43 +00:00
|
|
|
{
|
2012-11-29 07:57:32 +00:00
|
|
|
*aType = nsIDOMCSSRule::KEYFRAME_RULE;
|
2011-04-12 06:18:43 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframeRule::GetCssText(nsAString& aCssText)
|
|
|
|
{
|
2012-11-20 19:55:14 +00:00
|
|
|
DoGetKeyText(aCssText);
|
2011-04-12 06:18:43 +00:00
|
|
|
aCssText.AppendLiteral(" { ");
|
|
|
|
nsAutoString tmp;
|
|
|
|
mDeclaration->ToString(tmp);
|
|
|
|
aCssText.Append(tmp);
|
|
|
|
aCssText.AppendLiteral(" }");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframeRule::SetCssText(const nsAString& aCssText)
|
|
|
|
{
|
|
|
|
// FIXME: implement???
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframeRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
|
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return Rule::GetParentStyleSheet(aSheet);
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframeRule::GetParentRule(nsIDOMCSSRule** aParentRule)
|
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return Rule::GetParentRule(aParentRule);
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
|
2014-07-14 22:57:46 +00:00
|
|
|
css::Rule*
|
|
|
|
nsCSSKeyframeRule::GetCSSRule()
|
|
|
|
{
|
|
|
|
return Rule::GetCSSRule();
|
|
|
|
}
|
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframeRule::GetKeyText(nsAString& aKeyText)
|
2012-11-20 19:55:14 +00:00
|
|
|
{
|
|
|
|
DoGetKeyText(aKeyText);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsCSSKeyframeRule::DoGetKeyText(nsAString& aKeyText) const
|
2011-04-12 06:18:43 +00:00
|
|
|
{
|
|
|
|
aKeyText.Truncate();
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t i = 0, i_end = mKeys.Length();
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(i_end != 0, "must have some keys");
|
2011-04-12 06:18:43 +00:00
|
|
|
for (;;) {
|
|
|
|
aKeyText.AppendFloat(mKeys[i] * 100.0f);
|
2014-01-04 15:02:17 +00:00
|
|
|
aKeyText.Append(char16_t('%'));
|
2011-04-12 06:18:43 +00:00
|
|
|
if (++i == i_end) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
aKeyText.AppendLiteral(", ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframeRule::SetKeyText(const nsAString& aKeyText)
|
|
|
|
{
|
|
|
|
nsCSSParser parser;
|
|
|
|
|
2011-05-28 22:38:48 +00:00
|
|
|
InfallibleTArray<float> newSelectors;
|
2011-04-12 06:18:43 +00:00
|
|
|
// FIXME: pass filename and line number
|
2014-03-05 04:13:20 +00:00
|
|
|
if (!parser.ParseKeyframeSelectorString(aKeyText, nullptr, 0, newSelectors)) {
|
2011-04-12 06:18:43 +00:00
|
|
|
// for now, we don't do anything if the parse fails
|
2014-03-05 04:13:20 +00:00
|
|
|
return NS_OK;
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
|
2014-03-05 04:13:20 +00:00
|
|
|
nsIDocument* doc = GetDocument();
|
|
|
|
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
|
|
|
|
|
|
|
|
newSelectors.SwapElements(mKeys);
|
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* sheet = GetStyleSheet();
|
2012-09-30 16:40:24 +00:00
|
|
|
if (sheet) {
|
|
|
|
sheet->SetModifiedByChildRule();
|
2014-03-05 04:13:20 +00:00
|
|
|
|
|
|
|
if (doc) {
|
|
|
|
doc->StyleRuleChanged(sheet, this, this);
|
|
|
|
}
|
2011-05-03 01:43:44 +00:00
|
|
|
}
|
2011-04-12 06:18:43 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframeRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
|
|
|
|
{
|
|
|
|
if (!mDOMDeclaration) {
|
|
|
|
mDOMDeclaration = new nsCSSKeyframeStyleDeclaration(this);
|
|
|
|
}
|
|
|
|
NS_ADDREF(*aStyle = mDOMDeclaration);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-04-12 02:46:35 +00:00
|
|
|
nsCSSKeyframeRule::ChangeDeclaration(css::Declaration* aDeclaration)
|
2011-04-12 06:18:43 +00:00
|
|
|
{
|
2014-03-05 04:13:20 +00:00
|
|
|
// Our caller already did a BeginUpdate/EndUpdate, but with
|
|
|
|
// UPDATE_CONTENT, and we need UPDATE_STYLE to trigger work in
|
|
|
|
// PresShell::EndUpdate.
|
|
|
|
nsIDocument* doc = GetDocument();
|
|
|
|
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
|
|
|
|
|
2012-02-02 16:59:39 +00:00
|
|
|
// Be careful to not assign to an nsAutoPtr if we would be assigning
|
|
|
|
// the thing it already holds.
|
|
|
|
if (aDeclaration != mDeclaration) {
|
|
|
|
mDeclaration = aDeclaration;
|
|
|
|
}
|
2011-04-12 06:18:43 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* sheet = GetStyleSheet();
|
2012-09-30 16:40:24 +00:00
|
|
|
if (sheet) {
|
|
|
|
sheet->SetModifiedByChildRule();
|
2014-03-05 04:13:20 +00:00
|
|
|
|
|
|
|
if (doc) {
|
|
|
|
doc->StyleRuleChanged(sheet, this, this);
|
|
|
|
}
|
2011-05-03 01:43:44 +00:00
|
|
|
}
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
|
2012-01-03 02:19:14 +00:00
|
|
|
/* virtual */ size_t
|
2013-06-23 12:03:39 +00:00
|
|
|
nsCSSKeyframeRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
2012-01-03 02:19:14 +00:00
|
|
|
{
|
|
|
|
return aMallocSizeOf(this);
|
|
|
|
|
|
|
|
// Measurement of the following members may be added later if DMD finds it is
|
|
|
|
// worthwhile:
|
|
|
|
// - mKeys
|
|
|
|
// - mDeclaration
|
|
|
|
// - mDOMDeclaration
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
// -------------------------------------------
|
|
|
|
// nsCSSKeyframesRule
|
|
|
|
//
|
|
|
|
|
|
|
|
nsCSSKeyframesRule::nsCSSKeyframesRule(const nsCSSKeyframesRule& aCopy)
|
|
|
|
// copy everything except our reference count. GroupRule's copy
|
|
|
|
// constructor also doesn't copy the lazily-constructed
|
|
|
|
// mRuleCollection.
|
|
|
|
: GroupRule(aCopy),
|
|
|
|
mName(aCopy.mName)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSKeyframesRule::~nsCSSKeyframesRule()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-04-08 01:23:46 +00:00
|
|
|
/* virtual */ already_AddRefed<css::Rule>
|
2011-04-12 06:18:43 +00:00
|
|
|
nsCSSKeyframesRule::Clone() const
|
|
|
|
{
|
2011-04-08 01:23:46 +00:00
|
|
|
nsRefPtr<css::Rule> clone = new nsCSSKeyframesRule(*this);
|
2011-04-12 06:18:43 +00:00
|
|
|
return clone.forget();
|
|
|
|
}
|
|
|
|
|
2011-04-12 02:46:35 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsCSSKeyframesRule, css::GroupRule)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsCSSKeyframesRule, css::GroupRule)
|
2011-04-12 06:18:43 +00:00
|
|
|
|
|
|
|
// QueryInterface implementation for nsCSSKeyframesRule
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsCSSKeyframesRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMMozCSSKeyframesRule)
|
2011-04-08 01:23:46 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
|
2011-04-12 06:18:43 +00:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozCSSKeyframesRule)
|
2012-10-08 02:39:09 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(GroupRule)
|
2011-04-12 06:18:43 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsCSSKeyframesRule::List(FILE* out, int32_t aIndent) const
|
2011-04-12 06:18:43 +00:00
|
|
|
{
|
2014-11-27 06:29:44 +00:00
|
|
|
nsAutoCString indentStr;
|
2014-11-27 06:29:44 +00:00
|
|
|
for (int32_t indent = aIndent; --indent >= 0; ) {
|
2014-11-27 06:29:44 +00:00
|
|
|
indentStr.AppendLiteral(" ");
|
2014-11-27 06:29:44 +00:00
|
|
|
}
|
2012-11-20 19:55:14 +00:00
|
|
|
|
2014-11-27 06:29:44 +00:00
|
|
|
fprintf_stderr(out, "%s@keyframes %s {\n",
|
|
|
|
indentStr.get(), NS_ConvertUTF16toUTF8(mName).get());
|
|
|
|
|
2012-11-20 19:55:14 +00:00
|
|
|
GroupRule::List(out, aIndent);
|
2014-11-27 06:29:44 +00:00
|
|
|
|
|
|
|
fprintf_stderr(out, "%s}\n", indentStr.get());
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
/* virtual */ int32_t
|
2011-04-12 06:18:43 +00:00
|
|
|
nsCSSKeyframesRule::GetType() const
|
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return Rule::KEYFRAMES_RULE;
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsCSSKeyframesRule::GetType(uint16_t* aType)
|
2011-04-12 06:18:43 +00:00
|
|
|
{
|
2012-11-29 07:57:32 +00:00
|
|
|
*aType = nsIDOMCSSRule::KEYFRAMES_RULE;
|
2011-04-12 06:18:43 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframesRule::GetCssText(nsAString& aCssText)
|
|
|
|
{
|
2012-07-09 01:25:10 +00:00
|
|
|
aCssText.AssignLiteral("@keyframes ");
|
2011-04-12 06:18:43 +00:00
|
|
|
aCssText.Append(mName);
|
|
|
|
aCssText.AppendLiteral(" {\n");
|
|
|
|
nsAutoString tmp;
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0, i_end = mRules.Count(); i != i_end; ++i) {
|
2011-04-12 06:18:43 +00:00
|
|
|
static_cast<nsCSSKeyframeRule*>(mRules[i])->GetCssText(tmp);
|
|
|
|
aCssText.Append(tmp);
|
2014-05-22 03:48:51 +00:00
|
|
|
aCssText.Append('\n');
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
2014-05-22 03:48:51 +00:00
|
|
|
aCssText.Append('}');
|
2011-04-12 06:18:43 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframesRule::SetCssText(const nsAString& aCssText)
|
|
|
|
{
|
|
|
|
// FIXME: implement???
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframesRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
|
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return GroupRule::GetParentStyleSheet(aSheet);
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframesRule::GetParentRule(nsIDOMCSSRule** aParentRule)
|
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return GroupRule::GetParentRule(aParentRule);
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
|
2014-07-14 22:57:46 +00:00
|
|
|
css::Rule*
|
|
|
|
nsCSSKeyframesRule::GetCSSRule()
|
|
|
|
{
|
|
|
|
return GroupRule::GetCSSRule();
|
|
|
|
}
|
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframesRule::GetName(nsAString& aName)
|
|
|
|
{
|
|
|
|
aName = mName;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframesRule::SetName(const nsAString& aName)
|
|
|
|
{
|
2014-03-05 04:13:20 +00:00
|
|
|
if (mName == aName) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDocument* doc = GetDocument();
|
|
|
|
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
|
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
mName = aName;
|
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* sheet = GetStyleSheet();
|
2012-09-30 16:40:24 +00:00
|
|
|
if (sheet) {
|
|
|
|
sheet->SetModifiedByChildRule();
|
2014-03-05 04:13:20 +00:00
|
|
|
|
|
|
|
if (doc) {
|
|
|
|
doc->StyleRuleChanged(sheet, this, this);
|
|
|
|
}
|
2011-05-03 01:43:44 +00:00
|
|
|
}
|
2011-04-12 06:18:43 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframesRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
|
|
|
|
{
|
2011-04-12 02:46:35 +00:00
|
|
|
return GroupRule::GetCssRules(aRuleList);
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-02-16 05:38:34 +00:00
|
|
|
nsCSSKeyframesRule::AppendRule(const nsAString& aRule)
|
2011-04-12 06:18:43 +00:00
|
|
|
{
|
|
|
|
// The spec is confusing, and I think we should just append the rule,
|
|
|
|
// which also turns out to match WebKit:
|
|
|
|
// http://lists.w3.org/Archives/Public/www-style/2011Apr/0034.html
|
|
|
|
nsCSSParser parser;
|
|
|
|
|
|
|
|
// FIXME: pass filename and line number
|
|
|
|
nsRefPtr<nsCSSKeyframeRule> rule =
|
2012-07-30 14:20:58 +00:00
|
|
|
parser.ParseKeyframeRule(aRule, nullptr, 0);
|
2011-04-12 06:18:43 +00:00
|
|
|
if (rule) {
|
2014-03-05 04:13:20 +00:00
|
|
|
nsIDocument* doc = GetDocument();
|
|
|
|
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
|
|
|
|
|
2012-01-11 19:36:43 +00:00
|
|
|
AppendStyleRule(rule);
|
2014-03-05 04:13:20 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* sheet = GetStyleSheet();
|
2014-03-05 04:13:20 +00:00
|
|
|
if (sheet) {
|
|
|
|
sheet->SetModifiedByChildRule();
|
|
|
|
|
|
|
|
if (doc) {
|
|
|
|
doc->StyleRuleChanged(sheet, this, this);
|
|
|
|
}
|
|
|
|
}
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static const uint32_t RULE_NOT_FOUND = uint32_t(-1);
|
2011-04-12 06:18:43 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t
|
2011-04-12 06:18:43 +00:00
|
|
|
nsCSSKeyframesRule::FindRuleIndexForKey(const nsAString& aKey)
|
|
|
|
{
|
|
|
|
nsCSSParser parser;
|
|
|
|
|
2011-05-28 22:38:48 +00:00
|
|
|
InfallibleTArray<float> keys;
|
2011-04-12 06:18:43 +00:00
|
|
|
// FIXME: pass filename and line number
|
2012-07-30 14:20:58 +00:00
|
|
|
if (parser.ParseKeyframeSelectorString(aKey, nullptr, 0, keys)) {
|
2011-04-12 06:18:43 +00:00
|
|
|
// The spec isn't clear, but we'll match on the key list, which
|
|
|
|
// mostly matches what WebKit does, except we'll do last-match
|
|
|
|
// instead of first-match, and handling parsing differences better.
|
|
|
|
// http://lists.w3.org/Archives/Public/www-style/2011Apr/0036.html
|
|
|
|
// http://lists.w3.org/Archives/Public/www-style/2011Apr/0037.html
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = mRules.Count(); i-- != 0; ) {
|
2011-04-12 06:18:43 +00:00
|
|
|
if (static_cast<nsCSSKeyframeRule*>(mRules[i])->GetKeys() == keys) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return RULE_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframesRule::DeleteRule(const nsAString& aKey)
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t index = FindRuleIndexForKey(aKey);
|
2011-04-12 06:18:43 +00:00
|
|
|
if (index != RULE_NOT_FOUND) {
|
2014-03-05 04:13:20 +00:00
|
|
|
nsIDocument* doc = GetDocument();
|
|
|
|
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
|
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
mRules.RemoveObjectAt(index);
|
2014-03-05 04:13:20 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* sheet = GetStyleSheet();
|
2012-09-30 16:40:24 +00:00
|
|
|
if (sheet) {
|
|
|
|
sheet->SetModifiedByChildRule();
|
2014-03-05 04:13:20 +00:00
|
|
|
|
|
|
|
if (doc) {
|
|
|
|
doc->StyleRuleChanged(sheet, this, this);
|
|
|
|
}
|
2011-05-03 01:43:44 +00:00
|
|
|
}
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSKeyframesRule::FindRule(const nsAString& aKey,
|
|
|
|
nsIDOMMozCSSKeyframeRule** aResult)
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t index = FindRuleIndexForKey(aKey);
|
2011-04-12 06:18:43 +00:00
|
|
|
if (index == RULE_NOT_FOUND) {
|
2012-07-30 14:20:58 +00:00
|
|
|
*aResult = nullptr;
|
2011-04-12 06:18:43 +00:00
|
|
|
} else {
|
|
|
|
NS_ADDREF(*aResult = static_cast<nsCSSKeyframeRule*>(mRules[index]));
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// GroupRule interface
|
2011-09-29 06:19:26 +00:00
|
|
|
/* virtual */ bool
|
2011-04-12 06:18:43 +00:00
|
|
|
nsCSSKeyframesRule::UseForPresentation(nsPresContext* aPresContext,
|
|
|
|
nsMediaQueryResultCacheKey& aKey)
|
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(false, "should not be called");
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2011-04-12 06:18:43 +00:00
|
|
|
}
|
|
|
|
|
2012-01-03 02:19:14 +00:00
|
|
|
/* virtual */ size_t
|
2013-06-23 12:03:39 +00:00
|
|
|
nsCSSKeyframesRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
2012-01-03 02:19:14 +00:00
|
|
|
{
|
|
|
|
size_t n = aMallocSizeOf(this);
|
|
|
|
n += GroupRule::SizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
|
|
|
|
// Measurement of the following members may be added later if DMD finds it is
|
|
|
|
// worthwhile:
|
|
|
|
// - mName
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2012-08-31 21:21:28 +00:00
|
|
|
// -------------------------------------------
|
|
|
|
// nsCSSPageStyleDeclaration
|
|
|
|
//
|
|
|
|
|
|
|
|
nsCSSPageStyleDeclaration::nsCSSPageStyleDeclaration(nsCSSPageRule* aRule)
|
|
|
|
: mRule(aRule)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSPageStyleDeclaration::~nsCSSPageStyleDeclaration()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!mRule, "DropReference not called.");
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsCSSPageStyleDeclaration)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsCSSPageStyleDeclaration)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(nsCSSPageStyleDeclaration)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSPageStyleDeclaration)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsDOMCSSDeclaration)
|
|
|
|
|
|
|
|
css::Declaration*
|
2015-04-10 00:41:35 +00:00
|
|
|
nsCSSPageStyleDeclaration::GetCSSDeclaration(Operation aOperation)
|
2012-08-31 21:21:28 +00:00
|
|
|
{
|
|
|
|
if (mRule) {
|
|
|
|
return mRule->Declaration();
|
|
|
|
} else {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsCSSPageStyleDeclaration::GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv)
|
|
|
|
{
|
|
|
|
GetCSSParsingEnvironmentForRule(mRule, aCSSParseEnv);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSPageStyleDeclaration::GetParentRule(nsIDOMCSSRule** aParent)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aParent);
|
|
|
|
|
|
|
|
NS_IF_ADDREF(*aParent = mRule);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsCSSPageStyleDeclaration::SetCSSDeclaration(css::Declaration* aDecl)
|
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(aDecl, "must be non-null");
|
2012-08-31 21:21:28 +00:00
|
|
|
mRule->ChangeDeclaration(aDecl);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDocument*
|
|
|
|
nsCSSPageStyleDeclaration::DocToUpdate()
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsINode*
|
|
|
|
nsCSSPageStyleDeclaration::GetParentObject()
|
|
|
|
{
|
|
|
|
return mRule ? mRule->GetDocument() : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------
|
|
|
|
// nsCSSPageRule
|
|
|
|
//
|
|
|
|
|
|
|
|
nsCSSPageRule::nsCSSPageRule(const nsCSSPageRule& aCopy)
|
|
|
|
// copy everything except our reference count and mDOMDeclaration
|
|
|
|
: Rule(aCopy)
|
|
|
|
, mDeclaration(new css::Declaration(*aCopy.mDeclaration))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSPageRule::~nsCSSPageRule()
|
|
|
|
{
|
|
|
|
if (mDOMDeclaration) {
|
|
|
|
mDOMDeclaration->DropReference();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ already_AddRefed<css::Rule>
|
|
|
|
nsCSSPageRule::Clone() const
|
|
|
|
{
|
|
|
|
nsRefPtr<css::Rule> clone = new nsCSSPageRule(*this);
|
|
|
|
return clone.forget();
|
|
|
|
}
|
|
|
|
|
2013-06-13 22:13:13 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsCSSPageRule)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsCSSPageRule)
|
|
|
|
|
2013-08-02 01:29:05 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsCSSPageRule)
|
|
|
|
|
2013-06-13 22:13:13 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsCSSPageRule)
|
|
|
|
if (tmp->mDOMDeclaration) {
|
|
|
|
tmp->mDOMDeclaration->DropReference();
|
|
|
|
tmp->mDOMDeclaration = nullptr;
|
|
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCSSPageRule)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDOMDeclaration)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
2012-08-31 21:21:28 +00:00
|
|
|
|
|
|
|
// QueryInterface implementation for nsCSSPageRule
|
2013-06-13 22:13:13 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSPageRule)
|
2012-08-31 21:21:28 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSPageRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSPageRule)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(nsCSSPageRule, Rule)
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
nsCSSPageRule::List(FILE* out, int32_t aIndent) const
|
|
|
|
{
|
2014-11-27 06:29:44 +00:00
|
|
|
nsAutoCString str;
|
2014-11-27 06:29:44 +00:00
|
|
|
for (int32_t indent = aIndent; --indent >= 0; ) {
|
2014-11-27 06:29:44 +00:00
|
|
|
str.AppendLiteral(" ");
|
2014-11-27 06:29:44 +00:00
|
|
|
}
|
2012-11-20 19:55:14 +00:00
|
|
|
|
2014-11-27 06:29:44 +00:00
|
|
|
str.AppendLiteral("@page { ");
|
|
|
|
nsAutoString tmp;
|
|
|
|
mDeclaration->ToString(tmp);
|
|
|
|
AppendUTF16toUTF8(tmp, str);
|
|
|
|
str.AppendLiteral("}\n");
|
|
|
|
fprintf_stderr(out, "%s", str.get());
|
2012-08-31 21:21:28 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* virtual */ int32_t
|
|
|
|
nsCSSPageRule::GetType() const
|
|
|
|
{
|
|
|
|
return Rule::PAGE_RULE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSPageRule::GetType(uint16_t* aType)
|
|
|
|
{
|
|
|
|
*aType = nsIDOMCSSRule::PAGE_RULE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSPageRule::GetCssText(nsAString& aCssText)
|
|
|
|
{
|
|
|
|
aCssText.AppendLiteral("@page { ");
|
|
|
|
nsAutoString tmp;
|
|
|
|
mDeclaration->ToString(tmp);
|
|
|
|
aCssText.Append(tmp);
|
|
|
|
aCssText.AppendLiteral(" }");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSPageRule::SetCssText(const nsAString& aCssText)
|
|
|
|
{
|
|
|
|
// FIXME: implement???
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSPageRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
|
|
|
|
{
|
|
|
|
return Rule::GetParentStyleSheet(aSheet);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSPageRule::GetParentRule(nsIDOMCSSRule** aParentRule)
|
|
|
|
{
|
|
|
|
return Rule::GetParentRule(aParentRule);
|
|
|
|
}
|
|
|
|
|
2014-07-14 22:57:46 +00:00
|
|
|
css::Rule*
|
|
|
|
nsCSSPageRule::GetCSSRule()
|
|
|
|
{
|
|
|
|
return Rule::GetCSSRule();
|
|
|
|
}
|
|
|
|
|
2012-08-31 21:21:28 +00:00
|
|
|
css::ImportantRule*
|
|
|
|
nsCSSPageRule::GetImportantRule()
|
|
|
|
{
|
|
|
|
if (!mDeclaration->HasImportantData()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
if (!mImportantRule) {
|
|
|
|
mImportantRule = new css::ImportantRule(mDeclaration);
|
|
|
|
}
|
|
|
|
return mImportantRule;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsCSSPageRule::MapRuleInfoInto(nsRuleData* aRuleData)
|
|
|
|
{
|
|
|
|
mDeclaration->MapNormalRuleInfoInto(aRuleData);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSPageRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
|
|
|
|
{
|
|
|
|
if (!mDOMDeclaration) {
|
|
|
|
mDOMDeclaration = new nsCSSPageStyleDeclaration(this);
|
|
|
|
}
|
|
|
|
NS_ADDREF(*aStyle = mDOMDeclaration);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsCSSPageRule::ChangeDeclaration(css::Declaration* aDeclaration)
|
|
|
|
{
|
|
|
|
mImportantRule = nullptr;
|
2013-01-09 18:33:09 +00:00
|
|
|
// Be careful to not assign to an nsAutoPtr if we would be assigning
|
|
|
|
// the thing it already holds.
|
|
|
|
if (aDeclaration != mDeclaration) {
|
|
|
|
mDeclaration = aDeclaration;
|
|
|
|
}
|
2012-08-31 21:21:28 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* sheet = GetStyleSheet();
|
2012-08-31 21:21:28 +00:00
|
|
|
if (sheet) {
|
|
|
|
sheet->SetModifiedByChildRule();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ size_t
|
2013-06-23 12:03:39 +00:00
|
|
|
nsCSSPageRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
2012-08-31 21:21:28 +00:00
|
|
|
{
|
|
|
|
return aMallocSizeOf(this);
|
|
|
|
}
|
|
|
|
|
2012-08-02 00:32:12 +00:00
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
CSSSupportsRule::CSSSupportsRule(bool aConditionMet,
|
2014-07-14 22:57:54 +00:00
|
|
|
const nsString& aCondition,
|
|
|
|
uint32_t aLineNumber, uint32_t aColumnNumber)
|
|
|
|
: css::GroupRule(aLineNumber, aColumnNumber)
|
|
|
|
, mUseGroup(aConditionMet)
|
|
|
|
, mCondition(aCondition)
|
2012-08-02 00:32:12 +00:00
|
|
|
{
|
|
|
|
}
|
2012-01-03 02:19:14 +00:00
|
|
|
|
2014-07-08 21:23:18 +00:00
|
|
|
CSSSupportsRule::~CSSSupportsRule()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-02 00:32:12 +00:00
|
|
|
CSSSupportsRule::CSSSupportsRule(const CSSSupportsRule& aCopy)
|
|
|
|
: css::GroupRule(aCopy),
|
|
|
|
mUseGroup(aCopy.mUseGroup),
|
|
|
|
mCondition(aCopy.mCondition)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* virtual */ void
|
2012-08-22 15:56:38 +00:00
|
|
|
CSSSupportsRule::List(FILE* out, int32_t aIndent) const
|
2012-08-02 00:32:12 +00:00
|
|
|
{
|
2014-11-27 06:29:44 +00:00
|
|
|
nsAutoCString indentStr;
|
2014-11-27 06:29:44 +00:00
|
|
|
for (int32_t indent = aIndent; --indent >= 0; ) {
|
2014-11-27 06:29:44 +00:00
|
|
|
indentStr.AppendLiteral(" ");
|
2014-11-27 06:29:44 +00:00
|
|
|
}
|
2012-08-02 00:32:12 +00:00
|
|
|
|
2014-11-27 06:29:44 +00:00
|
|
|
fprintf_stderr(out, "%s@supports %s {\n",
|
|
|
|
indentStr.get(), NS_ConvertUTF16toUTF8(mCondition).get());
|
|
|
|
|
2012-08-02 00:32:12 +00:00
|
|
|
css::GroupRule::List(out, aIndent);
|
2014-11-27 06:29:44 +00:00
|
|
|
|
|
|
|
fprintf_stderr(out, "%s}\n", indentStr.get());
|
2012-08-02 00:32:12 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
/* virtual */ int32_t
|
2012-08-02 00:32:12 +00:00
|
|
|
CSSSupportsRule::GetType() const
|
|
|
|
{
|
|
|
|
return Rule::SUPPORTS_RULE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ already_AddRefed<mozilla::css::Rule>
|
|
|
|
CSSSupportsRule::Clone() const
|
|
|
|
{
|
|
|
|
nsRefPtr<css::Rule> clone = new CSSSupportsRule(*this);
|
|
|
|
return clone.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ bool
|
|
|
|
CSSSupportsRule::UseForPresentation(nsPresContext* aPresContext,
|
|
|
|
nsMediaQueryResultCacheKey& aKey)
|
|
|
|
{
|
|
|
|
return mUseGroup;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(CSSSupportsRule, css::GroupRule)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(CSSSupportsRule, css::GroupRule)
|
|
|
|
|
|
|
|
// QueryInterface implementation for CSSSupportsRule
|
|
|
|
NS_INTERFACE_MAP_BEGIN(CSSSupportsRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
|
2012-11-27 05:30:30 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSGroupingRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSConditionRule)
|
2012-08-02 00:32:12 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSSupportsRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSSupportsRule)
|
2012-10-08 02:39:09 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(GroupRule)
|
2012-08-02 00:32:12 +00:00
|
|
|
|
|
|
|
// nsIDOMCSSRule methods
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
CSSSupportsRule::GetType(uint16_t* aType)
|
2012-08-02 00:32:12 +00:00
|
|
|
{
|
|
|
|
*aType = nsIDOMCSSRule::SUPPORTS_RULE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSSupportsRule::GetCssText(nsAString& aCssText)
|
|
|
|
{
|
|
|
|
aCssText.AssignLiteral("@supports ");
|
|
|
|
aCssText.Append(mCondition);
|
2013-08-02 07:04:31 +00:00
|
|
|
css::GroupRule::AppendRulesToCssText(aCssText);
|
|
|
|
return NS_OK;
|
2012-08-02 00:32:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSSupportsRule::SetCssText(const nsAString& aCssText)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSSupportsRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
|
|
|
|
{
|
|
|
|
return css::GroupRule::GetParentStyleSheet(aSheet);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSSupportsRule::GetParentRule(nsIDOMCSSRule** aParentRule)
|
|
|
|
{
|
|
|
|
return css::GroupRule::GetParentRule(aParentRule);
|
|
|
|
}
|
|
|
|
|
2014-07-14 22:57:46 +00:00
|
|
|
css::Rule*
|
|
|
|
CSSSupportsRule::GetCSSRule()
|
|
|
|
{
|
|
|
|
return css::GroupRule::GetCSSRule();
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:30:30 +00:00
|
|
|
// nsIDOMCSSGroupingRule methods
|
2012-08-02 00:32:12 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSSupportsRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
|
|
|
|
{
|
|
|
|
return css::GroupRule::GetCssRules(aRuleList);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
CSSSupportsRule::InsertRule(const nsAString & aRule, uint32_t aIndex, uint32_t* _retval)
|
2012-08-02 00:32:12 +00:00
|
|
|
{
|
|
|
|
return css::GroupRule::InsertRule(aRule, aIndex, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
CSSSupportsRule::DeleteRule(uint32_t aIndex)
|
2012-08-02 00:32:12 +00:00
|
|
|
{
|
|
|
|
return css::GroupRule::DeleteRule(aIndex);
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:30:30 +00:00
|
|
|
// nsIDOMCSSConditionRule methods
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSSupportsRule::GetConditionText(nsAString& aConditionText)
|
|
|
|
{
|
|
|
|
aConditionText.Assign(mCondition);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSSupportsRule::SetConditionText(const nsAString& aConditionText)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ size_t
|
2013-06-23 12:03:39 +00:00
|
|
|
CSSSupportsRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
2012-11-27 05:30:30 +00:00
|
|
|
{
|
|
|
|
size_t n = aMallocSizeOf(this);
|
|
|
|
n += css::GroupRule::SizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
n += mCondition.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2012-08-02 00:32:12 +00:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-06-12 01:10:00 +00:00
|
|
|
// -------------------------------------------
|
|
|
|
// nsCSSCounterStyleRule
|
|
|
|
//
|
|
|
|
|
|
|
|
nsCSSCounterStyleRule::nsCSSCounterStyleRule(const nsCSSCounterStyleRule& aCopy)
|
2014-07-25 01:50:24 +00:00
|
|
|
: Rule(aCopy)
|
|
|
|
, mName(aCopy.mName)
|
|
|
|
, mGeneration(aCopy.mGeneration)
|
2014-06-12 01:10:00 +00:00
|
|
|
{
|
2014-07-25 01:50:24 +00:00
|
|
|
for (size_t i = 0; i < ArrayLength(mValues); ++i) {
|
|
|
|
mValues[i] = aCopy.mValues[i];
|
|
|
|
}
|
2014-06-12 01:10:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSCounterStyleRule::~nsCSSCounterStyleRule()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ already_AddRefed<css::Rule>
|
|
|
|
nsCSSCounterStyleRule::Clone() const
|
|
|
|
{
|
|
|
|
nsRefPtr<css::Rule> clone = new nsCSSCounterStyleRule(*this);
|
|
|
|
return clone.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSCounterStyleRule::Getter const
|
|
|
|
nsCSSCounterStyleRule::kGetters[] = {
|
|
|
|
#define CSS_COUNTER_DESC(name_, method_) &nsCSSCounterStyleRule::Get##method_,
|
|
|
|
#include "nsCSSCounterDescList.h"
|
|
|
|
#undef CSS_COUNTER_DESC
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(nsCSSCounterStyleRule)
|
|
|
|
NS_IMPL_RELEASE(nsCSSCounterStyleRule)
|
|
|
|
|
|
|
|
// QueryInterface implementation for nsCSSCounterStyleRule
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsCSSCounterStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSCounterStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSCounterStyleRule)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
IMPL_STYLE_RULE_INHERIT(nsCSSCounterStyleRule, css::Rule)
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
nsCSSCounterStyleRule::List(FILE* out, int32_t aIndent) const
|
|
|
|
{
|
|
|
|
nsCString baseInd, descInd;
|
|
|
|
for (int32_t indent = aIndent; --indent >= 0; ) {
|
|
|
|
baseInd.AppendLiteral(" ");
|
|
|
|
}
|
|
|
|
descInd = baseInd;
|
|
|
|
descInd.AppendLiteral(" ");
|
|
|
|
|
2014-11-27 06:29:44 +00:00
|
|
|
fprintf_stderr(out, "%s@counter-style %s (rev.%u) {\n",
|
|
|
|
baseInd.get(), NS_ConvertUTF16toUTF8(mName).get(),
|
|
|
|
mGeneration);
|
2014-06-12 01:10:00 +00:00
|
|
|
// TODO
|
2014-11-27 06:29:44 +00:00
|
|
|
fprintf_stderr(out, "%s}\n", baseInd.get());
|
2014-06-12 01:10:00 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* virtual */ int32_t
|
|
|
|
nsCSSCounterStyleRule::GetType() const
|
|
|
|
{
|
|
|
|
return Rule::COUNTER_STYLE_RULE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIDOMCSSRule methods
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSCounterStyleRule::GetType(uint16_t* aType)
|
|
|
|
{
|
|
|
|
*aType = nsIDOMCSSRule::COUNTER_STYLE_RULE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSCounterStyleRule::GetCssText(nsAString& aCssText)
|
|
|
|
{
|
|
|
|
aCssText.AssignLiteral(MOZ_UTF16("@counter-style "));
|
|
|
|
nsStyleUtil::AppendEscapedCSSIdent(mName, aCssText);
|
|
|
|
aCssText.AppendLiteral(MOZ_UTF16(" {\n"));
|
|
|
|
for (nsCSSCounterDesc id = nsCSSCounterDesc(0);
|
|
|
|
id < eCSSCounterDesc_COUNT;
|
|
|
|
id = nsCSSCounterDesc(id + 1)) {
|
|
|
|
if (mValues[id].GetUnit() != eCSSUnit_Null) {
|
|
|
|
nsAutoString tmp;
|
|
|
|
(this->*kGetters[id])(tmp);
|
|
|
|
aCssText.AppendLiteral(MOZ_UTF16(" "));
|
|
|
|
AppendASCIItoUTF16(nsCSSProps::GetStringValue(id), aCssText);
|
|
|
|
aCssText.AppendLiteral(MOZ_UTF16(": "));
|
|
|
|
aCssText.Append(tmp);
|
|
|
|
aCssText.AppendLiteral(MOZ_UTF16(";\n"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aCssText.AppendLiteral(MOZ_UTF16("}"));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSCounterStyleRule::SetCssText(const nsAString& aCssText)
|
|
|
|
{
|
|
|
|
// FIXME: implement???
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSCounterStyleRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
|
|
|
|
{
|
|
|
|
return Rule::GetParentStyleSheet(aSheet);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSCounterStyleRule::GetParentRule(nsIDOMCSSRule** aParentRule)
|
|
|
|
{
|
|
|
|
return Rule::GetParentRule(aParentRule);
|
|
|
|
}
|
|
|
|
|
2014-07-14 22:57:46 +00:00
|
|
|
css::Rule*
|
|
|
|
nsCSSCounterStyleRule::GetCSSRule()
|
|
|
|
{
|
|
|
|
return Rule::GetCSSRule();
|
|
|
|
}
|
|
|
|
|
2014-06-12 01:10:00 +00:00
|
|
|
// nsIDOMCSSCounterStyleRule methods
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSCounterStyleRule::GetName(nsAString& aName)
|
|
|
|
{
|
|
|
|
aName.Truncate();
|
|
|
|
nsStyleUtil::AppendEscapedCSSIdent(mName, aName);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSCounterStyleRule::SetName(const nsAString& aName)
|
|
|
|
{
|
|
|
|
nsCSSParser parser;
|
|
|
|
nsAutoString name;
|
|
|
|
if (parser.ParseCounterStyleName(aName, nullptr, name)) {
|
|
|
|
nsIDocument* doc = GetDocument();
|
|
|
|
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
|
|
|
|
|
|
|
|
mName = name;
|
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* sheet = GetStyleSheet();
|
2014-06-12 01:10:00 +00:00
|
|
|
if (sheet) {
|
|
|
|
sheet->SetModifiedByChildRule();
|
|
|
|
if (doc) {
|
|
|
|
doc->StyleRuleChanged(sheet, this, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t
|
|
|
|
nsCSSCounterStyleRule::GetSystem() const
|
|
|
|
{
|
|
|
|
const nsCSSValue& system = GetDesc(eCSSCounterDesc_System);
|
|
|
|
switch (system.GetUnit()) {
|
|
|
|
case eCSSUnit_Enumerated:
|
|
|
|
return system.GetIntValue();
|
|
|
|
case eCSSUnit_Pair:
|
|
|
|
return system.GetPairValue().mXValue.GetIntValue();
|
|
|
|
default:
|
|
|
|
return NS_STYLE_COUNTER_SYSTEM_SYMBOLIC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsCSSValue&
|
|
|
|
nsCSSCounterStyleRule::GetSystemArgument() const
|
|
|
|
{
|
|
|
|
const nsCSSValue& system = GetDesc(eCSSCounterDesc_System);
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(system.GetUnit() == eCSSUnit_Pair,
|
|
|
|
"Invalid system value");
|
2014-06-12 01:10:00 +00:00
|
|
|
return system.GetPairValue().mYValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsCSSCounterStyleRule::SetDesc(nsCSSCounterDesc aDescID, const nsCSSValue& aValue)
|
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(aDescID >= 0 && aDescID < eCSSCounterDesc_COUNT,
|
|
|
|
"descriptor ID out of range");
|
2014-06-12 01:10:00 +00:00
|
|
|
|
|
|
|
nsIDocument* doc = GetDocument();
|
|
|
|
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
|
|
|
|
|
|
|
|
mValues[aDescID] = aValue;
|
|
|
|
mGeneration++;
|
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* sheet = GetStyleSheet();
|
2014-06-12 01:10:00 +00:00
|
|
|
if (sheet) {
|
|
|
|
sheet->SetModifiedByChildRule();
|
|
|
|
if (doc) {
|
|
|
|
doc->StyleRuleChanged(sheet, this, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSCounterStyleRule::GetSystem(nsAString& aSystem)
|
|
|
|
{
|
|
|
|
const nsCSSValue& value = GetDesc(eCSSCounterDesc_System);
|
|
|
|
if (value.GetUnit() == eCSSUnit_Null) {
|
|
|
|
aSystem.Truncate();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
aSystem = NS_ConvertASCIItoUTF16(nsCSSProps::ValueToKeyword(
|
|
|
|
GetSystem(), nsCSSProps::kCounterSystemKTable));
|
|
|
|
if (value.GetUnit() == eCSSUnit_Pair) {
|
|
|
|
aSystem.Append(' ');
|
|
|
|
GetSystemArgument().AppendToString(
|
|
|
|
eCSSProperty_UNKNOWN, aSystem, nsCSSValue::eNormalized);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSCounterStyleRule::GetSymbols(nsAString& aSymbols)
|
|
|
|
{
|
|
|
|
const nsCSSValue& value = GetDesc(eCSSCounterDesc_Symbols);
|
|
|
|
|
|
|
|
aSymbols.Truncate();
|
|
|
|
if (value.GetUnit() == eCSSUnit_List) {
|
|
|
|
for (const nsCSSValueList* item = value.GetListValue();
|
|
|
|
item; item = item->mNext) {
|
|
|
|
item->mValue.AppendToString(eCSSProperty_UNKNOWN,
|
|
|
|
aSymbols,
|
|
|
|
nsCSSValue::eNormalized);
|
|
|
|
if (item->mNext) {
|
|
|
|
aSymbols.Append(' ');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSCounterStyleRule::GetAdditiveSymbols(nsAString& aSymbols)
|
|
|
|
{
|
|
|
|
const nsCSSValue& value = GetDesc(eCSSCounterDesc_AdditiveSymbols);
|
|
|
|
|
|
|
|
aSymbols.Truncate();
|
|
|
|
if (value.GetUnit() == eCSSUnit_PairList) {
|
|
|
|
for (const nsCSSValuePairList* item = value.GetPairListValue();
|
|
|
|
item; item = item->mNext) {
|
|
|
|
item->mXValue.AppendToString(eCSSProperty_UNKNOWN,
|
|
|
|
aSymbols, nsCSSValue::eNormalized);
|
|
|
|
aSymbols.Append(' ');
|
|
|
|
item->mYValue.AppendToString(eCSSProperty_UNKNOWN,
|
|
|
|
aSymbols, nsCSSValue::eNormalized);
|
|
|
|
if (item->mNext) {
|
|
|
|
aSymbols.AppendLiteral(", ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSCounterStyleRule::GetRange(nsAString& aRange)
|
|
|
|
{
|
|
|
|
const nsCSSValue& value = GetDesc(eCSSCounterDesc_Range);
|
|
|
|
|
|
|
|
switch (value.GetUnit()) {
|
|
|
|
case eCSSUnit_Auto:
|
|
|
|
aRange.AssignLiteral(MOZ_UTF16("auto"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCSSUnit_PairList:
|
|
|
|
aRange.Truncate();
|
|
|
|
for (const nsCSSValuePairList* item = value.GetPairListValue();
|
|
|
|
item; item = item->mNext) {
|
|
|
|
const nsCSSValue& lower = item->mXValue;
|
|
|
|
const nsCSSValue& upper = item->mYValue;
|
|
|
|
if (lower.GetUnit() == eCSSUnit_Enumerated) {
|
|
|
|
NS_ASSERTION(lower.GetIntValue() ==
|
|
|
|
NS_STYLE_COUNTER_RANGE_INFINITE,
|
|
|
|
"Unrecognized keyword");
|
|
|
|
aRange.AppendLiteral("infinite");
|
|
|
|
} else {
|
|
|
|
aRange.AppendInt(lower.GetIntValue());
|
|
|
|
}
|
|
|
|
aRange.Append(' ');
|
|
|
|
if (upper.GetUnit() == eCSSUnit_Enumerated) {
|
|
|
|
NS_ASSERTION(upper.GetIntValue() ==
|
|
|
|
NS_STYLE_COUNTER_RANGE_INFINITE,
|
|
|
|
"Unrecognized keyword");
|
|
|
|
aRange.AppendLiteral("infinite");
|
|
|
|
} else {
|
|
|
|
aRange.AppendInt(upper.GetIntValue());
|
|
|
|
}
|
|
|
|
if (item->mNext) {
|
|
|
|
aRange.AppendLiteral(", ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
aRange.Truncate();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCSSCounterStyleRule::GetSpeakAs(nsAString& aSpeakAs)
|
|
|
|
{
|
|
|
|
const nsCSSValue& value = GetDesc(eCSSCounterDesc_SpeakAs);
|
|
|
|
|
|
|
|
switch (value.GetUnit()) {
|
|
|
|
case eCSSUnit_Enumerated:
|
|
|
|
switch (value.GetIntValue()) {
|
|
|
|
case NS_STYLE_COUNTER_SPEAKAS_BULLETS:
|
|
|
|
aSpeakAs.AssignLiteral(MOZ_UTF16("bullets"));
|
|
|
|
break;
|
|
|
|
case NS_STYLE_COUNTER_SPEAKAS_NUMBERS:
|
|
|
|
aSpeakAs.AssignLiteral(MOZ_UTF16("numbers"));
|
|
|
|
break;
|
|
|
|
case NS_STYLE_COUNTER_SPEAKAS_WORDS:
|
|
|
|
aSpeakAs.AssignLiteral(MOZ_UTF16("words"));
|
|
|
|
break;
|
|
|
|
case NS_STYLE_COUNTER_SPEAKAS_SPELL_OUT:
|
|
|
|
aSpeakAs.AssignLiteral(MOZ_UTF16("spell-out"));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("Unknown speech synthesis");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCSSUnit_Auto:
|
|
|
|
case eCSSUnit_Ident:
|
|
|
|
aSpeakAs.Truncate();
|
|
|
|
value.AppendToString(eCSSProperty_UNKNOWN,
|
|
|
|
aSpeakAs, nsCSSValue::eNormalized);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
aSpeakAs.Truncate();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsCSSCounterStyleRule::GetDescriptor(nsCSSCounterDesc aDescID,
|
|
|
|
nsAString& aValue)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aDescID == eCSSCounterDesc_Negative ||
|
|
|
|
aDescID == eCSSCounterDesc_Prefix ||
|
|
|
|
aDescID == eCSSCounterDesc_Suffix ||
|
|
|
|
aDescID == eCSSCounterDesc_Pad ||
|
|
|
|
aDescID == eCSSCounterDesc_Fallback,
|
|
|
|
"Unexpected descriptor");
|
|
|
|
const nsCSSValue& value = GetDesc(aDescID);
|
|
|
|
aValue.Truncate();
|
|
|
|
if (value.GetUnit() != eCSSUnit_Null) {
|
|
|
|
value.AppendToString(
|
|
|
|
eCSSProperty_UNKNOWN, aValue, nsCSSValue::eNormalized);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CSS_COUNTER_DESC_GETTER(name_) \
|
|
|
|
NS_IMETHODIMP \
|
|
|
|
nsCSSCounterStyleRule::Get##name_(nsAString& a##name_) \
|
|
|
|
{ \
|
|
|
|
return GetDescriptor(eCSSCounterDesc_##name_, a##name_);\
|
|
|
|
}
|
|
|
|
CSS_COUNTER_DESC_GETTER(Negative)
|
|
|
|
CSS_COUNTER_DESC_GETTER(Prefix)
|
|
|
|
CSS_COUNTER_DESC_GETTER(Suffix)
|
|
|
|
CSS_COUNTER_DESC_GETTER(Pad)
|
|
|
|
CSS_COUNTER_DESC_GETTER(Fallback)
|
|
|
|
#undef CSS_COUNTER_DESC_GETTER
|
|
|
|
|
|
|
|
/* static */ bool
|
|
|
|
nsCSSCounterStyleRule::CheckDescValue(int32_t aSystem,
|
|
|
|
nsCSSCounterDesc aDescID,
|
|
|
|
const nsCSSValue& aValue)
|
|
|
|
{
|
|
|
|
switch (aDescID) {
|
|
|
|
case eCSSCounterDesc_System:
|
|
|
|
if (aValue.GetUnit() != eCSSUnit_Pair) {
|
|
|
|
return aValue.GetIntValue() == aSystem;
|
|
|
|
} else {
|
|
|
|
return aValue.GetPairValue().mXValue.GetIntValue() == aSystem;
|
|
|
|
}
|
|
|
|
|
|
|
|
case eCSSCounterDesc_Symbols:
|
|
|
|
switch (aSystem) {
|
|
|
|
case NS_STYLE_COUNTER_SYSTEM_NUMERIC:
|
|
|
|
case NS_STYLE_COUNTER_SYSTEM_ALPHABETIC:
|
|
|
|
// for these two system, the list must contain at least 2 elements
|
|
|
|
return aValue.GetListValue()->mNext;
|
|
|
|
case NS_STYLE_COUNTER_SYSTEM_EXTENDS:
|
|
|
|
// for extends system, no symbols should be set
|
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
case eCSSCounterDesc_AdditiveSymbols:
|
|
|
|
switch (aSystem) {
|
|
|
|
case NS_STYLE_COUNTER_SYSTEM_EXTENDS:
|
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsCSSCounterStyleRule::SetDescriptor(nsCSSCounterDesc aDescID,
|
|
|
|
const nsAString& aValue)
|
|
|
|
{
|
|
|
|
nsCSSParser parser;
|
|
|
|
nsCSSValue value;
|
2014-06-20 10:32:49 +00:00
|
|
|
CSSStyleSheet* sheet = GetStyleSheet();
|
2014-06-12 01:10:00 +00:00
|
|
|
nsIURI* baseURL = nullptr;
|
|
|
|
nsIPrincipal* principal = nullptr;
|
|
|
|
if (sheet) {
|
|
|
|
baseURL = sheet->GetBaseURI();
|
|
|
|
principal = sheet->Principal();
|
|
|
|
}
|
|
|
|
if (parser.ParseCounterDescriptor(aDescID, aValue, nullptr,
|
|
|
|
baseURL, principal, value)) {
|
|
|
|
if (CheckDescValue(GetSystem(), aDescID, value)) {
|
|
|
|
SetDesc(aDescID, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CSS_COUNTER_DESC_SETTER(name_) \
|
|
|
|
NS_IMETHODIMP \
|
|
|
|
nsCSSCounterStyleRule::Set##name_(const nsAString& a##name_) \
|
|
|
|
{ \
|
|
|
|
return SetDescriptor(eCSSCounterDesc_##name_, a##name_); \
|
|
|
|
}
|
|
|
|
CSS_COUNTER_DESC_SETTER(System)
|
|
|
|
CSS_COUNTER_DESC_SETTER(Symbols)
|
|
|
|
CSS_COUNTER_DESC_SETTER(AdditiveSymbols)
|
|
|
|
CSS_COUNTER_DESC_SETTER(Negative)
|
|
|
|
CSS_COUNTER_DESC_SETTER(Prefix)
|
|
|
|
CSS_COUNTER_DESC_SETTER(Suffix)
|
|
|
|
CSS_COUNTER_DESC_SETTER(Range)
|
|
|
|
CSS_COUNTER_DESC_SETTER(Pad)
|
|
|
|
CSS_COUNTER_DESC_SETTER(Fallback)
|
|
|
|
CSS_COUNTER_DESC_SETTER(SpeakAs)
|
|
|
|
#undef CSS_COUNTER_DESC_SETTER
|
|
|
|
|
|
|
|
/* virtual */ size_t
|
|
|
|
nsCSSCounterStyleRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
|
|
|
{
|
|
|
|
return aMallocSizeOf(this);
|
|
|
|
}
|