Bug 1341647 - stylo: Move HTMLBodyElement::WalkContentStyleRules to the mapped attr functionality; r=bz

MozReview-Commit-ID: 90qDHl0Ane4

--HG--
extra : rebase_source : e3dace4a0ec7345ec801c02db7339e78a6242a1e
This commit is contained in:
Manish Goregaokar 2017-03-29 12:10:00 -07:00
parent 290c64c982
commit 111b56703c
22 changed files with 331 additions and 261 deletions

View File

@ -287,6 +287,10 @@ public:
*/
const nsMappedAttributes* GetMappedAttributes() const;
void ClearMappedServoStyle() {
mAttrsAndChildren.ClearMappedServoStyle();
}
/**
* Set the inline style declaration for this element. This will send
* an appropriate AttributeChanged notification if aNotify is true.

View File

@ -721,10 +721,26 @@ nsAttrAndChildArray::MappedAttrCount() const
return mImpl && mImpl->mMappedAttrs ? (uint32_t)mImpl->mMappedAttrs->Count() : 0;
}
nsresult
nsAttrAndChildArray::ForceMapped(nsMappedAttributeElement* aContent, nsIDocument* aDocument)
{
nsHTMLStyleSheet* sheet = aDocument->GetAttributeStyleSheet();
RefPtr<nsMappedAttributes> mapped = GetModifiableMapped(aContent, sheet, false, 0);
return MakeMappedUnique(mapped);
}
void
nsAttrAndChildArray::ClearMappedServoStyle() {
if (mImpl && mImpl->mMappedAttrs) {
mImpl->mMappedAttrs->ClearServoStyle();
}
}
nsMappedAttributes*
nsAttrAndChildArray::GetModifiableMapped(nsMappedAttributeElement* aContent,
nsHTMLStyleSheet* aSheet,
bool aWillAddAttr)
bool aWillAddAttr,
int32_t aAttrCount)
{
if (mImpl && mImpl->mMappedAttrs) {
return mImpl->mMappedAttrs->Clone(aWillAddAttr);
@ -734,7 +750,7 @@ nsAttrAndChildArray::GetModifiableMapped(nsMappedAttributeElement* aContent,
nsMapRuleToAttributesFunc mapRuleFunc =
aContent->GetAttributeMappingFunction();
return new nsMappedAttributes(aSheet, mapRuleFunc);
return new (aAttrCount) nsMappedAttributes(aSheet, mapRuleFunc);
}
nsresult

View File

@ -136,6 +136,13 @@ public:
}
const nsMappedAttributes* GetMapped() const;
// Force this to have mapped attributes, even if those attributes are empty.
nsresult ForceMapped(nsMappedAttributeElement* aContent, nsIDocument* aDocument);
// Clear the servo declaration block on the mapped attributes, if any
// Will assert off main thread
void ClearMappedServoStyle();
private:
nsAttrAndChildArray(const nsAttrAndChildArray& aOther) = delete;
nsAttrAndChildArray& operator=(const nsAttrAndChildArray& aOther) = delete;
@ -149,7 +156,8 @@ private:
nsMappedAttributes*
GetModifiableMapped(nsMappedAttributeElement* aContent,
nsHTMLStyleSheet* aSheet,
bool aWillAddAttr);
bool aWillAddAttr,
int32_t aAttrCount = 1);
nsresult MakeMappedUnique(nsMappedAttributes* aAttributes);
uint32_t AttrSlotsSize() const

View File

@ -55,6 +55,7 @@
#include "nsGlobalWindow.h"
#include "nsPIWindowRoot.h"
#include "nsLayoutUtils.h"
#include "nsMappedAttributes.h"
#include "nsView.h"
#include "GroupedSHistory.h"
#include "PartialSHistory.h"
@ -1203,11 +1204,27 @@ nsFrameLoader::MarginsChanged(uint32_t aMarginWidth,
mDocShell->SetMarginWidth(aMarginWidth);
mDocShell->SetMarginHeight(aMarginHeight);
// There's a cached property declaration block
// that needs to be updated
if (nsIDocument* doc = mDocShell->GetDocument()) {
// We don't need to do anything for Gecko here because
// we plan to RebuildAllStyleData anyway.
if (doc->GetStyleBackendType() == StyleBackendType::Servo) {
for (nsINode* cur = doc; cur; cur = cur->GetNextNode()) {
if (cur->IsHTMLElement(nsGkAtoms::body)) {
static_cast<HTMLBodyElement*>(cur)->ClearMappedServoStyle();
}
}
}
}
// Trigger a restyle if there's a prescontext
// FIXME: This could do something much less expensive.
RefPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
if (presContext)
// rebuild, because now the same nsMappedAttributes* will produce
// a different style
presContext->RebuildAllStyleData(nsChangeHint(0), eRestyle_Subtree);
}

View File

@ -70,16 +70,22 @@ nsMappedAttributes::Clone(bool aWillAddAttr)
void* nsMappedAttributes::operator new(size_t aSize, uint32_t aAttrCount) CPP_THROW_NEW
{
NS_ASSERTION(aAttrCount > 0, "zero-attribute nsMappedAttributes requested");
size_t size = aSize + aAttrCount * sizeof(InternalAttr);
// aSize will include the mAttrs buffer so subtract that.
void* newAttrs = ::operator new(aSize - sizeof(void*[1]) +
aAttrCount * sizeof(InternalAttr));
// We don't want to under-allocate, however, so do not subtract
// if we have zero attributes. The zero attribute case only happens
// for <body>'s mapped attributes
if (aAttrCount != 0) {
size -= sizeof(void*[1]);
}
void* newAttrs = ::operator new(size);
#ifdef DEBUG
static_cast<nsMappedAttributes*>(newAttrs)->mBufferSize = aAttrCount;
#endif
return newAttrs;
}
@ -90,7 +96,6 @@ void
nsMappedAttributes::SetAndTakeAttr(nsIAtom* aAttrName, nsAttrValue& aValue)
{
NS_PRECONDITION(aAttrName, "null name");
uint32_t i;
for (i = 0; i < mAttrCount && !Attrs()[i].mName.IsSmaller(aAttrName); ++i) {
if (Attrs()[i].mName.Equals(aAttrName)) {

View File

@ -84,6 +84,11 @@ public:
return mServoStyle;
}
void ClearServoStyle() {
MOZ_ASSERT(NS_IsMainThread());
mServoStyle = nullptr;
}
// nsIStyleRule
virtual void MapRuleInfoInto(nsRuleData* aRuleData) override;
virtual bool MightMapInheritedStyleData() override;

View File

@ -27,180 +27,8 @@ namespace dom {
//----------------------------------------------------------------------
BodyRule::BodyRule(HTMLBodyElement* aPart)
: mPart(aPart)
{
}
BodyRule::~BodyRule()
{
}
NS_IMPL_ISUPPORTS(BodyRule, nsIStyleRule)
/* virtual */ void
BodyRule::MapRuleInfoInto(nsRuleData* aData)
{
if (!(aData->mSIDs & NS_STYLE_INHERIT_BIT(Margin)) || !mPart)
return; // We only care about margins.
int32_t bodyMarginWidth = -1;
int32_t bodyMarginHeight = -1;
int32_t bodyTopMargin = -1;
int32_t bodyBottomMargin = -1;
int32_t bodyLeftMargin = -1;
int32_t bodyRightMargin = -1;
// check the mode (fortunately, the ruleData has a presContext for us to use!)
NS_ASSERTION(aData->mPresContext, "null presContext in ruleNode was unexpected");
nsCompatibility mode = aData->mPresContext->CompatibilityMode();
const nsAttrValue* value;
if (mPart->GetAttrCount() > 0) {
// if marginwidth/marginheight are set, reflect them as 'margin'
value = mPart->GetParsedAttr(nsGkAtoms::marginwidth);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyMarginWidth = value->GetIntegerValue();
if (bodyMarginWidth < 0) bodyMarginWidth = 0;
nsCSSValue* marginLeft = aData->ValueForMarginLeft();
if (marginLeft->GetUnit() == eCSSUnit_Null)
marginLeft->SetFloatValue((float)bodyMarginWidth, eCSSUnit_Pixel);
nsCSSValue* marginRight = aData->ValueForMarginRight();
if (marginRight->GetUnit() == eCSSUnit_Null)
marginRight->SetFloatValue((float)bodyMarginWidth, eCSSUnit_Pixel);
}
value = mPart->GetParsedAttr(nsGkAtoms::marginheight);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyMarginHeight = value->GetIntegerValue();
if (bodyMarginHeight < 0) bodyMarginHeight = 0;
nsCSSValue* marginTop = aData->ValueForMarginTop();
if (marginTop->GetUnit() == eCSSUnit_Null)
marginTop->SetFloatValue((float)bodyMarginHeight, eCSSUnit_Pixel);
nsCSSValue* marginBottom = aData->ValueForMarginBottom();
if (marginBottom->GetUnit() == eCSSUnit_Null)
marginBottom->SetFloatValue((float)bodyMarginHeight, eCSSUnit_Pixel);
}
// topmargin (IE-attribute)
value = mPart->GetParsedAttr(nsGkAtoms::topmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyTopMargin = value->GetIntegerValue();
if (bodyTopMargin < 0) bodyTopMargin = 0;
nsCSSValue* marginTop = aData->ValueForMarginTop();
if (marginTop->GetUnit() == eCSSUnit_Null)
marginTop->SetFloatValue((float)bodyTopMargin, eCSSUnit_Pixel);
}
// bottommargin (IE-attribute)
value = mPart->GetParsedAttr(nsGkAtoms::bottommargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyBottomMargin = value->GetIntegerValue();
if (bodyBottomMargin < 0) bodyBottomMargin = 0;
nsCSSValue* marginBottom = aData->ValueForMarginBottom();
if (marginBottom->GetUnit() == eCSSUnit_Null)
marginBottom->SetFloatValue((float)bodyBottomMargin, eCSSUnit_Pixel);
}
// leftmargin (IE-attribute)
value = mPart->GetParsedAttr(nsGkAtoms::leftmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyLeftMargin = value->GetIntegerValue();
if (bodyLeftMargin < 0) bodyLeftMargin = 0;
nsCSSValue* marginLeft = aData->ValueForMarginLeft();
if (marginLeft->GetUnit() == eCSSUnit_Null)
marginLeft->SetFloatValue((float)bodyLeftMargin, eCSSUnit_Pixel);
}
// rightmargin (IE-attribute)
value = mPart->GetParsedAttr(nsGkAtoms::rightmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyRightMargin = value->GetIntegerValue();
if (bodyRightMargin < 0) bodyRightMargin = 0;
nsCSSValue* marginRight = aData->ValueForMarginRight();
if (marginRight->GetUnit() == eCSSUnit_Null)
marginRight->SetFloatValue((float)bodyRightMargin, eCSSUnit_Pixel);
}
}
// if marginwidth or marginheight is set in the <frame> and not set in the <body>
// reflect them as margin in the <body>
if (bodyMarginWidth == -1 || bodyMarginHeight == -1) {
nsCOMPtr<nsIDocShell> docShell(aData->mPresContext->GetDocShell());
if (docShell) {
nscoord frameMarginWidth=-1; // default value
nscoord frameMarginHeight=-1; // default value
docShell->GetMarginWidth(&frameMarginWidth); // -1 indicates not set
docShell->GetMarginHeight(&frameMarginHeight);
if ((frameMarginWidth >= 0) && (bodyMarginWidth == -1)) { // set in <frame> & not in <body>
if (eCompatibility_NavQuirks == mode) {
if ((bodyMarginHeight == -1) && (0 > frameMarginHeight)) // nav quirk
frameMarginHeight = 0;
}
}
if ((frameMarginHeight >= 0) && (bodyMarginHeight == -1)) { // set in <frame> & not in <body>
if (eCompatibility_NavQuirks == mode) {
if ((bodyMarginWidth == -1) && (0 > frameMarginWidth)) // nav quirk
frameMarginWidth = 0;
}
}
if ((bodyMarginWidth == -1) && (frameMarginWidth >= 0)) {
nsCSSValue* marginLeft = aData->ValueForMarginLeft();
if (marginLeft->GetUnit() == eCSSUnit_Null)
marginLeft->SetFloatValue((float)frameMarginWidth, eCSSUnit_Pixel);
nsCSSValue* marginRight = aData->ValueForMarginRight();
if (marginRight->GetUnit() == eCSSUnit_Null)
marginRight->SetFloatValue((float)frameMarginWidth, eCSSUnit_Pixel);
}
if ((bodyMarginHeight == -1) && (frameMarginHeight >= 0)) {
nsCSSValue* marginTop = aData->ValueForMarginTop();
if (marginTop->GetUnit() == eCSSUnit_Null)
marginTop->SetFloatValue((float)frameMarginHeight, eCSSUnit_Pixel);
nsCSSValue* marginBottom = aData->ValueForMarginBottom();
if (marginBottom->GetUnit() == eCSSUnit_Null)
marginBottom->SetFloatValue((float)frameMarginHeight, eCSSUnit_Pixel);
}
}
}
}
/* virtual */ bool
BodyRule::MightMapInheritedStyleData()
{
return false;
}
/* virtual */ bool
BodyRule::GetDiscretelyAnimatedCSSValue(nsCSSPropertyID aProperty,
nsCSSValue* aValue)
{
MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet");
return false;
}
#ifdef DEBUG
/* virtual */ void
BodyRule::List(FILE* out, int32_t aIndent) const
{
nsAutoCString indent;
for (int32_t index = aIndent; --index >= 0; ) {
indent.AppendLiteral(" ");
}
fprintf_stderr(out, "%s[body rule] {}\n", indent.get());
}
#endif
//----------------------------------------------------------------------
HTMLBodyElement::~HTMLBodyElement()
{
if (mContentStyleRule) {
mContentStyleRule->mPart = nullptr;
}
}
JSObject*
@ -347,21 +175,146 @@ HTMLBodyElement::ParseAttribute(int32_t aNamespaceID,
aResult);
}
void
HTMLBodyElement::UnbindFromTree(bool aDeep, bool aNullParent)
{
if (mContentStyleRule) {
mContentStyleRule->mPart = nullptr;
mContentStyleRule = nullptr;
}
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
}
void
HTMLBodyElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Margin)) {
// This is the one place where we try to set the same property
// multiple times in presentation attributes. Servo does not support
// querying if a property is set (because that is O(n) behavior
// in ServoSpecifiedValues). Instead, we use the below values to keep
// track of whether we have already set a property, and if so, what value
// we set it to (which is used when handling margin
// attributes from the containing frame element)
int32_t bodyMarginWidth = -1;
int32_t bodyMarginHeight = -1;
int32_t bodyTopMargin = -1;
int32_t bodyBottomMargin = -1;
int32_t bodyLeftMargin = -1;
int32_t bodyRightMargin = -1;
// check the mode (fortunately, the GenericSpecifiedValues has a presContext for us to use!)
NS_ASSERTION(aData->mPresContext, "null presContext in MapAttributesIntoRule was unexpected");
nsCompatibility mode = aData->mPresContext->CompatibilityMode();
const nsAttrValue* value;
// if marginwidth/marginheight are set, reflect them as 'margin'
value = aAttributes->GetAttr(nsGkAtoms::marginwidth);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyMarginWidth = value->GetIntegerValue();
if (bodyMarginWidth < 0) {
bodyMarginWidth = 0;
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, (float)bodyMarginWidth);
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, (float)bodyMarginWidth);
}
value = aAttributes->GetAttr(nsGkAtoms::marginheight);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyMarginHeight = value->GetIntegerValue();
if (bodyMarginHeight < 0) {
bodyMarginHeight = 0;
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_top, (float)bodyMarginHeight);
aData->SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)bodyMarginHeight);
}
// topmargin (IE-attribute)
if (bodyMarginHeight == -1) {
value = aAttributes->GetAttr(nsGkAtoms::topmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyTopMargin = value->GetIntegerValue();
if (bodyTopMargin < 0) {
bodyTopMargin = 0;
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_top, (float)bodyTopMargin);
}
}
// bottommargin (IE-attribute)
if (bodyMarginHeight == -1) {
value = aAttributes->GetAttr(nsGkAtoms::bottommargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyBottomMargin = value->GetIntegerValue();
if (bodyBottomMargin < 0) {
bodyBottomMargin = 0;
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)bodyBottomMargin);
}
}
// leftmargin (IE-attribute)
if (bodyMarginWidth == -1) {
value = aAttributes->GetAttr(nsGkAtoms::leftmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyLeftMargin = value->GetIntegerValue();
if (bodyLeftMargin < 0) {
bodyLeftMargin = 0;
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, (float)bodyLeftMargin);
}
}
// rightmargin (IE-attribute)
if (bodyMarginWidth == -1) {
value = aAttributes->GetAttr(nsGkAtoms::rightmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyRightMargin = value->GetIntegerValue();
if (bodyRightMargin < 0) {
bodyRightMargin = 0;
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, (float)bodyRightMargin);
}
}
// if marginwidth or marginheight is set in the <frame> and not set in the <body>
// reflect them as margin in the <body>
if (bodyMarginWidth == -1 || bodyMarginHeight == -1) {
nsCOMPtr<nsIDocShell> docShell(aData->mPresContext->GetDocShell());
if (docShell) {
nscoord frameMarginWidth=-1; // default value
nscoord frameMarginHeight=-1; // default value
docShell->GetMarginWidth(&frameMarginWidth); // -1 indicates not set
docShell->GetMarginHeight(&frameMarginHeight);
if (frameMarginWidth >= 0 && bodyMarginWidth == -1) { // set in <frame> & not in <body>
if (eCompatibility_NavQuirks == mode) {
if (bodyMarginHeight == -1 && 0 > frameMarginHeight) { // nav quirk
frameMarginHeight = 0;
}
}
}
if (frameMarginHeight >= 0 && bodyMarginHeight == -1) { // set in <frame> & not in <body>
if (eCompatibility_NavQuirks == mode) {
if (bodyMarginWidth == -1 && 0 > frameMarginWidth) { // nav quirk
frameMarginWidth = 0;
}
}
}
if (bodyMarginWidth == -1 && frameMarginWidth >= 0) {
if (bodyLeftMargin == -1) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, (float)frameMarginWidth);
}
if (bodyRightMargin == -1) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, (float)frameMarginWidth);
}
}
if (bodyMarginHeight == -1 && frameMarginHeight >= 0) {
if (bodyTopMargin == -1) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_top, (float)frameMarginHeight);
}
if (bodyBottomMargin == -1) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)frameMarginHeight);
}
}
}
}
}
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Display))) {
// When display if first asked for, go ahead and get our colors set up.
nsIPresShell *presShell = aData->PresContext()->GetPresShell();
@ -412,22 +365,6 @@ HTMLBodyElement::GetAttributeMappingFunction() const
return &MapAttributesIntoRule;
}
NS_IMETHODIMP
HTMLBodyElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
{
nsGenericHTMLElement::WalkContentStyleRules(aRuleWalker);
if (!mContentStyleRule && IsInUncomposedDoc()) {
// XXXbz should this use OwnerDoc() or GetComposedDoc()?
// sXBL/XBL2 issue!
mContentStyleRule = new BodyRule(this);
}
if (aRuleWalker && mContentStyleRule) {
aRuleWalker->Forward(mContentStyleRule);
}
return NS_OK;
}
NS_IMETHODIMP_(bool)
HTMLBodyElement::IsAttributeMapped(const nsIAtom* aAttribute) const
{
@ -436,12 +373,12 @@ HTMLBodyElement::IsAttributeMapped(const nsIAtom* aAttribute) const
{ &nsGkAtoms::vlink },
{ &nsGkAtoms::alink },
{ &nsGkAtoms::text },
// These aren't mapped through attribute mapping, but they are
// mapped through a style rule, so it is attribute dependent style.
// XXXldb But we don't actually replace the body rule when we have
// dynamic changes...
{ &nsGkAtoms::marginwidth },
{ &nsGkAtoms::marginheight },
{ &nsGkAtoms::topmargin },
{ &nsGkAtoms::rightmargin },
{ &nsGkAtoms::bottommargin },
{ &nsGkAtoms::leftmargin },
{ nullptr },
};
@ -490,6 +427,36 @@ HTMLBodyElement::IsEventAttributeName(nsIAtom *aName)
EventNameType_HTMLBodyOrFramesetOnly);
}
nsresult
HTMLBodyElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
{
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
return mAttrsAndChildren.ForceMapped(this, OwnerDoc());
}
nsresult
HTMLBodyElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue,
bool aNotify)
{
nsresult rv = nsGenericHTMLElement::AfterSetAttr(aNameSpaceID,
aName, aValue, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
// if the last mapped attribute was removed, don't clear the
// nsMappedAttributes, our style can still depend on the containing frame element
if (!aValue && IsAttributeMapped(aName)) {
nsresult rv = mAttrsAndChildren.ForceMapped(this, OwnerDoc());
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
}
#define EVENT(name_, id_, type_, struct_) /* nothing; handled by the superclass */
// nsGenericHTMLElement::GetOnError returns
// already_AddRefed<EventHandlerNonNull> while other getters return

View File

@ -15,28 +15,6 @@ namespace mozilla {
namespace dom {
class OnBeforeUnloadEventHandlerNonNull;
class HTMLBodyElement;
class BodyRule: public nsIStyleRule
{
virtual ~BodyRule();
public:
explicit BodyRule(HTMLBodyElement* aPart);
NS_DECL_ISUPPORTS
// nsIStyleRule interface
virtual void MapRuleInfoInto(nsRuleData* aRuleData) override;
virtual bool MightMapInheritedStyleData() override;
virtual bool GetDiscretelyAnimatedCSSValue(nsCSSPropertyID aProperty,
nsCSSValue* aValue) override;
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
HTMLBodyElement* mPart; // not ref-counted, cleared by content
};
class HTMLBodyElement final : public nsGenericHTMLElement,
public nsIDOMHTMLBodyElement
@ -125,23 +103,28 @@ public:
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult) override;
virtual void UnbindFromTree(bool aDeep = true,
bool aNullParent = true) override;
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) override;
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
virtual already_AddRefed<nsIEditor> GetAssociatedEditor() override;
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
virtual bool IsEventAttributeName(nsIAtom* aName) override;
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers) override;
/**
* Called when an attribute has just been changed
*/
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify) override;
protected:
virtual ~HTMLBodyElement();
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
RefPtr<BodyRule> mContentStyleRule;
private:
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
function loadFrame() {
document.documentElement.className = "";
}
</script>
<iframe id=frame onload="loadFrame()" src="data:text/html,<body><span lang='en'>text</span></body>" marginwidth="100px" marginheight="100px" width=300px height=300px></iframe>
</body>
</html>

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
function loadFrame() {
let frame = document.getElementById('frame');
frame.contentDocument.body.removeAttribute('lang');
document.documentElement.className = "";
}
</script>
<iframe id=frame onload="loadFrame()" src="data:text/html,<body lang='en'>text</body>" marginwidth="100px" marginheight="100px" width=300px height=300px></iframe>
</body>
</html>

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<body>
this text should have a margin of 100px on the top and left
<p style="direction: rtl">this text should have a margin of 100px on the right</p>
<script type="text/javascript">
document.body.setAttribute("topmargin", "100px");
document.body.setAttribute("leftmargin", "100px");
document.body.setAttribute("rightmargin", "100px");
</script>
</body>
</html>

