blink渲染知识四 - layout basics

Posted by DaveHyatt onFriday, August 10th, 2007 at 2:01 pm

When renderers are first created and added to the tree, they haveno position or size yet. The process by which all of the boxes havetheir positions and sizes determined is called layout. Allrenderers have a layout method.

Rendertree创立后,renderer没有坐标和尺寸,需要layout来计算

void layout()

Layout is a recursive operation. A class called FrameViewrepresents the containing view for the document, and it also has alayout method. The frame view is responsible formanaging the layout of the render tree.

There are two types of layout that the FrameView canperform. The first (and by far the most common) is a layout of theentire render tree. In this case the root of the render tree has itslayout method called and then the entire render tree gets updated.The second type of layout is constrained to a specific subtree of therender tree. It is used in situations where the layout of some smallsubtree can’t possibly affect its surroundings. Right now thesubtree layout is only used by text fields (but may be used byoverflow:auto blocks and other similar constructs in the future).

FrameView维护了一个rendertree, 他对应了一个document,他有layout函数来完成真个tree的layout操作,是递归的。FrameView的layout操作有2种:1是fulllayout整棵树,2是只layoutsubtree.

TheDirty Bits

Layout uses a dirty bit system to determine whether an objectactually needs a layout. Whenever new renderers are inserted into thetree, they dirty themselves and the relevant links in their ancestorchain. There are three unique bits that are used by the render tree.

bool needsLayout() const { return m_needsLayout ||
m_normalChildNeedsLayout ||
                                  m_posChildNeedsLayout; }
bool selfNeedsLayout() const { return m_needsLayout; }
bool posChildNeedsLayout() const { return m_posChildNeedsLayout;
}
bool normalChildNeedsLayout() const
{ return m_normalChildNeedsLayout; }

The first bit is used when the renderer itself is dirty, and itcan be queried using the method selfNeedsLayout.Whenever this bit is set to true, relevant ancestorrenderers have bits set indicating that they have a dirty child. Thetype of bit set depends on the positioned status of the previous linkin the chain being dirtied. posChildNeedsLayout is usedto indicate that a positioned child got dirtied.normalChildNeedsLayout is used to indicate that anin-flow child got dirtied. By distinguishing between these two typesof children, layout can be optimized for the case where onlypositioned elements moved.

TheContaining Block

What exactly did I mean by “the relevant ancestor chain”? Whenan object is marked as needing layout, the ancestor chain that isdirtied is based on a CSS concept called the containing block.The containing block is also used to establish the coordinatespace of children. Renderers have xPos and yPoscoordinates, and these are relative to their containing blocks. Sowhat exactly is a containing block?

Hereis the CSS 2.1 spec’s introduction to the concept.

My own way of introducing the concept in terms of the WebCorerender tree would be as follows:

A renderer’s containingblock is an ancestor block of the renderer that is responsible fordetermining that renderer’s position.

In other words when layout recurs down the render tree, it is ablock’s responsibility to position all of the renderers that haveit as their containing block.

The root of the render tree iscalled the RenderView,and this class corresponds to the initialcontaining block according to CSS2.1. Itis also the renderer that will be returned if the renderer()method is called on the Document.

RenderView.h

The initial containing block isalways sized to the viewport.In desktop browsers, this is the visible area in the browser window.It is also always at position (0,0) relative to the entire document.Here’s a picture illustrating where the initial containing block ispositioned for a document. The black bordered box represents theRenderView, and the grey box represents the entiredocument.

If the document is scrolled, then the initial containing blockwill be moved offscreen. It is always at the top of the document andsized to the viewport. One area of confusion that people often havewith the initial containing block is that they expect it to somehowbe outside the document and part of the viewport.

Hereis the detailed containing block specification in CSS2.1.

