blink渲染知识(二) - webcore rendering basics

Dom tree和Rendertree是独立的tree.

Render tree由renderobject构成,并且renderobject并不和DOMnode一一对应。有些dommode可能没有renderobject.比如有些节点的css属性标记为display:none不显示。

Domtree的节点可以通过renderer()函数得到对应的rendertree中的renderObject节点。

Renderer是通过对domtree的节点执行attach操作创建的。

attach的过程中,计算一个dom节点的cssstyle信息,生成一个RenderStyle对象,并设置到新建立的renderObject里面。

Attach是从上到下的递归过程,从父节点开始。

当一个dom节点从domtree中移除或者document关闭时,需要将对应的renderObjectdestroy掉,这个过程靠dom节点的detach操作完成,detach是从下到上的过程,先把childdetach,然后再detach父节点。Detach也是断开renderer和dom节点关联的过程。

RenderBox继承自RenderObject,但是表示的是遵守cssbox model的renderer.

Css box model:

http://www.w3.org/TR/CSS21/box.html#box-dimensions






renderStyle对象里取得的css属性一般只是初始的css设置,而实际物体的尺寸可能已经动态改变了。

如果有scroolbar,那么scroollbar位于border区域和padding区域之间,属于client区域,但不属于content区域。

Box模型的坐标都是相对父亲的相对坐标



attach的图:





This is the first of a series of posts designed to help peopleinterested in hacking on WebCore’s rendering system. I’ll beposting these articles as I finish them on this blog, and they willalso be available in the documentation section of the Web site.

TheDOM Tree

A Web page is parsed into a tree of nodes called the DocumentObject Model (DOM for short). The base class for all nodes in thetree isNode.

Node.h

Nodes break down into several categories. The node types that arerelevant to the rendering code are:

  • Document – The root of the tree is always the document.There are three document classes,Document,HTMLDocument and SVGDocument. The first isused for all XML documents other than SVG documents. The secondapplies only to HTML documents and inherits fromDocument.
    Thethird applies to SVG documents and also inherits from Document.

    Document.h
    HTMLDocument.h

  • Elements – All of the tags that occur in HTML or XML sourceturn into elements. From a rendering perspective, an element is anode with a tag name that can be used to cast to a specific subclassthat can be queried for data that the renderer needs.

    Element.h

  • Text – Raw text that occurs in between elements gets turnedinto text nodes. Text nodes store this raw text, and the render treecan query the node for its character data.

    Text.h

TheRender Tree

At the heart of rendering is the render tree. The render tree isvery similar to the DOM in that it is a tree of objects, where eachobject can correspond to the document, elements or text nodes. Therender tree can also contain additional objects that have nocorresponding DOM node.

The base class of all render tree nodes is RenderObject.

RenderObject.h

The RenderObject for a DOM node can be obtained usingthe renderer() method onNode.

RenderObject* renderer() const

The following methods are most commonly used to walk the rendertree.

RenderObject* firstChild() const;
RenderObject* lastChild() const;
RenderObject* previousSibling() const;
RenderObject* nextSibling() const;

Here is an example of a loop that walks a renderer’s immediatechildren. This is the most common walk that occurs in the render treecode.

for (RenderObject* child = firstChild(); child; child =
child->nextSibling()) {
    ...
}
Creatingthe Render Tree

Renderers are created through a process on the DOM calledattachment. As a document is parsed and DOM nodes are added, amethod calledattach gets called on the DOM nodes to createthe renderers.

void attach()

The attach method computes style information for the DOM node. Ifthe display CSS property for the element is set tononeor if the node is a descendant of an element with display: noneset, then no renderer will be created. The subclass of the node andthe CSS display property value are used together to determine whatkind of renderer to make for the node.

Attach is a top down recursiveoperation. A parent node will always have its renderer createdbefore any of its descendants will have their renderers created.

Destroyingthe Render Tree

Renderers are destroyed when DOM nodes are removed from thedocument or when the document gets torn down (e.g., because thetab/window it was in got closed).Amethod called detachgets called on the DOM nodes to disconnect and destroy the renderers.

void detach()

Detachment is a bottom uprecursive operation. Descendant nodes will always have theirrenderers destroyed before a parent destroys its renderer.

AccessingStyle Information

During attachment the DOM queries CSS to obtain style informationfor an element. The resultant information is stored in an objectcalled aRenderStyle.

RenderStyle.h

Every single CSS property that WebKit supports can be queried viathis object. RenderStyles are reference counted objects. If a DOMnode creates a renderer, then it connects the style information tothat renderer using thesetStyle method on the renderer.

