Files
palemoon27/layout/style/nsDOMCSSAttrDeclaration.cpp
T
roytam1 886c0a2723 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1215411 - Define MOZ_FALLTHROUGH annotation to suppress clang's -Wimplicit-fallthrough warnings. r=botond (5549d55e8b)
- Bug 1202794 - Explicitly clear array in SortChildrenBy3DZOrder to satisfy the move analysis, r=mattwoodrow (0c53a3db36)
- Bug 1217168 - Respect layer clip rects during plugin visibility computation. r=jimm (6289d35ff1)
- Bug 1220693 - Make mozilla::Atomic<enum class> work even on compilers that don't have <atomic>. r=froydnj (ef1b490ffd)
- Bug 947062 - Make background-position inline-style changes and CSS animations trigger layer activity. r=roc (44bc576960)
- Bug 1201330 - Refactor LayerActivity property management. r=roc (92528b8765)
- Bug 1201330 - Keep scroll handler induced layer activity active until the scroll frame becomes inactive. r=roc (08670902ec)
- Bug 1147707 - Intersect correctly in DisplayItemClip::ApplyNonRoundedIntersection. r=roc (66991b6be6)
- better attempt at 10.5 compaitbility, avoiding out-of-bounds array access (18f481ff6b)
- Bug 1217662 - part 1 - make LayerManagerUserDataDestroy a static function of LayerManager; r=mattwoodrow (f2d34451e0)
- Bug 1217662 - part 2 - move mozilla::layers::LayerUserData to a separate header; r=mattwoodrow (036d7327fa)
- Bug 1217662 - part 3 - move nsDisplayBlendContainer::GetLayerState out-of-line; r=mattwoodrow (fb2bd6bd20)
- Bug 1217662 - part 4 - move {LayerManager,Layer}::RemoveUserData out-of-line; r=mattwoodrow (86836f2a9b)
- Bug 1217662 - part 5 - move FrameLayerBuilder and helper classes's ctors/dtors out-of-line; r=mattwoodrow (e838bde0ec)
- Bug 1217662 - part 6 - remove Layers.h #include from FrameListBuilder.h; r=mattwoodrow (8aea4cb842)
- Bug 1216288 - Disable warning when we don't build an active layer for RenderFrameParent within an opacity:0 subtree. r=roc (2c5e70760a)
- Bug 1169996 - Don't lose eEditorMailMask; r=ehsan (b4647557bb)
- Bug 1211654 - Force opacity layers that were only created for APZ hit-testing information to always be inactive. r=mstange (4c56d440cf)
- Bug 1154336 - Convert nsTextEditorState::mRestoringSelection into a strong reference; r=baku (3e24a6ad18)
- Bug 549674 part.1 Commit composition string at setting value of <input> or <textarea> r=smaug (e6a6471370)
- Bug 1109410 Resolve CSS transform in ContentEventHandler::ConvertToRootViewRelativeOffset() r=roc (5ff3388f28)
- Bug 1180589 part 3 - Rename shadowed variable name; r=bholley (7194cda020)
- Bug 1222145 - Bump maximum video size to 8k. r=jya (056778dda9)
- Bug 1180589 part 1 - Add simulator code for TV Manager API; r=seanlin (dd78a38a27)
- Bug 1180589 part 2 - Add code to create a simulated mediastream; r=se# (c255e0dd07)
- spacing (856ee42504)
- missing bit of Bug 1136827 - Stop synchronously (befed33dbe)
- bit of Bug 1204401 (c1f98ed982)
- bits of 1142527 (dc39662797)
- Bug 1212220 - cache pref values so they are safe to access off the main thread. r=roc. (adb186836b)
- Bug 1194918 - Add VideoSink which contains either AudioSinkWrapper or DecodedStreamSink as a default operating MediaSink in MDSM. r=jwwang. (7ccda9b055)
- Bug 1194918 - Move av-sync and video frame rendering logic from MDSM to VideoSink. r=jwwang. (ba56ae120b)
- Bug 1202533 - Fix naming convention of MediaSink::PlaybackParams. (eed5ed3839)
- Bug 1194918 - Override function SetVolume/SetPreservesPitch in VideoSink for the contained AudioSink. r=jwwang. (0d96e6a395)
- Bug 1198663. Skip null Images in VideoSink::RenderVideoFrames instead of treating them as valid. r=jwwang (aaac235c1f)
- Bug 1207198: P2. Defer dormant request while ReadMetadata is pending in MDSM. r=sotaro (0a8e1f4bb0)
- Bug 1209850: Only attempt to initialize decoders as they are required. r=alfredo (615e41b66b)
- Bug 1192733: fix the MediaFormatReader can not back from dormant state. r=jya (c266107d33)
- Bug 1207198: P1. Do not initialize decoders during ReadMetadata. r=cpearce (4174dbc409)
- missing bit of 1196696 (7b1c0fbe95)
- Bug 1208922. Part 6 - IsWaitingOnCDMResource() is not used by MDSM anymore. Remove it from MediaDecoderReader and make it private in MediaFormatReader. r=cpearce. (db67939710)
- adapted of Bug 1208922. Part 3 - forward the CDMProxy from MediaDecoder (a5dca2f89d)
2022-12-09 12:38:41 +08:00

