void StyleBuilderFunctions::applyValueCSSPropertyTextAlign(StyleResolverState& state, CSSValue* value) { CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); if (primitiveValue->isValueID() && primitiveValue->getValueID() != CSSValueWebkitMatchParent) state.style()->setTextAlign(*primitiveValue); else if (state.parentStyle()->textAlign() == TASTART) state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT); else if (state.parentStyle()->textAlign() == TAEND) state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection() ? RIGHT : LEFT); else state.style()->setTextAlign(state.parentStyle()->textAlign()); }
FontWeight StyleBuilderConverter::convertFontWeight(StyleResolverState& state, CSSValue* value) { CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); switch (primitiveValue->getValueID()) { case CSSValueBolder: return FontDescription::bolderWeight(state.parentStyle()->fontDescription().weight()); case CSSValueLighter: return FontDescription::lighterWeight(state.parentStyle()->fontDescription().weight()); default: return *primitiveValue; } }
float ViewportStyleResolver::viewportArgumentValue(CSSPropertyID id) const { float defaultValue = ViewportDescription::ValueAuto; // UserZoom default value is CSSValueZoom, which maps to true, meaning that // yes, it is user scalable. When the value is set to CSSValueFixed, we // return false. if (id == CSSPropertyUserZoom) defaultValue = 1; CSSValue* value = m_propertySet->getPropertyCSSValue(id); if (!value || !value->isPrimitiveValue()) return defaultValue; CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); if (primitiveValue->isNumber() || primitiveValue->isPx()) return primitiveValue->getFloatValue(); if (primitiveValue->isFontRelativeLength()) return primitiveValue->getFloatValue() * m_document->computedStyle()->getFontDescription().computedSize(); if (primitiveValue->isPercentage()) { float percentValue = primitiveValue->getFloatValue() / 100.0f; switch (id) { case CSSPropertyMaxZoom: case CSSPropertyMinZoom: case CSSPropertyZoom: return percentValue; default: ASSERT_NOT_REACHED(); break; } } switch (primitiveValue->getValueID()) { case CSSValueAuto: return defaultValue; case CSSValueLandscape: return ViewportDescription::ValueLandscape; case CSSValuePortrait: return ViewportDescription::ValuePortrait; case CSSValueZoom: return defaultValue; case CSSValueInternalExtendToZoom: return ViewportDescription::ValueExtendToZoom; case CSSValueFixed: return 0; default: return defaultValue; } }
void FontBuilder::setFontVariantLigaturesValue(CSSValue* value) { FontDescriptionChangeScope scope(this); FontDescription::LigaturesState commonLigaturesState = FontDescription::NormalLigaturesState; FontDescription::LigaturesState discretionaryLigaturesState = FontDescription::NormalLigaturesState; FontDescription::LigaturesState historicalLigaturesState = FontDescription::NormalLigaturesState; if (value->isValueList()) { CSSValueList* valueList = toCSSValueList(value); for (size_t i = 0; i < valueList->length(); ++i) { CSSValue* item = valueList->itemWithoutBoundsCheck(i); ASSERT(item->isPrimitiveValue()); if (item->isPrimitiveValue()) { CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(item); switch (primitiveValue->getValueID()) { case CSSValueNoCommonLigatures: commonLigaturesState = FontDescription::DisabledLigaturesState; break; case CSSValueCommonLigatures: commonLigaturesState = FontDescription::EnabledLigaturesState; break; case CSSValueNoDiscretionaryLigatures: discretionaryLigaturesState = FontDescription::DisabledLigaturesState; break; case CSSValueDiscretionaryLigatures: discretionaryLigaturesState = FontDescription::EnabledLigaturesState; break; case CSSValueNoHistoricalLigatures: historicalLigaturesState = FontDescription::DisabledLigaturesState; break; case CSSValueHistoricalLigatures: historicalLigaturesState = FontDescription::EnabledLigaturesState; break; default: ASSERT_NOT_REACHED(); break; } } } } #if !ASSERT_DISABLED else { ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue()); ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNormal); } #endif scope.fontDescription().setCommonLigaturesState(commonLigaturesState); scope.fontDescription().setDiscretionaryLigaturesState(discretionaryLigaturesState); scope.fontDescription().setHistoricalLigaturesState(historicalLigaturesState); }
void StyleBuilderFunctions::applyValueCSSPropertyTextIndent(StyleResolverState& state, CSSValue* value) { Length lengthOrPercentageValue; TextIndentLine textIndentLineValue = ComputedStyle::initialTextIndentLine(); TextIndentType textIndentTypeValue = ComputedStyle::initialTextIndentType(); for (auto& listValue : toCSSValueList(*value)) { CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(listValue.get()); if (!primitiveValue->getValueID()) lengthOrPercentageValue = primitiveValue->convertToLength(state.cssToLengthConversionData()); else if (primitiveValue->getValueID() == CSSValueEachLine) textIndentLineValue = TextIndentEachLine; else if (primitiveValue->getValueID() == CSSValueHanging) textIndentTypeValue = TextIndentHanging; else ASSERT_NOT_REACHED(); } state.style()->setTextIndent(lengthOrPercentageValue); state.style()->setTextIndentLine(textIndentLineValue); state.style()->setTextIndentType(textIndentTypeValue); }
void StyleBuilderFunctions::applyValueCSSPropertyResize(StyleResolverState& state, CSSValue* value) { CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); EResize r = RESIZE_NONE; if (primitiveValue->getValueID() == CSSValueAuto) { if (Settings* settings = state.document().settings()) r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE; } else { r = *primitiveValue; } state.style()->setResize(r); }
void CSSToStyleMap::mapAnimationPlayState(CSSAnimationData* layer, CSSValue* value) const { if (value->isInitialValue()) { layer->setPlayState(CSSAnimationData::initialAnimationPlayState()); return; } if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); EAnimPlayState playState = (primitiveValue->getValueID() == CSSValuePaused) ? AnimPlayStatePaused : AnimPlayStatePlaying; layer->setPlayState(playState); }
void StyleBuilderFunctions::applyValueCSSPropertyVerticalAlign(StyleResolverState& state, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); if (primitiveValue->getValueID()) { state.style()->setVerticalAlign(*primitiveValue); return; } state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedConversion | PercentConversion>(state.cssToLengthConversionData())); }
void CSSToStyleMap::mapAnimationPlayState(Animation* layer, CSSValue* value) { if (value->isInitialValue()) { layer->setPlayState(Animation::initialAnimationPlayState()); return; } if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); EAnimPlayState playState = (primitiveValue->getValueID() == CSSValuePaused) ? AnimPlayStatePaused : AnimPlayStatePlaying; layer->setPlayState(playState); }
bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const CSSPrimitiveValue& primitiveValue) { // FIXME: consider other types. if (primitiveValue.isNumber() || primitiveValue.isPercentage() || primitiveValue.isAngle() || primitiveValue.isRGBColor() || primitiveValue.isURI()) return false; if (primitiveValue.isLength()) return primitiveValue.isFontRelativeLength() || primitiveValue.isViewportPercentageLength(); if (primitiveValue.isCalculated()) { CSSLengthArray lengthArray(CSSPrimitiveValue::LengthUnitTypeCount); primitiveValue.accumulateLengthArray(lengthArray); return lengthArray[CSSPrimitiveValue::UnitTypeFontSize] != 0 || lengthArray[CSSPrimitiveValue::UnitTypeFontXSize] != 0 || lengthArray[CSSPrimitiveValue::UnitTypeRootFontSize] != 0 || lengthArray[CSSPrimitiveValue::UnitTypeZeroCharacterWidth] != 0 || lengthArray[CSSPrimitiveValue::UnitTypeViewportWidth] != 0 || lengthArray[CSSPrimitiveValue::UnitTypeViewportHeight] != 0 || lengthArray[CSSPrimitiveValue::UnitTypeViewportMin] != 0 || lengthArray[CSSPrimitiveValue::UnitTypeViewportMax] != 0; } if (Pair* pair = primitiveValue.getPairValue()) { return interpolationRequiresStyleResolve(*pair->first()) || interpolationRequiresStyleResolve(*pair->second()); } if (Rect* rect = primitiveValue.getRectValue()) { return interpolationRequiresStyleResolve(*rect->top()) || interpolationRequiresStyleResolve(*rect->right()) || interpolationRequiresStyleResolve(*rect->bottom()) || interpolationRequiresStyleResolve(*rect->left()); } if (Quad* quad = primitiveValue.getQuadValue()) { return interpolationRequiresStyleResolve(*quad->top()) || interpolationRequiresStyleResolve(*quad->right()) || interpolationRequiresStyleResolve(*quad->bottom()) || interpolationRequiresStyleResolve(*quad->left()); } if (primitiveValue.isShape()) return interpolationRequiresStyleResolve(*primitiveValue.getShapeValue()); CSSValueID id = primitiveValue.getValueID(); bool isColor = ((id >= CSSValueAqua && id <= CSSValueTransparent) || (id >= CSSValueAliceblue && id <= CSSValueYellowgreen) || id == CSSValueGrey); return (id != CSSValueNone) && !isColor; }
void StyleBuilderFunctions::applyValueCSSPropertyWillChange(StyleResolverState& state, CSSValue* value) { ASSERT(value->isValueList()); bool willChangeContents = false; bool willChangeScrollPosition = false; Vector<CSSPropertyID> willChangeProperties; for (CSSValueListIterator i(value); i.hasMore(); i.advance()) { CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(i.value()); if (CSSPropertyID propertyID = primitiveValue->getPropertyID()) willChangeProperties.append(propertyID); else if (primitiveValue->getValueID() == CSSValueContents) willChangeContents = true; else if (primitiveValue->getValueID() == CSSValueScrollPosition) willChangeScrollPosition = true; else ASSERT_NOT_REACHED(); } state.style()->setWillChangeContents(willChangeContents); state.style()->setWillChangeScrollPosition(willChangeScrollPosition); state.style()->setWillChangeProperties(willChangeProperties); state.style()->setSubtreeWillChangeContents(willChangeContents || state.parentStyle()->subtreeWillChangeContents()); }
void CSSToStyleMap::mapAnimationProperty(Animation* animation, CSSValue* value) { if (value->isInitialValue()) { animation->setAnimationMode(Animation::AnimateAll); animation->setProperty(CSSPropertyInvalid); return; } if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); if (primitiveValue->getValueID() == CSSValueAll) { animation->setAnimationMode(Animation::AnimateAll); animation->setProperty(CSSPropertyInvalid); } else if (primitiveValue->getValueID() == CSSValueNone) { animation->setAnimationMode(Animation::AnimateNone); animation->setProperty(CSSPropertyInvalid); } else { animation->setAnimationMode(Animation::AnimateSingleProperty); animation->setProperty(primitiveValue->getPropertyID()); } }
void StyleBuilderFunctions::applyValueCSSPropertyColor(StyleResolverState& state, CSSValue* value) { CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); // As per the spec, 'color: currentColor' is treated as 'color: inherit' if (primitiveValue->getValueID() == CSSValueCurrentcolor) { applyInheritCSSPropertyColor(state); return; } if (state.applyPropertyToRegularStyle()) state.style()->setColor(StyleBuilderConverter::convertColor(state, value)); if (state.applyPropertyToVisitedLinkStyle()) state.style()->setVisitedLinkColor(StyleBuilderConverter::convertColor(state, value, true)); }
PassRefPtr<TimingFunction> CSSToStyleMap::animationTimingFunction(CSSValue* value, bool allowInitial) { if (allowInitial && value->isInitialValue()) { return CSSAnimationData::initialAnimationTimingFunction(); } if (value->isPrimitiveValue()) { CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); switch (primitiveValue->getValueID()) { case CSSValueLinear: return LinearTimingFunction::preset(); break; case CSSValueEase: return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease); break; case CSSValueEaseIn: return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseIn); break; case CSSValueEaseOut: return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseOut); break; case CSSValueEaseInOut: return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseInOut); break; case CSSValueStepStart: return StepsTimingFunction::preset(StepsTimingFunction::Start); break; case CSSValueStepMiddle: return StepsTimingFunction::preset(StepsTimingFunction::Middle); break; case CSSValueStepEnd: return StepsTimingFunction::preset(StepsTimingFunction::End); break; default: break; } return nullptr; } if (value->isCubicBezierTimingFunctionValue()) { CSSCubicBezierTimingFunctionValue* cubicTimingFunction = toCSSCubicBezierTimingFunctionValue(value); return CubicBezierTimingFunction::create(cubicTimingFunction->x1(), cubicTimingFunction->y1(), cubicTimingFunction->x2(), cubicTimingFunction->y2()); } else if (value->isStepsTimingFunctionValue()) { CSSStepsTimingFunctionValue* stepsTimingFunction = toCSSStepsTimingFunctionValue(value); return StepsTimingFunction::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtPosition()); } return nullptr; }
static bool positionFromThreeOrFourValues(CSSPrimitiveValue** values, CSSValue*& resultX, CSSValue*& resultY) { CSSPrimitiveValue* center = nullptr; for (int i = 0; values[i]; i++) { CSSPrimitiveValue* currentValue = values[i]; if (!currentValue->isValueID()) return false; CSSValueID id = currentValue->getValueID(); if (id == CSSValueCenter) { if (center) return false; center = currentValue; continue; } CSSValue* result = nullptr; if (values[i + 1] && !values[i + 1]->isValueID()) { result = CSSValuePair::create(currentValue, values[++i], CSSValuePair::KeepIdenticalValues); } else { result = currentValue; } if (id == CSSValueLeft || id == CSSValueRight) { if (resultX) return false; resultX = result; } else { ASSERT(id == CSSValueTop || id == CSSValueBottom); if (resultY) return false; resultY = result; } } if (center) { ASSERT(resultX || resultY); if (resultX && resultY) return false; if (!resultX) resultX = center; else resultY = center; } ASSERT(resultX && resultY); return true; }
void CSSToStyleMap::mapAnimationIterationCount(Animation* animation, CSSValue* value) { if (value->isInitialValue()) { animation->setIterationCount(Animation::initialAnimationIterationCount()); return; } if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); if (primitiveValue->getValueID() == CSSValueInfinite) animation->setIterationCount(Animation::IterationCountInfinite); else animation->setIterationCount(primitiveValue->getFloatValue()); }
void CSSToStyleMap::mapAnimationName(CSSAnimationData* layer, CSSValue* value) const { if (value->isInitialValue()) { layer->setName(CSSAnimationData::initialAnimationName()); return; } if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); if (primitiveValue->getValueID() == CSSValueNone) layer->setIsNoneAnimation(true); else layer->setName(primitiveValue->getStringValue()); }
void CSSToStyleMap::mapAnimationName(Animation* layer, CSSValue* value) { if (value->isInitialValue()) { layer->setName(Animation::initialAnimationName()); return; } if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); if (primitiveValue->getValueID() == CSSValueNone) layer->setIsNoneAnimation(true); else layer->setName(primitiveValue->getStringValue()); }
void StyleBuilderFunctions::applyValueCSSPropertyPerspective(StyleResolverState& state, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); if (primitiveValue->getValueID() == CSSValueNone) { state.style()->setPerspective(0); return; } if (!primitiveValue->isLength()) return; float perspectiveValue = primitiveValue->computeLength<float>(state.cssToLengthConversionData()); if (perspectiveValue >= 0.0f) state.style()->setPerspective(perspectiveValue); }
void CSSToStyleMap::mapAnimationIterationCount(CSSAnimationData* animation, CSSValue* value) const { if (value->isInitialValue()) { animation->setIterationCount(CSSAnimationData::initialAnimationIterationCount()); return; } if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); if (primitiveValue->getValueID() == CSSValueInfinite) animation->setIterationCount(CSSAnimationData::IterationCountInfinite); else animation->setIterationCount(primitiveValue->getFloatValue()); }
PassRefPtr<TimingFunction> CSSToStyleMap::mapAnimationTimingFunction(CSSValue* value, bool allowStepMiddle) { // FIXME: We should probably only call into this function with a valid // single timing function value which isn't initial or inherit. We can // currently get into here with initial since the parser expands unset // properties in shorthands to initial. if (value->isPrimitiveValue()) { CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); switch (primitiveValue->getValueID()) { case CSSValueLinear: return LinearTimingFunction::shared(); case CSSValueEase: return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease); case CSSValueEaseIn: return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseIn); case CSSValueEaseOut: return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseOut); case CSSValueEaseInOut: return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseInOut); case CSSValueStepStart: return StepsTimingFunction::preset(StepsTimingFunction::Start); case CSSValueStepMiddle: if (allowStepMiddle) return StepsTimingFunction::preset(StepsTimingFunction::Middle); return CSSTimingData::initialTimingFunction(); case CSSValueStepEnd: return StepsTimingFunction::preset(StepsTimingFunction::End); default: ASSERT_NOT_REACHED(); return CSSTimingData::initialTimingFunction(); } } if (value->isCubicBezierTimingFunctionValue()) { CSSCubicBezierTimingFunctionValue* cubicTimingFunction = toCSSCubicBezierTimingFunctionValue(value); return CubicBezierTimingFunction::create(cubicTimingFunction->x1(), cubicTimingFunction->y1(), cubicTimingFunction->x2(), cubicTimingFunction->y2()); } if (value->isInitialValue()) return CSSTimingData::initialTimingFunction(); CSSStepsTimingFunctionValue* stepsTimingFunction = toCSSStepsTimingFunctionValue(value); if (stepsTimingFunction->stepAtPosition() == StepsTimingFunction::Middle && !allowStepMiddle) return CSSTimingData::initialTimingFunction(); return StepsTimingFunction::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtPosition()); }
void StyleBuilderFunctions::applyValueCSSPropertyWebkitClipPath(StyleResolverState& state, CSSValue* value) { if (value->isBasicShapeValue()) { state.style()->setClipPath(ShapeClipPathOperation::create(basicShapeForValue(state, *value))); } if (value->isPrimitiveValue()) { CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); if (primitiveValue->getValueID() == CSSValueNone) { state.style()->setClipPath(nullptr); } else if (primitiveValue->isURI()) { String cssURLValue = primitiveValue->getStringValue(); KURL url = state.document().completeURL(cssURLValue); // FIXME: It doesn't work with forward or external SVG references (see https://bugs.webkit.org/show_bug.cgi?id=90405) state.style()->setClipPath(ReferenceClipPathOperation::create(cssURLValue, AtomicString(url.fragmentIdentifier()))); } } }
void CSSToStyleMap::mapAnimationTimingFunction(Animation* animation, CSSValue* value) { if (value->isInitialValue()) { animation->setTimingFunction(Animation::initialAnimationTimingFunction()); return; } if (value->isPrimitiveValue()) { CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); switch (primitiveValue->getValueID()) { case CSSValueLinear: animation->setTimingFunction(LinearTimingFunction::create()); break; case CSSValueEase: animation->setTimingFunction(CubicBezierTimingFunction::create()); break; case CSSValueEaseIn: animation->setTimingFunction(CubicBezierTimingFunction::create(CubicBezierTimingFunction::EaseIn)); break; case CSSValueEaseOut: animation->setTimingFunction(CubicBezierTimingFunction::create(CubicBezierTimingFunction::EaseOut)); break; case CSSValueEaseInOut: animation->setTimingFunction(CubicBezierTimingFunction::create(CubicBezierTimingFunction::EaseInOut)); break; case CSSValueStepStart: animation->setTimingFunction(StepsTimingFunction::create(1, true)); break; case CSSValueStepEnd: animation->setTimingFunction(StepsTimingFunction::create(1, false)); break; default: break; } return; } if (value->isCubicBezierTimingFunctionValue()) { CSSCubicBezierTimingFunctionValue* cubicTimingFunction = static_cast<CSSCubicBezierTimingFunctionValue*>(value); animation->setTimingFunction(CubicBezierTimingFunction::create(cubicTimingFunction->x1(), cubicTimingFunction->y1(), cubicTimingFunction->x2(), cubicTimingFunction->y2())); } else if (value->isStepsTimingFunctionValue()) { CSSStepsTimingFunctionValue* stepsTimingFunction = static_cast<CSSStepsTimingFunctionValue*>(value); animation->setTimingFunction(StepsTimingFunction::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtStart())); } else if (value->isLinearTimingFunctionValue()) animation->setTimingFunction(LinearTimingFunction::create()); }
FontDescription::VariantLigatures StyleBuilderConverter::convertFontVariantLigatures(StyleResolverState&, CSSValue* value) { if (value->isValueList()) { FontDescription::VariantLigatures ligatures; CSSValueList* valueList = toCSSValueList(value); for (size_t i = 0; i < valueList->length(); ++i) { CSSValue* item = valueList->item(i); CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(item); switch (primitiveValue->getValueID()) { case CSSValueNoCommonLigatures: ligatures.common = FontDescription::DisabledLigaturesState; break; case CSSValueCommonLigatures: ligatures.common = FontDescription::EnabledLigaturesState; break; case CSSValueNoDiscretionaryLigatures: ligatures.discretionary = FontDescription::DisabledLigaturesState; break; case CSSValueDiscretionaryLigatures: ligatures.discretionary = FontDescription::EnabledLigaturesState; break; case CSSValueNoHistoricalLigatures: ligatures.historical = FontDescription::DisabledLigaturesState; break; case CSSValueHistoricalLigatures: ligatures.historical = FontDescription::EnabledLigaturesState; break; case CSSValueNoContextual: ligatures.contextual = FontDescription::DisabledLigaturesState; break; case CSSValueContextual: ligatures.contextual = FontDescription::EnabledLigaturesState; break; default: ASSERT_NOT_REACHED(); break; } } return ligatures; } ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue()); ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNormal); return FontDescription::VariantLigatures(); }
void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CSSValue* value) { ASSERT_WITH_MESSAGE(!isExpandedShorthand(id), "Shorthand property id = %d wasn't expanded at parsing time", id); bool isInherit = state.parentNode() && value->isInheritedValue(); bool isInitial = value->isInitialValue() || (!state.parentNode() && value->isInheritedValue()); ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInherit -> (state.parentNode() && state.parentStyle()) CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimitiveValue(value) : 0; if (primitiveValue && primitiveValue->getValueID() == CSSValueCurrentcolor) state.style()->setHasCurrentColor(); if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() && !CSSPropertyMetadata::isInheritedProperty(id)) state.parentStyle()->setHasExplicitlyInheritedProperties(); StyleBuilder::applyProperty(id, state, value, isInitial, isInherit); }
void StyleBuilderFunctions::applyValueCSSPropertyTextAlign(StyleResolverState& state, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); // FIXME : Per http://www.w3.org/TR/css3-text/#text-align0 can now take <string> but this is not implemented in the // rendering code. if (primitiveValue->isString()) return; if (primitiveValue->isValueID() && primitiveValue->getValueID() != CSSValueWebkitMatchParent) state.style()->setTextAlign(*primitiveValue); else if (state.parentStyle()->textAlign() == TASTART) state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT); else if (state.parentStyle()->textAlign() == TAEND) state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection() ? RIGHT : LEFT); else state.style()->setTextAlign(state.parentStyle()->textAlign()); }
void StyleBuilderFunctions::applyValueCSSPropertyLineHeight(StyleResolverState& state, CSSValue* value) { CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); Length lineHeight; if (primitiveValue->getValueID() == CSSValueNormal) { lineHeight = RenderStyle::initialLineHeight(); } else if (primitiveValue->isLength()) { lineHeight = primitiveValue->computeLength<Length>(state.cssToLengthConversionData()); } else if (primitiveValue->isPercentage()) { lineHeight = Length((state.style()->computedFontSize() * primitiveValue->getIntValue()) / 100.0, Fixed); } else if (primitiveValue->isNumber()) { lineHeight = Length(primitiveValue->getDoubleValue() * 100.0, Percent); } else if (primitiveValue->isCalculated()) { Length length = Length(primitiveValue->cssCalcValue()->toCalcValue(state.cssToLengthConversionData())); lineHeight = Length(valueForLength(length, state.style()->fontSize()), Fixed); } else { return; } state.style()->setLineHeight(lineHeight); }
void CSSToStyleMap::mapFillAttachment(FillLayer* layer, CSSValue* value) const { if (value->isInitialValue()) { layer->setAttachment(FillLayer::initialFillAttachment(layer->type())); return; } if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); switch (primitiveValue->getValueID()) { case CSSValueFixed: layer->setAttachment(FixedBackgroundAttachment); break; case CSSValueLocal: layer->setAttachment(LocalBackgroundAttachment); break; default: return; } }
bool FontFace::setFamilyValue(CSSValueList* familyList) { // The font-family descriptor has to have exactly one family name. if (familyList->length() != 1) return false; CSSPrimitiveValue* familyValue = toCSSPrimitiveValue(familyList->itemWithoutBoundsCheck(0)); AtomicString family; if (familyValue->isString()) { family = AtomicString(familyValue->getStringValue()); } else if (familyValue->isValueID()) { // We need to use the raw text for all the generic family types, since @font-face is a way of actually // defining what font to use for those types. switch (familyValue->getValueID()) { case CSSValueSerif: family = FontFamilyNames::webkit_serif; break; case CSSValueSansSerif: family = FontFamilyNames::webkit_sans_serif; break; case CSSValueCursive: family = FontFamilyNames::webkit_cursive; break; case CSSValueFantasy: family = FontFamilyNames::webkit_fantasy; break; case CSSValueMonospace: family = FontFamilyNames::webkit_monospace; break; case CSSValueWebkitPictograph: family = FontFamilyNames::webkit_pictograph; break; default: return false; } } m_family = family; return true; }
void StyleBuilderFunctions::applyValueCSSPropertyBaselineShift(StyleResolverState& state, CSSValue* value) { SVGComputedStyle& svgStyle = state.style()->accessSVGStyle(); CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); if (!primitiveValue->isValueID()) { svgStyle.setBaselineShift(BS_LENGTH); svgStyle.setBaselineShiftValue(StyleBuilderConverter::convertLength(state, primitiveValue)); return; } switch (primitiveValue->getValueID()) { case CSSValueBaseline: svgStyle.setBaselineShift(BS_LENGTH); svgStyle.setBaselineShiftValue(Length(Fixed)); return; case CSSValueSub: svgStyle.setBaselineShift(BS_SUB); return; case CSSValueSuper: svgStyle.setBaselineShift(BS_SUPER); return; default: ASSERT_NOT_REACHED(); } }