void setStyle(RenderStyle*)

The renderer adds a reference to the style that it will maintainuntil it either gets a new style or gets destroyed.

The RenderStyle can be accessed from a RenderObjectusing thestyle() method.

RenderStyle* style() const

TheCSS Box Model

One of the principal workhorse subclasses of RenderObjectis RenderBox. This subclass represents objects that obeythe CSS box model. These include any objects that have borders,padding, margins, width and height. Right now some objects that donot follow the CSS box model (e.g., SVG objects) still subclass fromRenderBox. This is actually a mistake that will be fixedin the future through refactoring of the render tree.

Thisdiagram from the CSS2.1 spec illustrates the parts of a CSS box.The following methods can be used to obtain the border/margin/paddingwidths.The RenderStyleshould not be used unless the intent is to look at the original rawstyle information, since what is actually computed for theRenderObjectcould be very different (especially for tables, which can overridecell padding and have collapsed borders between cells).

int marginTop() const;
int marginBottom() const;
int marginLeft() const;
int marginRight() const;
 
int paddingTop() const;
int paddingBottom() const;
int paddingLeft() const;
int paddingRight() const;
 
int borderTop() const;
int borderBottom() const;
int borderLeft() const;
int borderRight() const;

The width() and height() methods givethe width and height of the box including its borders.

int width() const;
int height() const;

The client box is the area of the box excluding borders andscrollbars. Padding is included.

int clientLeft() const { return borderLeft(); }
int clientTop() const { return borderTop(); }
int clientWidth() const;
int clientHeight() const;

The term content box is used to describe the area of theCSS box that excludes the borders and padding.

IntRect contentBox() const;
int contentWidth() const { return clientWidth() - paddingLeft()
- paddingRight(); }
int contentHeight() const { return
clientHeight() - paddingTop() - paddingBottom(); }

When a box has a horizontal orvertical scrollbar, it is placed in between the border and thepadding. A scrollbar’s size is included in the client width andclient height. Scrollbars are not part of the content box. Thesize of the scrollable area and the current scroll position can bothbe obtained from theRenderObject. I will cover this inmore detail in a separate section on scrolling.

int scrollLeft() const;
int scrollTop() const;
int scrollWidth() const;
int scrollHeight() const;

Boxes also have x and ypositions. These positions are relative to the ancestor that isresponsible for deciding where this box should be placed.Thereare numerous exceptions to this rule, however, and this is one of themost confusing areas of the render tree.

int xPos() const;
int yPos() const;



Chrome内核解析 -- 背景篇:Chromium/Blink的工作流程 转载请注明出处:http://blog.youkuaiyun.com/yunchao_he/article/details/41697489 本节简单介绍Chromium/Blink绘制页面的工作流程。用户点击链接或输入网址,到最终显示网页内容,经历了以下几个重要步骤: Chromium的启动和资源加载:网页本身(比如index.html),以及它所指向的图片,音视频文件,和它包含的其它网页(HTML, CSS, JavaScript文件)及这些网页里的图片和音 阅读详情

相关推荐

miRNA测序数据生信分析——第一讲,总结概述

这里的miRNA测序指转录水平的测序。这里每一个数据库都可以在线访问,但是如果要本地使用,都需要进行数据库文件下载,整理。

weixin_44616693的博客 4956

WebCore Rendering I --- the basic

原文:http://www.webkit.org/blog/114/webcore-rendering-i-the-basics/ 一下是翻译版本,后面还有对照版本。  这是一系列文章中的第一篇,目的是帮助那些对WebCore rendering有兴趣的人们。 当完成这些文章

bertzhang的专栏 1821

LaTeX小白必看:5分钟搞定GB/T 7714-2005参考文献格式(Texmaker+BibTeX实战)

本文为LaTeX初学者提供了使用Texmaker编辑器和BibTeX工具链,快速实现GB/T 7714-2005参考文献格式的实战指南。文章详细解析了从获取gbt7714-2005.bst样式文件、编写.bib数据库到四步编译流程的核心步骤,并附有常见问题解决方案,帮助用户高效、准确地完成学术论文的参考文献排版。

weixin_29295541的博客 338

wml

for VC 1.WebKitLibraries\win\tools\vsprops    FeatureDefines.vsprops Name="ENABLE_WML" Value="ENABLE_WML" PerformEnvironmentSet="true" /> 2.WebCore DerivedSource.cpp remove #include "WMLEle

elfylin的专栏 1142

共模电感在EMI滤波中的实战应用与设计技巧