View File

@ -0,0 +1,7 @@
<!DOCTYPE html>
<html>
<body topmargin="100px" leftmargin="100px" rightmargin="100px">
this text should have a margin of 100px on the top and left
<p style="direction: rtl">this text should have a margin of 100px on the right</p>
</body>
</html>

View File

@ -35,7 +35,7 @@ fails == 596455-2b.html 596455-2b.html
== bug448564-4a.html bug448564-4a.html
== bug502168-1_malformed.html bug502168-1_malformed.html
fails == responsive-image-load-shortcircuit.html responsive-image-load-shortcircuit.html
== responsive-image-load-shortcircuit.html responsive-image-load-shortcircuit.html
== image-load-shortcircuit-1.html image-load-shortcircuit-1.html
== image-load-shortcircuit-2.html image-load-shortcircuit-2.html
@ -43,7 +43,7 @@ fails == responsive-image-load-shortcircuit.html responsive-image-load-shortcirc
# image-orientation when determining the size of the image.
# (Fuzzy necessary due to pixel-wise comparison of different JPEGs.
# The vast majority of the fuzziness comes from Linux and WinXP.)
fails == bug917595-iframe-1.html bug917595-iframe-1.html # Bug 1341647
== bug917595-iframe-1.html bug917595-iframe-1.html
fails == bug917595-exif-rotated.jpg bug917595-exif-rotated.jpg
# Test support for SVG-as-image in <picture> elements.
@ -63,3 +63,10 @@ pref(permissions.default.image,2) HTTP == bug1196784-with-srcset.html bug1196784
# Test video with rotation information can be rotated.
== bug1228601-video-rotation-90.html bug1228601-video-rotation-90.html
# Test that dynamically setting body margin attributes updates style appropriately
== body-topmargin-dynamic.html body-topmargin-dynamic.html
# Test that dynamically removing a nonmargin mapped attribute does not
# destroy margins inherited from the frame.
== body-frame-margin-remove-other-pres-hint.html body-frame-margin-remove-other-pres-hint.html

