mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1274835 - Refactor code to process basic shape from clip-path. r=heycam
This can be used in the implementation of shape-outside. MozReview-Commit-ID: C7bd4D2Kwpm --HG-- extra : rebase_source : fefdd869b1ede3c518e496d8b25ffa5953a7145d
This commit is contained in:
parent
3afaab9b67
commit
d06693b2f0
@ -5887,11 +5887,11 @@ nsComputedDOMStyle::BasicShapeRadiiToString(nsAString& aCssText,
|
|||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<CSSValue>
|
already_AddRefed<CSSValue>
|
||||||
nsComputedDOMStyle::CreatePrimitiveValueForClipPath(
|
nsComputedDOMStyle::CreatePrimitiveValueForBasicShape(
|
||||||
const nsStyleBasicShape* aStyleBasicShape, uint8_t aSizingBox)
|
const nsStyleBasicShape* aStyleBasicShape)
|
||||||
{
|
{
|
||||||
RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(false);
|
MOZ_ASSERT(aStyleBasicShape, "Expect a valid basic shape pointer!");
|
||||||
if (aStyleBasicShape) {
|
|
||||||
nsStyleBasicShape::Type type = aStyleBasicShape->GetShapeType();
|
nsStyleBasicShape::Type type = aStyleBasicShape->GetShapeType();
|
||||||
// Shape function name and opening parenthesis.
|
// Shape function name and opening parenthesis.
|
||||||
nsAutoString shapeFunctionString;
|
nsAutoString shapeFunctionString;
|
||||||
@ -5963,7 +5963,17 @@ nsComputedDOMStyle::CreatePrimitiveValueForClipPath(
|
|||||||
shapeFunctionString.Append(')');
|
shapeFunctionString.Append(')');
|
||||||
RefPtr<nsROCSSPrimitiveValue> functionValue = new nsROCSSPrimitiveValue;
|
RefPtr<nsROCSSPrimitiveValue> functionValue = new nsROCSSPrimitiveValue;
|
||||||
functionValue->SetString(shapeFunctionString);
|
functionValue->SetString(shapeFunctionString);
|
||||||
valueList->AppendCSSValue(functionValue.forget());
|
return functionValue.forget();
|
||||||
|
}
|
||||||
|
|
||||||
|
already_AddRefed<CSSValue>
|
||||||
|
nsComputedDOMStyle::CreatePrimitiveValueForClipPath(
|
||||||
|
const nsStyleBasicShape* aStyleBasicShape, uint8_t aSizingBox)
|
||||||
|
{
|
||||||
|
RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(false);
|
||||||
|
if (aStyleBasicShape) {
|
||||||
|
valueList->AppendCSSValue(
|
||||||
|
CreatePrimitiveValueForBasicShape(aStyleBasicShape));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aSizingBox == NS_STYLE_CLIP_SHAPE_SIZING_NOBOX) {
|
if (aSizingBox == NS_STYLE_CLIP_SHAPE_SIZING_NOBOX) {
|
||||||
|
@ -643,9 +643,12 @@ private:
|
|||||||
already_AddRefed<CSSValue> CreatePrimitiveValueForStyleFilter(
|
already_AddRefed<CSSValue> CreatePrimitiveValueForStyleFilter(
|
||||||
const nsStyleFilter& aStyleFilter);
|
const nsStyleFilter& aStyleFilter);
|
||||||
|
|
||||||
// Helper function for computing basic shape styles.
|
|
||||||
already_AddRefed<CSSValue> CreatePrimitiveValueForClipPath(
|
already_AddRefed<CSSValue> CreatePrimitiveValueForClipPath(
|
||||||
const nsStyleBasicShape* aStyleBasicShape, uint8_t aSizingBox);
|
const nsStyleBasicShape* aStyleBasicShape, uint8_t aSizingBox);
|
||||||
|
|
||||||
|
// Helper function for computing basic shape styles.
|
||||||
|
already_AddRefed<CSSValue> CreatePrimitiveValueForBasicShape(
|
||||||
|
const nsStyleBasicShape* aStyleBasicShape);
|
||||||
void BoxValuesToString(nsAString& aString,
|
void BoxValuesToString(nsAString& aString,
|
||||||
const nsTArray<nsStyleCoord>& aBoxValues);
|
const nsTArray<nsStyleCoord>& aBoxValues);
|
||||||
void BasicShapeRadiiToString(nsAString& aCssText,
|
void BasicShapeRadiiToString(nsAString& aCssText,
|
||||||
|
@ -9522,35 +9522,18 @@ nsRuleNode::ComputeSVGData(void* aStartStruct,
|
|||||||
COMPUTE_END_INHERITED(SVG, svg)
|
COMPUTE_END_INHERITED(SVG, svg)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
already_AddRefed<nsStyleBasicShape>
|
||||||
nsRuleNode::SetStyleClipPathToCSSValue(nsStyleClipPath* aStyleClipPath,
|
nsRuleNode::GetStyleBasicShapeFromCSSValue(const nsCSSValue& aValue,
|
||||||
const nsCSSValue* aValue,
|
|
||||||
nsStyleContext* aStyleContext,
|
nsStyleContext* aStyleContext,
|
||||||
nsPresContext* aPresContext,
|
nsPresContext* aPresContext,
|
||||||
RuleNodeCacheConditions& aConditions)
|
RuleNodeCacheConditions& aConditions)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aValue->GetUnit() == eCSSUnit_Array,
|
|
||||||
"expected a basic shape or reference box");
|
|
||||||
|
|
||||||
const nsCSSValue::Array* array = aValue->GetArrayValue();
|
|
||||||
MOZ_ASSERT(array->Count() == 1 || array->Count() == 2,
|
|
||||||
"Expect one or both of a shape function and geometry-box");
|
|
||||||
|
|
||||||
uint8_t sizingBox = NS_STYLE_CLIP_SHAPE_SIZING_NOBOX;
|
|
||||||
RefPtr<nsStyleBasicShape> basicShape;
|
RefPtr<nsStyleBasicShape> basicShape;
|
||||||
for (size_t i = 0; i < array->Count(); ++i) {
|
|
||||||
if (array->Item(i).GetUnit() == eCSSUnit_Enumerated) {
|
nsCSSValue::Array* shapeFunction = aValue.GetArrayValue();
|
||||||
int32_t type = array->Item(i).GetIntValue();
|
|
||||||
if (type > NS_STYLE_CLIP_SHAPE_SIZING_VIEW ||
|
|
||||||
type < NS_STYLE_CLIP_SHAPE_SIZING_NOBOX) {
|
|
||||||
NS_NOTREACHED("unexpected reference box");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sizingBox = (uint8_t)type;
|
|
||||||
} else if (array->Item(i).GetUnit() == eCSSUnit_Function) {
|
|
||||||
nsCSSValue::Array* shapeFunction = array->Item(i).GetArrayValue();
|
|
||||||
nsCSSKeyword functionName =
|
nsCSSKeyword functionName =
|
||||||
(nsCSSKeyword)shapeFunction->Item(0).GetIntValue();
|
(nsCSSKeyword)shapeFunction->Item(0).GetIntValue();
|
||||||
|
|
||||||
if (functionName == eCSSKeyword_polygon) {
|
if (functionName == eCSSKeyword_polygon) {
|
||||||
MOZ_ASSERT(!basicShape, "did not expect value");
|
MOZ_ASSERT(!basicShape, "did not expect value");
|
||||||
basicShape = new nsStyleBasicShape(nsStyleBasicShape::ePolygon);
|
basicShape = new nsStyleBasicShape(nsStyleBasicShape::ePolygon);
|
||||||
@ -9683,8 +9666,39 @@ nsRuleNode::SetStyleClipPathToCSSValue(nsStyleClipPath* aStyleClipPath,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NS_NOTREACHED("unexpected basic shape function");
|
NS_NOTREACHED("unexpected basic shape function");
|
||||||
|
}
|
||||||
|
|
||||||
|
return basicShape.forget();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsRuleNode::SetStyleClipPathToCSSValue(nsStyleClipPath* aStyleClipPath,
|
||||||
|
const nsCSSValue* aValue,
|
||||||
|
nsStyleContext* aStyleContext,
|
||||||
|
nsPresContext* aPresContext,
|
||||||
|
RuleNodeCacheConditions& aConditions)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(aValue->GetUnit() == eCSSUnit_Array,
|
||||||
|
"expected a basic shape or reference box");
|
||||||
|
|
||||||
|
const nsCSSValue::Array* array = aValue->GetArrayValue();
|
||||||
|
MOZ_ASSERT(array->Count() == 1 || array->Count() == 2,
|
||||||
|
"Expect one or both of a shape function and geometry-box");
|
||||||
|
|
||||||
|
uint8_t sizingBox = NS_STYLE_CLIP_SHAPE_SIZING_NOBOX;
|
||||||
|
RefPtr<nsStyleBasicShape> basicShape;
|
||||||
|
for (size_t i = 0; i < array->Count(); ++i) {
|
||||||
|
if (array->Item(i).GetUnit() == eCSSUnit_Enumerated) {
|
||||||
|
int32_t type = array->Item(i).GetIntValue();
|
||||||
|
if (type > NS_STYLE_CLIP_SHAPE_SIZING_VIEW ||
|
||||||
|
type < NS_STYLE_CLIP_SHAPE_SIZING_NOBOX) {
|
||||||
|
NS_NOTREACHED("unexpected reference box");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
sizingBox = (uint8_t)type;
|
||||||
|
} else if (array->Item(i).GetUnit() == eCSSUnit_Function) {
|
||||||
|
basicShape = GetStyleBasicShapeFromCSSValue(array->Item(i), aStyleContext,
|
||||||
|
aPresContext, aConditions);
|
||||||
} else {
|
} else {
|
||||||
NS_NOTREACHED("unexpected value");
|
NS_NOTREACHED("unexpected value");
|
||||||
return;
|
return;
|
||||||
|
@ -788,6 +788,11 @@ protected:
|
|||||||
nsStyleContext* aContext,
|
nsStyleContext* aContext,
|
||||||
bool aIsBoxShadow,
|
bool aIsBoxShadow,
|
||||||
mozilla::RuleNodeCacheConditions& aConditions);
|
mozilla::RuleNodeCacheConditions& aConditions);
|
||||||
|
already_AddRefed<nsStyleBasicShape>
|
||||||
|
GetStyleBasicShapeFromCSSValue(const nsCSSValue& aValue,
|
||||||
|
nsStyleContext* aStyleContext,
|
||||||
|
nsPresContext* aPresContext,
|
||||||
|
mozilla::RuleNodeCacheConditions& aConditions);
|
||||||
bool SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter,
|
bool SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter,
|
||||||
const nsCSSValue& aValue,
|
const nsCSSValue& aValue,
|
||||||
nsStyleContext* aStyleContext,
|
nsStyleContext* aStyleContext,
|
||||||
|
Loading…
Reference in New Issue
Block a user