PassRefPtr<ShadowList> ShadowList::blend(const ShadowList* from, const ShadowList* to, double progress, const Color& currentColor) { size_t fromLength = from ? from->shadows().size() : 0; size_t toLength = to ? to->shadows().size() : 0; if (!fromLength && !toLength) return nullptr; ShadowDataVector shadows; DEFINE_STATIC_LOCAL( ShadowData, defaultShadowData, (FloatPoint(), 0, 0, Normal, StyleColor(Color::transparent))); DEFINE_STATIC_LOCAL( ShadowData, defaultInsetShadowData, (FloatPoint(), 0, 0, Inset, StyleColor(Color::transparent))); size_t maxLength = std::max(fromLength, toLength); for (size_t i = 0; i < maxLength; ++i) { const ShadowData* fromShadow = i < fromLength ? &from->shadows()[i] : 0; const ShadowData* toShadow = i < toLength ? &to->shadows()[i] : 0; if (!fromShadow) fromShadow = toShadow->style() == Inset ? &defaultInsetShadowData : &defaultShadowData; else if (!toShadow) toShadow = fromShadow->style() == Inset ? &defaultInsetShadowData : &defaultShadowData; shadows.append(toShadow->blend(*fromShadow, progress, currentColor)); } return ShadowList::adopt(shadows); }
void SVGAnimatedColorAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType* from, SVGAnimatedType* to, SVGAnimatedType* toAtEndOfDuration, SVGAnimatedType* animated) { ASSERT(m_animationElement); ASSERT(m_contextElement); StyleColor fromStyleColor = m_animationElement->animationMode() == ToAnimation ? animated->color() : from->color(); StyleColor toStyleColor = to->color(); StyleColor toAtEndOfDurationStyleColor = toAtEndOfDuration->color(); StyleColor& animatedStyleColor = animated->color(); // Apply CSS inheritance rules. m_animationElement->adjustForInheritance<StyleColor>(parseColorFromString, m_animationElement->fromPropertyValueType(), fromStyleColor, m_contextElement); m_animationElement->adjustForInheritance<StyleColor>(parseColorFromString, m_animationElement->toPropertyValueType(), toStyleColor, m_contextElement); // Apply currentColor rules. Color fallbackColor = fallbackColorForCurrentColor(m_contextElement); Color fromColor = fromStyleColor.resolve(fallbackColor); Color toColor = toStyleColor.resolve(fallbackColor); Color toAtEndOfDurationColor = toAtEndOfDurationStyleColor.resolve(fallbackColor); Color animatedColor = animatedStyleColor.resolve(fallbackColor); float animatedRed = animatedColor.red(); m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.red(), toColor.red(), toAtEndOfDurationColor.red(), animatedRed); float animatedGreen = animatedColor.green(); m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.green(), toColor.green(), toAtEndOfDurationColor.green(), animatedGreen); float animatedBlue = animatedColor.blue(); m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.blue(), toColor.blue(), toAtEndOfDurationColor.blue(), animatedBlue); float animatedAlpha = animatedColor.alpha(); m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.alpha(), toColor.alpha(), toAtEndOfDurationColor.alpha(), animatedAlpha); animatedStyleColor = StyleColor(makeRGBA(roundf(animatedRed), roundf(animatedGreen), roundf(animatedBlue), roundf(animatedAlpha))); }
void SVGColorProperty::calculateAnimatedValue(SVGAnimationElement* animationElement, float percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> fromValue, PassRefPtr<NewSVGPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) { StyleColor fromStyleColor = toSVGColorProperty(fromValue)->m_styleColor; StyleColor toStyleColor = toSVGColorProperty(toValue)->m_styleColor; StyleColor toAtEndOfDurationStyleColor = toSVGColorProperty(toAtEndOfDurationValue)->m_styleColor; // Apply currentColor rules. ASSERT(contextElement); Color fallbackColor = fallbackColorForCurrentColor(contextElement); Color fromColor = fromStyleColor.resolve(fallbackColor); Color toColor = toStyleColor.resolve(fallbackColor); Color toAtEndOfDurationColor = toAtEndOfDurationStyleColor.resolve(fallbackColor); Color animatedColor = m_styleColor.resolve(fallbackColor); ASSERT(animationElement); float animatedRed = animatedColor.red(); animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.red(), toColor.red(), toAtEndOfDurationColor.red(), animatedRed); float animatedGreen = animatedColor.green(); animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.green(), toColor.green(), toAtEndOfDurationColor.green(), animatedGreen); float animatedBlue = animatedColor.blue(); animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.blue(), toColor.blue(), toAtEndOfDurationColor.blue(), animatedBlue); float animatedAlpha = animatedColor.alpha(); animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.alpha(), toColor.alpha(), toAtEndOfDurationColor.alpha(), animatedAlpha); m_styleColor = StyleColor(makeRGBA(roundf(animatedRed), roundf(animatedGreen), roundf(animatedBlue), roundf(animatedAlpha))); }
StyleColor CSSParser::colorFromRGBColorString(const String& string) { // FIXME: Rework css parser so it is more SVG aware. RGBA32 color; if (parseColor(color, string.stripWhiteSpace())) return StyleColor(color); // FIXME: This branch catches the string currentColor, but we should error if we have an illegal color value. return StyleColor::currentColor(); }
void SVGColorProperty::add(PassRefPtr<NewSVGPropertyBase> other, SVGElement* contextElement) { ASSERT(contextElement); Color fallbackColor = fallbackColorForCurrentColor(contextElement); Color fromColor = toSVGColorProperty(other)->m_styleColor.resolve(fallbackColor); Color toColor = m_styleColor.resolve(fallbackColor); m_styleColor = StyleColor(ColorDistance::addColors(fromColor, toColor)); }
void ColorChooserPopupUIController::setValueAndClosePopup(int numValue, const String& stringValue) { ASSERT(m_popup); ASSERT(m_client); if (numValue == ColorPickerPopupActionSetValue) m_client->didChooseColor(StyleColor(stringValue).color()); if (numValue == ColorPickerPopupActionChooseOtherColor) openColorChooser(); closePopup(); }
PassRefPtr<RenderStyle> RenderScrollbar::getScrollbarPseudoStyle(ScrollbarPart partType, PseudoId pseudoId) { if (!owningRenderer()) return nullptr; RefPtr<RenderStyle> result = owningRenderer()->getUncachedPseudoStyle(PseudoStyleRequest(pseudoId, this, partType), owningRenderer()->style()); // Scrollbars for root frames should always have background color // unless explicitly specified as transparent. So we force it. // This is because WebKit assumes scrollbar to be always painted and missing background // causes visual artifact like non-paint invalidated dirty region. if (result && m_owningFrame && m_owningFrame->view() && !m_owningFrame->view()->isTransparent() && !result->hasBackground()) result->setBackgroundColor(StyleColor(Color::white)); return result; }
void ColorChooserPopupUIController::setValue(const String& value) { ASSERT(m_client); m_client->didChooseColor(StyleColor(value).color()); }
InterpolationValue CSSColorInterpolationType::maybeConvertNeutral(const InterpolationValue&, ConversionCheckers&) const { return convertStyleColorPair(StyleColor(Color::transparent), StyleColor(Color::transparent)); }
PassOwnPtr<InterpolationValue> CSSColorInterpolationType::maybeConvertNeutral(const UnderlyingValue&, ConversionCheckers&) const { return convertStyleColorPair(StyleColor(Color::transparent), StyleColor(Color::transparent)); }