什么弟什么兄| 大学团委书记什么级别| 自主神经功能紊乱吃什么药| 金银花洗澡对婴儿有什么好处| 婚检都检查什么项目| 大肠杆菌属于什么菌| sch是什么意思| 吃什么补血补气最快| 喝酒前吃什么保护胃| 胃动力不足吃什么中成药| 处变不惊是什么意思| 额头高代表什么| 子宫后位是什么意思| 宫颈ca什么意思| 肚子疼拉稀吃什么药| 大血小板比率偏高是什么原因| 水瓶男喜欢什么样的女生| 农历6月21日是什么星座| 中午一点是什么时辰| 内痔有什么症状| 过敏吃什么药| 细胞骨架是由什么构成| 梦见两条大蟒蛇是什么征兆| take是什么意思| 1月21号什么星座| 口中发甜是什么原因| 50年属什么生肖| 贴士是什么意思| 紧张吃什么药| 北京市市长是什么级别| 眼皮重是什么原因| 经常感冒是什么原因| 什么原因导致流鼻血| 晚上咳嗽吃什么药| 天青色等烟雨是什么意思| 季昌明是什么级别| 高血压能喝什么饮料| 为什么会胃胀气| 附件炎是什么原因引起的| 手指甲变薄是什么原因| 什么地响| 什么是菜花病| 胸膜炎吃什么药| 手指缝里长水泡还痒是什么原因| 恶魔是什么意思| 山竹是什么| 突然肚子疼是什么原因| 怀孕为什么要吃叶酸| 灵魂伴侣是指什么意思| 甲功五项是什么意思| 春秋鼎盛是什么意思| 肝囊肿是什么原因引起的| 脊椎炎有什么症状| 卵子排出体外是什么样子| 吃什么补血最好最快| 睾丸痛是什么原因| ards是什么病的简称| 皮肤暗黄是什么原因造成的| 卤米松软膏主治什么| 造诣是什么意思| 慢阻肺是什么原因引起的| 什么山色| 虫草是什么| 脚底冰凉是什么原因| 小狗感冒吃什么药| 含羞草为什么害羞| 掌勺是什么意思| 沵是什么意思| 冷冻和冷藏有什么区别| 二个月不来月经是什么原因| 卡姿兰是什么档次| 历时是什么意思| 骆驼奶有什么功效| 花生属于什么类食物| 夏天适合吃什么| 肚子痛去医院挂什么科| 心脏不舒服有什么症状| 肝气不舒有什么症状| 母乳是什么颜色| 痔疮不治会有什么危害| 男人吃荔枝有什么好处| tga是什么意思| 趴在桌子上睡觉有什么坏处| ph值什么意思| 黑色的蜜蜂是什么蜂| 11.4什么星座| 慕斯蛋糕是什么意思| 龟苓膏有什么功效| 手抖挂什么科室| 前列腺炎吃什么食物好| 血沉偏高是什么原因| 补充免疫力吃什么好| 尿次数多是什么原因| 什么水果糖分最高| 木耳和什么菜搭配好吃| 男人身体虚吃什么补| 尿酸高能喝什么酒| 小孩体质差吃什么能增强抵抗力| 用什么泡脚可以脸上祛斑| 重阳节送老人什么礼物| pp材质和ppsu材质有什么区别| 培土什么意思| 悉如外人的悉是什么意思| 乳腺囊实性结节是什么意思| 知了什么时候叫| 湿疹和热疹有什么区别| 煲排骨汤放什么材料好| 欲言又止什么意思| bambi什么意思| 被交警开罚单不交有什么后果| 月泉读什么| 元五行属什么| 中医考证需要什么条件| 铁观音是属于什么茶| 一个月一个办念什么| 感冒了不能吃什么食物| 五险一金的一金是什么| 阑尾炎能吃什么水果| 邓超什么星座的| 咖啡不能和什么一起吃| 蒸馏水敷脸有什么作用| 非典型细胞是什么意思| 什么是表达方式| 牙齿出血是什么病征兆| 93是什么意思| 道家思想的核心是什么| 前列腺增生用什么药| 人体七大营养素是什么| moss是什么意思| 黑猫警长是什么猫| ad吃到什么时候| 攒是什么意思| 门静脉增宽是什么意思| 有出息是什么意思| 高血压降不下来是什么原因| asic是什么意思| 入睡困难吃什么中成药| 嗓子发炎肿痛吃什么药| 杭州吃什么| 香港什么东西值得买| 浅黄色是什么颜色| 天珠是什么材质| 磨盘有什么风水说法| 双肺纹理增多模糊是什么意思| 肌酐高是什么问题| 1997年属牛是什么命| 眼睛浮肿是什么原因| 物化是什么意思| 去港澳旅游需要什么证件| c14阳性 是什么意思| 高烧不退有什么好办法| 跳梁小丑是什么生肖| 关节由什么组成| 尼姑是什么生肖| 杞子配什么增强性功能| mic是什么| 床单什么颜色有助于睡眠| professional是什么意思| 咽颊炎吃什么药| 扁桃体结石长什么样| 甲状腺激素高吃什么药| 印度为什么叫三哥| 中堂相当于现在什么官| 上海元宵节吃什么| 苦海翻起爱恨是什么歌| 冬至广东吃什么| 女性口臭都是什么原因| 活检是什么检查| bm什么意思| 什么是1型和2型糖尿病| 荷叶搭配什么一起喝减肥效果好| 以貌取人是什么意思| 六根不净是什么意思| 冰妹什么意思| 张柏芝和谢霆锋为什么离婚| 膝跳反射属于什么反射| 残留是什么意思| 潜意识是什么意思| 百字五行属什么| 摩羯座女和什么星座最配| 胎儿永存左上腔静脉是什么意思| 燕窝是什么东西做成的| 鹿晗的粉丝名叫什么| 咽鼓管炎吃什么药| 英雄的动物是什么生肖| pm代表什么| 一个夸一个瓜念什么| p是什么医学| hepes缓冲液是什么| 婉甸女装属于什么档次| 爬山虎是什么茎| 肾阴虚的症状是什么| 宫颈ca什么意思| 为什么会得偏头痛| 滇红是什么茶| 贞洁是什么意思| 精子对女性有什么好处| 晚上2点是什么时辰| 精液是什么味道| 胎盘下缘达宫颈内口是什么意思| 豆浆和豆奶有什么区别| 肝火旺会出现什么症状| 办独生子女证需要什么材料| 甲状腺有什么反应| 吃什么食物有助于睡眠| .什么意思| 尿性什么意思| 放我鸽子是什么意思| 为什么突然长痣| kumpoo是什么牌子| 葡萄上的白霜是什么| 下巴上有痣代表什么| 走马观花的走是什么意思| 工业氧气和医用氧气有什么区别| 低血钾是什么病| 脚一直出汗是什么原因| 夺魁是什么意思| 独是什么生肖| 算了是什么意思| 活检是什么检查| 脉搏快是什么原因| 指教是什么意思| 呼吸短促是什么原因| 什么时候不容易怀孕| 黄鼠狼最怕什么| 同房为什么会出血| 尿酸高是为什么| 过敏性紫癜有什么危害| 小孩什么时候会说话| 甲沟炎是什么原因引起的| 脑死亡是什么意思| 乌合之众什么意思| 做梦梦见下大雨是什么意思| 颈椎病吃什么药效果好| 空调制冷效果差是什么原因| 鼻孔干燥是什么原因| 宝妈男是什么意思| 家有喜事指什么生肖| 低压高吃什么药效果好| 毫不犹豫的意思是什么| 逆钟向转位什么意思| 鱼水之欢是什么意思| 狸猫换太子什么意思| 病毒性扁桃体发炎吃什么药| 什么地摇动| 来月经不能吃什么水果| mlb是什么档次| 什么秒必争| 爱华仕是什么档次| 耳浴10分钟什么意思| 宝齐莱算什么档次的表| 头发黄是什么原因| 什么人不适合喝骆驼奶| 众望所归是什么意思| 小叶紫檀有什么功效| 曲安奈德是什么药| 小孩晚上睡觉流口水是什么原因| 胎盘后壁是什么意思| 1996年属鼠五行属什么| 阴道里面瘙痒是什么原因| 玥是什么意思| 数值是什么意思| 狮子头是什么肉| 陈皮治什么病| 百度
wiki:SVG properties