View File

@ -63,3 +63,10 @@ pref(permissions.default.image,2) HTTP == bug1196784-with-srcset.html bug1196784
# Test video with rotation information can be rotated.
== bug1228601-video-rotation-90.html bug1228601-video-rotated-ref.html
# Test that dynamically setting body margin attributes updates style appropriately
== body-topmargin-dynamic.html body-topmargin-ref.html
# Test that dynamically removing a nonmargin mapped attribute does not
# destroy margins inherited from the frame.
== body-frame-margin-remove-other-pres-hint.html body-frame-margin-remove-other-pres-hint-ref.html

View File

@ -16,12 +16,12 @@ random-if(cocoaWidget) fails-if(!haveTestPlugin&&!Android) skip-if(stylo) == plu
fails == plugin-transform-alpha-zindex.html plugin-transform-alpha-zindex.html
== plugin-busy-alpha-zindex.html plugin-busy-alpha-zindex.html
== plugin-background.html plugin-background.html
fails == plugin-background-1-step.html plugin-background-1-step.html # bug 1348723
fails == plugin-background-2-step.html plugin-background-2-step.html # bug 1348723
fails == plugin-background-5-step.html plugin-background-5-step.html # bug 1348723
fails == plugin-background-10-step.html plugin-background-10-step.html # bug 1348723
== plugin-background-1-step.html plugin-background-1-step.html # bug 1348723
== plugin-background-2-step.html plugin-background-2-step.html # bug 1348723
== plugin-background-5-step.html plugin-background-5-step.html # bug 1348723
== plugin-background-10-step.html plugin-background-10-step.html # bug 1348723
== plugin-transform-1.html plugin-transform-1.html
fails == plugin-transform-2.html plugin-transform-2.html
fails == shrink-1.html shrink-1.html
== shrink-1.html shrink-1.html
== update-1.html update-1.html
skip-if(!haveTestPlugin) == windowless-layers.html windowless-layers.html

