зеркало из https://github.com/mozilla/gecko-dev.git
Bug 649142 - Part 2: Convert logical properties to their physical equivalents during the cascade. r=dbaron
We will add cases to EnsurePhysicalProperty's switch statement as we convert the existing shorthand-implemented logical properties to the new, CSS_PROPERTY_LOGICAL-bearing properties.
This commit is contained in:
Родитель
6cceecc24a
Коммит
8c1da42424
|
@ -163,6 +163,25 @@ MapSinglePropertyInto(nsCSSProperty aProp,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If aProperty is a logical property, converts it to the equivalent physical
|
||||
* property based on writing mode information obtained from aRuleData's
|
||||
* style context. Returns true if aProperty was changed.
|
||||
*/
|
||||
static inline void
|
||||
EnsurePhysicalProperty(nsCSSProperty& aProperty, nsRuleData* aRuleData)
|
||||
{
|
||||
uint8_t direction = aRuleData->mStyleContext->StyleVisibility()->mDirection;
|
||||
bool ltr = direction == NS_STYLE_DIRECTION_LTR;
|
||||
|
||||
switch (aProperty) {
|
||||
default:
|
||||
NS_ABORT_IF_FALSE(nsCSSProps::PropHasFlags(aProperty,
|
||||
CSS_PROPERTY_LOGICAL),
|
||||
"unhandled logical property");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
|
||||
{
|
||||
|
@ -173,10 +192,20 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
|
|||
if (!(aRuleData->mSIDs & mStyleBits))
|
||||
return;
|
||||
|
||||
for (uint32_t i = 0; i < mNumProps; i++) {
|
||||
// We process these in reverse order so that we end up mapping the
|
||||
// right property when one can be expressed using both logical and
|
||||
// physical property names.
|
||||
for (uint32_t i = mNumProps; i-- > 0; ) {
|
||||
nsCSSProperty iProp = PropertyAtIndex(i);
|
||||
if (nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[iProp]) &
|
||||
aRuleData->mSIDs) {
|
||||
if (nsCSSProps::PropHasFlags(iProp, CSS_PROPERTY_LOGICAL)) {
|
||||
EnsurePhysicalProperty(iProp, aRuleData);
|
||||
// We can't cache anything on the rule tree if we use any data from
|
||||
// the style context, since data cached in the rule tree could be
|
||||
// used with a style context with a different value.
|
||||
aRuleData->mCanStoreInRuleTree = false;
|
||||
}
|
||||
nsCSSValue* target = aRuleData->ValueFor(iProp);
|
||||
if (target->GetUnit() == eCSSUnit_Null) {
|
||||
const nsCSSValue *val = ValueAtIndex(i);
|
||||
|
@ -605,11 +634,17 @@ nsCSSExpandedDataBlock::MapRuleInfoInto(nsCSSProperty aPropID,
|
|||
const nsCSSValue* src = PropertyAt(aPropID);
|
||||
MOZ_ASSERT(src->GetUnit() != eCSSUnit_Null);
|
||||
|
||||
nsCSSValue* dest = aRuleData->ValueFor(aPropID);
|
||||
nsCSSProperty physicalProp = aPropID;
|
||||
if (nsCSSProps::PropHasFlags(aPropID, CSS_PROPERTY_LOGICAL)) {
|
||||
EnsurePhysicalProperty(physicalProp, aRuleData);
|
||||
aRuleData->mCanStoreInRuleTree = false;
|
||||
}
|
||||
|
||||
nsCSSValue* dest = aRuleData->ValueFor(physicalProp);
|
||||
MOZ_ASSERT(dest->GetUnit() == eCSSUnit_TokenStream &&
|
||||
dest->GetTokenStreamValue()->mPropertyID == aPropID);
|
||||
|
||||
MapSinglePropertyInto(aPropID, src, dest, aRuleData);
|
||||
MapSinglePropertyInto(physicalProp, src, dest, aRuleData);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
Загрузка…
Ссылка в новой задаче