<?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>Anurag Bhatnagar&#039;s Blog &#187; Open Source</title>
	<atom:link href="http://www.anuragbhatnagar.com/category/open-source/feed" rel="self" type="application/rss+xml" />
	<link>http://www.anuragbhatnagar.com</link>
	<description></description>
	<lastBuildDate>Wed, 18 Apr 2012 00:39:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Processing.js Bug 1606 &#8211; Review needs work update</title>
		<link>http://www.anuragbhatnagar.com/open-source/processing-js-bug-1606-review-needs-work-update</link>
		<comments>http://www.anuragbhatnagar.com/open-source/processing-js-bug-1606-review-needs-work-update#comments</comments>
		<pubDate>Wed, 14 Dec 2011 20:14:23 +0000</pubDate>
		<dc:creator>anurag</dc:creator>
				<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.anuragbhatnagar.com/?p=374</guid>
		<description><![CDATA[Bug: Link here Commit: Link here At the last checkpoint for this bug, my code had been reviewed by John Buckley and he had suggested some changes. Here&#8217;s the update: Tested it on IE9 to make sure it works, results below:]]></description>
			<content:encoded><![CDATA[<p>Bug: <a href="https://processing-js.lighthouseapp.com/projects/41284/tickets/1606" target="_blank">Link here</a><br />
Commit: <a href="https://github.com/anuragbhatnagar/processing-js/commit/3eeb73e992d9b6879d8aee15d88e1a9534099289" target="_blank">Link here</a></p>
<p>At the last checkpoint for this bug, my code had been reviewed by <a href="https://processing-js.lighthouseapp.com/users/133445" target="_blank">John Buckley</a> and he had suggested some changes.</p>
<p>Here&#8217;s the update:</p>
<pre class="brush: jscript; title: ; notranslate">
/* IE9+ Compatibility mode fix  - Bug 1606*/  

if (document.documentMode &gt;= 9 &amp;&amp; !document.doctype) {
  throw(&quot;DocType directive is missing. The recommended DocType in IE 9 is the HTML 5 DocType: &lt;!DOCTYPE html&gt;&quot;);
}
</pre>
<p>Tested it on IE9 to make sure it works, results below:</p>
<p><center><br />
<a style="float:left;" href="http://www.anuragbhatnagar.com/wp-content/uploads/2011/12/IE9_no_doctype_error.jpg" target="_blank"><img style="width:250px;" src="http://www.anuragbhatnagar.com/wp-content/uploads/2011/12/IE9_no_doctype_error.jpg" alt="PJS sketch in IE9 without any Doctype" /></a><a style="float:right;" href="http://www.anuragbhatnagar.com/wp-content/uploads/2011/12/ie9_doctype.jpg" target="_blank"><img style="width:250px;" src="http://www.anuragbhatnagar.com/wp-content/uploads/2011/12/ie9_doctype.jpg" alt="PJS sketch in IE9 with HTML5 Doctype" /></a><br />
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anuragbhatnagar.com/open-source/processing-js-bug-1606-review-needs-work-update/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update: Processing.js bugs &#8211; review needs work</title>
		<link>http://www.anuragbhatnagar.com/open-source/update-processing-js-bugs-review-needs-work</link>
		<comments>http://www.anuragbhatnagar.com/open-source/update-processing-js-bugs-review-needs-work#comments</comments>
		<pubDate>Fri, 02 Dec 2011 23:03:51 +0000</pubDate>
		<dc:creator>anurag</dc:creator>
				<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.anuragbhatnagar.com/?p=366</guid>
		<description><![CDATA[Just as I was beginning to feel exceptionally lucky, my processing.js bug patches were NOT accepted in the first iteration Check for IE9 non-HTML5 mode filter(BLUR) issue Their status is now changed to &#8220;review-needs-work&#8221;. And work I shall&#8230;with the benefit of comments from John Buckley I am sure it won&#8217;t take too long. Except&#8230; being [...]]]></description>
			<content:encoded><![CDATA[<p>Just as I was beginning to feel exceptionally lucky, <a target="_blank" href="http://www.anuragbhatnagar.com/open-source/progress-made-on-processing-js-blur-filter-bug">my processing.js bug patches</a> were NOT accepted in the first iteration <img src='http://www.anuragbhatnagar.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p><a target="_blank" href="https://processing-js.lighthouseapp.com/projects/41284/tickets/1606-add-check-for-ie9-non-html5-mode">Check for IE9 non-HTML5 mode</a><br />
<a target="_blank" href="https://processing-js.lighthouseapp.com/projects/41284/tickets/1392-filterblur-shifts-contents-of-blurred-image">filter(BLUR) issue</a></p>
<p>Their status is now changed to &#8220;review-needs-work&#8221;. And work I shall&#8230;with the benefit of comments from <a target="_blank" href="http://jbuckley.ca/">John Buckley</a> I am sure it won&#8217;t take too long. Except&#8230; being only two weeks away from finals for this semester, time is of the essence, and I&#8217;m afraid work on them will be put on the back-burner for now.</p>
<p>I did sign up for the second part of the <a target="_blank" href="https://cs.senecac.on.ca/course/dps911">Open Source project</a> though, so I&#8217;m sure I&#8217;ll get through these bugs, and adopt some more in due time <img src='http://www.anuragbhatnagar.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.anuragbhatnagar.com/open-source/update-processing-js-bugs-review-needs-work/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running the Mozilla Mouse lock tests</title>
		<link>http://www.anuragbhatnagar.com/open-source/running-the-mozilla-mouse-lock-tests</link>
		<comments>http://www.anuragbhatnagar.com/open-source/running-the-mozilla-mouse-lock-tests#comments</comments>
		<pubDate>Fri, 02 Dec 2011 22:48:14 +0000</pubDate>
		<dc:creator>anurag</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[makefile]]></category>
		<category><![CDATA[mochi test]]></category>
		<category><![CDATA[mochitest]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[mouselock]]></category>
		<category><![CDATA[mouselockable]]></category>
		<category><![CDATA[mozilla]]></category>

		<guid isPermaLink="false">http://www.anuragbhatnagar.com/?p=354</guid>
		<description><![CDATA[Having written a first draft of the Mozilla mouse lock tests, I went ahead to put it all together and run them on my nightly build. I created a new test branch on my github for the tests I had written, and added the two new files in the conventional mochi test format: I added [...]]]></description>
			<content:encoded><![CDATA[<p>Having written <a href="http://www.anuragbhatnagar.com/open-source/mouselockable-mochi-tests-draft" target="_blank">a first draft</a> of the Mozilla mouse lock tests, I went ahead to put it all together and run them on my nightly build.</p>
<p>I created a <a href="https://github.com/anuragbhatnagar/mozilla-central/tree/test" target="_blank">new test branch on my github</a> for the tests I had written, and added the two new files in the conventional mochi test format:</p>
<pre class="brush: jscript; title: ; notranslate">
    &lt;pre id=&quot;test&quot;&gt;
        &lt;script type=&quot;application/javascript&quot;&gt;

            /** Test for Bug 633602 **/
            /** Test to see if navigator.pointer object is of MouseLockable type **/
            SimpleTest.waitForExplicitFinish()
            SimpleTest.waitForFocus(function() {
              var c = navigator.pointer;
			  var IsSameType = c instanceof MouseLockable;
			  is(IsSameType, true, &quot;Error message&quot;);
              SimpleTest.finish();
            });
        &lt;/script&gt;
    &lt;/pre&gt;
</pre>
<p>I added the two tests in the following directory: mozilla-central\dom\tests\mochitest\mouselock</p>
<p>Edited the Makefile.in to include my tests:</p>
<pre class="brush: jscript; title: ; notranslate">
_TEST_FILES	= \
    test_isInstanceofMouselockable.html \
    test_mouseLockableHasRequiredMethods.html \
</pre>
<p>And I was ready to give them a test after merging in all the final changes from <a href="https://github.com/humphd/mozilla-central" target="_blank">humphd</a>.</p>
<p>I did a rebuild of the firefox in my new test branch after resolving merge conflicts and ran the tests:</p>
<pre class="brush: jscript; title: ; notranslate">
TEST_PATH=dom/tests/mochitest/mouselock/test_isInstanceofMouselockable.html make -C ffobjdir mochitest-plain
TEST_PATH=dom/tests/mochitest/mouselock/test_mouseLockableHasRequiredMethods.html make -C ffobjdir mochitest-plain
</pre>
<p>Results are below. Final step was to send a pull request to the Mozilla MouseLock test module owner <a href="http://raymondhung.wordpress.com/" target="_blank">Raymond</a> <a href="https://github.com/rhung/mozilla-central/pull/5" target="_blank">here</a></p>
<p><center><br />
<a style="float: left;" href="http://www.anuragbhatnagar.com/wp-content/uploads/2011/12/testpassed1.jpg" target="_blank"><img style="width: 250px;" src="http://www.anuragbhatnagar.com/wp-content/uploads/2011/12/testpassed1.jpg" alt="Passed Has Required Methods Test" /></a><a style="float: right;" href="http://www.anuragbhatnagar.com/wp-content/uploads/2011/12/testpassed2.jpg" target="_blank"><img style="width: 250px;" src="http://www.anuragbhatnagar.com/wp-content/uploads/2011/12/testpassed2.jpg" alt="Passed is instance of MouseLockable test" /></a></center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anuragbhatnagar.com/open-source/running-the-mozilla-mouse-lock-tests/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MouseLockable Mochi Tests &#8211; First draft of tests</title>
		<link>http://www.anuragbhatnagar.com/open-source/mouselockable-mochi-tests-draft</link>
		<comments>http://www.anuragbhatnagar.com/open-source/mouselockable-mochi-tests-draft#comments</comments>
		<pubDate>Thu, 01 Dec 2011 13:03:04 +0000</pubDate>
		<dc:creator>anurag</dc:creator>
				<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.anuragbhatnagar.com/?p=343</guid>
		<description><![CDATA[Hurrah! We (mostly Prof. Humphrey) implemented Mouse Lock in Firefox! Following the specs given by W3C, we implemented Mouse Lock that will be shipped in the new version of firefox in the coming few weeks (I believe by Feb 2012). To get a grasp what we accomplished, check out the first demos (ever, on firefox) [...]]]></description>
			<content:encoded><![CDATA[<p>Hurrah! We (mostly Prof. Humphrey) implemented Mouse Lock in Firefox! Following the <a href="http://dvcs.w3.org/hg/webevents/raw-file/default/mouse-lock.html" target="_blank">specs</a> given by <a href="http://www.w3.org/" target="_blank">W3C</a>, we <a href="http://zenit.senecac.on.ca/wiki/index.php/Implementing_the_Mouse_Lock_API_in_Firefox" target="_blank"> implemented Mouse Lock</a> that will be shipped in the new version of firefox in the coming few weeks (I believe by Feb 2012).</p>
<p>To get a grasp what we accomplished, check out the first demos (ever, on firefox) of the mouse lock implementation:</p>
<p><a href="http://humphd.github.com/mozilla-central/mouselock/index.html" target="_blank">Mouse Lock Demos</a></p>
<p>The journey lasted just a couple of weeks, but the amount of new concepts and ideas I was introduced to is amazing. This experience was the first c++ project I was a part of in a non-c++ course (of which I have had only 2). The techniques of Mozilla development, like translating specs into IDL, then coding the classes, using reference tools like <a href="http://mxr.mozilla.org/mozilla-central/" target="_blank">MXR</a> and <a href="http://dxr.mozilla.org/mozilla/" target="_blank">DXR</a>, and debugging in a new environment have been thrilling to learn and participate in. Of-course all of this was in concert with interacting on irc with the open source community, becoming more familiar with git and the make tool, and most of all, going through the actual process of problem solving, solo and in a team.</p>
<p>However, for all the work already done, about 80% of it, we have another 90% left. If the math doesn&#8217;t add up, you can take it with up <a href="http://vocamus.net/dave/" target="_blank">Prof. Humphrey</a> who I have quoted here.</p>
<p>Now the next step of writing tests begins.</p>
<p>I have written 3 <a href="https://developer.mozilla.org/en/Mochitest" target="_blank">Mochi tests</a> for MouseLockable:</p>
<ul>
<li>navigator.pointer (readonly) is a MouseLockable</li>
<li>MouseLockable has lock(), unlock(), islocked()</li>
<li>&#8220;The unlock method cancels the mouse lock state&#8221;</li>
</ul>
<p>Below are the first drafts of the actual js code to test each of them, that I will refactor over the next day and push off to the MouseLockable tests module owner <a target="_blank" href="http://raymondhung.wordpress.com/">Raymond</a>.</p>
<p>All of them passed when I tried them on <a href="http://ted.mielczarek.org/code/mozilla/mochitest-maker/" target="_blank">Mochi Test Maker</a> on my nightly build, after merging in the <a target="_blank" href="https://github.com/humphd/mozilla-central">latest commits</a> last night.</p>
<p>Test 1: Test to see if navigator.pointer object is of MouseLockable typ</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script class=&quot;testbody&quot; type=&quot;text/javascript&quot;&gt;

/** Test for Bug 633602 **/
/** Test to see if navigator.pointer object is of MouseLockable type **/

var c = navigator.pointer;
var IsSameType = c instanceof MouseLockable;
is(IsSameType, true, &quot;Error message&quot;);

&lt;/script&gt;
</pre>
<p>Test 2: Test to see if MouseLockable has lock(), unlock(), islocked()</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script class=&quot;testbody&quot; type=&quot;text/javascript&quot;&gt;

/** Test for Bug 633602 **/
/** Test to see if MouseLockable has lock(), unlock(), islocked() **/

var hasProperty1 = MouseLockable.prototype.hasOwnProperty('lock');
var hasProperty2 = MouseLockable.prototype.hasOwnProperty('islocked');
var hasProperty3 = MouseLockable.prototype.hasOwnProperty('unlock');
var allPassed = false;

if (hasProperty1 &amp;&amp; hasProperty2 &amp;&amp; hasProperty3) { allPassed = true; }

is(allPassed, true, &quot;Error message&quot;);

&lt;/script&gt;
</pre>
<p>Test 3: Test to see if unlock() will cancel the lock() state in MouseLockable</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script class=&quot;testbody&quot; type=&quot;text/javascript&quot;&gt;

/** Test for Bug 633602 **/
/** Test to see if unlock() will cancel the lock() state in MouseLockable **/

var np = navigator.pointer;
var locked = np.islocked();
np.lock = np.lock();
var locked2 = np.islocked();
np.unlock();
var locked3 = np.islocked();

var allPassed = false;

if (!(locked) &amp;&amp; (locked2) &amp;&amp; !(locked3) ) { allPassed = true; }

is(allPassed, true, &quot;Error message&quot;);

&lt;/script&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.anuragbhatnagar.com/open-source/mouselockable-mochi-tests-draft/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Escape key event in Firefox to exit MouseLock</title>
		<link>http://www.anuragbhatnagar.com/open-source/escape-key-event-in-firefox-to-exit-mouselock</link>
		<comments>http://www.anuragbhatnagar.com/open-source/escape-key-event-in-firefox-to-exit-mouselock#comments</comments>
		<pubDate>Sun, 20 Nov 2011 08:36:14 +0000</pubDate>
		<dc:creator>anurag</dc:creator>
				<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.anuragbhatnagar.com/?p=327</guid>
		<description><![CDATA[I&#8217;ve been working on another task in the MouseLock implementation: When ESC key is pressed, mouse lock should exit. I&#8217;ve been going through mxr, dxr and comments in other mozilla bugs, and came up with the following code that we might need to check for the ESC key press: However, it doesn&#8217;t work for now. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on another task in the MouseLock implementation: When ESC key is pressed, mouse lock should exit.</p>
<p>I&#8217;ve been going through mxr, dxr and comments in other mozilla bugs, and came up with the following code that we might need to check for the ESC key press:</p>
<pre class="brush: jscript; title: ; notranslate">
nsEvent* aEvent;
  const nsKeyEvent* keyEvent = static_cast&lt;const nsKeyEvent*&gt;(aEvent);
  int key = keyEvent-&gt;keyCode ? keyEvent-&gt;keyCode : keyEvent-&gt;charCode;

  if (key == NS_VK_ESCAPE) {
	  fprintf(stderr, &quot;Escape key is pressed!&quot;);
	  mIsLocked = PR_FALSE;
  }
</pre>
<p>However, it doesn&#8217;t work for now.</p>
<p>It builds if I insert it in the lock method for now, but I am not sure how to make it work. How will the lock/unlock method know to listen for this event? I am not sure how to implement that in c++ yet&#8230;will continue working on that.</p>
<p>Also, to those who need help setting up Visual Studio as their FF debugger on Windows: <a target="_blank" href="https://cs.senecac.on.ca/~david.humphrey/writing/debugging-firefox.html"</a> and <a target="_blank" href="https://developer.mozilla.org/en/Debugging_Mozilla_on_Windows_FAQ">https://developer.mozilla.org/en/Debugging_Mozilla_on_Windows_FAQ</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Update:</p>
<p>Just found this piece of code:</p>
<pre class="brush: jscript; title: ; notranslate">
// if we can use the keyboard (eg Ctrl+L or Ctrl+E) to open the toolbars, we
// should provide a way to collapse them too.
if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE) {
   FullScreen._shouldAnimate = false;
   FullScreen.mouseoverToggle(false, true);
}
</pre>
<p>http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser.js#4027</p>
<p>Maybe we should also have a variable like _shouldMouseLock. On pressing ESC we can set it to false, and it could trigger the unlock() method. We could use the same variable to trigger unlock when the browser/window/tab loses focus.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anuragbhatnagar.com/open-source/escape-key-event-in-firefox-to-exit-mouselock/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Progress made on processing.js blur filter bug</title>
		<link>http://www.anuragbhatnagar.com/open-source/progress-made-on-processing-js-blur-filter-bug</link>
		<comments>http://www.anuragbhatnagar.com/open-source/progress-made-on-processing-js-blur-filter-bug#comments</comments>
		<pubDate>Sun, 20 Nov 2011 04:28:37 +0000</pubDate>
		<dc:creator>anurag</dc:creator>
				<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.anuragbhatnagar.com/?p=315</guid>
		<description><![CDATA[It&#8217;s been a while since I reported my progress on the blur filter bug assigned to me. I made some progress last week by isolating the shifting caused in the canvas to these lines of code, using breakpoints through firebug. After playing around for a little bit to determine the magnitude of the shift caused, [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I reported my progress on the <a target="_blank" href="https://processing-js.lighthouseapp.com/projects/41284/tickets/1392-filterblur-shifts-contents-of-blurred-image">blur filter bug</a> assigned to me. I made some progress last week by isolating the shifting caused in the canvas to <a target="_blank" href="https://github.com/anuragbhatnagar/processing-js/blob/t1606/processing.js#L15557">these lines of code</a>, using breakpoints through firebug. </p>
<p>After playing around for a little bit to determine the magnitude of the shift caused, I saw when I subtracted 200 from the yi and ymi values, the shifting seemed to stop. In this case, my canvas size had been (200,200). I tried changing the canvas size and the value I had to subtract from the variables to seemingly remove any shifting, and it was exactly the value of the width of the canvas. I also tried changing the height of the canvas, to not be the same as the width, and as long as I subtracted the width from those variables, the shifting seemed to be gone. </p>
<p>Next, I needed to find out how to refer to the width of the canvas in the code. I searched the entire processing.js file for variables containing &#8216;width&#8217; and &#8216;canvas&#8217;, but didn&#8217;t find the correct reference. After sometime I dropped by the #processing.js channel on irc, and got my answer from pomax. I adjusted the code in the processing.js file as follows: </p>
<pre class="brush: jscript; highlight: [2,3]; title: ; notranslate">

        // subtract canvas width to adjust for shifting canvas (bug #1392)
        yi += aImgWidth-p.externals.canvas.width;
        ymi += aImgWidth-p.externals.canvas.width;
        ym++;
      }
</pre>
<p>I ran several tests in processing js helper using different canvas values. When I was confident I had adjusted for the shifting, I started to research how to write ref tests, as pomax had suggested this should be my next step before I request a peer review. </p>
<p>I wound up at this page on <a target="_blank" href="https://processing-js.lighthouseapp.com/projects/41284/writing-automated-tests">how to write ref tests</a>.</p>
<p>Step 1 &#8211; I used the following sketch to build the ref test using the generator (located in: processing-js / test / ref / ref-test-builder.html):</p>
<pre class="brush: jscript; title: ; notranslate">
void setup ()
{
    size( 100, 100 );
}

void draw ()
{
    for ( int i = 0; i &lt; 5; i++ )
    {
        fill(200);
        ellipse(25,30,35,40);
    }
    filter( BLUR );
    exit();
}
</pre>
<p>Step 2 &#8211; I put the generated code in blurFilter.pde file and in the processing-js / test / ref / directory.<br />
Step 3 &#8211; I edited tests.js in the same directory to include the test file I just created as the first test and tagged it under &#8217;2D&#8217;.</p>
<pre class="brush: jscript; highlight: [2]; title: ; notranslate">
var tests = [
  { path: &quot;blurFilter.pde&quot;, tags: [&quot;2D&quot;] },
  { path: &quot;stretch.pde&quot;, tags: [&quot;3D&quot;] },
  { path: &quot;arc-fill-crisp.pde&quot;, tags: [&quot;2D&quot;], epsilonOverride: 0.07 },
</pre>
<p>Step 4 &#8211; I ran index.html, selected 2D tests only, and hit start.<br />
Step 5 &#8211; Voila! My test passed!</p>
<p>I also ran the test again after reverting the changes I made to adjust the shifting canvas, to make sure the test did fail before my changes. Sure enough, they did, and you can clearly see the direction in which the canvas shifted in the red pixels marking the offset in the failed test.</p>
<p>Committed the code <a target="_blank" href="https://github.com/anuragbhatnagar/processing-js/commit/4a3eb5b28a8b4f384fb0319646057bd003988ea2">here</a>, and the final commit after all changes <a target="_blank" href="https://github.com/anuragbhatnagar/processing-js/commit/b095a071d07eb45cba72834d8ea7b685f8514a37">here</a>. Will be requesting peer review on lighthouse next.</p>
<p>Screen-shots of failed and passed tests attached below:</p>
<p>Mine if the first test in the screenshot, check out the red mark in the failed test screenshot showing how the canvas had been shifting before.</p>
<p><center><br />
<a style="float:left;" href="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/pjs_failed.jpg" target="_blank"><img style="width:250px;" src="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/pjs_failed.jpg" alt="Failed test for Bug 1392" /></a><a style="float:right;" href="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/pjs_success.jpg" target="_blank"><img style="width:250px;" src="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/pjs_success.jpg" alt="Successful test for Bug 1392" /></a><br />
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anuragbhatnagar.com/open-source/progress-made-on-processing-js-blur-filter-bug/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Taking on a task in the Mouse Lock implementation</title>
		<link>http://www.anuragbhatnagar.com/open-source/taking-on-a-task-in-the-mouse-lock-implementation</link>
		<comments>http://www.anuragbhatnagar.com/open-source/taking-on-a-task-in-the-mouse-lock-implementation#comments</comments>
		<pubDate>Sat, 19 Nov 2011 07:33:06 +0000</pubDate>
		<dc:creator>anurag</dc:creator>
				<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.anuragbhatnagar.com/?p=304</guid>
		<description><![CDATA[Now that I am getting a handle on the code (limited to the MouseLockable class) and encouraged by the progress made by Diogo and Raymond in implementing some of the tasks required for the Mouse Lock implementation, I decided to jump right in as well. One of the requirements as per the specs is that [...]]]></description>
			<content:encoded><![CDATA[<p>Now that I am getting a handle on the code (limited to the MouseLockable class) and encouraged by the progress made by <a href="http://diogogmt.wordpress.com/2011/11/18/mouselocklost-event/" target="_blank">Diogo</a> and <a target="_blank" href="http://raymondhung.wordpress.com/2011/11/19/road-to-mouse-lock-part-3/">Raymond</a> in implementing some of the tasks required for the Mouse Lock implementation, I decided to jump right in as well.</p>
<p>One of the requirements as per the specs is that the mouse cursor not be displayed while the mouse lock is on. So clearly, this method will be called from within the lock() method which we&#8217;ve got a start on. Next idea that immediately comes to mind is to somehow use the code that implements the CSS property of &#8216;cursor:none&#8217; to achieve the same goal within the window that has mouse lock enabled.</p>
<p>Some of my colleagues have also started on the same road and I thought I would join in and discover with them.</p>
<p>The first breakthrough was to stumble upon this: <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=346690">Bug 346690</a>. It is the bug that implements the Cursor:None property of CSS3 in firefox. Going through the discussion in the comments of that thread gave me various clues like &#8216;OnHideCursor()&#8217; method and where some of the code relating to this implementation was saved. For windows, it is found in the file: mozilla-central/widget/src/windows/nsWindow.cpp.</p>
<p>I found an interesting part of the code in this file <a target="_blank" href="https://github.com/anuragbhatnagar/mozilla-central/blob/mouselockable/widget/src/windows/nsWindow.cpp#L2427">here</a>:</p>
<pre class="brush: jscript; title: ; notranslate">
case eCursor_none:
      newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_NONE));
      break;
</pre>
<p>It seems to be the code where the properties for the cursor are set in c++. So the next step is to study it further, discuss on irc and use <a href="http://mxr.mozilla.org" target="_blank">mxr</a> and <a href="http://dxr.mozilla.org" target="_blank">dxr</a> to find more clues as to how the CSS3 cursor none property was implemented.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anuragbhatnagar.com/open-source/taking-on-a-task-in-the-mouse-lock-implementation/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Finally getting down to coding the MouseLock implementation in Firefox</title>
		<link>http://www.anuragbhatnagar.com/open-source/finally-getting-down-to-coding-the-mouselock-implementation-in-firefox</link>
		<comments>http://www.anuragbhatnagar.com/open-source/finally-getting-down-to-coding-the-mouselock-implementation-in-firefox#comments</comments>
		<pubDate>Sat, 19 Nov 2011 07:17:07 +0000</pubDate>
		<dc:creator>anurag</dc:creator>
				<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.anuragbhatnagar.com/?p=297</guid>
		<description><![CDATA[Continuing development on the implementation of the mouse lock bug, I&#8217;ve caught up to my fellow students and Prof. Humphrey in DPS909 by setting up the lock() method. In my last blog post on the implementation of the MouseLock bug I mentioned I had a working build of firefox with the MouseLockable class code. Yesterday [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing development on the implementation of <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602" target="_blank">the mouse lock bug</a>, I&#8217;ve caught up to my fellow students and Prof. Humphrey in DPS909 by setting up the lock() method.</p>
<p>In my last blog post on the implementation of the <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602" target="_blank">MouseLock bug</a> I mentioned I had a working build of firefox with the MouseLockable class code. Yesterday I was able to add the init() and lock() methods to the class, and re-build successfully. I also did a small test in the web console of the nightly build to test the code:</p>
<p><center><a href="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/scr21.jpg" target="_blank"><img src="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/scr21.jpg" style="width:300px;" /></a></center></p>
<p>The lock() and unlock() methods are not yet implemented, but I am just changing the value of a variable to test that the code works so far, here it is:</p>
<pre class="brush: jscript; title: ; notranslate">
nsresult
nsDOMMouseLockable::Init(nsIDOMWindow* aContentWindow)
{
  NS_ENSURE_ARG_POINTER(aContentWindow);
  // Hang on to the window so we can check for fullscreen
  mWindow = aContentWindow;
  return NS_OK;
}

/* void lock (); */
NS_IMETHODIMP nsDOMMouseLockable::Lock()
{
  mWindow-&gt;GetFullScreen(&amp;mIsLocked);
  mIsLocked = PR_TRUE;
  return NS_OK;
}

/* void unlock (); */
NS_IMETHODIMP nsDOMMouseLockable::Unlock()
{
  mIsLocked = PR_FALSE;
  return NS_OK;
}

/* bool islocked (); */
NS_IMETHODIMP nsDOMMouseLockable::Islocked(bool *_retval NS_OUTPARAM)
{
  NS_ENSURE_ARG_POINTER(_retval);
  *_retval = mIsLocked;
  return NS_OK;
}
</pre>
<p>Since my last post, I pulled in code from <a href="https://github.com/humphd/mozilla-central" target="_blank">humphd</a>, <a href="https://github.com/diogomgt/mozilla-central" target="_blank">diogogmt</a> and <a href="https://github.com/rhung/mozilla-central" target="_blank">rhung</a> into my repository and merged their changes with mine.</p>
<p>Here is my latest <a href="https://github.com/anuragbhatnagar/mozilla-central/commit/11faa51b1265f25c422694adf059ea9b802d12d6"  target="_blank"> commit</a> after the merges and the lock() method code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anuragbhatnagar.com/open-source/finally-getting-down-to-coding-the-mouselock-implementation-in-firefox/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tinkering with Firefox Code as a beginner &#8211; lessons learned</title>
		<link>http://www.anuragbhatnagar.com/open-source/tinkering-with-firefox-code-as-a-beginner-lessons-learned</link>
		<comments>http://www.anuragbhatnagar.com/open-source/tinkering-with-firefox-code-as-a-beginner-lessons-learned#comments</comments>
		<pubDate>Wed, 09 Nov 2011 17:35:14 +0000</pubDate>
		<dc:creator>anurag</dc:creator>
				<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.anuragbhatnagar.com/?p=278</guid>
		<description><![CDATA[I was fortunate to have a good start in building firefox for the first time &#8211; except the windows style line endings error &#8211; I didn&#8217;t have any other difficulties and was able to get the build running locally quickly. However, when I started to play around to make a change to the source code, [...]]]></description>
			<content:encoded><![CDATA[<p>I was fortunate to have a good start in building firefox for the first time &#8211; except the windows style line endings error &#8211; I didn&#8217;t have any other difficulties and was able to get the build running locally quickly.</p>
<p>However, when I started to play around to make a change to the source code, I started getting into a lot of trouble. I have been trying to re-build firefox for about the last 4 hours, and only now got it to work again. Here&#8217;s what happened and what I learned:</p>
<p>For my first mod to the code, I thought I would insert a printf statement just before an error that I was getting on my build:</p>
<p><center><a href="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/scr7.jpg" target="_blank"><img style="width:350px;" src="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/scr7.jpg" alt="Firefox debug mode build" /></a></center></p>
<p>The error was inside a .cpp file inside my object directory. Even though it was inside my objdir, I thought it will be safe to make a change, as I was modifying a cpp file and not .obj file. I made the following change to the code, just before the line that threw the exception that I saw in my build.</p>
<pre class="brush: jscript; highlight: [4]; title: ; notranslate">
if ( aInstancePtr )
      {
        nsCOMPtr&lt;nsISupportsWeakReference&gt; factoryPtr = do_QueryInterface(aInstancePtr, &amp;status);
        printf(&quot;My first printf! Woohoo!&quot;);
        NS_ASSERTION(factoryPtr, &quot;Oops!  You're asking for a weak reference to an object that doesn't support that.&quot;);
        if ( factoryPtr )
          {
            status = factoryPtr-&gt;GetWeakReference(&amp;result);
          }
        // else, |status| has already been set by |do_QueryInterface|
      }
</pre>
<p>I ran the make command again in a different objdir and waited for the new ff to build, but it kept stalling at different steps. I waited for over 30 minutes the first time, and then an hour and so on but the make command would just freeze. I tried building with slightly different config options (disabling debug and test just to build quickly), but it still kept hanging.</p>
<p>During this whole time that it was building and failing, I was going over the different folders and files of the source code. While the folder names and file names made some sense, opening the file and trying to understand the code made far lesser sense. Even in files I thought I will be able to follow the more code I read, I got lost very quickly.</p>
<p>Then, I made a small change to one of the only files I could make sense of:</p>
<p>\mozilla-central\browser\branding\nightly\pref\firefox-branding.js</p>
<p>There were no comments for the lines I changed, but they were self-explanatory &#8211; they set the default url for firefox. I changed the value of the url from about:blank to the url for Planet CDOT.</p>
<pre class="brush: jscript; title: ; notranslate">
pref(&quot;startup.homepage_override_url&quot;,&quot;http://zenit.senecac.on.ca/~chris.tyler/planet/&quot;);
pref(&quot;startup.homepage_welcome_url&quot;,&quot;http://zenit.senecac.on.ca/~chris.tyler/planet/&quot;);
</pre>
<p>I made the same change in another similar file I found, but then reverted it back, because I thought this was the reason my build didn&#8217;t work (the comments had warned not to make the change):</p>
<p>\mozilla-central\browser\branding\nightly\locales\browserconfig.properties</p>
<pre class="brush: jscript; title: ; notranslate">
# Do NOT localize or otherwise change these values
browser.startup.homepage=about:blank
</pre>
<p>I had been trying the re-build in another objdir all this while because I wanted to save the working build I had, and also preserve one of the changes I had made to a .cpp file inside it. This is when I realized how silly it is to modify a file (whichever type of file) inside the objdir &#8211; because the changes will just get overwritten with a new build. And if you don&#8217;t rebuild, the changes will never take effect. (I know&#8230;.I can&#8217;t believe it took me to long to realize this <img src='http://www.anuragbhatnagar.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> )</p>
<p>So it was pretty straight-forward from here, I delete all the other objdirs I had created leaving the original one that worked. I ran the make command again, targeting the same objdir &#8211; the build worked, taking just 16 minutes, as most of the object files didn&#8217;t have to be compiled again.</p>
<p>I knew my printf change was a lost cause, but I was hoping to see if the other change I made (changing the default url) would work. I didn&#8217;t expect it to work because there was the other properties files that still clearly defined the start-up homepage as &#8216;about:blank&#8217;, but somehow &#8211; and you&#8217;ll just have to trust me on this (or try it for yourself) &#8211; the default url that the firefox nightly build opened with was Planet CDOT!</p>
<p><center><a href="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/scr6.jpg" target="_blank"><img style="width:350px;" src="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/scr6.jpg" alt="Firefox debug mode build" /></a></center></p>
<p>While going through the c++ code and the &#8220;wall&#8221; of text during the builds, I noticed a lot of interface names and class names began with the prefix &#8216;ns&#8217;. For example, nsIArray. I wondered if this was a remnant of the code borrowed into the Mozilla project from &#8216;Netscape&#8217;. I have seen the NS prefix in class names in ios code library (iPhone) too, but that was because that code was imported from NextStep, which was the second company founded by Steve Jobs after he left Apple, which was merged back into Apple when he re-joined. </p>
<p>So I googled to see if my assumption was right, and it turns out the stated reason for why a lot of the code has the &#8216;ns&#8217; prefix is because it stands for &#8216;Namespace&#8217;. Strange.</p>
<p>Anyway, in that search I also came across this useful article:</p>
<p><a href="https://developer.mozilla.org/En/Mozilla_Coding_Style_Guide" target="_blank">https://developer.mozilla.org/En/Mozilla_Coding_Style_Guide</a></p>
<p>Stay tuned for my first working printf in Mozilla code&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anuragbhatnagar.com/open-source/tinkering-with-firefox-code-as-a-beginner-lessons-learned/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Making a Firefox Debug Build on Windows</title>
		<link>http://www.anuragbhatnagar.com/open-source/making-a-firefox-debug-build-on-windows</link>
		<comments>http://www.anuragbhatnagar.com/open-source/making-a-firefox-debug-build-on-windows#comments</comments>
		<pubDate>Wed, 09 Nov 2011 11:51:07 +0000</pubDate>
		<dc:creator>anurag</dc:creator>
				<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.anuragbhatnagar.com/?p=266</guid>
		<description><![CDATA[As the first step towards setting up my development environment for working on the Mouse Lock Implementation on Firefox, I cloned the unofficial Mozilla Central repo, having sanitized it for windows style line-endings. I checked out a branch that I will work on for the bug. Next step was to download the Mozilla build package [...]]]></description>
			<content:encoded><![CDATA[<p>As the first step towards setting up my development environment for working on the Mouse Lock Implementation on Firefox, I cloned the unofficial Mozilla Central repo, having <a target="_blank" href="http://zenit.senecac.on.ca/wiki/index.php/Mouse_Lock_Implementation_FAQ#How_do_I_resolve_the_windows_line_ending_error_when_trying_to_build_FireFox.3F">sanitized it for windows style line-endings</a>. I checked out a branch that I will work on for the <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602" target="_blank">bug</a>. </p>
<p>Next step was to download <a href="http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32/MozillaBuildSetup-Latest.exe" target="_blank">the Mozilla build package for Windows</a>, that includes most of the tools I will need to setup, configure and then debug the Mozilla code.</p>
<p>After installing it I ran the start-msvc10 bat file and navigated to the mozilla-central directory. I edited the .mozconfig file for the firefox debug build with the following options:</p>
<pre class="brush: jscript; title: ; notranslate">
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/ff-dbg-objdir
mk_add_options MOZ_MAKE_FLAGS=-j5
ac_add_options --enable-application=browser
ac_add_options --disable-optimize
ac_add_options --enable-debug
ac_add_options --enable-tests
</pre>
<p>The documentation I consulted for these configurations can be found <a href="https://developer.mozilla.org/en/Configuring_Build_Options" target="_blank">here</a>.</p>
<p>The next step was to just call the make command to do its thing:</p>
<pre class="brush: jscript; title: ; notranslate">
time make -f client.mk build &gt; log.txt
</pre>
<p>The log file of my make command is available <a href="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/log.txt" target="_blank">here</a>.</p>
<p>In an compile time of 32 minutes, my Intel i3 dual core took just 4 and a half minutes (running up to 5 processes concurrently as set in the configure options), to compile about 3680 object files (to calculate this, run this command on your objdir -> find . -name &#8216;*.obj&#8217; -type f | wc -l).</p>
<p>I found my local firefox build in this location: \mozilla-central\ff-dbg-objdir\dist\bin</p>
<p>It ran with a lot of warnings, which I understand is normal, but I did get a local build of firefox in debug mode working on my machine!</p>
<p>Next step&#8230;diving into the code and start hacking. Stay tuned&#8230;<br />
<center><br />
<a href="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/scr2.jpg" target="_blank"><img style="width:350px;" src="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/scr2.jpg" alt="Firefox debug mode build" /></a><br />
<a href="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/scr4.jpg" target="_blank"><img style="width:350px;" src="http://www.anuragbhatnagar.com/wp-content/uploads/2011/11/scr4.jpg" alt="Firefox debug mode build" /></a><br />
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anuragbhatnagar.com/open-source/making-a-firefox-debug-build-on-windows/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

