惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
雷峰网
雷峰网
Recent Announcements
Recent Announcements
月光博客
月光博客
G
Google Developers Blog
腾讯CDC
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
T
Tenable Blog
云风的 BLOG
云风的 BLOG
W
WeLiveSecurity
博客园 - 【当耐特】
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 聂微东
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
P
Privacy International News Feed
MyScale Blog
MyScale Blog
K
Kaspersky official blog
T
The Blog of Author Tim Ferriss
Attack and Defense Labs
Attack and Defense Labs
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
aimingoo的专栏
aimingoo的专栏
I
Intezer
Vercel News
Vercel News
小众软件
小众软件
Simon Willison's Weblog
Simon Willison's Weblog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
Netflix TechBlog - Medium
P
Proofpoint News Feed
Latest news
Latest news
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tor Project blog
S
Security Affairs
P
Proofpoint News Feed
博客园 - 三生石上(FineUI控件)
博客园 - Franky
C
Cyber Attacks, Cyber Crime and Cyber Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
美团技术团队
Recent Commits to openclaw:main
Recent Commits to openclaw:main
S
Security @ Cisco Blogs
L
LINUX DO - 热门话题
Know Your Adversary
Know Your Adversary
Project Zero
Project Zero
D
Docker
L
Lohrmann on Cybersecurity
F
Full Disclosure

David Baron's Weblog

Software engineering, responsibility, and ownership Software engineering, responsibility, and ownership David Baron's weblog: Security and Inequality Running animations on the compositor thread David Baron's weblog: Tying ecosystems through browsers David Baron's weblog: Payments on the Web Thoughts on migrating to a secure Web David Baron's weblog: The need for government David Baron's weblog: Priority of constituencies How browser developers should seek feedback from Web developers A possible approach to shorter release cycles David Baron's weblog: Fifteen years Why debug builds (and assertions) are important Ten years of the Mozilla Foundation Open licensing at the W3C Why adding compositing and blending to CSS is harder than it looks How you can help with removing -moz- prefixes Moving bug history out of the primary display of a bug report Beware of locale-specific behavior in the C library Eating dogfood and shipping software Specification style and the future of the Web The bug system I wish I had CSS border-image changes and unprefixing Improving font size readability on Firefox for Android David Baron's weblog: CSS Animations, part 2 Hue-preserving color inversion with SVG filters Changes to handling of @-moz-keyframes David Baron's weblog: window.matchMedia() David Baron's weblog: CSS Animations What does a blur radius mean? Crash analysis in the future David Baron's weblog: calc() David Baron's weblog: colorDepth The most important field in a bug report: the summary WOFF font format submitted to W3C David Baron's weblog: :-moz-any() selector grouping setTimeout with a shorter delay Faster repainting in SVG foreignObject David Baron's weblog: Distributed Extensibility David Baron's weblog: Broadening crash analysis Correlating crashes with binary extensions or plugins David Baron's weblog: ex-HTML Downloadable font formats for the Web Web Accessibility as a Political Movement David Baron's weblog: CSS priorities David Baron's weblog: Bug priorities David Baron's weblog: Semi-vacation Some new CSS features in Firefox 3 David Baron's weblog: New selectors David Baron's weblog: The age of bugs Seeking a good Linux distribution David Baron's weblog: Teaching to the test David Baron's weblog: March 2008 David Baron's weblog: February 2008 David Baron's weblog: January 2008 David Baron's weblog: October 2007 David Baron's weblog: September 2007 David Baron's weblog: August 2007 David Baron's weblog: June 2007 David Baron's weblog: April 2007 David Baron's weblog: March 2007 David Baron's weblog: January 2007 David Baron's weblog: September 2006 David Baron's weblog: August 2006 David Baron's weblog: July 2006 David Baron's weblog: May 2006 David Baron's weblog: February 2006 David Baron's weblog: January 2006 David Baron's weblog: December 2005 David Baron's weblog: October 2005 David Baron's weblog: September 2005 David Baron's weblog: June 2005 David Baron's weblog: May 2005 David Baron's weblog: April 2005 David Baron's weblog: March 2005 David Baron's weblog: February 2005 David Baron's weblog: October 2004 David Baron's weblog: September 2004 David Baron's weblog: August 2004 David Baron's weblog: June 2004 David Baron's weblog: May 2004 David Baron's weblog: April 2004 David Baron's weblog: March 2004 David Baron's weblog: February 2004 David Baron's weblog: January 2004 David Baron's weblog: November 2003 David Baron's weblog: October 2003 David Baron's weblog: September 2003 David Baron's weblog: August 2003 David Baron's weblog: July 2003 David Baron's weblog: June 2003 David Baron's weblog: May 2003 David Baron's weblog: April 2003 David Baron's weblog: March 2003 David Baron's weblog: February 2003 David Baron's weblog: January 2003 David Baron's weblog: December 2002 David Baron's weblog: November 2002 David Baron's weblog: September 2002
David Baron's weblog: Hidden complexity in specifications
David Baron · 2010-06-01 · via David Baron's Weblog

