Bug 1334330 - Part 11: stylo: Use ServoUtils abstraction for GenericSpecifiedValues to remove virtual dispatch overhead in nostylo mode; r=bz,emilio

MozReview-Commit-ID: 8yGWs2uOjES

--HG--
extra : rebase_source : 2fed3ab11c243a3b045116abd04dbb9e939c5dc2
This commit is contained in:
Manish Goregaokar 2017-01-26 16:51:01 -08:00
Родитель f70f115d57
Коммит e4852035e0
35 изменённых файлов: 270 добавлений и 101 удалений

Просмотреть файл

@ -37,6 +37,6 @@ nsMappedAttributeElement::GetAttributeMappingFunction() const
void
nsMappedAttributeElement::MapNoAttributesInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData)
mozilla::GenericSpecifiedValues* aGenericData)
{
}

Просмотреть файл

@ -20,7 +20,7 @@ class nsMappedAttributes;
struct nsRuleData;
typedef void (*nsMapRuleToAttributesFunc)(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData);
mozilla::GenericSpecifiedValues* aData);
typedef nsStyledElement nsMappedAttributeElementBase;
@ -37,7 +37,7 @@ public:
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
static void MapNoAttributesInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) override;
virtual bool SetMappedAttribute(nsIDocument* aDocument,

Просмотреть файл

@ -6,11 +6,10 @@
#include "mozilla/dom/HTMLBRElement.h"
#include "mozilla/dom/HTMLBRElementBinding.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsAttrValueInlines.h"
#include "nsStyleConsts.h"
#include "nsMappedAttributes.h"
#include "nsRuleData.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(BR)

Просмотреть файл

@ -6,6 +6,7 @@
#include "HTMLBodyElement.h"
#include "mozilla/dom/HTMLBodyElementBinding.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsAttrValueInlines.h"
#include "nsGkAtoms.h"
#include "nsStyleConsts.h"
@ -15,7 +16,6 @@
#include "nsHTMLStyleSheet.h"
#include "nsIEditor.h"
#include "nsMappedAttributes.h"
#include "nsRuleData.h"
#include "nsIDocShell.h"
#include "nsRuleWalker.h"
#include "nsGlobalWindow.h"

Просмотреть файл

@ -10,11 +10,11 @@
#include "mozilla/dom/NodeListBinding.h"
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/css/StyleRule.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsGkAtoms.h"
#include "nsStyleConsts.h"
#include "nsIAtom.h"
#include "nsCSSRuleProcessor.h"
#include "nsRuleData.h"
#include "nsRuleProcessorData.h"
#include "nsRuleWalker.h"
#include "nsCSSParser.h"

Просмотреть файл

@ -6,9 +6,9 @@
#include "HTMLFontElement.h"
#include "mozilla/dom/HTMLFontElementBinding.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsAttrValueInlines.h"
#include "nsMappedAttributes.h"
#include "nsRuleData.h"
#include "nsContentUtils.h"
#include "nsCSSParser.h"

Просмотреть файл

@ -7,10 +7,10 @@
#include "mozilla/dom/HTMLHeadingElement.h"
#include "mozilla/dom/HTMLHeadingElementBinding.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsGkAtoms.h"
#include "nsStyleConsts.h"
#include "nsMappedAttributes.h"
#include "nsRuleData.h"
#include "mozAutoDocUpdate.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Heading)

Просмотреть файл

@ -6,10 +6,10 @@
#include "mozilla/dom/HTMLIFrameElement.h"
#include "mozilla/dom/HTMLIFrameElementBinding.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsMappedAttributes.h"
#include "nsAttrValueInlines.h"
#include "nsError.h"
#include "nsRuleData.h"
#include "nsStyleConsts.h"
#include "nsContentUtils.h"
#include "nsSandboxFlags.h"

Просмотреть файл

@ -41,11 +41,10 @@
#include "nsILoadGroup.h"
#include "nsRuleData.h"
#include "nsIDOMHTMLMapElement.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStates.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "mozilla/net/ReferrerPolicy.h"
#include "nsLayoutUtils.h"

Просмотреть файл

@ -69,11 +69,11 @@
#include "mozilla/ContentEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStates.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "mozilla/InternalMutationEvent.h"
#include "mozilla/TextEvents.h"
#include "mozilla/TouchEvents.h"
#include "nsRuleData.h"
#include <algorithm>
// input type=radio

Просмотреть файл

@ -7,11 +7,11 @@
#include "mozilla/dom/HTMLLIElement.h"
#include "mozilla/dom/HTMLLIElementBinding.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsAttrValueInlines.h"
#include "nsGkAtoms.h"
#include "nsStyleConsts.h"
#include "nsMappedAttributes.h"
#include "nsRuleData.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(LI)

Просмотреть файл

@ -10,6 +10,7 @@
#include "mozAutoDocUpdate.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/Element.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "mozilla/dom/HTMLFormSubmission.h"
#include "mozilla/dom/HTMLOptionElement.h"
#include "mozilla/dom/HTMLOptionsCollectionBinding.h"

Просмотреть файл

@ -7,9 +7,9 @@
#include "mozilla/dom/HTMLParagraphElement.h"
#include "mozilla/dom/HTMLParagraphElementBinding.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsStyleConsts.h"
#include "nsMappedAttributes.h"
#include "nsRuleData.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Paragraph)

Просмотреть файл

@ -7,11 +7,11 @@
#include "mozilla/dom/HTMLPreElement.h"
#include "mozilla/dom/HTMLPreElementBinding.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsAttrValueInlines.h"
#include "nsGkAtoms.h"
#include "nsStyleConsts.h"
#include "nsMappedAttributes.h"
#include "nsRuleData.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Pre)

Просмотреть файл

@ -17,6 +17,7 @@
#include "mozilla/dom/HTMLOptionElement.h"
#include "mozilla/dom/HTMLSelectElementBinding.h"
#include "mozilla/dom/UnionTypes.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsContentCreatorFunctions.h"
#include "nsContentList.h"
#include "nsError.h"
@ -32,7 +33,6 @@
#include "nsLayoutUtils.h"
#include "nsMappedAttributes.h"
#include "nsPresState.h"
#include "nsRuleData.h"
#include "nsServiceManagerUtils.h"
#include "nsStyleConsts.h"
#include "nsTextNode.h"

Просмотреть файл

@ -12,9 +12,9 @@
#include "mozilla/dom/HTMLParamElementBinding.h"
#include "mozilla/dom/HTMLQuoteElementBinding.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsAttrValueInlines.h"
#include "nsStyleConsts.h"
#include "nsRuleData.h"
#include "nsMappedAttributes.h"
#include "nsContentUtils.h"
#include "nsIContentSecurityPolicy.h"

Просмотреть файл

@ -9,12 +9,12 @@
#include "mozilla/dom/HTMLOListElementBinding.h"
#include "mozilla/dom/HTMLUListElementBinding.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsGenericHTMLElement.h"
#include "nsAttrValueInlines.h"
#include "nsGkAtoms.h"
#include "nsStyleConsts.h"
#include "nsMappedAttributes.h"
#include "nsRuleData.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(SharedList)

Просмотреть файл

@ -7,10 +7,10 @@
#include "mozilla/dom/HTMLSpanElement.h"
#include "mozilla/dom/HTMLSpanElementBinding.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsGkAtoms.h"
#include "nsStyleConsts.h"
#include "nsIAtom.h"
#include "nsRuleData.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Span)

Просмотреть файл

@ -5,9 +5,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/HTMLTableCaptionElement.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsAttrValueInlines.h"
#include "nsMappedAttributes.h"
#include "nsRuleData.h"
#include "mozilla/dom/HTMLTableCaptionElementBinding.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(TableCaption)

Просмотреть файл

@ -7,9 +7,9 @@
#include "mozilla/dom/HTMLTableCellElement.h"
#include "mozilla/dom/HTMLTableElement.h"
#include "mozilla/dom/HTMLTableRowElement.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsMappedAttributes.h"
#include "nsAttrValueInlines.h"
#include "nsRuleData.h"
#include "nsRuleWalker.h"
#include "celldata.h"
#include "mozilla/dom/HTMLTableCellElementBinding.h"

Просмотреть файл

@ -5,10 +5,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/HTMLTableColElement.h"
#include "mozilla/dom/HTMLTableColElementBinding.h"
#include "nsMappedAttributes.h"
#include "nsAttrValueInlines.h"
#include "nsRuleData.h"
#include "mozilla/dom/HTMLTableColElementBinding.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(TableCol)

Просмотреть файл

@ -5,8 +5,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/HTMLTableElement.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsAttrValueInlines.h"
#include "nsRuleData.h"
#include "nsHTMLStyleSheet.h"
#include "nsMappedAttributes.h"
#include "mozilla/dom/HTMLCollectionBinding.h"

Просмотреть файл

@ -6,9 +6,9 @@
#include "mozilla/dom/HTMLTableRowElement.h"
#include "mozilla/dom/HTMLTableElement.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsMappedAttributes.h"
#include "nsAttrValueInlines.h"
#include "nsRuleData.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/HTMLTableRowElementBinding.h"
#include "nsContentList.h"

Просмотреть файл

@ -5,9 +5,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/HTMLTableSectionElement.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsMappedAttributes.h"
#include "nsAttrValueInlines.h"
#include "nsRuleData.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/HTMLTableSectionElementBinding.h"
#include "nsContentUtils.h"

Просмотреть файл

@ -7,10 +7,10 @@
#include "mozilla/dom/HTMLTemplateElement.h"
#include "mozilla/dom/HTMLTemplateElementBinding.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "nsGkAtoms.h"
#include "nsStyleConsts.h"
#include "nsIAtom.h"
#include "nsRuleData.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Template)

Просмотреть файл

@ -13,6 +13,7 @@
#include "mozilla/dom/HTMLTextAreaElementBinding.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStates.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "mozilla/MouseEvents.h"
#include "nsAttrValueInlines.h"
#include "nsContentCID.h"
@ -37,7 +38,6 @@
#include "nsPresContext.h"
#include "nsPresState.h"
#include "nsReadableUtils.h"
#include "nsRuleData.h"
#include "nsStyleConsts.h"
#include "nsTextEditorState.h"
#include "nsIController.h"

Просмотреть файл

@ -10,6 +10,7 @@
#include "mozilla/EventListenerManager.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/EventStates.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/Likely.h"
@ -49,7 +50,6 @@
#include "nsNameSpaceManager.h"
#include "nsError.h"
#include "nsScriptLoader.h"
#include "nsRuleData.h"
#include "nsIPrincipal.h"
#include "nsContainerFrame.h"
#include "nsStyleUtil.h"
@ -1530,7 +1530,7 @@ nsGenericHTMLElement::MapBackgroundInto(const nsMappedAttributes* aAttributes,
nsAttrValue* value =
const_cast<nsAttrValue*>(aAttributes->GetAttr(nsGkAtoms::background));
if (value) {
nsRuleData* aRuleData = aData->AsRuleData();
nsRuleData* aRuleData = aData->AsGecko();
// Gecko-specific code
// Gecko caches the image on the attr directly, but we need not
// do the same thing for Servo.

Просмотреть файл

@ -654,7 +654,7 @@ public:
* @see GetAttributeMappingFunction
*/
static void MapCommonAttributesInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
/**
* Same as MapCommonAttributesInto except that it does not handle hidden.
*
@ -663,7 +663,7 @@ public:
* @see GetAttributeMappingFunction
*/
static void MapCommonAttributesIntoExceptHidden(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
static const MappedAttributeEntry sCommonAttributeMap[];
static const MappedAttributeEntry sImageMarginSizeAttributeMap[];
@ -681,7 +681,7 @@ public:
* @see GetAttributeMappingFunction
*/
static void MapImageAlignAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
/**
* Helper to map the align attribute into a style struct for things
@ -692,7 +692,7 @@ public:
* @see GetAttributeMappingFunction
*/
static void MapDivAlignAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
/**
* Helper to map the valign attribute into a style struct for things
@ -703,7 +703,7 @@ public:
* @see GetAttributeMappingFunction
*/
static void MapVAlignAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
/**
* Helper to map the image border attribute into a style struct.
@ -713,7 +713,7 @@ public:
* @see GetAttributeMappingFunction
*/
static void MapImageBorderAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
/**
* Helper to map the image margin attribute into a style struct.
*
@ -722,7 +722,7 @@ public:
* @see GetAttributeMappingFunction
*/
static void MapImageMarginAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
/**
* Helper to map the image position attribute into a style struct.
*
@ -731,7 +731,7 @@ public:
* @see GetAttributeMappingFunction
*/
static void MapImageSizeAttributesInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
/**
* Helper to map `width` attribute into a style struct.
@ -741,7 +741,7 @@ public:
* @see GetAttributeMappingFunction
*/
static void MapWidthAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
/**
* Helper to map `height` attribute into a style struct.
*
@ -750,7 +750,7 @@ public:
* @see GetAttributeMappingFunction
*/
static void MapHeightAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
/**
* Helper to map the background attribute
* into a style struct.
@ -760,7 +760,7 @@ public:
* @see GetAttributeMappingFunction
*/
static void MapBackgroundInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
/**
* Helper to map the bgcolor attribute
* into a style struct.
@ -770,7 +770,7 @@ public:
* @see GetAttributeMappingFunction
*/
static void MapBGColorInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
/**
* Helper to map the background attributes (currently background and bgcolor)
* into a style struct.
@ -780,7 +780,7 @@ public:
* @see GetAttributeMappingFunction
*/
static void MapBackgroundAttributesInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
/**
* Helper to map the scrolling attribute on FRAME and IFRAME
* into a style struct.
@ -790,7 +790,7 @@ public:
* @see GetAttributeMappingFunction
*/
static void MapScrollingAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
/**
* Get the presentation context for this content node.
* @return the presentation context

Просмотреть файл

@ -26,6 +26,7 @@
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStates.h"
#include "mozilla/GenericSpecifiedValuesInlines.h"
#include "mozilla/dom/ElementBinding.h"
using namespace mozilla;
@ -489,7 +490,7 @@ void
nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData)
{
nsRuleData* aData = aGenericData->AsRuleData();
nsRuleData* aData = aGenericData->AsGecko();
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
// scriptsizemultiplier
//

Просмотреть файл

@ -72,7 +72,7 @@ public:
nsIDocument* aDocument);
static void MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
mozilla::GenericSpecifiedValues* aGenericData);
virtual nsresult GetEventTargetParent(
mozilla::EventChainPreVisitor& aVisitor) override;

Просмотреть файл

@ -13,33 +13,45 @@
#ifndef mozilla_GenericSpecifiedValues_h
#define mozilla_GenericSpecifiedValues_h
#include "mozilla/ServoUtils.h"
#include "nsCSSProps.h"
#include "nsCSSValue.h"
#include "nsPresContext.h"
struct nsRuleData;
namespace mozilla {
// 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 {
protected:
explicit GenericSpecifiedValues(StyleBackendType aType, nsPresContext* aPresContext,
uint32_t aSIDs)
: mType(aType), mPresContext(aPresContext), mSIDs(aSIDs) {}
public:
MOZ_DECL_STYLO_METHODS(nsRuleData, nsRuleData)
// Check if we already contain a certain longhand
virtual bool PropertyIsSet(nsCSSPropertyID aId) = 0;
inline bool PropertyIsSet(nsCSSPropertyID aId);
// 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.
virtual bool ShouldComputeStyleStruct(uint64_t aInheritBits) = 0;
inline bool ShouldComputeStyleStruct(uint64_t aInheritBits) {
return aInheritBits & mSIDs;
}
virtual nsPresContext* PresContext() = 0;
inline nsPresContext* PresContext() {
return mPresContext;
}
// Set a property to an identifier (string)
virtual void SetIdentStringValue(nsCSSPropertyID aId, const nsString& aValue) = 0;
virtual void SetIdentStringValueIfUnset(nsCSSPropertyID aId, const nsString& aValue) = 0;
inline void SetIdentStringValue(nsCSSPropertyID aId, const nsString& aValue);
inline void SetIdentStringValueIfUnset(nsCSSPropertyID aId, const nsString& aValue);
// Set a property to a keyword (usually NS_STYLE_* or StyleFoo::*)
virtual void SetKeywordValue(nsCSSPropertyID aId, int32_t aValue) = 0;
virtual void SetKeywordValueIfUnset(nsCSSPropertyID aId, int32_t aValue) = 0;
inline void SetKeywordValue(nsCSSPropertyID aId, int32_t aValue);
inline void SetKeywordValueIfUnset(nsCSSPropertyID aId, int32_t aValue);
template<typename T,
typename = typename std::enable_if<std::is_enum<T>::value>::type>
@ -57,33 +69,37 @@ public:
}
// Set a property to an integer value
virtual void SetIntValue(nsCSSPropertyID aId, int32_t aValue) = 0;
inline void SetIntValue(nsCSSPropertyID aId, int32_t aValue);
// Set a property to a pixel value
virtual void SetPixelValue(nsCSSPropertyID aId, float aValue) = 0;
virtual void SetPixelValueIfUnset(nsCSSPropertyID aId, float aValue) = 0;
inline void SetPixelValue(nsCSSPropertyID aId, float aValue);
inline void SetPixelValueIfUnset(nsCSSPropertyID aId, float aValue);
// Set a property to a percent value
virtual void SetPercentValue(nsCSSPropertyID aId, float aValue) = 0;
virtual void SetPercentValueIfUnset(nsCSSPropertyID aId, float aValue) = 0;
inline void SetPercentValue(nsCSSPropertyID aId, float aValue);
inline void SetPercentValueIfUnset(nsCSSPropertyID aId, float aValue);
// Set a property to `auto`
virtual void SetAutoValue(nsCSSPropertyID aId) = 0;
virtual void SetAutoValueIfUnset(nsCSSPropertyID aId) = 0;
inline void SetAutoValue(nsCSSPropertyID aId);
inline void SetAutoValueIfUnset(nsCSSPropertyID aId);
// Set a property to `currentcolor`
virtual void SetCurrentColor(nsCSSPropertyID aId) = 0;
virtual void SetCurrentColorIfUnset(nsCSSPropertyID aId) = 0;
inline void SetCurrentColor(nsCSSPropertyID aId);
inline void SetCurrentColorIfUnset(nsCSSPropertyID aId);
// Set a property to an RGBA nscolor value
virtual void SetColorValue(nsCSSPropertyID aId, nscolor aValue) = 0;
virtual void SetColorValueIfUnset(nsCSSPropertyID aId, nscolor aValue) = 0;
inline void SetColorValue(nsCSSPropertyID aId, nscolor aValue);
inline void SetColorValueIfUnset(nsCSSPropertyID aId, nscolor aValue);
// Set font-family to a string
virtual void SetFontFamily(const nsString& aValue) = 0;
inline void SetFontFamily(const nsString& aValue);
// Add a quirks-mode override to the decoration color of elements nested in <a>
virtual void SetTextDecorationColorOverride() = 0;
inline void SetTextDecorationColorOverride();
virtual nsRuleData* AsRuleData() = 0;
const mozilla::StyleBackendType mType;
nsPresContext* const mPresContext;
const uint32_t mSIDs;
};
} // namespace mozilla
#endif // mozilla_GenericSpecifiedValues_h

Просмотреть файл

@ -0,0 +1,162 @@
/* -*- 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/. */
/*
* Inlined methods for GenericSpecifiedValues. Will just redirect to
* nsRuleData methods when compiled without stylo, but will do
* virtual dispatch (by checking which kind of container it is)
* in stylo mode.
*/
#ifndef mozilla_GenericSpecifiedValuesInlines_h
#define mozilla_GenericSpecifiedValuesInlines_h
#include "nsRuleData.h"
#include "mozilla/GenericSpecifiedValues.h"
namespace mozilla {
MOZ_DEFINE_STYLO_METHODS(GenericSpecifiedValues, nsRuleData, nsRuleData)
bool
GenericSpecifiedValues::PropertyIsSet(nsCSSPropertyID aId)
{
MOZ_STYLO_FORWARD(PropertyIsSet, (aId))
}
void
GenericSpecifiedValues::SetIdentStringValue(nsCSSPropertyID aId, const nsString& aValue)
{
MOZ_STYLO_FORWARD(SetIdentStringValue, (aId, aValue))
}
void
GenericSpecifiedValues::SetIdentStringValueIfUnset(nsCSSPropertyID aId, const nsString& aValue)
{
MOZ_STYLO_FORWARD(SetIdentStringValueIfUnset, (aId, aValue))
}
void
GenericSpecifiedValues::SetKeywordValue(nsCSSPropertyID aId, int32_t aValue)
{
// there are some static asserts in MOZ_STYLO_FORWARD which
// won't work with the overloaded SetKeywordValue function,
// so we copy its expansion and use SetIntValue for decltype
// instead
static_assert(!mozilla::IsSame<decltype(&MOZ_STYLO_THIS_TYPE::SetIntValue),
decltype(&MOZ_STYLO_GECKO_TYPE::SetKeywordValue)>
::value, "Gecko subclass should define its own SetKeywordValue");
static_assert(!mozilla::IsSame<decltype(&MOZ_STYLO_THIS_TYPE::SetIntValue),
decltype(&MOZ_STYLO_SERVO_TYPE::SetKeywordValue)>
::value, "Servo subclass should define its own SetKeywordValue");
if (IsServo()) {
return AsServo()->SetKeywordValue(aId, aValue);
}
return AsGecko()->SetKeywordValue(aId, aValue);
}
void
GenericSpecifiedValues::SetKeywordValueIfUnset(nsCSSPropertyID aId, int32_t aValue)
{
// there are some static asserts in MOZ_STYLO_FORWARD which
// won't work with the overloaded SetKeywordValue function,
// so we copy its expansion and use SetIntValue for decltype
// instead
static_assert(!mozilla::IsSame<decltype(&MOZ_STYLO_THIS_TYPE::SetIntValue),
decltype(&MOZ_STYLO_GECKO_TYPE::SetKeywordValueIfUnset)>
::value, "Gecko subclass should define its own SetKeywordValueIfUnset");
static_assert(!mozilla::IsSame<decltype(&MOZ_STYLO_THIS_TYPE::SetIntValue),
decltype(&MOZ_STYLO_SERVO_TYPE::SetKeywordValueIfUnset)>
::value, "Servo subclass should define its own SetKeywordValueIfUnset");
if (IsServo()) {
return AsServo()->SetKeywordValueIfUnset(aId, aValue);
}
return AsGecko()->SetKeywordValueIfUnset(aId, aValue);
}
void
GenericSpecifiedValues::SetIntValue(nsCSSPropertyID aId, int32_t aValue)
{
MOZ_STYLO_FORWARD(SetIntValue, (aId, aValue))
}
void
GenericSpecifiedValues::SetPixelValue(nsCSSPropertyID aId, float aValue)
{
MOZ_STYLO_FORWARD(SetPixelValue, (aId, aValue))
}
void
GenericSpecifiedValues::SetPixelValueIfUnset(nsCSSPropertyID aId, float aValue)
{
MOZ_STYLO_FORWARD(SetPixelValueIfUnset, (aId, aValue))
}
void
GenericSpecifiedValues::SetPercentValue(nsCSSPropertyID aId, float aValue)
{
MOZ_STYLO_FORWARD(SetPercentValue, (aId, aValue))
}
void
GenericSpecifiedValues::SetPercentValueIfUnset(nsCSSPropertyID aId, float aValue)
{
MOZ_STYLO_FORWARD(SetPercentValueIfUnset, (aId, aValue))
}
void
GenericSpecifiedValues::SetAutoValue(nsCSSPropertyID aId)
{
MOZ_STYLO_FORWARD(SetAutoValue, (aId))
}
void
GenericSpecifiedValues::SetAutoValueIfUnset(nsCSSPropertyID aId)
{
MOZ_STYLO_FORWARD(SetAutoValueIfUnset, (aId))
}
void
GenericSpecifiedValues::SetCurrentColor(nsCSSPropertyID aId)
{
MOZ_STYLO_FORWARD(SetCurrentColor, (aId))
}
void
GenericSpecifiedValues::SetCurrentColorIfUnset(nsCSSPropertyID aId)
{
MOZ_STYLO_FORWARD(SetCurrentColorIfUnset, (aId))
}
void
GenericSpecifiedValues::SetColorValue(nsCSSPropertyID aId, nscolor aValue)
{
MOZ_STYLO_FORWARD(SetColorValue, (aId, aValue))
}
void
GenericSpecifiedValues::SetColorValueIfUnset(nsCSSPropertyID aId, nscolor aValue)
{
MOZ_STYLO_FORWARD(SetColorValueIfUnset, (aId, aValue))
}
void
GenericSpecifiedValues::SetFontFamily(const nsString& aValue)
{
MOZ_STYLO_FORWARD(SetFontFamily, (aValue))
}
void
GenericSpecifiedValues::SetTextDecorationColorOverride()
{
MOZ_STYLO_FORWARD(SetTextDecorationColorOverride, ())
}
} // namespace mozilla
#endif // mozilla_GenericSpecifiedValuesInlines_h

Просмотреть файл

@ -87,6 +87,7 @@ EXPORTS.mozilla += [
'DeclarationBlockInlines.h',
'DocumentStyleRootIterator.h',
'GenericSpecifiedValues.h',
'GenericSpecifiedValuesInlines.h',
'HandleRefPtr.h',
'IncrementalClearCOMRuleArray.h',
'LayerAnimationInfo.h',

Просмотреть файл

@ -28,8 +28,7 @@ nsRuleData::GetPoisonOffset()
nsRuleData::nsRuleData(uint32_t aSIDs, nsCSSValue* aValueStorage,
nsPresContext* aContext, nsStyleContext* aStyleContext)
: mSIDs(aSIDs),
mPresContext(aContext),
: GenericSpecifiedValues(StyleBackendType::Gecko, aContext, aSIDs),
mStyleContext(aStyleContext),
mValueStorage(aValueStorage)
{

Просмотреть файл

@ -26,13 +26,11 @@ struct nsRuleData;
typedef void (*nsPostResolveFunc)(void* aStyleStruct, nsRuleData* aData);
struct nsRuleData final: GenericSpecifiedValues
struct nsRuleData final: mozilla::GenericSpecifiedValues
{
const uint32_t mSIDs;
mozilla::RuleNodeCacheConditions mConditions;
bool mIsImportantRule;
mozilla::SheetType mLevel;
nsPresContext* const mPresContext;
nsStyleContext* const mStyleContext;
// We store nsCSSValues needed to compute the data for one or more
@ -122,37 +120,29 @@ struct nsRuleData final: GenericSpecifiedValues
#undef CSS_PROP_PUBLIC_OR_PRIVATE
// GenericSpecifiedValues overrides
bool PropertyIsSet(nsCSSPropertyID aId) override {
bool PropertyIsSet(nsCSSPropertyID aId) {
return ValueFor(aId)->GetUnit() != eCSSUnit_Null;
}
bool ShouldComputeStyleStruct(uint64_t aInheritBits) override {
return mSIDs & aInheritBits;
}
nsPresContext* PresContext() override {
return mPresContext;
}
void SetIdentStringValue(nsCSSPropertyID aId,
const nsString& aValue) override {
const nsString& aValue) {
ValueFor(aId)->SetStringValue(aValue, eCSSUnit_Ident);
}
void SetIdentStringValueIfUnset(nsCSSPropertyID aId,
const nsString& aValue) override {
const nsString& aValue) {
if (!PropertyIsSet(aId)) {
SetIdentStringValue(aId, aValue);
}
}
void SetKeywordValue(nsCSSPropertyID aId,
int32_t aValue) override {
int32_t aValue) {
ValueFor(aId)->SetIntValue(aValue, eCSSUnit_Enumerated);
}
void SetKeywordValueIfUnset(nsCSSPropertyID aId,
int32_t aValue) override {
int32_t aValue) {
if (!PropertyIsSet(aId)) {
SetKeywordValue(aId, aValue);
}
@ -160,70 +150,70 @@ struct nsRuleData final: GenericSpecifiedValues
void SetIntValue(nsCSSPropertyID aId,
int32_t aValue) override {
int32_t aValue) {
ValueFor(aId)->SetIntValue(aValue, eCSSUnit_Integer);
}
void SetPixelValue(nsCSSPropertyID aId,
float aValue) override {
float aValue) {
ValueFor(aId)->SetFloatValue(aValue, eCSSUnit_Pixel);
}
void SetPixelValueIfUnset(nsCSSPropertyID aId,
float aValue) override {
float aValue) {
if (!PropertyIsSet(aId)) {
SetPixelValue(aId, aValue);
}
}
void SetPercentValue(nsCSSPropertyID aId,
float aValue) override {
float aValue) {
ValueFor(aId)->SetPercentValue(aValue);
}
void SetAutoValue(nsCSSPropertyID aId) override {
void SetAutoValue(nsCSSPropertyID aId) {
ValueFor(aId)->SetAutoValue();
}
void SetAutoValueIfUnset(nsCSSPropertyID aId) override {
void SetAutoValueIfUnset(nsCSSPropertyID aId) {
if (!PropertyIsSet(aId)) {
SetAutoValue(aId);
}
}
void SetPercentValueIfUnset(nsCSSPropertyID aId,
float aValue) override {
float aValue) {
if (!PropertyIsSet(aId)) {
SetPercentValue(aId, aValue);
}
}
void SetCurrentColor(nsCSSPropertyID aId) override {
void SetCurrentColor(nsCSSPropertyID aId) {
ValueFor(aId)->SetIntValue(NS_COLOR_CURRENTCOLOR, eCSSUnit_EnumColor);
}
void SetCurrentColorIfUnset(nsCSSPropertyID aId) override {
void SetCurrentColorIfUnset(nsCSSPropertyID aId) {
if (!PropertyIsSet(aId)) {
SetCurrentColor(aId);
}
}
void SetColorValue(nsCSSPropertyID aId,
nscolor aValue) override {
nscolor aValue) {
ValueFor(aId)->SetColorValue(aValue);
}
void SetColorValueIfUnset(nsCSSPropertyID aId,
nscolor aValue) override {
nscolor aValue) {
if (!PropertyIsSet(aId)) {
SetColorValue(aId, aValue);
}
}
void SetFontFamily(const nsString& aValue) override;
void SetTextDecorationColorOverride() override;
void SetFontFamily(const nsString& aValue);
void SetTextDecorationColorOverride();
nsRuleData* AsRuleData() override {
nsRuleData* AsRuleData() {
return this;
}