SVG Properties

What is an SVG property?

It is a storage for data type which can be primitive, DOM type or SVG type. Example of primitive types are int, float, boolean. Examples for DOM type is DOMString. And examples for SVG types are SVGNumber, SVGNumberList, SVGLength, SVGLengthList, SVGAngle, SVGPoint, SVGPointList.

What is so special about SVG property?

  1. It has to provide a DOM interface. The interface can get or set its value similar to getAttribute() and setAttribute() methods.
  2. It has to be RefCounted because the DOM object will encapsulate the same SVG property and this DOM object can outlive the owner element.
  3. It is a reflection of a DOM attribute. Two cases have to be handled:
    1. When setAttribute() called for the underlaying attribute, SVGElement::parseAttribute() will be called to update the SVG property. Then SVGElement::svgAttributeChanged() is called to invalidate the renderer and the dependent SVG objects.
    2. When the SVG property is changed through the DOM interface. This change will be handled in two steps:
      • The commit step which is called immediately after changing the property's value. It will mark the value of the underlaying attribute to be invalid and it will call SVGElement::svgAttributeChanged().
      • The synchronize step which happens later when the value of attribute is required. The valueAsString() of the SVG property is set as the attribute value. In other words, synchronizing the attribute value is lazily updated from the reflection SVG property only when it is needed.
  4. Most of the properties are animated properties. The animated property has two members baseVal() and the animal(). Each of them are from the same SVG property type. animal() differs from baseVal() only when animating. Otherwise they have to be the same value.
  5. The animal() of the animated property is read only; no changes from the DOM is allowed.
  6. The SVG property can be attached to an SVGElement or it can be detached.
    • When the property is attached, a change in its value has to be synchronized with the attribute value.
    • When the property is detached, a change in its value has no effect on any other element.
  7. Some properties are SVG lists of SVG types, e.g. SVGNumberList and SVGPointList. In addition of having the list itself Refcounted, all the items of this list have to be RefCounted also. The items can outlive the owner list and the owner list.

