Skip to content

Commit

Permalink
Merge m-i to m-c, a=merge
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: LQ8vDnOLtXR
  • Loading branch information
philor committed Dec 31, 2016
2 parents 9eeb28d + 8f2731a commit e8852fe
Show file tree
Hide file tree
Showing 48 changed files with 347 additions and 207 deletions.
28 changes: 27 additions & 1 deletion dom/canvas/WebGLShaderValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ ShaderValidator::CanLinkTo(const ShaderValidator* prev, nsCString* const out_log
continue;

if (!itrVert->isSameUniformAtLinkTime(*itrFrag)) {
nsPrintfCString error("Uniform `%s`is not linkable between"
nsPrintfCString error("Uniform `%s` is not linkable between"
" attached shaders.",
itrFrag->name.c_str());
*out_log = error;
Expand All @@ -282,6 +282,32 @@ ShaderValidator::CanLinkTo(const ShaderValidator* prev, nsCString* const out_log
}
}
}
{
const auto vertVars = sh::GetInterfaceBlocks(prev->mHandle);
const auto fragVars = sh::GetInterfaceBlocks(mHandle);
if (!vertVars || !fragVars) {
nsPrintfCString error("Could not create uniform block list.");
*out_log = error;
return false;
}

for (const auto& fragVar : *fragVars) {
for (const auto& vertVar : *vertVars) {
if (vertVar.name != fragVar.name)
continue;

if (!vertVar.isSameInterfaceBlockAtLinkTime(fragVar)) {
nsPrintfCString error("Interface block `%s` is not linkable between"
" attached shaders.",
fragVar.name.c_str());
*out_log = error;
return false;
}

break;
}
}
}

const auto& vertVaryings = ShGetVaryings(prev->mHandle);
const auto& fragVaryings = ShGetVaryings(mHandle);
Expand Down
3 changes: 2 additions & 1 deletion dom/performance/PerformanceMainThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PerformanceMainThread,
Performance)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTiming,
mNavigation)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
// Performance inherits DOMEventTargetHelper which calls
// NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(PerformanceMainThread,
Expand Down
2 changes: 1 addition & 1 deletion dom/smil/nsSMILAnimationController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ nsSMILAnimationController::AddStyleUpdatesTo(RestyleTracker& aTracker)
// mIsCSS true means that the rules are the ones returned from
// Element::GetSMILOverrideStyleDeclaration (via nsSMILCSSProperty objects),
// and mIsCSS false means the rules are nsSMILMappedAttribute objects
// returned from nsSVGElement::GetAnimatedContentStyleRule.
// returned from nsSVGElement::GetAnimatedContentDeclarationBlock.
nsRestyleHint rshint = key.mIsCSS ? eRestyle_StyleAttribute_Animations
: eRestyle_SVGAttrAnimations;
aTracker.AddPendingRestyle(key.mElement, rshint, nsChangeHint(0));
Expand Down
2 changes: 1 addition & 1 deletion dom/smil/nsSMILMappedAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ nsSMILMappedAttribute::FlushChangesToTargetAttr() const
{
// Clear animated content-style-rule
mElement->DeleteProperty(SMIL_MAPPED_ATTR_ANIMVAL,
SMIL_MAPPED_ATTR_STYLERULE_ATOM);
SMIL_MAPPED_ATTR_STYLEDECL_ATOM);
nsIDocument* doc = mElement->GetUncomposedDoc();

// Request animation restyle
Expand Down
6 changes: 3 additions & 3 deletions dom/smil/nsSMILMappedAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
#include "mozilla/Attributes.h"
#include "nsSMILCSSProperty.h"

