Files
palemoon27/layout/style/nsHTMLCSSStyleSheet.cpp
roytam1 0c05a61d5f import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1208584 - Silence unconstrained size warning by default. r=jfkthame (31f1771976)
- Bug 1248864 - Part 1: Move RestyleManager.h to EXPORTS.mozilla. r=dholbert (2ab8ae0d6a)
- Bug 1248864 - Part 2: Add skeleton ServoRestyleManager and a RestyleManagerHandle smart pointer. r=dholbert (8c9e032edc)
- Bug 1248864 - Part 3: Use RestyleManagerHandle instead of concrete restyle manager class. r=dholbert (ec282e77fa)
- Bug 1237825. Find the root scroll frame even if the root element doesn't have a primary frame. r=mstange (ed4f14ebd4)
- Bug 1237813. Refactor nsLayoutUtils::FindScrollableFrameFor to use GetScrollFrameFromContent. r=botond (403968c84c)
- Bug 1238777: Bail early from ComputeSnappedImageDrawingParameters if we're somehow drawing from a 0-sized subimage. r=tn (da3ccc27f0)
- Bug 1250377 - Part 1: Use MOZ_STYLO environment variable to switch on Servo-backed style system. r=bholley (4ce8d0bcf0)
- Bug 1250377 - Part 2: Stub out enough ServoStyleSet methods to be able to create one for a document. r=bholley (1ef3b5c843)
- Bug 1250377 - Part 3: Create a ServoStyleSet for HTML documents in content docshells. r=bholley (4ed1a5e6fc)
- Bug 1250790 - Don't try to add CSSStyleSheets from the style sheet service to a ServoStyleSet. r=bholley (f1291300d7)
- Bug 1247478: Rename FirstAdditionalAuthorSheet() to GetFirstAdditionalAuthorSheet(), since it can return null. r=heycam (cffd112172)
- Bug 1253007 - part 1 - use UniquePtr for RangePaintInfo in nsPresShell.cpp; r=dholbert (ad14ef91b7)
- Bug 1253007 - part 2 - pass a const& to PaintRangePaintInfo; rs=dholbert (9317f5b704)
- Bug 1171371 - On memory-pressure, remove any stale images from the visible images list. r=tn (9108fdc561)
- Bug 1251150. Add some crash annotations to try to track down a crash bug. r=dholbert (0b81d26d89)
- Bug 1257315 (Part 1) - Add a visualization of visibility tracking to the APZ minimap. r=botond,mattwoodrow (c15a5ce0f8)
- Bug 1257315 (Part 2) - Release old visible regions info when new info is available or a layers ID is no longer used. r=botond (3c5a1fb6e0)
- Rename PCompositor to PCompositorBridge. (bug 1258479 part 1, r=mattwoodrow) (77390ba817)
- Bug 1134385. Silk documentation. r=kats (23f43fa035)
- Bug 1134385 follow-up - fix link to image in documentation. DONTBUILD because NPOTB. r=me (68809f8347)
- Bug 1238743 - remove a bogus assertion in TextureClient.cpp. r=kats (6b10b546c5)
- Bug 1241484 - Null check mActor in WaitForCompositorRecycle. r=nical (95f848830f)
- Bug 1250117 - Fix b2g timeouts when gralloc is disabled. r=sotaro (2e67d92251)
- Bug 1250117 - Trivial b2g build fix. r=me (9fab71821d)
- Bug 1249273 - Enable BufferTextureHost to recycle a TextureSource that is not marked as owned. r=sotaro (f09b043af6)
- Bug 1250500 - Avoid copying BufferTextureHost when possible. r=sotaro (8f44549c6c)
- Bug 1248323: P1. Add support for YUV422 IOSurface. r=nical (e3eb53aa1c)
- Bug 1248323: P2. Add readback code for converting YUV422 MacIOSurfaces into RGB. r=nical (d93574fd13)
- Bug 1248323: P3. Add test for NV12/YUV422 readback. r=me (5373a2f839)
- Bug 1249273 - Lazily prepare TextureSources and recycle them when possible in ImageHost. r=sotaro (66bb273c84)
- Bug 1251910: Fix YUV422 IOSurface. r=mattwoodrow. (bfdbb2f60b)
2024-01-31 14:18:31 +08:00

