Backed out changeset 7943ca5e483a (bug 1338936) for Windows build bustage. r=backout on a CLOSED TREE

This commit is contained in:
Sebastian Hengst 2017-02-19 10:38:09 +01:00
parent a64b195d9b
commit 7cf1fe31f8
9 changed files with 105 additions and 155 deletions

View File

@ -17,7 +17,6 @@
#include "mozilla/HashFunctions.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/ServoDeclarationBlock.h"
#include "mozilla/ServoSpecifiedValues.h"
using namespace mozilla;
@ -290,14 +289,19 @@ nsMappedAttributes::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
}
void
nsMappedAttributes::LazilyResolveServoDeclaration(nsPresContext* aContext)
nsMappedAttributes::LazilyResolveServoDeclaration(nsRuleData* aRuleData,
nsCSSPropertyID* aIndexToIdMapping,
size_t aRuleDataSize)
{
MapRuleInfoInto(aRuleData);
MOZ_ASSERT(!mServoStyle,
"LazilyResolveServoDeclaration should not be called if mServoStyle is already set");
if (mRuleMapper) {
mServoStyle = Servo_DeclarationBlock_CreateEmpty().Consume();
ServoSpecifiedValues servo = ServoSpecifiedValues(aContext, mServoStyle.get());
(*mRuleMapper)(this, &servo);
mServoStyle = Servo_DeclarationBlock_CreateEmpty().Consume();
for (size_t i = 0; i < aRuleDataSize; i++) {
nsCSSValue& val = aRuleData->mValueStorage[i];
if (val.GetUnit() != eCSSUnit_Null) {
Servo_DeclarationBlock_AddPresValue(mServoStyle.get(), aIndexToIdMapping[i], &val);
}
}
}

View File

@ -72,9 +72,16 @@ public:
const nsAttrName* GetExistingAttrNameFromQName(const nsAString& aName) const;
int32_t IndexOfAttr(nsIAtom* aLocalName) const;
// Apply the contained mapper to the contained set of servo rules,
// unless the servo rules have already been initialized.
void LazilyResolveServoDeclaration(nsPresContext* aPresContext);
// Apply the contained mapper to an empty nsRuleData object
// that is able to contain all properties. Set contained servo declaration block
// to result of this computation.
// aIndexToIdMapping is
// a table that maps from an index in the rule data to the corresponding
// property ID. aRuleDataSize is the length of the backing storage
// of the rule data.
void LazilyResolveServoDeclaration(nsRuleData* aRuleData,
nsCSSPropertyID* aIndexToIdMapping,
size_t aRuleDataSize);
// Obtain the contained servo declaration block
// May return null if called before the inner block

View File

@ -19,11 +19,7 @@
#include "nsPresContext.h"
struct nsRuleData;
namespace mozilla {
class ServoSpecifiedValues;
// 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.
@ -34,7 +30,7 @@ protected:
: mType(aType), mPresContext(aPresContext), mSIDs(aSIDs) {}
public:
MOZ_DECL_STYLO_METHODS(nsRuleData, ServoSpecifiedValues)
MOZ_DECL_STYLO_METHODS(nsRuleData, nsRuleData)
// Check if we already contain a certain longhand
inline bool PropertyIsSet(nsCSSPropertyID aId);

View File

@ -16,11 +16,10 @@
#include "nsRuleData.h"
#include "mozilla/GenericSpecifiedValues.h"
#include "mozilla/ServoSpecifiedValues.h"
namespace mozilla {
MOZ_DEFINE_STYLO_METHODS(GenericSpecifiedValues, nsRuleData, ServoSpecifiedValues)
MOZ_DEFINE_STYLO_METHODS(GenericSpecifiedValues, nsRuleData, nsRuleData)
bool
GenericSpecifiedValues::PropertyIsSet(nsCSSPropertyID aId)

View File

@ -1,26 +0,0 @@
/* -*- 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/ServoSpecifiedValues.h"
namespace {
#define STYLE_STRUCT(name, checkdata_cb) | NS_STYLE_INHERIT_BIT(name)
const uint64_t ALL_SIDS = 0
#include "nsStyleStructList.h"
;
#undef STYLE_STRUCT
} // anonymous namespace
ServoSpecifiedValues::ServoSpecifiedValues(nsPresContext* aContext,
RawServoDeclarationBlock* aDecl)
: GenericSpecifiedValues(StyleBackendType::Servo, aContext, ALL_SIDS)
, mDecl(aDecl)
{
}

View File

@ -1,109 +0,0 @@
/* -*- 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/. */
/*
* Servo-backed specified value store, to be used when mapping presentation
* attributes
*/
#ifndef mozilla_ServoSpecifiedValues_h
#define mozilla_ServoSpecifiedValues_h
#include "mozilla/GenericSpecifiedValues.h"
#include "mozilla/ServoBindings.h"
namespace mozilla {
class ServoSpecifiedValues final: public GenericSpecifiedValues
{
public:
ServoSpecifiedValues(nsPresContext* aContext, RawServoDeclarationBlock* aDecl);
// GenericSpecifiedValues overrides
bool PropertyIsSet(nsCSSPropertyID aId) {
return false;
}
void SetIdentStringValue(nsCSSPropertyID aId,
const nsString& aValue) {
}
void SetIdentStringValueIfUnset(nsCSSPropertyID aId,
const nsString& aValue) {
}
void SetKeywordValue(nsCSSPropertyID aId,
int32_t aValue) {
}
void SetKeywordValueIfUnset(nsCSSPropertyID aId,
int32_t aValue) {
}
void SetIntValue(nsCSSPropertyID aId,
int32_t aValue) {
}
void SetPixelValue(nsCSSPropertyID aId,
float aValue) {
}
void SetPixelValueIfUnset(nsCSSPropertyID aId,
float aValue) {
}
void SetPercentValue(nsCSSPropertyID aId,
float aValue) {
}
void SetAutoValue(nsCSSPropertyID aId) {
}
void SetAutoValueIfUnset(nsCSSPropertyID aId) {
}
void SetPercentValueIfUnset(nsCSSPropertyID aId,
float aValue) {
}
void SetCurrentColor(nsCSSPropertyID aId) {
}
void SetCurrentColorIfUnset(nsCSSPropertyID aId) {
}
void SetColorValue(nsCSSPropertyID aId,
nscolor aValue) {
}
void SetColorValueIfUnset(nsCSSPropertyID aId,
nscolor aValue) {
}
void SetFontFamily(const nsString& aValue) {
}
void SetTextDecorationColorOverride() {
}
private:
RefPtr<RawServoDeclarationBlock> mDecl;
};
} // namespace mozilla
#endif // mozilla_ServoSpecifiedValues_h

View File

@ -102,7 +102,6 @@ EXPORTS.mozilla += [
'ServoDeclarationBlock.h',
'ServoElementSnapshot.h',
'ServoPropPrefList.h',
'ServoSpecifiedValues.h',
'ServoStyleRule.h',
'ServoStyleSet.h',
'ServoStyleSheet.h',
@ -208,7 +207,6 @@ UNIFIED_SOURCES += [
'ServoCSSRuleList.cpp',
'ServoDeclarationBlock.cpp',
'ServoElementSnapshot.cpp',
'ServoSpecifiedValues.cpp',
'ServoStyleRule.cpp',
'ServoStyleSet.cpp',
'ServoStyleSheet.cpp',

View File

@ -554,17 +554,94 @@ nsHTMLStyleSheet::DropMappedAttributes(nsMappedAttributes* aMapped)
NS_ASSERTION(entryCount == mMappedAttrTable.EntryCount(), "not removed");
}
namespace {
// Struct containing once-initialized information about
// our synthesized rule data
struct StaticRuleDataInfo
{
// the bitmask used.
uint64_t mMask;
// the number of properties contained
size_t mPropCount;
// offset of given style struct in array
size_t mOffsets[nsStyleStructID_Length];
// location of property in given array
nsCSSPropertyID* mIndexToPropertyMapping;
};
}
static void
CalculateIndexArray(StaticRuleDataInfo* aInfo)
{
// this will leak at shutdown, but it's not much and this code is temporary
// anyway.
aInfo->mIndexToPropertyMapping = new nsCSSPropertyID[aInfo->mPropCount];
size_t structOffset;
size_t propertyIndex;
#define CSS_PROP_LIST_EXCLUDE_LOGICAL
#define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
structOffset = aInfo->mOffsets[eStyleStruct_##stylestruct_]; \
propertyIndex = nsCSSProps::PropertyIndexInStruct(eCSSProperty_##id_); \
aInfo->mIndexToPropertyMapping[structOffset + propertyIndex] = eCSSProperty_##id_;
#include "nsCSSPropList.h"
#undef CSS_PROP
#undef CSS_PROP_LIST_EXCLUDE_LOGICAL
}
static StaticRuleDataInfo
CalculateRuleDataInfo()
{
StaticRuleDataInfo sizes;
sizes.mMask = 0;
sizes.mPropCount = 0;
#define STYLE_STRUCT(name, checkdata_cb) \
sizes.mMask |= NS_STYLE_INHERIT_BIT(name); \
sizes.mOffsets[eStyleStruct_##name] = sizes.mPropCount; \
sizes.mPropCount += nsCSSProps::PropertyCountInStruct(eStyleStruct_##name);
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
CalculateIndexArray(&sizes);
return sizes;
}
void
nsHTMLStyleSheet::CalculateMappedServoDeclarations()
{
nsPresContext* presContext = mDocument->GetShell()->GetPresContext();
// avoid recalculating or reallocating
static StaticRuleDataInfo sizes = CalculateRuleDataInfo();
if (!mMappedAttrsDirty) {
return;
}
mMappedAttrsDirty = false;
void* dataStorage = alloca(sizes.mPropCount * sizeof(nsCSSValue));
for (auto iter = mMappedAttrTable.Iter(); !iter.Done(); iter.Next()) {
MappedAttrTableEntry* attr = static_cast<MappedAttrTableEntry*>(iter.Get());
if (attr->mAttributes->GetServoStyle()) {
// Only handle cases which haven't been filled in already
continue;
}
attr->mAttributes->LazilyResolveServoDeclaration(presContext);
// Construction cleans up any values we may have set
AutoCSSValueArray dataArray(dataStorage, sizes.mPropCount);
// synthesized ruleData
// we pass null for the style context because the code we call into
// doesn't deal with the style context. This is temporary.
nsRuleData ruleData(sizes.mMask, dataArray.get(),
mDocument->GetShell()->GetPresContext(), nullptr);
// Copy the offsets; ruleData won't know where to find properties otherwise
mozilla::PodCopy(ruleData.mValueOffsets,
sizes.mOffsets,
nsStyleStructID_Length);
attr->mAttributes->LazilyResolveServoDeclaration(&ruleData,
sizes.mIndexToPropertyMapping,
sizes.mPropCount);
}
}

View File

@ -213,6 +213,10 @@ struct nsRuleData final: mozilla::GenericSpecifiedValues
void SetFontFamily(const nsString& aValue);
void SetTextDecorationColorOverride();
nsRuleData* AsRuleData() {
return this;
}
private:
inline size_t GetPoisonOffset();