SVG Tear-Off objects

The old design of managing the SVG properties relied on storing only the underlaying data in the SVG element. For example, the SVGRectElement was storing an an SVGLengthValue for the baseVal of 'x' property. When the property is requested from the DOM an SVGAnimatedLength has to be constructed. Constructing the SVGAnimatedLength happens through creating and caching an animated SVG tear-off object. The animated tear-off object is a RefCounted and it holds two SVGLength objects for the baseVal and the animVal. The SVGLength object is another type of tear-off objects. This design has many flaws:

  1. The animated tear off objects are cached in a hash table outside of the SVGElement although it holds a raw pointer to the property raw data in the SVGElement.
  2. It was difficult to deal with optional properties, for example the 'stdDeviation' property of SVGFEGaussianBlurElement. This is because the key of hash table is the pair <SVGElement, attributeName>
  3. It was difficult to deal with list properties, for example the 'x' property of SVGTextPositioningElement. The individual items of the SVG tear off object holds raw pointers to the raw data items in the SVGElement. It becomes even more difficult when animating. The animVal tear off list owns the values of the items while the baseVal tear off list items hold pointers to the raw data which is held by the SVGElement.
  4. When animating, SVGAnimateElementBase creates SVGAnimatedType objects for from, to, toAtEndOfDuration and current values. The SVGAnimatedType is basically a union of raw pointers to the raw data. The current SVGAnimatedType points to the raw data stored by the animVal of the SVG tear off objects. The rest of the SVGAnimatedType objects points to raw data created by the SVGAnimator when parsing the from, to and toAtEndOfDuration strings.