194 lines
6.3 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
/* DOM object for element.style */
#include "nsDOMCSSAttrDeclaration.h"
#include "mozilla/css/Declaration.h"
#include "mozilla/css/StyleRule.h"
#include "mozilla/dom/Element.h"
#include "nsIDocument.h"
#include "nsIDOMMutationEvent.h"
#include "nsIURI.h"
#include "nsNodeUtils.h"
#include "nsWrapperCacheInlines.h"
#include "nsIFrame.h"
#include "ActiveLayerTracker.h"
using namespace mozilla;
nsDOMCSSAttributeDeclaration::nsDOMCSSAttributeDeclaration(dom::Element* aElement,
bool aIsSMILOverride)
: mElement(aElement)
, mIsSMILOverride(aIsSMILOverride)
{
MOZ_COUNT_CTOR(nsDOMCSSAttributeDeclaration);
NS_ASSERTION(aElement, "Inline style for a NULL element?");
}
nsDOMCSSAttributeDeclaration::~nsDOMCSSAttributeDeclaration()
{
MOZ_COUNT_DTOR(nsDOMCSSAttributeDeclaration);
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMCSSAttributeDeclaration, mElement)
// mElement holds a strong ref to us, so if it's going to be
// skipped, the attribute declaration can't be part of a garbage
// cycle.
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsDOMCSSAttributeDeclaration)
if (tmp->mElement && Element::CanSkip(tmp->mElement, true)) {
if (tmp->PreservingWrapper()) {
// This marks the wrapper black.
tmp->GetWrapper();
}
return true;
}
return tmp->IsBlack();
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(nsDOMCSSAttributeDeclaration)
return tmp->IsBlack() ||
(tmp->mElement && Element::CanSkipInCC(tmp->mElement));
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsDOMCSSAttributeDeclaration)
return tmp->IsBlack() ||
(tmp->mElement && Element::CanSkipThis(tmp->mElement));
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCSSAttributeDeclaration)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_IMPL_QUERY_TAIL_INHERITING(nsDOMCSSDeclaration)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCSSAttributeDeclaration)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCSSAttributeDeclaration)
nsresult
nsDOMCSSAttributeDeclaration::SetCSSDeclaration(css::Declaration* aDecl)
{
NS_ASSERTION(mElement, "Must have Element to set the declaration!");
return
mIsSMILOverride ? mElement->SetSMILOverrideStyleDeclaration(aDecl, true) :
mElement->SetInlineStyleDeclaration(aDecl, nullptr, true);
}
nsIDocument*
nsDOMCSSAttributeDeclaration::DocToUpdate()
{
// We need OwnerDoc() rather than GetCurrentDoc() because it might
// be the BeginUpdate call that inserts mElement into the document.
return mElement->OwnerDoc();
}
css::Declaration*
nsDOMCSSAttributeDeclaration::GetCSSDeclaration(Operation aOperation)
{
if (!mElement)
return nullptr;
css::Declaration* declaration;
if (mIsSMILOverride)
declaration = mElement->GetSMILOverrideStyleDeclaration();
else
declaration = mElement->GetInlineStyleDeclaration();
// Notify observers that our style="" attribute is going to change
// unless:
// * this is a declaration that holds SMIL animation values (which
// aren't reflected in the DOM style="" attribute), or
// * we're getting the declaration for reading, or
// * we're getting it for property removal but we don't currently have
// a declaration.
// XXXbz this is a bit of a hack, especially doing it before the
// BeginUpdate(), but this is a good chokepoint where we know we
// plan to modify the CSSDeclaration, so need to notify
// AttributeWillChange if this is inline style.
if (!mIsSMILOverride &&
((aOperation == eOperation_Modify) ||
(aOperation == eOperation_RemoveProperty && declaration))) {
nsNodeUtils::AttributeWillChange(mElement, kNameSpaceID_None,
nsGkAtoms::style,
nsIDOMMutationEvent::MODIFICATION,
nullptr);
}
if (declaration) {
return declaration;
}
if (aOperation != eOperation_Modify) {
return nullptr;
}
// cannot fail
RefPtr<css::Declaration> decl = new css::Declaration();
decl->InitializeEmpty();
// this *can* fail (inside SetAttrAndNotify, at least).
nsresult rv;
if (mIsSMILOverride)
rv = mElement->SetSMILOverrideStyleDeclaration(decl, false);
else
rv = mElement->SetInlineStyleDeclaration(decl, nullptr, false);
if (NS_FAILED(rv)) {
return nullptr; // the decl will be destroyed along with the style rule
}
return decl;
}
void
nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv)
{
NS_ASSERTION(mElement, "Something is severely broken -- there should be an Element here!");
nsIDocument* doc = mElement->OwnerDoc();
aCSSParseEnv.mSheetURI = doc->GetDocumentURI();
aCSSParseEnv.mBaseURI = mElement->GetBaseURI();
aCSSParseEnv.mPrincipal = mElement->NodePrincipal();
aCSSParseEnv.mCSSLoader = doc->CSSLoader();
}
NS_IMETHODIMP
nsDOMCSSAttributeDeclaration::GetParentRule(nsIDOMCSSRule **aParent)
{
NS_ENSURE_ARG_POINTER(aParent);
*aParent = nullptr;
return NS_OK;
}
/* virtual */ nsINode*
nsDOMCSSAttributeDeclaration::GetParentObject()
{
return mElement;
}
NS_IMETHODIMP
nsDOMCSSAttributeDeclaration::SetPropertyValue(const nsCSSProperty aPropID,
const nsAString& aValue)
{
// Scripted modifications to style.opacity or style.transform
// could immediately force us into the animated state if heuristics suggest
// this is scripted animation.
if (aPropID == eCSSProperty_opacity || aPropID == eCSSProperty_transform ||
aPropID == eCSSProperty_left || aPropID == eCSSProperty_top ||
aPropID == eCSSProperty_right || aPropID == eCSSProperty_bottom ||
aPropID == eCSSProperty_margin_left || aPropID == eCSSProperty_margin_top ||
aPropID == eCSSProperty_margin_right || aPropID == eCSSProperty_margin_bottom ||
aPropID == eCSSProperty_background_position) {
nsIFrame* frame = mElement->GetPrimaryFrame();
if (frame) {
ActiveLayerTracker::NotifyInlineStyleRuleModified(frame, aPropID);
}
}
return nsDOMCSSDeclaration::SetPropertyValue(aPropID, aValue);
}