The rules can be summarized as follows:

  • The root element’s renderer(i.e., the <html> element) will always have the RenderView asits containing block.

  • If a renderer has a CSS positionof relative or static, then the containing block will be the nearestblock-level ancestor in the render tree.

  • If a renderer has a CSS positionof fixed, then the containing block will be the RenderView.Technically the RenderView does not act as a viewport, so theRenderView has to adjust the coordinates of fixed positioned objectsto account for the document scroll position. It is simpler to justlet the RenderView act like a viewport containing block for this onecase rather than having a separate renderer just for the viewport.

  • If a renderer has a CSS position of absolute, then thecontaining block is the nearest block-level ancestor with a positionother than static. If no such ancestor exists, then the containingblock will be the RenderView.

The render tree has two convenience methods for asking if anobject has a position of absolute, fixed or relative. They are:

bool isPositioned() const;   // absolute or fixed positioning
bool isRelPositioned() const;  //
relative positioning

Throughout most of the code the term positioned refers toboth absolute and fixed positioned objects in CSS. The termrelPositioned refers to relative positioned objects in CSS.

The render tree has a method for obtaining the containing block ofa renderer.

RenderBlock* containingBlock() const

When an object is marked as needing layout, it walks up acontainer chain setting either the normalChildNeedsLayoutbit or the posChildNeedsLayout bit. The isPositionedstatus of the previous link in the chain determines what bit getsset. The container chain roughly corresponds to the containing blockchain, although intermediate inlines are still dirtied as well. Adifferent method called container is used instead ofcontainingBlock to determine the chain for dirtyingbecause of this distinction.

RenderObject* container() const

layoutIfNeededand setNeedsLayout(false)

The layoutIfNeeded method (similar in terminology toAppKit’s displayIfNeeded method) is a convenient shorthand fortelling a renderer to only do a layout if it has a dirty bit set.

void layoutIfNeeded()

All layout methods typically end with setNeedsLayout(false).It is important to clear dirty bits on the renderer before leavingthe layout method, so that future layout calls won’t mistakenlythink that the object is still dirty.

Anatomyof a Layout Method

At a high level layout methods usually look something like this:

void layout()
{
    ASSERT(needsLayout());
 
    // Determine the width and horizontal margins of this
object.
    ...
 
    for (RenderObject* child = firstChild(); child; child =
child->nextSibling()) {
        // Determine if the child needs to get a relayout
despite the dirty bit not being set.
        ...
 
        // Place the child.
        ...
 
        // Lay out the child
        child->layoutIfNeeded();
 
       ...
    }
 
    // Now the intrinsic height of the object is known because
the children are placed
    // Determine the final height
    ...
 
    setNeedsLayout(false);
}

We will drill into specific layout methods in future articles.

国央企创新负责人如何通过平台提升技术需求挖掘与资源配置的精准性?.docx 国央企创新负责人如何通过平台提升技术需求挖掘与资源配置的精准性? 立即下载

相关推荐

科技中介服务机构在协助企业对接科研成果时,如何提升服务响应速度与专业化水平.docx

科技中介服务机构在协助企业对接科研成果时,如何提升服务响应速度与专业化水平

Blink渲染调试记录Ⅰ