View File

@ -533,6 +533,9 @@ ServoRestyleManager::AttributeChanged(Element* aElement, int32_t aNameSpaceID,
if (aAttribute == nsGkAtoms::cellpadding && aElement->IsHTMLElement(nsGkAtoms::table)) {
PostRestyleEvent(aElement, eRestyle_Subtree, nsChangeHint(0));
}
if (aElement->IsAttributeMapped(aAttribute)) {
Servo_NoteExplicitHints(aElement, eRestyle_Self, nsChangeHint(0));
}
}
nsresult

View File

@ -282,7 +282,7 @@ fails == 243519-7.html 243519-7.html
== 260406-1.html 260406-1.html
== 261826-1.xul 261826-1.xul
== 262151-1.html 262151-1.html
fails == 262998-1.html 262998-1.html
== 262998-1.html 262998-1.html
== 267353-1.html 267353-1.html
== 269908-1.html 269908-1.html
== 269908-2.html 269908-2.html
@ -871,10 +871,10 @@ fails == 402940-3.html 402940-3.html
== 403129-4.html 403129-4.html
fails random == 403134-1.html 403134-1.html
== 403181-1.xml 403181-1.xml
fails == 403249-1a.html 403249-1a.html
fails == 403249-1b.html 403249-1b.html
fails == 403249-2a.html 403249-2a.html
fails == 403249-2b.html 403249-2b.html
== 403249-1a.html 403249-1a.html
== 403249-1b.html 403249-1b.html
== 403249-2a.html 403249-2a.html
== 403249-2b.html 403249-2b.html
== 403328-1.html 403328-1.html
== 403426-1.html 403426-1.html
== 403455-1.html 403455-1.html
@ -899,8 +899,8 @@ fails == 404123-2.html 404123-2.html
random-if(cocoaWidget) HTTP(..) == 404149-1.xul 404149-1.xul
== 404180-1.html 404180-1.html
== 404301-1.html 404301-1.html
fails == 404309-1a.html 404309-1a.html
fails == 404309-1b.html 404309-1b.html
== 404309-1a.html 404309-1a.html
== 404309-1b.html 404309-1b.html
# Disabled due to compartments for now.
== data:application/xml,<foo/> data:application/xml,<foo/>
fails == 404553-1.html 404553-1.html
@ -1155,7 +1155,7 @@ fails == 440112.html 440112.html
fails == 440149-1.html 440149-1.html
== 441259-1.html 441259-1.html
== 441259-2.html 441259-2.html
fails == 442542-1.html 442542-1.html
== 442542-1.html 442542-1.html
fails == 444015-1.html 444015-1.html
== 444375-1.html 444375-1.html
fails == 444928-1.html 444928-1.html
@ -1356,8 +1356,8 @@ fails == 485275-1.html 485275-1.html
== 490173-2.html 490173-2.html
== 490176-1.html 490176-1.html
== 490177-1.svg 490177-1.svg
fails == 490182-1a.html 490182-1a.html
fails == 490182-1b.html 490182-1b.html
== 490182-1a.html 490182-1a.html
== 490182-1b.html 490182-1b.html
pref(browser.display.focus_ring_width,1) == 491180-1.html 491180-1.html
pref(browser.display.focus_ring_width,1) == 491180-2.html 491180-2.html
== 491323-1.xul 491323-1.xul