New Design for the SVG properties

The goal of the new design is to make the life cycle of the SVG properties clear. It has to well define the relationship between the property and its owner such that synchronizing the change in the property with the SVGElement becomes straightforward.

  • The SVGElement will own the RefCounted animated SVG property which will own the RefCounted SVG properties for the baseVal and the animVal. This eliminates the need to cache the animated SVG property outside the SVGElement like what the SVG tear off objects were doing.
  • If the property is of list of an SVG type, the items will be RefCounted of the SVG type.
  • The properties will be registered once by the owner SVGElement to associate a pointer to a member in the SVGElement with an attributeName.
  • The property registry will create an accessor for every property. The accessor knows how to get the property value when it is given a pointer to an SVGElement.
  • The SMIL animation is carried out by new types of SVGAnimator. The SVGAnimator calculates the new value of the animVal by the SVGAnimationFunction. The SVGAnimator commits the change in the animVal by invalidating the SVGElement. The SVG renderer will get the new animVal when it gets the property value and the SVGElement finds that the property is being animated.

Mechanic of the SVG property

  1. Define the property registry of the element such that it associate the class with its all superclasses. And define a member of this type. For example the SVGRectElement has this definition and member declartion:
    using PropertyRegistry = SVGPropertyOwnerRegistry<SVGRectElement, SVGGeometryElement, SVGExternalResourcesRequired>;
    PropertyRegistry m_propertyRegistry { *this };
    
  2. Override the virtual method propertyRegistry() which will allow the base class SVGElement to perform operations on all the SVG properties of any superclass.
    const SVGPropertyRegistry& propertyRegistry() const final { return m_propertyRegistry; }
    
  3. The property of defined in the header file of the SVG element exactly as it is defined in the IDL file. For example, SVGRectElement will have this member
    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, LengthModeWidth) };
    
  4. Define the following two functions for every property with the same name. The first is one a const function. This function will return the current value. The expectation is this function will be called from the rendering code. So it does not have to get a RefCounted to the animated property. But rather it cares about the current value only. The second one is none const function. The expectation is this function will be called from the DOM interface. So it needs the RefCounted animated property. For example the SVGRectElement will have these two methods for the 'x' property:
    const SVGLengthValue& x() const { return m_x->currentValue(); }
    Ref<SVGAnimatedLength>& x() { return m_x; }
    
  5. The SVGAnimatedLength has two members named m_baseVal and m_animVal. Both of them are of type SVGLength.
  6. The property is registered only once in the constructor of the SVG element. This registration will associate the data member with the attribute name. For example the constructor of the SVGRectElement will have this statement:
    PropertyRegistry::registerProperty<SVGNames::xAttr, &SVGRectElement::m_x>();
    
  7. This statement calls the override method of SVGPropertyOwnerRegistry
    template<const LazyNeverDestroyed<const QualifiedName>& attributeName, Ref<SVGAnimatedLength> OwnerType::*property>
    static void registerProperty()
    {
        registerProperty(attributeName, SVGAnimatedLengthAccessor<OwnerType>::template singleton<property>());
    }
    
  8. This registration associates a pointer to a member of SVGRectElement with the attributeName through the SVGAnimatedLengthAccessor.
  9. When the animation of an SVG animated property starts, SVGAnimateElementBase asks the SVGPropertyRegistry to create an SVGAnimator for this property. SVGPropertyRegistry finds the property accessor and asks it to create the SVGAnimator. For example, this is the createAnimator method of SVGAnimatedLengthAccessor:
    RefPtr<SVGAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
    {
        SVGLengthMode lengthMode = property(owner)->baseVal()->value().unitMode();
        return SVGAnimatedLengthAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive, lengthMode);
    }
    
  10. When SVGAnimateElementBase wants to progress the animation, it asks the animator to calculate a new value of the property based on the timeline of the animation. The SVGAnimator asks the SVGAnimationFunction to do so given a reference to the animVal of the property. For example here is the progress() method of SVGAnimatedLengthAnimator:
    void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final
    {
        m_function.progress(targetElement, percentage, repeatCount, m_animated->animVal()->value());
    }
    

