首页 > 编程语言 >[Javascript] Rendering process

[Javascript] Rendering process

时间:2023-06-11 18:13:34浏览次数:43  
标签:elements like render DOM process Javascript tree Rendering nodes

 

DOM (Documnet Object Model) Tree:

When a web page is loaded, the browser reads the HTML and builds the DOM tree. The DOM is a tree-like structure that represents the content of the webpage. Each HTML tag becomes a node in the tree, and these nodes can have child nodes based on the HTML nesting. 

 

CSSOM (CSS Object Model) Tree:

Parallel to the construction of the DOM, the browser also builds the CSSOM tree. This is another tree-like structure that is built by reading the CSS styles that apply to the webpage. Each CSS rule becomes a part of this tree, which is used to determine how the nodes in the DOM should be styled.

 

Render Tree:

Once the browser has both the DOM and CSSOM trees, it combines them into the render tree. The render tree includes all the visual DOM nodes from the DOM tree along with their respective styles from the CSSOM. It doesn't include non-visual nodes like <head>, <script>, and <meta> or nodes that are hidden via CSS (like elements with display: none)

 

Layout (or Reflow):

After the render tree is built, the browser goes through a "layout" process, sometimes called "reflow". In this step, the browser calculates the exact position and size each node in the render tree should have on the screen. It takes into account the viewport size, the position and size of all elements, and how they interact with each other.

 

Painting:

After the layout phase, the browser "paints" the render tree, turning each node into actual pixels on the screen. This involves drawing out text, colors, images, borders, and shadows, basically every visual part of the elements

Compositing:

Some elements have special styles like transform or opacity that can be layered separately onto the page. After painting, these elements are composited onto the page, meaning they are drawn over the top of the other elements.

 

Displaying Page:

The final output after all these steps is a pixel-perfect webpage displayed on your screen.

 

Answer: D

A: Wrong, because Render tree doesn't contain all the elements, not include non-visible elements or `::before` & `::after` elements.

B: Not just based on z-index, Compositing is the process of layering painted elements (or 'layers') onto the screen to create the final visual output. Compositing does take into account the stacking context (which z-index is a part of), but it also considers other CSS properties like opacity, transformations (like rotate or scale), and certain types of filters.

C: Painting consider color, layout doesn't.

E: None-visible elements are in the DOM tree, just not in the render tree.

标签:elements,like,render,DOM,process,Javascript,tree,Rendering,nodes
From: https://www.cnblogs.com/Answer1215/p/17473295.html

相关文章

  • [Javascript] async / defer
     normalscript,withoutasyncdefer:Scriptfetchedandexecutedimmediately,beforebrowsercontinuesparsingthepage(ItstopsHTMLparsing).Ifthescriptislarge,thiscancausenoticeabledelaysinpageloading. async:Scriptisfetchedasynchr......
  • Python使用multiprocessing实现一个最简单的分布式作业调度系统
    介绍Python的multiprocessing模块不但支持多进程,其中managers子模块还支持把多进程分布到多台机器上。一个服务进程可以作为调度者,将任务分布到其他多个机器的多个进程中,依靠网络通信。想到这,就在想是不是可以使用此模块来实现一个简单的作业调度系统。实现Job首先创建一个Job类,为......
  • JavaScript模块化实现方式详解
    前言JavaScript是一门非常灵活的编程语言,但是在开发大型应用时,代码的组织和管理变得非常重要。为了解决这个问题,JavaScript社区提出了模块化的概念。模块化可以将代码分割成小的、独立的模块,每个模块只关注自己的功能,这样可以提高代码的可维护性和可重用性。在JavaScript中,有多种......
  • Odoo 通过Javascript调用模型中自定义方法
    实践环境Odoo14.0-20221212(CommunityEdition)代码实现在js脚本函数中调用模型中自定义方法:this._rpc({model:'demo.wizard',//模型名称,即模型类定义中_name的值method:'action_select_records_via_checkbox',//模型中自定义名称args:['arg_value......
  • JavaScript学习笔记:Web安全模型
    为了保证安全,浏览器中的JavaScript不能读写设备中的文件,也不能访问任意的服务器。同源策略同源策略指的是脚本只能访问与包含它的文档同源资源。源是指文档URL中的协议、主机与端口部分,完全相同则是同源,任意一项不同都不是同源。脚本文件的URL与同源策略毫不相干,同源策略至于......
  • JavaScript学习笔记:客户端编程之异常处理
    未被捕获的异常在程序中,往往会出现异常。虽然主动捕获这些异常是保证程序健壮的必要做法,但是难免会漏掉一些。对于未被捕获的异常,浏览器会在控制台显示一条错误信息,该信息包含异常信息和其在代码中出现的位置。window.onerrorWindow对象有一个onerror属性,将其指定为一个函数,可......
  • Shellcode Execution in a Local Process with QueueUserAPC and NtTestAlert(nim学习
    ShellcodeExecutioninaLocalProcesswithQueueUserAPCandNtTestAlertAPC队列异步过程调用(APC)队列是一个与线程关联的队列,用于存储要在该线程上下文中异步执行的函数。操作系统内核会跟踪每个线程的APC队列,并在适当的时机触发队列中挂起的函数。APC队列通常用于实现线......
  • javascript简单介绍
    javaScript简介介绍:一种弱类型世界上最流行的脚本语言,其源代码不需要经过编译,而是由浏览器直接运行,控制网页的行为。表现层CSScss层叠样式表是一门标记语言,并不是编程语言,因此不能进行自定义变量,不可以引用等,就是不具备任何语法支持。前端人员提供了一种css的预处理器,提供css......
  • jenkins中的坑_CreateProcess error=1392
    环境:windows11,jdk1.8,jenkins_2.346.war起因最近在使用jenkins部署项目的时候,填写仓库的url地址时,发现填完后报500这个错误,于是我打开jenkins的控制台,发现了这个报错,***java.io.IOException:CreateProcesserror=1392,文件或目录损坏且无法读取。***我就把这个错误信息去百度......
  • JavaScript 构造器模式:创建可重用的对象
    前言JavaScript是一种基于对象的语言,对象是JavaScript中最重要的概念之一。在JavaScript中,我们可以使用构造器模式来创建可重用的对象。本文将介绍JavaScript构造器模式的概念、用法和实例,并给出博客标题《JavaScript构造器模式:创建可重用的对象》。构造器模式构造器模......