As an implementor of specifications ("specs"), one thing that scares me when I read a spec is a requirement stated very briefly that requires lots of complexity in implementations.

Some classic examples of such statements are the statement from HTML 4.0 that “User agents should ignore empty P elements” or the statement from CSS1 that “Two or more adjoining vertical margins (i.e., with no border, padding or content between them) are collapsed to use the maximum of the margin values”.

These types of statements scare me for two reasons. First, in many (but not all) cases, it means that the required complexity won't be implemented the same way across implementations. In the examples above: Should the empty paragraphs be ignored by the parser and thus not appear in the DOM, or just not be displayed once they're in the DOM? What if script takes a non-empty paragraph and removes its contents? Should it disappear from the DOM? If it is then made non-empty, does it reappear? What makes margins adjoining? If the margins of a parent and its first child are adjoining (can they be?), where are the edges of the boxes? If an element whose top and bottom margins are adjoining contains floats, where are those floats placed?

Second, and more importantly, it means that the authors of the specification probably weren't aware of the complexity, and therefore didn't consider it when designing the specification. A major part of the job of a specification designer is to make tradeoffs: is meeting a particular requirement important enough to increase complexity, and thus make implementations more likely to be later or buggier? If the specification's authors weren't aware of the complexity, they probably weren't even thinking about the tradeoff.

When I was first involved in CSS spec development, I made the mistake of trying to remedy the first problem without also trying to remedy the second. Hixie and I wrote many proposals to make things that were unclear in CSS specifications more precise in a way that was compatible with the small statements that were in the specification. We treated little bits of spec as the incantations of an oracle, and demonstrated that there was only one way to satisfy all of them at the same time.

When we did this, we should have stepped back and reevaluated the requirements. (Given a specification that was then in use, there were additional compatibility requirements that didn't exist when the spec was written, but they often weren't significant, since implementations were often quite incompatible, which meant that content largely didn't depend on the areas where they disagreed.) For example, adjoining margins are now defined in terms of three pairs that make margins adjoining (plus the idea that being adjoining is transitive): (1) the bottom margin of one block with the top margin of its next sibling block (2) the top (bottom) margin of a first (last) child block with the top (bottom) margin of its parent and (3) the top and bottom margins of an empty block. There was a real use case for the first, and maybe for the second, but not for the third (other than satisfying the sentence in the HTML spec on empty paragraphs—a sentence I think was intended to break existing content to punish its authors for misusing HTML). However, allowing the top and bottom margins of a single element to collapse with each other increased the complexity of margin collapsing a lot.

So, I see two lessons from this. First, if you're writing a spec and you are aware of the tradeoffs, you should make it clear in the spec that you are (which also points out the complexity to implementors and testers). Second, if you're fixing a spec that's unclear, you should evaluate whether the complexity of the fix is really needed, or whether it's better to change existing parts of the spec to make better tradeoffs between complexity and features.