Important classes

Below is a list of some important classes which are used for manipulating the SVG properties.

Class name Description Important Methods
SVGProperty It is a RefCounted object. It is the base of the SVG types: SVGNumber, SVGPoint, SVGRect, SVGMatrix, SVGTransfrom, SVGLength and SVGPathSeg.
SVGPathSeg It is a special kind of SVGProperty because it is only an abstract class. Only the super classes of it can be created.
SVGPathSegValue It is a template class of SVGPathSeg with a template parameter pack. All the SVGPathSeg types are derived from this template.
SVGAnimatedProperty It is the base class of all the animated properties, e.g. SVGAnimatedLength and SVGAnimatedString. It maintains two members baseVal and animVal..
SVGList It is a template class and which provides the basic DOM interface of an SVG list.
SVGPropertyList It holds RefCounted items. It is the base class of SVGValuePropertyList and SVGPathSegList.
SVGValuePropertyList It holds SVG type items, e.g. SVGNumber and SVGPoint.
SVGPathSegList It is a SVGList of Ref<SVGPathSeg> but it does lazy conversions: from SVGPathByteStream to list of Ref<SVGPathSeg> and from list of Ref<SVGPathSeg> to SVGPathByteStream.
SVGPropertyOwner It is the base class of all the SVGProperty owners. It is driven by SVGElement, SVGAnimatedProperty, SVGPropertyList and SVGTransform.
SVGPropertyRegistry It manages the SVGProperties, connect them to their attributes and defines their accessors.
SVGAccessor It is used to access an SVGProperty in an SVGElement. The accessor can access a pair of SVGProperties if they are associated with the same attribute. One important task of an accessor is creating the SVGAnimator of an SVGAnimatedProperty of an SVGElement.
SVGAnimator It is responsible of changing the animVal of an SVGAnimatedProperty over a period of time.
SVGAnimationFunction This is where the new animated value of an SVGAnimator is calculated.
Last modified 6年 ago Last modified on 2025-08-07 下午7:33:31
Note: See TracWiki for help on using the wiki.
脑袋痛什么原因 tiamo是什么意思 多囊卵巢有什么症状表现 外籍是什么意思 肾功能不全是什么意思
内向的人适合什么职业 医学上是什么意思 产检都检查什么项目 教师节贺卡上写什么 葛根粉吃了有什么好处
什么产品美白效果最好最快 信心是什么意思 为什么吐后反而舒服了 什么是肌张力 ol什么意思
7.10是什么日子 湿疹有什么症状 38岁属什么的生肖 主张是什么意思 检查贫血挂什么科
人瘦肚子大是什么原因hcv7jop5ns5r.cn 发生火灾时的正确做法是什么hcv9jop5ns7r.cn tvb为什么演员都走了hcv7jop5ns1r.cn 男人下面有异味什么原因bjcbxg.com 乳房有溢液是什么原因hcv8jop5ns6r.cn
glu是什么氨基酸hcv8jop6ns2r.cn 探病送什么花hcv8jop3ns5r.cn 烟雾病是什么hcv8jop3ns2r.cn 感冒怕冷吃什么药wuhaiwuya.com 什么的叮咛hcv8jop6ns3r.cn
钠低是什么原因hcv9jop0ns2r.cn 真菌感染吃什么药hcv9jop1ns3r.cn 什么样的闪电hcv9jop2ns4r.cn 女人得性疾病什么症状hcv9jop2ns1r.cn 为什么尽量抽混合型烟xinmaowt.com
毒龙钻什么意思hebeidezhi.com 孙俪什么学历hcv8jop7ns1r.cn http什么意思hcv7jop5ns1r.cn 脑供血不足吃什么中药hcv9jop2ns2r.cn 超标是什么意思hcv8jop4ns9r.cn
百度