2017-01-27 00:39:13 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Generic representation of a container of specified CSS values, which
|
|
|
|
* could potentially be Servo- or Gecko- format. Used to make attribute mapping
|
|
|
|
* code generic over style backends.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef mozilla_GenericSpecifiedValues_h
|
|
|
|
#define mozilla_GenericSpecifiedValues_h
|
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
#include "mozilla/ServoUtils.h"
|
2017-01-27 00:39:13 +03:00
|
|
|
#include "nsCSSProps.h"
|
|
|
|
#include "nsCSSValue.h"
|
|
|
|
#include "nsPresContext.h"
|
|
|
|
|
|
|
|
struct nsRuleData;
|
2017-02-13 03:02:29 +03:00
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
namespace mozilla {
|
2017-02-13 03:02:29 +03:00
|
|
|
|
|
|
|
class ServoSpecifiedValues;
|
|
|
|
|
2017-01-27 00:39:13 +03:00
|
|
|
// This provides a common interface for attribute mappers (MapAttributesIntoRule)
|
|
|
|
// to use regardless of the style backend. If the style backend is Gecko,
|
|
|
|
// this will contain an nsRuleData. If it is Servo, it will be a PropertyDeclarationBlock.
|
|
|
|
class GenericSpecifiedValues {
|
2017-01-27 03:51:01 +03:00
|
|
|
protected:
|
|
|
|
explicit GenericSpecifiedValues(StyleBackendType aType, nsPresContext* aPresContext,
|
|
|
|
uint32_t aSIDs)
|
|
|
|
: mType(aType), mPresContext(aPresContext), mSIDs(aSIDs) {}
|
|
|
|
|
2017-01-27 00:39:13 +03:00
|
|
|
public:
|
2017-02-13 03:02:29 +03:00
|
|
|
MOZ_DECL_STYLO_METHODS(nsRuleData, ServoSpecifiedValues)
|
2017-01-27 03:51:01 +03:00
|
|
|
|
2017-01-27 00:39:13 +03:00
|
|
|
// Check if we already contain a certain longhand
|
2017-01-27 03:51:01 +03:00
|
|
|
inline bool PropertyIsSet(nsCSSPropertyID aId);
|
2017-01-27 03:51:01 +03:00
|
|
|
// Check if we are able to hold longhands from a given
|
|
|
|
// style struct. Pass the result of NS_STYLE_INHERIT_BIT to this
|
|
|
|
// function. Can accept multiple inherit bits or'd together.
|
2017-01-27 03:51:01 +03:00
|
|
|
inline bool ShouldComputeStyleStruct(uint64_t aInheritBits) {
|
|
|
|
return aInheritBits & mSIDs;
|
|
|
|
}
|
2017-01-27 03:51:01 +03:00
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
inline nsPresContext* PresContext() {
|
|
|
|
return mPresContext;
|
|
|
|
}
|
2017-01-27 03:51:01 +03:00
|
|
|
|
|
|
|
// Set a property to an identifier (string)
|
2017-01-27 03:51:01 +03:00
|
|
|
inline void SetIdentStringValue(nsCSSPropertyID aId, const nsString& aValue);
|
|
|
|
inline void SetIdentStringValueIfUnset(nsCSSPropertyID aId, const nsString& aValue);
|
2017-01-27 03:51:01 +03:00
|
|
|
|
|
|
|
// Set a property to a keyword (usually NS_STYLE_* or StyleFoo::*)
|
2017-01-27 03:51:01 +03:00
|
|
|
inline void SetKeywordValue(nsCSSPropertyID aId, int32_t aValue);
|
|
|
|
inline void SetKeywordValueIfUnset(nsCSSPropertyID aId, int32_t aValue);
|
2017-01-27 03:51:01 +03:00
|
|
|
|
|
|
|
template<typename T,
|
|
|
|
typename = typename std::enable_if<std::is_enum<T>::value>::type>
|
|
|
|
void SetKeywordValue(nsCSSPropertyID aId, T aValue) {
|
|
|
|
static_assert(mozilla::EnumTypeFitsWithin<T, int32_t>::value,
|
|
|
|
"aValue must be an enum that fits within 32 bits");
|
|
|
|
SetKeywordValue(aId, static_cast<int32_t>(aValue));
|
|
|
|
}
|
|
|
|
template<typename T,
|
|
|
|
typename = typename std::enable_if<std::is_enum<T>::value>::type>
|
|
|
|
void SetKeywordValueIfUnset(nsCSSPropertyID aId, T aValue) {
|
|
|
|
static_assert(mozilla::EnumTypeFitsWithin<T, int32_t>::value,
|
|
|
|
"aValue must be an enum that fits within 32 bits");
|
|
|
|
SetKeywordValueIfUnset(aId, static_cast<int32_t>(aValue));
|
|
|
|
}
|
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
// Set a property to an integer value
|
2017-01-27 03:51:01 +03:00
|
|
|
inline void SetIntValue(nsCSSPropertyID aId, int32_t aValue);
|
2017-01-27 03:51:01 +03:00
|
|
|
// Set a property to a pixel value
|
2017-01-27 03:51:01 +03:00
|
|
|
inline void SetPixelValue(nsCSSPropertyID aId, float aValue);
|
|
|
|
inline void SetPixelValueIfUnset(nsCSSPropertyID aId, float aValue);
|
2017-01-27 03:51:01 +03:00
|
|
|
|
2017-04-10 10:28:48 +03:00
|
|
|
inline void SetLengthValue(nsCSSPropertyID aId, nsCSSValue aValue);
|
|
|
|
|
2017-04-10 10:28:48 +03:00
|
|
|
// Set a property to a number value
|
|
|
|
inline void SetNumberValue(nsCSSPropertyID aId, float aValue);
|
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
// Set a property to a percent value
|
2017-01-27 03:51:01 +03:00
|
|
|
inline void SetPercentValue(nsCSSPropertyID aId, float aValue);
|
|
|
|
inline void SetPercentValueIfUnset(nsCSSPropertyID aId, float aValue);
|
2017-01-27 03:51:01 +03:00
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
// Set a property to `auto`
|
2017-01-27 03:51:01 +03:00
|
|
|
inline void SetAutoValue(nsCSSPropertyID aId);
|
|
|
|
inline void SetAutoValueIfUnset(nsCSSPropertyID aId);
|
2017-01-27 03:51:01 +03:00
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
// Set a property to `currentcolor`
|
2017-01-27 03:51:01 +03:00
|
|
|
inline void SetCurrentColor(nsCSSPropertyID aId);
|
|
|
|
inline void SetCurrentColorIfUnset(nsCSSPropertyID aId);
|
2017-01-27 03:51:01 +03:00
|
|
|
|
|
|
|
// Set a property to an RGBA nscolor value
|
2017-01-27 03:51:01 +03:00
|
|
|
inline void SetColorValue(nsCSSPropertyID aId, nscolor aValue);
|
|
|
|
inline void SetColorValueIfUnset(nsCSSPropertyID aId, nscolor aValue);
|
2017-01-27 00:39:13 +03:00
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
// Set font-family to a string
|
2017-01-27 03:51:01 +03:00
|
|
|
inline void SetFontFamily(const nsString& aValue);
|
2017-01-27 03:51:01 +03:00
|
|
|
// Add a quirks-mode override to the decoration color of elements nested in <a>
|
2017-01-27 03:51:01 +03:00
|
|
|
inline void SetTextDecorationColorOverride();
|
2017-04-10 10:28:48 +03:00
|
|
|
inline void SetBackgroundImage(nsAttrValue& value);
|
2017-01-27 03:51:01 +03:00
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
const mozilla::StyleBackendType mType;
|
|
|
|
nsPresContext* const mPresContext;
|
|
|
|
const uint32_t mSIDs;
|
2017-01-27 00:39:13 +03:00
|
|
|
};
|
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
#endif // mozilla_GenericSpecifiedValues_h
|