本文深入探讨了共模电感在EMI滤波中的关键作用与设计技巧,涵盖电感值选择、饱和电流风险、磁芯材料性能及绕组工艺等实战经验。通过具体案例解析,展示了共模电感在开关电源、高速接口及汽车电子中的高效应用,帮助工程师解决电磁兼容问题并提升信号完整性。

weixin_27051161的博客 419

stm32H743IIT6 cubemx HAL USB UVC摄像头基础

stm32性能已经很强了, 可以驱动ov5640摄像头, 所以可以把摄像头接在stm32上, 当作一个摄像头驱动器, 连接到电脑上 开发环境: stm32cubemx 6.0.1 单片机: 自己做的stm32h743iit6核心板,兼容正点原子 学习资料: 圈圈学USB 鱼鹰谈单片机 从零开始学习USBhttps://to-run-away.blog.youkuaiyun.com/article/details/85038393 整个项目是基于CDC串口上修改 1 stm32 USB 代码概览 ..

紫枫洛天的博客 7754

webkit内核分析之 Frame

参考地址:http://blog.youkuaiyun.com/dlmu2001/article/details/6164873 1.    描述 Frame类是WebCore内核同应用之间联系的一个重要的类。它有点像设计模式中的Façade,将内核的各个不同的零配件组装在了一起,但又不是Façade,因为用户很多时候还是要直接去操作里面的组件。除了设计上的考虑,Frame还有语法上的意义,它对应于Pag...

weixin_34150503的博客 455

【图像超分】论文精读:RepSR: Training Efficient VGG-style Super-Resolution Networks with Structural Re-Paramete

摘要: 本文提出RepSR,一种基于结构重新参数化和批量归一化(BN)的高效VGG式超分辨率网络。针对SR任务中BN易引发伪影的问题,作者通过分析发现训练-测试阶段的不一致性是主因,并提出先使用小批量统计训练、后期切换为总体统计的优化策略。RepSR块设计包含干净的残差路径和带改进BN的扩展-压缩卷积路径,有效平衡了训练非线性与推理效率。实验表明,RepSR在不同模型规模下优于现有重参数化方法,且实际推理速度更快。该工作为SR提供了性能与效率兼优的解决方案,相关代码未开源。 关键词: 超分辨率、结构重参数化

主要更新底层视觉(去噪、超分等)相关的科研内容,形式为【论文精读】+【论文复现】 306

Webkit自带谷歌浏览器实例分析(1)

这个程序是用source insight阅读的,,,source insight怎一个强字了得?!从main函数开始分析:intmain (int argc, char* argv[]){    gtk_init (&argc, &argv);       /*初始化gtk整个实例,每个gtk中必有的*/    if (!g_thread_supported ())        g_thread_init (NULL);GtkWidget* vbox = gtk_vbox_new (FALSE, 0); 

743

python全栈入门到实战【基础篇 03】入门实操:第一个Python程序 + PyCharm使用 + 输入输出全解析

本文是一篇Python入门教程,主要介绍PyCharm编辑器的安装配置和基础使用,以及Python输入输出语法的实操练习。文章分为四个部分:1)PyCharm的下载安装与基础配置;2)第一个Python程序"Hello World"的编写与运行;3)Python输入输出函数print()和input()的详细讲解;4)个人信息录入系统的实战案例。教程包含大量截图和动图演示,适合Python新手跟随操作,快速掌握编辑器使用和基础语法。

那些看似不起波澜的日复一日,会在某天让你看到坚持的意义 4034

【数据集】中国2003年至2022年全天空每日气温数据集

中国2003年至2022年全天空每日气温数据集

WW、forever的博客 604

Webkit生成一个render节点的过程

Webkit如何生成一个render节点 生成Element: 首先通过解析一个HTML文件,解析出一个tag, 然后通过tag生成HTMLElemen节点,调用堆栈如下:   0# HEMLSelectElement (HTMLSelectElement.cpp) 1# HTMLSelectElement::create (同上) 2# selectConstr

arrowyi_gbd的专栏 742

Open3D (C++) 点云边界提取【2025最新版】

Compute the boundary points of a point cloud.The implementation is inspired by the PCL implementation. Reference:https://pointclouds.org/documentation/classpcl_1_1_boundary_estimation.html

点云侠的博客 872

WebKit之WebCore篇

<br />转自: 浅谈WebKi谈WebKit之WWebKit之WebCore篇 <br /> <br />1、从源代码目录结构来看<br /> WebCore目录主要包括如下目录:<br />bindings 包含将Dom Binding给JavascriptCore方面的代码,同时包含依据idl接口描述文件,自动生成对应于JavascriptCore的Binding实现的脚本等内容;<br /><br />bridge 主要包含NPPlugin方面的接口访问等内容;<br /><br />c

