Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2022-04-27 16:25:45 +08:00
commit e78e741a17
45 changed files with 1137 additions and 43 deletions

View file

@ -15,6 +15,7 @@
#include "FrameLayerBuilder.h"
#include "nsSVGEffects.h"
#include "imgIContainer.h"
#include "Image.h"
namespace mozilla {
namespace css {
@ -394,6 +395,14 @@ ImageLoader::Notify(imgIRequest* aRequest, int32_t aType, const nsIntRect* aData
return OnFrameUpdate(aRequest);
}
if (aType == imgINotificationObserver::DECODE_COMPLETE) {
nsCOMPtr<imgIContainer> image;
aRequest->GetImage(getter_AddRefs(image));
if (image && mDocument) {
image->PropagateUseCounters(mDocument);
}
}
return NS_OK;
}
@ -499,5 +508,19 @@ ImageLoader::UnblockOnload(imgIRequest* aRequest)
return NS_OK;
}
void
ImageLoader::FlushUseCounters()
{
for (auto iter = mImages.Iter(); !iter.Done(); iter.Next()) {
nsPtrHashKey<Image>* key = iter.Get();
ImageLoader::Image* image = key->GetKey();
imgIRequest* request = image->mRequests.GetWeak(mDocument);
nsCOMPtr<imgIContainer> container;
request->GetImage(getter_AddRefs(container));
}
}
} // namespace css
} // namespace mozilla

View file

@ -70,6 +70,8 @@ public:
void DestroyRequest(imgIRequest* aRequest);
void FlushUseCounters();
private:
~ImageLoader() {}

View file

@ -681,12 +681,14 @@ nsCSSExpandedDataBlock::TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
bool aIsImportant,
bool aOverrideImportant,
bool aMustCallValueAppended,
css::Declaration* aDeclaration)
css::Declaration* aDeclaration,
nsIDocument* aSheetDocument)
{
if (!nsCSSProps::IsShorthand(aPropID)) {
return DoTransferFromBlock(aFromBlock, aPropID,
aIsImportant, aOverrideImportant,
aMustCallValueAppended, aDeclaration);
aMustCallValueAppended, aDeclaration,
aSheetDocument);
}
// We can pass CSSEnabledState::eIgnore (here, and in ClearProperty
@ -698,7 +700,8 @@ nsCSSExpandedDataBlock::TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aPropID, aEnabledState) {
changed |= DoTransferFromBlock(aFromBlock, *p,
aIsImportant, aOverrideImportant,
aMustCallValueAppended, aDeclaration);
aMustCallValueAppended, aDeclaration,
aSheetDocument);
}
return changed;
}
@ -709,7 +712,8 @@ nsCSSExpandedDataBlock::DoTransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
bool aIsImportant,
bool aOverrideImportant,
bool aMustCallValueAppended,
css::Declaration* aDeclaration)
css::Declaration* aDeclaration,
nsIDocument* aSheetDocument)
{
bool changed = false;
MOZ_ASSERT(aFromBlock.HasPropertyBit(aPropID), "oops");
@ -737,6 +741,13 @@ nsCSSExpandedDataBlock::DoTransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
aDeclaration->ValueAppended(aPropID);
}
if (aSheetDocument) {
UseCounter useCounter = nsCSSProps::UseCounterFor(aPropID);
if (useCounter != eUseCounter_UNKNOWN) {
aSheetDocument->SetDocumentAndPageUseCounter(useCounter);
}
}
SetPropertyBit(aPropID);
aFromBlock.ClearPropertyBit(aPropID);

View file