215 lines
6.5 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
/*
* style sheet and style rule processor representing style attributes
*/
#include "nsHTMLCSSStyleSheet.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/css/StyleRule.h"
#include "nsIStyleRuleProcessor.h"
#include "nsPresContext.h"
#include "nsRuleWalker.h"
#include "nsRuleProcessorData.h"
#include "mozilla/dom/Element.h"
#include "nsAttrValue.h"
#include "nsAttrValueInlines.h"
#include "nsCSSPseudoElements.h"
#include "mozilla/RestyleManagerHandle.h"
#include "mozilla/RestyleManagerHandleInlines.h"
using namespace mozilla;
using namespace mozilla::dom;
nsHTMLCSSStyleSheet::nsHTMLCSSStyleSheet()
{
}
nsHTMLCSSStyleSheet::~nsHTMLCSSStyleSheet()
{
// We may go away before all of our cached style attributes do,
// so clean up any that are left.
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.
MOZ_ASSERT(value->mType == nsAttrValue::eCSSDeclaration);
css::Declaration* declaration = value->mValue.mCSSDeclaration;
declaration->SetHTMLCSSStyleSheet(nullptr);
value->mValue.mCached = 0;
iter.Remove();
}
}
NS_IMPL_ISUPPORTS(nsHTMLCSSStyleSheet, nsIStyleRuleProcessor)
/* virtual */ void
nsHTMLCSSStyleSheet::RulesMatching(ElementRuleProcessorData* aData)
{
ElementRulesMatching(aData->mPresContext, aData->mElement,
aData->mRuleWalker);
}
void
nsHTMLCSSStyleSheet::ElementRulesMatching(nsPresContext* aPresContext,
Element* aElement,
nsRuleWalker* aRuleWalker)
{
// just get the one and only style rule from the content's STYLE attribute
css::Declaration* declaration = aElement->GetInlineStyleDeclaration();
if (declaration) {
declaration->SetImmutable();
aRuleWalker->Forward(declaration);
}
declaration = aElement->GetSMILOverrideStyleDeclaration();
if (declaration) {
MOZ_ASSERT(aPresContext->RestyleManager()->IsGecko(),
"stylo: ElementRulesMatching must not be called when we have "
"a Servo-backed style system");
RestyleManager* restyleManager = aPresContext->RestyleManager()->AsGecko();
if (!restyleManager->SkipAnimationRules()) {
// Animation restyle (or non-restyle traversal of rules)
// Now we can walk SMIL overrride style, without triggering transitions.
declaration->SetImmutable();
aRuleWalker->Forward(declaration);
}
}
}
void
nsHTMLCSSStyleSheet::PseudoElementRulesMatching(Element* aPseudoElement,
CSSPseudoElementType
aPseudoType,
nsRuleWalker* aRuleWalker)
{
MOZ_ASSERT(nsCSSPseudoElements::
PseudoElementSupportsStyleAttribute(aPseudoType));
MOZ_ASSERT(aPseudoElement);
// just get the one and only style rule from the content's STYLE attribute
css::Declaration* declaration = aPseudoElement->GetInlineStyleDeclaration();
if (declaration) {
declaration->SetImmutable();
aRuleWalker->Forward(declaration);
}
}
/* virtual */ void
nsHTMLCSSStyleSheet::RulesMatching(PseudoElementRuleProcessorData* aData)
{
if (nsCSSPseudoElements::PseudoElementSupportsStyleAttribute(aData->mPseudoType) &&
aData->mPseudoElement) {
PseudoElementRulesMatching(aData->mPseudoElement, aData->mPseudoType,
aData->mRuleWalker);
}
}
/* virtual */ void
nsHTMLCSSStyleSheet::RulesMatching(AnonBoxRuleProcessorData* aData)
{
}
#ifdef MOZ_XUL
/* virtual */ void
nsHTMLCSSStyleSheet::RulesMatching(XULTreeRuleProcessorData* aData)
{
}
#endif
// Test if style is dependent on content state
/* virtual */ nsRestyleHint
nsHTMLCSSStyleSheet::HasStateDependentStyle(StateRuleProcessorData* aData)
{
return nsRestyleHint(0);
}
/* virtual */ nsRestyleHint
nsHTMLCSSStyleSheet::HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData)
{
return nsRestyleHint(0);
}
/* virtual */ bool
nsHTMLCSSStyleSheet::HasDocumentStateDependentStyle(StateRuleProcessorData* aData)
{
return false;
}
// Test if style is dependent on attribute
/* virtual */ nsRestyleHint
nsHTMLCSSStyleSheet::HasAttributeDependentStyle(
AttributeRuleProcessorData* aData,
RestyleHintData& aRestyleHintDataResult)
{
// Perhaps should check that it's XUL, SVG, (or HTML) namespace, but
// it doesn't really matter.
if (aData->mAttrHasChanged && aData->mAttribute == nsGkAtoms::style) {
return eRestyle_StyleAttribute;
}
return nsRestyleHint(0);
}
/* virtual */ bool
nsHTMLCSSStyleSheet::MediumFeaturesChanged(nsPresContext* aPresContext)
{
return false;
}
/* virtual */ size_t
nsHTMLCSSStyleSheet::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
// The size of mCachedStyleAttrs's mTable member (a PLDHashTable) is
// significant in itself, but more significant is the size of the nsString
// members of the nsStringHashKeys.
size_t n = 0;
n += mCachedStyleAttrs.ShallowSizeOfExcludingThis(aMallocSizeOf);
for (auto iter = mCachedStyleAttrs.ConstIter(); !iter.Done(); iter.Next()) {
// We don't own the MiscContainers (the hash table values) so we don't
// count them. We do care about the size of the nsString members in the
// keys though.
n += iter.Key().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
}
return n;
}
/* virtual */ size_t
nsHTMLCSSStyleSheet::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
void
nsHTMLCSSStyleSheet::CacheStyleAttr(const nsAString& aSerialized,
MiscContainer* aValue)
{
mCachedStyleAttrs.Put(aSerialized, aValue);
}
void
nsHTMLCSSStyleSheet::EvictStyleAttr(const nsAString& aSerialized,
MiscContainer* aValue)
{
#ifdef DEBUG
{
NS_ASSERTION(aValue == mCachedStyleAttrs.Get(aSerialized),
"Cached value does not match?!");
}
#endif
mCachedStyleAttrs.Remove(aSerialized);
}
MiscContainer*
nsHTMLCSSStyleSheet::LookupStyleAttr(const nsAString& aSerialized)
{
return mCachedStyleAttrs.Get(aSerialized);
}