View File

@ -16,5 +16,5 @@ fails == mq_print_orientation.xhtml mq_print_orientation.xhtml
== mq_print_minheight_updown.xhtml mq_print_minheight_updown.xhtml
== mq_print_minwidth_updown.xhtml mq_print_minwidth_updown.xhtml
fails == scoped-mq-update.html scoped-mq-update.html
== scoped-mq-update.html scoped-mq-update.html
fails == system-metrics-1.html system-metrics-1.html

View File

@ -20,7 +20,7 @@ fails == float-outside-block-push.html float-outside-block-push.html
== 478834-1.html 478834-1.html
== 546048-1.html 546048-1.html
== 775350-1.html 775350-1.html
fails == 1114329.html 1114329.html
== 1114329.html 1114329.html
== 1236745-1.html 1236745-1.html
fails == 1260031-1.html?display:table 1260031-1.html?display:table
fails == 1260031-1.html?display:table-cell 1260031-1.html?display:table-cell

View File

@ -48,5 +48,5 @@ skip-if(!asyncPan) == inline-4.html inline-4.html
== block-in-inline-1.html block-in-inline-1.html
== block-in-inline-2.html block-in-inline-2.html
== block-in-inline-3.html block-in-inline-3.html
fails == block-in-inline-continuations.html block-in-inline-continuations.html
== block-in-inline-continuations.html block-in-inline-continuations.html
== inner-table-1.html inner-table-1.html

