<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mozilla Hacks - the Web developer blog &#187; Christopher Blizzard</title>
	<atom:link href="http://hacks.mozilla.org/author/blizzard/feed/" rel="self" type="application/rss+xml" />
	<link>http://hacks.mozilla.org</link>
	<description>hacks.mozilla.org</description>
	<lastBuildDate>Wed, 08 Feb 2012 22:52:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Introducing Aurora 9</title>
		<link>http://hacks.mozilla.org/2011/09/introducing-aurora-9/</link>
		<comments>http://hacks.mozilla.org/2011/09/introducing-aurora-9/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 22:22:45 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Aurora]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Feature]]></category>
		<category><![CDATA[Featured Article]]></category>
		<category><![CDATA[Firefox 9]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=9688</guid>
		<description><![CDATA[We have just released Aurora 9 (download and test Aurora 9), which is planned to be the upcoming Firefox 9. In it, we have a number of new things that we hope will get you excited! JavaScript Type Inference We&#8217;ve improved JavaScript performance once again with type inference. We&#8217;ve made significant improvements on both the [...]]]></description>
			<content:encoded><![CDATA[<p>We have just released Aurora 9 (<a href="http://www.mozilla.org/en-US/firefox/channel/">download and test Aurora 9</a>), which is planned to be the upcoming Firefox 9. In it, we have a number of new things that we hope will get you excited!</p>
<p><span id="more-9688"></span></p>
<h2>JavaScript Type Inference</h2>
<p>We&#8217;ve improved JavaScript performance once again with type inference. We&#8217;ve made significant improvements on both the V8 and Kraken benchmarks, and you should see real-world improvements to JavaScript performance as well.</p>
<h2>JavaScript Interface for Do Not Track</h2>
<p>Firefox 4 introduced <a href="https://developer.mozilla.org/en/The_Do_Not_Track_Field_Guide/Introduction/How_Do_Not_Track_works">Do Not Track</a>, and now there is a way to detect a users&#8217;prefence through JavaScript as well:</p>
<p><iframe style="width: 100%; height: 100px;" src="http://jsfiddle.net/robnyman/cFqXk/1/embedded/" width="320" height="240"></iframe></p>
<h2>mouseenter and mouseleave events</h2>
<p>For some time now, <a href="http://www.quirksmode.org/dom/events/mouseover.html">web developers have been struggling</a> with handling <code>mouseover</code> and <code>mouseout</code> events on elements, since when child elements have gained focus, the event has bubbled up and triggered <code>mouseout</code> on the parent element &#8211; something you would in most cases not like to happen.</p>
<p>Therefore, we are now happy to introduce support for <code>mouseenter</code> and <code>mouseleave</code> events:</p>
<p><iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/robnyman/ZVTa2/12/embedded/" width="320" height="240"></iframe></p>
<h2>Camera UI for Mobile</h2>
<p>You can now use an input element to trigger a native app to take pictures. Please try the <a href="http://jsbin.com/iwerow/27/">Camera UI for Mobile demo</a>.</p>
<h2>Support for chunked XMLHttpRequest</h2>
<p>When doing XMLHttpRequest requests with large data sets, you can now <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=687087">get partial data</a> as it arrives instead of waiting for it all to show up. You can use this to build more responsive and more efficient web sites.</p>
<h2>Other changes</h2>
<p>We&#8217;ve also got support for a bunch of other changes as well.  These will be added to the <a href="https://developer.mozilla.org/en/Firefox_9_for_developers">Firefox 9 for Developers page over the next few weeks.</a></p>
<div class="changelog">
<h4>HTML</h4>
<ul>
<li>We now support <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=654352">document.caretPositionFromPoint</a>
<li>We now support <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=683852">Node.contains(node)</a>
<li>We now <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=685139">return true for node.contains(node)</a>, as other browsers do.  (The spec says we should return false but the spec is probably wrong given the behaviour of all browsers.)
<li>We now support <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=685798">Node.parentElement</a>
<li>We no longer <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=685518">taint the canvas data when drawing images where @crossorigin is set on them</a>
<li>We now only <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=682554">fire onreadystatechange on the document element</a>
<li>There is now <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=605365">UI for HTML5 Forms Validation in Fennec</a>
<li>We now fire <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=185236">load and error events on stylesheet link elements that are loaded dynamically</a>
<li>We now support <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=543789">DOM3 composition events</a>
</ul>
</div>
<div class="changelog">
<h4>Graphics</h4>
<ul>
<li>We now support <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=600556">Vista-style ICO files</a></li>
<li>We now <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=573583">decode images only when drawing them</a>, instead of ahead of time</li>
</ul>
</div>
<div class="changelog">
<h4>Layout</h4>
<ul>
<li>We now support the <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=446569">CSS3 columns shorthand where column-count and column-width can be combined</a>
<li>We now support <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=677582">CSS3 text-overflow: &lt;left&gt; &lt;right&gt;</a>
<li>We now support the font-stretch property (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=3512">bug number 3512, filed in 1999!</a>)
<li>You can now use <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=688405">65534 rowspans instead of 8190</a>, to match IE.
</ul>
</div>
<div class="changelog">
<h4>Video</h4>
<ul>
<li>We now support <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=648595">temporal media URIs for HTML5 video</a>.</li>
</ul>
</div>
<div class="changelog">
<h4>Network</h4>
<ul>
<li>We&#8217;ve changed the way we handle <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=665706">semicolons during URL parsing</a></li>
<li>We no longer pop up a <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=423506">download dialog bog when a server returns no data</a> and instead show a corrupted content error, to match other browsers.</li>
<li>We&#8217;ve made some <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=686312">minor</a> <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=687243">protocol</a> fixes to WebSockets</li>
<li>If you include an <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=272541">empty disposition type it&#8217;s treated as an &#8220;attachment&#8221;</a></li>
<li>We don&#8217;t <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=255119">show redirect content after denying automatic redirect to javascript: URL</a></li>
</ul>
</div>
<div class="changelog">
<h4>Tools</h4>
<ul>
<li>We now <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=612658">cache data for the window.console API</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2011/09/introducing-aurora-9/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>What&#8217;s new for Web Developers in Firefox 7</title>
		<link>http://hacks.mozilla.org/2011/09/whats-new-for-web-developers-in-firefox-7/</link>
		<comments>http://hacks.mozilla.org/2011/09/whats-new-for-web-developers-in-firefox-7/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 14:30:22 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Featured Article]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Firefox 7]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=9593</guid>
		<description><![CDATA[Today we&#8217;re releasing Firefox Update 7. This update contains work that&#8217;s been stabilizing over the last 3 months and there are quite a few interesting things to talk about. To be clear, this is not the canonical list of changes, just highlights. As always, we&#8217;ve created a page to track the changes that web developers [...]]]></description>
			<content:encoded><![CDATA[<p>Today we&#8217;re releasing Firefox Update 7.  This update contains work that&#8217;s been stabilizing over the last 3 months and there are quite a few interesting things to talk about.</p>
<p>To be clear, this is not the canonical list of changes, just highlights.  As always, we&#8217;ve created a page to track the changes that web developers will care about.  For the full list please see the <a href="https://developer.mozilla.org/en/Firefox_7_for_developers">Firefox 7 for developers page.</a></p>
<p><strong>Firefox now supports text-overflow: ellipsis</strong></p>
<p>Firefox now supports the <code><a href="https://developer.mozilla.org/En/CSS/text-overflow">ellipsis</a></code> mode for the <code>text-overflow</code> property.  This property is supported in <a href="https://developer.mozilla.org/En/CSS/text-overflow#Browser_compatibility">other browsers</a> which means developers should be able to start using it in the wild.  Here&#8217;s an example of how text-overflow ellipsis works:</p>
<p>HTML:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;body&gt;
      &lt;div class=&quot;inner&quot;&gt;I am some very long text!&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>CSS:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #6666ff;">.inner</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">120px</span><span style="color: #00AA00;">;</span>
    text-<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> ellipsis<span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">white-space</span><span style="color: #00AA00;">:</span><span style="color: #993333;">nowrap</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">red</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">dashed</span> <span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Result:</p>
<p><img src="http://hacks.mozilla.org/wp-content/uploads/2011/09/ellipsis.png"/></p>
<p>As you can see, it&#8217;s pretty easy to make text that cuts off in a sane way with this new property.  Our <a href="https://developer.mozilla.org/En/CSS/text-overflow">developer page for the property</a> also contains sample syntax for other browsers.</p>
<p><strong>WebSockets: Updated protocol and available on mobile</strong></p>
<p>First, WebSockets is now enabled by default for Firefox for Mobile.  For mobile networks that are high-latency and have high connection setup-up costs, WebSockets offers an opportunity to create a much better experience than is available with polling HTTP.</p>
<p>Second, we&#8217;ve updated to the most recent draft version of the <a href="https://developer.mozilla.org/en/WebSockets">WebSockets</a> protocol from the IETF.  Somewhat confusingly, this is version 8 of the protocol, but is <a href="http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10" title="IETF WebSockets version 10">draft version 10</a>.  This will be mostly of interest to people who are building applications on top of WebSockets and tool vendors, but is worth calling out since it affects backwards compatibility.</p>
<p>Since the WebSockets work is ongoing, the namespace for WebSockets remains moz-prefixed to indicate that it&#8217;s not yet finalized.</p>
<p><strong>An even faster Canvas element</strong></p>
<p>The <code>canvas</code> element in Firefox 7 is even faster.  We&#8217;ve revised our code for Canvas based on what we learned in previous Firefox releases and how people are using Canvas in the wild.  Based on that you are likely to see much snappier performance on many demos when drawing to canvas elements.  For an example, see our <a href="https://developer.mozilla.org/en-US/demos/detail/runfield">Runfield</a> demo.</p>
<p><strong>Web sites can no longer resize your main browser window</strong></p>
<p>It&#8217;s no longer possible for a web site to change the default size of a window in a browser, according to the <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=565541#c24">following rules</a>:</p>
<ol>
<li>You can&#8217;t resize a window or tab that wasn&#8217;t created by window.open.
<li>You can&#8217;t resize a window or tab when it&#8217;s in a window with more than one tab.
</ol>
<p><strong>Support for the new Navigation Web Timing Spec</strong></p>
<p>Firefox Update 7 now supports the <a href="https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html" title="Navigation Timing Spec">Navigation Timing spec</a>.  This allows a web page author to monitor parts of web page performance in the page itself.  For people who are interested in page load and navigation performance, they can send that back to the server which can give them a better view into real-world performance.</p>
<p>There are a couple of other specs in this space &#8211; the <a href="https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/UserTiming/Overview.html">User Timing</a> and <a href="http://www.w3c-test.org/webperf/specs/ResourceTiming/">Resource Timing</a> &#8211; but those are still under discussion in working groups and as such we have not yet implemented them.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2011/09/whats-new-for-web-developers-in-firefox-7/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Firefox 4 Beta 9 &#8211; a huge pile of awesome</title>
		<link>http://hacks.mozilla.org/2011/01/firefox-4-beta-9-a-huge-pile-of-awesome/</link>
		<comments>http://hacks.mozilla.org/2011/01/firefox-4-beta-9-a-huge-pile-of-awesome/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 18:47:06 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Featured Article]]></category>
		<category><![CDATA[Firefox 4]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=6401</guid>
		<description><![CDATA[Hello, and welcome to the post for Firefox 4 beta 9. If you&#8217;re reading this then you&#8217;re interested in what we&#8217;ve got coming down the pipe for the latest beta for the wonderful browser known as Firefox 4. We&#8217;re starting to reach the end of our development cycle for the next release of Firefox and [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, and welcome to the post for Firefox 4 beta 9.  If you&#8217;re reading this then you&#8217;re interested in what we&#8217;ve got coming down the pipe for the latest beta for the wonderful browser known as Firefox 4.  We&#8217;re starting to reach the end of our development cycle for the next release of Firefox and I thought it might be worth it to give a full overview of everything that we&#8217;ve got in store for web developers vs. Firefox 3.6.  So if you&#8217;ve read previous releases, some of this will look familiar.  But this is a new beta and we&#8217;ve been busy, so there&#8217;s something new in here for everyone.</p>
<h3>Performance</h3>
<p>One of Firefox 4&#8242;s main themes is Performance.  As such, we&#8217;ve done a huge amount of work to improve browser performance across the board, from startup time, to JavaScript performance, to interactive performance and making the user interface easier and more efficient to drive. That being said, here are some of the things we&#8217;ve done to improve performance up to Beta 9.</p>
<p><strong>The JaegerMonkey has landed.</strong></p>
<p>And you might have noticed that it&#8217;s <a href="http://blog.mozilla.com/rob-sayre/2010/09/14/release-the-kraken/">really fast</a>.  This is the world&#8217;s first third-generation JavaScript engine, using Baseline JIT technology similar to engines found in other browsers and kicked up a level with the Tracing engine found in Firefox 3.6.  As such, we&#8217;re competitive on benchmarks such as <a href="http://arewefastyet.com/">Sunspider and V8</a>, but we&#8217;re also fast at a whole mess of things that we expect to see in the set of next-generation web applications, hence <a href="http://krakenbenchmark.mozilla.com/">Kraken</a>.</p>
<p><strong>Hardware Acceleration</strong></p>
<p>Firefox 4 supports full hardware acceleration on Windows 7 and Windows Vista via a combination of D2D, DX9 and DX10.  This allows us to accelerate everything from Canvas drawing to video rendering.  Windows XP users will also enjoy hardware acceleration for many operations because we&#8217;re using our new Layers infrastructure along with DX9.  And, of course, OSX users have excellent OpenGL support, so we&#8217;ve got that covered as well.</p>
<p><strong>Compartments</strong></p>
<p><a href="http://andreasgal.wordpress.com/2010/10/13/compartments/">Compartments</a>, added in Beta 7, is infrastructure that we&#8217;ve added to Firefox to improve performance, give us a better base for security and, over the long term, give us better responsiveness because of its positive effects on garbage collection.  (Note that there are some parts of Compartments that still have not landed.)  If you want to learn about why Compartments are so important, have a look at <a href="http://andreasgal.wordpress.com/2010/10/13/compartments/">Andreas Gal&#8217;s great post on the topic</a>.  He does a great job of explaining what they are and how they work.</p>
<p><strong>Improved DOM performance and style resolution</strong></p>
<p>We&#8217;ve made a huge number of improvements to our overall DOM and style resolution performance as well.  Although JavaScript gets much of the focus these days, it turns out that in page load and interactive performance, the DOM and style resolution (usually as part of reflowing a document) often affect page performance more than JavaScript.  And as such we&#8217;ve seen improvement across the board in this area with Firefox 4.  In some tests we&#8217;re a solid 2x faster than Firefox 3.6.</p>
<p><strong>JavaScript typed arrays</strong></p>
<p>If you&#8217;re doing processing with JavaScript and you want to process low-level data, Firefox now supports <a href="https://developer.mozilla.org/en/JavaScript_typed_arrays">native typed arrays in JavaScript</a>.  This can make a <a href="http://blog.vlad1.com/2010/07/30/fun-with-fast-javascript/">gigantic difference in how fast items are processed if you&#8217;re doing WebGL or image manipulation</a>.</p>
<p>In addition, if you&#8217;re getting data from an XHR request, you can get that data as a <a href="https://developer.mozilla.org/en/using_xmlhttprequest#Receiving_binary_data_using_JavaScript_typed_arrays">JavaScript native typed array for fast processing with <code>mozResponseArrayBuffer</code>.</a></p>
<p><strong>JavaScript animation scheduling APIs</strong></p>
<p>We now support events that let you <a href="https://developer.mozilla.org/en/DOM/Animations_using_MozBeforePaint">schedule animations from JavaScript</a>.  Doing this means you aren&#8217;t wasting CPU and battery by running your animations as fast as possible when the underlying rendering engine isn&#8217;t going to draw them anyway.  (Gecko now has an internal timer for all drawing and will render at a maximum of 60fps, the edge of human perception.  It will also turn this timer down to 1fps for tabs that aren&#8217;t in the foreground.  Use it.)  This is most useful for people building libraries, but you should be aware that there&#8217;s a better way to animate in Gecko.</p>
<p><strong>Retained layers</strong></p>
<p>As mentioned above, Firefox now has an internal Layers system for improved drawing performance for many types of web pages.  Images, fixed backgrounds, inline video, etc. are now rendered to an internal layer and then composited with other parts of a web page in a way that can take advantage of hardware acceleration.  This improves the page load time and interactive performance of many web pages.</p>
<p><strong>Asynchronous plug-in painting</strong></p>
<p>On Windows and Linux we now paint plug-ins asynchronously.  In previous releases when we wanted to paint a web page that included a plug-in, we would have to ask the plug-in for the data to paint.  If a plug-in was slow or was hung, it would make the browser feel slow.  Now we&#8217;re able to get that data asynchronously, which means that the overall responsiveness of the browser should be improved.</p>
<p><strong>Vastly improved cache</strong></p>
<p>Firefox 4 has a vastly improved disk cache.  This disk cache should result in faster start-up performance and runtime performance.  But why mention this here?  Our expectation is that site owners should see much higher cache hit rates with Firefox 4 as we dynamically set the cache size based on how much space is free on an end-user&#8217;s hard drive.</p>
<h3>WebGL</h3>
<p>Firefox 4 now has WebGL enabled by default.  Based on the original <a href="http://blog.vlad1.com/canvas-3d/">3-D Canvas</a> work by Vladimir Vukićević, this is being widely implemented in browsers.  The WebGL spec is on the short path to a 1.0 release and we&#8217;re very excited to see this be used in the wild.</p>
<p>Want a demo?  Try the amazing <a href="http://vocamus.net/dave/?p=1233">Flight of the Navigator</a> where we combine WebGL with a number of other technologies in Firefox 4 &mdash; HTML5 video, the Audio API, all remixed with live data from the web.</p>
<h3>JavaScript</h3>
<p>The new JaegerMonkey engine in Firefox 4 isn&#8217;t just faster, it&#8217;s also got some new tricks as well.  Our goal is to bring new tools to developers and that includes evolving the JavaScript language.  Here are two examples of where we&#8217;ve made other improvements:</p>
<p><strong>ECMAScript 5</strong></p>
<p>Firefox 4 Beta 9 contains much of the <a href="http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/">new version of the JavaScript language</a>.  Our goal with Firefox 4 is to have industry-leading support for ECMAScript 5, including the new <code>strict</code> mode.  You can track our progress on the <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=445494">ES5 bug.</a></p>
<h3>Web Console</h3>
<p>Firefox 4 will include the <a href="https://developer.mozilla.org/en/Using_the_Web_Console">Web Console</a>.  This is a new tool that will let you inspect a web page as it&#8217;s running, see network activity, see messages logged with <code>console.log</code>, see warnings for a page&#8217;s CSS, and a number of other things.</p>
<p>Note this that is something that we&#8217;ll be including with Firefox 4 directly.  It&#8217;s not an add-on.</p>
<p>(Also Firebug will be ready for the final Firefox 4 release.)</p>
<h3>HTML5</h3>
<p>Firefox has always had excellent support for HTML5, even as far back as Firefox 3.5.  Firefox 4 builds on that history with a bunch of new HTML5-related features.</p>
<p><strong>Forms</strong></p>
<p>We&#8217;ve started to implement much of HTML5 forms.  We include support for new input types, <code>datalist</code> support, new input attributes like <code>autofocus</code> and <code>placeholder</code>, decoupled forms, form options, validation mechanisms, constraint validation and new CSS selectors to bind them all together.  There&#8217;s a <a href="http://hacks.mozilla.org/2010/11/firefox-4-html5-forms/">great post up on the Hacks site</a> covering our HTML5 forms support in Firefox 4.  If you want more information, <a href="http://hacks.mozilla.org/2010/11/firefox-4-html5-forms/">check it out</a>.</p>
<p><strong>Parser</strong></p>
<p>Firefox 4 includes an HTML5-ready parser.  This parser brings with it some <a href="http://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser-inline-svg-speed-and-more/">new capabilities, most notably inline SVG</a>, but also improves performance by running the parsing algorithm on its own processor.  It also brings our parser algorithm closer to the standard and lays the foundation for consistent parsing across browsers.</p>
<p><strong>Support for WebM</strong></p>
<p>Firefox 4 includes support for <a href="http://www.webmproject.org/">WebM</a>, the new royalty-free format for video on the web.  It works on YouTube if you join their <a href="http://www.youtube.com/html5">HTML5 beta</a>.  It also works with embedded YouTube videos if you use their new <a href="http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html">iframe embedding API</a>.  (Join the beta and see an example <a href="http://www.0xdeadbeef.com/weblog/2010/08/24-hours-of-lemons/">at the bottom of this post</a>.)</p>
<p><strong>Video Buffer API</strong></p>
<p>We now support the <a href="http://blog.pearce.org.nz/2010/08/buffered-attribute-landed-for-html5.html">buffered attribute</a> for HTML5 video.  This means it&#8217;s possible to give users an accurate measure of how much video has been buffered instead of having to guess from the download rate and your current position in the stream.</p>
<p><strong>Video &#8220;preload&#8221; support</strong></p>
<p>We&#8217;ve replaced the <a href="http://hacks.mozilla.org/2010/08/video_preload_attribute/">&#8220;autobuffer&#8221; attribute for HTML5 video with the new &#8220;preload&#8221; attribute</a>.  This attribute gives you much better control over how videos are pre-buffered if they are included on a page rather than the old on/off system that was included with Firefox 3.5.</p>
<p><strong>History pushState and replaceState</strong></p>
<p>Firefox 4 now supports the HTML5 <a href="https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history">pushState and replaceState history modification calls</a>.  These allow you to create or modify the browser navigation history.  These are extremely useful for applications that might want to generate history entries using the hash after the URL (useful for HTML-based slides, for example.)  Other sites have been using these APIs to hide history information so that site-internal navigation aids aren&#8217;t revealed as part of HTTP-referrers.</p>
<p><strong>Audio sampling and generation API</strong></p>
<p>Firefox 4 includes the <a href="https://wiki.mozilla.org/Audio_Data_API">Firefox Audio Data API</a>.  This API allows you read, modify and write data from audio and video elements.  This is now being widely experimented with and people are building some very beautiful things with it.</p>
<h3>DOM</h3>
<p>Firefox 4 includes a bunch of new DOM functionality, in addition to the performance improvements I mentioned before.</p>
<p><strong>Added support for .click() to the File upload control</strong></p>
<p>You can now <a href="https://developer.mozilla.org/en/using_files_from_web_applications#Using_hidden_file_input_elements_using_the_click%28%29_method">call <code>.click()</code> on a hidden File control</a> in order to bring up the platform file upload widget.  This means you don&#8217;t have to expose the (ugly) file upload control; instead you can build your own.  If you combine this with the new <a href="https://developer.mozilla.org/en/Using_files_from_web_applications">File APIs</a> and <a href="https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest#Monitoring_progress">progress events</a> and you&#8217;ve got a recipe for a very nice file upload experience. </p>
<p><strong>Support for .slice in the File API</strong></p>
<p>We now support the <a href="https://developer.mozilla.org/en/DOM/Blob">Blob API and the .slice APIs that come with it</a>.  This is useful for people who want to want to process small parts of an otherwise large File object from JavaScript.  You no longer have to load the entire file into memory.</p>
<p>It&#8217;s also useful for people who want to reliably upload large files.  With some server and JS code you can now split a large file into small sections and upload those chunks, including re-retrying failed sections, or even uploading several sections in parallel.</p>
<p><strong>Support for File API URLs</strong></p>
<p>We now support the <a href="http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/"><code>.url</code> attribute for the File API.</a>  This lets you take objects that you&#8217;ve gotten through the File API and use them for images, video, HTML or other URL-powered objects.</p>
<p><strong>Touch and multi-touch events</strong></p>
<p>Firefox 4 supports both <a href="http://hacks.mozilla.org/2010/08/firefox4-beta3/">touch and multi-touch events, exposed to the DOM</a>.  Support for this functionality is available on Windows 7 systems.</p>
<p><strong>Detect click-to-touch</strong></p>
<p>You can now tell if a mouse or finger generated an event with the <a href="https://developer.mozilla.org/en/DOM/event.mozInputSource">mozInputSource</a> property.  This is useful with the touch and multi-touch events and makes it possible to build apps that treat touch and mouse input differently.</p>
<p><strong>IndexedDB</strong></p>
<p>Firefox 4 will include a super-early version of <a href="http://www.w3.org/TR/IndexedDB/">IndexedDB</a>.  This emerging standard for local storage is still undergoing change and will be private-prefixed until it&#8217;s stable.  We have some early <a href="https://developer.mozilla.org/en/IndexedDB">API docs</a> on IndexedDB, but the spec and implementation we have in Firefox 4 have both changed since the docs were last updated.  As we get closer to release time we&#8217;ll be updating the docs and talk more about the implementation. Meanwhile, you can read the <a href="https://developer.mozilla.org/en/IndexedDB/IndexedDB_primer">IndexedDB primer</a> for an overview of using the IndexedDB API.</p>
<p><strong>FormData</strong></p>
<p>Firefox 4 includes support for the new <a href="http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/">FormData</a> object, which makes it easier to interact with HTML forms.  It also enables some new capabilities, like making it easy to upload a file as part of a form accessed via the File API.</p>
<p><strong>SVG Animation and SMIL</strong></p>
<p>In Firefox 4 you can now <a href="https://developer.mozilla.org/en/SVG/SVG_animation_with_SMIL">animate SVG with SMIL.</a></p>
<p><strong>SVG as Images and CSS backgrounds</strong></p>
<p>You can now use SVG as the source of an &lt;img&gt; tag.  You can even animate them with SMIL.  And you can also use SVGs as backgrounds in CSS.</p>
<p><strong>Get a Canvas as a File object</strong></p>
<p>Many people wanted a Canvas accessible as a file object for uploads and other purposes.  You can now use the <code>mozGetAsFile()</code> method <a href="https://developer.mozilla.org/en/DOM/HTMLCanvasElement">on a canvas</a> and it will return an image file.</p>
<p><strong>Resizable text areas</strong></p>
<p>If you&#8217;ve been using a beta, you&#8217;ve noticed that text areas are now resizable by default.  You can disable that with the new <a href="https://developer.mozilla.org/en/CSS/resize"><code>resize</code></a> CSS property.</p>
<h3>CSS</h3>
<p>Firefox 4 includes a huge pile of new CSS properties and promotions from the private CSS namespace into the final namespace due to the maturation of some of the standards in this space.</p>
<p><strong>CSS Transitions</strong></p>
<p>Firefox 4 will include support for <a href="https://developer.mozilla.org/en/CSS/CSS_transitions">CSS Transitions</a>.  Since the spec is still early, these are still <code>-moz</code> prefixed extensions.</p>
<p><strong>calc()</strong></p>
<p>We now support an early version of <code>calc</code> private-namespaced as <code><a href="https://developer.mozilla.org/en/CSS/-moz-calc">-moz-calc</a></code>.  This will let you use simple expressions anywhere you would normally want to use a length.  This can make the CSS layout of pages much simpler.  (No more divs for spacing!)</p>
<p><strong>-moz-any()</strong></p>
<p>We now support a new extremely useful CSS extension: <a href="http://hacks.mozilla.org/2010/05/moz-any-selector-grouping/">-moz-any()</a> selector grouping.  This will be very useful in HTML5 contexts.  Please read the post for more information.</p>
<p><strong>-moz-element()</strong></p>
<p>The <code><a href="http://hacks.mozilla.org/2010/08/mozelement/">-moz-element</a></code> is an extension to the <code>background-image</code> property that lets you use any element as the background for another element.  This is hugely useful &#038; powerful and we hope that other browsers will adopt it as well.</p>
<p><strong>-moz-placeholder()</strong></p>
<p>The <code><a href="https://developer.mozilla.org/en/CSS/%3A-moz-placeholder">:-moz-placeholder</a></code> allows you to change the attributes of background text that&#8217;s a placeholder in an HTML5 form.  This allows you to change the color or other attribute of the text.  This can be very useful if you&#8217;ve changed the style of the actual text box and you want the background text to match.</p>
<p><strong>border-radius</strong></p>
<p>The <code>border-radius</code> attribute is now supported, replacing the old <a href="https://developer.mozilla.org/en/css/-moz-border-radius"><code>-moz-border-radius</code></a> attribute.</p>
<p><strong>box-shadow</strong></p>
<p><code><a href="https://developer.mozilla.org/En/CSS/Box-shadow">box-shadow</a></code> has replaced <code>-moz-box-shadow</code>.</p>
<p><strong>-moz-font-feature-settings</strong></p>
<p>Firefox 4 will include support for <a href="http://hacks.mozilla.org/2010/11/firefox-4-font-feature-support/">exposing much more of the capabilities of TrueType fonts</a> with the <code><a href="https://developer.mozilla.org/en/CSS/-moz-font-feature-settings">-moz-font-feature-settings</a></code> property.  It&#8217;s possible to take advantage of all kinds of font capabilities &mdash; kerning, ligatures, alternates, real small caps, and stylistic sets, to name just a few.</p>
<p><strong>Consistent CSS units</strong></p>
<p>We&#8217;ve changed our handling of pixel sizes to match Internet Explorer, Safari and Chrome so that 1 inch always equals 96 pixels.  See <a href="http://weblogs.mozillazine.org/roc/archives/2010/08/css_units_chang.html">Robert&#8217;s post for more information</a> on these changes.</p>
<p><strong>Support for a physical CSS unit</strong></p>
<p>We&#8217;ve introduced a new CSS unit, <a href="http://weblogs.mozillazine.org/roc/archives/2010/08/css_units_chang.html"><code>mozmm</code></a> for the rare instance where you actually want a physical size to be used.  Once again, see <a href="http://weblogs.mozillazine.org/roc/archives/2010/08/css_units_chang.html">Robert&#8217;s post for more information</a> on this new unit.</p>
<p><strong>device-pixel-ratio</strong></p>
<p>Firefox now supports the <code><a href="https://developer.mozilla.org/En/CSS/Media_queries#-moz-device-pixel-ratio">-moz-device-pixel-ratio</a></code> media query that gives you the number of device pixels per CSS pixel.</p>
<p><strong>resize</strong></p>
<p>As mentioned above, we now have a <code><a href="https://developer.mozilla.org/en/CSS/resize">resize</a></code> CSS property that lets you disable resizable input text areas.</p>
<p><strong>-moz-tab-size</strong></p>
<p>We now support the <a href="https://developer.mozilla.org/en/CSS/-moz-tab-size"><code>-moz-tab-size</code></a> property that lets you specify the width in space characters of how to render a tab character (U+0009) when rendering text.</p>
<p><strong>-moz-focusring</strong></p>
<p>The new CSS pseudo-selector, <a href="https://developer.mozilla.org/en/CSS/%3a-moz-focusring"><code>-moz-focusring</code></a> lets you specify the appearance of an element when it&#8217;s focused and it would have a focus ring drawn around it.  Different operating systems have different conventions for when to draw a focus ring or not and this lets you control the look of form controls while keeping to platform conventions.</p>
<p><strong>-moz-image-rect</strong></p>
<p>The new <a href="https://developer.mozilla.org/en/CSS/-moz-image-rect"><code>-moz-image-rect</code></a> lets you use a sub-rectangle of an image as part of a <a href="https://developer.mozilla.org/en/CSS/background"><code>background</code></a> or <a href="https://developer.mozilla.org/en/CSS/background-image"><code>background-image</code></a>.</p>
<h3>Security</h3>
<p>Last but not least, Firefox 4 supports a huge number of new security tools, useful for both users and web developers alike.  Here&#8217;s a quick overview of the new technologies we&#8217;re delivering:</p>
<p><strong>Content Security Policy</strong></p>
<p><a href="https://developer.mozilla.org/en/Security/CSP">Content Security Policy (CSP)</a> is a set of tools that web developers can use to help prevent a couple different classes of attacks.  In particular, it offers tools to mitigate cross-site scripting attacks, click-jacking and packet sniffing attacks.</p>
<p>Another important piece of CSP is that when one of the rules is violated, Firefox can send back information about that violation to the web site, making it a useful canary to improve security for other browsers too.</p>
<p><strong>X-Frame-Options</strong></p>
<p>Firefox 4 now supports the <a href="https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header">X-Frame-Options header</a>, one defense against clickjacking.  This response header is supported by other browsers as well.  (This was also delivered as part of a Firefox 3.6 update, but is worth calling out since it&#8217;s new since the original 3.6 release.)</p>
<p><strong>HSTS (ForceTLS)</strong></p>
<p>Firefox 4 supports the obtusely-named <a href="http://tools.ietf.org/html/draft-hodges-strict-transport-sec-02">HTTP Strict Transport Security (HSTS) headers</a>.  You can use these headers to tell the browser that it should never, ever contact a site over unencrypted HTTP.</p>
<p>Firefox users can also use the <a href="https://addons.mozilla.org/en-US/firefox/addon/246797/">STS UI add-on to add and remove sites from the HSTS list</a>, even sites that don&#8217;t natively support HSTS.</p>
<p><strong>CORS Improvements</strong></p>
<p>We&#8217;ve fixed some bugs in our CORS implementation.</p>
<p><strong>:visited changes</strong></p>
<p>Firefox 4 includes the changes required to help improve your privacy online by <a href="http://hacks.mozilla.org/2010/03/privacy-related-changes-coming-to-css-vistited/">closing a decade-old hole in CSS rules that let any website query your browsing history</a>.  These changes have also been picked up by WebKit-based browsers and we&#8217;ve heard rumors that IE 9 might pick up this important change as well.</p>
<h3>That&#8217;s a lot of stuff</h3>
<p>Yes, it really is!  We hope that you like it.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2011/01/firefox-4-beta-9-a-huge-pile-of-awesome/feed/</wfw:commentRss>
		<slash:comments>108</slash:comments>
		</item>
		<item>
		<title>Fun With Fast JavaScript</title>
		<link>http://hacks.mozilla.org/2010/08/fun-with-fast-javascript/</link>
		<comments>http://hacks.mozilla.org/2010/08/fun-with-fast-javascript/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 19:07:47 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Demo]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JägerMonkey]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[TraceMonkey]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5509</guid>
		<description><![CDATA[This post is by Vladimir Vukićević and is a re-post from his personal weblog. Fast JavaScript is a cornerstone of the modern web. In the past, application authors had to wait for browser developers to implement any complex functionality in the browser itself, so that they could access it from script code. Today, many of [...]]]></description>
			<content:encoded><![CDATA[<p><em>This post is by Vladimir Vukićević and is a <a href="http://blog.vlad1.com/2010/07/30/fun-with-fast-javascript/">re-post from his personal weblog.</a></em></p>
<p>Fast JavaScript is a cornerstone of the modern web.  In the past, application authors had to wait for browser developers to implement any complex functionality in the browser itself, so that they could access it from script code.  Today, many of those functions can move straight into JavaScript itself.  This has many advantages for application authors: there&#8217;s no need to wait for a new version of a browser before you can develop or ship your app, you can tailor the functionality to exactly what you need, and you can improve it directly (make it faster, higher quality, more precise, etc.).</p>
<p><a href="http://blog.vlad1.com/wp-content/uploads/2010/07/2010-06-24_1353.png" ><img class="alignleft size-full wp-image-316" title="JavaScript Darkroom" src="http://blog.vlad1.com/wp-content/uploads/2010/07/2010-06-24_1353.png" alt="" width="300" height="238" /></a>Here are two examples that show off what can be done with the improved JS engine and capabilities that will be present in Firefox 4.  The first example shows <a href="http://people.mozilla.com/~vladimir/demos/darkroom/darkroom.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/people.mozilla.com');">a simple web-based Darkroom</a><a></a> that allows you to perform color correction on an image.  The HTML+JS is around 700 lines of code, not counting jQuery.  This is based on a demo that&#8217;s included with Google&#8217;s Native Client (NaCl) SDK; in that demo, the color correction work is done inside native code going through NaCl.  That demo (originally presented as &#8220;too slow to run in JavaScript&#8221;) is a few thousand lines of code, and involves downloading and installing platform-specific compilers, multiple steps to test/deploy code, and installing a plugin on the browser side.</p>
<p>I get about 15-16 frames per second with the default zoomed out image (around 5 million pixels per second &#8212; that number won&#8217;t be affected by image size) on my MacBook Pro, which is definitely fast enough for live manipulation.  The algorithm could be tightened up to make this faster still.  Further optimizations to the JS engine could help here as well; for example, I noticed that we spend a lot of time doing floating point to integer conversions for writing the computed pixels back to the display canvas, due to how the canvas API specifies image data handling.</p>
<p>The Web Darkroom tool also supports drag &amp; drop, so you can take any image from your computer and drop it onto the canvas to load it.  A long (long!) time ago, back in 2006, I wrote <a href="http://people.mozilla.com/~vladimir/corppr/" onclick="javascript:pageTracker._trackPageview('/outbound/article/people.mozilla.com');">an addon called &#8220;Croppr!&#8221;</a>.  It was intended to be used with Flickr, allowing users to play around with custom crops of any image, and then leave crop suggestions in comments to be viewed using Croppr.  It almost certainly doesn&#8217;t work any more, but it would be neat to update it: this time with both cropping and color correction.  Someone with the addon (perhaps a <a href="https://jetpack.mozillalabs.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/jetpack.mozillalabs.com');">Jetpack</a> now!) could then visit a Flickr photo and experiment, and leave suggestions for the photographer.</p>
<p><a href="http://blog.vlad1.com/wp-content/uploads/2010/07/2010-06-24_1352.png" ><img class="alignright size-full wp-image-318" title="JavaScript Video FFT" src="http://blog.vlad1.com/wp-content/uploads/2010/07/2010-06-24_1352.png" alt="" width="350" height="425" /></a>The <a href="http://people.mozilla.com/~vladimir/demos/jsfft/jsfft.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/people.mozilla.com');">second example</a> is based on some work that Dave Humphrey and others have been doing to bring audio manipulation to the web platform.  Originally, their spec included a pre-computed FFT with each audio frame delivered to the web app.  I suggested that there&#8217;s no need for this &#8212; while a FFT is useful for some applications, for others it would be wasted work.  Those apps that want a FFT could implement one in JS.  Some benchmark numbers backed this up &#8212; using the <a href="https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/TypedArray-spec.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/cvs.khronos.org');">typed arrays</a> originally created for <a href="http://webgl.org/" onclick="javascript:pageTracker._trackPageview('/outbound/article/webgl.org');">WebGL</a>, computing an FFT in JS was approaching the speed of native code.  Again, both could be sped up (perhaps using SSE2 or something like Mono.Simd on the JS side), but it&#8217;s fast enough to be useful already.</p>
<p>The demo shows this in action.  A numeric benchmark isn&#8217;t really all that interesting, so instead I take a video clip, and as it&#8217;s playing, I extract a portion of the green channel of each frame and compute its 2D FFT, which is then displayed.  The original clip plays at 24 frames per second, so that&#8217;s the upper bound of this demo.  Using Float32 typed arrays, the computation and playback proceeds at around 22-24fps for me.</p>
<p>You can grab the video controls and scrub to a specific frame.  (The frame rate calculation is only correct while the video is playing normally, not while you&#8217;re scrubbing.)  The video source uses Theora, so you&#8217;ll need a browser that can play Theora content.  (I didn&#8217;t have a similar clip that uses WebM, or I could have used that.)</p>
<p>These examples are demonstrating the strength of the trace-based JIT technique that Firefox has used for accelerating JavaScript since Firefox 3.5.  However, not all code can see such dramatic speedups from that type of acceleration.  Because of that, we&#8217;ll be including a full method-based JIT for Firefox 4 (for more details, see <a href="http://www.bailopan.net/blog/?p=683" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.bailopan.net');">David Anderson&#8217;s blog</a>, as well as <a href="http://blog.mozilla.com/dmandelin/2010/05/10/jm-halfway/" onclick="javascript:pageTracker._trackPageview('/outbound/article/blog.mozilla.com');">David Mandelin&#8217;s blog</a>).  This will provide significantly faster baseline JS performance, with the trace JIT becoming a turbocharger for code that it would naturally apply to.</p>
<p>Combining fast JavaScript performance alongside new web platform technologies such as WebGL and Audio will make for some pretty exciting web apps, and I&#8217;m looking forward to seeing what developers do with them!</p>
<p><i>Edit: Made some last-minute changes to the demos, which ended up pulling in a slightly broken version of jQuery UI that wasn&#8217;t all that happy with Safari.  Should be fixed now!</i></p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/08/fun-with-fast-javascript/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Brendan Eich at JSConf 2010 &#8211; what&#8217;s coming in ECMAScript 5 and more</title>
		<link>http://hacks.mozilla.org/2010/07/brendan-eich-at-jsconf-2010-whats-coming-in-ecmascript-5-and-more/</link>
		<comments>http://hacks.mozilla.org/2010/07/brendan-eich-at-jsconf-2010-whats-coming-in-ecmascript-5-and-more/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 17:28:19 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5244</guid>
		<description><![CDATA[Note: We at Mozilla wholeheartedly approve of Brendan&#8217;s use of Bruce Campbell.]]></description>
			<content:encoded><![CDATA[<p>Note: We at Mozilla wholeheartedly approve of Brendan&#8217;s use of Bruce Campbell.</p>
<p><embed src="http://blip.tv/play/g_MngeuuEQI" type="application/x-shockwave-flash" width="480" height="346" allowscriptaccess="always" allowfullscreen="true"></embed></p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/07/brendan-eich-at-jsconf-2010-whats-coming-in-ecmascript-5-and-more/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Firefox 4 &#8211; FormData and the new File.url object</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/</link>
		<comments>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 01:58:20 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[FileAPI]]></category>
		<category><![CDATA[Firefox 4]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237</guid>
		<description><![CDATA[This is a guest post from Jonas Sicking, who does much of the work inside of Gecko on content facing features. He covers FormData, which we&#8217;ve talked about before, but shows how it can connect to an important part of the File API we&#8217;ve added for Firefox 4: File.url. In Firefox 4 we&#8217;re continuing to [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a guest post from Jonas Sicking, who does much of the work inside of Gecko on content facing features.  He covers <a href="http://hacks.mozilla.org/2010/05/formdata-interface-coming-to-firefox/">FormData, which we&#8217;ve talked about before</a>, but shows how it can connect to an important part of the File API we&#8217;ve added for Firefox 4: File.url.</em></p>
<p>In Firefox 4 we&#8217;re continuing to add support for easier and better file handling. Two features that are available in Firefox 4 Beta 1 are <code>File.url</code> and <code>FormData</code>. In this post I&#8217;ll give a short introduction to both of them.</p>
<p>Starting with Firefox 3.6 we supported a standardized way of reading files using the <code>FileReader</code> object. This object allowed you to read the contents of a file into memory to analyze its content or display the contents to the user. For example to display a preview of an image to a user, you could use the following script</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> reader <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> FileReader<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
reader.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  previewImage.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> reader.<span style="color: #660066;">result</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
reader.<span style="color: #660066;">readAsDataURL</span><span style="color: #009900;">&#40;</span>myFile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>There are two unfortunate things to note here. First of all, <code>reader.result</code> is a data url which contains the whole contents of the file. I.e. the full file contents is kept in memory. Not only that, data urls are often base64 encoded, and each base64 encoded character is stored in a javascript character, which generally uses 2 bytes of memory. The result is that if the above code is used to read a 10MB image file, <code>reader.result</code> is a 26.7MB large string.</p>
<p>The other unfortunate thing is that the above code is somewhat complicated since it needs to use asynchronous events to read from disk.</p>
<p>In Firefox 4 Beta 1 you can instead use the following code</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">previewImage.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> myFile.<span style="color: #660066;">url</span><span style="color: #339933;">;</span></pre></div></div>

<p>This uses the <code>File.url</code> property defined by the <a href="http://dev.w3.org/2006/webapi/FileAPI/">File API</a> specification. The property returns a short, about 40 characters, url. The contents of this url you generally won&#8217;t have to care about, but for the interested it contains a randomly generated identifier prefixed by a special scheme.</p>
<p>This can url can then be used anywhere where generic urls are used, and reading from that url directly reads from the file. The example above makes the image element read directly from the file and display the resulting image to the user. The load works just like when loading from a http url, normal &#8216;load&#8217; events and &#8216;error&#8217; events are fired as appropriate.</p>
<p>You can also display HTML files by using an <code>&lt;iframe&gt;</code> and setting its <code>src</code> to the value returned by <code>File.url</code>. However you have to watch out for that relative url in the HTML file won&#8217;t work as the relative urls are resolved against the generated url returned from <code>File.url</code>. This is intentional as the user might have only granted access to the HTML file, and not to the image files.</p>
<p>Other places where this URL can be useful is for CSS background images, to set the background of an element to use a local file. Or even read from the url using <code>XMLHttpRequest</code> if you have existing code that uses <code>XMLHttpRequest</code> and which you don&#8217;t want to convert to use <code>FileReader</code>.</p>
<p>The other feature that we are supporting in Firefox 4 Beta 1 is the <code>FormData</code> object. This object is useful if you have existing server infrastructure for receiving files which uses <code>multipart/form-data</code> encoding.</p>
<p>In Firefox 3.6, sending a file to a server using <code>multipart/form-data</code> encoding using <code>XMLHttpRequest</code> required a a bit of manual work. You had to use a <code>FileReader</code> to read the contents of the file into memory, then manually <code>multipart/form-data</code> encode it, and then finally send it to a server. This both required more code, as well as required that the whole file contents was read into memory.</p>
<p>In Firefox 4, you&#8217;ll be able to use the FormData object from the <a href="http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html">XMLHttpRequest Level 2</a> specification. This allows the following clean code</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> fd <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> FormData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fd.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;fileField&quot;</span><span style="color: #339933;">,</span> myFile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> xhr <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xhr.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;POST&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;file_handler.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xhr.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span>fd<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This will automatically <code>multipart/form-data</code> encode the file and send it to the server. The contents of the file is read in small chunks and thus doesn&#8217;t use any significant amounts of memory. It will send the same contents as a form with the following markup:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">enctype</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;multipart/form-data&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;file&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fileField&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<p>If you want to send multiple files, simply call <code>fd.append</code> for each file you want to submit and the files will all be sent in a single request. You can of course still use the normal progress events, both for upload and download progress, that <code>XMLHttpRequest</code> always supplies.</p>
<p>However <code>FormData</code> also has another nice feature. You can also send normal, non-file, <code>multipart/form-data</code> values. For example</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> fd <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> FormData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fd.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;author&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;Jonas Sicking&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fd.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;New File APIs&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fd.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;attachment1&quot;</span><span style="color: #339933;">,</span> file1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fd.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;attachment2&quot;</span><span style="color: #339933;">,</span> file2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> xhr <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xhr.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;POST&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;file_handler.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xhr.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span>fd<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You can even get a FormData object which contains all the information from a <code>&lt;form&gt;</code>. (However note that the syntax for this is likely to change before final release)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> fd <span style="color: #339933;">=</span> myFormElement.<span style="color: #660066;">getFormData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> xhr <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xhr.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;POST&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;file_handler.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xhr.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span>fd<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Here <code>fd</code> will contain data from all the form fields, from radio buttons to file fields, that are contained in the form.</p>
<p>As always, we&#8217;re all ears for feedback about these features. Please let us know what you think, and especially if you have tested them out and they do not appear to do what you expect them to. You can use <a href="http://www.mozilla.com/en-US/firefox/beta/feedback/">http://www.mozilla.com/en-US/firefox/beta/feedback/</a> to give us feedback, or use the feedback button in the upper right corner (see below screenshot).</p>
<p><img src="http://farm2.static.flickr.com/1373/4728758428_bc8645d408.jpg"></p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Firefox 4 beta 1 is here &#8211; what&#8217;s in it for web developers?</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-beta-1-is-here-whats-in-it-for-web-developers/</link>
		<comments>http://hacks.mozilla.org/2010/07/firefox-4-beta-1-is-here-whats-in-it-for-web-developers/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 22:33:14 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Firefox 4]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5120</guid>
		<description><![CDATA[Today we&#8217;re releasing the first beta-quality version of Firefox 4, which starts us down the path to a final release of Firefox 4. We&#8217;re handling this beta differently than we&#8217;ve done other releases. In previous betas we&#8217;ve made milestone-like releases. For this beta we&#8217;ll be making more frequent updates during the beta program. So if [...]]]></description>
			<content:encoded><![CDATA[<p>Today we&#8217;re <a href="http://www.mozilla.com/en-US/firefox/beta/">releasing the first beta-quality version of Firefox 4</a>, which starts us down the path to a final release of Firefox 4.  We&#8217;re handling this beta differently than we&#8217;ve done other releases.  In previous betas we&#8217;ve made milestone-like releases.  For this beta we&#8217;ll be making more frequent updates during the beta program.  So if you download the beta build and run it you&#8217;ll likely get updates every two to three weeks, instead of a couple of months apart.  We believe that this will give us the ability to reply to people&#8217;s feedback quickly and get fixes and changes tested earlier.  This, in turn, will mean we&#8217;ll be able to release a much higher quality browser as a result.</p>
<p>First, let&#8217;s talk about feedback.  This beta includes two ways to give us feedback.</p>
<p><img src="http://farm2.static.flickr.com/1373/4728758428_bc8645d408.jpg"></p>
<p><strong>The Feedback Button</strong> – Pictured above and included with the beta is a Feedback Add-on. This puts a big Feedback button on the right hand side of the browser that lets you give quick and easy feedback about something you like or something you don’t. We’ll be reviewing this feedback through the beta process, so please leave comments. The Add-On also uses <a href="https://testpilot.mozillalabs.com/">Test Pilot</a> to figure out how people use the browser – <a href="http://mozillalabs.com/testpilot/2010/03/17/popular-menu-buttons/">menus</a>, <a href="http://mozillalabs.com/testpilot/2009/12/15/accounts-and-passwords/">how people use passwords</a>, etc. But through this beta process we’ll also be using it to measure things like platform performance and other interesting data we need to build a great browser. Just like Test Pilot, no data will be collected without you knowing about it, you&#8217;ll always be asked before any collected data is sent from your computer to Mozilla, and that data will be subject to very strict <a href="http://www.mozilla.com/firefox/beta/feedbackprivacypolicy/">privacy policies</a>.</p>
<p>If you&#8217;re a web developer the beta process will be especially valuable.  There are a lot of new features in Firefox 4.0b1 that weren&#8217;t in 3.6 &#8211; which we&#8217;ll go over &#8211; but we&#8217;ll keep adding and fixing features throughout the beta process and your feedback will be incredibly important.  So please take the time to download the beta and try it.  Run it all the time, if you can, and watch it change over time.</p>
<p><strong>Performance</strong></p>
<p>Firefox 4 contains a large number of performance improvements over Firefox 3.6.  As a web developer you&#8217;re likely to notice big improvements in overall performance.</p>
<p><strong>DOM and Style Performance</strong> &#8211; We&#8217;ve made huge improvements in our DOM and style resolution engine, meaning that pages that have complex CSS rules and selector matching will generally work faster and better.  (On some tests in the Zimbra performance test suite we&#8217;ve seen a solid 2x improvement.)</p>
<p><strong>Reduced IO in the page load path</strong> &#8211; One big area where we&#8217;ve made huge improvements in Firefox 4 vs. 3.6 is the <a href="https://wiki.mozilla.org/Firefox/Goals/2010Q1/IO_Reduction">removal of tons of I/O from the main UI thread</a>.  This means making sure that when we do history look-ups for coloring links based on browser history, that those look-ups are done off the main thread, to making sure that we&#8217;re not synchronously writing data to the HTTP cache on the main thread.  This alone has improved the overall feel of the browser more than anything else.</p>
<p><strong>JavaScript</strong> &#8211; The JavaScript engine is much faster as well, although beta 1 does <em>not</em> include the new <a href="http://hacks.mozilla.org/2010/03/improving-javascript-performance-with-jagermonkey/">JägerMonkey</a> work.  That work is well underway and will be landing through the beta process, and is already <a href="http://arewefastyet.com/">showing positive results</a>.</p>
<p><strong>Hardware Acceleration via Layers</strong> &#8211; We&#8217;ve also got excellent support in this beta for Hardware Acceleration.  If you&#8217;re using HTML5 video and you go full screen, we&#8217;ll use OpenGL on Macs or Linux and DirectX 9 on Windows to accelerate video rendering.  (As we expand our <a href="https://wiki.mozilla.org/Gecko:Layers">Gecko Layers</a> work we&#8217;ll also be extending this acceleration to in-page content where it makes sense.)</p>
<p><strong>Hardware Acceleration via D2D</strong> If you&#8217;re on Windows 7 or an updated Windows Vista we also have <a href="http://www.basschouten.com/blog1.php/2009/11/22/direct2d-hardware-rendering-a-browser">full support for D2D-enabled rendering</a>.  This can be a <em>substantial</em> performance improvement for many types of rendering and is also something the IE team is also doing for IE9.  It&#8217;s not on by default in this beta but you can easily <a href="http://www.basschouten.com/blog1.php/2010/03/02/presenting-direct2d-hardware-acceleratio">turn it on</a> and try it out.  The best demos that we&#8217;ve seen for D2D support are actually the <a href="http://ie.microsoft.com/testdrive/Performance/01FlyingImages/Default.html">IE Flying Images</a> and the <a href="http://ie.microsoft.com/testdrive/Performance/10FlickrExplorer/Default.html">IE Flickr Explorer</a> demo.  Firefox actually performs wonderfully on these demos, better than the IE9 builds in most cases.</p>
<p><strong>Out of process plugins &#8211; even for the Mac</strong> &#8211; We already delivered out of process plugins to Windows and Linux users using 3.6 a couple of weeks ago, but it&#8217;s now available on OSX as well.  Moving plugins out of process improves stability, responsiveness and memory consumption.  For OSX we have support for running Flash 10.1 out of process on OSX 10.6.  (It requires support from 10.6 and changes to the event models for both Firefox and individual plugins.)</p>
<p><strong>HTML5 support</strong></p>
<p>Firefox has had <a href="http://caniuse.com/#cats=HTML5&#038;statuses=rec,pr,cr,wd,ietf">early and excellent support for HTML5</a> and the beta release continues to build on that history.</p>
<p><strong>HTML5 Forms</strong> &#8211; We&#8217;ve started to land support for many <a href="https://wiki.mozilla.org/User:Mounir.lamouri/HTML5_Forms">HTML5 forms</a>.  We&#8217;ll be landing more HTML5 form features during the beta process opportunistically depending on pretty tough <a href="https://wiki.mozilla.org/User:Mounir.lamouri/HTML5_Forms#Shipping_Criteria">shipping criteria</a>.</p>
<p><strong>HTML5 Sections</strong> &#8211; We now support HTML5 sections like <code>&lt;article&gt;, &lt;section&gt;, &lt;nav&gt;, &lt;aside&gt;, &lt;hgroup&gt;, &lt;header&gt;  and &lt;footer&gt;.</code></p>
<p><strong>WebSockets</strong> &#8211; This release includes support for <a href="http://jimbergman.net/tag/websocket-example/">WebSockets</a>, based on version -76 of the spec.</p>
<p><strong>HTML5 History</strong> &#8211; We&#8217;ve also got support for the new HTML5 history items: <a href="https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history#Adding_and_modifying_history_entries"><code>pushState</code> and <code>replaceState</code></a>.  These are very important calls that make it easier to build pages-as-applications and can also be very important for improving privacy as you move from site to site.</p>
<p><strong>HTML5 Parser</strong> &#8211; We&#8217;re also the first browser to fully support the HTML5 parsing algorithm, one of the most important parts of the HTML5 spec.  The parser allows us to <a href="http://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser-inline-svg-speed-and-more/">embed SVG and MathML directly into HTML content</a>, but also promises developers the ability to have the same behaviour in different browsers, even when developers make mistakes in their mark-up.  Our hope is that other browsers will follow us on this work since it&#8217;s one of the biggest interoperability parts of the HTML5 specification and will really help developers.</p>
<p>And, of course, we have support for HTML5 Canvas (including D2D hardware acceleration), Video and a huge pile of other HTML5 technologies.</p>
<p><strong>HTML5 Video</strong></p>
<p><strong>WebM Support</strong> &#8211; The biggest change here so far is that we&#8217;ve got support for <a href="http://hacks.mozilla.org/2010/05/firefox-youtube-and-webm/">WebM</a>.  If you&#8217;re part of the <a href="http://www.youtube.com/html5">Youtube HTML5</a> beta WebM videos should play pretty well.</p>
<p><strong>Other, upcoming interfaces</strong> &#8211; Note that through the beta process we&#8217;ll also be adding support for a JavaScript-driven full screen API for video, support for the <code>buffered</code> attribute and be renaming the <code>autobuffer</code> attribute to <code>preload</code>.</p>
<p><strong>Storage and File API</strong></p>
<p><strong>IndexedDB</strong> &#8211; Firefox 4 beta 1 also includes a super-early snapshot of the new <a href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html">IndexedDB standard for storage</a>.  Due to the fast pace in changes in the standard, the object is available on the privately-namespaced <code>window.moz_indexedDB</code> object.  This is a pretty complex item, and we&#8217;ll have more posts on it soon.</p>
<p><strong>URI Support for the File API</strong> &#8211; We&#8217;ve also early support for the URI support inside of the File API.  This means that it&#8217;s possible to process large amounts of data like images or videos from the File API without having to load the entire file into memory.  You should also be able to reference private File API URLs in image and video tags for preview or manipulation.</p>
<p><strong>FormData</strong> &#8211; We also have support for the <a href="http://hacks.mozilla.org/2010/05/formdata-interface-coming-to-firefox/">FormData</a> method, which makes it much easier to send complex data from the File API and other sources to servers.</p>
<p><strong>Animation and Graphics</strong></p>
<p><strong>SMIL</strong> &#8211; We&#8217;ve added support for SVG Animation (SMIL.)  If you&#8217;re running a 4.0 beta there are a huge number of <a href="http://srufaculty.sru.edu/david.dailey/svg/SVGAnimations.htm#SMIL">beautiful examples on this page by David Dailey</a> worth looking through.</p>
<p><strong>SVG Everywhere</strong> &#8211; Later in the Firefox beta release cycle we&#8217;ll also be adding support for SVG-as-img and SVG-as-CSS-background.  Most of that work is done, but it hasn&#8217;t landed yet.</p>
<p><strong>CSS Transitions</strong> &#8211; This beta release contains a nearly complete implementation of <a href="https://developer.mozilla.org/en/CSS/CSS_transitions">CSS Transitions</a>, privately namespaced with a <code>-moz</code> prefix.  The only big things left here are the animation of transforms and gradients.  (Gradients is still waiting on working group feedback, code for transitions is under review.)</p>
<p><strong>WebGL</strong> &#8211; This build also has improved support for WebGL, although it is not yet on by default.  (You can learn how to <a href="http://blog.vlad1.com/2009/09/18/webgl-in-firefox-nightly-builds/">turn it on in an older post from Vlad</a>.)  The WebGL spec is on its way to a 1.0 release and is being implemented in Chrome, Safari and Firefox.  We would like to ship it in Firefox 4, but that decision will be based on spec stability as well as the availability of drivers.  If you&#8217;re on a Mac WebGL should work very well.  On Windows with ATI and NVIDIA drivers, it should also work very well.  Windows people with Intel drivers are in less luck due to very poor driver support from Intel.  (Including your author!)  Linux is more complicated due to wildly varying driver support &#8211; people with NVIDIA drivers seem to work well, others less so, but work is underway to help fix many issues on Linux.</p>
<p><strong>CSS</strong></p>
<p><strong>Resizable <code>textarea</code> Elements</strong> &#8211; Textarea elements are now resizable by default.  You can use the <code><a href="https://developer.mozilla.org/en/CSS/-moz-resize">-moz-resize</a></code> property to change the default.</p>
<p><strong>New <code>-moz-any</code> selector</strong> &#8211; The <code>-moz-any</code> is a powerful selector that lets you replace large and complicated selectors with much smaller ones.  Please see the <a href="http://hacks.mozilla.org/2010/05/moz-any-selector-grouping/">post for more examples.</a></p>
<p><strong>New CSS3 <code>calc()</code> support</strong> &#8211; This beta includes support for the new CSS3 calc() value.  This lets you specify sizes that include a combination of percentages and absolute values and is hugely popular with developers.  Please see the <a href="http://hacks.mozilla.org/2010/06/css3-calc/">post on CSS3 calc</a> for examples.</p>
<p><strong>Selecting a section of a background image</strong> &#8211; You can now use the new <code>-moz-image-rect</code> selector to select only a section of a background for display.</p>
<p><strong>Removed support for <code>-moz-background-size</code></strong> &#8211; The <code>-moz-background-size</code> property has been renamed to its final <code><a href="https://developer.mozilla.org/en/CSS/background-size">background-size</a></code> name.  <code>-moz-background-size</code> is no longer supported.</p>
<p><strong>DOM and Events</strong></p>
<p><strong>CSS Touch Source on Input Events</strong> &#8211; You can now tell if an input event came from a mouse or touch with <code><a href="https://developer.mozilla.org/en/DOM/event.mozInputSource">event.mozInputSource</a></code>.</p>
<p><strong>Obtaining boundary rectangles for ranges</strong> &#8211; The Range object now has <code>getClientRects()</code> and <code>getBoundingClientRect()</code> methods.</p>
<p><strong>Capturing mouse events on arbitrary elements</strong> &#8211; Support for the Internet Explorer-originated <code>setCapture()</code> and <code>releaseCapture()</code> APIs has been added.</p>
<p><strong>Support for <code>document.onreadystatechange</code></strong> &#8211; We now support the <code><a href="https://developer.mozilla.org/en/DOM/document.onreadystatechange">document.onreadystatechange</a></code>.</p>
<p><strong>Security</strong></p>
<p><strong>Content Security Policy</strong> &#8211; This beta contains support for <a href="http://people.mozilla.org/~bsterne/content-security-policy/">Content Security Policy</a>.  CSP allows you to control what the browser is allowed to do when loading content from your site.  CSP is built to mitigate Cross-site Scripting Attacks and Cross Site Request Forgery.  It also contains an automated reporting mechanism so that admins can get reports of problems that may affect other browsers.</p>
<p><strong>In Closing</strong></p>
<p>So that&#8217;s about it for the start of the Firefox 4 beta.  We&#8217;ll be adding a few more features during the beta release process and we&#8217;ll post about is as they land.  And we&#8217;ll also have more information coming about some of these features in depth.  And, of course, we&#8217;ll continue to work on performance through the beta process as well.  Please test and post comments if you have them here, or use the Feedback system in Firefox.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/07/firefox-4-beta-1-is-here-whats-in-it-for-web-developers/feed/</wfw:commentRss>
		<slash:comments>54</slash:comments>
		</item>
		<item>
		<title>HTML5 adoption stories: box.net and html5 drag and drop</title>
		<link>http://hacks.mozilla.org/2010/06/html5-adoption-stories-box-net-and-html5-drag-and-drop/</link>
		<comments>http://hacks.mozilla.org/2010/06/html5-adoption-stories-box-net-and-html5-drag-and-drop/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 15:46:12 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Device APIs]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Drag and Drop]]></category>
		<category><![CDATA[FileAPI]]></category>
		<category><![CDATA[Firefox 3.6]]></category>
		<category><![CDATA[Firefox 4]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5012</guid>
		<description><![CDATA[This is a guest post from Tomas Barreto, a developer who works at box.net. They recently adopted HTML5 drag and drop as a way to share files with other people using new features in Firefox. The included video is a pitch for the feature and service, but shows how easy it is to do simple [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a guest post from Tomas Barreto, a developer who works at <a href="http://box.net/">box.net</a>.  They recently adopted HTML5 drag and drop as a way to share files with other people using new features in Firefox.  The included video is a pitch for the feature and service, but shows how easy it is to do simple HTML5-based upload progress even with multiple files.  Tomas gives an overview of the relatively simple JavaScript required to do this, and how improvements in Firefox 4 will make things even easier.  Also have a quick look at the bottom of the post for links to additional docs and resources.<br />
</em></p>
<p>At Box.net, we’re always exploring new ways to help users get content quickly and securely onto our cloud content management platform. So when asked, “What feature would make you use Box more?” during the Box Hack Olympics in April, my colleague CJ and I decided to tackle the most intuitive way to upload files: simply dragging them from the desktop into Box.</p>
<p>We considered technologies ranging from Gears to Firefox plugins, but only HTML5 had sufficient adoption. By using some of the JavaScript APIs defined in the HTML5 standard, CJ and I could create a seamless drag and drop experience for our users on supporting browsers. Furthermore, using an HTML5-based upload feature would allow us to enable users to select multiple files at once, and also display progress on the client without polling. And with HTML5 adoption across the latest versions of three of the top four browsers, we felt confident about building an upload method based on this new technology without the trade-offs of using a third-party plug-in.</p>
<p>We rolled out the first rev of our drag and drop feature a few weeks ago, and we’re impressed with how quickly it has been adopted. It’s already one of the most popular ways to get files onto Box, and in its first week it surpassed our old AJAX upload method. You can check out our demo video to get a feel for the feature:</p>
<p><object width="500" height="304"><param name="movie" value="http://www.youtube-nocookie.com/v/rkY7MGilQZY&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/rkY7MGilQZY&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="304"></embed></object></p>
<p>To build this feature, we referenced a handful of online examples that explained how to use Firefox 3 <a href="https://developer.mozilla.org/en/DOM/FileReader">FileReader</a> object and the drag and drop file event support. Our first implementation used this object to load the file into memory and then took advantage of the latest <a href="https://developer.mozilla.org/En/Using_XMLHttpRequest">XMLHttpRequest</a> events to track progress on the client.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> files <span style="color: #339933;">=</span> event.<span style="color: #660066;">originalEvent</span>.<span style="color: #660066;">dataTransfer</span>.<span style="color: #660066;">files</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// drop event</span>
<span style="color: #003366; font-weight: bold;">var</span> reader <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> FileReader<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
reader.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> file_contents <span style="color: #339933;">=</span> event.<span style="color: #660066;">target</span>.<span style="color: #660066;">result</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> request <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  ... <span style="color: #006600; font-style: italic;">// attach event listeners to monitor progress and detect errors</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> post_body <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
&nbsp;
  .. <span style="color: #006600; font-style: italic;">// build post body</span>
&nbsp;
  post_body <span style="color: #339933;">+=</span> file_contents<span style="color: #339933;">;</span>
&nbsp;
  .. <span style="color: #006600; font-style: italic;">// finish post body</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://example.com/file_upload'</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> request <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  request.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;POST&quot;</span><span style="color: #339933;">,</span>  url<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// open asynchronous post request</span>
  request.<span style="color: #660066;">setRequestHeader</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'content-type'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'multipart/form-data; boundary=&quot;&quot;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// make sure to set a boundary</span>
  request.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span>post_body<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
reader.<span style="color: #660066;">readAsBinaryString</span><span style="color: #009900;">&#40;</span>files<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This approach worked well because we could use the same server processing code that we previously used for uploads. The main disadvantage here is that the FileReader object reads the entire file into memory, which is not optimal for a general upload use case. Our current HTML5 implementation uses this logic and has forced us to restrict drag and drop uploads to just 25mb.  However, thanks to recommendations from the Mozilla team, we’ll be taking an alternative approach for V2 of drag and drop, where the file is read chunks as needed by the request. Here’s how we’re going to do it:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> files <span style="color: #339933;">=</span> event.<span style="color: #660066;">originalEvent</span>.<span style="color: #660066;">dataTransfer</span>.<span style="color: #660066;">files</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// drop event</span>
<span style="color: #003366; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://example.com/file_upload'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> request <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
request.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;POST&quot;</span><span style="color: #339933;">,</span>  url<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// open asynchronous post request</span>
request.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span>files<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Since this approach is not formatted as a multipart form-data, it will require some adjustments on our back-end to support receiving file uploads in this way. However, it&#8217;s definitely worth the trade-off since we’ll get all the benefits of the previous method and we don&#8217;t need special file size restrictions. In the future, we&#8217;ll consider using <a href="http://hacks.mozilla.org/2010/05/formdata-interface-coming-to-firefox/">yet another way to efficiently upload files that is supported in Firefox 4 and uses the traditional multi-part form</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> files <span style="color: #339933;">=</span> event.<span style="color: #660066;">originalEvent</span>.<span style="color: #660066;">dataTransfer</span>.<span style="color: #660066;">files</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// drop event</span>
<span style="color: #003366; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://example.com/file_upload'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> request <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> fd <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> FormData<span style="color: #339933;">;</span>
fd.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;myFile&quot;</span><span style="color: #339933;">,</span> files<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
request.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;POST&quot;</span><span style="color: #339933;">,</span>  url<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// open asynchronous post request</span>
request.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span>fd<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We’re already exploring more ways to enrich the Box experience using HTML5. With HTML5, we can build faster, richer and more interactive features with native browser support, and bridge the traditional gap between desktop software and web applications. Here are just a few cool new upload-related features on our roadmap:</p>
<ul>
<li>Pause/Resume uploads using the Blob slice API to split files into chunks (this will be a huge robustness boost, especially for large uploads)</li>
<li>Allowing uploads to resume even after the browser closes by caching the file using <a href="http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/">IndexedDB</a> support (possibly in Firefox 4)</li>
</ul>
<p>We’d also like to begin a discussion about supporting the reverse drag and drop use case: dragging files from the browser to the desktop. Based on our users’ enthusiasm around the drag and drop upload feature, we think the reverse functionality would well received. If you are interested in contributing to a specification for this feature, please let us know (html5 [-at$] box.net)!</p>
<p>Resources:</p>
<ul>
<li><a href="https://developer.mozilla.org/en/using_files_from_web_applications">Using File APIs from web applications</a>
<li><a href="https://developer.mozilla.org/En/Using_XMLHttpRequest">Using XMLHttpRequest</a>
<li><a href="https://developer.mozilla.org/En/DragDrop/Drag_and_Drop">Using HTML5 Drag and Drop</a><br />
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/06/html5-adoption-stories-box-net-and-html5-drag-and-drop/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>upcoming changes to the viewport meta tag for firefox mobile</title>
		<link>http://hacks.mozilla.org/2010/05/upcoming-changes-to-the-viewport-meta-tag-for-firefox-mobile/</link>
		<comments>http://hacks.mozilla.org/2010/05/upcoming-changes-to-the-viewport-meta-tag-for-firefox-mobile/#comments</comments>
		<pubDate>Thu, 27 May 2010 16:59:03 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4952</guid>
		<description><![CDATA[This is a guest post by Matt Brubeck who works on the Firefox Mobile team. The upcoming release of Mobile Firefox (Fennec) 1.1 features improved support for the &#60;meta name="viewport"&#62; tag. Previous version of Fennec supported the width, height, and initial-scale viewport properties, but had problems with some sites designed for iPhone and Android browsers. [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a guest post by <a href="http://limpet.net/mbrubeck/">Matt Brubeck</a> who works on the Firefox Mobile team.</em></p>
<p>The upcoming release of <a href="https://wiki.mozilla.org/Mobile/Fennec">Mobile Firefox (Fennec)</a> 1.1 features improved<br />
support for the <code>&lt;meta name="viewport"&gt;</code> tag.  Previous version of Fennec supported the <code>width</code>, <code>height</code>, and <code>initial-scale</code> viewport properties, but had <a href="http://starkravingfinkle.org/blog/2010/01/perils-of-the-viewport-meta-tag/">problems</a> with some sites designed for iPhone and Android browsers. We now support the same properties Mobile Safari does, and we also changed Fennec to render mobile sites more consistently on screens of different sizes and resolutions.</p>
<p class="caption">touch.facebook.com before:</p>
<p class="figure"><img src="http://limpet.net/mbrubeck/images/2010/05-11-fennec-meta-viewport-2.png"></p>
<p class="caption">touch.facebook.com after:</p>
<p class="figure"><img src="http://limpet.net/mbrubeck/images/2010/05-11-fennec-meta-viewport-1.png"></p>
<p>You can see these changes for yourself in the latest <a href="http://ftp.mozilla.org/pub/mozilla.org/mobile/nightly/latest-mobile-1.9.2/">Fennec 1.1</a> and <a href="http://ftp.mozilla.org/pub/mozilla.org/mobile/nightly/latest-mobile-trunk/">trunk</a> nightly builds for Maemo, Android, Windows, Mac, or Linux.</p>
<h2>Background</h2>
<p>Mobile browers like Fennec render pages in a virtual &ldquo;window&rdquo; (the viewport), usually wider than the screen, so they don&#8217;t need to squeeze every page layout into a tiny window (which would break many non-mobile-optimized sites).  Users can pan and zoom to see different areas of the page.</p>
<p>Mobile Safari introduced the &ldquo;viewport meta tag&rdquo; to let web developers control the viewport&#8217;s size and scale.  Many other mobile browsers now support this tag, although it is not part of any web standard. Apple&#8217;s <a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html#//apple_ref/doc/uid/TP40006509-SW29">documentation</a> does a good job explaining how web developers can use this tag, but we had to do some detective work to figure out exactly how to implement it in Fennec.  For example, Safari&#8217;s documentation says the content is a &ldquo;comma-delimited list,&rdquo; but existing browsers and web pages use any mix of commas, semicolons, and spaces as separators.</p>
<h2>Viewport basics</h2>
<p>A typical mobile-optimized site contains something like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;viewport&quot;</span></span>
<span style="color: #009900;"> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width=device-width, initial-scale=1, maximum-scale=1&quot;</span><span style="color: #66cc66;">/</span>&gt;</span></pre></div></div>

<p>The <code>width</code> property controls the size of the viewport.  It can be set to a specific number of pixels like <code>width=600</code> or to the special value <code>device-width</code> value which is the width of the screen in CSS pixels at a scale of 100%.  (There are corresponding <code>height</code> and <code>device-height</code> values, which may be useful for pages with elements that change size or position based on the viewport height.)</p>
<p>The <code>initial-scale</code> property controls the zoom level when the page is first loaded.  The <code>maximum-scale</code>, <code>minimum-scale</code>, and <code>user-scalable</code> properties control how users are allowed to zoom the page in or out.</p>
<h2>A pixel is not a pixel</h2>
<p>The iPhone and many popular Android phones have 3- to 4-inch (7&ndash;10 cm) screens with 320×480 pixels (~160 dpi).  Firefox for Maemo runs on the Nokia N900, which has the same physical size but 480×800 pixels (~240 dpi).  Because of this, the last version of Fennec displayed many pages about one third smaller (in actual, physical size) than iPhone or Android.  This caused usability and readability problems on many touch-optimized web sites. Peter-Paul Koch wrote about this problem in <a href="http://www.quirksmode.org/blog/archives/2010/04/a_pixel_is_not.html">A pixel is not a pixel</a>.</p>
<p>Fennec 1.1 for Maemo will use 1.5 hardware pixels for each CSS &ldquo;pixel&rdquo;, following the lead of Android&#8217;s WebKit-based browser. This means a page with <code>initial-scale=1</code> will render at close to the same physical size in Fennec for Maemo, Mobile Safari for iPhone, and the Android Browser on both <a href="http://developer.android.com/guide/practices/screens_support.html#range">HDPI and MDPI</a> phones.  This is consistent with the <a href="http://www.w3.org/TR/CSS2/syndata.html#length-units">CSS 2.1 specification</a>, which says:</p>
<blockquote>
<p>If the pixel density of the output device is very different from that of a typical computer display, the user agent should rescale pixel values. It is recommended that the pixel unit refer to the whole number of device pixels that best approximates the reference pixel. It is recommended that the reference pixel be the visual angle of one pixel on a device with a pixel density of 96dpi and a distance from the reader of an arm&#8217;s length.</p>
</blockquote>
<p>For web developers, this means that 320px be full width in portrait mode at scale=1, on all of the above-mentioned handheld devices, and they may size their layouts and images accordingly.  But remember that not all mobile devices are the same width; you should also make sure that your pages work well in landscape mode, and on larger devices like the iPad and Android tablets.</p>
<p>On 240-dpi screens, pages with <code>initial-scale=1</code> will effectively be zoomed to 150% by both Fennec and Android WebKit.  Their text will be smooth and crisp, but their bitmap images will probably not take advantage of the full screen resolution.  To get sharper images on these screens, web developers may want to design images &ndash; or whole layouts &ndash; at 150% of their final size (or 200%, to support the rumored 320-dpi iPhone) and then scale them down using CSS or viewport properties.</p>
<p>Right now Fennec uses the same default ratio of 1.5 on all devices. (It&#8217;s a hidden preference that can be changed in about:config or by an add-on.) Later we&#8217;ll need to change this &ndash; as well as many other parts of Fennec&#8217;s user interface &ndash; to work correctly on screens with different pixel densities.  Note that the default ratio of 1.5 is true only when the viewport scale equals 1.  Otherwise, the relationship between CSS pixels and device pixels depends on the current zoom level.</p>
<h2>Viewport width and screen width</h2>
<p>Many sites set their viewport to <code>"width=320, initial-scale=1"</code> to fit precisely onto the iPhone display in portrait mode.  As mentioned above, this caused <a href="http://starkravingfinkle.org/blog/2010/01/perils-of-the-viewport-meta-tag/">problems</a> when Fennec 1.0 endered these sites, especially in landscape mode.  To fix this, Fennec 1.1 will expand the viewport width if necessary to fill the screen at the requested scale.  This matches the behavior of Android and Mobile Safari, and is especially useful on large-screen devices like the iPad.  (Allen Pike&#8217;s <a href="http://www.antipode.ca/2010/choosing-a-viewport-for-ipad-sites/">Choosing a viewport for iPad sites</a> has a good explanation for web developers.)</p>
<p>For pages that set an initial or maximum scale, this means the <code>width</code> property actually translates into a <em>minimum</em> viewport width.  For example, if your layout needs at least 500 pixels of width then you can use the following markup.  When the screen is more than 500 pixels wide, the browser will expand the viewport (rather than zoom in) to fit the screen:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;viewport&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width=500, initial-scale=1&quot;</span><span style="color: #66cc66;">/</span>&gt;</span></pre></div></div>

<p>Fennec 1.1 also adds support for <code>minimum-scale</code>, <code>maximum-scale</code>, and <code>user-scalable</code>, with defaults and limits similar to <a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html">Safari&#8217;s</a>.  These properties affect the initial scale and width, as well as limiting changes in zoom level.</p>
<p>Mobile browsers handle orientation changes slightly differently. For example, Mobile Safari often just zooms the page when changing from portrait to landscape, instead of laying out the page as it would if originally loaded in landscape.  If web developers want their scale settings to remain consistent when switching orientations on the iPhone, they must add a <code>maximum-scale</code> value to prevent this zooming, which has the sometimes-unwanted side effect of preventing users from zooming in:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;viewport&quot;</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">&quot;initial-scale=1, maximum-scale=1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>This is not necessary in Fennec; when the device changes orientation, Fennec updates the viewport size, the page layout, and JavaScript/CSS properties like <code>device-width</code>, based on its new “window” dimensions.</p>
<h2>Standards</h2>
<p>There is clearly demand for the viewport meta tag, since it is supported by most popular mobile browsers and used by thousands of web sites.  It would be good to have a true standard for web pages to control viewport properties. According to the HTML5 spec, extensions to the <code>meta</code> element should first be registered on the <a href="http://wiki.whatwg.org/wiki/MetaExtensions">WHATWG wiki</a> and then go through the W3C standards process.  If this happens, then we at Mozilla will work to make sure we can implement any changes made during standardization.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/05/upcoming-changes-to-the-viewport-meta-tag-for-firefox-mobile/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Fast JavaScript and Audio: Speech Synthesis in Your Browser</title>
		<link>http://hacks.mozilla.org/2010/05/fast-javascript-and-audio-speech-synthesis-in-your-browser/</link>
		<comments>http://hacks.mozilla.org/2010/05/fast-javascript-and-audio-speech-synthesis-in-your-browser/#comments</comments>
		<pubDate>Wed, 26 May 2010 17:31:27 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Audio]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4945</guid>
		<description><![CDATA[If you haven&#8217;t been keeping track of David Humphrey&#8217;s work to bring audio manipulation to Firefox, you&#8217;re missing out. He&#8217;s made an update post with a huge number of demos, requiring some of the most recent advances in JavaScript found in Firefox &#8211; binary arrays, super-fast tracing-based FFT analysis, etc. This was my favorite bit [...]]]></description>
			<content:encoded><![CDATA[<p>If you haven&#8217;t been keeping track of <a href="http://vocamus.net/dave/?p=1092">David Humphrey&#8217;s work to bring audio manipulation to Firefox</a>, you&#8217;re missing out.  He&#8217;s made an update post with a huge number of demos, requiring some of the most recent advances in JavaScript found in Firefox &#8211; binary arrays, super-fast tracing-based FFT analysis, etc.  This was my favorite bit of <a href="http://vocamus.net/dave/?p=1092">his post</a>:</p>
<p><em>I think that my favourite demo by far this time around is one that I’ve been waiting to see since we first began these experiments.  I’ve written in the past that our work could be used to solve many web accessibility problems.  A few weeks ago I mentioned on irc that someone should take a shot at building a text to speech engine in JavaScript, now that we have typed arrays.  Yury quietly went off and built one based on the <a href="http://www.speech.cs.cmu.edu/flite/">flite engine</a>.  When you run this, remember that you’re watching a browser speak with no plugins of any kind. This is all done in JavaScript.</em></p>
<p><object width="400" height="190"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=12039415&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=12039415&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="190"></embed></object>
<p><a href="http://vimeo.com/12039415">Web Audio Data API &#8211; Text to Speech Demo</a> from <a href="http://vimeo.com/user1962563">David Humphrey</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/05/fast-javascript-and-audio-speech-synthesis-in-your-browser/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Firefox, YouTube and WebM</title>
		<link>http://hacks.mozilla.org/2010/05/firefox-youtube-and-webm/</link>
		<comments>http://hacks.mozilla.org/2010/05/firefox-youtube-and-webm/#comments</comments>
		<pubDate>Wed, 19 May 2010 16:24:23 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Featured Article]]></category>
		<category><![CDATA[Firefox 4]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4817</guid>
		<description><![CDATA[Five important items of note today relating to Mozilla&#8217;s support for the VP8 codec: 1. Google will be releasing VP8 under an open source and royalty-free basis. VP8 is a high-quality video codec that Google acquired when they purchased the company On2. The VP8 codec represents a vast improvement in quality-per-bit over Theora and is [...]]]></description>
			<content:encoded><![CDATA[<p>Five important items of note today relating to <a href="http://blog.mozilla.com/blog/2010/05/19/open-web-open-video-and-webm/">Mozilla&#8217;s support for the VP8 codec</a>:</p>
<p>1. <strong>Google will be releasing VP8 under an open source and royalty-free basis.</strong>  VP8 is a high-quality video codec that Google acquired when they purchased the company <a href="http://www.on2.com">On2</a>.  The VP8 codec represents a vast improvement in quality-per-bit over Theora and is comparable in quality to H.264.</p>
<p>2. <strong>The VP8 codec will be combined with the Vorbis audio codec and a subset of the Matroska container format to build a new standard for Open Video on the web called WebM.</strong>  You can find out more about the project at its new site: <a href="http://www.webmproject.org/">http://www.webmproject.org/</a>.</p>
<p>3. <strong>We will include support for WebM in Firefox.</strong>  You can get super-early <a href="http://nightly.mozilla.org/webm">WebM</a> builds of Firefox 4 pre-alpha today.  WebM will also be included in Google Chrome and Opera.</p>
<p>4. <strong>Every video on YouTube will be transcoded into WebM.</strong>  They have about 1.2 million videos available today and will be working through their back catalog over time.  But they have committed to supporting everything.</p>
<p>5. <strong>This is something that is supported by many partners, not just Google and others.</strong>  Content providers like Brightcove have signed up to support WebM as part of a full HTML5 video solution.  Hardware companies, encoding providers and other parts of the video stack are all part of the list of companies backing WebM.  Even Adobe will be supporting WebM in Flash.  Firefox, with its market share and principled leadership and YouTube, with its video reach are the most important partners in this solution, but we are only a small part of the larger ecosystem of video.</p>
<p>We&#8217;re extremely excited to see Google joining us to support Open Video.  They are making technology available on terms consistent with the Open Web and the W3C Royalty-Free licensing terms.  And &#8211; most importantly &#8211; they are committing to support a full open video stack on the world&#8217;s largest video site.  This changes the landscape for video and moves the baseline for what other sites have to do to maintain parity and keep up with upcoming advances in video technology, not to mention compatibility with the set of browsers that are growing their userbase and advancing technology on the web.</p>
<p>At Mozilla, we&#8217;ve wanted video on the web to move as fast as the rest of the web.  That has required a baseline of open technology to build on.  Theora was a good start, but VP8 is better.  Expect us to start pushing on video innovation with vigor.  We&#8217;ll innovate like the web has, moving from the edges in, with dozens of small revolutions that add up to something larger than the sum of those parts.  VP8 is one of those pieces, <a href="http://caniuse.com/#agents=All&#038;eras=All&#038;cats=HTML5&#038;statuses=rec,pr,cr,wd,ietf">HTML5 </a>is another.  If you watch this weblog, you can start to see those <a href="http://hacks.mozilla.org/2010/04/beyond-html5-experiments-with-interactive-audio/">other pieces starting to emerge as well</a>.  The web is creeping into more and more technologies, with Firefox leading the way.  We intend to keep leading the web beyond HTML5 to the next place it needs to be.</p>
<p>Today is a day of great change.  Tomorrow will be another.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/05/firefox-youtube-and-webm/feed/</wfw:commentRss>
		<slash:comments>96</slash:comments>
		</item>
		<item>
		<title>Firefox 4: the HTML5 parser &#8211; inline SVG, speed and more</title>
		<link>http://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser-inline-svg-speed-and-more/</link>
		<comments>http://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser-inline-svg-speed-and-more/#comments</comments>
		<pubDate>Tue, 11 May 2010 15:55:26 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4685</guid>
		<description><![CDATA[This is a guest post from Henri Sivonen, who has been working on Firefox&#8217;s new HTML5 parser. The HTML parser is one of the most complicated and sensitive pieces of a browser. It controls how your HTML source is turned into web pages and as such changes to it are rare and need to be [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a guest post from <a href="http://hsivonen.iki.fi/">Henri Sivonen</a>, who has been working on Firefox&#8217;s new HTML5 parser.  The HTML parser is one of the most complicated and sensitive pieces of a browser.  It controls how your HTML source is turned into web pages and as such changes to it are rare and need to be well-tested.  While most of Gecko has been rebuilt since its initial inception in the late 90s, the parser was one of the stand-outs as being &#8220;original.&#8221;  This replaces that code with a new parser that&#8217;s faster, compliant with the new HTML5 standard and enables a lot of new functionality as well.</em></p>
<p>A project to replace Gecko’s old HTML parser, dating from 1998, has been ongoing for some time now. The parser was just turned on by default on the trunk, so you can now try it out by simply <A HREF="http://nightly.mozilla.org/">downloading a nightly build</A> without having to flip any configuration switch.</p>
<p>There are four main things that improve with the new HTML5 parser:</p>
<ul>
<li>You can now use SVG and MathML inline in HTML5 pages, without XML namespaces.
<li>Parsing is now done off Firefox&#8217;s main UI thread, improving overall browser responsiveness.
<li>It&#8217;s improved the speed of <CODE>innerHTML</CODE> calls by about 20%.
<li>With the landing of the new parser we&#8217;ve fixed <a href="https://bugzilla.mozilla.org/buglist.cgi?status_whiteboard_type=substring&#038;status_whiteboard=[fixed%20by%20the%20HTML5%20parser]&#038;resolution=FIXED">dozens of long-standing parser related bugs</a>.
</ul>
<p>
<strong><a href="http://hsivonen.iki.fi/test/moz/html5-hacks-demo.html">Try the demo with a</a> <a href="http://nightly.mozilla.org">Firefox Nightly</a> or another HTML5-ready browser.  It should look like this:</a></strong>
</p>
<p>
<a href="http://hsivonen.iki.fi/test/moz/html5-hacks-demo.html"><img src="http://hacks.mozilla.org/wp-content/uploads/2010/05/html5-parser.png"/></a>
</p>
<p><strong>What Is It?</strong></p>
<p>The HTML5 parser in Gecko turns a stream of bytes into a DOM tree according to the <A HREF="http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html">HTML5 parsing algorithm</A>. </p>
<p>HTML5 is the first specification that tells implementors, in detail, how parse HTML. Before HTML5, HTML specifications didn’t say how to turn a stream of bytes into a DOM tree. In theory, HTML before HTML5 was supposed to be defined in terms of SGML. This implied a certain relationship between the source of valid HTML documents and the DOM. However, parsing wasn’t well-defined for invalid documents (and Web content most often isn’t valid HTML4) and there are SGML constructs that were in theory part of HTML but that in reality popular browsers didn’t implement.</p>
<p>The lack of a proper specification led to browser developers filling in the blanks on their own and reverse engineering the browser with the largest market share (first Mosaic, then Netscape, then IE) when in doubt about how to get compatible behavior. This led to a lot of unwritten common rules but also to different behavior across browsers.</p>
<p>The HTML5 parsing algorithm standardizes well-defined behavior that browsers and other applications that consume HTML can converge on. By design, the HTML5 parsing algorithm is suitable for processing existing HTML content, so applications don’t need to continue maintaining their legacy parsers for legacy content. Concretely, in the trunk nightlies, the HTML5 parser is used for all <CODE>text/html</CODE> content.</p>
<p><strong>How Is It Different?</strong></p>
<p>The HTML5 parsing algorithm has two major parts: tokenization and tree building. Tokenization is the process of splitting the source stream into tags, text, comments and attributes inside tags. The tree building phase takes the tags and the interleaving text and comments and builds the DOM tree. The tokenization part of the HTML5 parsing algorithm is closer to what Internet Explorer does than what Gecko used to do. Internet Explorer has had the majority market share for a while, so sites have generally been tested not to break when subjected to IE’s tokenizer. The tree building part is close to what WebKit does already. Of the major browser engines WebKit had the most reasonable tree building solution prior to HTML5.</p>
<p>Furthermore, the new HTML5 parser parses network streams off the main thread. Traditionally, browsers have performed most tasks on the main thread. Radical changes like off-the-main-thread parsing are made possible by the more maintainable code base of the HTML5 parser compared to Gecko’s old HTML parser.</p>
<p><strong>What’s In It for Web Developers?</strong></p>
<p>The changes mentioned above are mainly of interest to browser developers. A key feature of the HTML5 parser is that you don’t notice that anything has changed.</p>
<p>However, there is one big new Web developer-facing feature, too: inline MathML and SVG. HTML5 parsing liberates MathML and SVG from XML and makes them available in the main file format of the Web.</p>
<p>This means that you can include typographically sophisticated math in your HTML document without having to recast the entire document as XHTML or, more importantly, without having to retrofit the software that powers your site to output well-formed XHTML. For example, you can now include the solution for quadratic equations inline in HTML:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;math<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>x<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>=<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mfrac<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mrow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;minus;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>b<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;PlusMinus;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;msqrt<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;msup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>b<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/msup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;minus;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;InvisibleTimes;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>a<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;InvisibleTimes;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>c<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/msqrt<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mrow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mrow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;InvisibleTimes;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>a<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mrow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mfrac<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/math<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Likewise, you can include scalable inline art as SVG without having to recast your HTML as XHTML. As screen sized and pixel densities become more varied, making graphics look crisp at all zoom levels becomes more important. Although it has previously been possible to use SVG graphics in HTML documents by reference (using the <CODE>object</CODE> element), putting SVG inline is more convenient in some cases. For example, an icon such as a warning sign can now be included inline instead of including it from an external file.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;svg</span> <span style="color: #000066;">height</span>=86 <span style="color: #000066;">width</span>=90 <span style="color: #000066;">viewBox</span>=<span style="color: #ff0000;">'5 9 90 86'</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">'float: right;'</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;path</span> <span style="color: #000066;">stroke</span>=#F53F0C <span style="color: #000066;">stroke-width</span>=10 <span style="color: #000066;">fill</span>=#F5C60C <span style="color: #000066;">stroke-linejoin</span>=round <span style="color: #000066;">d</span>=<span style="color: #ff0000;">'M 10,90 L 90,90 L 50,14 Z'</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;line</span> <span style="color: #000066;">stroke</span>=black <span style="color: #000066;">stroke-width</span>=10 <span style="color: #000066;">stroke-linecap</span>=round <span style="color: #000066;">x1</span>=50 <span style="color: #000066;">x2</span>=50 <span style="color: #000066;">y1</span>=45 <span style="color: #000066;">y2</span>=75 <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/svg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Make yourself a page that starts with <code>&lt;!DOCTYPE html&gt;</code> and put these two pieces of code in it and it should work with a new nightly.</p>
<p>In general, if you have a piece of MathML or SVG as XML, you can just copy and paste the XML markup inline into HTML (omitting the XML declaration and the doctype if any). There are two caveats: The markup must not use namespace prefixes for elements (i.e. no <CODE>svg:svg</CODE> or <CODE>math:math</CODE>) and the namespace prefix for the XLink namespace has to be <CODE>xlink</CODE>.</p>
<p>In the MathML and SVG snippits above you’ll see that the inline MathML and SVG pieces above are more HTML-like and less crufty than merely XML pasted inline. There are no namespace declarations and unnecessary quotes around attribute values have been omitted. The quote omission works, because the tags are tokenized by the HTML5 tokenizer—not by an XML tokenizer. The namespace declaration omission works, because the HTML5 tree builder doesn’t use attributes looking like namespace declarations to assign MathMLness or SVGness to elements. Instead, <CODE>&lt;svg&gt;</CODE> establishes a scope of elements that get assigned to the SVG namespace in the DOM and <CODE>&lt;math&gt;</CODE> establishes a scope of elements that get assigned to the MathML namespace in the DOM. You’ll also notice that the MathML example uses named character references that previously haven’t been supported in HTML.</p>
<p>Here’s a quick summary of inline MathML and SVG parsing for Web authors:</p>
<ul>
<li><CODE>&lt;svg&gt;</CODE>…<CODE>&lt;/svg&gt;</CODE> is assigned to the SVG namespace in the DOM.
<li><CODE>&lt;math&gt;</CODE>…<CODE>&lt;/math&gt;</CODE> is assigned to the MathML namespace in the DOM.
<li><CODE>foreignObject</CODE> and <CODE>annotation-xml</CODE> (an various less important elements) establish a nested HTML scope, so you can nest SVG, MathML and HTML as you’d expect to be able to nest them.
<li>The parser case-corrects markup so <CODE>&lt;SVG VIEWBOX=&#8217;0 0 10 10&#8242;&gt;</CODE> works in HTML source.
<li>The DOM methods and CSS selectors behave case-sensitively, so you need to write your DOM calls and CSS selectors using the canonical case, which is camelCase for various parts of SVG such as <CODE>viewBox</CODE>.
<li>The syntax <CODE>&lt;foo/&gt;</CODE> opens and immediately closes the <CODE>foo</CODE> element if it is a MathML or SVG element (i.e. not an HTML element).
<li>Attributes are tokenized the same way they are tokenized in HTML, so you can omit quotes in the same situations where you can omit quotes in HTML (i.e. when the attribute value is not the empty string and does not contain whitespace, <CODE>&quot;</CODE>, <CODE>&#8216;</CODE>, <CODE>`</CODE>, <CODE>&lt;</CODE>, <CODE>=</CODE>, or <CODE>&gt;</CODE>).
<li><B>Warning:</B> the two above features do not combine well due to the reuse of legacy-compatible HTML tokenization. If you omit quotes on the last attribute value, you must have a space before the closing slash. <CODE>&lt;circle fill=green /&gt;</CODE> is OK but <CODE>&lt;circle fill=red/&gt;</CODE> is not.
<li>Attributes starting with <CODE>xmlns</CODE> have <I>absolutely no effect</I> on what namespace elements or attributes end up in, so you don’t need to use attributes starting with <CODE>xmlns</CODE>.
<li>Attributes in the XLink namespace must use the prefix <CODE>xlink</CODE> (e.g. <CODE>xlink:href</CODE>).
<li>Element names must not have prefixes or colons in them.
<li>The content of SVG <CODE>script</CODE> elements is tokenized like they are tokenized in XML—not like the content of HTML <CODE>script</CODE> elements is tokenized.
<li>When an SVG or MathML element is open <CODE>&lt;![CDATA[</CODE>…<CODE>]]&gt;</CODE> sections work the way they do in XML. You can use this to hide text content from older browsers that don’t support SVG or MathML in <CODE>text/html</CODE>.
<li>The MathML named characters are available for use in named character references everywhere in the document (also in HTML content).
<li>To deal with legacy pages where authors have pasted partial SVG fragments into HTML (who knows why) or used a <CODE>&lt;math&gt;</CODE> tag for non-MathML purposes, attempts to nest various common HTML elements as children of SVG elements (without <CODE>foreignObject</CODE>) will immediately break out of SVG or MathML context. This may make some typos have surprising effects.
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser-inline-svg-speed-and-more/feed/</wfw:commentRss>
		<slash:comments>66</slash:comments>
		</item>
		<item>
		<title>Beyond HTML5: experiments with interactive audio</title>
		<link>http://hacks.mozilla.org/2010/04/beyond-html5-experiments-with-interactive-audio/</link>
		<comments>http://hacks.mozilla.org/2010/04/beyond-html5-experiments-with-interactive-audio/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 18:57:33 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Audio]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Device APIs]]></category>
		<category><![CDATA[Featured Demo]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Multi-touch]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[WebGL]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4659</guid>
		<description><![CDATA[This is a re-post of an important post from David Humphrey who has been doing a lot of experiments on top of Mozilla&#8217;s extensible platform and doing experiments with multi-touch, sound, video, WebGL and all sorts of other goodies. It&#8217;s worth going through all of the demos below. You&#8217;ll find some stuff that will amaze [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a <a href="http://vocamus.net/dave/?p=1074">re-post of an important post from David Humphrey</a> who has been doing a lot of experiments on top of Mozilla&#8217;s extensible platform and doing experiments with multi-touch, sound, video, WebGL and all sorts of other goodies.  It&#8217;s worth going through all of the demos below.  You&#8217;ll find some stuff that will amaze and inspire you.</em></p>
<p><em>David&#8217;s work is important because it&#8217;s showing where the web is going, and where Mozilla is helping to take it.  It&#8217;s not enough that we&#8217;re working on HTML5, which we&#8217;re about finished with, but we&#8217;re trying to figure out what&#8217;s next.  Mozilla&#8217;s platform, Gecko, is a huge part of why we&#8217;re able to experiment and learn as fast as we can.  And that&#8217;s reflected with what&#8217;s possible here.  It&#8217;s a web you can see, touch and interact with in new ways.</em></p>
<p><em>David&#8217;s post follows:</em></p>
<p>I’m working with an ever growing group of web, audio, and Mozilla  developers on <a href="http://vocamus.net/dave/?p=974">a project</a> to expose audio  spectrum data to JavaScript from Firefox’s audio and video elements.  Today we show what we did at www2010.</p>
<p>I&#8217;m in Raleigh, North Carolina, with <a href="https://twitter.com/F1LT3R/">Al MacDonald</a> for the <a href="http://www2010.org/www/">www2010</a> conference.  We&#8217;re here to present our work on exposing audio data in the browser.  Over the past month <a href="https://twitter.com/corban">Corban</a>, <a href="https://twitter.com/ccliffe">Charles</a>, and a bunch of other friends have been working with us to refine the API and get new types of demos ready.  We ended-up with 11 demos, some of which I&#8217;ve shown here before.  Here are the others.</p>
<p>The first was done by <a href="http://twitter.com/jseidelin">Jacob Seidelin</a>, and shows many cool 2D visualizations of audio using our API.  You can see the <a href="http://blog.nihilogic.dk/2010/04/html5-audio-visualizations.html">live version</a> on his site, or check out <a href="http://vimeo.com/11355121">this video</a>:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=11355121&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=11355121&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>The second and third demos where done by <a href="https://twitter.com/ccliffe">Charles Cliffe</a>, and show 3D visualizations using WebGL and his <a href="http://www.cubicvr.org/">CubicVR engine</a>.  These also show off his JavaScript beat detection code.  Is JavaScript fast enough to do real-time analysis of audio and synchronized 3D graphics?  Yes, yes it is.  The live versions are <a href="http://cubicvr.org/CubicVR.js/BeatDetektor2HD.html">here</a> and <a href="http://cubicvr.org/CubicVR.js/BeatDetektor1HD.html">here</a>, and here are <a href="http://vimeo.com/11345262">some</a> <a href="http://vimeo.com/11345685">videos</a>:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=11345262&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=11345262&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=11345685&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=11345685&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>The fourth demo was done by <a href="https://twitter.com/corban">Corban Brook</a> and shows how audio data can be mixed live using script.  Here he mutes the main audio, plays it, passes the data through a low pass filter written in JavaScript, then dumps the modified frames into a second audio element to be played.  It&#8217;s a technique we need to apply more widely, as it holds a lot of potential.  Here&#8217;s the <a href="http://weare.buildingsky.net/processing/dsp.js/examples/filter.html">live version</a>, and here&#8217;s a <a href="http://vimeo.com/11335434">video</a> (check out his updated <a href="http://weare.buildingsky.net/processing/dsp.js/examples/synthesizer.html">JavaScript synthesizer</a>, which we also presented):</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=11335434&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=11335434&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>The fifth and sixth demos were done by Al (with the help of many).  When I was last in Boston, for the Processing.js meetup at Bocoup, we met with <a href="http://twitter.com/shepazu">Doug Schepers</a> from the W3C.  He loved our stuff, and was talking to us about ideas that would be cool to build.  He pulled out his iPhone and showed us <a href="http://vimeo.com/2184392">Brian Eno&#8217;s Bloom</a> audio app.  &#8220;It would be cool to do this in the browser.&#8221;  Yeah, it is cool, and here it is, written in a <a href="http://code.bocoup.com/bloop/color/bloop.html">few hundred lines of JavaScript and Processing.js</a> (<a href="http://vimeo.com/11346141">video 1</a>, <a href="http://vimeo.com/11345133">video 2</a>):</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=11346141&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=11346141&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=11345133&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=11345133&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>This demo also showcases the awesome work of <a href="http://felipe.wordpress.com/">Felipe Gomes</a>, who has a patch to add <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=508906">multi-touch DOM events to Firefox</a>.  The method we&#8217;ve used here can be taken a lot further.  Imagine being able to connect multiple browsers together for collaborative music creation, layering other audio underneath, mixing fragments vs. just oscillators, etc.  We built this one in a week, and the web is capable of a lot more.</p>
<p>One of the main points of our talk was to emphasize that what we&#8217;re talking about here isn&#8217;t just a concept, and it isn&#8217;t some far away future.  This is real code, running in a real browser, and it&#8217;s all being done in HTML5 and JavaScript.  The web is fast enough to do real-time audio processing now, powerful enough and expressive enough to create music.  And the community of digital music and audio hackers, visualizers, etc. are hungry for it.  So hungry that they are seeking us out, downloading our hacked builds and creating gorgeous web audio applications.</p>
<p>We want to keep going, and we need help.  We need help from those within Mozilla, the W3C, and other browsers to get this stuff into shipping browsers.  We need the audio, digital music, accessibility, and web communities to come together in order to help us build js audio libraries and more sample applications.  Yesterday <a href="http://twitter.com/joehewitt/status/13090747143">Joe Hewitt was talking on twitter</a> about how web browser vendors need to experiment more with non-standard APIs.  I couldn&#8217;t agree more, and here&#8217;s a chance for people to put their money where their mouth is.  Let&#8217;s make audio a scriptable part of the open web.</p>
<p>I&#8217;m currently creating new builds of our updated patch for Firefox, and will post links to them here when I&#8217;m done.  You can read more about the technical details of our work <a href="https://wiki.mozilla.org/Audio_Data_API">here</a>, and get involved in the bug <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=490705">here</a>.  You can talk more with me on irc in the <a href="irc://irc.mozilla.org/processing.js">processing.js channel</a> (I&#8217;m <em>humph</em> on moznet), or talk to me on twitter (<a href="http://twitter.com/humphd">@humphd</a>) or by <a href="mailto:david.humphrey@senecac.on.ca">email</a>.  One way or another, get in touch so you can help us push this forward.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/04/beyond-html5-experiments-with-interactive-audio/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>WebSockets in Firefox</title>
		<link>http://hacks.mozilla.org/2010/04/websockets-in-firefox/</link>
		<comments>http://hacks.mozilla.org/2010/04/websockets-in-firefox/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 17:11:19 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Feature]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[WebSocket]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4491</guid>
		<description><![CDATA[Here&#8217;s the pitch for WebSockets: a low-complexity, low-latency, bi-directional communication system that has a pretty simple API for web developers. Let&#8217;s break that down, and then talk about if and when we&#8217;re going to include it in Firefox: Low-complexity The WebSocket protocol, which is started via an HTTP-like handshake, has a relatively simple model for [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the pitch for <a href="http://en.wikipedia.org/wiki/Web_Sockets">WebSockets</a>: a low-complexity, low-latency, bi-directional communication system that has a <a href="http://dev.w3.org/html5/websockets/#websocket">pretty simple API</a> for web developers.  Let&#8217;s break that down, and then talk about if and when we&#8217;re going to include it in Firefox:</p>
<p><strong>Low-complexity</strong></p>
<p>The WebSocket protocol, which is started via an HTTP-like handshake, has a relatively simple model for sending text packets back and forth.  The complexity of the protocol is quite low.  There&#8217;s no multiplexing, no support for binary data, and once the data connection is set up, the actual transport is quite cheap.</p>
<p>Note that there are people who feel &#8211; possibly correctly &#8211; that support for multiplexing and binary data should be added.  That would obviously increase the complexity but in some cases might be worth the cost.  But more on that later.</p>
<p><strong>Bi-directional Communication</strong></p>
<p>One of the key aspects of WebSocket is its support for simple bi-directional communication.  Servers can easily send updates to clients and clients can send updates to servers.  Many of the <a href="http://en.wikipedia.org/wiki/Comet_%28programming%29">comet-style</a> applications that people have built will be much simpler and faster with this model because the protocol and API support it directly.</p>
<p>While allowing for bi-directional communication it also is bound by the HTTP same-origin model.  That is, it&#8217;s doesn&#8217;t give the browser the ability to connect to any site on any port it wants to.</p>
<p>So WebSocket is really TCP with the HTTP security model.</p>
<p><strong>Low-latency</strong></p>
<p>This is actually the primary value in WebSockets.  The key thing is that the cost of sending a small amount of data is also very small.  It&#8217;s possible to do bi-directional communication today with comet-style applications, but small amounts of data often require a huge amount of overhead to do so.</p>
<p>A second-hand story to give you a sense of scale: Google Wave, which tries to do real-time communication with keystrokes has a several-kilobyte overhead for just about every keystroke because of the TCP startup, teardown and HTTP message headers involved with what should be only a few bytes sent over the wire.</p>
<p>I haven&#8217;t tried, but I&#8217;m going to guess that if you built <a href="http://code.google.com/p/quake2-gwt-port/">Quake</a> on top of HTTP comet that the interactive experience would be poor.  So this is where WebSockets really shine.</p>
<p><strong>Simple API</strong></p>
<p>The <a href="http://dev.w3.org/html5/websockets/#the-websocket-interface">actual API</a> that a developer sees for WebSocket is relatively simple.  You can send messages, you can get messages, you get events when sockets open, close or there&#8217;s an error.  Additional complexity, which I&#8217;m sure others will develop, will happen in JavaScript and backend libraries.</p>
<p>(While this might seem like punting on the issue of complexity, this is actually the model for success we&#8217;ve seen for other browser standards: build something relatively simple that others can experiment with.  When we understand what&#8217;s slow or what&#8217;s preventing progress, iterate and improve.)</p>
<p><strong>When will it be in Firefox?</strong></p>
<p>We really really want to support WebSockets in the next version of Firefox.  And a lot of other people want us to include support too.</p>
<p><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=472529">The first set of test patches</a>, written by the wonderful Wellington Fernando de Macedo (one of our most excellent contributors!) was first submitted in April of 2009.  Since then we&#8217;ve been iterating both on the patches themselves and following the spec as it&#8217;s changed.</p>
<p>Unfortunately, the spec itself is still under revision.  WebSockets did ship in <a href="http://blog.chromium.org/2009/12/web-sockets-now-available-in-google.html">Chrome</a> with version 4 and I&#8217;m told by Chrome developers that it&#8217;s going to be included in Chrome 5, without changes.  Unfortunately, the <a href="http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75">version that Google included in Chrome</a> doesn&#8217;t reflect the <a href="http://www.whatwg.org/specs/web-socket-protocol/">current draft</a>.  The handshake for how to start a WebSocket connection has changed, largely to improve security on servers.  There&#8217;s also a lot of ongoing discussion on the role of <a href="http://www.ietf.org/mail-archive/web/hybi/current/msg01810.html">integrated compression</a>, direct support for binary data (instead of encoding binary data as strings), whether or not the protocol should support multiplexing and a number of other issues.</p>
<p>Since WebSocket isn&#8217;t used widely yet, and that Chrome has an uptake rate that&#8217;s similar to Firefox, the hope is that once a more recent draft makes it through the process that both Chrome and Firefox can include a more recent version at around the same time.</p>
<p>So in short: we want to ship it because the promise of WebSockets is great, but we&#8217;ll have to see if it&#8217;s stable and safe enough to do so.  Code isn&#8217;t the issue &#8211; we&#8217;ve had that for a while.  It&#8217;s whether or not there&#8217;s consensus on if the protocol is &#8220;done enough&#8221; to ship it to a few hundred million people.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/04/websockets-in-firefox/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>a series of updates on what&#8217;s coming in Firefox 4</title>
		<link>http://hacks.mozilla.org/2010/04/a-series-of-updates-on-whats-coming-in-firefox-4/</link>
		<comments>http://hacks.mozilla.org/2010/04/a-series-of-updates-on-whats-coming-in-firefox-4/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 17:17:06 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4479</guid>
		<description><![CDATA[Over the next couple of weeks, people like Paul Rouget and I are going to post a series of updates on a bunch of technologies that are part of our next release. That release, likely called Firefox 4, was underway before the release of Firefox 3.6 and already includes a bunch of new features, bug [...]]]></description>
			<content:encoded><![CDATA[<p>Over the next couple of weeks, people like <a href="http://twitter.com/paulrouget">Paul Rouget</a> and <a href="http://twitter.com/chrisblizzard">I</a> are going to post a series of updates on a bunch of technologies that are part of our next release.  That release, likely called Firefox 4, was underway before the release of Firefox 3.6 and already includes a bunch of new features, bug fixes and performance enhancements.  (As an aside, I personally suspect that in a lot of ways Firefox 4 is likely to be a revolutionary release for both users and web developers, but more on that in later posts.)</p>
<p>Since we&#8217;re in the middle of the development cycle it&#8217;s important for web developers to know what&#8217;s coming and how they can test them.  We&#8217;ll talk candidly about not only what&#8217;s coming, but why they are important.  Very often in the current race to improve browsers context is lost on why something is or isn&#8217;t included, or why something is higher priority than something else.  We&#8217;ll try and shine some context on a lot of these things as well as give good technical info about our roadmap to the next Firefox release.</p>
<p>So stay tuned, it&#8217;s going to be a fun ride.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/04/a-series-of-updates-on-whats-coming-in-firefox-4/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Theora on N900</title>
		<link>http://hacks.mozilla.org/2010/04/theora-on-n900/</link>
		<comments>http://hacks.mozilla.org/2010/04/theora-on-n900/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 17:00:41 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4383</guid>
		<description><![CDATA[This is a re-post from Matthew Gregan&#8217;s personal weblog on the work that he&#8217;s been doing to bring HTML5 open video to mobile devices. Google recently announced funding for some work to bring Theora to ARM devices via a CPU-driven code path. Mozilla has been funding similar work over the last year or so to [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a re-post from <a href="http://blog.mjg.im/2010/04/16/theora-on-n900.html">Matthew Gregan&#8217;s personal weblog</a> on the work that he&#8217;s been doing to bring HTML5 open video to mobile devices.  Google <a href="http://google-opensource.blogspot.com/2010/04/interesting-times-for-video-on-web.html">recently announced</a> funding for some work to bring Theora to ARM devices via a CPU-driven code path.  Mozilla has been funding <a href="http://www.schleef.org/blog/2009/11/11/theora-on-ti-c64x-dsp-and-omap3/">similar work over the last year or so to do video decoding on DSPs</a> found in mobile devices, leaving the CPU largely idle.</em></p>
<p><em>We realize this post isn&#8217;t strictly web developer-facing, but it&#8217;s interesting enough for those who want to know how this stuff works under the covers.</em></p>
<p><strong>Theora on N900: Or, how to play full-screen Theora video on the N900 with 80% idle CPU.</strong>
<p>The C64x+ DSP is often found in systems built upon TI&#8217;s OMAP3 <abbr title='System On A Chip'>SoC</abbr>, such as the Palm Pre, Motorola Droid, and Nokia N900. Last year, Mozilla funded a port, named Leonora, of Xiph&#8217;s Theora video codec to the TI C64x+ <abbr title='Digital Signal Processor'>DSP</abbr>. David Schleef conducted the port impressively quickly and <a href='http://www.schleef.org/blog/2009/11/11/theora-on-ti-c64x-dsp-and-omap3/'>published his results</a>. The intention of this project was to provide a high quality set of royalty free media codecs for a common mobile computing platform. The initial focus is Firefox Mobile on the N900, so I am working on integrating David&#8217;s work into Firefox. To experiment with other facilities Firefox could use to accelerate video playback and test integration, I&#8217;ve been hacking on a <a href='http://github.com/kinetiknz/plogg'>branch</a> of a stand-alone Ogg Theora and Vorbis player originally written by Chris Double called <a href='http://www.bluishcoder.co.nz/2009/06/27/playing-ogg-files-with-audio-and-video.html'>plogg</a>.</p>
<p>Decoding and playing video can be a CPU intensive process, especially when all of the steps are fighting for time on a single CPU. The expensive parts of the playback process can be broken down into a few coarse pieces, in approximate descending order of cost:</p>
<ol>
<li>Video frame decode</li>
<li>Video colour-space conversion (Y&#8217;CbCr to RGB)</li>
<li>Video frame display</li>
<li>Audio block decode</li>
<li>Audio block playback</li>
</ol>
<p>David&#8217;s DSP work enables item 1 to be off-loaded from the CPU completely, effectively providing &#8220;hardware accelerated&#8221; video decoding. Most devices have some way to off-load items 2 and 3 to the graphics hardware, but it can be difficult to make use of this while integrating with an existing graphics rendering pipeline.</p>
<p>The N900 has a 800&#215;480 pixel display, so my hope was to play a 800&#215;480 video full-screen at 30 frames per second with low CPU use and good battery life.</p>
<p>The ARM CPU in the N900 is quite fast. Doing a pure video-decode-only test, the original Theora library, which currently does not have ARM specific optimizations, is able to decode a 640&#215;360 video at 76 frames per second, and it can even decode an 800&#215;480 video at 32 frames per second. With the <a href='http://google-opensource.blogspot.com/2010/04/interesting-times-for-video-on-web.html'>ARM optimized port by Robin Watts</a>, those numbers become 110 FPS and 47 FPS. David&#8217;s DSP port produces 78 FPS and 39 FPS, and it leaves the CPU completely idle because the entire decode is off-loaded to the DSP. With these numbers, it&#8217;s clear that the N900 is up to the task of playing back video smoothly if we can get the bits on the screen fast enough.</p>
<p>I am using plogg as a basis for experimentation using techniques applicable in the Firefox rendering engine. This requirement immediately excludes some techniques. For example, using hardware Y&#8217;CbCr overlays to display the video frames is excluded because it is not possible for Firefox to render arbitrary HTML content over the top of the overlay.</p>
<p>Chris&#8217;s original version of plogg used SDL&#8217;s Y&#8217;CbCr overlay API, which uses a fast direct overlay path on most systems. This provided a baseline for playback performance. Decoding my 800&#215;480 test video with the DSP, it was possible to play back at 33 FPS with around 20% CPU idle. Unlike the decode-only benchmarks mentioned above, the plogg benchmarks are playing both audio and video with correct A/V synchronisation. With 44.1kHz stereo audio, I observed that 10-15% of the device&#8217;s CPU is used by PulseAudio. This indicates that audio playback may constitute a significant amount of processor time with some configurations.</p>
<p>Because there was already work underway to provide OpenGL accelerated compositing in Firefox with the newly conceived <a href='http://weblogs.mozillazine.org/roc/archives/2010/04/layers.html'>Layers API</a>, it seemed logical to try using a <abbr title='GL Shading Language'>GLSL</abbr> fragment shader to off-load colour-space conversion to the GPU. This turned out to be too slow to play back a full-screen video.</p>
<p>Looking at the list of vendor-specific OpenGL extensions available on the N900, I discovered the <a href='http://www.tiexpressdsp.com/index.php/OpenGLES_Texture_Streaming_-_bc-cat_User_Guide'>texture streaming API</a>. This allows a program to directly map texture memory and copy Y&#8217;CbCr data into that memory without having to perform an expensive texture upload or colour-space conversion. The colour-space conversion is off-loaded to dedicated graphics hardware inaccessible via the standard OpenGL APIs. Using this and the modified bc-cat kernel module from the <a href='http://gitorious.org/gst-plugin-bc/gst-plugin-bc/trees/master'>gst-bc-cat</a> project, it&#8217;s possible to play back at 26 FPS with 81% CPU idle.</p>
<p>One drawback of the current bc-cat kernel driver is that there is a very limited set of texture formats supported (NV12, UYVY, RGB565, and YUYV), and none of them are the same as what Theora produces. To work around this, a format conversion is required to convert planar Y&#8217;CbCr to packed 4:2:2 UYVY. Fortunately, this conversion is much simpler than a full colour-space conversion. Timothy Terriberry sent me a <a href='http://github.com/kinetiknz/plogg/tree/master/patches/'>couple of patches</a> to off-load this conversion work to the DSP. If it&#8217;s possible to extend the bc-cat driver to support texture formats compatible with Theora&#8217;s output, performance can be further improved.</p>
<p>The test files used for benchmarking were: Big Buck Bunny (video: 640&#215;360 @ 500 kbps 24 FPS, audio: 64 kbps 48kHz stereo, 9m 56s, 40MB) and the movie trailer for 9 (video: 800&#215;480 @ 2 Mbps 23.98 FPS, audio: 44.1kHz stereo, 2m 30s, 30MB). Benchmarks were run with the CPU frequency fixed at 600MHz.</p>
<p>In summary, it&#8217;s possible to play full-screen Ogg Theora videos on the N900 at full frame rates with low CPU use by off-loading video decoding to the DSP and colour-space conversion and painting to the GPU. There are opportunities for optimization left, tuning for battery life needs to be investigated, and the integration into Firefox still needs to be done.</p>
<p><em>Video decode-only:</em><br />
<table width='70%'>
<tr>
<th>Decoder</th>
<th>FPS (800&#215;480)</th>
<th>Idle CPU</th>
</tr>
<tr>
<td>libtheora 1.1</td>
<td>32</td>
<td>0.7%</td>
</tr>
<tr>
<td>TheorARM 0.04</td>
<td>47</td>
<td>0.4%</td>
</tr>
<tr>
<td>leonora (DSP)</td>
<td>39</td>
<td>99.0%</td>
</tr>
</table>
<p><em>Playback (video decode + paint, audio decode + not played). DSP decoding video:</em><br />
<table width='70%'>
<tr>
<th>Method</th>
<th>FPS (800&#215;480)</th>
<th>Idle CPU</th>
</tr>
<tr>
<td>SDL/overlay</td>
<td>33</td>
<td>20.0%</td>
</tr>
<tr>
<td>OpenGL/bc-cat</td>
<td>26</td>
<td>81.4%</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/04/theora-on-n900/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>mozilla developer preview 4 ready for testing</title>
		<link>http://hacks.mozilla.org/2010/04/mozilla-developer-preview-4-ready-for-testing/</link>
		<comments>http://hacks.mozilla.org/2010/04/mozilla-developer-preview-4-ready-for-testing/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 18:41:01 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Featured Article]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4364</guid>
		<description><![CDATA[Note: this is a re-post of the entry in the Mozilla Project Development Weblog. There&#8217;s some juicy stuff in here for Web Developers that need testing. In particular, this is the first build with the CSS history changes. As part of our ongoing platform development work, we&#8217;re happy to announce the fourth pre-release of the [...]]]></description>
			<content:encoded><![CDATA[<p><em>Note: this is a re-post of the entry in the <a href="https://developer.mozilla.org/devnews/index.php/2010/04/12/mozilla-developer-preview-number-4-now-available/">Mozilla Project Development Weblog</a>.  There&#8217;s some juicy stuff in here for Web Developers that need testing.  In particular, this is the first build with the CSS history changes.</em></p>
<p>As part of our ongoing platform development work, we&#8217;re happy to announce the fourth pre-release of the Gecko 1.9.3 platform.  Gecko 1.9.3 will form the core of Firefox and other Mozilla project releases.</p>
<p>It&#8217;s <a href="http://www.mozilla.org/projects/devpreview/releasenotes/#download">available for download on Mac, Windows or Linux</a>.</p>
<p>Mozilla expects to release a Developer Preview every 2-3 weeks. If you&#8217;ve been running a previous release, you will be automatically updated to the latest version when it is released. </p>
<p>This preview release contains a lot of interesting stuff that&#8217;s worth pointing out, and contains many things that were also in <a href="http://developer.mozilla.org/devnews/index.php/2010/03/03/mozilla-developer-preview-now-available-with-out-of-process-plugins/">previous releases</a>.  Here are the things of note in this release:</p>
<p><b>User Interface Changes</b></p>
<ul>
<li>Open tabs that match searches in the Awesomebar now show up as &#8220;Switch to Tab.&#8221;</li>
<li>This is the first preview release to contain resizable text areas by default.</li>
</ul>
<p><b>Web Developer Changes</b></p>
<ul>
<li>This is the first preview release to contain changes to CSS :visited that prevent a large class of history sniffing attacks.  You can find more information about the details of why this change is important over on the <a href="http://hacks.mozilla.org/2010/03/privacy-related-changes-coming-to-css-vistited/">hacks post on the topic</a> and on the <a href="http://blog.mozilla.com/security/2010/03/31/plugging-the-css-history-leak/">Mozilla Security Weblog</a>.  Note that this change is likely to break some web sites and requires early testing &#8211; please test if you can.
</li>
<li>SVG Attributes which are mapped to CSS properties can now be animated with SMIL.  See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=534028">the bug</a> or a <a href="http://people.mozilla.org/~dholbert/tests/smil/compat_tests/xmlVsCssChart_v1.svg">demo</a>.
</li>
</ul>
<p><b>Plugins</b></p>
<ul>
<li>
Out of process plugins support for Windows and Linux continues to improve.  This release contains many bug fixes vs. our previous developer preview releases.  (In fact, it&#8217;s good enough that we&#8217;ve ported this code back to the 3.6 branch and have <a href="http://www.mozilla.com/en-US/firefox/lorentz/">pushed that to beta for a later 3.6.x release</a>.)</li>
<li>This is the first release that contains support for out of process plugins for the Mac.  If you are running OSX 10.6 <i>and</i> you&#8217;re running the latest <a href="http://labs.adobe.com/downloads/flashplayer10.html">Flash beta</a>, Flash should run out of process</li>
</ul>
<p><b>Performance</b></p>
<ul>
<li>One area where people complained about performance was restart performance when applying an update.  It turns out that a lot of what made that experience poor wasn&#8217;t startup time, it was browser shutdown time.  We&#8217;ve made a fix since the last preview release that made a <a href="http://autonome.wordpress.com/2010/03/19/firefox-performance-update-startup-and-otherwise-march-19-2010/">whopping 97% improvement in shutdown time</a>.  (That&#8217;s not a typo, it&#8217;s basically free now.)</li>
<li>Our work to reduce the <a href="https://wiki.mozilla.org/Firefox/Goals/2010Q1/IO_Reduction">amount of I/O on the main thread</a> continues unabated.  This preview release will feel much snappier than previous snapshots, and feel <i>much</i> faster than Firefox 3.6.</li>
<li>We continue to add hardware acceleration support.  If you&#8217;re on Windows and you&#8217;ve got decent OpenGL 2 drivers, <a href="http://www.basschouten.com/blog1.php/2010/04/07/firefox-video-goes-up-to-11">open video will use hardware to scale the video when you&#8217;re in full screen mode</a>.  For large HD videos this can make a huge difference in the smoothness of the experience and how much power + CPU are used.  We&#8217;ll be adding OSX and Linux support at some point in the future as well, but we&#8217;re starting with Windows.</li>
<li>We continue to make improvements and bug fixes to our support for Direct2D.  (Not enabled by default.  If you want to turn it on see <a href="http://www.basschouten.com/blog1.php/2010/03/02/presenting-direct2d-hardware-acceleratio">Bas&#8217; post</a>.)  If you&#8217;re running Alpha 4 on Windows Vista or Windows 7, and you&#8217;ve turned on D2D, try running <a href="http://www.tapper-ware.net/stable/web.dom.stresstest.transform/">this stress test example in Alpha 4 vs. Firefox 3.6.</a>  The difference is pretty amazing.  You can also see what this looks like compared to other browsers in this <a href="http://www.tapper-ware.net/files/stresstest.comparison.ogg">this video.</a>  (Thanks to <a href="http://www.tapper-ware.net/">Hans Schmucker</a> for the video and demo.)
</li>
</ul>
<p><b>Platform</b></p>
<ul>
<li>
JS-ctypes, our new easy-to-use system for extension authors who want to call into native code now has support for complex types: structures, pointers, and arrays.  For more information on this, and how easy it can make calling into native code from JavaScript, see <a href="http://blog.mozilla.com/dwitte/2010/03/12/extension-authors-browser-hackers-meet-js-ctypes/">Dan Witte&#8217;s post</a>.</li>
<li>Mozilla is now sporting an infallible allocator.  What is this odd-sounding thing, you ask?  It&#8217;s basically an allocator that when memory can&#8217;t be allocated it aborts instead of returning NULL.  This reduces the surface area for an entire class of security bugs related to checking NULL pointers, and also allows us to vastly simplify a huge amount of Gecko&#8217;s source code.
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/04/mozilla-developer-preview-4-ready-for-testing/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>privacy-related changes coming to CSS :visited</title>
		<link>http://hacks.mozilla.org/2010/03/privacy-related-changes-coming-to-css-vistited/</link>
		<comments>http://hacks.mozilla.org/2010/03/privacy-related-changes-coming-to-css-vistited/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 15:26:13 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4274</guid>
		<description><![CDATA[For more information about this, have a look at David Baron&#8217;s post, the bug and the post on the security blog. For many years the CSS :visited selector has been a vector for querying a user&#8217;s history. It&#8217;s not particularly dangerous by itself, but when it&#8217;s combined with getComputedStyle() in JavaScript it means that someone [...]]]></description>
			<content:encoded><![CDATA[<p><em>For more information about this, have a look at <a href="http://dbaron.org/mozilla/visited-privacy">David Baron&#8217;s post</a>, the <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=147777">bug</a> and the post on the <a href="http://blog.mozilla.com/security/2010/03/31/plugging-the-css-history-leak/">security blog</a>.</em></p>
<p>For many years the <a href="http://www.w3.org/TR/css3-selectors/#the-link-pseudo-classes-link-and-visited">CSS :visited</a> selector has been a vector for querying a user&#8217;s history.  It&#8217;s not particularly dangerous by itself, but when it&#8217;s combined with <code><a href="https://developer.mozilla.org/en/DOM/window.getComputedStyle">getComputedStyle()</a></code> in JavaScript it means that someone can walk through your history and figure out where you&#8217;ve been.  And quickly &#8211; some tests show the <a href="http://saizai.livejournal.com/960791.html">ability to test 210,000 URLs per minute</a>.  At that rate, it&#8217;s possible to brute force a lot of your history or at least establish your <a href="http://panopticlick.eff.org">identity through fingerprinting</a>.  Given that browsers often keep history for a long time it can reveal quite a bit about where you&#8217;ve been on the web.</p>
<p>At Mozilla we&#8217;re serious about protecting people&#8217;s privacy, so we&#8217;re going to fix this problem for our users.  To do so we&#8217;re making changes to how :visited works in Firefox.  We&#8217;re not sure what release this will be part of yet and the fixes are still making their way through code review, but we wanted to give a heads up to people as soon as we understood how we wanted to approach fixing this.</p>
<p>These changes will have some impact on web sites and developers, so you should be aware of them.  At a high level here&#8217;s what&#8217;s changing:</p>
<ul>
<li><code>getComputedStyle</code> (and similar functions like <code>querySelector</code>) will lie.  They will always return values as if a user has never visited a site.</li>
<li>You will still be able to visually style visited links, but you&#8217;re severely limited in what you can use.  We&#8217;re limiting the CSS properties that can be used to style visited links to <code><a href="https://developer.mozilla.org/en/CSS/color">color</a></code>, <code><a href="https://developer.mozilla.org/en/CSS/background-color">background-color</a></code>, <code><a href="https://developer.mozilla.org/en/CSS/border-top-color">border-*-color</a></code>, and <code><a href="https://developer.mozilla.org/en/CSS/outline-color">outline-color</a></code> and the color parts of the <code><a href="https://developer.mozilla.org/en/SVG/Tutorial/Fill_Stroke_and_Gradients">fill</a></code> and <code><a href="https://developer.mozilla.org/en/SVG/Tutorial/Fill_Stroke_and_Gradients">stroke</a></code> properties.  For any other parts of the style for visited links, the style for unvisited links is used instead.  In addition, for the list of properties you can change above, you won&#8217;t be able to set <a href="http://www.w3.org/TR/css3-color/#rgba-color">rgba()</a> or <a href="http://www.w3.org/TR/css3-color/#hsla-color">hsla()</a> colors or <code><a href="http://www.w3.org/TR/css3-color/#transparent">transparent</a></code> on them.</li>
</ul>
<p>These are pretty obvious cases that are used widely.  There are a couple of subtle changes to how selectors work as well:</p>
<ul>
<li>If you use a sibling selector (<a href="http://www.w3.org/TR/css3-selectors/#combinators">combinator</a>) like <code>:visited + span</code> then the <code>span</code> will be styled as if the link were unvisited.</li>
<li>If you&#8217;re using nested link elements (rare) and the element being matched is different than the link whose presence in history is being tested, then the element will be drawn as if the link were unvisited as well.</li>
</ul>
<p>These last two are somewhat confusing, and we&#8217;ll have examples of them up in a separate post.</p>
<p>The impact on web developers here should be minimal, and that&#8217;s part of our intent.  But there are a couple of areas that will likely require changes to sites:</p>
<ul>
<li>If you&#8217;re using <a href="https://developer.mozilla.org/en/CSS/background-image">background images</a> to style links and indicate if they are visited, that will no longer work.
<li>We won&#8217;t support <a href="https://developer.mozilla.org/en/CSS/CSS_transitions">CSS Transitions</a> that related to visitedness.  There isn&#8217;t that much CSS Transition content on the web, so this is unlikely to affect very many people, but it&#8217;s still worth noting as another vector we won&#8217;t support.
</ul>
<p>We&#8217;d like to hear more about how you&#8217;re using CSS :visited and what the impact will be on your site.  If you see something that&#8217;s going to cause something to break, we&#8217;d like to at least get it documented.  Please leave a comment here with more information so others can see it as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/03/privacy-related-changes-coming-to-css-vistited/feed/</wfw:commentRss>
		<slash:comments>169</slash:comments>
		</item>
		<item>
		<title>a quick note on JavaScript engine components</title>
		<link>http://hacks.mozilla.org/2010/03/a-quick-note-on-javascript-engine-components/</link>
		<comments>http://hacks.mozilla.org/2010/03/a-quick-note-on-javascript-engine-components/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 21:23:00 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Feature]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[JägerMonkey]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4143</guid>
		<description><![CDATA[There have been a bunch of posts about the JägerMonkey (JM) post that we made the other day, some of which get things subtly wrong about the pieces of technology that are being used as part of Mozilla&#8217;s JM work. So here&#8217;s the super-quick overview of what we&#8217;re using, what the various parts do and [...]]]></description>
			<content:encoded><![CDATA[<p>There have been a bunch of posts about the <a href="http://hacks.mozilla.org/2010/03/improving-javascript-performance-with-jagermonkey/">JägerMonkey (JM) post</a> that we made the other day, some of which get things subtly wrong about the pieces of technology that are being used as part of Mozilla&#8217;s JM work.  So here&#8217;s the super-quick overview of what we&#8217;re using, what the various parts do and where they came from:</p>
<p>1. <strong>SpiderMonkey.</strong>This is Mozilla&#8217;s core JavaScript Interpreter.  This engine takes raw JavaScript and turns it into an intermediate bytecode.  That bytecode is then interpreted.  SpiderMonkey was responsible for all JavaScript handling in Firefox 3 and earlier.  We continue to make improvements to this engine, as it&#8217;s still the basis for a lot of work that we did in Firefox 3.5, 3.6 and later releases as well.</p>
<p>2. <strong>Tracing.</strong> Tracing was added before Firefox 3.5 and was responsible for much of the big jump that we made in performance.  (Although some of that was because we also improved the underlying SpiderMonkey engine as well.)</p>
<p>This is what we do to trace:</p>
<ol>
<li>Monitor interpreted JavaScript code during execution looking for code paths that are used more than once.
<li>When we find a piece of code that&#8217;s used more than once, optimize that code.
<li>Take that optimized representation and assemble it to machine code and execute it.
</ol>
<p>What we&#8217;ve found since Firefox 3.5 is that when we&#8217;re in full tracing mode, we&#8217;re really really fast.  We&#8217;re slow when we have to &#8220;fall back&#8221; to SpiderMonkey and interpret + record.</p>
<p>One difficult part of tracing is generating code that runs fast.  This is done by a piece of code called <strong>Nanojit</strong>.  Nanojit is a piece of code that was originally part of the <strong>Tamarin</strong> project.  Mozilla isn&#8217;t using most of Tamarin for two reasons: 1. we&#8217;re not shipping ECMAScript 4 and 2. the interpreted part of Tamarin was much slower than SpiderMonkey.  For Firefox 3.5 we took the best part &#8211; Nanojit &#8211; and bolted it to the back of SpiderMonkey instead.</p>
<p>Nanojit does two things: it takes a high-level representation of JavaScript and does optimization.  It also includes an assembler to take that optimized representation and generate native code for machine-level execution.</p>
<p>Mozilla and Adobe continue to collaborate on Nanojit.  Adobe uses Nanojit as part of their ActionScript VM.</p>
<p>3. <strong>Nitro Assembler.</strong> This is a piece of code that we&#8217;re taking from Apple&#8217;s version of webkit that generates native code for execution.  The Nitro Assembler is very different than Nanojit.  While Nanojit takes a high-level representation, does optimization and then generates code all the Nitro Assembler does is generate code.  So it&#8217;s complex, low-level code, but it doesn&#8217;t do the same set of things that Nanojit does.</p>
<p>We&#8217;re using the Nitro assembler (along with a lot of other new code) to basically build what everyone else has &#8211; compiled JavaScript &#8211; and then we&#8217;re going to do what we did with Firefox 3.5 &#8211; bolt tracing onto the back of that.  So we&#8217;ll hopefully have the best of all worlds: SpiderMonkey generating native code to execute like the other VMs with the ability to go onto trace for tight inner loops for even more performance.</p>
<p>I hope this helps to explain what bits of technology we&#8217;re using and how they fit into the overall picture of Firefox&#8217;s JS performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/03/a-quick-note-on-javascript-engine-components/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>Mozilla developer preview (Gecko 1.9.3a2) now available</title>
		<link>http://hacks.mozilla.org/2010/03/mozilla-developer-preview-gecko-1-9-3a2-now-available/</link>
		<comments>http://hacks.mozilla.org/2010/03/mozilla-developer-preview-gecko-1-9-3a2-now-available/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 20:28:57 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Feature]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4126</guid>
		<description><![CDATA[We&#8217;ve posted a new release of our Mozilla developer preview series as a way to test new features that we&#8217;re putting into the Mozilla platform. These features may or may not make it into a future Firefox release, either for desktops or for mobile phones. But that&#8217;s why we do these releases &#8211; to get [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve posted a new release of our Mozilla developer preview series as a way to test new features that we&#8217;re putting into the Mozilla platform.  These features may or may not make it into a future Firefox release, either for desktops or for mobile phones.  But that&#8217;s why we do these releases &#8211; to get testing and feedback early so we know how to treat them.</p>
<p>Note that this release does not contain two things that have gotten press recently: <a href="http://www.basschouten.com/blog1.php/2009/11/22/direct2d-hardware-rendering-a-browser">D2D</a> or the new <a href="http://hacks.mozilla.org/2010/03/improving-javascript-performance-with-jagermonkey/">JavaScript VM</a> work we&#8217;ve been doing.</p>
<p>Since this is a weblog focused on web developers, I think that it&#8217;s important to talk about what&#8217;s new for all of you.  So we&#8217;ll jump right into that:</p>
<h3>Out of Process Plugins</h3>
<p>We did an <a href="http://hacks.mozilla.org/2010/02/mozilla-developer-preview-gecko-1-9-3a1-available-for-download/">a1 release</a> about three weeks ago in order to get testing on some of the new web developer features (which we&#8217;ll list here again.)  The biggest change between that release and this one is the inclusion of out of process plugins for Windows and Linux.  (Mac is a little bit more work and we&#8217;re working on it as fast as our little fingers will type.)</p>
<p>There are a lot of plugins out there on the web, and they exist to varying degrees of quality.  So we&#8217;re pushing plugins out of process so that when <a href="http://www.flickr.com/photos/christopherblizzard/4397728218/">one of them crashes</a> it doesn&#8217;t take the entire browser with it.  (It also has lots of other nice side effects &#8211; we can better control memory usage, CPU usage and it also helps with general UI lag.)</p>
<p>If you want to know more about it, have a look at <a href="http://benjamin.smedbergs.us/blog/2010-03-03/firefox-safe-from-plugin-crashes/">this post by Ben Smedberg</a> who goes over how it works, what prefs you can set and how you can help test it.  It would help us a lot of you did.</p>
<p>(If you really want to get on the testing train we strongly suggest you start running our <a href="http://nightly.mozilla.org">nightly builds</a> which are the ultimate in bleeding edge but are generally stable enough for daily use.)</p>
<p>Anyway, on to the feature list and performance improvements taken from the <a href="https://developer.mozilla.org/devnews/index.php/2010/03/03/mozilla-developer-preview-now-available-with-out-of-process-plugins/">release announcement</a>:</p>
<h3>Web Developer Features</h3>
<ul>
<li>Support for <a href="https://developer.mozilla.org/en/Introducing_Content_Security_Policy">Content Security Policy</a>.  This is largely complete, minus the ability to disable <code>eval()</code>.
</li>
<li>The placeholder attribute for &lt;input/&gt; and &lt;textarea&gt; is now supported.
</li>
<li>Support for SMIL Animation in SVG. Support for animating some SVG attributes is still under development and the <code>animateMotion</code> element isn&#8217;t supported yet.
</li>
<li>Support for CSS Transitions. This support is not quite complete: support for animation of transforms and gradients has not yet been implemented.
</li>
<li>Support for WebGL, which is disabled by default but can be enabled by changing a preference. See <a href="http://hacks.mozilla.org/2009/09/webgl-for-firefox/">this blog post</a> and <a href="http://hacks.mozilla.org/2009/12/webgl-draft-released-today/">this blog post</a> for more details.
</li>
<li>Support for the <code>getClientRects</code> and <code>getBoundingClientRect</code> methods on Range  objects. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=396392">bug 396392</a> for details.</li>
<li>Support for the <code>setCapture</code> and <code>releaseCapture</code> methods on DOM elements. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=503943">bug 503943</a> for details.</li>
<li>Support for the HTML5 <a href="https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history#Adding_and_modifying_history_entries"><code>History.pushState()</code> and <code>History.replaceState()</code> methods and the <code>popstate</code> event</a>. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=500328">bug 500328</a> for details.</li>
<li>Support for the <code><a href="https://developer.mozilla.org/en/CSS/background-image">-moz-image-rect()</a></code> value for background-image. See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=113577">bug 113577</a> for more details.
</li>
</ul>
<p>For the full list of new web developer features please visit our page on <a href="https://developer.mozilla.org/en/Upcoming_Firefox_features_for_developers">Upcoming Features for Web Developers</a>.</p>
<h3>Performance Improvements</h3>
<ul>
<li>We&#8217;ve removed link history lookup from the main thread and made it asynchronous.  This results in <a href="https://wiki.mozilla.org/Firefox/Goals/2010Q1/IO_Reduction">less I/O during page loads</a> and improves overall browser responsiveness.</li>
<li>Loading the <a href="http://www.whatwg.org/specs/web-apps/current-work/">HTML5 spec</a> no longer causes very long browser pauses.
</li>
<li>A large number of layout performance improvements have been made, including work around DOM access times, color management performance, text area improvements and many other hot spots in the layout engine.</li>
<li>The JavaScript engine has many improvements: String handling is improved, faster closures, some support for recursion in TraceMonkey to name a few.</li>
<li>Improvements to the performance of repainting HTML in <code>&lt;foreignObject&gt;</code>.
</li>
<li>Strings are not copied between the main DOM code and <a href="https://developer.mozilla.org/En/Using_web_workers">web workers</a>, improving performance for threaded JavaScript which moves large pieces of data between threads.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/03/mozilla-developer-preview-gecko-1-9-3a2-now-available/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

