为什么Internet Explorer需要“hasLayout”旗? [英] Why does Internet Explorer need the "hasLayout" flag?

查看:142
本文介绍了为什么Internet Explorer需要“hasLayout”旗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像许多开发者在网站上使用Internet Explorer一样,我似乎遇到了许多由臭名昭着的 hasLayout 标志

Like many developers working on web sites for Internet Explorer, I seem to come across a lot of bugs that are caused by the notorious hasLayout flag.

我明白这个标志做什么,它是如何工作的(大部分)。一个很好的解释我读的另一天(虽然我找不到源)是 hasLayout 在IE中基本上意味着使这个元素一个矩形。

I understand what this flag does and how it works (for the most part). A good explanation I read the other day (although I can't find the source) is that hasLayout in IE essentially means "Make this element a rectangle."

这显然比这更复杂,但很好地总结了这一点(在我看来)。

It's obviously more complicated than that, but it's pretty well summed up with that (in my opinion).

不明白是为什么浏览器使用这个标志。当找到一个答案,我发现一个听起来合乎逻辑:

What I don't understand is why the browser uses this flag. When looking for an answer, I found one that sounded logical:


Internet Explorer必须处理非常旧的旧代码从CSS之前如火如荼。作为使浏览器容易添加CSS的架构决定,使用 hasLayout 标志来触发某些CSS属性,以便页面正确呈现。这可以追溯到IE4的时间。

Internet Explorer had to deal with very old legacy code from before CSS was really in full swing. As an architectural decision to make the browser easy to add CSS on to it, the hasLayout flag was used to trigger certain CSS properties so the page would be rendered correctly. This dates back to around the time of IE4.

这对我来说几乎是有意义的,直到我意识到Firefox )不得不处理同样的问题。 Netscape已经存在几乎只要Internet Explorer,但它不需要任何内部 hasLayout 标志,或任何类似,据我所知。

This almost made sense to me, until I realized that Firefox (Netscape at the time) had to deal with the same problem. Netscape has been around for pretty much as long as Internet Explorer, however it doesn't need any internal hasLayout flag, or anything similar,as far as I know.

看到 hasLayout 标志是如何在Internet Explorer中的许多错误的来源,有没有人知道为什么IE有这个标志和其他浏览器不需要它?

Seeing as how the hasLayout flag is the source of so many bugs in Internet Explorer, does anyone know why IE has this flag and other browsers don't need it?

这是我想知道纯粹出于好奇,如果任何人有任何理论或恰好知道答案。我想更多地了解为什么(或为什么不)这个标志是有用的。

This is something I'd like to know purely out of curiosity if anyone has any theories or happens to know the answer. I'd like to understand more about why (or why not) this flag is useful.

推荐答案

Netscape渲染器完全重新写后NS4。 IE的Trident渲染引擎没有这样的爱。此有良好的商业意义 - IE在重写期间持续提高增量,部分是因为这一点(并且部分是因为它的分配安排...)设法捕获市场的巨大份额...

The Netscape renderer was completely re-written post-NS4. IE's "Trident" rendering engine got no such love. This made good business sense - IE continued to improve incrementally while NS was being re-written, and partially because of this (and partially because of its distribution arrangement...) managed to capture a huge share of the market...

但最终结果是一个旧的,繁琐的代码库,为开发人员带来了生命,因此必须痛苦地意识到应该隐藏的实现细节。

But the end result is an old, crufty codebase which makes life hell for developers, who must consequently be painfully aware of what should be hidden implementation details.

最后一点是关键:浏览器的渲染器是一个抽象,允许您在几行标记中创建一些东西,这将需要数百或数千行低级渲染和事件处理代码。像所有的编程抽象,它泄漏一点...这是真的IE,Netscape,Firefox,Opera,Webkit ...每个浏览器都有开发者工作狂热以堵塞抽象中的泄漏。除了五年,IE没有。 其他泄漏已被插入,但呈现引擎变得越来越像筛子。

Now, that last point is key: a browser's renderer is an abstraction, allowing you to create in a few lines of markup something that would take hundreds or thousands of lines of low-level rendering and event-handling code. And like all programming abstractions, it leaks a bit... This is true for IE, Netscape, Firefox, Opera, Webkit... And each browser has developers working feverishly to plug the leaks in the abstractions. Except, for five years, IE did not. Other leaks were plugged, but the rendering engine became more and more sieve-like.

这些因素共同导致暴露 hasLayout

Together, these to factors conspire to expose things like hasLayout.

这篇关于为什么Internet Explorer需要“hasLayout”旗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