/* We'll use the empty-string atom |nsGkAtoms::_empty| as the key for storing
* an element's animated content style rule in its Property Table, under the
/* We'll use the empty-string atom |nsGkAtoms::_empty| as the key for storing an
* element's animated content style declaration in its Property Table, under the
* property-category SMIL_MAPPED_ATTR_ANIMVAL. Everything else stored in that
* category is keyed off of the XML attribute name, so the empty string is a
* good "reserved" key to use for storing the style rule (since XML attributes
* all have nonempty names).
*/
#define SMIL_MAPPED_ATTR_STYLERULE_ATOM nsGkAtoms::_empty
#define SMIL_MAPPED_ATTR_STYLEDECL_ATOM nsGkAtoms::_empty

/**
* nsSMILMappedAttribute: Implements the nsISMILAttr interface for SMIL
Expand Down
119 changes: 60 additions & 59 deletions dom/svg/nsSVGElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "nsError.h"
#include "nsIPresShell.h"
#include "nsGkAtoms.h"
#include "mozilla/css/StyleRule.h"
#include "nsRuleWalker.h"
#include "mozilla/css/Declaration.h"
#include "nsCSSProps.h"
Expand Down Expand Up @@ -53,6 +52,8 @@
#include "nsAttrValueOrString.h"
#include "nsSMILAnimationController.h"
#include "mozilla/dom/SVGElementBinding.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/DeclarationBlockInlines.h"
#include "mozilla/Unused.h"
#include "mozilla/RestyleManagerHandle.h"
#include "mozilla/RestyleManagerHandleInlines.h"
Expand Down Expand Up @@ -94,6 +95,10 @@ nsSVGElement::nsSVGElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
{
}

nsSVGElement::~nsSVGElement()
{
}

JSObject*
nsSVGElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
{
Expand Down Expand Up @@ -293,12 +298,11 @@ nsSVGElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
"Unexpected use of nsMappedAttributes within SVG");

// If this is an svg presentation attribute we need to map it into
// the content stylerule.
// the content declaration block.
// XXX For some reason incremental mapping doesn't work, so for now
// just delete the style rule and lazily reconstruct it in
// GetContentStyleRule()
// just delete the style rule and lazily reconstruct it as needed).
if (aNamespaceID == kNameSpaceID_None && IsAttributeMapped(aName)) {
mContentStyleRule = nullptr;
mContentDeclarationBlock = nullptr;
}

if (IsEventAttributeName(aName) && aValue) {
Expand Down Expand Up @@ -659,9 +663,11 @@ nsSVGElement::UnsetAttrInternal(int32_t aNamespaceID, nsIAtom* aName,
// Maybe consolidate?

if (aNamespaceID == kNameSpaceID_None) {
// If this is an svg presentation attribute, remove rule to force an update
if (IsAttributeMapped(aName))
mContentStyleRule = nullptr;
// If this is an svg presentation attribute, remove declaration block to
// force an update
if (IsAttributeMapped(aName)) {
mContentDeclarationBlock = nullptr;
}

if (IsEventAttributeName(aName)) {
EventListenerManager* manager = GetExistingListenerManager();
Expand Down Expand Up @@ -903,11 +909,12 @@ nsSVGElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
#ifdef DEBUG
// printf("nsSVGElement(%p)::WalkContentStyleRules()\n", this);
#endif
if (!mContentStyleRule)
UpdateContentStyleRule();
if (!mContentDeclarationBlock) {
UpdateContentDeclarationBlock();
}

if (mContentStyleRule) {
css::Declaration* declaration = mContentStyleRule->GetDeclaration();
if (mContentDeclarationBlock) {
css::Declaration* declaration = mContentDeclarationBlock->AsGecko();
declaration->SetImmutable();
aRuleWalker->Forward(declaration);
}
Expand All @@ -930,13 +937,13 @@ nsSVGElement::WalkAnimatedContentStyleRules(nsRuleWalker* aRuleWalker)
"WalkAnimatedContentStyleRules");
if (!restyleManager->AsGecko()->SkipAnimationRules()) {
// update/walk the animated content style rule.
css::StyleRule* animContentStyleRule = GetAnimatedContentStyleRule();
if (!animContentStyleRule) {
UpdateAnimatedContentStyleRule();
animContentStyleRule = GetAnimatedContentStyleRule();
DeclarationBlock* animContentDeclBlock = GetAnimatedContentDeclarationBlock();
if (!animContentDeclBlock) {
UpdateAnimatedContentDeclarationBlock();
animContentDeclBlock = GetAnimatedContentDeclarationBlock();
}
if (animContentStyleRule) {
css::Declaration* declaration = animContentStyleRule->GetDeclaration();
if (animContentDeclBlock) {
css::Declaration* declaration = animContentDeclBlock->AsGecko();
declaration->SetImmutable();
aRuleWalker->Forward(declaration);
}
Expand Down Expand Up @@ -1153,10 +1160,10 @@ class MOZ_STACK_CLASS MappedAttrParser {
void ParseMappedAttrValue(nsIAtom* aMappedAttrName,
const nsAString& aMappedAttrValue);

// If we've parsed any values for mapped attributes, this method returns
// a new already_AddRefed css::StyleRule that incorporates the parsed
// If we've parsed any values for mapped attributes, this method returns the
// already_AddRefed css::Declaration that incorporates the parsed
// values. Otherwise, this method returns null.
already_AddRefed<css::StyleRule> CreateStyleRule();
already_AddRefed<css::Declaration> GetDeclarationBlock();

private:
// MEMBER DATA
Expand All @@ -1168,7 +1175,7 @@ class MOZ_STACK_CLASS MappedAttrParser {
nsCOMPtr<nsIURI> mBaseURI;

// Declaration for storing parsed values (lazily initialized)
css::Declaration* mDecl;
RefPtr<css::Declaration> mDecl;

// For reporting use counters
nsSVGElement* mElement;
Expand All @@ -1179,15 +1186,15 @@ MappedAttrParser::MappedAttrParser(css::Loader* aLoader,
already_AddRefed<nsIURI> aBaseURI,
nsSVGElement* aElement)
: mParser(aLoader), mDocURI(aDocURI), mBaseURI(aBaseURI),
mDecl(nullptr), mElement(aElement)
mElement(aElement)
{
}

MappedAttrParser::~MappedAttrParser()
{
MOZ_ASSERT(!mDecl,
"If mDecl was initialized, it should have been converted "
"into a style rule (and had its pointer cleared)");
"If mDecl was initialized, it should have been returned via "
"GetDeclarationBlock (and had its pointer cleared)");
}

void
Expand Down Expand Up @@ -1241,16 +1248,10 @@ MappedAttrParser::ParseMappedAttrValue(nsIAtom* aMappedAttrName,
}
}

already_AddRefed<css::StyleRule>
MappedAttrParser::CreateStyleRule()
already_AddRefed<css::Declaration>
MappedAttrParser::GetDeclarationBlock()
{
if (!mDecl) {
return nullptr; // No mapped attributes were parsed
}

RefPtr<css::StyleRule> rule = new css::StyleRule(nullptr, mDecl, 0, 0);
mDecl = nullptr; // We no longer own the declaration -- drop our pointer to it
return rule.forget();
return mDecl.forget();
}

} // namespace
Expand All @@ -1259,9 +1260,10 @@ MappedAttrParser::CreateStyleRule()
// Implementation Helpers:

void
nsSVGElement::UpdateContentStyleRule()
nsSVGElement::UpdateContentDeclarationBlock()
{
NS_ASSERTION(!mContentStyleRule, "we already have a content style rule");
NS_ASSERTION(!mContentDeclarationBlock,
"we already have a content declaration block");

uint32_t attrCount = mAttrsAndChildren.AttrCount();
if (!attrCount) {
Expand Down Expand Up @@ -1310,7 +1312,7 @@ nsSVGElement::UpdateContentStyleRule()
mAttrsAndChildren.AttrAt(i)->ToString(value);
mappedAttrParser.ParseMappedAttrValue(attrName->Atom(), value);
}
mContentStyleRule = mappedAttrParser.CreateStyleRule();
mContentDeclarationBlock = mappedAttrParser.GetDeclarationBlock();
}

static void
Expand All @@ -1319,7 +1321,7 @@ ParseMappedAttrAnimValueCallback(void* aObject,
void* aPropertyValue,
void* aData)
{
MOZ_ASSERT(aPropertyName != SMIL_MAPPED_ATTR_STYLERULE_ATOM,
MOZ_ASSERT(aPropertyName != SMIL_MAPPED_ATTR_STYLEDECL_ATOM,
"animated content style rule should have been removed "
"from properties table already (we're rebuilding it now)");

Expand All @@ -1335,25 +1337,25 @@ ParseMappedAttrAnimValueCallback(void* aObject,
mappedAttrParser->ParseMappedAttrValue(aPropertyName, animValStr);
}

// Callback for freeing animated content style rule, in property table.
// Callback for freeing animated content decl block, in property table.
static void
ReleaseStyleRule(void* aObject, /* unused */
ReleaseDeclBlock(void* aObject, /* unused */
nsIAtom* aPropertyName,
void* aPropertyValue,
void* aData /* unused */)
{
MOZ_ASSERT(aPropertyName == SMIL_MAPPED_ATTR_STYLERULE_ATOM,
MOZ_ASSERT(aPropertyName == SMIL_MAPPED_ATTR_STYLEDECL_ATOM,
"unexpected property name, for animated content style rule");
css::StyleRule* styleRule = static_cast<css::StyleRule*>(aPropertyValue);
MOZ_ASSERT(styleRule, "unexpected null style rule");
styleRule->Release();
auto decl = static_cast<DeclarationBlock*>(aPropertyValue);
MOZ_ASSERT(decl, "unexpected null decl");
decl->Release();
}

void
nsSVGElement::UpdateAnimatedContentStyleRule()
nsSVGElement::UpdateAnimatedContentDeclarationBlock()
{
MOZ_ASSERT(!GetAnimatedContentStyleRule(),
"Animated content style rule already set");
MOZ_ASSERT(!GetAnimatedContentDeclarationBlock(),
"Animated content declaration block already set");

nsIDocument* doc = OwnerDoc();
if (!doc) {
Expand All @@ -1366,30 +1368,29 @@ nsSVGElement::UpdateAnimatedContentStyleRule()
doc->PropertyTable(SMIL_MAPPED_ATTR_ANIMVAL)->
Enumerate(this, ParseMappedAttrAnimValueCallback, &mappedAttrParser);

RefPtr<css::StyleRule>
animContentStyleRule(mappedAttrParser.CreateStyleRule());
RefPtr<DeclarationBlock> animContentDeclBlock =
mappedAttrParser.GetDeclarationBlock();

if (animContentStyleRule) {
if (animContentDeclBlock) {
#ifdef DEBUG
nsresult rv =
#endif
SetProperty(SMIL_MAPPED_ATTR_ANIMVAL,
SMIL_MAPPED_ATTR_STYLERULE_ATOM,
animContentStyleRule.get(),
ReleaseStyleRule);
Unused << animContentStyleRule.forget();
SMIL_MAPPED_ATTR_STYLEDECL_ATOM,
animContentDeclBlock.forget().take(),
ReleaseDeclBlock);
MOZ_ASSERT(rv == NS_OK,
"SetProperty failed (or overwrote something)");
}
}

css::StyleRule*
nsSVGElement::GetAnimatedContentStyleRule()
DeclarationBlock*
nsSVGElement::GetAnimatedContentDeclarationBlock()
{
return
static_cast<css::StyleRule*>(GetProperty(SMIL_MAPPED_ATTR_ANIMVAL,
SMIL_MAPPED_ATTR_STYLERULE_ATOM,
nullptr));
static_cast<DeclarationBlock*>(GetProperty(SMIL_MAPPED_ATTR_ANIMVAL,
SMIL_MAPPED_ATTR_STYLEDECL_ATOM,
nullptr));
}

/**
Expand Down
Loading

0 comments on commit e8852fe

Please sign in to comment.