2015-11-23 08:12:49 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-02-27 04:35:25 +03:00
|
|
|
|
2006-03-25 08:47:31 +03:00
|
|
|
/*
|
|
|
|
* style sheet and style rule processor representing style attributes
|
|
|
|
*/
|
|
|
|
|
2009-12-31 18:56:32 +03:00
|
|
|
#include "nsHTMLCSSStyleSheet.h"
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2018-05-30 19:15:25 +03:00
|
|
|
#include "mozilla/DeclarationBlock.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2010-05-05 22:18:05 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2012-09-30 20:40:24 +04:00
|
|
|
#include "nsAttrValue.h"
|
|
|
|
#include "nsAttrValueInlines.h"
|
2016-02-17 23:37:00 +03:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2017-02-13 06:21:33 +03:00
|
|
|
#include "mozilla/RestyleManager.h"
|
2010-04-30 17:12:06 +04:00
|
|
|
|
2013-11-15 06:42:57 +04:00
|
|
|
using namespace mozilla;
|
2010-04-30 17:12:06 +04:00
|
|
|
using namespace mozilla::dom;
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2020-03-17 12:38:32 +03:00
|
|
|
nsHTMLCSSStyleSheet::nsHTMLCSSStyleSheet() = default;
|
1998-05-14 03:42:18 +04:00
|
|
|
|
2012-09-30 20:40:24 +04:00
|
|
|
nsHTMLCSSStyleSheet::~nsHTMLCSSStyleSheet() {
|
|
|
|
// We may go away before all of our cached style attributes do,
|
|
|
|
// so clean up any that are left.
|
2015-11-23 08:12:49 +03:00
|
|
|
for (auto iter = mCachedStyleAttrs.Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
MiscContainer*& value = iter.Data();
|
|
|
|
|
|
|
|
// Ideally we'd just call MiscContainer::Evict, but we can't do that since
|
|
|
|
// we're iterating the hashtable.
|
2016-10-18 07:29:03 +03:00
|
|
|
if (value->mType == nsAttrValue::eCSSDeclaration) {
|
|
|
|
DeclarationBlock* declaration = value->mValue.mCSSDeclaration;
|
|
|
|
declaration->SetHTMLCSSStyleSheet(nullptr);
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("unexpected cached nsAttrValue type");
|
2016-06-24 06:35:12 +03:00
|
|
|
}
|
2015-11-23 08:12:49 +03:00
|
|
|
|
|
|
|
value->mValue.mCached = 0;
|
|
|
|
iter.Remove();
|
|
|
|
}
|
2012-09-30 20:40:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHTMLCSSStyleSheet::CacheStyleAttr(const nsAString& aSerialized,
|
|
|
|
MiscContainer* aValue) {
|
2021-02-26 12:11:46 +03:00
|
|
|
mCachedStyleAttrs.InsertOrUpdate(aSerialized, aValue);
|
2012-09-30 20:40:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHTMLCSSStyleSheet::EvictStyleAttr(const nsAString& aSerialized,
|
|
|
|
MiscContainer* aValue) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
2015-04-20 21:43:06 +03:00
|
|
|
NS_ASSERTION(aValue == mCachedStyleAttrs.Get(aSerialized),
|
2012-09-30 20:40:24 +04:00
|
|
|
"Cached value does not match?!");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
mCachedStyleAttrs.Remove(aSerialized);
|
|
|
|
}
|
|
|
|
|
|
|
|
MiscContainer* nsHTMLCSSStyleSheet::LookupStyleAttr(
|
|
|
|
const nsAString& aSerialized) {
|
|
|
|
return mCachedStyleAttrs.Get(aSerialized);
|
|
|
|
}
|