leeeryan 3941

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

谷歌浏览器的源码分析(34)

通过上一次的分析,我们看到所有网页数据经过HTML分析器之后,都会变成一个一个RenderObject对象,那么这些RenderObject对象又是怎么样显示到界面上面的呢?现在就带着这个疑问来分析下面的代码,这样肯定会找到解决方法的。怎么样找到入口呢?其实可以先从界面显示的类开始,可以看到显示界面的窗口类名称叫做Chrome_RenderWidgetHostHWND,有了这个类名称,就...

anjichan4261的博客 613

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

webkit源码解读-FileList

FileList是文件组件的表示形式,是一个包装了系列File对象的对象。里面通过vector保持多个文件对象。class FileList : public ScriptWrappable, public RefCounted<FileList> { public: // 需要用create创建该类对象 static Ref<FileList> create() { /

标子 的专栏 707

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

blink渲染知识10 - render tree的构建点

何时在哪里thread构建的,先找到构建rendertree的code. 有RenderTreeBuilder类。 上面1.16rendering basics中讲了,RenderTree是通过对dom节点执行attach操作建立的。在dom被建立时,对其节点执行attach操作,即可创建renderobject, 建立rendertree. 当docuemnt关闭,或从dom中移除一个节

421

blink渲染知识(一)

http://dev.chromium.org/developers/design-documents/gpu-accelerated-compositing-in-chrome 4大trees: TheDOM tree, whichis our fundamental retained model TheRenderObject tree,which has a 1:1m

1082

blink渲染知识14 - 阶段总结

总结一下执行流程。 4.5.0上,ui线程,impl线程就是执行childcompositor的ui线程。 1.ui 线程onDraw=>awContents.onDraw会调用chilidcompositor来使用其activelayer tree合成一个compositorframe,也就是调用BrowserViewRender::onDrawHW.并向webcore

519

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

WebKit/Blink 渲染网页的主要步骤

1.  发送网络资源请求。      WebKit在渲染网页之前,首先需要从网络上下载资源文件,这里把资源文件分为两类,一类称为主资源文件,比如Frame,另外一类成为子资源文件,比如图片,JavaScript脚本,CSS脚本,字体,音频视频文件等等。以前WebKit在加载这两种资源文件时采用不同的路径,主资源文件通过DocumentLoader类来加载,子资源文件通过DocLoader类来加载

HTML5, Chromium和WebKit技术 3783

blink渲染知识12 - 硬件渲染之触发beginframe

ThreadProxy::BeginMainFrame会触发renderlayer tree中各layer的paint.那么谁触发的BeginMainFrame? ThreadProxy::ScheduledActionSendBeginMainFrame -> Proxy::MainThreadTaskRunner()->PostTask( FROM_HERE, base::

1304

blink渲染知识11 - renderlayer tree的构建点

在收到了数据后,网页加载完成,创建rendertree时,也会对应创建renderlayer. 创建renderlayer的Callstack: #0 WebCore::RenderLayer::RenderLayer (this=0x69014000,renderer=0x69004000, type=) at../../third_party/WebKit/Source/cor

477

Chromium Blink项目最新技术报告和下一步发展方向

摘要:BlinkOn3会议11月份刚在Google的MountainView办公地点举行,本文选取了BlinkOn3的几个话题,如为Blink绘图瘦身的SlimmingPaint,多优先级的Blink调度器,Oilpan垃圾回收机制,用JavaScript开发新的DOM特性等等,和大家一起分享Blink项目目前取得的进展和下一步发展方向。

Chromium技术分享 7022

【无线传感网】Blink组件的学习

CTP(Collection Tree Protocol)是TinyOS中的一种组件,用于无线传感网络中数据收集和传输,主要用作数据聚集、时间同步、路由和排队等方面。该协议在TinyOS中有多个不同版本的实现,包括原生版本、Adaptive CTP和Collection Tree Protocol Lite等。以下是CTP组件中一些重要的功能介绍:**数据聚集:**CTP允许无线传感节点将数据聚集到父节点或协调节点,从而减少网络流量和能源消耗。

m0_75045191的博客 1587

blink渲染知识8 - 软渲染

我觉的软件渲染的关键点:ui线程软件raster,并且软件合成。 http://blog.youkuaiyun.com/hongbomin/article/details/17931223 摘要 渲染过程可以形象地理解为用一支笔将特定的内容在一张纸上画出来,然后呈现在屏幕上,而对笔和纸张的选择决定了渲染的方式。在Chromiumon Android: 认识ChromiumWebView一文中我们提到

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

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值