View File

@ -302,9 +302,9 @@ fails == outline.html outline.html
== overflow-on-outer-svg-02a.xhtml overflow-on-outer-svg-02a.xhtml
== overflow-on-outer-svg-02b.xhtml overflow-on-outer-svg-02b.xhtml
== overflow-on-outer-svg-02c.xhtml overflow-on-outer-svg-02c.xhtml
fails == overflow-on-outer-svg-02d.xhtml overflow-on-outer-svg-02d.xhtml
== overflow-on-outer-svg-02d.xhtml overflow-on-outer-svg-02d.xhtml
== overflow-on-outer-svg-03a.xhtml overflow-on-outer-svg-03a.xhtml
fails == overflow-on-outer-svg-03b.xhtml overflow-on-outer-svg-03b.xhtml
== overflow-on-outer-svg-03b.xhtml overflow-on-outer-svg-03b.xhtml
pref(svg.paint-order.enabled,true) == paint-order-01.svg paint-order-01.svg
pref(svg.paint-order.enabled,true) == paint-order-02.svg paint-order-02.svg
pref(svg.paint-order.enabled,true) == paint-order-03.svg paint-order-03.svg

View File

@ -30,7 +30,6 @@ to mochitest command.
## Failures
* Media query support:
* test_bug1089417.html [1]
* test_bug418986-2.html: matchMedia support [3]
* test_bug453896_deck.html: &lt;style media&gt; support [8]
* test_media_queries.html [657]