@ -20,6 +20,7 @@
struct nsRuleData;
class nsCSSExpandedDataBlock;
class nsIDocument;
namespace mozilla {
namespace css {
@ -257,6 +258,8 @@ public:
* Returns true if something changed, false otherwise. Calls
* |ValueAppended| on |aDeclaration| if the property was not
* previously set, or in any case if |aMustCallValueAppended| is true.
* Calls |SetDocumentAndPageUseCounter| on |aSheetDocument| if it is
* non-null and |aPropID| has a use counter.
*/
bool TransferFromBlock(nsCSSExpandedDataBlock& aFromBlock,
nsCSSPropertyID aPropID,
@ -264,7 +267,8 @@ public:
bool aIsImportant,
bool aOverrideImportant,
bool aMustCallValueAppended,
mozilla::css::Declaration* aDeclaration);
mozilla::css::Declaration* aDeclaration,
nsIDocument* aSheetDocument);
/**
* Copies the values for aPropID into the specified aRuleData object.
@ -298,7 +302,8 @@ private:
bool aIsImportant,
bool aOverrideImportant,
bool aMustCallValueAppended,
mozilla::css::Declaration* aDeclaration);
mozilla::css::Declaration* aDeclaration,
nsIDocument* aSheetDocument);
#ifdef DEBUG
void DoAssertInitialState();

View file

@ -143,6 +143,8 @@ public:
nsresult SetStyleSheet(CSSStyleSheet* aSheet);
nsIDocument* GetDocument();
nsresult SetQuirkMode(bool aQuirkMode);
nsresult SetChildLoader(mozilla::css::Loader* aChildLoader);
@ -1657,6 +1659,15 @@ CSSParserImpl::SetStyleSheet(CSSStyleSheet* aSheet)
return NS_OK;
}
nsIDocument*
CSSParserImpl::GetDocument()
{
if (!mSheet) {
return nullptr;
}
return mSheet->GetDocument();
}
nsresult
CSSParserImpl::SetQuirkMode(bool aQuirkMode)
{
@ -1978,7 +1989,8 @@ CSSParserImpl::ParseTransformProperty(const nsAString& aPropValue,
declaration->ExpandTo(&mData);
changed = mData.TransferFromBlock(mTempData, eCSSProperty_transform,
EnabledState(), false,
true, false, declaration);
true, false, declaration,
GetDocument());
declaration->CompressFrom(&mData);
}
@ -2059,7 +2071,8 @@ CSSParserImpl::ParseProperty(const nsCSSPropertyID aPropID,
aDeclaration->ExpandTo(&mData);
*aChanged = mData.TransferFromBlock(mTempData, aPropID,
EnabledState(), aIsImportant,
true, false, aDeclaration);
true, false, aDeclaration,
GetDocument());
aDeclaration->CompressFrom(&mData);
}
CLEAR_ERROR();
@ -7573,7 +7586,7 @@ CSSParserImpl::ParseDeclaration(css::Declaration* aDeclaration,
*aChanged |= mData.TransferFromBlock(mTempData, propID, EnabledState(),
status == ePriority_Important,
false, aMustCallValueAppended,
aDeclaration);
aDeclaration, GetDocument());
}
return true;
@ -15355,17 +15368,17 @@ CSSParserImpl::ParseFontFeatureSettings(nsCSSValue& aValue)
return true;
}
bool
CSSParserImpl::ParseFontVariationSettings(nsCSSValue& aValue)
{
// TODO: Actually implement this.
// This stub is here because websites insist on considering this
// very hardware-dependent and O.S.-variable low-level font-control
// as a "critical feature" which it isn't as there is 0 guarantee
// that font variation settings are supported or honored by any
// operating system used by the client.
return true;
bool
CSSParserImpl::ParseFontVariationSettings(nsCSSValue& aValue)
{
// TODO: Actually implement this.
// This stub is here because websites insist on considering this
// very hardware-dependent and O.S.-variable low-level font-control
// as a "critical feature" which it isn't as there is 0 guarantee
// that font variation settings are supported or honored by any
// operating system used by the client.
return true;
}
bool

View file

@ -3423,6 +3423,21 @@ nsCSSProps::gPropertyEnabled[eCSSProperty_COUNT_with_aliases] = {
#undef IS_ENABLED_BY_DEFAULT
};
#include "../../dom/base/PropertyUseCounterMap.inc"
/* static */ const UseCounter
nsCSSProps::gPropertyUseCounter[eCSSProperty_COUNT_no_shorthands] = {
#define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) privatename_
#define CSS_PROP_LIST_INCLUDE_LOGICAL
#define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
static_cast<UseCounter>(USE_COUNTER_FOR_CSS_PROPERTY_##method_),
#include "nsCSSPropList.h"
#undef CSS_PROP
#undef CSS_PROP_LIST_INCLUDE_LOGICAL
#undef CSS_PROP_PUBLIC_OR_PRIVATE
};
// Check that all logical property flags are used appropriately.
#define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \

View file

@ -19,6 +19,7 @@
#include "nsStyleStructFwd.h"
#include "nsCSSKeywords.h"
#include "mozilla/CSSEnabledState.h"
#include "mozilla/UseCounter.h"
#include "mozilla/EnumTypeTraits.h"
// Length of the "--" prefix on custom names (such as custom property names,
@ -639,8 +640,19 @@ public:
return gPropertyEnabled[aProperty];
}
// A table for the use counter associated with each CSS property. If a
// property does not have a use counter defined in UseCounters.conf, then
// its associated entry is |eUseCounter_UNKNOWN|.
static const mozilla::UseCounter gPropertyUseCounter[eCSSProperty_COUNT_no_shorthands];
public:
static mozilla::UseCounter UseCounterFor(nsCSSPropertyID aProperty) {
MOZ_ASSERT(0 <= aProperty && aProperty < eCSSProperty_COUNT_no_shorthands,
"out of range");
return gPropertyUseCounter[aProperty];
}
static bool IsEnabled(nsCSSPropertyID aProperty, EnabledState aEnabled)
{
if (IsEnabled(aProperty)) {