概述 这是本人对Blink渲染的调试记录,调试的Chromium版本为95.0.4638.54 调试入口为"third_party\blink\renderer\core\dom\element.cc",入口函数是2720行的Element::AttachLayoutTree函数。 主要函数 这个函数的主要函数如下所示: void Element::AttachLayoutTree(AttachContext& context) { // 获取CSS样式 const ComputedStyle

qq_45827926的博客 420

国央企创新负责人在推动内部技术成果转化与外部协同创新时,如何实现资源的高效整合与协同联动?.docx

国央企创新负责人在推动内部技术成果转化与外部协同创新时,如何实现资源的高效整合与协同联动?

深入Flutter (一) 积极推进“组合”方式

原文:Inside Flutter Inside Flutter This document describes the inner workings of the Flutter toolkit that make Flutter’s API possible. Because Flutter widgets are built using aggressive composition, user interfaces built with Flutter have a large number of w

m0_53337932的博客 603

机器人入门实战:用 ROS2 和 Gazebo 先把差速车 URDF 跑起来,再做一版 SLAM 建图(含教学手册与源码骨架)

原创教学资源包(VIP专属)。围绕机器人开发项目实战搭建可复现闭环:用差速车 URDF 把 base_link、左右轮和激光连杆的关节树写自洽,配一间教学库房的 Gazebo 世界与 launch 骨架;再提供一版合成二维占用栅格建图,对比纯里程计写入和扫描匹配修正,用来分辨 odom 系漂移与 map 系 SLAM 输出。内含中文实战手册与可 make 抽检的 ROS 2 源码骨架。实现均为教学桩,注释标明不是完整 Navigation2 栈,不能替代实机传感器标定,也不是 Cartographer / slam_toolbox 的生产方案。 使用方法:解压后进入 src/ 目录(需 Linux、Python 3;不必安装 ROS 2 或 Gazebo 也能抽检)。先执行 make clean && make test,或运行 python3 scripts/smoke_test.py,看到 ALL SMOKE TESTS PASSED 后再阅读手册.md、README.md 与源码注释。若本机已安装 ROS 2 Humble/Jazzy 与 Gazebo,再把 src/diffbot_slam_tutor 放入工作空间,按 README 中「读者本地环境再跑」的 launch 命令启动仿真。细节见手册.md 与 src/README_SRC.txt。 适合作为成长任务「机器人开发项目实战」的自制合规 VIP 资源上传。建议售价 9.90 元。模型与数据均为虚构示例,不含刷量、搬运或真实个人信息。

两路半桥LLC谐振变换器软开关Simulink仿真(模拟谐振参数不同、分裂电容)

内容概要:本文介绍了“两路半桥LLC谐振变换器软开关Simulink仿真”资源包,重点在于基于Simulink平台对两路半桥LLC谐振变换器进行高精度建模与动态仿真,特别考虑了谐振参数不一致及分裂电容等非理想工况对系统性能的影响。该仿真模型不仅涵盖了主电路拓扑、软开关实现机制与谐振网络设计,还深入分析了不同参数配置下系统的启动特性、稳态效率、动态响应及软开关条件的满足情况。通过参数扫描与对比仿真,帮助用户掌握LLC变换器的关键设计要素与优化方法,具备较强的工程指导价值和科研教学意义。; 适合人群:电力电子、电气工程及其自动化等相关专业的高校师生,以及从事高频开关电源、新能源变换器、车载充电机等领域的研发工程师和技术人员。; 使用场景及目标:① 掌握两路并联半桥LLC谐振变换器的建模与仿真方法;② 理解软开关技术在提升变换器效率与降低EMI方面的关键作用;③ 分析谐振参数偏差与分裂电容结构对系统均流特性、增益曲线及软开关范围的影响;④ 支持科研项目中的拓扑验证、控制策略开发与故障工况分析; 阅读建议:建议结合Simulink仿真模型与配套说明文档进行学习,重点关注谐振腔参数设置、驱动时序设计及软开关波形观测;可通过调整谐振电感、电容值或引入参数失配,观察系统行为变化,深入理解LLC变换器的稳定边界与优化设计原则。

浏览器是如何工作的(转载)

Preface This comprehensive primer on the internal operations of WebKit and Gecko is the result of much research done by Israeli developer Tali Garsiel. Over a few years, she reviewed all the publish...

少年 1906

双向全桥CLLC谐振变换器仿真模型(Simulink仿真实现)

内容概要:本文系统介绍了双向全桥CLLC谐振变换器的Simulink仿真模型,重点阐述了变频控制、闭环仿真及其与多种电力电子拓扑(如维也纳整流器、DAB变换器、图腾柱PFC等)的联合仿真设计。资源包涵盖2.5kW双向全桥LLC、V2G电动汽车充放电系统、三相PFC、多相交错LLC等多种变换器的仿真案例,并深入展示了三电平VIENNA整流器在双闭环PI控制与SVPWM调制策略下,结合上下电容电压差值补偿实现中点电位平衡的先进控制方法。通过仿真验证,该策略不仅有效维持了800V直流母线电压的稳定,还在动态工况下显著提升了电容电压的均衡度,同时保持了较低的输入电流THD,充分体现了SVPWM与中点平衡控制协同优化的技术优势。; 适合人群:具备电力电子与自动控制理论基础,从事新能源发电、电动汽车、工业电源、微电网等领域的研究生、工程师及科研人员。; 使用场景及目标:① 学习并构建高频谐振变换器(如LLC、CLLC)的Simulink仿真模型,掌握其变频与混合控制策略;② 深入理解并应用中点电位平衡、双闭环PI控制、SVPWM调制等核心技术于VIENNA等三电平变换器中;③ 复现高水平期刊论文中的控制算法,服务于科研项目申报、学术论文撰写或工程产品开发。; 阅读建议:该资源为综合性仿真资料库,建议使用者结合自身研究方向(如电动汽车充电、新能源并网)选择对应案例进行精学,重点关注控制策略的设计逻辑、仿真参数的整定方法以及SVPWM与中点平衡的协同机制,并充分利用附带的计算书和参考文献深化理解,以实现从仿真模型到实际工程应用的顺利转化。

Basic-layout布局

一、基础布局 通过基础的 24 分栏,迅速简便地创建布局。 通过 row 和 col 组件,并通过 col 组件的 span 属性我们就可以自由地组合布局。 &lt;el-row&gt; &lt;el-col :span="24"&gt;&lt;div class="grid-content bg-purple-dark"&gt;&lt;/div&gt;&lt;/el-col&amp

hrbsfdxzhq01的博客 1039

全桥LLC谐振(变频+移相混合控制)变换器闭环仿真模型(Simulink仿真实现)

全桥LLC谐振(变频+移相混合控制)变换器闭环仿真模型(Simulink仿真实现)

虚拟同步发电机(VSG)惯量阻尼自适应控制仿真模型(simulink仿真实现)

内容概要:本文提供了“虚拟同步发电机(VSG)惯量阻尼自适应控制仿真模型”的Simulink仿真实现方法,系统阐述了如何通过仿真手段研究VSG在电力系统中的动态响应特性,重点聚焦于其惯量与阻尼的自适应控制策略。文中详细说明了模型构建流程,涵盖控制算法设计、参数调节、根轨迹分析等内容,并通过对比不同调节系数下的系统响应,深入探讨了控制参数对系统稳定性与动态性能的影响。该仿真模型有效复现了VSG模拟传统同步发电机惯性与阻尼特性的能力,对于提升新能源并网系统的频率稳定性和抗扰动能力具有重要研究价值。; 适合人群:具备电力系统、自动化或相关领域基础知识,从事新能源并网、微电网控制、电力电子与电力系统仿真研究的研究生、科研人员及工程师。; 使用场景及目标:①用于教学与科研中深入理解虚拟同步发电机的工作原理及其在现代电力系统中的应用;②为新能源发电系统接入电网时的稳定性分析与控制策略设计提供仿真验证平台;③支持对VSG控制参数进行优化,提升系统应对负荷波动和扰动的能力。; 阅读建议:建议读者结合Matlab/Simulink软件动手实践,按照文档结构逐步搭建仿真模型,重点关注控制环路设计与参数整定部分,同时参考提供的代码与仿真结果进行对比分析,以加深对VSG自适应控制机制的理解。

1023 -- iOS之CALayer类

这个就真的是属性方法太多了,而且很多不经常用,就不一一翻译了,之前那些翻译也没有时间写使用总结,还有避坑,有时间再搞了。只翻译用到的属性和方法就好了,其实这个就是UIView的数据源,而且动画都要用到这些数据,具体哪些我也不知道啊,还没看啊,有一些官网文档是需要看的。 需要阅读的文档: ...

qq_30185503的博客 572

两相交错并联Boost电路仿真模型(Simulink仿真实现)

内容概要:本文介绍了“两相交错并联Boost电路仿真模型(Simulink仿真实现)”的技术资源,属于电力电子变换器领域的仿真研究内容。该模型基于Simulink平台构建,旨在深入分析两相交错并联Boost电路的工作原理、动态响应特性及控制策略。交错并联结构通过错开各相开关管的导通时刻,有效降低输入电流纹波、提升系统效率与功率密度,适用于中高功率DC-DC变换应用场景。资源包含完整的主电路建模、PWM驱动信号生成、闭环控制器设计(如电压/电流双闭环控制)等关键模块,并可能涵盖软启动、均流控制等关键技术问题。整个仿真模型强调理论分析与工程实践的紧密结合,不仅有助于理解电路基本行为,也为优化控制算法提供验证平台,服务于科研与教学需求。; 适合人群:电气工程、自动化、电力电子及相关专业的高校本科生、研究生,以及从事电源系统研发的工程技术人员,具备一定的电路理论、自动控制原理和Simulink仿真基础者更佳。; 使用场景及目标:① 学习和掌握两相交错并联Boost电路的拓扑结构、工作机理及性能优势;② 利用Simulink进行电力电子电路的建模与仿真,深入理解PWM控制、闭环调节、均流控制等核心技术的应用;③ 为科研项目、课程设计或毕业设计提供可复用的仿真案例和技术支持,辅助开展中高功率电源系统的创新设计与优化研究。; 阅读建议:建议结合Simulink软件动手搭建并调试模型,通过调整占空比、开关频率、电感参数等变量,观察其对输入电流纹波、输出电压稳定性及动态响应的影响,以深化对电路特性的理解;同时可参考文中列出的其他相关资源(如LLC、PFC等仿真模型)进行横向对比学习,拓宽电力电子系统设计视野。

uiautomator2使用教程

UiAutomator是Google提供的用来做安卓自动化测试的一个Java库,基于Accessibility服务。功能很强,可以对第三方App进行测试,获取屏幕上任意一个APP的任意一个控件属性,并对其进行任意操作,但有两个缺点:1. 测试脚本只能使用Java语言 2. 测试脚本要打包成jar或者apk包上传到设备上才能运行。 我们希望测试逻辑能够用Python编写,能够在电脑上运行的时候就控制...

weixin_43709411的博客 1万+

区域电网含风光火压缩空气储能抽水蓄能以及电化学储能的联合调度,加入IEEE39系统,进行潮流计算,分析电能质量研究(Matlab代码实现)

内容概要:本文研究了包含风能、太阳能、火电以及压缩空气储能、抽水蓄能和电化学储能等多种能源形式的区域电网联合调度问题,通过将系统接入IEEE 39节点标准测试系统,利用Matlab平台开展潮流计算与电能质量分析,旨在提升高比例可再生能源接入背景下电网运行的稳定性与供电品质。研究重点涵盖多类型电源与多种储能系统的协调优化调度策略设计,深入探讨储能系统在削峰填谷、平滑新能源出力波动方面的关键作用,并对复杂运行工况下电压偏差、频率波动、谐波污染等电能质量问题进行评估与改善。通过构建完整的仿真模型,系统性地分析了联合调度对电网电能质量的影响机制,为现代电力系统中多能互补与协同控制提供了理论依据和技术参考。; 适合人群:具备电力系统分析、优化调度及电能质量相关基础知识,熟悉Matlab/Simulink仿真环境的研究生、科研人员及电力系统相关领域的工程师。; 使用场景及目标:①为含多种储能的区域电网联合调度研究提供完整的Matlab仿真案例与开源代码参考;②分析大规模新能源接入对IEEE 39系统潮流分布及电能质量的综合影响,并定量评估不同类型储能系统的调控效果;③为电力系统优化调度、电能质量综合治理、多能协同控制等学术研究与工程项目提供可复现的技术支撑与解决方案。; 阅读建议:本资源以Matlab代码实现为核心,读者应在掌握电力系统基本理论的基础上,重点关注联合调度的数学建模过程、储能系统充放电策略的制定逻辑以及电能质量各项评价指标的计算方法。建议在学习过程中动手调试仿真代码,尝试调整系统参数、优化目标权重或改变新能源渗透率,以深入理解系统动态行为与控制策略的有效性。

2026最新基于Aria2下载器解决百度网盘限速问题

Aria下载器

上一篇: blink渲染知识三- blocking and inlines
下一篇: blink渲染知识5 - absulte/fixed and relative positioning
csshell2002
博客等级 码龄11年 30粉丝 41原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值