Bug 1338936 - Part 2: stylo: Add necessary stubbed-out bindings for ServoSpecifiedValues; r=bz,emilio
MozReview-Commit-ID: 6wg32flypt7
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -1517,16 +1517,22 @@ nsGenericHTMLElement::MapImageBorderAttr
void
nsGenericHTMLElement::MapBackgroundInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (!aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Background)))
return;
+ if (aData->IsServo()) {
+ // FIXME(bug 1339711)
+ NS_WARNING("stylo: cannot handle background presentation attribute");
+ return;
+ }
+
nsPresContext* presContext = aData->PresContext();
if (!aData->PropertyIsSet(eCSSProperty_background_image) &&
presContext->UseDocumentColors()) {
// background
nsAttrValue* value =
const_cast<nsAttrValue*>(aAttributes->GetAttr(nsGkAtoms::background));
if (value) {
@@ -1540,19 +1546,16 @@ nsGenericHTMLElement::MapBackgroundInto(
// put it in the style tree.
if (value->Type() == nsAttrValue::eURL) {
value->LoadImage(presContext->Document());
}
if (value->Type() == nsAttrValue::eImage) {
nsCSSValueList* list = backImage->SetListValue();
list->mValue.SetImageValue(value->GetImageValue());
}
- } else {
- // FIXME(bug 1330041)
- MOZ_ASSERT_UNREACHABLE("stylo: cannot handle background");
}
}
}
}
void
nsGenericHTMLElement::MapBGColorInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
--- a/dom/mathml/nsMathMLElement.cpp
+++ b/dom/mathml/nsMathMLElement.cpp
@@ -485,16 +485,22 @@ nsMathMLElement::ParseNumericValue(const
aCSSValue.SetFloatValue(floatValue, cssUnit);
return true;
}
void
nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData)
{
+ if (aGenericData->IsServo()) {
+ // FIXME (bug 1339711) handle MathML properties in Stylo
+ NS_WARNING("stylo: cannot handle MathML presentation attributes");
+ return;
+ }
+
nsRuleData* aData = aGenericData->AsGecko();
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
// scriptsizemultiplier
//
// "Specifies the multiplier to be used to adjust font size due to changes
// in scriptlevel.
//
// values: number
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -170,20 +170,56 @@ SERVO_BINDING_FUNC(Servo_DeclarationBloc
nsCSSPropertyID property,
nsACString* value, bool is_important)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_RemoveProperty, void,
RawServoDeclarationBlockBorrowed declarations,
const nsACString* property)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_RemovePropertyById, void,
RawServoDeclarationBlockBorrowed declarations,
nsCSSPropertyID property)
-SERVO_BINDING_FUNC(Servo_DeclarationBlock_AddPresValue, void,
+
+// presentation attributes
+SERVO_BINDING_FUNC(Servo_DeclarationBlock_PropertyIsSet, bool,
+ RawServoDeclarationBlockBorrowed declarations,
+ nsCSSPropertyID property)
+SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetIdentStringValue, void,
+ RawServoDeclarationBlockBorrowed declarations,
+ nsCSSPropertyID property,
+ const nsAString& value)
+SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetKeywordValue, void,
+ RawServoDeclarationBlockBorrowed declarations,
+ nsCSSPropertyID property,
+ int32_t value)
+SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetIntValue, void,
+ RawServoDeclarationBlockBorrowed declarations,
+ nsCSSPropertyID property,
+ int32_t value)
+SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetPixelValue, void,
RawServoDeclarationBlockBorrowed declarations,
nsCSSPropertyID property,
- nsCSSValueBorrowedMut css_value)
+ float value)
+SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetPercentValue, void,
+ RawServoDeclarationBlockBorrowed declarations,
+ nsCSSPropertyID property,
+ float value)
+SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetAutoValue, void,
+ RawServoDeclarationBlockBorrowed declarations,
+ nsCSSPropertyID property)
+SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetCurrentColor, void,
+ RawServoDeclarationBlockBorrowed declarations,
+ nsCSSPropertyID property)
+SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetColorValue, void,
+ RawServoDeclarationBlockBorrowed declarations,
+ nsCSSPropertyID property,
+ nscolor value)
+SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetFontFamily, void,
+ RawServoDeclarationBlockBorrowed declarations,
+ const nsAString& value)
+SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetTextDecorationColorOverride, void,
+ RawServoDeclarationBlockBorrowed declarations)
// CSS supports()
SERVO_BINDING_FUNC(Servo_CSSSupports2, bool,
const nsACString* name, const nsACString* value)
SERVO_BINDING_FUNC(Servo_CSSSupports, bool,
const nsACString* cond)
// Computed style data
--- a/layout/style/ServoSpecifiedValues.cpp
+++ b/layout/style/ServoSpecifiedValues.cpp
@@ -1,13 +1,14 @@
/* -*- 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/. */
+#include "mozilla/ServoBindings.h"
#include "mozilla/ServoSpecifiedValues.h"
namespace {
#define STYLE_STRUCT(name, checkdata_cb) | NS_STYLE_INHERIT_BIT(name)
const uint64_t ALL_SIDS = 0
#include "nsStyleStructList.h"
;
@@ -20,8 +21,84 @@ using namespace mozilla;
ServoSpecifiedValues::ServoSpecifiedValues(nsPresContext* aContext,
RawServoDeclarationBlock* aDecl)
: GenericSpecifiedValues(StyleBackendType::Servo, aContext, ALL_SIDS)
, mDecl(aDecl)
{
}
+
+bool
+ServoSpecifiedValues::PropertyIsSet(nsCSSPropertyID aId)
+{
+ // We always create fresh ServoSpecifiedValues for each property
+ // mapping, so unlike Gecko there aren't existing properties from
+ // the cascade that we wish to avoid overwriting.
+ //
+ // If a property is being overwritten, that's a bug. Check for it
+ // in debug mode (this is O(n^2) behavior since Servo will traverse
+ // the array each time you add a new property)
+ MOZ_ASSERT(!Servo_DeclarationBlock_PropertyIsSet(mDecl, aId),
+ "Presentation attribute mappers should never attempt to set the same property twice");
+ return false;
+}
+
+void
+ServoSpecifiedValues::SetIdentStringValue(nsCSSPropertyID aId,
+ const nsString& aValue)
+{
+ Servo_DeclarationBlock_SetIdentStringValue(mDecl, aId, aValue);
+}
+
+void
+ServoSpecifiedValues::SetKeywordValue(nsCSSPropertyID aId, int32_t aValue)
+{
+ Servo_DeclarationBlock_SetKeywordValue(mDecl, aId, aValue);
+}
+
+void
+ServoSpecifiedValues::SetIntValue(nsCSSPropertyID aId, int32_t aValue)
+{
+ Servo_DeclarationBlock_SetIntValue(mDecl, aId, aValue);
+}
+
+void
+ServoSpecifiedValues::SetPixelValue(nsCSSPropertyID aId, float aValue)
+{
+ Servo_DeclarationBlock_SetPixelValue(mDecl, aId, aValue);
+}
+
+void
+ServoSpecifiedValues::SetPercentValue(nsCSSPropertyID aId, float aValue)
+{
+ Servo_DeclarationBlock_SetPercentValue(mDecl, aId, aValue);
+}
+
+void
+ServoSpecifiedValues::SetAutoValue(nsCSSPropertyID aId)
+{
+ Servo_DeclarationBlock_SetAutoValue(mDecl, aId);
+}
+
+void
+ServoSpecifiedValues::SetCurrentColor(nsCSSPropertyID aId)
+{
+ Servo_DeclarationBlock_SetCurrentColor(mDecl, aId);
+}
+
+void
+ServoSpecifiedValues::SetColorValue(nsCSSPropertyID aId, nscolor aColor)
+{
+ Servo_DeclarationBlock_SetColorValue(mDecl, aId, aColor);
+}
+
+void
+ServoSpecifiedValues::SetFontFamily(const nsString& aValue)
+{
+ Servo_DeclarationBlock_SetFontFamily(mDecl, aValue);
+}
+
+void
+ServoSpecifiedValues::SetTextDecorationColorOverride()
+{
+ Servo_DeclarationBlock_SetTextDecorationColorOverride(mDecl);
+}
--- a/layout/style/ServoSpecifiedValues.h
+++ b/layout/style/ServoSpecifiedValues.h
@@ -19,91 +19,90 @@ namespace mozilla {
class ServoSpecifiedValues final: public GenericSpecifiedValues
{
public:
ServoSpecifiedValues(nsPresContext* aContext, RawServoDeclarationBlock* aDecl);
// GenericSpecifiedValues overrides
- bool PropertyIsSet(nsCSSPropertyID aId) {
- return false;
- }
+ bool PropertyIsSet(nsCSSPropertyID aId);
void SetIdentStringValue(nsCSSPropertyID aId,
- const nsString& aValue) {
-
- }
+ const nsString& aValue);
void SetIdentStringValueIfUnset(nsCSSPropertyID aId,
const nsString& aValue) {
-
+ if (!PropertyIsSet(aId)) {
+ SetIdentStringValue(aId, aValue);
+ }
}
void SetKeywordValue(nsCSSPropertyID aId,
- int32_t aValue) {
- }
+ int32_t aValue);
void SetKeywordValueIfUnset(nsCSSPropertyID aId,
int32_t aValue) {
-
+ if (!PropertyIsSet(aId)) {
+ SetKeywordValue(aId, aValue);
+ }
}
void SetIntValue(nsCSSPropertyID aId,
- int32_t aValue) {
- }
+ int32_t aValue);
void SetPixelValue(nsCSSPropertyID aId,
- float aValue) {
- }
+ float aValue);
void SetPixelValueIfUnset(nsCSSPropertyID aId,
float aValue) {
+ if (!PropertyIsSet(aId)) {
+ SetPixelValue(aId, aValue);
+ }
}
void SetPercentValue(nsCSSPropertyID aId,
- float aValue) {
- }
+ float aValue);
- void SetAutoValue(nsCSSPropertyID aId) {
- }
+ void SetAutoValue(nsCSSPropertyID aId);
void SetAutoValueIfUnset(nsCSSPropertyID aId) {
+ if (!PropertyIsSet(aId)) {
+ SetAutoValue(aId);
+ }
}
void SetPercentValueIfUnset(nsCSSPropertyID aId,
float aValue) {
-
+ if (!PropertyIsSet(aId)) {
+ SetPercentValue(aId, aValue);
+ }
}
- void SetCurrentColor(nsCSSPropertyID aId) {
-
- }
+ void SetCurrentColor(nsCSSPropertyID aId);
void SetCurrentColorIfUnset(nsCSSPropertyID aId) {
-
+ if (!PropertyIsSet(aId)) {
+ SetCurrentColor(aId);
+ }
}
void SetColorValue(nsCSSPropertyID aId,
- nscolor aValue) {
-
- }
+ nscolor aValue);
void SetColorValueIfUnset(nsCSSPropertyID aId,
nscolor aValue) {
-
+ if (!PropertyIsSet(aId)) {
+ SetColorValue(aId, aValue);
+ }
}
- void SetFontFamily(const nsString& aValue) {
-
- }
- void SetTextDecorationColorOverride() {
-
- }
+ void SetFontFamily(const nsString& aValue);
+ void SetTextDecorationColorOverride();
private:
RefPtr<RawServoDeclarationBlock> mDecl;
};
} // namespace mozilla
#endif // mozilla_ServoSpecifiedValues_h