Merge mozilla-central into services-central
authorGregory Szorc <gps@mozilla.com>
Tue, 03 Jul 2012 09:55:45 -0700
changeset 98768 55cf49a44cdc66d9a01f0e78a83635fddda5d436
parent 98767 d07cb07160dd75a9dd7a678dbeeb439dafd24790 (current diff)
parent 98227 edf132b767b0fc739e3b80b35e2870c051846936 (diff)
child 98769 5099eb0d0287ed8214ce5c650e43ec2eb8322bcc
push id11640
push userryanvm@gmail.com
push dateTue, 10 Jul 2012 00:53:29 +0000
treeherdermozilla-inbound@6b0d194eabed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge mozilla-central into services-central
b2g/config/mozconfigs/desktop/linux32/nightly
b2g/config/mozconfigs/desktop/linux64/nightly
b2g/config/mozconfigs/desktop/macosx64/nightly
b2g/config/mozconfigs/desktop/win32/nightly
b2g/config/mozconfigs/linux32/debug
b2g/config/mozconfigs/linux32/nightly
config/nsinstall_win.c
dom/apps/src/Webapps.jsm
extensions/spellcheck/hunspell/tests/1463589.aff
extensions/spellcheck/hunspell/tests/1463589.dic
extensions/spellcheck/hunspell/tests/1463589.sug
extensions/spellcheck/hunspell/tests/1463589.test
extensions/spellcheck/hunspell/tests/1463589.wrong
extensions/spellcheck/hunspell/tests/1463589_utf.aff
extensions/spellcheck/hunspell/tests/1463589_utf.dic
extensions/spellcheck/hunspell/tests/1463589_utf.sug
extensions/spellcheck/hunspell/tests/1463589_utf.test
extensions/spellcheck/hunspell/tests/1463589_utf.wrong
extensions/spellcheck/hunspell/tests/1592880.aff
extensions/spellcheck/hunspell/tests/1592880.dic
extensions/spellcheck/hunspell/tests/1592880.good
extensions/spellcheck/hunspell/tests/1592880.test
extensions/spellcheck/hunspell/tests/1695964.aff
extensions/spellcheck/hunspell/tests/1695964.dic
extensions/spellcheck/hunspell/tests/1695964.sug
extensions/spellcheck/hunspell/tests/1695964.test
extensions/spellcheck/hunspell/tests/1695964.wrong
extensions/spellcheck/hunspell/tests/1706659.aff
extensions/spellcheck/hunspell/tests/1706659.dic
extensions/spellcheck/hunspell/tests/1706659.test
extensions/spellcheck/hunspell/tests/1706659.wrong
extensions/spellcheck/hunspell/tests/1975530.aff
extensions/spellcheck/hunspell/tests/1975530.dic
extensions/spellcheck/hunspell/tests/1975530.good
extensions/spellcheck/hunspell/tests/1975530.test
extensions/spellcheck/hunspell/tests/1975530.wrong
extensions/spellcheck/hunspell/tests/2970240.aff
extensions/spellcheck/hunspell/tests/2970240.dic
extensions/spellcheck/hunspell/tests/2970240.good
extensions/spellcheck/hunspell/tests/2970240.test
extensions/spellcheck/hunspell/tests/2970240.wrong
extensions/spellcheck/hunspell/tests/2970242.aff
extensions/spellcheck/hunspell/tests/2970242.dic
extensions/spellcheck/hunspell/tests/2970242.good
extensions/spellcheck/hunspell/tests/2970242.test
extensions/spellcheck/hunspell/tests/2970242.wrong
extensions/spellcheck/hunspell/tests/2999225.aff
extensions/spellcheck/hunspell/tests/2999225.dic
extensions/spellcheck/hunspell/tests/2999225.good
extensions/spellcheck/hunspell/tests/2999225.test
extensions/spellcheck/hunspell/tests/IJ.aff
extensions/spellcheck/hunspell/tests/IJ.dic
extensions/spellcheck/hunspell/tests/IJ.good
extensions/spellcheck/hunspell/tests/IJ.sug
extensions/spellcheck/hunspell/tests/IJ.test
extensions/spellcheck/hunspell/tests/IJ.wrong
extensions/spellcheck/hunspell/tests/Makefile.am
extensions/spellcheck/hunspell/tests/Makefile.in
extensions/spellcheck/hunspell/tests/affixes.aff
extensions/spellcheck/hunspell/tests/affixes.dic
extensions/spellcheck/hunspell/tests/affixes.good
extensions/spellcheck/hunspell/tests/affixes.test
extensions/spellcheck/hunspell/tests/alias.aff
extensions/spellcheck/hunspell/tests/alias.dic
extensions/spellcheck/hunspell/tests/alias.good
extensions/spellcheck/hunspell/tests/alias.test
extensions/spellcheck/hunspell/tests/alias2.aff
extensions/spellcheck/hunspell/tests/alias2.dic
extensions/spellcheck/hunspell/tests/alias2.good
extensions/spellcheck/hunspell/tests/alias2.morph
extensions/spellcheck/hunspell/tests/alias2.test
extensions/spellcheck/hunspell/tests/alias3.aff
extensions/spellcheck/hunspell/tests/alias3.dic
extensions/spellcheck/hunspell/tests/alias3.good
extensions/spellcheck/hunspell/tests/alias3.morph
extensions/spellcheck/hunspell/tests/alias3.test
extensions/spellcheck/hunspell/tests/allcaps.aff
extensions/spellcheck/hunspell/tests/allcaps.dic
extensions/spellcheck/hunspell/tests/allcaps.good
extensions/spellcheck/hunspell/tests/allcaps.sug
extensions/spellcheck/hunspell/tests/allcaps.test
extensions/spellcheck/hunspell/tests/allcaps.wrong
extensions/spellcheck/hunspell/tests/allcaps2.aff
extensions/spellcheck/hunspell/tests/allcaps2.dic
extensions/spellcheck/hunspell/tests/allcaps2.good
extensions/spellcheck/hunspell/tests/allcaps2.sug
extensions/spellcheck/hunspell/tests/allcaps2.test
extensions/spellcheck/hunspell/tests/allcaps2.wrong
extensions/spellcheck/hunspell/tests/allcaps3.aff
extensions/spellcheck/hunspell/tests/allcaps3.dic
extensions/spellcheck/hunspell/tests/allcaps3.good
extensions/spellcheck/hunspell/tests/allcaps3.test
extensions/spellcheck/hunspell/tests/allcaps3.wrong
extensions/spellcheck/hunspell/tests/allcaps_utf.aff
extensions/spellcheck/hunspell/tests/allcaps_utf.dic
extensions/spellcheck/hunspell/tests/allcaps_utf.good
extensions/spellcheck/hunspell/tests/allcaps_utf.sug
extensions/spellcheck/hunspell/tests/allcaps_utf.test
extensions/spellcheck/hunspell/tests/allcaps_utf.wrong
extensions/spellcheck/hunspell/tests/arabic.aff
extensions/spellcheck/hunspell/tests/arabic.dic
extensions/spellcheck/hunspell/tests/arabic.test
extensions/spellcheck/hunspell/tests/arabic.wrong
extensions/spellcheck/hunspell/tests/base.aff
extensions/spellcheck/hunspell/tests/base.dic
extensions/spellcheck/hunspell/tests/base.good
extensions/spellcheck/hunspell/tests/base.sug
extensions/spellcheck/hunspell/tests/base.test
extensions/spellcheck/hunspell/tests/base.wrong
extensions/spellcheck/hunspell/tests/base_utf.aff
extensions/spellcheck/hunspell/tests/base_utf.dic
extensions/spellcheck/hunspell/tests/base_utf.good
extensions/spellcheck/hunspell/tests/base_utf.sug
extensions/spellcheck/hunspell/tests/base_utf.test
extensions/spellcheck/hunspell/tests/base_utf.wrong
extensions/spellcheck/hunspell/tests/break.aff
extensions/spellcheck/hunspell/tests/break.dic
extensions/spellcheck/hunspell/tests/break.good
extensions/spellcheck/hunspell/tests/break.test
extensions/spellcheck/hunspell/tests/break.wrong
extensions/spellcheck/hunspell/tests/breakdefault.aff
extensions/spellcheck/hunspell/tests/breakdefault.dic
extensions/spellcheck/hunspell/tests/breakdefault.good
extensions/spellcheck/hunspell/tests/breakdefault.sug
extensions/spellcheck/hunspell/tests/breakdefault.test
extensions/spellcheck/hunspell/tests/breakdefault.wrong
extensions/spellcheck/hunspell/tests/breakoff.aff
extensions/spellcheck/hunspell/tests/breakoff.dic
extensions/spellcheck/hunspell/tests/breakoff.good
extensions/spellcheck/hunspell/tests/breakoff.test
extensions/spellcheck/hunspell/tests/breakoff.wrong
extensions/spellcheck/hunspell/tests/checkcompoundcase.aff
extensions/spellcheck/hunspell/tests/checkcompoundcase.dic
extensions/spellcheck/hunspell/tests/checkcompoundcase.good
extensions/spellcheck/hunspell/tests/checkcompoundcase.test
extensions/spellcheck/hunspell/tests/checkcompoundcase.wrong
extensions/spellcheck/hunspell/tests/checkcompoundcase2.aff
extensions/spellcheck/hunspell/tests/checkcompoundcase2.dic
extensions/spellcheck/hunspell/tests/checkcompoundcase2.good
extensions/spellcheck/hunspell/tests/checkcompoundcase2.test
extensions/spellcheck/hunspell/tests/checkcompoundcase2.wrong
extensions/spellcheck/hunspell/tests/checkcompoundcaseutf.aff
extensions/spellcheck/hunspell/tests/checkcompoundcaseutf.dic
extensions/spellcheck/hunspell/tests/checkcompoundcaseutf.good
extensions/spellcheck/hunspell/tests/checkcompoundcaseutf.test
extensions/spellcheck/hunspell/tests/checkcompoundcaseutf.wrong
extensions/spellcheck/hunspell/tests/checkcompounddup.aff
extensions/spellcheck/hunspell/tests/checkcompounddup.dic
extensions/spellcheck/hunspell/tests/checkcompounddup.good
extensions/spellcheck/hunspell/tests/checkcompounddup.test
extensions/spellcheck/hunspell/tests/checkcompounddup.wrong
extensions/spellcheck/hunspell/tests/checkcompoundpattern.aff
extensions/spellcheck/hunspell/tests/checkcompoundpattern.dic
extensions/spellcheck/hunspell/tests/checkcompoundpattern.good
extensions/spellcheck/hunspell/tests/checkcompoundpattern.test
extensions/spellcheck/hunspell/tests/checkcompoundpattern.wrong
extensions/spellcheck/hunspell/tests/checkcompoundpattern2.aff
extensions/spellcheck/hunspell/tests/checkcompoundpattern2.dic
extensions/spellcheck/hunspell/tests/checkcompoundpattern2.good
extensions/spellcheck/hunspell/tests/checkcompoundpattern2.test
extensions/spellcheck/hunspell/tests/checkcompoundpattern2.wrong
extensions/spellcheck/hunspell/tests/checkcompoundpattern3.aff
extensions/spellcheck/hunspell/tests/checkcompoundpattern3.dic
extensions/spellcheck/hunspell/tests/checkcompoundpattern3.good
extensions/spellcheck/hunspell/tests/checkcompoundpattern3.test
extensions/spellcheck/hunspell/tests/checkcompoundpattern3.wrong
extensions/spellcheck/hunspell/tests/checkcompoundpattern4.aff
extensions/spellcheck/hunspell/tests/checkcompoundpattern4.dic
extensions/spellcheck/hunspell/tests/checkcompoundpattern4.good
extensions/spellcheck/hunspell/tests/checkcompoundpattern4.test
extensions/spellcheck/hunspell/tests/checkcompoundpattern4.wrong
extensions/spellcheck/hunspell/tests/checkcompoundrep.aff
extensions/spellcheck/hunspell/tests/checkcompoundrep.dic
extensions/spellcheck/hunspell/tests/checkcompoundrep.good
extensions/spellcheck/hunspell/tests/checkcompoundrep.test
extensions/spellcheck/hunspell/tests/checkcompoundrep.wrong
extensions/spellcheck/hunspell/tests/checkcompoundtriple.aff
extensions/spellcheck/hunspell/tests/checkcompoundtriple.dic
extensions/spellcheck/hunspell/tests/checkcompoundtriple.good
extensions/spellcheck/hunspell/tests/checkcompoundtriple.test
extensions/spellcheck/hunspell/tests/checkcompoundtriple.wrong
extensions/spellcheck/hunspell/tests/checksharps.aff
extensions/spellcheck/hunspell/tests/checksharps.dic
extensions/spellcheck/hunspell/tests/checksharps.good
extensions/spellcheck/hunspell/tests/checksharps.sug
extensions/spellcheck/hunspell/tests/checksharps.test
extensions/spellcheck/hunspell/tests/checksharps.wrong
extensions/spellcheck/hunspell/tests/checksharpsutf.aff
extensions/spellcheck/hunspell/tests/checksharpsutf.dic
extensions/spellcheck/hunspell/tests/checksharpsutf.good
extensions/spellcheck/hunspell/tests/checksharpsutf.sug
extensions/spellcheck/hunspell/tests/checksharpsutf.test
extensions/spellcheck/hunspell/tests/checksharpsutf.wrong
extensions/spellcheck/hunspell/tests/circumfix.aff
extensions/spellcheck/hunspell/tests/circumfix.dic
extensions/spellcheck/hunspell/tests/circumfix.good
extensions/spellcheck/hunspell/tests/circumfix.morph
extensions/spellcheck/hunspell/tests/circumfix.test
extensions/spellcheck/hunspell/tests/circumfix.wrong
extensions/spellcheck/hunspell/tests/colons_in_words.aff
extensions/spellcheck/hunspell/tests/colons_in_words.dic
extensions/spellcheck/hunspell/tests/colons_in_words.test
extensions/spellcheck/hunspell/tests/complexprefixes.aff
extensions/spellcheck/hunspell/tests/complexprefixes.dic
extensions/spellcheck/hunspell/tests/complexprefixes.good
extensions/spellcheck/hunspell/tests/complexprefixes.test
extensions/spellcheck/hunspell/tests/complexprefixes.wrong
extensions/spellcheck/hunspell/tests/complexprefixes2.aff
extensions/spellcheck/hunspell/tests/complexprefixes2.dic
extensions/spellcheck/hunspell/tests/complexprefixes2.good
extensions/spellcheck/hunspell/tests/complexprefixes2.test
extensions/spellcheck/hunspell/tests/complexprefixesutf.aff
extensions/spellcheck/hunspell/tests/complexprefixesutf.dic
extensions/spellcheck/hunspell/tests/complexprefixesutf.good
extensions/spellcheck/hunspell/tests/complexprefixesutf.test
extensions/spellcheck/hunspell/tests/complexprefixesutf.wrong
extensions/spellcheck/hunspell/tests/compoundaffix.aff
extensions/spellcheck/hunspell/tests/compoundaffix.dic
extensions/spellcheck/hunspell/tests/compoundaffix.good
extensions/spellcheck/hunspell/tests/compoundaffix.test
extensions/spellcheck/hunspell/tests/compoundaffix.wrong
extensions/spellcheck/hunspell/tests/compoundaffix2.aff
extensions/spellcheck/hunspell/tests/compoundaffix2.dic
extensions/spellcheck/hunspell/tests/compoundaffix2.good
extensions/spellcheck/hunspell/tests/compoundaffix2.test
extensions/spellcheck/hunspell/tests/compoundaffix3.aff
extensions/spellcheck/hunspell/tests/compoundaffix3.dic
extensions/spellcheck/hunspell/tests/compoundaffix3.good
extensions/spellcheck/hunspell/tests/compoundaffix3.test
extensions/spellcheck/hunspell/tests/compoundaffix3.wrong
extensions/spellcheck/hunspell/tests/compoundflag.aff
extensions/spellcheck/hunspell/tests/compoundflag.dic
extensions/spellcheck/hunspell/tests/compoundflag.good
extensions/spellcheck/hunspell/tests/compoundflag.test
extensions/spellcheck/hunspell/tests/compoundflag.wrong
extensions/spellcheck/hunspell/tests/compoundrule.aff
extensions/spellcheck/hunspell/tests/compoundrule.dic
extensions/spellcheck/hunspell/tests/compoundrule.good
extensions/spellcheck/hunspell/tests/compoundrule.test
extensions/spellcheck/hunspell/tests/compoundrule.wrong
extensions/spellcheck/hunspell/tests/compoundrule2.aff
extensions/spellcheck/hunspell/tests/compoundrule2.dic
extensions/spellcheck/hunspell/tests/compoundrule2.good
extensions/spellcheck/hunspell/tests/compoundrule2.test
extensions/spellcheck/hunspell/tests/compoundrule2.wrong
extensions/spellcheck/hunspell/tests/compoundrule3.aff
extensions/spellcheck/hunspell/tests/compoundrule3.dic
extensions/spellcheck/hunspell/tests/compoundrule3.good
extensions/spellcheck/hunspell/tests/compoundrule3.test
extensions/spellcheck/hunspell/tests/compoundrule3.wrong
extensions/spellcheck/hunspell/tests/compoundrule4.aff
extensions/spellcheck/hunspell/tests/compoundrule4.dic
extensions/spellcheck/hunspell/tests/compoundrule4.good
extensions/spellcheck/hunspell/tests/compoundrule4.test
extensions/spellcheck/hunspell/tests/compoundrule4.wrong
extensions/spellcheck/hunspell/tests/compoundrule5.aff
extensions/spellcheck/hunspell/tests/compoundrule5.dic
extensions/spellcheck/hunspell/tests/compoundrule5.good
extensions/spellcheck/hunspell/tests/compoundrule5.morph
extensions/spellcheck/hunspell/tests/compoundrule5.test
extensions/spellcheck/hunspell/tests/compoundrule5.wrong
extensions/spellcheck/hunspell/tests/compoundrule6.aff
extensions/spellcheck/hunspell/tests/compoundrule6.dic
extensions/spellcheck/hunspell/tests/compoundrule6.good
extensions/spellcheck/hunspell/tests/compoundrule6.test
extensions/spellcheck/hunspell/tests/compoundrule6.wrong
extensions/spellcheck/hunspell/tests/compoundrule7.aff
extensions/spellcheck/hunspell/tests/compoundrule7.dic
extensions/spellcheck/hunspell/tests/compoundrule7.good
extensions/spellcheck/hunspell/tests/compoundrule7.test
extensions/spellcheck/hunspell/tests/compoundrule7.wrong
extensions/spellcheck/hunspell/tests/compoundrule8.aff
extensions/spellcheck/hunspell/tests/compoundrule8.dic
extensions/spellcheck/hunspell/tests/compoundrule8.good
extensions/spellcheck/hunspell/tests/compoundrule8.test
extensions/spellcheck/hunspell/tests/compoundrule8.wrong
extensions/spellcheck/hunspell/tests/condition.aff
extensions/spellcheck/hunspell/tests/condition.dic
extensions/spellcheck/hunspell/tests/condition.good
extensions/spellcheck/hunspell/tests/condition.test
extensions/spellcheck/hunspell/tests/condition.wrong
extensions/spellcheck/hunspell/tests/condition_utf.aff
extensions/spellcheck/hunspell/tests/condition_utf.dic
extensions/spellcheck/hunspell/tests/condition_utf.good
extensions/spellcheck/hunspell/tests/condition_utf.test
extensions/spellcheck/hunspell/tests/condition_utf.wrong
extensions/spellcheck/hunspell/tests/conditionalprefix.aff
extensions/spellcheck/hunspell/tests/conditionalprefix.dic
extensions/spellcheck/hunspell/tests/conditionalprefix.good
extensions/spellcheck/hunspell/tests/conditionalprefix.morph
extensions/spellcheck/hunspell/tests/conditionalprefix.test
extensions/spellcheck/hunspell/tests/conditionalprefix.wrong
extensions/spellcheck/hunspell/tests/digits_in_words.aff
extensions/spellcheck/hunspell/tests/digits_in_words.dic
extensions/spellcheck/hunspell/tests/digits_in_words.test
extensions/spellcheck/hunspell/tests/digits_in_words.wrong
extensions/spellcheck/hunspell/tests/encoding.aff
extensions/spellcheck/hunspell/tests/encoding.dic
extensions/spellcheck/hunspell/tests/encoding.good
extensions/spellcheck/hunspell/tests/encoding.test
extensions/spellcheck/hunspell/tests/flag.aff
extensions/spellcheck/hunspell/tests/flag.dic
extensions/spellcheck/hunspell/tests/flag.good
extensions/spellcheck/hunspell/tests/flag.test
extensions/spellcheck/hunspell/tests/flaglong.aff
extensions/spellcheck/hunspell/tests/flaglong.dic
extensions/spellcheck/hunspell/tests/flaglong.good
extensions/spellcheck/hunspell/tests/flaglong.test
extensions/spellcheck/hunspell/tests/flagnum.aff
extensions/spellcheck/hunspell/tests/flagnum.dic
extensions/spellcheck/hunspell/tests/flagnum.good
extensions/spellcheck/hunspell/tests/flagnum.test
extensions/spellcheck/hunspell/tests/flagutf8.aff
extensions/spellcheck/hunspell/tests/flagutf8.dic
extensions/spellcheck/hunspell/tests/flagutf8.good
extensions/spellcheck/hunspell/tests/flagutf8.test
extensions/spellcheck/hunspell/tests/fogemorpheme.aff
extensions/spellcheck/hunspell/tests/fogemorpheme.dic
extensions/spellcheck/hunspell/tests/fogemorpheme.good
extensions/spellcheck/hunspell/tests/fogemorpheme.test
extensions/spellcheck/hunspell/tests/fogemorpheme.wrong
extensions/spellcheck/hunspell/tests/forbiddenword.aff
extensions/spellcheck/hunspell/tests/forbiddenword.dic
extensions/spellcheck/hunspell/tests/forbiddenword.good
extensions/spellcheck/hunspell/tests/forbiddenword.test
extensions/spellcheck/hunspell/tests/forbiddenword.wrong
extensions/spellcheck/hunspell/tests/forceucase.aff
extensions/spellcheck/hunspell/tests/forceucase.dic
extensions/spellcheck/hunspell/tests/forceucase.good
extensions/spellcheck/hunspell/tests/forceucase.sug
extensions/spellcheck/hunspell/tests/forceucase.test
extensions/spellcheck/hunspell/tests/forceucase.wrong
extensions/spellcheck/hunspell/tests/fullstrip.aff
extensions/spellcheck/hunspell/tests/fullstrip.dic
extensions/spellcheck/hunspell/tests/fullstrip.good
extensions/spellcheck/hunspell/tests/fullstrip.test
extensions/spellcheck/hunspell/tests/germancompounding.aff
extensions/spellcheck/hunspell/tests/germancompounding.dic
extensions/spellcheck/hunspell/tests/germancompounding.good
extensions/spellcheck/hunspell/tests/germancompounding.test
extensions/spellcheck/hunspell/tests/germancompounding.wrong
extensions/spellcheck/hunspell/tests/germancompoundingold.aff
extensions/spellcheck/hunspell/tests/germancompoundingold.dic
extensions/spellcheck/hunspell/tests/germancompoundingold.good
extensions/spellcheck/hunspell/tests/germancompoundingold.test
extensions/spellcheck/hunspell/tests/germancompoundingold.wrong
extensions/spellcheck/hunspell/tests/i35725.aff
extensions/spellcheck/hunspell/tests/i35725.dic
extensions/spellcheck/hunspell/tests/i35725.good
extensions/spellcheck/hunspell/tests/i35725.sug
extensions/spellcheck/hunspell/tests/i35725.test
extensions/spellcheck/hunspell/tests/i35725.wrong
extensions/spellcheck/hunspell/tests/i53643.aff
extensions/spellcheck/hunspell/tests/i53643.dic
extensions/spellcheck/hunspell/tests/i53643.good
extensions/spellcheck/hunspell/tests/i53643.test
extensions/spellcheck/hunspell/tests/i53643.wrong
extensions/spellcheck/hunspell/tests/i54633.aff
extensions/spellcheck/hunspell/tests/i54633.dic
extensions/spellcheck/hunspell/tests/i54633.good
extensions/spellcheck/hunspell/tests/i54633.sug
extensions/spellcheck/hunspell/tests/i54633.test
extensions/spellcheck/hunspell/tests/i54633.wrong
extensions/spellcheck/hunspell/tests/i54980.aff
extensions/spellcheck/hunspell/tests/i54980.dic
extensions/spellcheck/hunspell/tests/i54980.good
extensions/spellcheck/hunspell/tests/i54980.test
extensions/spellcheck/hunspell/tests/i58202.aff
extensions/spellcheck/hunspell/tests/i58202.dic
extensions/spellcheck/hunspell/tests/i58202.good
extensions/spellcheck/hunspell/tests/i58202.sug
extensions/spellcheck/hunspell/tests/i58202.test
extensions/spellcheck/hunspell/tests/i58202.wrong
extensions/spellcheck/hunspell/tests/i68568.aff
extensions/spellcheck/hunspell/tests/i68568.dic
extensions/spellcheck/hunspell/tests/i68568.test
extensions/spellcheck/hunspell/tests/i68568.wrong
extensions/spellcheck/hunspell/tests/i68568utf.aff
extensions/spellcheck/hunspell/tests/i68568utf.dic
extensions/spellcheck/hunspell/tests/i68568utf.test
extensions/spellcheck/hunspell/tests/i68568utf.wrong
extensions/spellcheck/hunspell/tests/iconv.aff
extensions/spellcheck/hunspell/tests/iconv.dic
extensions/spellcheck/hunspell/tests/iconv.good
extensions/spellcheck/hunspell/tests/iconv.test
extensions/spellcheck/hunspell/tests/ignore.aff
extensions/spellcheck/hunspell/tests/ignore.dic
extensions/spellcheck/hunspell/tests/ignore.good
extensions/spellcheck/hunspell/tests/ignore.test
extensions/spellcheck/hunspell/tests/ignoreutf.aff
extensions/spellcheck/hunspell/tests/ignoreutf.dic
extensions/spellcheck/hunspell/tests/ignoreutf.good
extensions/spellcheck/hunspell/tests/ignoreutf.test
extensions/spellcheck/hunspell/tests/keepcase.aff
extensions/spellcheck/hunspell/tests/keepcase.dic
extensions/spellcheck/hunspell/tests/keepcase.good
extensions/spellcheck/hunspell/tests/keepcase.sug
extensions/spellcheck/hunspell/tests/keepcase.test
extensions/spellcheck/hunspell/tests/keepcase.wrong
extensions/spellcheck/hunspell/tests/korean.aff
extensions/spellcheck/hunspell/tests/korean.dic
extensions/spellcheck/hunspell/tests/korean.good
extensions/spellcheck/hunspell/tests/korean.test
extensions/spellcheck/hunspell/tests/korean.wrong
extensions/spellcheck/hunspell/tests/map.aff
extensions/spellcheck/hunspell/tests/map.dic
extensions/spellcheck/hunspell/tests/map.sug
extensions/spellcheck/hunspell/tests/map.test
extensions/spellcheck/hunspell/tests/map.wrong
extensions/spellcheck/hunspell/tests/maputf.aff
extensions/spellcheck/hunspell/tests/maputf.dic
extensions/spellcheck/hunspell/tests/maputf.sug
extensions/spellcheck/hunspell/tests/maputf.test
extensions/spellcheck/hunspell/tests/maputf.wrong
extensions/spellcheck/hunspell/tests/morph.aff
extensions/spellcheck/hunspell/tests/morph.dic
extensions/spellcheck/hunspell/tests/morph.good
extensions/spellcheck/hunspell/tests/morph.morph
extensions/spellcheck/hunspell/tests/morph.test
extensions/spellcheck/hunspell/tests/needaffix.aff
extensions/spellcheck/hunspell/tests/needaffix.dic
extensions/spellcheck/hunspell/tests/needaffix.good
extensions/spellcheck/hunspell/tests/needaffix.test
extensions/spellcheck/hunspell/tests/needaffix.wrong
extensions/spellcheck/hunspell/tests/needaffix2.aff
extensions/spellcheck/hunspell/tests/needaffix2.dic
extensions/spellcheck/hunspell/tests/needaffix2.good
extensions/spellcheck/hunspell/tests/needaffix2.morph
extensions/spellcheck/hunspell/tests/needaffix2.test
extensions/spellcheck/hunspell/tests/needaffix3.aff
extensions/spellcheck/hunspell/tests/needaffix3.dic
extensions/spellcheck/hunspell/tests/needaffix3.good
extensions/spellcheck/hunspell/tests/needaffix3.test
extensions/spellcheck/hunspell/tests/needaffix3.wrong
extensions/spellcheck/hunspell/tests/needaffix4.aff
extensions/spellcheck/hunspell/tests/needaffix4.dic
extensions/spellcheck/hunspell/tests/needaffix4.good
extensions/spellcheck/hunspell/tests/needaffix4.test
extensions/spellcheck/hunspell/tests/needaffix5.aff
extensions/spellcheck/hunspell/tests/needaffix5.dic
extensions/spellcheck/hunspell/tests/needaffix5.good
extensions/spellcheck/hunspell/tests/needaffix5.test
extensions/spellcheck/hunspell/tests/needaffix5.wrong
extensions/spellcheck/hunspell/tests/ngram_utf_fix.aff
extensions/spellcheck/hunspell/tests/ngram_utf_fix.dic
extensions/spellcheck/hunspell/tests/ngram_utf_fix.good
extensions/spellcheck/hunspell/tests/ngram_utf_fix.sug
extensions/spellcheck/hunspell/tests/ngram_utf_fix.test
extensions/spellcheck/hunspell/tests/ngram_utf_fix.wrong
extensions/spellcheck/hunspell/tests/nosuggest.aff
extensions/spellcheck/hunspell/tests/nosuggest.dic
extensions/spellcheck/hunspell/tests/nosuggest.good
extensions/spellcheck/hunspell/tests/nosuggest.sug
extensions/spellcheck/hunspell/tests/nosuggest.test
extensions/spellcheck/hunspell/tests/nosuggest.wrong
extensions/spellcheck/hunspell/tests/oconv.aff
extensions/spellcheck/hunspell/tests/oconv.dic
extensions/spellcheck/hunspell/tests/oconv.good
extensions/spellcheck/hunspell/tests/oconv.sug
extensions/spellcheck/hunspell/tests/oconv.test
extensions/spellcheck/hunspell/tests/oconv.wrong
extensions/spellcheck/hunspell/tests/onlyincompound.aff
extensions/spellcheck/hunspell/tests/onlyincompound.dic
extensions/spellcheck/hunspell/tests/onlyincompound.good
extensions/spellcheck/hunspell/tests/onlyincompound.sug
extensions/spellcheck/hunspell/tests/onlyincompound.test
extensions/spellcheck/hunspell/tests/onlyincompound.wrong
extensions/spellcheck/hunspell/tests/onlyincompound2.aff
extensions/spellcheck/hunspell/tests/onlyincompound2.dic
extensions/spellcheck/hunspell/tests/onlyincompound2.good
extensions/spellcheck/hunspell/tests/onlyincompound2.test
extensions/spellcheck/hunspell/tests/onlyincompound2.wrong
extensions/spellcheck/hunspell/tests/opentaal_cpdpat.aff
extensions/spellcheck/hunspell/tests/opentaal_cpdpat.dic
extensions/spellcheck/hunspell/tests/opentaal_cpdpat.good
extensions/spellcheck/hunspell/tests/opentaal_cpdpat.test
extensions/spellcheck/hunspell/tests/opentaal_cpdpat.wrong
extensions/spellcheck/hunspell/tests/opentaal_cpdpat2.aff
extensions/spellcheck/hunspell/tests/opentaal_cpdpat2.dic
extensions/spellcheck/hunspell/tests/opentaal_cpdpat2.good
extensions/spellcheck/hunspell/tests/opentaal_cpdpat2.test
extensions/spellcheck/hunspell/tests/opentaal_cpdpat2.wrong
extensions/spellcheck/hunspell/tests/opentaal_forbiddenword1.aff
extensions/spellcheck/hunspell/tests/opentaal_forbiddenword1.dic
extensions/spellcheck/hunspell/tests/opentaal_forbiddenword1.good
extensions/spellcheck/hunspell/tests/opentaal_forbiddenword1.sug
extensions/spellcheck/hunspell/tests/opentaal_forbiddenword1.test
extensions/spellcheck/hunspell/tests/opentaal_forbiddenword1.wrong
extensions/spellcheck/hunspell/tests/opentaal_forbiddenword2.aff
extensions/spellcheck/hunspell/tests/opentaal_forbiddenword2.dic
extensions/spellcheck/hunspell/tests/opentaal_forbiddenword2.good
extensions/spellcheck/hunspell/tests/opentaal_forbiddenword2.sug
extensions/spellcheck/hunspell/tests/opentaal_forbiddenword2.test
extensions/spellcheck/hunspell/tests/opentaal_forbiddenword2.wrong
extensions/spellcheck/hunspell/tests/opentaal_keepcase.aff
extensions/spellcheck/hunspell/tests/opentaal_keepcase.dic
extensions/spellcheck/hunspell/tests/opentaal_keepcase.good
extensions/spellcheck/hunspell/tests/opentaal_keepcase.sug
extensions/spellcheck/hunspell/tests/opentaal_keepcase.test
extensions/spellcheck/hunspell/tests/opentaal_keepcase.wrong
extensions/spellcheck/hunspell/tests/phone.aff
extensions/spellcheck/hunspell/tests/phone.dic
extensions/spellcheck/hunspell/tests/phone.sug
extensions/spellcheck/hunspell/tests/phone.test
extensions/spellcheck/hunspell/tests/phone.wrong
extensions/spellcheck/hunspell/tests/rep.aff
extensions/spellcheck/hunspell/tests/rep.dic
extensions/spellcheck/hunspell/tests/rep.sug
extensions/spellcheck/hunspell/tests/rep.test
extensions/spellcheck/hunspell/tests/rep.wrong
extensions/spellcheck/hunspell/tests/reputf.aff
extensions/spellcheck/hunspell/tests/reputf.dic
extensions/spellcheck/hunspell/tests/reputf.sug
extensions/spellcheck/hunspell/tests/reputf.test
extensions/spellcheck/hunspell/tests/reputf.wrong
extensions/spellcheck/hunspell/tests/simplifiedtriple.aff
extensions/spellcheck/hunspell/tests/simplifiedtriple.dic
extensions/spellcheck/hunspell/tests/simplifiedtriple.good
extensions/spellcheck/hunspell/tests/simplifiedtriple.test
extensions/spellcheck/hunspell/tests/simplifiedtriple.wrong
extensions/spellcheck/hunspell/tests/slash.aff
extensions/spellcheck/hunspell/tests/slash.dic
extensions/spellcheck/hunspell/tests/slash.good
extensions/spellcheck/hunspell/tests/slash.test
extensions/spellcheck/hunspell/tests/sug.aff
extensions/spellcheck/hunspell/tests/sug.dic
extensions/spellcheck/hunspell/tests/sug.sug
extensions/spellcheck/hunspell/tests/sug.test
extensions/spellcheck/hunspell/tests/sug.wrong
extensions/spellcheck/hunspell/tests/suggestiontest/List_of_common_misspellings.txt
extensions/spellcheck/hunspell/tests/suggestiontest/Makefile.am
extensions/spellcheck/hunspell/tests/suggestiontest/Makefile.in
extensions/spellcheck/hunspell/tests/suggestiontest/README
extensions/spellcheck/hunspell/tests/suggestiontest/prepare
extensions/spellcheck/hunspell/tests/suggestiontest/test
extensions/spellcheck/hunspell/tests/sugutf.aff
extensions/spellcheck/hunspell/tests/sugutf.dic
extensions/spellcheck/hunspell/tests/sugutf.sug
extensions/spellcheck/hunspell/tests/sugutf.test
extensions/spellcheck/hunspell/tests/sugutf.wrong
extensions/spellcheck/hunspell/tests/test.sh
extensions/spellcheck/hunspell/tests/utf8.aff
extensions/spellcheck/hunspell/tests/utf8.dic
extensions/spellcheck/hunspell/tests/utf8.good
extensions/spellcheck/hunspell/tests/utf8.test
extensions/spellcheck/hunspell/tests/utf8_bom.aff
extensions/spellcheck/hunspell/tests/utf8_bom.dic
extensions/spellcheck/hunspell/tests/utf8_bom.good
extensions/spellcheck/hunspell/tests/utf8_bom.test
extensions/spellcheck/hunspell/tests/utf8_bom2.aff
extensions/spellcheck/hunspell/tests/utf8_bom2.dic
extensions/spellcheck/hunspell/tests/utf8_bom2.good
extensions/spellcheck/hunspell/tests/utf8_bom2.test
extensions/spellcheck/hunspell/tests/utf8_nonbmp.aff
extensions/spellcheck/hunspell/tests/utf8_nonbmp.dic
extensions/spellcheck/hunspell/tests/utf8_nonbmp.good
extensions/spellcheck/hunspell/tests/utf8_nonbmp.sug
extensions/spellcheck/hunspell/tests/utf8_nonbmp.test
extensions/spellcheck/hunspell/tests/utf8_nonbmp.wrong
extensions/spellcheck/hunspell/tests/utfcompound.aff
extensions/spellcheck/hunspell/tests/utfcompound.dic
extensions/spellcheck/hunspell/tests/utfcompound.good
extensions/spellcheck/hunspell/tests/utfcompound.test
extensions/spellcheck/hunspell/tests/utfcompound.wrong
extensions/spellcheck/hunspell/tests/warn.aff
extensions/spellcheck/hunspell/tests/warn.dic
extensions/spellcheck/hunspell/tests/warn.good
extensions/spellcheck/hunspell/tests/warn.test
extensions/spellcheck/hunspell/tests/zeroaffix.aff
extensions/spellcheck/hunspell/tests/zeroaffix.dic
extensions/spellcheck/hunspell/tests/zeroaffix.good
extensions/spellcheck/hunspell/tests/zeroaffix.morph
extensions/spellcheck/hunspell/tests/zeroaffix.test
js/src/config/nsinstall_win.c
mobile/android/base/resources/color/awesomebar_tab_text.xml
mobile/android/base/resources/drawable-hdpi/awesomebar_tab.9.png
mobile/android/base/resources/drawable-hdpi/awesomebar_tab_pressed.9.png
mobile/android/base/resources/drawable-xhdpi-v11/awesomebar_tab.9.png
mobile/android/base/resources/drawable-xhdpi-v11/awesomebar_tab_pressed.9.png
mobile/android/base/resources/drawable/awesomebar_tab.9.png
mobile/android/base/resources/drawable/awesomebar_tab_press.xml
mobile/android/base/resources/drawable/awesomebar_tab_press_selected.xml
mobile/android/base/resources/drawable/awesomebar_tab_pressed.9.png
toolkit/crashreporter/google-breakpad/src/client/windows/crash_generation/Makefile.in
toolkit/crashreporter/google-breakpad/src/client/windows/handler/Makefile.in
toolkit/crashreporter/google-breakpad/src/client/windows/sender/Makefile.in
toolkit/crashreporter/google-breakpad/src/common/windows/Makefile.in
--- a/accessible/public/nsIAccessibilityService.h
+++ b/accessible/public/nsIAccessibilityService.h
@@ -10,17 +10,16 @@
 #include "nsIAccessibleRetrieval.h"
 #include "nsIAccessibleEvent.h"
 
 #include "nsAutoPtr.h"
 
 class Accessible;
 class nsINode;
 class nsIContent;
-class nsIDocument;
 class nsIFrame;
 class nsIPresShell;
 class nsObjectFrame;
 
 // 10ff6dca-b219-4b64-9a4c-67a62b86edce
 #define NS_IACCESSIBILITYSERVICE_IID \
 { 0x84dd9182, 0x6639, 0x4377, \
  { 0xa4, 0x13, 0xad, 0xe1, 0xae, 0x4e, 0x52, 0xdd } }
--- a/accessible/src/atk/ApplicationAccessibleWrap.cpp
+++ b/accessible/src/atk/ApplicationAccessibleWrap.cpp
@@ -890,16 +890,20 @@ bool
 ShouldA11yBeEnabled()
 {
   static bool sChecked = false, sShouldEnable = false;
   if (sChecked)
     return sShouldEnable;
 
   sChecked = true;
 
+  EPlatformDisabledState disabledState = PlatformDisabledState();
+  if (disabledState == ePlatformIsDisabled)
+    return sShouldEnable = false;
+
   // check if accessibility enabled/disabled by environment variable
   const char* envValue = PR_GetEnv(sAccEnv);
   if (envValue)
     return sShouldEnable = !!atoi(envValue);
 
 #ifdef MOZ_ENABLE_DBUS
   PreInit();
   bool dbusSuccess = false;
--- a/accessible/src/base/AccEvent.cpp
+++ b/accessible/src/base/AccEvent.cpp
@@ -8,17 +8,16 @@
 #include "ApplicationAccessibleWrap.h"
 #include "nsAccessibilityService.h"
 #include "nsAccUtils.h"
 #include "DocAccessible.h"
 #include "nsIAccessibleText.h"
 #include "nsAccEvent.h"
 #include "States.h"
 
-#include "nsIDOMDocument.h"
 #include "nsEventStateManager.h"
 #include "nsIServiceManager.h"
 #ifdef MOZ_XUL
 #include "nsIDOMXULMultSelectCntrlEl.h"
 #endif
 
 using namespace mozilla::a11y;
 
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -37,35 +37,24 @@
 #include "nsHTMLWin32ObjectAccessible.h"
 #endif
 #include "TextLeafAccessibleWrap.h"
 
 #ifdef DEBUG
 #include "Logging.h"
 #endif
 
-#include "nsCURILoader.h"
-#include "nsEventStates.h"
-#include "nsIContentViewer.h"
 #include "nsIDOMDocument.h"
-#include "nsIDOMHTMLAreaElement.h"
-#include "nsIDOMHTMLLegendElement.h"
 #include "nsIDOMHTMLObjectElement.h"
-#include "nsIDOMHTMLOptGroupElement.h"
-#include "nsIDOMHTMLOptionElement.h"
 #include "nsIDOMXULElement.h"
-#include "nsIHTMLDocument.h"
 #include "nsImageFrame.h"
-#include "nsILink.h"
 #include "nsIObserverService.h"
 #include "nsLayoutUtils.h"
 #include "nsNPAPIPluginInstance.h"
-#include "nsISupportsUtils.h"
 #include "nsObjectFrame.h"
-#include "nsTextFragment.h"
 #include "mozilla/FunctionTimer.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/Util.h"
 
 #ifdef MOZ_XUL
 #include "XULAlertAccessible.h"
--- a/accessible/src/base/nsCoreUtils.cpp
+++ b/accessible/src/base/nsCoreUtils.cpp
@@ -253,55 +253,46 @@ nsCoreUtils::IsAncestorOf(nsINode *aPoss
     if (parentNode == aPossibleAncestorNode)
       return true;
   }
 
   return false;
 }
 
 nsresult
-nsCoreUtils::ScrollSubstringTo(nsIFrame *aFrame,
-                               nsIDOMNode *aStartNode, PRInt32 aStartIndex,
-                               nsIDOMNode *aEndNode, PRInt32 aEndIndex,
+nsCoreUtils::ScrollSubstringTo(nsIFrame* aFrame, nsRange* aRange,
                                PRUint32 aScrollType)
 {
   nsIPresShell::ScrollAxis vertical, horizontal;
   ConvertScrollTypeToPercents(aScrollType, &vertical, &horizontal);
 
-  return ScrollSubstringTo(aFrame, aStartNode, aStartIndex, aEndNode, aEndIndex,
-                           vertical, horizontal);
+  return ScrollSubstringTo(aFrame, aRange, vertical, horizontal);
 }
 
 nsresult
-nsCoreUtils::ScrollSubstringTo(nsIFrame *aFrame,
-                               nsIDOMNode *aStartNode, PRInt32 aStartIndex,
-                               nsIDOMNode *aEndNode, PRInt32 aEndIndex,
+nsCoreUtils::ScrollSubstringTo(nsIFrame* aFrame, nsRange* aRange,
                                nsIPresShell::ScrollAxis aVertical,
                                nsIPresShell::ScrollAxis aHorizontal)
 {
-  if (!aFrame || !aStartNode || !aEndNode)
+  if (!aFrame)
     return NS_ERROR_FAILURE;
 
   nsPresContext *presContext = aFrame->PresContext();
 
-  nsRefPtr<nsIDOMRange> scrollToRange = new nsRange();
   nsCOMPtr<nsISelectionController> selCon;
   aFrame->GetSelectionController(presContext, getter_AddRefs(selCon));
   NS_ENSURE_TRUE(selCon, NS_ERROR_FAILURE);
 
-  scrollToRange->SetStart(aStartNode, aStartIndex);
-  scrollToRange->SetEnd(aEndNode, aEndIndex);
-
   nsCOMPtr<nsISelection> selection;
   selCon->GetSelection(nsISelectionController::SELECTION_ACCESSIBILITY,
                        getter_AddRefs(selection));
 
   nsCOMPtr<nsISelectionPrivate> privSel(do_QueryInterface(selection));
   selection->RemoveAllRanges();
-  selection->AddRange(scrollToRange);
+  selection->AddRange(aRange);
 
   privSel->ScrollIntoViewInternal(
     nsISelectionController::SELECTION_ANCHOR_REGION,
     true, aVertical, aHorizontal);
 
   selection->CollapseToStart();
 
   return NS_OK;
--- a/accessible/src/base/nsCoreUtils.h
+++ b/accessible/src/base/nsCoreUtils.h
@@ -16,16 +16,18 @@
 #include "nsIFrame.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsIDOMDOMStringList.h"
 #include "nsIMutableArray.h"
 #include "nsPoint.h"
 #include "nsTArray.h"
 
+class nsRange;
+
 /**
  * Core utils.
  */
 class nsCoreUtils
 {
 public:
   /**
    * Return true if the given node has registered click, mousedown or mouseup
@@ -124,41 +126,31 @@ public:
                               nsINode *aPossibleDescendantNode,
                               nsINode *aRootNode = nsnull);
 
   /**
    * Helper method to scroll range into view, used for implementation of
    * nsIAccessibleText::scrollSubstringTo().
    *
    * @param aFrame        the frame for accessible the range belongs to.
-   * @param aStartNode    start node of a range
-   * @param aStartOffset  an offset inside the start node
-   * @param aEndNode      end node of a range
-   * @param aEndOffset    an offset inside the end node
+   * @param aRange    the range to scroll to
    * @param aScrollType   the place a range should be scrolled to
    */
-  static nsresult ScrollSubstringTo(nsIFrame *aFrame,
-                                    nsIDOMNode *aStartNode, PRInt32 aStartIndex,
-                                    nsIDOMNode *aEndNode, PRInt32 aEndIndex,
+  static nsresult ScrollSubstringTo(nsIFrame* aFrame, nsRange* aRange,
                                     PRUint32 aScrollType);
 
   /** Helper method to scroll range into view, used for implementation of
    * nsIAccessibleText::scrollSubstringTo[Point]().
    *
    * @param aFrame        the frame for accessible the range belongs to.
-   * @param aStartNode    start node of a range
-   * @param aStartOffset  an offset inside the start node
-   * @param aEndNode      end node of a range
-   * @param aEndOffset    an offset inside the end node
+   * @param aRange    the range to scroll to
    * @param aVertical     how to align vertically, specified in percents, and when.
    * @param aHorizontal     how to align horizontally, specified in percents, and when.
    */
-  static nsresult ScrollSubstringTo(nsIFrame *aFrame,
-                                    nsIDOMNode *aStartNode, PRInt32 aStartIndex,
-                                    nsIDOMNode *aEndNode, PRInt32 aEndIndex,
+  static nsresult ScrollSubstringTo(nsIFrame* aFrame, nsRange* aRange,
                                     nsIPresShell::ScrollAxis aVertical,
                                     nsIPresShell::ScrollAxis aHorizontal);
 
   /**
    * Scrolls the given frame to the point, used for implememntation of
    * nsIAccessible::scrollToPoint and nsIAccessibleText::scrollSubstringToPoint.
    *
    * @param aScrollableFrame  the scrollable frame
--- a/accessible/src/generic/HyperTextAccessible.cpp
+++ b/accessible/src/generic/HyperTextAccessible.cpp
@@ -11,34 +11,31 @@
 #include "DocAccessible.h"
 #include "Role.h"
 #include "States.h"
 #include "TextAttrs.h"
 
 #include "nsIClipboard.h"
 #include "nsContentUtils.h"
 #include "nsFocusManager.h"
-#include "nsIDOMCharacterData.h"
-#include "nsIDOMDocument.h"
 #include "nsIDOMRange.h"
-#include "nsIDOMXULDocument.h"
 #include "nsIEditingSession.h"
 #include "nsIEditor.h"
 #include "nsIFrame.h"
 #include "nsFrameSelection.h"
 #include "nsILineIterator.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIPlaintextEditor.h"
 #include "nsIScrollableFrame.h"
-#include "nsISelectionPrivate.h"
 #include "nsIServiceManager.h"
 #include "nsTextFragment.h"
 #include "mozilla/Selection.h"
 #include "gfxSkipChars.h"
 
+using namespace mozilla;
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // HyperTextAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 HyperTextAccessible::
   HyperTextAccessible(nsIContent* aNode, DocAccessible* aDoc) :
@@ -517,19 +514,17 @@ HyperTextAccessible::DOMPointToHypertext
 
   if (aNodeOffset == -1) {
     findNode = aNode;
 
   } else if (aNode->IsNodeOfType(nsINode::eTEXT)) {
     // For text nodes, aNodeOffset comes in as a character offset
     // Text offset will be added at the end, if we find the offset in this hypertext
     // We want the "skipped" offset into the text (rendered text without the extra whitespace)
-    nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
-    NS_ASSERTION(content, "No nsIContent for dom node");
-    nsIFrame *frame = content->GetPrimaryFrame();
+    nsIFrame *frame = aNode->AsContent()->GetPrimaryFrame();
     NS_ENSURE_TRUE(frame, nsnull);
     nsresult rv = ContentToRenderedOffset(frame, aNodeOffset, &addTextOffset);
     NS_ENSURE_SUCCESS(rv, nsnull);
     // Get the child node and 
     findNode = aNode;
 
   } else {
     // findNode could be null if aNodeOffset == # of child nodes, which means
@@ -630,101 +625,66 @@ HyperTextAccessible::DOMPointToHypertext
       return childAccAtOffset;
     }
   }
 
   return nsnull;
 }
 
 nsresult
-HyperTextAccessible::HypertextOffsetToDOMPoint(PRInt32 aHTOffset,
-                                               nsIDOMNode** aNode,
-                                               PRInt32* aOffset)
-{
-  nsCOMPtr<nsIDOMNode> endNode;
-  PRInt32 endOffset;
-
-  return HypertextOffsetsToDOMRange(aHTOffset, aHTOffset, aNode, aOffset,
-                                    getter_AddRefs(endNode), &endOffset);
-}
-
-nsresult
 HyperTextAccessible::HypertextOffsetsToDOMRange(PRInt32 aStartHTOffset,
                                                 PRInt32 aEndHTOffset,
-                                                nsIDOMNode** aStartNode,
-                                                PRInt32* aStartOffset,
-                                                nsIDOMNode** aEndNode,
-                                                PRInt32* aEndOffset)
+                                                nsRange* aRange)
 {
-  NS_ENSURE_ARG_POINTER(aStartNode);
-  *aStartNode = nsnull;
-
-  NS_ENSURE_ARG_POINTER(aStartOffset);
-  *aStartOffset = -1;
-
-  NS_ENSURE_ARG_POINTER(aEndNode);
-  *aEndNode = nsnull;
-
-  NS_ENSURE_ARG_POINTER(aEndOffset);
-  *aEndOffset = -1;
-
   // If the given offsets are 0 and associated editor is empty then return
   // collapsed range with editor root element as range container.
   if (aStartHTOffset == 0 && aEndHTOffset == 0) {
     nsCOMPtr<nsIEditor> editor = GetEditor();
     if (editor) {
       bool isEmpty = false;
       editor->GetDocumentIsEmpty(&isEmpty);
       if (isEmpty) {
         nsCOMPtr<nsIDOMElement> editorRootElm;
         editor->GetRootElement(getter_AddRefs(editorRootElm));
 
-        nsCOMPtr<nsIDOMNode> editorRoot(do_QueryInterface(editorRootElm));
+        nsCOMPtr<nsINode> editorRoot(do_QueryInterface(editorRootElm));
         if (editorRoot) {
-          *aStartOffset = *aEndOffset = 0;
-          NS_ADDREF(*aStartNode = editorRoot);
-          NS_ADDREF(*aEndNode = editorRoot);
+          aRange->SetStart(editorRoot, 0);
+          aRange->SetEnd(editorRoot, 0);
 
           return NS_OK;
         }
       }
     }
   }
 
   nsRefPtr<Accessible> startAcc, endAcc;
   PRInt32 startOffset = aStartHTOffset, endOffset = aEndHTOffset;
   nsIFrame *startFrame = nsnull, *endFrame = nsnull;
 
   startFrame = GetPosAndText(startOffset, endOffset, nsnull, &endFrame, nsnull,
                              getter_AddRefs(startAcc), getter_AddRefs(endAcc));
   if (!startAcc || !endAcc)
     return NS_ERROR_FAILURE;
 
-  nsCOMPtr<nsIDOMNode> startNode, endNode;
+  DOMPoint startPoint, endPoint;
   nsresult rv = GetDOMPointByFrameOffset(startFrame, startOffset, startAcc,
-                                         getter_AddRefs(startNode),
-                                         &startOffset);
+                                         &startPoint);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  rv = aRange->SetStart(startPoint.node, startPoint.idx);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (aStartHTOffset != aEndHTOffset) {
-    rv = GetDOMPointByFrameOffset(endFrame, endOffset, endAcc,
-                                  getter_AddRefs(endNode), &endOffset);
-    NS_ENSURE_SUCCESS(rv, rv);
-  } else {
-    endNode = startNode;
-    endOffset = startOffset;
-  }
+  if (aStartHTOffset == aEndHTOffset)
+    return aRange->SetEnd(startPoint.node, startPoint.idx);
 
-  NS_ADDREF(*aStartNode = startNode);
-  *aStartOffset = startOffset;
+  rv = GetDOMPointByFrameOffset(endFrame, endOffset, endAcc, &endPoint);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-  NS_ADDREF(*aEndNode = endNode);
-  *aEndOffset = endOffset;
-
-  return NS_OK;
+  return aRange->SetEnd(endPoint.node, endPoint.idx);
 }
 
 PRInt32
 HyperTextAccessible::GetRelativeOffset(nsIPresShell* aPresShell,
                                        nsIFrame* aFromFrame,
                                        PRInt32 aFromOffset,
                                        Accessible* aFromAccessible,
                                        nsSelectionAmount aAmount,
@@ -1550,28 +1510,22 @@ HyperTextAccessible::SetSelectionRange(P
   // Set the selection
   SetSelectionBounds(0, aStartPos, aEndPos);
 
   // If range 0 was successfully set, clear any additional selection 
   // ranges remaining from previous selection
   nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
   NS_ENSURE_STATE(frameSelection);
 
-  nsCOMPtr<nsISelection> domSel =
+  Selection* domSel =
     frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL);
   NS_ENSURE_STATE(domSel);
 
-  PRInt32 numRanges = 0;
-  domSel->GetRangeCount(&numRanges);
-
-  for (PRInt32 count = 0; count < numRanges - 1; count ++) {
-    nsCOMPtr<nsIDOMRange> range;
-    domSel->GetRangeAt(1, getter_AddRefs(range));
-    domSel->RemoveRange(range);
-  }
+  for (PRInt32 idx = domSel->GetRangeCount() - 1; idx > 0; idx--)
+    domSel->RemoveRange(domSel->GetRangeAt(idx));
 
   // When selection is done, move the focus to the selection if accessible is
   // not focusable. That happens when selection is set within hypertext
   // accessible.
   if (isFocusable)
     return NS_OK;
 
   nsFocusManager* DOMFocusManager = nsFocusManager::GetFocusManager();
@@ -1620,31 +1574,25 @@ HyperTextAccessible::GetCaretOffset(PRIn
   if (focusDisp == FocusManager::eNone)
     return NS_OK;
 
   // Turn the focus node and offset of the selection into caret hypretext
   // offset.
   nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
   NS_ENSURE_STATE(frameSelection);
 
-  nsISelection* domSel =
+  Selection* domSel =
     frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL);
   NS_ENSURE_STATE(domSel);
 
-  nsCOMPtr<nsIDOMNode> focusDOMNode;
-  nsresult rv = domSel->GetFocusNode(getter_AddRefs(focusDOMNode));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  PRInt32 focusOffset;
-  rv = domSel->GetFocusOffset(&focusOffset);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsINode* focusNode = domSel->GetFocusNode();
+  PRInt32 focusOffset = domSel->GetFocusOffset();
 
   // No caret if this DOM node is inside of focused node but the selection's
   // focus point is not inside of this DOM node.
-  nsCOMPtr<nsINode> focusNode(do_QueryInterface(focusDOMNode));
   if (focusDisp == FocusManager::eContainedByFocus) {
     nsINode *resultNode =
       nsCoreUtils::GetDOMNodeFromDOMPoint(focusNode, focusOffset);
 
     nsINode* thisNode = GetNode();
     if (resultNode != thisNode &&
         !nsCoreUtils::IsAncestorOf(thisNode, resultNode))
       return NS_OK;
@@ -1658,29 +1606,31 @@ PRInt32
 HyperTextAccessible::CaretLineNumber()
 {
   // Provide the line number for the caret, relative to the
   // currently focused node. Use a 1-based index
   nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
   if (!frameSelection)
     return -1;
 
-  nsISelection* domSel =
+  Selection* domSel =
     frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL);
   if (!domSel)
     return - 1;
 
-  nsCOMPtr<nsIDOMNode> caretNode;
-  domSel->GetFocusNode(getter_AddRefs(caretNode));
-  nsCOMPtr<nsIContent> caretContent = do_QueryInterface(caretNode);
-  if (!caretContent || !nsCoreUtils::IsAncestorOf(GetNode(), caretContent))
+  nsINode* caretNode = domSel->GetFocusNode();
+  if (!caretNode || !caretNode->IsContent())
     return -1;
 
-  PRInt32 caretOffset, returnOffsetUnused;
-  domSel->GetFocusOffset(&caretOffset);
+  nsIContent* caretContent = caretNode->AsContent();
+  if (!nsCoreUtils::IsAncestorOf(GetNode(), caretContent))
+    return -1;
+
+  PRInt32 returnOffsetUnused;
+  PRInt32 caretOffset = domSel->GetFocusOffset();
   nsFrameSelection::HINT hint = frameSelection->GetHint();
   nsIFrame *caretFrame = frameSelection->GetFrameForNodeOffset(caretContent, caretOffset,
                                                                hint, &returnOffsetUnused);
   NS_ENSURE_TRUE(caretFrame, -1);
 
   PRInt32 lineNumber = 1;
   nsAutoLineIterator lineIterForCaret;
   nsIContent *hyperTextContent = IsContent() ? mContent.get() : nsnull;
@@ -1731,35 +1681,34 @@ HyperTextAccessible::FrameSelection()
 void
 HyperTextAccessible::GetSelectionDOMRanges(PRInt16 aType,
                                            nsTArray<nsRange*>* aRanges)
 {
   nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
   if (!frameSelection)
     return;
 
-  nsISelection* domSel = frameSelection->GetSelection(aType);
+  Selection* domSel = frameSelection->GetSelection(aType);
   if (!domSel)
     return;
 
   nsCOMPtr<nsINode> startNode = GetNode();
 
   nsCOMPtr<nsIEditor> editor = GetEditor();
   if (editor) {
     nsCOMPtr<nsIDOMElement> editorRoot;
     editor->GetRootElement(getter_AddRefs(editorRoot));
     startNode = do_QueryInterface(editorRoot);
   }
 
   if (!startNode)
     return;
 
   PRUint32 childCount = startNode->GetChildCount();
-  nsCOMPtr<nsISelectionPrivate> privSel(do_QueryInterface(domSel));
-  nsresult rv = privSel->
+  nsresult rv = domSel->
     GetRangesForIntervalArray(startNode, 0, startNode, childCount, true, aRanges);
   NS_ENSURE_SUCCESS(rv,);
 
   // Remove collapsed ranges
   PRUint32 numRanges = aRanges->Length();
   for (PRUint32 idx = 0; idx < numRanges; idx ++) {
     if ((*aRanges)[idx]->Collapsed()) {
       aRanges->RemoveElementAt(idx);
@@ -1837,53 +1786,42 @@ HyperTextAccessible::GetSelectionBounds(
 /*
  * Changes the start and end offset of the specified selection.
  */
 NS_IMETHODIMP
 HyperTextAccessible::SetSelectionBounds(PRInt32 aSelectionNum,
                                         PRInt32 aStartOffset,
                                         PRInt32 aEndOffset)
 {
+  if (IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  if (aSelectionNum < 0)
+    return NS_ERROR_INVALID_ARG;
+
   nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
   NS_ENSURE_STATE(frameSelection);
 
-  nsCOMPtr<nsISelection> domSel =
+  Selection* domSel =
     frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL);
   NS_ENSURE_STATE(domSel);
 
+  PRUint32 rangeCount = domSel->GetRangeCount();
+  if (rangeCount < static_cast<PRUint32>(aSelectionNum))
+    return NS_ERROR_INVALID_ARG;
+
   // Caret is a collapsed selection
   bool isOnlyCaret = (aStartOffset == aEndOffset);
-
-  PRInt32 rangeCount = 0;
-  domSel->GetRangeCount(&rangeCount);
-  nsCOMPtr<nsIDOMRange> range;
-  if (aSelectionNum == rangeCount) { // Add a range
+  nsRefPtr<nsRange> range;
+  if (aSelectionNum == rangeCount)
     range = new nsRange();
-  }
-  else if (aSelectionNum < 0 || aSelectionNum > rangeCount) {
-    return NS_ERROR_INVALID_ARG;
-  }
-  else {
-    domSel->GetRangeAt(aSelectionNum, getter_AddRefs(range));
-    NS_ENSURE_TRUE(range, NS_ERROR_FAILURE);
-  }
+  else
+    range = domSel->GetRangeAt(aSelectionNum);
 
-  PRInt32 startOffset = 0, endOffset = 0;
-  nsCOMPtr<nsIDOMNode> startNode, endNode;
-
-  nsresult rv = HypertextOffsetsToDOMRange(aStartOffset, aEndOffset,
-                                           getter_AddRefs(startNode), &startOffset,
-                                           getter_AddRefs(endNode), &endOffset);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = range->SetStart(startNode, startOffset);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = isOnlyCaret ? range->Collapse(true) :
-                     range->SetEnd(endNode, endOffset);
+  nsresult rv = HypertextOffsetsToDOMRange(aStartOffset, aEndOffset, range);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // If new range was created then add it, otherwise notify selection listeners
   // that existing selection range was changed.
   if (aSelectionNum == rangeCount)
     return domSel->AddRange(range);
 
   domSel->RemoveRange(range);
@@ -1895,68 +1833,57 @@ HyperTextAccessible::SetSelectionBounds(
  * Adds a selection bounded by the specified offsets.
  */
 NS_IMETHODIMP
 HyperTextAccessible::AddSelection(PRInt32 aStartOffset, PRInt32 aEndOffset)
 {
   nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
   NS_ENSURE_STATE(frameSelection);
 
-  nsCOMPtr<nsISelection> domSel =
+  Selection* domSel =
     frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL);
   NS_ENSURE_STATE(domSel);
 
-  PRInt32 rangeCount = 0;
-  domSel->GetRangeCount(&rangeCount);
-
-  return SetSelectionBounds(rangeCount, aStartOffset, aEndOffset);
+  return SetSelectionBounds(domSel->GetRangeCount(), aStartOffset, aEndOffset);
 }
 
 /*
  * Removes the specified selection.
  */
 NS_IMETHODIMP
 HyperTextAccessible::RemoveSelection(PRInt32 aSelectionNum)
 {
   nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
   NS_ENSURE_STATE(frameSelection);
 
-  nsCOMPtr<nsISelection> domSel =
+  Selection* domSel =
     frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL);
   NS_ENSURE_STATE(domSel);
 
-  PRInt32 rangeCount;
-  domSel->GetRangeCount(&rangeCount);
-  if (aSelectionNum < 0 || aSelectionNum >= rangeCount)
+  if (aSelectionNum < 0 || aSelectionNum >= domSel->GetRangeCount())
     return NS_ERROR_INVALID_ARG;
 
-  nsCOMPtr<nsIDOMRange> range;
-  domSel->GetRangeAt(aSelectionNum, getter_AddRefs(range));
-  return domSel->RemoveRange(range);
+  return domSel->RemoveRange(domSel->GetRangeAt(aSelectionNum));
 }
 
 // void nsIAccessibleText::
 //   scrollSubstringTo(in long startIndex, in long endIndex,
 //                     in unsigned long scrollType);
 NS_IMETHODIMP
 HyperTextAccessible::ScrollSubstringTo(PRInt32 aStartIndex, PRInt32 aEndIndex,
                                        PRUint32 aScrollType)
 {
-  PRInt32 startOffset, endOffset;
-  nsCOMPtr<nsIDOMNode> startNode, endNode;
+  if (IsDefunct())
+    return NS_ERROR_FAILURE;
 
-  nsresult rv = HypertextOffsetsToDOMRange(aStartIndex, aEndIndex,
-                                           getter_AddRefs(startNode),
-                                           &startOffset,
-                                           getter_AddRefs(endNode),
-                                           &endOffset);
+  nsRefPtr<nsRange> range = new nsRange();
+  nsresult rv = HypertextOffsetsToDOMRange(aStartIndex, aEndIndex, range);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  return nsCoreUtils::ScrollSubstringTo(GetFrame(), startNode, startOffset,
-                                        endNode, endOffset, aScrollType);
+  return nsCoreUtils::ScrollSubstringTo(GetFrame(), range, aScrollType);
 }
 
 // void nsIAccessibleText::
 //   scrollSubstringToPoint(in long startIndex, in long endIndex,
 //                          in unsigned long coordinateType,
 //                          in long x, in long y);
 NS_IMETHODIMP
 HyperTextAccessible::ScrollSubstringToPoint(PRInt32 aStartIndex,
@@ -1968,22 +1895,18 @@ HyperTextAccessible::ScrollSubstringToPo
   if (!frame)
     return NS_ERROR_FAILURE;
 
   nsIntPoint coords;
   nsresult rv = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordinateType,
                                                   this, &coords);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  PRInt32 startOffset, endOffset;
-  nsCOMPtr<nsIDOMNode> startNode, endNode;
-
-  rv = HypertextOffsetsToDOMRange(aStartIndex, aEndIndex,
-                                  getter_AddRefs(startNode), &startOffset,
-                                  getter_AddRefs(endNode), &endOffset);
+  nsRefPtr<nsRange> range = new nsRange();
+  rv = HypertextOffsetsToDOMRange(aStartIndex, aEndIndex, range);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsPresContext *presContext = frame->PresContext();
 
   bool initialScrolled = false;
   nsIFrame *parentFrame = frame;
   while ((parentFrame = parentFrame->GetParent())) {
     nsIScrollableFrame *scrollableFrame = do_QueryFrame(parentFrame);
@@ -2002,19 +1925,17 @@ HyperTextAccessible::ScrollSubstringToPo
 
         // avoid divide by zero
         size.width = size.width ? size.width : 1;
         size.height = size.height ? size.height : 1;
 
         PRInt16 hPercent = offsetPoint.x * 100 / size.width;
         PRInt16 vPercent = offsetPoint.y * 100 / size.height;
 
-        rv = nsCoreUtils::ScrollSubstringTo(GetFrame(), startNode, startOffset,
-                                            endNode, endOffset,
-                                            vPercent, hPercent);
+        rv = nsCoreUtils::ScrollSubstringTo(frame, range, vPercent, hPercent);
         NS_ENSURE_SUCCESS(rv, rv);
 
         initialScrolled = true;
       } else {
         // Substring was scrolled to the given point already inside its closest
         // scrollable area. If there are nested scrollable areas then make
         // sure we scroll lower areas to the given point inside currently
         // traversed scrollable area.
@@ -2224,62 +2145,57 @@ HyperTextAccessible::GetChildIndexAtOffs
 
   return -1;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // HyperTextAccessible protected
 
 nsresult
-HyperTextAccessible::GetDOMPointByFrameOffset(nsIFrame* aFrame,
-                                              PRInt32 aOffset,
+HyperTextAccessible::GetDOMPointByFrameOffset(nsIFrame* aFrame, PRInt32 aOffset,
                                               Accessible* aAccessible,
-                                              nsIDOMNode** aNode,
-                                              PRInt32* aNodeOffset)
+                                              DOMPoint* aPoint)
 {
   NS_ENSURE_ARG(aAccessible);
 
-  nsCOMPtr<nsIDOMNode> node;
-
   if (!aFrame) {
     // If the given frame is null then set offset after the DOM node of the
     // given accessible.
     NS_ASSERTION(!aAccessible->IsDoc(), 
                  "Shouldn't be called on document accessible!");
 
     nsIContent* content = aAccessible->GetContent();
     NS_ASSERTION(content, "Shouldn't operate on defunct accessible!");
 
     nsIContent* parent = content->GetParent();
 
-    *aNodeOffset = parent->IndexOf(content) + 1;
-    node = do_QueryInterface(parent);
+    aPoint->idx = parent->IndexOf(content) + 1;
+    aPoint->node = parent;
 
   } else if (aFrame->GetType() == nsGkAtoms::textFrame) {
-    nsCOMPtr<nsIContent> content(aFrame->GetContent());
+    nsIContent* content = aFrame->GetContent();
     NS_ENSURE_STATE(content);
 
     nsIFrame *primaryFrame = content->GetPrimaryFrame();
-    nsresult rv = RenderedToContentOffset(primaryFrame, aOffset, aNodeOffset);
+    nsresult rv = RenderedToContentOffset(primaryFrame, aOffset, &(aPoint->idx));
     NS_ENSURE_SUCCESS(rv, rv);
 
-    node = do_QueryInterface(content);
+    aPoint->node = content;
 
   } else {
-    nsCOMPtr<nsIContent> content(aFrame->GetContent());
+    nsIContent* content = aFrame->GetContent();
     NS_ENSURE_STATE(content);
 
-    nsCOMPtr<nsIContent> parent(content->GetParent());
+    nsIContent* parent = content->GetParent();
     NS_ENSURE_STATE(parent);
 
-    *aNodeOffset = parent->IndexOf(content);
-    node = do_QueryInterface(parent);
+    aPoint->idx = parent->IndexOf(content);
+    aPoint->node = parent;
   }
 
-  NS_IF_ADDREF(*aNode = node);
   return NS_OK;
 }
 
 // HyperTextAccessible
 nsresult
 HyperTextAccessible::RangeBoundToHypertextOffset(nsRange* aRange,
                                                  bool aIsStartBound,
                                                  bool aIsStartHTOffset,
--- a/accessible/src/generic/HyperTextAccessible.h
+++ b/accessible/src/generic/HyperTextAccessible.h
@@ -11,16 +11,25 @@
 #include "nsIAccessibleEditableText.h"
 
 #include "AccCollector.h"
 #include "AccessibleWrap.h"
 
 #include "nsFrameSelection.h"
 #include "nsISelectionController.h"
 
+namespace mozilla {
+namespace a11y {
+struct DOMPoint {
+  nsINode* node;
+  PRInt32 idx;
+};
+}
+}
+
 enum EGetTextType { eGetBefore=-1, eGetAt=0, eGetAfter=1 };
 
 // This character marks where in the text returned via nsIAccessibleText(),
 // that embedded object characters exist
 const PRUnichar kEmbeddedObjectChar = 0xfffc;
 const PRUnichar kImaginaryEmbeddedObjectChar = ' ';
 const PRUnichar kForcedNewLineChar = '\n';
 
@@ -126,42 +135,25 @@ public:
     *                       otherwise nsnull
     */
   Accessible* DOMPointToHypertextOffset(nsINode *aNode,
                                         PRInt32 aNodeOffset,
                                         PRInt32* aHypertextOffset,
                                         bool aIsEndOffset = false);
 
   /**
-   * Turn a hypertext offsets into DOM point.
-   *
-   * @param  aHTOffset  [in] the given start hypertext offset
-   * @param  aNode      [out] start node
-   * @param  aOffset    [out] offset inside the start node
-   */
-  nsresult HypertextOffsetToDOMPoint(PRInt32 aHTOffset,
-                                     nsIDOMNode **aNode,
-                                     PRInt32 *aOffset);
-
-  /**
    * Turn a start and end hypertext offsets into DOM range.
    *
    * @param  aStartHTOffset  [in] the given start hypertext offset
    * @param  aEndHTOffset    [in] the given end hypertext offset
-   * @param  aStartNode      [out] start node of the range
-   * @param  aStartOffset    [out] start offset of the range
-   * @param  aEndNode        [out] end node of the range
-   * @param  aEndOffset      [out] end offset of the range
+   * @param  aRange      [out] the range whose bounds to set
    */
   nsresult HypertextOffsetsToDOMRange(PRInt32 aStartHTOffset,
                                       PRInt32 aEndHTOffset,
-                                      nsIDOMNode **aStartNode,
-                                      PRInt32 *aStartOffset,
-                                      nsIDOMNode **aEndNode,
-                                      PRInt32 *aEndOffset);
+                                      nsRange* aRange);
 
   /**
    * Return true if the used ARIA role (if any) allows the hypertext accessible
    * to expose text interfaces.
    */
   bool IsTextRole();
 
   //////////////////////////////////////////////////////////////////////////////
@@ -350,17 +342,17 @@ protected:
    */
   void GetSelectionDOMRanges(PRInt16 aType, nsTArray<nsRange*>* aRanges);
 
   nsresult SetSelectionRange(PRInt32 aStartPos, PRInt32 aEndPos);
 
   // Helpers
   nsresult GetDOMPointByFrameOffset(nsIFrame* aFrame, PRInt32 aOffset,
                                     Accessible* aAccessible,
-                                    nsIDOMNode** aNode, PRInt32* aNodeOffset);
+                                    mozilla::a11y::DOMPoint* aPoint);
 
   
   /**
    * Return hyper text offset for the specified bound of the given DOM range.
    * If the bound is outside of the hyper text then offset value is either
    * 0 or number of characters of hyper text, it depends on type of requested
    * offset. The method is a wrapper for DOMPointToHypertextOffset.
    *
--- a/accessible/src/generic/ImageAccessible.cpp
+++ b/accessible/src/generic/ImageAccessible.cpp
@@ -14,17 +14,16 @@
 #include "imgIRequest.h"
 #include "nsGenericHTMLElement.h"
 #include "nsIDocument.h"
 #include "nsIImageLoadingContent.h"
 #include "nsILink.h"
 #include "nsIPresShell.h"
 #include "nsIServiceManager.h"
 #include "nsIDOMHTMLImageElement.h"
-#include "nsIDOMDocument.h"
 #include "nsPIDOMWindow.h"
 
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // ImageAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
--- a/accessible/src/generic/RootAccessible.cpp
+++ b/accessible/src/generic/RootAccessible.cpp
@@ -38,19 +38,17 @@
 #include "nsIDOMHTMLSelectElement.h"
 #include "nsIDOMDataContainerEvent.h"
 #include "nsIDOMNSEvent.h"
 #include "nsIDOMXULMultSelectCntrlEl.h"
 #include "nsIDOMXULPopupElement.h"
 #include "nsIDocument.h"
 #include "nsEventListenerManager.h"
 #include "nsIFrame.h"
-#include "nsIHTMLDocument.h"
 #include "nsIInterfaceRequestorUtils.h"
-#include "nsISelectionPrivate.h"
 #include "nsIServiceManager.h"
 #include "nsPIDOMWindow.h"
 #include "nsIWebBrowserChrome.h"
 #include "nsReadableUtils.h"
 #include "nsFocusManager.h"
 
 #ifdef MOZ_XUL
 #include "nsIXULDocument.h"
--- a/accessible/src/html/HTMLFormControlAccessible.cpp
+++ b/accessible/src/html/HTMLFormControlAccessible.cpp
@@ -10,17 +10,16 @@
 #include "nsARIAMap.h"
 #include "nsTextEquivUtils.h"
 #include "Relation.h"
 #include "Role.h"
 #include "States.h"
 
 #include "nsContentList.h"
 #include "nsIAccessibleRelation.h"
-#include "nsIDOMDocument.h"
 #include "nsIDOMHTMLInputElement.h"
 #include "nsIDOMNSEditableElement.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIDOMHTMLLegendElement.h"
 #include "nsIDOMHTMLTextAreaElement.h"
 #include "nsIDOMNodeList.h"
 #include "nsIEditor.h"
 #include "nsIFormControl.h"
--- a/accessible/src/msaa/AccessibleWrap.cpp
+++ b/accessible/src/msaa/AccessibleWrap.cpp
@@ -25,17 +25,16 @@
 #include "AccessibleStates.h"
 #include "RootAccessible.h"
 
 #ifdef DEBUG
 #include "Logging.h"
 #endif
 
 #include "nsIMutableArray.h"
-#include "nsIDOMDocument.h"
 #include "nsIFrame.h"
 #include "nsIScrollableFrame.h"
 #include "nsINameSpaceManager.h"
 #include "nsINodeInfo.h"
 #include "nsIServiceManager.h"
 #include "nsTextFormatter.h"
 #include "nsIView.h"
 #include "nsIViewManager.h"
--- a/accessible/src/msaa/HyperTextAccessibleWrap.cpp
+++ b/accessible/src/msaa/HyperTextAccessibleWrap.cpp
@@ -7,20 +7,41 @@
 
 #include "HyperTextAccessibleWrap.h"
 
 #include "nsEventShell.h"
 
 NS_IMPL_ISUPPORTS_INHERITED0(HyperTextAccessibleWrap,
                              HyperTextAccessible)
 
-IMPL_IUNKNOWN_INHERITED2(HyperTextAccessibleWrap,
-                         AccessibleWrap,
-                         ia2AccessibleHypertext,
-                         ia2AccessibleEditableText);
+STDMETHODIMP
+HyperTextAccessibleWrap::QueryInterface(REFIID aIID, void** aInstancePtr)
+{
+  if (!aInstancePtr)
+    return E_FAIL;
+
+  *aInstancePtr = NULL;
+
+  if (IsTextRole()) {
+    if (aIID == IID_IAccessibleText)
+      *aInstancePtr =
+        static_cast<IAccessibleText*>(static_cast<ia2AccessibleText*>(this));
+    else if (aIID == IID_IAccessibleHypertext)
+      *aInstancePtr = static_cast<IAccessibleHypertext*>(this);
+    else if (aIID == IID_IAccessibleEditableText)
+      *aInstancePtr = static_cast<IAccessibleEditableText*>(this);
+
+    if (*aInstancePtr) {
+      AddRef();
+      return S_OK;
+    }
+  }
+
+  return AccessibleWrap::QueryInterface(aIID, aInstancePtr);
+}
 
 nsresult
 HyperTextAccessibleWrap::HandleAccEvent(AccEvent* aEvent)
 {
   PRUint32 eventType = aEvent->GetEventType();
 
   if (eventType == nsIAccessibleEvent::EVENT_TEXT_REMOVED ||
       eventType == nsIAccessibleEvent::EVENT_TEXT_INSERTED) {
--- a/accessible/src/msaa/TextLeafAccessibleWrap.cpp
+++ b/accessible/src/msaa/TextLeafAccessibleWrap.cpp
@@ -150,20 +150,25 @@ STDMETHODIMP
 TextLeafAccessibleWrap::scrollToSubstring(
     /* [in] */ unsigned int aStartIndex,
     /* [in] */ unsigned int aEndIndex)
 {
 __try {
   if (IsDefunct())
     return E_FAIL;
 
-  nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
+  nsRefPtr<nsRange> range = new nsRange();
+  if (NS_FAILED(range->SetStart(mContent, aStartIndex)))
+      return E_FAIL;
+
+  if (NS_FAILED(range->SetEnd(mContent, aEndIndex)))
+  return E_FAIL;
+
   nsresult rv =
-    nsCoreUtils::ScrollSubstringTo(GetFrame(), DOMNode, aStartIndex,
-                                   DOMNode, aEndIndex,
+    nsCoreUtils::ScrollSubstringTo(GetFrame(), range,
                                    nsIAccessibleScrollType::SCROLL_TYPE_ANYWHERE);
   if (NS_FAILED(rv))
     return E_FAIL;
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return S_OK;
 }
 
 nsIFrame*
--- a/accessible/src/msaa/ia2AccessibleEditableText.cpp
+++ b/accessible/src/msaa/ia2AccessibleEditableText.cpp
@@ -8,35 +8,16 @@
 #include "ia2AccessibleEditableText.h"
 
 #include "AccessibleEditableText_i.c"
 #include "HyperTextAccessibleWrap.h"
 
 #include "nsCOMPtr.h"
 #include "nsString.h"
 
-// IUnknown
-
-STDMETHODIMP
-ia2AccessibleEditableText::QueryInterface(REFIID iid, void** ppv)
-{
-  *ppv = NULL;
-
-  if (IID_IAccessibleEditableText == iid) {
-    nsCOMPtr<nsIAccessibleEditableText> editTextAcc(do_QueryObject(this));
-    if (!editTextAcc)
-      return E_NOINTERFACE;
-    *ppv = static_cast<IAccessibleEditableText*>(this);
-    (reinterpret_cast<IUnknown*>(*ppv))->AddRef(); 
-    return S_OK;
-  }
-
-  return E_NOINTERFACE;
-}
-
 // IAccessibleEditableText
 
 STDMETHODIMP
 ia2AccessibleEditableText::copyText(long aStartOffset, long aEndOffset)
 {
 __try {
   HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
   if (textAcc->IsDefunct())
--- a/accessible/src/msaa/ia2AccessibleEditableText.h
+++ b/accessible/src/msaa/ia2AccessibleEditableText.h
@@ -12,19 +12,16 @@
 #include "nsIAccessibleEditableText.h"
 
 #include "AccessibleEditableText.h"
 
 class ia2AccessibleEditableText: public IAccessibleEditableText
 {
 public:
 
-  // IUnknown
-  STDMETHODIMP QueryInterface(REFIID, void**);
-
   // IAccessibleEditableText
   virtual HRESULT STDMETHODCALLTYPE copyText(
       /* [in] */ long startOffset,
       /* [in] */ long endOffset);
 
   virtual HRESULT STDMETHODCALLTYPE deleteText(
       /* [in] */ long startOffset,
       /* [in] */ long endOffset);
--- a/accessible/src/msaa/ia2AccessibleHypertext.cpp
+++ b/accessible/src/msaa/ia2AccessibleHypertext.cpp
@@ -6,35 +6,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ia2AccessibleHypertext.h"
 
 #include "AccessibleHypertext_i.c"
 
 #include "HyperTextAccessibleWrap.h"
 
-// IUnknown
-
-STDMETHODIMP
-ia2AccessibleHypertext::QueryInterface(REFIID iid, void** ppv)
-{
-  *ppv = NULL;
-  if (IID_IAccessibleHypertext == iid) {
-    HyperTextAccessibleWrap* hyperAcc = static_cast<HyperTextAccessibleWrap*>(this);
-    if (hyperAcc->IsTextRole()) {
-      *ppv = static_cast<IAccessibleHypertext*>(this);
-      (reinterpret_cast<IUnknown*>(*ppv))->AddRef();
-      return S_OK;
-    }
-    return E_NOINTERFACE;
-  }
-
-  return ia2AccessibleText::QueryInterface(iid, ppv);
-}
-
 // IAccessibleHypertext
 
 STDMETHODIMP
 ia2AccessibleHypertext::get_nHyperlinks(long* aHyperlinkCount)
 {
 __try {
   *aHyperlinkCount = 0;
 
--- a/accessible/src/msaa/ia2AccessibleHypertext.h
+++ b/accessible/src/msaa/ia2AccessibleHypertext.h
@@ -13,19 +13,16 @@
 #include "ia2AccessibleText.h"
 #include "AccessibleHypertext.h"
 
 class ia2AccessibleHypertext : public ia2AccessibleText,
                                public IAccessibleHypertext
 {
 public:
 
-  // IUnknown
-  STDMETHODIMP QueryInterface(REFIID, void**);
-
   // IAccessibleText
   FORWARD_IACCESSIBLETEXT(ia2AccessibleText)
 
   // IAccessibleHypertext
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_nHyperlinks(
       /* [retval][out] */ long* hyperlinkCount);
 
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_hyperlink(
--- a/accessible/src/msaa/ia2AccessibleText.cpp
+++ b/accessible/src/msaa/ia2AccessibleText.cpp
@@ -9,36 +9,16 @@
 
 #include "Accessible2.h"
 #include "AccessibleText_i.c"
 
 #include "HyperTextAccessibleWrap.h"
 
 #include "nsIPersistentProperties2.h"
 
-// IUnknown
-
-STDMETHODIMP
-ia2AccessibleText::QueryInterface(REFIID iid, void** ppv)
-{
-  *ppv = NULL;
-
-  if (IID_IAccessibleText == iid) {
-    nsCOMPtr<nsIAccessibleText> textAcc(do_QueryObject(this));
-    if (!textAcc) {
-      return E_NOINTERFACE;
-    }
-    *ppv = static_cast<IAccessibleText*>(this);
-    (reinterpret_cast<IUnknown*>(*ppv))->AddRef();
-    return S_OK;
-  }
-
-  return E_NOINTERFACE;
-}
-
 // IAccessibleText
 
 STDMETHODIMP
 ia2AccessibleText::addSelection(long aStartOffset, long aEndOffset)
 {
 __try {
   HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
   if (textAcc->IsDefunct())
--- a/accessible/src/msaa/ia2AccessibleText.h
+++ b/accessible/src/msaa/ia2AccessibleText.h
@@ -12,19 +12,16 @@
 #include "nsIAccessibleText.h"
 
 #include "AccessibleText.h"
 
 class ia2AccessibleText: public IAccessibleText
 {
 public:
 
-  // IUnknown
-  STDMETHODIMP QueryInterface(REFIID, void**);
-
   // IAccessibleText
   virtual HRESULT STDMETHODCALLTYPE addSelection(
       /* [in] */ long startOffset,
       /* [in] */ long endOffset);
 
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_attributes(
       /* [in] */ long offset,
       /* [out] */ long *startOffset,
--- a/accessible/src/msaa/nsAccessNodeWrap.cpp
+++ b/accessible/src/msaa/nsAccessNodeWrap.cpp
@@ -12,17 +12,16 @@
 #include "Compatibility.h"
 #include "nsAccessibilityService.h"
 #include "nsCoreUtils.h"
 #include "nsWinUtils.h"
 #include "RootAccessible.h"
 #include "Statistics.h"
 
 #include "nsAttrName.h"
-#include "nsIDocument.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIFrame.h"
 #include "nsINameSpaceManager.h"
 #include "nsPIDOMWindow.h"
 #include "nsIServiceManager.h"
 
 #include "mozilla/Preferences.h"
--- a/accessible/src/msaa/nsWinUtils.cpp
+++ b/accessible/src/msaa/nsWinUtils.cpp
@@ -8,16 +8,18 @@
 #include "nsWinUtils.h"
 
 #include "Compatibility.h"
 #include "DocAccessible.h"
 #include "nsCoreUtils.h"
 
 #include "mozilla/Preferences.h"
 #include "nsArrayUtils.h"
+#include "nsIArray.h"
+#include "nsIDocument.h"
 #include "nsIDocShellTreeItem.h"
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 
 // Window property used by ipc related code in identifying accessible
 // tab windows.
 const PRUnichar* kPropNameTabContent = L"AccessibleTabWindow";
--- a/accessible/src/msaa/nsWinUtils.h
+++ b/accessible/src/msaa/nsWinUtils.h
@@ -4,19 +4,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsWinUtils_h_
 #define nsWinUtils_h_
 
 #include "Accessible2.h"
+#include "nsIDOMCSSStyleDeclaration.h"
+#include "nsCOMPtr.h"
 
-#include "nsIArray.h"
-#include "nsIDocument.h"
+class nsIArray;
+class nsIContent;
 
 const LPCWSTR kClassNameRoot = L"MozillaUIWindowClass";
 const LPCWSTR kClassNameTabContent = L"MozillaContentWindowClass";
 
 class nsWinUtils
 {
 public:
   /**
--- a/b2g/Makefile.in
+++ b/b2g/Makefile.in
@@ -4,16 +4,18 @@
 
 DEPTH      = ..
 topsrcdir  = @top_srcdir@
 srcdir     = @srcdir@
 VPATH      = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS = chrome components locales app
+DIRS = chrome components locales
 
 ifeq ($(OS_ARCH),WINNT)
 DIRS += $(DEPTH)/xulrunner/tools/redit
 endif
 
+DIRS += app
+
 include $(topsrcdir)/config/rules.mk
 include $(topsrcdir)/testing/testsuite-targets.mk
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -329,16 +329,27 @@ nsBrowserAccess.prototype = {
     throw new Error('Not Implemented');
   },
 
   isTabContentWindow: function isTabContentWindow(contentWindow) {
     return contentWindow == window;
   }
 };
 
+// Listen for system messages and relay them to Gaia.
+Services.obs.addObserver(function(aSubject, aTopic, aData) {
+  let msg = JSON.parse(aData);
+  let origin = Services.io.newURI(msg.manifest, null, null).prePath;
+  shell.sendEvent(shell.contentBrowser.contentWindow,
+                  "mozChromeEvent", { type: "open-app",
+                                      url: msg.uri,
+                                      origin: origin,
+                                      manifest: msg.manifest } );
+}, "system-messages-open-app", false);
+
 (function Repl() {
   if (!Services.prefs.getBoolPref('b2g.remote-js.enabled')) {
     return;
   }
   const prompt = 'JS> ';
   let output;
   let reader = {
     onInputStreamReady : function repl_readInput(input) {
@@ -385,17 +396,17 @@ var CustomEventManager = {
     window.addEventListener("ContentStart", (function(evt) {
       let content = shell.contentBrowser.contentWindow;
       content.addEventListener("mozContentEvent", this, false, true);
     }).bind(this), false);
   },
 
   handleEvent: function custevt_handleEvent(evt) {
     let detail = evt.detail;
-    dump('XXX FIXME : Got a mozContentEvent: ' + detail.type);
+    dump('XXX FIXME : Got a mozContentEvent: ' + detail.type + "\n");
 
     switch(detail.type) {
       case 'desktop-notification-click':
       case 'desktop-notification-close':
         AlertsHelper.handleEvent(detail);
         break;
       case 'webapps-install-granted':
       case 'webapps-install-denied':
deleted file mode 100644
--- a/b2g/config/mozconfigs/linux32/debug
+++ /dev/null
@@ -1,23 +0,0 @@
-#GONK_TOOLCHAIN_VERSION=0
-#TOOLCHAIN_HOST=linux-x86
-#export GONK_PRODUCT=generic
-#gonk="/home/cjones/mozilla/gonk-toolchain-$GONK_TOOLCHAIN_VERSION"
-
-mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-b2g
-
-mk_add_options MOZ_MAKE_FLAGS="-j8"
-
-ac_add_options --enable-application=b2g
-
-ac_add_options --target=arm-android-eabi
-ac_add_options --with-gonk="$gonk"
-ac_add_options --with-gonk-toolchain-prefix="$gonk/prebuilt/$TOOLCHAIN_HOST/toolchain/arm-eabi-4.4.3/bin/arm-eabi-"
-ac_add_options --with-endian=little
-ac_add_options --disable-elf-hack
-ac_add_options --enable-debug-symbols
-ac_add_options --enable-profiling
-ac_add_options --with-ccache
-ac_add_options --enable-marionette
-
-# Enable dump() from JS.
-export CXXFLAGS=-DMOZ_ENABLE_JS_DUMP
deleted file mode 100644
--- a/b2g/config/mozconfigs/linux32/nightly
+++ /dev/null
@@ -1,23 +0,0 @@
-#GONK_TOOLCHAIN_VERSION=0
-#TOOLCHAIN_HOST=linux-x86
-#export GONK_PRODUCT=generic
-#gonk="/home/cjones/mozilla/gonk-toolchain-$GONK_TOOLCHAIN_VERSION"
-
-mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-b2g
-
-mk_add_options MOZ_MAKE_FLAGS="-j8"
-
-ac_add_options --enable-application=b2g
-
-ac_add_options --target=arm-android-eabi
-ac_add_options --with-gonk="$gonk"
-ac_add_options --with-gonk-toolchain-prefix="$gonk/prebuilt/$TOOLCHAIN_HOST/toolchain/arm-eabi-4.4.3/bin/arm-eabi-"
-ac_add_options --with-endian=little
-ac_add_options --disable-elf-hack
-ac_add_options --enable-debug-symbols
-ac_add_options --enable-profiling
-ac_add_options --with-ccache
-ac_add_options --enable-marionette
-
-# Enable dump() from JS.
-export CXXFLAGS=-DMOZ_ENABLE_JS_DUMP
rename from b2g/config/mozconfigs/desktop/linux32/nightly
rename to b2g/config/mozconfigs/linux32_gecko/nightly
--- a/b2g/config/mozconfigs/desktop/linux32/nightly
+++ b/b2g/config/mozconfigs/linux32_gecko/nightly
@@ -1,18 +1,16 @@
 ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
 ac_add_options --enable-update-packaging
 ac_add_options --enable-codesighs
 ac_add_options --enable-signmar
 
 # Nightlies only since this has a cost in performance
 #ac_add_options --enable-js-diagnostics
 
-. $topsrcdir/build/unix/mozconfig.linux
-
 # Avoid dependency on libstdc++ 4.5
 ac_add_options --enable-stdcxx-compat
 
 # This will overwrite the default of stripping everything and keep the symbol table.
 # This is useful for profiling and debugging and only increases the package size
 # by 2 MBs.
 STRIP_FLAGS="--strip-debug"
 
rename from b2g/config/mozconfigs/desktop/linux64/nightly
rename to b2g/config/mozconfigs/linux64_gecko/nightly
rename from b2g/config/mozconfigs/desktop/macosx64/nightly
rename to b2g/config/mozconfigs/macosx64_gecko/nightly
rename from b2g/config/mozconfigs/desktop/win32/nightly
rename to b2g/config/mozconfigs/win32_gecko/nightly
--- a/b2g/confvars.sh
+++ b/b2g/confvars.sh
@@ -32,8 +32,10 @@ MOZ_XULRUNNER=1
 else
 MOZ_XULRUNNER=
 MOZ_PLACES=1
 fi
 
 MOZ_APP_ID={3c2e2abc-06d4-11e1-ac3b-374f68613e61}
 MOZ_EXTENSION_MANAGER=1
 ENABLE_MARIONETTE=1
+
+MOZ_SYS_MSG=1
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -173,16 +173,17 @@
 @BINPATH@/components/dom_html.xpt
 @BINPATH@/components/dom_indexeddb.xpt
 @BINPATH@/components/dom_offline.xpt
 @BINPATH@/components/dom_json.xpt
 #ifdef MOZ_B2G_RIL
 @BINPATH@/components/dom_mms.xpt
 #endif
 @BINPATH@/components/dom_browserelement.xpt
+@BINPATH@/components/dom_messages.xpt
 @BINPATH@/components/dom_power.xpt
 @BINPATH@/components/dom_range.xpt
 @BINPATH@/components/dom_settings.xpt
 @BINPATH@/components/dom_sidebar.xpt
 @BINPATH@/components/dom_sms.xpt
 @BINPATH@/components/dom_storage.xpt
 @BINPATH@/components/dom_stylesheets.xpt
 @BINPATH@/components/dom_threads.xpt
@@ -458,16 +459,20 @@
 #endif
 @BINPATH@/components/TelemetryPing.js
 @BINPATH@/components/TelemetryPing.manifest
 @BINPATH@/components/Webapps.js
 @BINPATH@/components/Webapps.manifest
 @BINPATH@/components/AppsService.js
 @BINPATH@/components/AppsService.manifest
 
+@BINPATH@/components/SystemMessageInternal.js
+@BINPATH@/components/SystemMessageManager.js
+@BINPATH@/components/SystemMessageManager.manifest
+
 ; Modules
 @BINPATH@/modules/*
 
 ; Safe Browsing
 @BINPATH@/components/nsURLClassifier.manifest
 @BINPATH@/components/nsUrlClassifierHashCompleter.js
 @BINPATH@/components/nsUrlClassifierListManager.js
 @BINPATH@/components/nsUrlClassifierLib.js
--- a/browser/base/content/pageinfo/pageInfo.xul
+++ b/browser/base/content/pageinfo/pageInfo.xul
@@ -349,33 +349,28 @@
               <radio id="geo#2" command="cmd_geoToggle" label="&permBlock;"/>
             </radiogroup>
           </hbox>
         </vbox>
         <vbox class="permission">
           <label class="permissionLabel" id="permIndexedDBLabel"
                  value="&permIndexedDB;" control="indexedDBRadioGroup"/>
           <hbox role="group" aria-labelledby="permIndexedDBLabel">
-            <checkbox id="indexedDBDef" command="cmd_indexedDBDef" label="&permUseDefault;"/>
+            <checkbox id="indexedDBDef" command="cmd_indexedDBDef" label="&permAskAlways;"/>
             <spacer flex="1"/>
+            <vbox pack="center">
+              <label id="indexedDBStatus" control="indexedDBClear"/>
+            </vbox>
+            <button id="indexedDBClear" label="&permClearStorage;"
+                    accesskey="&permClearStorage.accesskey;" onclick="onIndexedDBClear();"/>
             <radiogroup id="indexedDBRadioGroup" orient="horizontal">
-              <!-- Ask and Allow are purposefully reversed here! -->
-              <radio id="indexedDB#1" command="cmd_indexedDBToggle" label="&permAskAlways;"/>
-              <radio id="indexedDB#0" command="cmd_indexedDBToggle" label="&permAllow;"/>
+              <radio id="indexedDB#1" command="cmd_indexedDBToggle" label="&permAllow;"/>
               <radio id="indexedDB#2" command="cmd_indexedDBToggle" label="&permBlock;"/>
             </radiogroup>
           </hbox>
-          <hbox>
-            <spacer flex="1"/>
-            <vbox pack="center">
-              <label id="indexedDBStatus" control="indexedDBClear" hidden="true"/>
-            </vbox>
-            <button id="indexedDBClear" label="&permClearStorage;" hidden="true"
-                    accesskey="&permClearStorage.accesskey;" onclick="onIndexedDBClear();"/>
-          </hbox>
         </vbox>
         <vbox class="permission" id="permPluginsRow">
           <label class="permissionLabel" id="permPluginsLabel"
                  value="&permPlugins;" control="pluginsRadioGroup"/>
           <hbox role="group" aria-labelledby="permPluginsLabel">
             <checkbox id="pluginsDef" command="cmd_pluginsDef" label="&permAskAlways;"/>
             <spacer flex="1"/>
             <radiogroup id="pluginsRadioGroup" orient="horizontal">
--- a/browser/base/content/pageinfo/permissions.js
+++ b/browser/base/content/pageinfo/permissions.js
@@ -46,17 +46,17 @@ var gPermObj = {
     return BLOCK;
   },
   geo: function getGeoDefaultPermissions()
   {
     return BLOCK;
   },
   indexedDB: function getIndexedDBDefaultPermissions()
   {
-    return UNKNOWN;
+    return BLOCK;
   },
   plugins: function getPluginsDefaultPermissions()
   {
     if (gPrefs.getBoolPref("plugins.click_to_play"))
       return BLOCK;
     return ALLOW;
   },
   fullscreen: function getFullscreenDefaultPermissions()
@@ -144,16 +144,19 @@ function onCheckboxClick(aPartId)
 {
   var permissionManager = Components.classes[PERMISSION_CONTRACTID]
                                     .getService(nsIPermissionManager);
 
   var command  = document.getElementById("cmd_" + aPartId + "Toggle");
   var checkbox = document.getElementById(aPartId + "Def");
   if (checkbox.checked) {
     permissionManager.remove(gPermURI.host, aPartId);
+    if (aPartId == "indexedDB") {
+      permissionManager.remove(gPermURI.host, "indexedDB-unlimited");
+    }
     command.setAttribute("disabled", "true");
     var perm = gPermObj[aPartId]();
     setRadioState(aPartId, perm);
   }
   else {
     onRadioClick(aPartId);
     command.removeAttribute("disabled");
   }
@@ -163,18 +166,17 @@ function onRadioClick(aPartId)
 {
   var permissionManager = Components.classes[PERMISSION_CONTRACTID]
                                     .getService(nsIPermissionManager);
 
   var radioGroup = document.getElementById(aPartId + "RadioGroup");
   var id = radioGroup.selectedItem.id;
   var permission = id.split('#')[1];
   permissionManager.add(gPermURI, aPartId, permission);
-  if (aPartId == "indexedDB" &&
-      (permission == ALLOW || permission == BLOCK)) {
+  if (aPartId == "indexedDB" && permission == BLOCK) {
     permissionManager.remove(gPermURI.host, "indexedDB-unlimited");
   }
   if (aPartId == "fullscreen" && permission == UNKNOWN) {
     permissionManager.remove(gPermURI.host, "fullscreen");
   }  
 }
 
 function setRadioState(aPartId, aValue)
@@ -200,16 +202,17 @@ function initIndexedDBRow()
 function onIndexedDBClear()
 {
   Components.classes["@mozilla.org/dom/indexeddb/manager;1"]
             .getService(nsIIndexedDatabaseManager)
             .clearDatabasesForURI(gPermURI);
 
   var permissionManager = Components.classes[PERMISSION_CONTRACTID]
                                     .getService(nsIPermissionManager);
+  permissionManager.remove(gPermURI.host, "indexedDB");
   permissionManager.remove(gPermURI.host, "indexedDB-unlimited");
   initIndexedDBRow();
 }
 
 function onIndexedDBUsageCallback(uri, usage, fileUsage)
 {
   if (!uri.equals(gPermURI)) {
     throw new Error("Callback received for bad URI: " + uri);
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -748,17 +748,17 @@
           return;
 
         var val = this._getSelectedValueForClipboard();
         if (!val)
           return;
 
         Cc["@mozilla.org/widget/clipboardhelper;1"]
           .getService(Ci.nsIClipboardHelper)
-          .copyStringToClipboard(val, document, Ci.nsIClipboard.kSelectionClipboard);
+          .copyStringToClipboard(val, Ci.nsIClipboard.kSelectionClipboard, document);
       ]]></handler>
     </handlers>
 
   </binding>
 
   <!-- Note: this binding is applied to the autocomplete popup used in the Search bar and in web page content -->
   <binding id="browser-autocomplete-result-popup" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete-result-popup">
     <implementation>
--- a/browser/components/shell/src/nsWindowsShellService.cpp
+++ b/browser/components/shell/src/nsWindowsShellService.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "imgIContainer.h"
 #include "imgIRequest.h"
-#include "nsIDOMDocument.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMHTMLImageElement.h"
 #include "nsIImageLoadingContent.h"
 #include "nsIPrefService.h"
 #include "nsIPrefLocalizedString.h"
 #include "nsIServiceManager.h"
 #include "nsIStringBundle.h"
 #include "nsNetUtil.h"
--- a/browser/devtools/sourceeditor/source-editor-orion.jsm
+++ b/browser/devtools/sourceeditor/source-editor-orion.jsm
@@ -758,18 +758,18 @@ SourceEditor.prototype = {
     this._primarySelectionTimeout = null;
 
     let text = this.getSelectedText();
     if (!text) {
       return;
     }
 
     clipboardHelper.copyStringToClipboard(text,
-                                          this.parentElement.ownerDocument,
-                                          Ci.nsIClipboard.kSelectionClipboard);
+                                          Ci.nsIClipboard.kSelectionClipboard,
+                                          this.parentElement.ownerDocument);
   },
 
   /**
    * Highlight the current line using the Orion annotation model.
    *
    * @private
    * @param object aEvent
    *        The Selection event object.
--- a/browser/devtools/sourceeditor/test/browser_bug695035_middle_click_paste.js
+++ b/browser/devtools/sourceeditor/test/browser_bug695035_middle_click_paste.js
@@ -49,18 +49,18 @@ function editorLoaded()
   editor.setText(initialText);
 
   let expectedString = "foobarBug695035-" + Date.now();
 
   let doCopy = function() {
     let clipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].
                           getService(Ci.nsIClipboardHelper);
     clipboardHelper.copyStringToClipboard(expectedString,
-                                          testWin.document,
-                                          Ci.nsIClipboard.kSelectionClipboard);
+                                          Ci.nsIClipboard.kSelectionClipboard,
+                                          testWin.document);
   };
 
   let onCopy = function() {
     editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste);
 
     EventUtils.synthesizeMouse(editor.editorElement, 10, 10, {}, testWin);
     EventUtils.synthesizeMouse(editor.editorElement, 11, 11, {button: 1}, testWin);
   };
--- a/browser/devtools/sourceeditor/test/head.js
+++ b/browser/devtools/sourceeditor/test/head.js
@@ -91,18 +91,18 @@ function waitForSelection(aExpectedStrin
 
     // First we wait for a known value different from the expected one.
     var preExpectedVal = waitForSelection._monotonicCounter +
                          "-waitForSelection-known-value";
 
     let clipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].
                           getService(Ci.nsIClipboardHelper);
     clipboardHelper.copyStringToClipboard(preExpectedVal,
-                                          document,
-                                          Ci.nsIClipboard.kSelectionClipboard);
+                                          Ci.nsIClipboard.kSelectionClipboard,
+                                          document);
 
     wait(function(aData) aData == preExpectedVal,
          function() {
            // Call the original setup fn
            aSetupFn();
            wait(inputValidatorFn, aSuccessFn, aFailureFn, requestedFlavor);
          }, aFailureFn, "text/unicode");
 }
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -656,16 +656,19 @@ bin/libfreebl_32int64_3.so
 #else
 @BINPATH@/crashreporter@BIN_SUFFIX@
 @BINPATH@/crashreporter.ini
 #ifdef XP_UNIX
 @BINPATH@/Throbber-small.gif
 #endif
 #endif
 @BINPATH@/crashreporter-override.ini
+#ifdef MOZ_CRASHREPORTER_INJECTOR
+@BINPATH@/breakpadinjector.dll
+#endif
 #endif
 
 ; [Extensions]
 ;
 #ifdef MOZ_ENABLE_GNOMEVFS
 bin/components/@DLL_PREFIX@nkgnomevfs@DLL_SUFFIX@
 #endif
 
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -14,21 +14,18 @@ include $(DEPTH)/config/autoconf.mk
 # For sanity's sake, we compile nsinstall without the wrapped system
 # headers, so that we can use it to set up the wrapped system headers.
 VISIBILITY_FLAGS =
 
 # STDCXX_COMPAT is not needed here, and will actually fail because
 # libstdc++-compat is not built yet.
 STDCXX_COMPAT =
 
+ifneq (WINNT,$(HOST_OS_ARCH))
 HOST_PROGRAM	= nsinstall$(HOST_BIN_SUFFIX)
-
-ifeq (WINNT,$(HOST_OS_ARCH))
-HOST_CSRCS	= nsinstall_win.c
-else
 HOST_CSRCS	= nsinstall.c pathsub.c
 endif
 
 TARGETS		= $(HOST_PROGRAM) $(SIMPLE_PROGRAMS)
 
 ifndef CROSS_COMPILE
 ifdef USE_ELF_DYNSTR_GC
 TARGETS		+= elf-dynstr-gc
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -151,16 +151,17 @@ VPX_NEED_OBJ_INT_EXTRACT = @VPX_NEED_OBJ
 LIBJPEG_TURBO_AS = @LIBJPEG_TURBO_AS@
 LIBJPEG_TURBO_ASFLAGS = @LIBJPEG_TURBO_ASFLAGS@
 LIBJPEG_TURBO_X86_ASM = @LIBJPEG_TURBO_X86_ASM@
 LIBJPEG_TURBO_X64_ASM = @LIBJPEG_TURBO_X64_ASM@
 LIBJPEG_TURBO_ARM_ASM = @LIBJPEG_TURBO_ARM_ASM@
 NS_PRINTING = @NS_PRINTING@
 MOZ_PDF_PRINTING = @MOZ_PDF_PRINTING@
 MOZ_CRASHREPORTER = @MOZ_CRASHREPORTER@
+MOZ_CRASHREPORTER_INJECTOR = @MOZ_CRASHREPORTER_INJECTOR@
 MOZ_HELP_VIEWER = @MOZ_HELP_VIEWER@
 MOC = @MOC@
 RCC = @RCC@
 MOZ_NSS_PATCH = @MOZ_NSS_PATCH@
 MOZ_WEBGL = @MOZ_WEBGL@
 MOZ_ANGLE = @MOZ_ANGLE@
 MOZ_DIRECTX_SDK_PATH = @MOZ_DIRECTX_SDK_PATH@
 MOZ_DIRECTX_SDK_CPU_SUFFIX = @MOZ_DIRECTX_SDK_CPU_SUFFIX@
@@ -268,16 +269,18 @@ MOZ_GIO_CFLAGS = @MOZ_GIO_CFLAGS@
 MOZ_GIO_LIBS = @MOZ_GIO_LIBS@
 
 MOZ_NATIVE_NSPR = @MOZ_NATIVE_NSPR@
 MOZ_NATIVE_NSS = @MOZ_NATIVE_NSS@
 
 MOZ_B2G_RIL = @MOZ_B2G_RIL@
 MOZ_B2G_BT = @MOZ_B2G_BT@
 
+MOZ_SYS_MSG = @MOZ_SYS_MSG@
+
 MOZ_ASAN = @MOZ_ASAN@
 MOZ_CFLAGS_NSS = @MOZ_CFLAGS_NSS@
 MOZ_NO_WLZDEFS = @MOZ_NO_WLZDEFS@
 
 BUILD_CTYPES = @BUILD_CTYPES@
 
 COMPILE_ENVIRONMENT = @COMPILE_ENVIRONMENT@
 CROSS_COMPILE   = @CROSS_COMPILE@
--- a/config/config.mk
+++ b/config/config.mk
@@ -628,47 +628,63 @@ GARBAGE		+= $(DEPENDENCIES) $(MKDEPENDEN
 
 ifeq ($(OS_ARCH),Darwin)
 ifndef NSDISTMODE
 NSDISTMODE=absolute_symlink
 endif
 PWD := $(CURDIR)
 endif
 
+NSINSTALL_PY := $(PYTHON) $(call core_abspath,$(topsrcdir)/config/nsinstall.py)
+# For Pymake, wherever we use nsinstall.py we're also going to try to make it
+# a native command where possible. Since native commands can't be used outside
+# of single-line commands, we continue to provide INSTALL for general use.
+# Single-line commands should be switched over to install_cmd.
+NSINSTALL_NATIVECMD := %nsinstall nsinstall
+
 ifdef NSINSTALL_BIN
 NSINSTALL = $(NSINSTALL_BIN)
 else
 ifeq (OS2,$(CROSS_COMPILE)$(OS_ARCH))
 NSINSTALL = $(MOZ_TOOLS_DIR)/nsinstall
 else
+ifeq ($(HOST_OS_ARCH),WINNT)
+NSINSTALL = $(NSINSTALL_PY)
+else
 NSINSTALL = $(CONFIG_TOOLS)/nsinstall$(HOST_BIN_SUFFIX)
+endif # WINNT
 endif # OS2
 endif # NSINSTALL_BIN
 
 
 ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2, $(OS_ARCH)))
-INSTALL		= $(NSINSTALL)
+INSTALL = $(NSINSTALL) -t
+ifdef .PYMAKE
+install_cmd = $(NSINSTALL_NATIVECMD) -t $(1)
+endif # .PYMAKE
+
 else
 
 # This isn't laid out as conditional directives so that NSDISTMODE can be
 # target-specific.
 INSTALL         = $(if $(filter copy, $(NSDISTMODE)), $(NSINSTALL) -t, $(if $(filter absolute_symlink, $(NSDISTMODE)), $(NSINSTALL) -L $(PWD), $(NSINSTALL) -R))
 
 endif # WINNT/OS2
 
+# The default for install_cmd is simply INSTALL
+install_cmd ?= $(INSTALL) $(1)
+
 # Use nsinstall in copy mode to install files on the system
 SYSINSTALL	= $(NSINSTALL) -t
+# This isn't necessarily true, just here
+sysinstall_cmd = install_cmd
 
-# Directory nsinstall. Windows and OS/2 nsinstall can't recursively copy
-# directories.
-ifneq (,$(filter WINNT os2-emx,$(HOST_OS_ARCH)))
-DIR_INSTALL = $(PYTHON) $(topsrcdir)/config/nsinstall.py
-else
+# Directory nsinstall.
 DIR_INSTALL = $(INSTALL)
-endif # WINNT/OS2
+dir_install_cmd = install_cmd
 
 #
 # Localization build automation
 #
 
 # Because you might wish to "make locales AB_CD=ab-CD", we don't hardcode
 # MOZ_UI_LOCALE directly, but use an intermediate variable that can be
 # overridden by the command line. (Besides, AB_CD is prettier).
--- a/config/makefiles/xpidl.mk
+++ b/config/makefiles/xpidl.mk
@@ -41,18 +41,18 @@ ifdef _xpidl-todo_ #{
 
 ## Logic batch #1
 xpidl-install-src-preqs=\
   $(XPIDLSRCS) \
   $(call mkdir_deps,$(IDL_DIR)) \
   $(NULL)
 
 xpidl-install-src: $(xpidl-install-src-preqs)
-	$(INSTALL) $(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val)))
+	$(call install_cmd,$(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val))))
 
 xpidl-install-headers-preqs =\
   $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) \
   $(call mkdir_deps,$(DIST)/include) \
   $(NULL)
 xpidl-install-headers: $(xpidl-install-headers-preqs)
-	$(INSTALL) $(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val)))
+	$(call install_cmd,$(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val))))
 
 endif #} _xpidl-todo_
--- a/config/nsinstall.py
+++ b/config/nsinstall.py
@@ -10,18 +10,19 @@
 # The basic limitation is, it doesn't even try to link and ignores
 # all related options.
 
 from optparse import OptionParser
 import os
 import os.path
 import sys
 import shutil
+import stat
 
-def nsinstall(argv):
+def _nsinstall_internal(argv):
   usage = "usage: %prog [options] arg1 [arg2 ...] target-directory"
   p = OptionParser(usage=usage)
 
   p.add_option('-D', action="store_true",
                help="Create a single directory only")
   p.add_option('-t', action="store_true",
                help="Preserve time stamp")
   p.add_option('-m', action="store",
@@ -56,46 +57,57 @@ def nsinstall(argv):
     # mode is specified
     try:
       options.m = int(options.m, 8)
     except:
       sys.stderr.write('nsinstall: ' + options.m + ' is not a valid mode\n')
       return 1
 
   # just create one directory?
-  if options.D:
-    if len(args) != 1:
+  def maybe_create_dir(dir, mode, try_again):
+    if os.path.exists(dir):
+      if not os.path.isdir(dir):
+        print >> sys.stderr, ('nsinstall: %s is not a directory' % dir)
+        return 1
+      if mode:
+        os.chmod(dir, mode)
+      return 0
+
+    try:
+      if mode:
+        os.makedirs(dir, mode)
+      else:
+        os.makedirs(dir)
+    except Exception, e:
+      # We might have hit EEXIST due to a race condition (see bug 463411) -- try again once
+      if try_again:
+        return maybe_create_dir(dir, mode, False)
+      print >> sys.stderr, ("nsinstall: failed to create directory %s: %s" % (dir, e))
       return 1
-    if os.path.exists(args[0]):
-      if not os.path.isdir(args[0]):
-        sys.stderr.write('nsinstall: ' + args[0] + ' is not a directory\n')
-        sys.exit(1)
-      if options.m:
-        os.chmod(args[0], options.m)
-      sys.exit()
-    if options.m:
-      os.makedirs(args[0], options.m)
     else:
-      os.makedirs(args[0])
-    return 0
+      return 0
 
   if options.X:
     options.X = [os.path.abspath(p) for p in options.X]
 
+  if options.D:
+    return maybe_create_dir(args[0], options.m, True)
+
   # nsinstall arg1 [...] directory
   if len(args) < 2:
     p.error('not enough arguments')
 
   def copy_all_entries(entries, target):
     for e in entries:
-      if options.X and os.path.abspath(e) in options.X:
+      e = os.path.abspath(e)
+      if options.X and e in options.X:
         continue
 
-      dest = os.path.join(target,
-                          os.path.basename(os.path.normpath(e)))
+      dest = os.path.join(target, os.path.basename(e))
+      dest = os.path.abspath(dest)
       handleTarget(e, dest)
       if options.m:
         os.chmod(dest, options.m)
 
   # set up handler
   if options.d:
     # we're supposed to create directories
     def handleTarget(srcpath, targetpath):
@@ -107,24 +119,62 @@ def nsinstall(argv):
       if os.path.isdir(srcpath):
         if not os.path.exists(targetpath):
           os.mkdir(targetpath)
         entries = [os.path.join(srcpath, e) for e in os.listdir(srcpath)]
         copy_all_entries(entries, targetpath)
         # options.t is not relevant for directories
         if options.m:
           os.chmod(targetpath, options.m)
-      elif options.t:
-        shutil.copy2(srcpath, targetpath)
       else:
-        shutil.copy(srcpath, targetpath)
+        if os.path.exists(targetpath):
+          # On Windows, read-only files can't be deleted
+          os.chmod(targetpath, stat.S_IWUSR)
+          os.remove(targetpath)
+        if options.t:
+          shutil.copy2(srcpath, targetpath)
+        else:
+          shutil.copy(srcpath, targetpath)
 
   # the last argument is the target directory
   target = args.pop()
-  # ensure target directory
-  if not os.path.isdir(target):
-    os.makedirs(target)
+  # ensure target directory (importantly, we do not apply a mode to the directory
+  # because we want to copy files into it and the mode might be read-only)
+  rv = maybe_create_dir(target, None, True)
+  if rv != 0:
+    return rv
 
   copy_all_entries(args, target)
   return 0
 
+# nsinstall as a native command is always UTF-8
+def nsinstall(argv):
+  return _nsinstall_internal([unicode(arg, "utf-8") for arg in argv])
+
 if __name__ == '__main__':
-  sys.exit(nsinstall(sys.argv[1:]))
+  # sys.argv corrupts characters outside the system code page on Windows
+  # <http://bugs.python.org/issue2128>. Use ctypes instead. This is also
+  # useful because switching to Unicode strings makes python use the wide
+  # Windows APIs, which is what we want here since the wide APIs normally do a
+  # better job at handling long paths and such.
+  if sys.platform == "win32":
+    import ctypes
+    from ctypes import wintypes
+    GetCommandLine = ctypes.windll.kernel32.GetCommandLineW
+    GetCommandLine.argtypes = []
+    GetCommandLine.restype = wintypes.LPWSTR
+
+    CommandLineToArgv = ctypes.windll.shell32.CommandLineToArgvW
+    CommandLineToArgv.argtypes = [wintypes.LPWSTR, ctypes.POINTER(ctypes.c_int)]
+    CommandLineToArgv.restype = ctypes.POINTER(wintypes.LPWSTR)
+
+    argc = ctypes.c_int(0)
+    argv_arr = CommandLineToArgv(GetCommandLine(), ctypes.byref(argc))
+    # The first argv will be "python", the second will be the .py file
+    argv = argv_arr[1:argc.value]
+  else:
+    # For consistency, do it on Unix as well
+    if sys.stdin.encoding is not None:
+      argv = [unicode(arg, sys.stdin.encoding) for arg in sys.argv]
+    else:
+      argv = [unicode(arg) for arg in sys.argv]
+
+  sys.exit(_nsinstall_internal(argv[1:]))
deleted file mode 100644
--- a/config/nsinstall_win.c
+++ /dev/null
@@ -1,747 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * The nsinstall command for Win32
- *
- * Our gmake makefiles use the nsinstall command to create the
- * object directories or installing headers and libs. This code was originally
- * taken from shmsdos.c
- */
-
-#include <direct.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <windows.h>
-#pragma hdrstop
-
-/*
- * sh_FileFcn --
- *
- * A function that operates on a file.  The pathname is either
- * absolute or relative to the current directory, and contains
- * no wildcard characters such as * and ?.   Additional arguments
- * can be passed to the function via the arg pointer.
- */
-
-typedef BOOL (*sh_FileFcn)(
-        wchar_t *pathName,
-        WIN32_FIND_DATA *fileData,
-        void *arg);
-
-static int shellCp (wchar_t **pArgv); 
-static int shellNsinstall (wchar_t **pArgv);
-static int shellMkdir (wchar_t **pArgv); 
-static BOOL sh_EnumerateFiles(const wchar_t *pattern, const wchar_t *where,
-        sh_FileFcn fileFcn, void *arg, int *nFiles);
-static const char *sh_GetLastErrorMessage(void);
-static BOOL sh_DoCopy(wchar_t *srcFileName, DWORD srcFileAttributes,
-        wchar_t *dstFileName, DWORD dstFileAttributes,
-        int force, int recursive);
-
-#define LONGPATH_PREFIX L"\\\\?\\"
-#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
-#define STR_LEN(a) (ARRAY_LEN(a) - 1)
-
-#ifdef __MINGW32__
-
-/* MingW currently does not implement a wide version of the
-   startup routines.  Workaround is to implement something like
-   it ourselves. */
-
-#include <shellapi.h>
-
-int wmain(int argc, WCHAR **argv);
-
-int main(int argc, char **argv)
-{
-    int result;
-    wchar_t *commandLine = GetCommandLineW();
-    int argcw = 0;
-    wchar_t **_argvw = CommandLineToArgvW( commandLine, &argcw );
-    wchar_t *argvw[argcw + 1];
-    int i;
-    if (!_argvw)
-        return 127;
-    /* CommandLineToArgvW doesn't output the ending NULL so
-       we have to manually add it on */
-    for ( i = 0; i < argcw; i++ )
-        argvw[i] = _argvw[i];
-    argvw[argcw] = NULL;
-
-    result = wmain(argcw, argvw);
-    LocalFree(_argvw);
-    return result;
-}
-#endif /* __MINGW32__ */
-
-/* changes all forward slashes in token to backslashes */
-void changeForwardSlashesToBackSlashes ( wchar_t *arg )
-{
-    if ( arg == NULL )
-        return;
-
-    while ( *arg ) {
-        if ( *arg == '/' )
-            *arg = '\\';
-        arg++;
-    }
-}
-
-int wmain(int argc, wchar_t *argv[ ])
-{
-    return shellNsinstall ( argv + 1 );
-}
-
-static int
-shellNsinstall (wchar_t **pArgv)
-{
-    int retVal = 0;     /* exit status */
-    int dirOnly = 0;    /* 1 if and only if -D is specified */
-    wchar_t **pSrc;
-    wchar_t **pDst;
-
-    /*
-     * Process the command-line options.  We ignore the
-     * options except for -D.  Some options, such as -m,
-     * are followed by an argument.  We need to skip the
-     * argument too.
-     */
-    while ( *pArgv && **pArgv == '-' ) {
-        wchar_t c = (*pArgv)[1];  /* The char after '-' */
-
-        if ( c == 'D' ) {
-            dirOnly = 1;
-        } else if ( c == 'm' ) {
-            pArgv++;  /* skip the next argument */
-        }
-        pArgv++;
-    }
-
-    if ( !dirOnly ) {
-        /* There are files to install.  Get source files */
-        if ( *pArgv ) {
-            pSrc = pArgv++;
-        } else {
-            fprintf( stderr, "nsinstall: not enough arguments\n");
-            return 3;
-        }
-    }
-
-    /* Get to last token to find destination directory */
-    if ( *pArgv ) {
-        pDst = pArgv++;
-        if ( dirOnly && *pArgv ) {
-            fprintf( stderr, "nsinstall: too many arguments with -D\n");
-            return 3;
-        }
-    } else {
-        fprintf( stderr, "nsinstall: not enough arguments\n");
-        return 3;
-    }
-    while ( *pArgv ) 
-        pDst = pArgv++;
-
-    retVal = shellMkdir ( pDst );
-    if ( retVal )
-        return retVal;
-    if ( !dirOnly )
-        retVal = shellCp ( pSrc );
-    return retVal;
-}
-
-static int
-shellMkdir (wchar_t **pArgv) 
-{
-    int retVal = 0; /* assume valid return */
-    wchar_t *arg;
-    wchar_t *pArg;
-    wchar_t path[_MAX_PATH];
-    wchar_t tmpPath[_MAX_PATH];
-    wchar_t *pTmpPath = tmpPath;
-
-    /* All the options are simply ignored in this implementation */
-    while ( *pArgv && **pArgv == '-' ) {
-        if ( (*pArgv)[1] == 'm' ) {
-            pArgv++;  /* skip the next argument (mode) */
-        }
-        pArgv++;
-    }
-
-    while ( *pArgv ) {
-        arg = *pArgv;
-        changeForwardSlashesToBackSlashes ( arg );
-        pArg = arg;
-        pTmpPath = tmpPath;
-        while ( 1 ) {
-            /* create part of path */
-            while ( *pArg ) {
-                *pTmpPath++ = *pArg++;
-                if ( *pArg == '\\' )
-                    break;
-            }
-            *pTmpPath = '\0';
-
-            /* check if directory already exists */
-            _wgetcwd ( path, _MAX_PATH );
-            if ( _wchdir ( tmpPath ) == -1 &&
-                 _wmkdir ( tmpPath ) == -1 && // might have hit EEXIST
-                 _wchdir ( tmpPath ) == -1) { // so try again
-                char buf[2048];
-                _snprintf(buf, 2048, "Could not create the directory: %S",
-                          tmpPath);
-                perror ( buf );
-                retVal = 3;
-                break;
-            } else {
-                // get back to the cwd
-                _wchdir ( path );
-            }
-            if ( *pArg == '\0' )      /* complete path? */
-                break;
-            /* loop for next directory */
-        }
-
-        pArgv++;
-    }
-    return retVal;
-}
-
-static const char *
-sh_GetLastErrorMessage()
-{
-    static char buf[128];
-
-    FormatMessageA(
-            FORMAT_MESSAGE_FROM_SYSTEM,
-            NULL,
-            GetLastError(),
-            MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),  /* default language */
-            buf,
-            sizeof(buf),
-            NULL
-    );
-    return buf;
-}
-
-/*
- * struct sh_FileData --
- *
- * A pointer to the sh_FileData structure is passed into sh_RecordFileData,
- * which will fill in the fields.
- */
-
-struct sh_FileData {
-    wchar_t pathName[_MAX_PATH];
-    DWORD dwFileAttributes;
-};
-
-/*
- * sh_RecordFileData --
- *
- * Record the pathname and attributes of the file in
- * the sh_FileData structure pointed to by arg.
- *
- * Always return TRUE (successful completion).
- *
- * This function is intended to be passed into sh_EnumerateFiles
- * to see if a certain pattern expands to exactly one file/directory,
- * and if so, record its pathname and attributes.
- */
-
-static BOOL
-sh_RecordFileData(wchar_t *pathName, WIN32_FIND_DATA *findData, void *arg)
-{
-    struct sh_FileData *fData = (struct sh_FileData *) arg;
-
-    wcscpy(fData->pathName, pathName);
-    fData->dwFileAttributes = findData->dwFileAttributes;
-    return TRUE;
-}
-
-static BOOL
-sh_DoCopy(wchar_t *srcFileName,
-          DWORD srcFileAttributes,
-          wchar_t *dstFileName,
-          DWORD dstFileAttributes,
-          int force,
-          int recursive
-)
-{
-    if (dstFileAttributes != 0xFFFFFFFF) {
-        if ((dstFileAttributes & FILE_ATTRIBUTE_READONLY) && force) {
-            dstFileAttributes &= ~FILE_ATTRIBUTE_READONLY;
-            SetFileAttributes(dstFileName, dstFileAttributes);
-        }
-    }
-
-    if (srcFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
-        fprintf(stderr, "nsinstall: %ls is a directory\n",
-                srcFileName);
-        return FALSE;
-    } else {
-        DWORD r;
-        wchar_t longSrc[1004] = LONGPATH_PREFIX;
-        wchar_t longDst[1004] = LONGPATH_PREFIX;
-        r = GetFullPathName(srcFileName, 1000, longSrc + STR_LEN(LONGPATH_PREFIX), NULL);
-        if (!r) {
-            fprintf(stderr, "nsinstall: couldn't get full path of %ls: %s\n",
-                    srcFileName, sh_GetLastErrorMessage());
-            return FALSE;
-        }
-        r = GetFullPathName(dstFileName, 1000, longDst + ARRAY_LEN(LONGPATH_PREFIX) - 1, NULL);
-        if (!r) {
-            fprintf(stderr, "nsinstall: couldn't get full path of %ls: %s\n",
-                    dstFileName, sh_GetLastErrorMessage());
-            return FALSE;
-        }
-
-        if (!CopyFile(longSrc, longDst, FALSE)) {
-            fprintf(stderr, "nsinstall: cannot copy %ls to %ls: %s\n",
-                    srcFileName, dstFileName, sh_GetLastErrorMessage());
-            return FALSE;
-        }
-    }
-    return TRUE;
-}
-
-/*
- * struct sh_CpCmdArg --
- *
- * A pointer to the sh_CpCmdArg structure is passed into sh_CpFileCmd.
- * The sh_CpCmdArg contains information about the cp command, and
- * provide a buffer for constructing the destination file name.
- */
-
-struct sh_CpCmdArg {
-    int force;                /* -f option, ok to overwrite an existing
-                               * read-only destination file */
-    int recursive;            /* -r or -R option, recursively copy
-                               * directories. Note: this field is not used
-                               * by nsinstall and should always be 0. */
-    wchar_t *dstFileName;        /* a buffer for constructing the destination
-                               * file name */
-    wchar_t *dstFileNameMarker;  /* points to where in the dstFileName buffer
-                               * we should write the file component of the
-                               * destination file */
-};
-
-/*
- * sh_CpFileCmd --
- *
- * Copy a file to the destination directory
- * 
- * This function is intended to be passed into sh_EnumerateFiles to
- * copy all the files specified by the pattern to the destination
- * directory.
- *
- * Return TRUE if the file is successfully copied, and FALSE otherwise.
- */
-
-static BOOL
-sh_CpFileCmd(wchar_t *pathName, WIN32_FIND_DATA *findData, void *cpArg)
-{
-    BOOL retVal = TRUE;
-    struct sh_CpCmdArg *arg = (struct sh_CpCmdArg *) cpArg;
-
-    wcscpy(arg->dstFileNameMarker, findData->cFileName);
-    return sh_DoCopy(pathName, findData->dwFileAttributes,
-            arg->dstFileName, GetFileAttributes(arg->dstFileName),
-            arg->force, arg->recursive);
-}
-
-static int
-shellCp (wchar_t **pArgv) 
-{
-    int retVal = 0;
-    wchar_t **pSrc;
-    wchar_t **pDst;
-    struct sh_CpCmdArg arg;
-    struct sh_FileData dstData;
-    int dstIsDir = 0;
-    int n;
-
-    arg.force = 0;
-    arg.recursive = 0;
-    arg.dstFileName = dstData.pathName;
-    arg.dstFileNameMarker = 0;
-
-    while (*pArgv && **pArgv == '-') {
-        wchar_t *p = *pArgv;
-
-        while (*(++p)) {
-            if (*p == 'f') {
-                arg.force = 1;
-            }
-        }
-        pArgv++;
-    }
-
-    /* the first source file */
-    if (*pArgv) {
-        pSrc = pArgv++;
-    } else {
-        fprintf(stderr, "nsinstall: not enough arguments\n");
-        return 3;
-    }
-
-    /* get to the last token to find destination */
-    if (*pArgv) {
-        pDst = pArgv++;
-    } else {
-        fprintf(stderr, "nsinstall: not enough arguments\n");
-        return 3;
-    }
-    while (*pArgv) {
-        pDst = pArgv++;
-    }
-
-    /*
-     * The destination pattern must unambiguously expand to exactly
-     * one file or directory.
-     */
-
-    changeForwardSlashesToBackSlashes(*pDst);
-    sh_EnumerateFiles(*pDst, *pDst, sh_RecordFileData, &dstData, &n);
-    assert(n >= 0);
-    if (n == 1) {
-        /*
-         * Is the destination a file or directory?
-         */
-
-        if (dstData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
-            dstIsDir = 1;
-        }
-    } else if (n > 1) {
-        fprintf(stderr, "nsinstall: %ls: ambiguous destination file "
-                "or directory\n", *pDst);
-        return 3;
-    } else {
-        /*
-         * n == 0, meaning that destination file or directory does
-         * not exist.  In this case the destination file directory
-         * name must be fully specified.
-         */
-
-        wchar_t *p;
-
-        for (p = *pDst; *p; p++) {
-            if (*p == '*' || *p == '?') {
-                fprintf(stderr, "nsinstall: %ls: No such file or directory\n",
-                        *pDst);
-                return 3;
-            }
-        }
-
-        /*
-         * Do not include the trailing \, if any, unless it is a root
-         * directory (\ or X:\).
-         */
-
-        if (p > *pDst && p[-1] == '\\' && p != *pDst + 1 && p[-2] != ':') {
-            p[-1] = '\0';
-        }
-        wcscpy(dstData.pathName, *pDst);
-        dstData.dwFileAttributes = 0xFFFFFFFF;
-    }
-
-    /*
-     * If there are two or more source files, the destination has
-     * to be a directory.
-     */
-
-    if (pDst - pSrc > 1 && !dstIsDir) {
-        fprintf(stderr, "nsinstall: cannot copy more than"
-                " one file to the same destination file\n");
-        return 3;
-    }
-
-    if (dstIsDir) {
-        arg.dstFileNameMarker = arg.dstFileName + wcslen(arg.dstFileName);
-
-        /*
-         * Now arg.dstFileNameMarker is pointing to the null byte at the
-         * end of string.  We want to make sure that there is a \ at the
-         * end of string, and arg.dstFileNameMarker should point right
-         * after that \. 
-         */
-
-        if (arg.dstFileNameMarker[-1] != '\\') {
-            *(arg.dstFileNameMarker++) = '\\';
-        }
-    }
-    
-    if (!dstIsDir) {
-        struct sh_FileData srcData;
-
-        assert(pDst - pSrc == 1);
-        changeForwardSlashesToBackSlashes(*pSrc);
-        sh_EnumerateFiles(*pSrc, *pSrc, sh_RecordFileData, &srcData, &n);
-        if (n == 0) {
-            fprintf(stderr, "nsinstall: %ls: No such file or directory\n",
-                    *pSrc);
-            retVal = 3;
-        } else if (n > 1) {
-            fprintf(stderr, "nsinstall: cannot copy more than one file or "
-                    "directory to the same destination\n");
-            retVal = 3;
-        } else {
-            assert(n == 1);
-            if (sh_DoCopy(srcData.pathName, srcData.dwFileAttributes,
-                    dstData.pathName, dstData.dwFileAttributes,
-                    arg.force, arg.recursive) == FALSE) {
-                retVal = 3;
-            }
-        }
-        return retVal;
-    }
-
-    for ( ; *pSrc != *pDst; pSrc++) {
-        BOOL rv;
-
-        changeForwardSlashesToBackSlashes(*pSrc);
-        rv = sh_EnumerateFiles(*pSrc, *pSrc, sh_CpFileCmd, &arg, &n);
-        if (rv == FALSE) {
-            retVal = 3;
-        } else {
-            if (n == 0) {
-                fprintf(stderr, "nsinstall: %ls: No such file or directory\n",
-                        *pSrc);
-                retVal = 3;
-            }
-        }
-    }
-
-    return retVal;
-}
-
-/*
- * sh_EnumerateFiles --
- *
- * Enumerate all the files in the specified pattern, which is a pathname
- * containing possibly wildcard characters such as * and ?.  fileFcn
- * is called on each file, passing the expanded file name, a pointer
- * to the file's WIN32_FILE_DATA, and the arg pointer.
- * 
- * It is assumed that there are no wildcard characters before the
- * character pointed to by 'where'.
- *
- * On return, *nFiles stores the number of files enumerated.  *nFiles is
- * set to this number whether sh_EnumerateFiles or 'fileFcn' succeeds
- * or not.
- *
- * Return TRUE if the files are successfully enumerated and all
- * 'fileFcn' invocations succeeded.  Return FALSE if something went
- * wrong.
- */
-
-static BOOL sh_EnumerateFiles(
-        const wchar_t *pattern,
-        const wchar_t *where,
-        sh_FileFcn fileFcn,
-        void *arg,
-        int *nFiles
-        )
-{
-    WIN32_FIND_DATA fileData;
-    HANDLE hSearch;
-    const wchar_t *src;
-    wchar_t *dst;
-    wchar_t fileName[_MAX_PATH];
-    wchar_t *fileNameMarker = fileName;
-    wchar_t *oldFileNameMarker;
-    BOOL hasWildcard = FALSE;
-    BOOL retVal = TRUE;
-    BOOL patternEndsInDotStar = FALSE;
-    BOOL patternEndsInDot = FALSE;  /* a special case of
-                                     * patternEndsInDotStar */
-    int numDotsInPattern;
-    int len;
-    
-    /*
-     * Windows expands patterns ending in ".", ".*", ".**", etc.
-     * differently from the glob expansion on Unix.  For example,
-     * both "foo." and "foo.*" match "foo", and "*.*" matches
-     * everything, including filenames with no dots.  So we need
-     * to throw away extra files returned by the FindNextFile()
-     * function.  We require that a matched filename have at least
-     * the number of dots in the pattern.
-     */
-    len = wcslen(pattern);
-    if (len >= 2) {
-        /* Start from the end of pattern and go backward */
-        const wchar_t *p = &pattern[len - 1];
-
-        /* We can have zero or more *'s */
-        while (p >= pattern && *p == '*') {
-            p--;
-        }
-        if (p >= pattern && *p == '.') {
-            patternEndsInDotStar = TRUE;
-            if (p == &pattern[len - 1]) {
-                patternEndsInDot = TRUE;
-            }
-            p--;
-            numDotsInPattern = 1;
-            while (p >= pattern && *p != '\\') {
-                if (*p == '.') {
-                    numDotsInPattern++;
-                }
-                p--;
-            }
-        }
-    }
-
-    *nFiles = 0;
-
-    /*
-     * Copy pattern to fileName, but only up to and not including
-     * the first \ after the first wildcard letter.
-     *
-     * Make fileNameMarker point to one of the following:
-     * - the start of fileName, if fileName does not contain any \.
-     * - right after the \ before the first wildcard letter, if there is
-     *   a wildcard character.
-     * - right after the last \, if there is no wildcard character.
-     */
-
-    dst = fileName;
-    src = pattern;
-    while (src < where) {
-        if (*src == '\\') {
-            oldFileNameMarker = fileNameMarker;
-            fileNameMarker = dst + 1;
-        }
-        *(dst++) = *(src++);
-    }
-
-    while (*src && *src != '*' && *src != '?') {
-        if (*src == '\\') {
-            oldFileNameMarker = fileNameMarker;
-            fileNameMarker = dst + 1;
-        }
-        *(dst++) = *(src++);
-    }
-
-    if (*src) {
-        /*
-         * Must have seen the first wildcard letter
-         */
-
-        hasWildcard = TRUE;
-        while (*src && *src != '\\') {
-            *(dst++) = *(src++);
-        }
-    }
-    
-    /* Now src points to either null or \ */
-
-    assert(*src == '\0' || *src == '\\');
-    assert(hasWildcard || *src == '\0');
-    *dst = '\0';
-
-    /*
-     * If the pattern does not contain any wildcard characters, then
-     * we don't need to go the FindFirstFile route.
-     */
-
-    if (!hasWildcard) {
-        /*
-         * See if it is the root directory, \, or X:\.
-         */
-
-        assert(!wcscmp(fileName, pattern));
-        assert(wcslen(fileName) >= 1);
-        if (dst[-1] == '\\' && (dst == fileName + 1 || dst[-2] == ':')) {
-            fileData.cFileName[0] = '\0';
-        } else {
-            /*
-             * Do not include the trailing \, if any
-             */
-
-            if (dst[-1] == '\\') {
-                assert(*fileNameMarker == '\0');
-                dst[-1] = '\0';
-                fileNameMarker = oldFileNameMarker;
-            } 
-            wcscpy(fileData.cFileName, fileNameMarker);
-        }
-        fileData.dwFileAttributes = GetFileAttributes(fileName);
-        if (fileData.dwFileAttributes == 0xFFFFFFFF) {
-            return TRUE;
-        }
-        *nFiles = 1;
-        return (*fileFcn)(fileName, &fileData, arg);
-    }
-
-    hSearch = FindFirstFile(fileName, &fileData);
-    if (hSearch == INVALID_HANDLE_VALUE) {
-        return retVal;
-    }
-
-    do {
-        if (!wcscmp(fileData.cFileName, L".")
-                || !wcscmp(fileData.cFileName, L"..")) {
-            /* 
-             * Skip over . and ..
-             */
-
-            continue;
-        }
-
-        if (patternEndsInDotStar) {
-            int nDots = 0;
-            wchar_t *p = fileData.cFileName;
-            while (*p) {
-                if (*p == '.') {
-                    nDots++;
-                }
-                p++;
-            }
-            /* Now p points to the null byte at the end of file name */
-            if (patternEndsInDot && (p == fileData.cFileName
-                    || p[-1] != '.')) {
-                /*
-                 * File name does not end in dot.  Skip this file.
-                 * Note: windows file name probably cannot end in dot,
-                 * but we do this check anyway.
-                 */
-                continue;
-            }
-            if (nDots < numDotsInPattern) {
-                /*
-                 * Not enough dots in file name.  Must be an extra
-                 * file in matching .* pattern.  Skip this file.
-                 */
-                continue;
-            }
-        }
-
-        wcscpy(fileNameMarker, fileData.cFileName);
-        if (*src && *(src + 1)) {
-            /*
-             * More to go.  Recurse.
-             */
-
-            int n;
-
-            assert(*src == '\\');
-            where = fileName + wcslen(fileName);
-            wcscat(fileName, src);
-            sh_EnumerateFiles(fileName, where, fileFcn, arg, &n);
-            *nFiles += n;
-        } else {
-            assert(wcschr(fileName, '*') == NULL);
-            assert(wcschr(fileName, '?') == NULL);
-            (*nFiles)++;
-            if ((*fileFcn)(fileName, &fileData, arg) == FALSE) {
-                retVal = FALSE;
-            }
-        }
-    } while (FindNextFile(hSearch, &fileData));
-
-    FindClose(hSearch);
-    return retVal;
-}
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -1185,24 +1185,24 @@ ifneq ($(XPI_NAME),)
 	$(NSINSTALL) -D $@
 
 export:: $(FINAL_TARGET)
 endif
 
 ifndef NO_DIST_INSTALL
 ifneq (,$(EXPORTS))
 export:: $(EXPORTS)
-	$(INSTALL) $(IFLAGS1) $^ $(DIST)/include
+	$(call install_cmd,$(IFLAGS1) $^ $(DIST)/include)
 endif
 endif # NO_DIST_INSTALL
 
 define EXPORT_NAMESPACE_RULE
 ifndef NO_DIST_INSTALL
 export:: $(EXPORTS_$(namespace))
-	$(INSTALL) $(IFLAGS1) $$^ $(DIST)/include/$(namespace)
+	$(call install_cmd,$(IFLAGS1) $$^ $(DIST)/include/$(namespace))
 endif # NO_DIST_INSTALL
 endef
 
 $(foreach namespace,$(EXPORTS_NAMESPACES),$(eval $(EXPORT_NAMESPACE_RULE)))
 
 ################################################################################
 # Copy each element of PREF_JS_EXPORTS
 
@@ -1241,17 +1241,17 @@ endif
 # Copy each element of AUTOCFG_JS_EXPORTS to $(FINAL_TARGET)/defaults/autoconfig
 
 ifneq ($(AUTOCFG_JS_EXPORTS),)
 $(FINAL_TARGET)/defaults/autoconfig::
 	$(NSINSTALL) -D $@
 
 ifndef NO_DIST_INSTALL
 export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_TARGET)/defaults/autoconfig
-	$(INSTALL) $(IFLAGS1) $^
+	$(call install_cmd,$(IFLAGS1) $^)
 endif
 
 endif
 
 ################################################################################
 # Export the elements of $(XPIDLSRCS)
 # generating .h and .xpt files and moving them to the appropriate places.
 
@@ -1307,17 +1307,17 @@ ifndef NO_GEN_XPT
 # no need to link together if XPIDLSRCS contains only XPIDL_MODULE
 ifneq ($(XPIDL_MODULE).idl,$(strip $(XPIDLSRCS)))
 $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS)) $(GLOBAL_DEPS)
 	$(XPIDL_LINK) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS))
 endif # XPIDL_MODULE.xpt != XPIDLSRCS
 
 libs:: $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt
 ifndef NO_DIST_INSTALL
-	$(INSTALL) $(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components
+	$(call install_cmd,$(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components)
 ifndef NO_INTERFACES_MANIFEST
 	@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/interfaces.manifest "interfaces $(XPIDL_MODULE).xpt"
 	@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/interfaces.manifest"
 endif
 endif
 
 endif # NO_GEN_XPT
 
@@ -1335,17 +1335,17 @@ endif
 $(IDL_DIR):
 	$(NSINSTALL) -D $@
 
 export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)
 
 ifneq ($(XPIDLSRCS),)
 ifndef NO_DIST_INSTALL
 export-idl:: $(XPIDLSRCS) $(IDL_DIR)
-	$(INSTALL) $(IFLAGS1) $^
+	$(call install_cmd,$(IFLAGS1) $^)
 endif
 endif
 	$(LOOP_OVER_PARALLEL_DIRS)
 	$(LOOP_OVER_DIRS)
 	$(LOOP_OVER_TOOL_DIRS)
 
 ################################################################################
 # Copy each element of EXTRA_COMPONENTS to $(FINAL_TARGET)/components
@@ -1355,17 +1355,17 @@ ifndef NO_JS_MANIFEST
 $(error .js component without matching .manifest. See https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0)
 endif
 endif
 endif
 
 ifdef EXTRA_COMPONENTS
 libs:: $(EXTRA_COMPONENTS)
 ifndef NO_DIST_INSTALL
-	$(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/components
+	$(call install_cmd,$(IFLAGS1) $^ $(FINAL_TARGET)/components)
 endif
 
 endif
 
 ifdef EXTRA_PP_COMPONENTS
 libs:: $(EXTRA_PP_COMPONENTS)
 ifndef NO_DIST_INSTALL
 	$(EXIT_ON_ERROR) \
@@ -1385,17 +1385,17 @@ libs::
 	$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest $(patsubst %,"manifest components/%",$(notdir $(EXTRA_MANIFESTS)))
 endif
 
 ################################################################################
 # Copy each element of EXTRA_JS_MODULES to $(FINAL_TARGET)/modules
 ifdef EXTRA_JS_MODULES
 libs:: $(EXTRA_JS_MODULES)
 ifndef NO_DIST_INSTALL
-	$(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/modules
+	$(call install_cmd,$(IFLAGS1) $^ $(FINAL_TARGET)/modules)
 endif
 
 endif
 
 ifdef EXTRA_PP_JS_MODULES
 libs:: $(EXTRA_PP_JS_MODULES)
 ifndef NO_DIST_INSTALL
 	$(EXIT_ON_ERROR) \
@@ -1418,42 +1418,42 @@ endif
 
 ifdef TESTING_JS_MODULES
 testmodulesdir = $(DEPTH)/_tests/modules/$(TESTING_JS_MODULE_DIR)
 
 GENERATED_DIRS += $(testmodulesdir)
 
 libs:: $(TESTING_JS_MODULES)
 ifndef NO_DIST_INSTALL
-	$(INSTALL) $(IFLAGS) $^ $(testmodulesdir)
+	$(call install_cmd,$(IFLAGS) $^ $(testmodulesdir))
 endif
 
 endif
 
 ################################################################################
 # SDK
 
 ifneq (,$(SDK_LIBRARY))
 $(SDK_LIB_DIR)::
 	$(NSINSTALL) -D $@
 
 ifndef NO_DIST_INSTALL
 libs:: $(SDK_LIBRARY) $(SDK_LIB_DIR)
-	$(INSTALL) $(IFLAGS2) $^
+	$(call install_cmd,$(IFLAGS2) $^)
 endif
 
 endif # SDK_LIBRARY
 
 ifneq (,$(strip $(SDK_BINARY)))
 $(SDK_BIN_DIR)::
 	$(NSINSTALL) -D $@
 
 ifndef NO_DIST_INSTALL
 libs:: $(SDK_BINARY) $(SDK_BIN_DIR)
-	$(INSTALL) $(IFLAGS2) $^
+	$(call install_cmd,$(IFLAGS2) $^)
 endif
 
 endif # SDK_BINARY
 
 ################################################################################
 # CHROME PACKAGING
 
 JAR_MANIFEST := $(srcdir)/jar.mn
--- a/config/tests/unit-nsinstall.py
+++ b/config/tests/unit-nsinstall.py
@@ -1,26 +1,42 @@
 import unittest
 
 import os, sys, os.path, time
 from tempfile import mkdtemp
 from shutil import rmtree
 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
+from mozprocess import processhandler
 
 from nsinstall import nsinstall
+import nsinstall as nsinstall_module
+NSINSTALL_PATH = nsinstall_module.__file__
+
+# Run the non-ASCII tests on (a) Windows, or (b) any platform with
+# sys.stdin.encoding set to UTF-8
+import codecs
+RUN_NON_ASCII_TESTS = (sys.platform == "win32" or
+                       (sys.stdin.encoding is not None and
+                        codecs.lookup(sys.stdin.encoding) == codecs.lookup("utf-8")))
 
 class TestNsinstall(unittest.TestCase):
     """
     Unit tests for nsinstall.py
     """
     def setUp(self):
         self.tmpdir = mkdtemp()
 
     def tearDown(self):
-        rmtree(self.tmpdir)
+        # Unicode strings means non-ASCII children can be deleted properly on
+        # Windows
+        if sys.stdin.encoding is None:
+            tmpdir = unicode(self.tmpdir)
+        else:
+            tmpdir = unicode(self.tmpdir, sys.stdin.encoding)
+        rmtree(tmpdir)
 
     # utility methods for tests
     def touch(self, file, dir=None):
         if dir is None:
             dir = self.tmpdir
         f = os.path.join(dir, file)
         open(f, 'w').close()
         return f
@@ -116,12 +132,42 @@ class TestNsinstall(unittest.TestCase):
         "Test that nsinstall -d works (create directories in target)"
         # -d makes no sense to me, but ok!
         testfile = self.touch("testfile")
         testdir = self.mkdirs("testdir")
         destdir = os.path.join(testdir, "subdir")
         self.assertEqual(nsinstall(["-d", testfile, destdir]), 0)
         self.assert_(os.path.isdir(os.path.join(destdir, "testfile")))
 
+    if RUN_NON_ASCII_TESTS:
+        def test_nsinstall_non_ascii(self):
+            "Test that nsinstall handles non-ASCII files"
+            filename = u"\u2325\u3452\u2415\u5081"
+            testfile = self.touch(filename)
+            testdir = self.mkdirs(u"\u4241\u1D04\u1414")
+            self.assertEqual(nsinstall([testfile.encode("utf-8"),
+                                        testdir.encode("utf-8")]), 0)
+
+            destfile = os.path.join(testdir, filename)
+            self.assert_(os.path.isfile(destfile))
+
+        def test_nsinstall_non_ascii_subprocess(self):
+            "Test that nsinstall as a subprocess handles non-ASCII files"
+            filename = u"\u2325\u3452\u2415\u5081"
+            testfile = self.touch(filename)
+            testdir = self.mkdirs(u"\u4241\u1D04\u1414")
+            # We don't use subprocess because it can't handle Unicode on
+            # Windows <http://bugs.python.org/issue1759845>. mozprocess calls
+            # CreateProcessW directly so it's perfect.
+            p = processhandler.ProcessHandlerMixin([sys.executable,
+                                                    NSINSTALL_PATH,
+                                                    testfile, testdir])
+            p.run()
+            rv = p.waitForFinish()
+
+            self.assertEqual(rv, 0)
+            destfile = os.path.join(testdir, filename)
+            self.assert_(os.path.isfile(destfile))
+
     #TODO: implement -R, -l, -L and test them!
 
 if __name__ == '__main__':
   unittest.main()
--- a/configure.in
+++ b/configure.in
@@ -5885,16 +5885,21 @@ if test -n "$MOZ_CRASHREPORTER"; then
     AC_SUBST(MOZ_GTHREAD_LIBS)
 
     MOZ_CHECK_HEADERS([curl/curl.h], [], [AC_MSG_ERROR([Couldn't find curl/curl.h which is required for the crash reporter.  Use --disable-crashreporter to disable the crash reporter.])])
   fi
 
   if (test "$OS_ARCH" != "$HOST_OS_ARCH"); then
     AC_MSG_ERROR([Breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.  Use --disable-crashreporter.])
   fi
+
+  if test "$OS_ARCH" == "WINNT" -a -z "$HAVE_64BIT_OS"; then
+    MOZ_CRASHREPORTER_INJECTOR=1
+    AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
+  fi
 fi
 
 MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
 [  --with-crashreporter-enable-percent=NN
                           Enable sending crash reports by default on NN% of users. (default=100)],
 [ val=`echo $withval | sed 's/[^0-9]//g'`
     MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"])
 
@@ -7433,16 +7438,22 @@ MOZ_ARG_ENABLE_BOOL(b2g-bt,
     MOZ_B2G_BT=1,
     MOZ_B2G_BT= )
 if test -n "$MOZ_B2G_BT"; then
    AC_DEFINE(MOZ_B2G_BT)
 fi
 AC_SUBST(MOZ_B2G_BT)
 
 dnl ========================================================
+dnl = Enable Support for System Messages API
+dnl ========================================================
+
+AC_SUBST(MOZ_SYS_MSG)
+
+dnl ========================================================
 dnl = Support for demangling undefined symbols
 dnl ========================================================
 if test -z "$SKIP_LIBRARY_CHECKS"; then
     AC_LANG_SAVE
     AC_LANG_CPLUSPLUS
     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
     AC_LANG_RESTORE
 fi
@@ -8348,16 +8359,17 @@ AC_SUBST(ENABLE_TESTS)
 AC_SUBST(ENABLE_MARIONETTE)
 AC_SUBST(IBMBIDI)
 AC_SUBST(MOZ_UNIVERSALCHARDET)
 AC_SUBST(ACCESSIBILITY)
 AC_SUBST(MOZ_SPELLCHECK)
 AC_SUBST(MOZ_JAVA_COMPOSITOR)
 AC_SUBST(MOZ_ONLY_TOUCH_EVENTS)
 AC_SUBST(MOZ_CRASHREPORTER)
+AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
 AC_SUBST(MOZ_MAINTENANCE_SERVICE)
 AC_SUBST(MOZ_VERIFY_MAR_SIGNATURE)
 AC_SUBST(MOZ_ENABLE_SIGNMAR)
 AC_SUBST(MOZ_UPDATER)
 AC_SUBST(MOZ_ANGLE)
 AC_SUBST(MOZ_DIRECTX_SDK_PATH)
 AC_SUBST(MOZ_DIRECTX_SDK_CPU_SUFFIX)
 AC_SUBST(MOZ_D3DX9_VERSION)
--- a/content/base/public/nsContentCreatorFunctions.h
+++ b/content/base/public/nsContentCreatorFunctions.h
@@ -12,17 +12,16 @@
 
 /**
  * Functions to create content, to be used only inside Gecko
  * (mozilla/content and mozilla/layout).
  */
 
 class nsAString;
 class nsIContent;
-class nsIDocument;
 class nsINodeInfo;
 class imgIRequest;
 class nsNodeInfoManager;
 class nsGenericHTMLElement;
 
 nsresult
 NS_NewElement(nsIContent** aResult,
               already_AddRefed<nsINodeInfo> aNodeInfo,
--- a/content/base/public/nsContentPolicyUtils.h
+++ b/content/base/public/nsContentPolicyUtils.h
@@ -120,24 +120,26 @@ NS_CP_ContentTypeName(PRUint32 contentTy
 #define CHECK_CONTENT_POLICY(action)                                          \
   PR_BEGIN_MACRO                                                              \
     nsCOMPtr<nsIContentPolicy> policy =                                       \
          do_GetService(NS_CONTENTPOLICY_CONTRACTID);                          \
     if (!policy)                                                              \
         return NS_ERROR_FAILURE;                                              \
                                                                               \
     return policy-> action (contentType, contentLocation, requestOrigin,      \
-                            context, mimeType, extra, decision);              \
+                            context, mimeType, extra, originPrincipal,        \
+                            decision);                                        \
   PR_END_MACRO
 
 /* Passes on parameters from its "caller"'s context. */
 #define CHECK_CONTENT_POLICY_WITH_SERVICE(action, _policy)                    \
   PR_BEGIN_MACRO                                                              \
     return _policy-> action (contentType, contentLocation, requestOrigin,     \
-                             context, mimeType, extra, decision);             \
+                             context, mimeType, extra, originPrincipal,       \
+                             decision);                                       \
   PR_END_MACRO
 
 /**
  * Check whether we can short-circuit this check and bail out.  If not, get the
  * origin URI to use.
  *
  * Note: requestOrigin is scoped outside the PR_BEGIN_MACRO/PR_END_MACRO on
  * purpose */
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -26,35 +26,26 @@ static fp_except_t allmask = FP_X_INV|FP
 #else
 static fp_except_t allmask = FP_X_INV|FP_X_OFL|FP_X_UFL|FP_X_DZ|FP_X_IMP|FP_X_DNML;
 #endif
 static fp_except_t oldmask = fpsetmask(~allmask);
 #endif
 
 #include "nsAString.h"
 #include "nsIStatefulFrame.h"
-#include "nsINodeInfo.h"
 #include "nsNodeInfoManager.h"
-#include "nsContentList.h"
 #include "nsDOMClassInfoID.h"
-#include "nsIXPCScriptable.h"
 #include "nsDataHashtable.h"
-#include "nsIScriptRuntime.h"
-#include "nsIScriptGlobalObject.h"
 #include "nsIDOMEvent.h"
 #include "nsTArray.h"
-#include "nsTextFragment.h"
 #include "nsReadableUtils.h"
 #include "nsINode.h"
-#include "nsHashtable.h"
 #include "nsIDOMNode.h"
 #include "nsHtml5StringParser.h"
-#include "nsIParser.h"
 #include "nsIDocument.h"
-#include "nsIFragmentContentSink.h"
 #include "nsContentSink.h"
 #include "nsMathUtils.h"
 #include "nsThreadUtils.h"
 #include "nsIContent.h"
 #include "nsCharSeparatedTokenizer.h"
 
 #include "mozilla/AutoRestore.h"
 #include "mozilla/GuardObjects.h"
@@ -65,19 +56,23 @@ struct nsNativeKeyEvent; // Don't includ
 class nsIDOMScriptObjectFactory;
 class nsIXPConnect;
 class nsIContent;
 class nsIDOMKeyEvent;
 class nsIDocument;
 class nsIDocumentObserver;
 class nsIDocShell;
 class nsINameSpaceManager;
+class nsIFragmentContentSink;
+class nsIScriptGlobalObject;
 class nsIScriptSecurityManager;
+class nsTextFragment;
 class nsIJSContextStack;
 class nsIThreadJSContextStack;
+class nsIParser;
 class nsIParserService;
 class nsIIOService;
 class nsIURI;
 class imgIContainer;
 class imgIDecoderObserver;
 class imgIRequest;
 class imgILoader;
 class imgICache;
@@ -90,16 +85,17 @@ class nsIStringBundle;
 class nsIContentPolicy;
 class nsILineBreaker;
 class nsIWordBreaker;
 class nsIJSRuntimeService;
 class nsEventListenerManager;
 class nsIScriptContext;
 class nsIRunnable;
 class nsIInterfaceRequestor;
+class nsINodeInfo;
 template<class E> class nsCOMArray;
 template<class K, class V> class nsRefPtrHashtable;
 struct JSRuntime;
 class nsIWidget;
 class nsIDragSession;
 class nsIPresShell;
 class nsIXPConnectJSObjectHolder;
 #ifdef MOZ_XTF
--- a/content/base/public/nsIContentPolicy.idl
+++ b/content/base/public/nsIContentPolicy.idl
@@ -1,29 +1,30 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ft=cpp tw=78 sw=2 et ts=8 : */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
+#include "nsIPrincipal.idl"
 
 interface nsIURI;
 interface nsIDOMNode;
 
 /**
  * Interface for content policy mechanism.  Implementations of this
  * interface can be used to control loading of various types of out-of-line
  * content, or processing of certain types of in-line content.
  *
  * WARNING: do not block the caller from shouldLoad or shouldProcess (e.g.,
  * by launching a dialog to prompt the user for something).
  */
 
-[scriptable,uuid(344f9cb0-9a17-44c5-ab96-ee707884266c)]
+[scriptable,uuid(e590e74f-bac7-4876-8c58-54dde92befb2)]
 interface nsIContentPolicy : nsISupports
 {
   const unsigned long TYPE_OTHER       = 1;
 
   /**
    * Indicates an executable script (such as JavaScript).
    */
   const unsigned long TYPE_SCRIPT      = 2;
@@ -204,17 +205,18 @@ interface nsIContentPolicy : nsISupports
    * up, content showing up doubled, etc.  If you need to do any of the things
    * above, do them off timeout or event.
    */
   short shouldLoad(in unsigned long aContentType,
                    in nsIURI        aContentLocation,
                    in nsIURI        aRequestOrigin,
                    in nsISupports   aContext,
                    in ACString      aMimeTypeGuess,
-                   in nsISupports   aExtra);
+                   in nsISupports   aExtra,
+                   [optional] in nsIPrincipal  aRequestPrincipal);
 
   /**
    * Should the resource be processed?
    * ShouldProcess will be called once all the information passed to it has
    * been determined about the resource, typically after part of the resource
    * has been loaded.
    *
    * @param aContentType      the type of content being tested. This will be one
@@ -246,11 +248,12 @@ interface nsIContentPolicy : nsISupports
    * involved is in an inconsistent state.  See the note on shouldLoad to see
    * what this means for implementors of this method.
    */
   short shouldProcess(in unsigned long aContentType,
                       in nsIURI        aContentLocation,
                       in nsIURI        aRequestOrigin,
                       in nsISupports   aContext,
                       in ACString      aMimeType,
-                      in nsISupports   aExtra);
+                      in nsISupports   aExtra,
+                      [optional] in nsIPrincipal  aRequestPrincipal);
 
 };
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -6,42 +6,42 @@
 #define nsIDocument_h___
 
 #include "nsINode.h"
 #include "nsStringGlue.h"
 #include "nsIDocumentObserver.h" // for nsUpdateType
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 #include "nsIURI.h"
-#include "nsWeakPtr.h"
-#include "nsIWeakReferenceUtils.h"
 #include "nsILoadGroup.h"
 #include "nsCRT.h"
 #include "mozFlushType.h"
 #include "nsIAtom.h"
 #include "nsCompatibility.h"
 #include "nsTObserverArray.h"
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 #include "nsNodeInfoManager.h"
-#include "nsIStreamListener.h"
 #include "nsIVariant.h"
 #include "nsIObserver.h"
 #include "nsGkAtoms.h"
 #include "nsAutoPtr.h"
 #include "nsPIDOMWindow.h"
 #include "nsSMILAnimationController.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIDocumentEncoder.h"
 #include "nsIFrameRequestCallback.h"
 #include "nsEventStates.h"
 #include "nsIStructuredCloneContainer.h"
-#include "nsIBFCacheEntry.h"
 #include "nsILoadContext.h"
 
+class nsIRequest;
+class nsPIDOMWindow;
+class nsIStreamListener;
+class nsIBFCacheEntry;
 class nsIContent;
 class nsPresContext;
 class nsIPresShell;
 class nsIDocShell;
 class nsStyleSet;
 class nsIStyleSheet;
 class nsIStyleRule;
 class nsCSSStyleSheet;
--- a/content/base/public/nsIStyleSheetLinkingElement.h
+++ b/content/base/public/nsIStyleSheetLinkingElement.h
@@ -3,17 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef nsIStyleSheetLinkingElement_h__
 #define nsIStyleSheetLinkingElement_h__
 
 
 #include "nsISupports.h"
 
-class nsIDocument;
 class nsICSSLoaderObserver;
 class nsIURI;
 
 #define NS_ISTYLESHEETLINKINGELEMENT_IID          \
 { 0xd753c84a, 0x17fd, 0x4d5f, \
  { 0xb2, 0xe9, 0x63, 0x52, 0x8c, 0x87, 0x99, 0x7a } }
 
 class nsIStyleSheet;
--- a/content/base/src/Link.cpp
+++ b/content/base/src/Link.cpp
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "Link.h"
 
 #include "nsEventStates.h"
 #include "nsIURL.h"
 #include "nsISizeOf.h"
 
-#include "nsContentUtils.h"
 #include "nsEscape.h"
 #include "nsGkAtoms.h"
 #include "nsString.h"
 #include "mozAutoDocUpdate.h"
 
 #include "mozilla/Services.h"
 
 namespace mozilla {
--- a/content/base/src/nsAttrValue.cpp
+++ b/content/base/src/nsAttrValue.cpp
@@ -8,18 +8,16 @@
  * attribute.
  */
 
 #include "nsAttrValue.h"
 #include "nsIAtom.h"
 #include "nsUnicharUtils.h"
 #include "mozilla/css/StyleRule.h"
 #include "mozilla/css/Declaration.h"
-#include "nsIHTMLDocument.h"
-#include "nsIDocument.h"
 #include "nsContentUtils.h"
 #include "nsReadableUtils.h"
 #include "prprf.h"
 #include "mozilla/HashFunctions.h"
 
 using namespace mozilla;
 
 #define MISC_STR_PTR(_cont) \
--- a/content/base/src/nsAttrValue.h
+++ b/content/base/src/nsAttrValue.h
@@ -18,17 +18,16 @@
 #include "nsCaseTreatment.h"
 #include "nsMargin.h"
 #include "nsCOMPtr.h"
 #include "SVGAttrValueWrapper.h"
 
 typedef PRUptrdiff PtrBits;
 class nsAString;
 class nsIAtom;
-class nsIDocument;
 template<class E, class A> class nsTArray;
 struct nsTArrayDefaultAllocator;
 
 namespace mozilla {
 namespace css {
 class StyleRule;
 }
 }
--- a/content/base/src/nsCCUncollectableMarker.cpp
+++ b/content/base/src/nsCCUncollectableMarker.cpp
@@ -3,17 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsCCUncollectableMarker.h"
 #include "nsIObserverService.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsServiceManagerUtils.h"
-#include "nsIDOMDocument.h"
 #include "nsIContentViewer.h"
 #include "nsIDocument.h"
 #include "nsIWindowMediator.h"
 #include "nsPIDOMWindow.h"
 #include "nsIWebNavigation.h"
 #include "nsISHistory.h"
 #include "nsISHEntry.h"
 #include "nsISHContainer.h"
--- a/content/base/src/nsCSPService.cpp
+++ b/content/base/src/nsCSPService.cpp
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "prlog.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsIURI.h"
 #include "nsIPrincipal.h"
 #include "nsIObserver.h"
-#include "nsIDocument.h"
 #include "nsIContent.h"
 #include "nsCSPService.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsIChannelPolicy.h"
 #include "nsIChannelEventSink.h"
 #include "nsIPropertyBag2.h"
 #include "nsIWritablePropertyBag2.h"
 #include "nsNetError.h"
@@ -53,16 +52,17 @@ NS_IMPL_ISUPPORTS2(CSPService, nsIConten
 /* nsIContentPolicy implementation */
 NS_IMETHODIMP
 CSPService::ShouldLoad(PRUint32 aContentType,
                        nsIURI *aContentLocation,
                        nsIURI *aRequestOrigin,
                        nsISupports *aRequestContext,
                        const nsACString &aMimeTypeGuess,
                        nsISupports *aExtra,
+                       nsIPrincipal *aRequestPrincipal,
                        PRInt16 *aDecision)
 {
     if (!aContentLocation)
         return NS_ERROR_FAILURE;
 
 #ifdef PR_LOGGING
     {
         nsCAutoString location;
@@ -119,16 +119,17 @@ CSPService::ShouldLoad(PRUint32 aContent
 
 NS_IMETHODIMP
 CSPService::ShouldProcess(PRUint32         aContentType,
                           nsIURI           *aContentLocation,
                           nsIURI           *aRequestOrigin,
                           nsISupports      *aRequestContext,
                           const nsACString &aMimeTypeGuess,
                           nsISupports      *aExtra,
+                          nsIPrincipal     *aRequestPrincipal,
                           PRInt16          *aDecision)
 {
     if (!aContentLocation)
         return NS_ERROR_FAILURE;
 
     // default decision is to accept the item
     *aDecision = nsIContentPolicy::ACCEPT;
 
--- a/content/base/src/nsCommentNode.cpp
+++ b/content/base/src/nsCommentNode.cpp
@@ -6,17 +6,16 @@
 /*
  * Implementations of DOM Core's nsIDOMComment node.
  */
 
 #include "nsIDOMComment.h"
 #include "nsGenericDOMDataNode.h"
 
 #include "nsCOMPtr.h"
-#include "nsIDocument.h"
 #include "nsGenericElement.h" // DOMCI_NODE_DATA
 
 class nsCommentNode : public nsGenericDOMDataNode,
                       public nsIDOMComment
 {
 public:
   nsCommentNode(already_AddRefed<nsINodeInfo> aNodeInfo);
   virtual ~nsCommentNode();
--- a/content/base/src/nsContentAreaDragDrop.h
+++ b/content/base/src/nsContentAreaDragDrop.h
@@ -10,17 +10,16 @@
 #include "nsCOMPtr.h"
 
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMEventListener.h"
 #include "nsITransferable.h"
 
 class nsIDOMNode;
 class nsIDOMWindow;
-class nsIDOMDocument;
 class nsIDOMDragEvent;
 class nsISelection;
 class nsITransferable;
 class nsIContent;
 class nsIURI;
 class nsIFile;
 class nsISimpleEnumerator;
 class nsDOMDataTransfer;
--- a/content/base/src/nsContentList.h
+++ b/content/base/src/nsContentList.h
@@ -36,17 +36,16 @@
 // was passed to the list's constructor.
 typedef bool (*nsContentListMatchFunc)(nsIContent* aContent,
                                          PRInt32 aNamespaceID,
                                          nsIAtom* aAtom,
                                          void* aData);
 
 typedef void (*nsContentListDestroyFunc)(void* aData);
 
-class nsIDocument;
 namespace mozilla {
 namespace dom {
 class Element;
 }
 }
 
 
 class nsBaseContentList : public nsINodeList
--- a/content/base/src/nsContentPolicy.cpp
+++ b/content/base/src/nsContentPolicy.cpp
@@ -71,16 +71,17 @@ nsContentPolicy::~nsContentPolicy()
 inline nsresult
 nsContentPolicy::CheckPolicy(CPMethod          policyMethod,
                              PRUint32          contentType,
                              nsIURI           *contentLocation,
                              nsIURI           *requestingLocation,
                              nsISupports      *requestingContext,
                              const nsACString &mimeType,
                              nsISupports      *extra,
+                             nsIPrincipal     *requestPrincipal,
                              PRInt16           *decision)
 {
     //sanity-check passed-through parameters
     NS_PRECONDITION(decision, "Null out pointer");
     WARN_IF_URI_UNINITIALIZED(contentLocation, "Request URI");
     WARN_IF_URI_UNINITIALIZED(requestingLocation, "Requesting URI");
 
 #ifdef DEBUG
@@ -117,17 +118,18 @@ nsContentPolicy::CheckPolicy(CPMethod   
      */
     nsresult rv;
     const nsCOMArray<nsIContentPolicy>& entries = mPolicies.GetEntries();
     PRInt32 count = entries.Count();
     for (PRInt32 i = 0; i < count; i++) {
         /* check the appropriate policy */
         rv = (entries[i]->*policyMethod)(contentType, contentLocation,
                                          requestingLocation, requestingContext,
-                                         mimeType, extra, decision);
+                                         mimeType, extra, requestPrincipal,
+                                         decision);
 
         if (NS_SUCCEEDED(rv) && NS_CP_REJECTED(*decision)) {
             /* policy says no, no point continuing to check */
             return NS_OK;
         }
     }
 
     // everyone returned failure, or no policies: sanitize result
@@ -172,36 +174,40 @@ nsContentPolicy::CheckPolicy(CPMethod   
 
 NS_IMETHODIMP
 nsContentPolicy::ShouldLoad(PRUint32          contentType,
                             nsIURI           *contentLocation,
                             nsIURI           *requestingLocation,
                             nsISupports      *requestingContext,
                             const nsACString &mimeType,
                             nsISupports      *extra,
+                            nsIPrincipal     *requestPrincipal,
                             PRInt16          *decision)
 {
     // ShouldProcess does not need a content location, but we do
     NS_PRECONDITION(contentLocation, "Must provide request location");
     nsresult rv = CheckPolicy(&nsIContentPolicy::ShouldLoad, contentType,
                               contentLocation, requestingLocation,
-                              requestingContext, mimeType, extra, decision);
+                              requestingContext, mimeType, extra,
+                              requestPrincipal, decision);
     LOG_CHECK("ShouldLoad");
 
     return rv;
 }
 
 NS_IMETHODIMP
 nsContentPolicy::ShouldProcess(PRUint32          contentType,
                                nsIURI           *contentLocation,
                                nsIURI           *requestingLocation,
                                nsISupports      *requestingContext,
                                const nsACString &mimeType,
                                nsISupports      *extra,
+                               nsIPrincipal     *requestPrincipal,
                                PRInt16          *decision)
 {
     nsresult rv = CheckPolicy(&nsIContentPolicy::ShouldProcess, contentType,
                               contentLocation, requestingLocation,
-                              requestingContext, mimeType, extra, decision);
+                              requestingContext, mimeType, extra,
+                              requestPrincipal, decision);
     LOG_CHECK("ShouldProcess");
 
     return rv;
 }
--- a/content/base/src/nsContentPolicy.h
+++ b/content/base/src/nsContentPolicy.h
@@ -26,23 +26,25 @@ class nsContentPolicy : public nsIConten
     //Array of policies
     nsCategoryCache<nsIContentPolicy> mPolicies;
 
     //Helper type for CheckPolicy
     typedef
     NS_STDCALL_FUNCPROTO(nsresult, CPMethod, nsIContentPolicy,
                          ShouldProcess,
                          (PRUint32, nsIURI*, nsIURI*, nsISupports*,
-                           const nsACString &, nsISupports*, PRInt16*));
+                           const nsACString &, nsISupports*, nsIPrincipal*,
+                           PRInt16*));
 
     //Helper method that applies policyMethod across all policies in mPolicies
     // with the given parameters
     nsresult CheckPolicy(CPMethod policyMethod, PRUint32 contentType,
                          nsIURI *aURI, nsIURI *origURI,
                          nsISupports *requestingContext,
                          const nsACString &mimeGuess, nsISupports *extra,
+                         nsIPrincipal *requestPrincipal,
                          PRInt16 *decision);
 };
 
 nsresult
 NS_NewContentPolicy(nsIContentPolicy **aResult);
 
 #endif /* __nsContentPolicy_h__ */
--- a/content/base/src/nsContentSink.cpp
+++ b/content/base/src/nsContentSink.cpp
@@ -9,70 +9,49 @@
  * DOM based on information from the parser.
  */
 
 #include "nsContentSink.h"
 #include "nsScriptLoader.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "mozilla/css/Loader.h"
-#include "nsStyleConsts.h"
 #include "nsStyleLinkElement.h"
-#include "nsINodeInfo.h"
 #include "nsIDocShell.h"
 #include "nsILoadContext.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsCPrefetchService.h"
 #include "nsIURI.h"
 #include "nsNetUtil.h"
 #include "nsIHttpChannel.h"
 #include "nsIContent.h"
-#include "nsIScriptElement.h"
-#include "nsContentErrors.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsIViewManager.h"
-#include "nsIContentViewer.h"
 #include "nsIAtom.h"
 #include "nsGkAtoms.h"
 #include "nsIDOMWindow.h"
-#include "nsIPrincipal.h"
-#include "nsIScriptGlobalObject.h"
 #include "nsNetCID.h"
 #include "nsIOfflineCacheUpdate.h"
 #include "nsIApplicationCache.h"
 #include "nsIApplicationCacheContainer.h"
 #include "nsIApplicationCacheChannel.h"
 #include "nsIScriptSecurityManager.h"
-#include "nsIDOMLoadStatus.h"
 #include "nsICookieService.h"
 #include "nsIPrompt.h"
-#include "nsServiceManagerUtils.h"
 #include "nsContentUtils.h"
-#include "nsCRT.h"
-#include "nsEscape.h"
-#include "nsWeakReference.h"
-#include "nsUnicharUtils.h"
 #include "nsNodeInfoManager.h"
 #include "nsIAppShell.h"
 #include "nsIWidget.h"
 #include "nsWidgetsCID.h"
-#include "nsIRequest.h"
-#include "nsNodeUtils.h"
 #include "nsIDOMNode.h"
-#include "nsThreadUtils.h"
-#include "nsPIDOMWindow.h"
 #include "mozAutoDocUpdate.h"
 #include "nsIWebNavigation.h"
-#include "nsIDocumentLoader.h"
-#include "nsICachingChannel.h"
-#include "nsICacheEntryDescriptor.h"
 #include "nsGenericHTMLElement.h"
 #include "nsHTMLDNSPrefetch.h"
-#include "nsISupportsPrimitives.h"
 #include "nsIObserverService.h"
 #include "mozilla/Preferences.h"
 #include "nsParserConstants.h"
 
 using namespace mozilla;
 
 PRLogModuleInfo* gContentSinkLogModuleInfo;
 
--- a/content/base/src/nsContentSink.h
+++ b/content/base/src/nsContentSink.h
@@ -11,32 +11,25 @@
 #ifndef _nsContentSink_h_
 #define _nsContentSink_h_
 
 // Base class for contentsink implementations.
 
 #include "nsICSSLoaderObserver.h"
 #include "nsWeakReference.h"
 #include "nsCOMPtr.h"
-#include "nsCOMArray.h"
 #include "nsString.h"
 #include "nsAutoPtr.h"
 #include "nsGkAtoms.h"
-#include "nsTHashtable.h"
-#include "nsHashKeys.h"
-#include "nsTArray.h"
 #include "nsITimer.h"
 #include "nsStubDocumentObserver.h"
-#include "nsIParserService.h"
 #include "nsIContentSink.h"
 #include "prlog.h"
-#include "nsIRequest.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsThreadUtils.h"
-#include "nsIScriptElement.h"
 
 class nsIDocument;
 class nsIURI;
 class nsIChannel;
 class nsIDocShell;
 class nsIParser;
 class nsIAtom;
 class nsIChannel;
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -11,61 +11,48 @@
 #include "jsapi.h"
 #include "jsdbgapi.h"
 #include "jsfriendapi.h"
 
 #include "nsJSUtils.h"
 #include "nsCOMPtr.h"
 #include "nsAString.h"
 #include "nsPrintfCString.h"
-#include "nsUnicharUtils.h"
-#include "nsServiceManagerUtils.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptContext.h"
-#include "nsIDOMScriptObjectFactory.h"
 #include "nsDOMCID.h"
 #include "nsContentUtils.h"
 #include "nsIXPConnect.h"
 #include "nsIContent.h"
 #include "mozilla/dom/Element.h"
 #include "nsIDocument.h"
 #include "nsINodeInfo.h"
-#include "nsReadableUtils.h"
 #include "nsIIdleService.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMNode.h"
 #include "nsIIOService.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 #include "nsIScriptSecurityManager.h"
-#include "nsDOMError.h"
 #include "nsPIDOMWindow.h"
 #include "nsIJSContextStack.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsParserCIID.h"
 #include "nsIParser.h"
 #include "nsIFragmentContentSink.h"
 #include "nsIContentSink.h"
-#include "nsIHTMLContentSink.h"
-#include "nsIXMLContentSink.h"
-#include "nsHTMLParts.h"
-#include "nsIServiceManager.h"
-#include "nsIAttribute.h"
 #include "nsContentList.h"
 #include "nsIHTMLDocument.h"
-#include "nsIDOMHTMLDocument.h"
-#include "nsIDOMHTMLCollection.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIForm.h"
 #include "nsIFormControl.h"
 #include "nsGkAtoms.h"
-#include "nsISupportsPrimitives.h"
 #include "imgIDecoderObserver.h"
 #include "imgIRequest.h"
 #include "imgIContainer.h"
 #include "imgILoader.h"
 #include "nsDocShellCID.h"
 #include "nsIImageLoadingContent.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
@@ -83,71 +70,61 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_
 #endif
 #include "nsIMIMEService.h"
 #include "nsLWBrkCIID.h"
 #include "nsILineBreaker.h"
 #include "nsIWordBreaker.h"
 #include "nsUnicodeProperties.h"
 #include "harfbuzz/hb.h"
 #include "nsIJSRuntimeService.h"
-#include "nsIDOMDocumentXBL.h"
 #include "nsBindingManager.h"
 #include "nsIURI.h"
 #include "nsIURL.h"
-#include "nsXBLBinding.h"
-#include "nsXBLPrototypeBinding.h"
-#include "nsEscape.h"
 #include "nsICharsetConverterManager.h"
 #include "nsEventListenerManager.h"
 #include "nsAttrName.h"
 #include "nsIDOMUserDataHandler.h"
 #include "nsContentCreatorFunctions.h"
-#include "nsGUIEvent.h"
 #include "nsMutationEvent.h"
 #include "nsIMEStateManager.h"
 #include "nsContentErrors.h"
 #include "nsUnicharUtilCIID.h"
 #include "nsINativeKeyBindings.h"
 #include "nsIDOMNSEvent.h"
 #include "nsXULPopupManager.h"
 #include "nsIPermissionManager.h"
-#include "nsIContentPrefService.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsNullPrincipal.h"
 #include "nsIRunnable.h"
 #include "nsDOMJSUtils.h"
 #include "nsGenericHTMLElement.h"
 #include "nsAttrValue.h"
 #include "nsReferencedElement.h"
 #include "nsIDragService.h"
 #include "nsIChannelEventSink.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsIOfflineCacheUpdate.h"
 #include "nsCPrefetchService.h"
 #include "nsIChromeRegistry.h"
 #include "nsEventDispatcher.h"
-#include "nsIMIMEHeaderParam.h"
 #include "nsIDOMXULCommandEvent.h"
-#include "nsIDOMDragEvent.h"
 #include "nsDOMDataTransfer.h"
 #include "nsHtml5Module.h"
 #include "nsPresContext.h"
 #include "nsLayoutStatics.h"
-#include "nsLayoutUtils.h"
-#include "nsFrameManager.h"
-#include "BasicLayers.h"
 #include "nsFocusManager.h"
 #include "nsTextEditorState.h"
 #include "nsIPluginHost.h"
 #include "nsICategoryManager.h"
 #include "nsIViewManager.h"
 #include "nsEventStateManager.h"
 #include "nsIDOMHTMLInputElement.h"
 #include "nsParserConstants.h"
 #include "nsIWebNavigation.h"
+#include "nsTextFragment.h"
 #include "mozilla/Selection.h"
 
 #ifdef IBMBIDI
 #include "nsIBidiKeyboard.h"
 #endif
 #include "nsCycleCollectionParticipant.h"
 
 // for ReportToConsole
@@ -162,31 +139,32 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_
 #include "nsIChannelPolicy.h"
 #include "nsChannelPolicy.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsContentDLF.h"
 #ifdef MOZ_MEDIA
 #include "nsHTMLMediaElement.h"
 #endif
 #include "nsDOMTouchEvent.h"
-#include "nsIScriptElement.h"
 #include "nsIContentViewer.h"
 #include "nsIObjectLoadingContent.h"
 #include "nsCCUncollectableMarker.h"
 #include "mozilla/Base64.h"
 #include "mozilla/Preferences.h"
 #include "nsDOMMutationObserver.h"
 #include "nsIDOMDocumentType.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsICharsetDetector.h"
 #include "nsICharsetDetectionObserver.h"
 #include "nsIPlatformCharset.h"
 #include "nsIEditor.h"
 #include "nsIEditorDocShell.h"
 #include "mozilla/Attributes.h"
+#include "nsIParserService.h"
+#include "nsIDOMScriptObjectFactory.h"
 
 #include "nsWrapperCacheInlines.h"
 
 extern "C" int MOZ_XMLTranslateEntity(const char* ptr, const char* end,
                                       const char** next, PRUnichar* result);
 extern "C" int MOZ_XMLCheckQName(const char* ptr, const char* end,
                                  int ns_aware, const char** colon);
 
--- a/content/base/src/nsDOMAttributeMap.cpp
+++ b/content/base/src/nsDOMAttributeMap.cpp
@@ -6,17 +6,16 @@
 /*
  * Implementation of the |attributes| property of DOM Core's nsIDOMNode object.
  */
 
 #include "nsDOMAttributeMap.h"
 #include "nsDOMAttribute.h"
 #include "nsIDOMDocument.h"
 #include "nsGenericElement.h"
-#include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsINameSpaceManager.h"
 #include "nsDOMError.h"
 #include "nsContentUtils.h"
 #include "nsNodeInfoManager.h"
 #include "nsAttrName.h"
 #include "nsUnicharUtils.h"
 
--- a/content/base/src/nsDOMAttributeMap.h
+++ b/content/base/src/nsDOMAttributeMap.h
@@ -12,17 +12,16 @@
 
 #include "nsIDOMNamedNodeMap.h"
 #include "nsString.h"
 #include "nsRefPtrHashtable.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIDOMNode.h"
 
 class nsIAtom;
-class nsIContent;
 class nsDOMAttribute;
 class nsINodeInfo;
 class nsIDocument;
 
 namespace mozilla {
 namespace dom {
 class Element;
 } // namespace dom
--- a/content/base/src/nsDOMDocumentType.cpp
+++ b/content/base/src/nsDOMDocumentType.cpp
@@ -7,22 +7,19 @@
  * Implementation of DOM Core's nsIDOMDocumentType node.
  */
 
 #include "nsDOMDocumentType.h"
 #include "nsDOMAttributeMap.h"
 #include "nsIDOMNamedNodeMap.h"
 #include "nsGkAtoms.h"
 #include "nsCOMPtr.h"
-#include "nsContentUtils.h"
 #include "nsDOMString.h"
 #include "nsNodeInfoManager.h"
-#include "nsIDocument.h"
 #include "nsIXPConnect.h"
-#include "nsIDOMDocument.h"
 #include "xpcpublic.h"
 #include "nsWrapperCacheInlines.h"
 
 nsresult
 NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
                       nsNodeInfoManager *aNodeInfoManager,
                       nsIAtom *aName,
                       const nsAString& aPublicId,
--- a/content/base/src/nsDOMFile.cpp
+++ b/content/base/src/nsDOMFile.cpp
@@ -9,17 +9,16 @@
 #include "nsContentCID.h"
 #include "nsContentUtils.h"
 #include "nsDOMClassInfoID.h"
 #include "nsDOMError.h"
 #include "nsICharsetDetector.h"
 #include "nsICharsetConverterManager.h"
 #include "nsIConverterInputStream.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsIFileStreams.h"
 #include "nsIInputStream.h"
 #include "nsIIPCSerializable.h"
 #include "nsIMIMEService.h"
 #include "nsIPlatformCharset.h"
 #include "nsISeekableStream.h"
 #include "nsIUnicharInputStream.h"
 #include "nsIUnicodeDecoder.h"
--- a/content/base/src/nsDOMLists.cpp
+++ b/content/base/src/nsDOMLists.cpp
@@ -5,17 +5,16 @@
 
 /*
  * Implementation of nsIDOMDOMStringList, used by various DOM stuff.
  */
 
 #include "nsDOMLists.h"
 #include "nsDOMError.h"
 #include "nsDOMClassInfoID.h"
-#include "nsContentUtils.h"
 #include "nsINode.h"
 
 nsDOMStringList::nsDOMStringList()
 {
 }
 
 nsDOMStringList::~nsDOMStringList()
 {
--- a/content/base/src/nsDOMSerializer.cpp
+++ b/content/base/src/nsDOMSerializer.cpp
@@ -2,23 +2,20 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsDOMSerializer.h"
 #include "nsIDOMNode.h"
 #include "nsDOMClassInfoID.h"
 #include "nsIOutputStream.h"
-#include "nsINode.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDocumentEncoder.h"
-#include "nsIContentSerializer.h"
 #include "nsString.h"
-#include "nsReadableUtils.h"
 #include "nsContentCID.h"
 #include "nsContentUtils.h"
 #include "nsDOMError.h"
 
 nsDOMSerializer::nsDOMSerializer()
 {
 }
 
--- a/content/base/src/nsDataDocumentContentPolicy.cpp
+++ b/content/base/src/nsDataDocumentContentPolicy.cpp
@@ -32,16 +32,17 @@ HasFlags(nsIURI* aURI, PRUint32 aURIFlag
 
 NS_IMETHODIMP
 nsDataDocumentContentPolicy::ShouldLoad(PRUint32 aContentType,
                                         nsIURI *aContentLocation,
                                         nsIURI *aRequestingLocation,
                                         nsISupports *aRequestingContext,
                                         const nsACString &aMimeGuess,
                                         nsISupports *aExtra,
+                                        nsIPrincipal *aRequestPrincipal,
                                         PRInt16 *aDecision)
 {
   *aDecision = nsIContentPolicy::ACCEPT;
   // Look for the document.  In most cases, aRequestingContext is a node.
   nsCOMPtr<nsIDocument> doc;
   nsCOMPtr<nsINode> node = do_QueryInterface(aRequestingContext);
   if (node) {
     doc = node->OwnerDoc();
@@ -124,13 +125,15 @@ nsDataDocumentContentPolicy::ShouldLoad(
 
 NS_IMETHODIMP
 nsDataDocumentContentPolicy::ShouldProcess(PRUint32 aContentType,
                                            nsIURI *aContentLocation,
                                            nsIURI *aRequestingLocation,
                                            nsISupports *aRequestingContext,
                                            const nsACString &aMimeGuess,
                                            nsISupports *aExtra,
+                                           nsIPrincipal *aRequestPrincipal,
                                            PRInt16 *aDecision)
 {
   return ShouldLoad(aContentType, aContentLocation, aRequestingLocation,
-                    aRequestingContext, aMimeGuess, aExtra, aDecision);
+                    aRequestingContext, aMimeGuess, aExtra, aRequestPrincipal,
+                    aDecision);
 }
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -155,17 +155,16 @@
 
 // FOR CSP (autogenerated by xpidl)
 #include "nsIContentSecurityPolicy.h"
 #include "nsCSPService.h"
 #include "nsHTMLStyleSheet.h"
 #include "nsHTMLCSSStyleSheet.h"
 
 #include "mozilla/dom/Link.h"
-#include "nsIHTMLDocument.h"
 #include "nsXULAppAPI.h"
 #include "nsDOMTouchEvent.h"
 
 #include "mozilla/Preferences.h"
 
 #include "imgILoader.h"
 #include "nsWrapperCacheInlines.h"
 
--- a/content/base/src/nsDocumentFragment.cpp
+++ b/content/base/src/nsDocumentFragment.cpp
@@ -9,23 +9,19 @@
 
 #include "nsISupports.h"
 #include "nsIContent.h"
 #include "nsIDOMDocumentFragment.h"
 #include "nsGenericElement.h"
 #include "nsINameSpaceManager.h"
 #include "nsINodeInfo.h"
 #include "nsNodeInfoManager.h"
-#include "nsIDocument.h"
-#include "nsIDOMDocument.h"
-#include "nsIDOMAttr.h"
 #include "nsDOMError.h"
 #include "nsGkAtoms.h"
 #include "nsDOMString.h"
-#include "nsIDOMUserDataHandler.h"
 #include "nsContentUtils.h"
 
 class nsDocumentFragment : public nsGenericElement,
                            public nsIDOMDocumentFragment
 {
 public:
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
--- a/content/base/src/nsHTMLContentSerializer.cpp
+++ b/content/base/src/nsHTMLContentSerializer.cpp
@@ -10,17 +10,16 @@
  * string that could be parsed into more or less the original DOM.
  */
 
 #include "nsHTMLContentSerializer.h"
 
 #include "nsIDOMElement.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsINameSpaceManager.h"
 #include "nsString.h"
 #include "nsUnicharUtils.h"
 #include "nsXPIDLString.h"
 #include "nsIServiceManager.h"
 #include "nsIDocumentEncoder.h"
 #include "nsGkAtoms.h"
 #include "nsIURI.h"
--- a/content/base/src/nsNoDataProtocolContentPolicy.cpp
+++ b/content/base/src/nsNoDataProtocolContentPolicy.cpp
@@ -5,36 +5,33 @@
 
 /*
  * Content policy implementation that prevents all loads of images,
  * subframes, etc from protocols that don't return data but rather open
  * applications (such as mailto).
  */
 
 #include "nsNoDataProtocolContentPolicy.h"
-#include "nsIDocument.h"
-#include "nsINode.h"
 #include "nsIDOMWindow.h"
-#include "nsIDOMDocument.h"
 #include "nsString.h"
-#include "nsContentUtils.h"
 #include "nsIProtocolHandler.h"
 #include "nsIIOService.h"
 #include "nsIExternalProtocolHandler.h"
 #include "nsNetUtil.h"
 
 NS_IMPL_ISUPPORTS1(nsNoDataProtocolContentPolicy, nsIContentPolicy)
 
 NS_IMETHODIMP
 nsNoDataProtocolContentPolicy::ShouldLoad(PRUint32 aContentType,
                                           nsIURI *aContentLocation,
                                           nsIURI *aRequestingLocation,
                                           nsISupports *aRequestingContext,
                                           const nsACString &aMimeGuess,
                                           nsISupports *aExtra,
+                                          nsIPrincipal *aRequestPrincipal,
                                           PRInt16 *aDecision)
 {
   *aDecision = nsIContentPolicy::ACCEPT;
 
   // Don't block for TYPE_OBJECT since such URIs are sometimes loaded by the
   // plugin, so they don't necessarily open external apps
   // TYPE_WEBSOCKET loads can only go to ws:// or wss://, so we don't need to
   // concern ourselves with them.
@@ -69,13 +66,15 @@ nsNoDataProtocolContentPolicy::ShouldLoa
 
 NS_IMETHODIMP
 nsNoDataProtocolContentPolicy::ShouldProcess(PRUint32 aContentType,
                                              nsIURI *aContentLocation,
                                              nsIURI *aRequestingLocation,
                                              nsISupports *aRequestingContext,
                                              const nsACString &aMimeGuess,
                                              nsISupports *aExtra,
+                                             nsIPrincipal *aRequestPrincipal,
                                              PRInt16 *aDecision)
 {
   return ShouldLoad(aContentType, aContentLocation, aRequestingLocation,
-                    aRequestingContext, aMimeGuess, aExtra, aDecision);
+                    aRequestingContext, aMimeGuess, aExtra, aRequestPrincipal,
+                    aDecision);
 }
--- a/content/base/src/nsRange.h
+++ b/content/base/src/nsRange.h
@@ -8,17 +8,17 @@
  */
 
 #ifndef nsRange_h___
 #define nsRange_h___
 
 #include "nsIDOMRange.h"
 #include "nsCOMPtr.h"
 #include "nsIDOMDocumentFragment.h"
-#include "nsIContent.h"
+#include "nsINode.h"
 #include "nsIDOMNode.h"
 #include "prmon.h"
 #include "nsStubMutationObserver.h"
 
 class nsRange : public nsIDOMRange,
                 public nsStubMutationObserver
 {
 public:
--- a/content/base/src/nsReferencedElement.cpp
+++ b/content/base/src/nsReferencedElement.cpp
@@ -6,17 +6,16 @@
 
 #include "nsReferencedElement.h"
 #include "nsContentUtils.h"
 #include "nsIURI.h"
 #include "nsBindingManager.h"
 #include "nsEscape.h"
 #include "nsXBLPrototypeBinding.h"
 #include "nsIDOMNode.h"
-#include "nsIDOMDocument.h"
 #include "nsIDOMElement.h"
 #include "nsCycleCollectionParticipant.h"
 
 void
 nsReferencedElement::Reset(nsIContent* aFromContent, nsIURI* aURI,
                            bool aWatch, bool aReferenceImage)
 {
   NS_ABORT_IF_FALSE(aFromContent, "Reset() expects non-null content pointer");
--- a/content/base/src/nsSyncLoadService.cpp
+++ b/content/base/src/nsSyncLoadService.cpp
@@ -12,17 +12,17 @@
 #include "nsIChannel.h"
 #include "nsIChannelEventSink.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsString.h"
 #include "nsWeakReference.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
-#include "nsIScriptSecurityManager.h"
+#include "nsIPrincipal.h"
 #include "nsContentUtils.h"
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
 #include "nsAutoPtr.h"
 #include "nsStreamUtils.h"
 #include "nsCrossSiteListenerProxy.h"
 
 /**
--- a/content/base/src/nsTraversal.cpp
+++ b/content/base/src/nsTraversal.cpp
@@ -4,18 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsTraversal.h"
 
 #include "nsIDOMNode.h"
 #include "nsIDOMNodeFilter.h"
 #include "nsDOMError.h"
-
-#include "nsIContent.h"
+#include "nsINode.h"
 
 #include "nsGkAtoms.h"
 
 nsTraversal::nsTraversal(nsINode *aRoot,
                          PRUint32 aWhatToShow,
                          nsIDOMNodeFilter *aFilter) :
     mRoot(aRoot),
     mWhatToShow(aWhatToShow),
--- a/content/base/src/nsTreeWalker.cpp
+++ b/content/base/src/nsTreeWalker.cpp
@@ -9,17 +9,16 @@
  */
 
 #include "nsTreeWalker.h"
 
 #include "nsIDOMNode.h"
 #include "nsIDOMNodeFilter.h"
 #include "nsDOMError.h"
 #include "nsINode.h"
-#include "nsIContent.h"
 
 #include "nsContentUtils.h"
 
 /*
  * Factories, constructors and destructors
  */
 
 nsTreeWalker::nsTreeWalker(nsINode *aRoot,
--- a/content/base/src/nsXHTMLContentSerializer.cpp
+++ b/content/base/src/nsXHTMLContentSerializer.cpp
@@ -10,17 +10,16 @@
  * string that could be parsed into more or less the original DOM.
  */
 
 #include "nsXHTMLContentSerializer.h"
 
 #include "nsIDOMElement.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsINameSpaceManager.h"
 #include "nsString.h"
 #include "nsUnicharUtils.h"
 #include "nsXPIDLString.h"
 #include "nsIServiceManager.h"
 #include "nsIDocumentEncoder.h"
 #include "nsGkAtoms.h"
 #include "nsIURI.h"
--- a/content/base/src/nsXMLHttpRequest.h
+++ b/content/base/src/nsXMLHttpRequest.h
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsXMLHttpRequest_h__
 #define nsXMLHttpRequest_h__
 
 #include "nsIXMLHttpRequest.h"
 #include "nsISupportsUtils.h"
 #include "nsString.h"
-#include "nsIDOMDocument.h"
 #include "nsIURI.h"
 #include "nsIHttpChannel.h"
 #include "nsIDocument.h"
 #include "nsIStreamListener.h"
 #include "nsWeakReference.h"
 #include "jsapi.h"
 #include "nsIScriptContext.h"
 #include "nsIChannelEventSink.h"
--- a/content/base/test/TestGetURL.cpp
+++ b/content/base/test/TestGetURL.cpp
@@ -1,15 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "TestHarness.h"
 
-#include "nsIDOMDocument.h"
 #include "nsIPrincipal.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIXMLHttpRequest.h"
 
 
 #define TEST_ENSURE_BASE(_test, _msg)       \
   PR_BEGIN_MACRO                            \
     if (_test) {                            \
--- a/content/canvas/src/CanvasUtils.cpp
+++ b/content/canvas/src/CanvasUtils.cpp
@@ -7,23 +7,20 @@
 #include <stdarg.h>
 
 #include "prmem.h"
 #include "prprf.h"
 
 #include "nsIServiceManager.h"
 
 #include "nsIConsoleService.h"
-#include "nsIDOMDocument.h"
-#include "nsIDocument.h"
 #include "nsIDOMCanvasRenderingContext2D.h"
 #include "nsICanvasRenderingContextInternal.h"
 #include "nsHTMLCanvasElement.h"
 #include "nsIPrincipal.h"
-#include "nsINode.h"
 
 #include "nsGfxCIID.h"
 
 #include "nsTArray.h"
 
 #include "CanvasUtils.h"
 #include "mozilla/gfx/Matrix.h"
 
--- a/content/canvas/src/DocumentRendererChild.cpp
+++ b/content/canvas/src/DocumentRendererChild.cpp
@@ -5,21 +5,19 @@
 #include "mozilla/ipc/DocumentRendererChild.h"
 
 #include "base/basictypes.h"
 
 #include "gfxImageSurface.h"
 #include "gfxPattern.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMWindow.h"
-#include "nsIDOMDocument.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeNode.h"
 #include "nsIDocShellTreeItem.h"
-#include "nsIDocument.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsCSSParser.h"
 #include "nsPresContext.h"
 #include "nsCOMPtr.h"
 #include "nsColor.h"
 #include "gfxContext.h"
 #include "nsLayoutUtils.h"
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -34,16 +34,17 @@
 
 #include "prenv.h"
 
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/Telemetry.h"
 
 #include "nsIObserverService.h"
+#include "mozilla/Services.h"
 #include "mozilla/dom/WebGLRenderingContextBinding.h"
 
 using namespace mozilla;
 using namespace mozilla::gl;
 using namespace mozilla::layers;
 
 NS_IMPL_ISUPPORTS1(WebGLMemoryPressureObserver, nsIObserver)
 
--- a/content/canvas/src/WebGLContext.h
+++ b/content/canvas/src/WebGLContext.h
@@ -6,37 +6,32 @@
 #ifndef WEBGLCONTEXT_H_
 #define WEBGLCONTEXT_H_
 
 #include <stdarg.h>
 #include <vector>
 
 #include "nsTArray.h"
 #include "nsDataHashtable.h"
-#include "nsRefPtrHashtable.h"
 #include "nsHashKeys.h"
 
 #include "nsIDocShell.h"
 
 #include "nsIDOMWebGLRenderingContext.h"
 #include "nsICanvasRenderingContextInternal.h"
 #include "nsHTMLCanvasElement.h"
-#include "nsWeakReference.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIMemoryReporter.h"
 #include "nsIJSNativeInitializer.h"
-#include "nsContentUtils.h"
 #include "nsWrapperCache.h"
 #include "nsIObserver.h"
 
 #include "GLContextProvider.h"
 #include "Layers.h"
 
-#include "nsDataHashtable.h"
-
 #include "mozilla/LinkedList.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/dom/ImageData.h"
 
 #ifdef XP_MACOSX
 #include "ForceDiscreteGPUHelperCGL.h"
 #endif
 
@@ -60,17 +55,16 @@
 #define MINVALUE_GL_MAX_FRAGMENT_UNIFORM_VECTORS      16    // Page 164
 #define MINVALUE_GL_MAX_VERTEX_UNIFORM_VECTORS        128   // Page 164
 #define MINVALUE_GL_MAX_VARYING_VECTORS               8     // Page 164
 #define MINVALUE_GL_MAX_TEXTURE_IMAGE_UNITS           8     // Page 164
 #define MINVALUE_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS    0     // Page 164
 #define MINVALUE_GL_MAX_RENDERBUFFER_SIZE             1024  // Different from the spec, which sets it to 1 on page 164
 #define MINVALUE_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS  8     // Page 164
 
-class nsIDocShell;
 class nsIPropertyBag;
 
 namespace mozilla {
 
 class WebGLTexture;
 class WebGLBuffer;
 class WebGLProgram;
 class WebGLShader;
--- a/content/canvas/src/WebGLContextUtils.cpp
+++ b/content/canvas/src/WebGLContextUtils.cpp
@@ -10,29 +10,22 @@
 #include "prprf.h"
 
 #include "nsIJSContextStack.h"
 #include "jsapi.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIVariant.h"
 
-#include "nsIDOMDocument.h"
 #include "nsIDOMEvent.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMDataContainerEvent.h"
 
-#include "nsContentUtils.h"
 #include "mozilla/Preferences.h"
 
-#if 0
-#include "nsIContentURIGrouper.h"
-#include "nsIContentPrefService.h"
-#endif
-
 using namespace mozilla;
 
 void
 WebGLContext::GenerateWarning(const char *fmt, ...)
 {
     va_list ap;
     va_start(ap, fmt);
 
--- a/content/canvas/src/WebGLContextValidate.cpp
+++ b/content/canvas/src/WebGLContextValidate.cpp
@@ -12,16 +12,17 @@
 #include "jsfriendapi.h"
 
 #if defined(USE_ANGLE)
 #include "angle/ShaderLang.h"
 #endif
 
 #include <algorithm>
 
+#include "mozilla/Services.h"
 #include "nsIObserverService.h"
 
 using namespace mozilla;
 
 /*
  * Pull data out of the program, post-linking
  */
 bool
--- a/content/canvas/src/nsCanvasRenderingContext2D.cpp
+++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp
@@ -11,17 +11,16 @@
 #include "prmem.h"
 #include "prenv.h"
 
 #include "nsIServiceManager.h"
 #include "nsMathUtils.h"
 
 #include "nsContentUtils.h"
 
-#include "nsIDOMDocument.h"
 #include "nsIDocument.h"
 #include "nsIDOMCanvasRenderingContext2D.h"
 #include "nsICanvasRenderingContextInternal.h"
 #include "nsHTMLCanvasElement.h"
 #include "nsSVGEffects.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsIVariant.h"
--- a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
+++ b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
@@ -11,17 +11,16 @@
 #include "prmem.h"
 #include "prenv.h"
 
 #include "nsIServiceManager.h"
 #include "nsMathUtils.h"
 
 #include "nsContentUtils.h"
 
-#include "nsIDOMDocument.h"
 #include "nsIDocument.h"
 #include "nsHTMLCanvasElement.h"
 #include "nsSVGEffects.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsIVariant.h"
 
 #include "nsIInterfaceRequestorUtils.h"
--- a/content/events/public/nsEventDispatcher.h
+++ b/content/events/public/nsEventDispatcher.h
@@ -5,18 +5,16 @@
 
 #ifdef MOZILLA_INTERNAL_API
 #ifndef nsEventDispatcher_h___
 #define nsEventDispatcher_h___
 
 #include "nsCOMPtr.h"
 #include "nsEvent.h"
 
-class nsIContent;
-class nsIDocument;
 class nsPresContext;
 class nsIDOMEvent;
 class nsIScriptGlobalObject;
 class nsIDOMEventTarget;
 class nsEventTargetChainItem;
 template<class E> class nsCOMArray;
 
 /**
--- a/content/events/public/nsMutationEvent.h
+++ b/content/events/public/nsMutationEvent.h
@@ -4,18 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsMutationEvent_h__
 #define nsMutationEvent_h__
 
 #include "nsGUIEvent.h"
 #include "nsIDOMNode.h"
 #include "nsIAtom.h"
-#include "nsIDOMEventTarget.h"
-#include "nsIContent.h"
 
 class nsMutationEvent : public nsEvent
 {
 public:
   nsMutationEvent(bool isTrusted, PRUint32 msg)
     : nsEvent(isTrusted, msg, NS_MUTATION_EVENT),
       mAttrChange(0)
   {
--- a/content/events/src/nsAsyncDOMEvent.cpp
+++ b/content/events/src/nsAsyncDOMEvent.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsAsyncDOMEvent.h"
 #include "nsIDOMEvent.h"
-#include "nsIDOMDocument.h"
 #include "nsIDOMEventTarget.h"
 #include "nsContentUtils.h"
 #include "nsEventDispatcher.h"
 #include "nsGUIEvent.h"
 
 nsAsyncDOMEvent::nsAsyncDOMEvent(nsINode *aEventNode, nsEvent &aEvent)
   : mEventNode(aEventNode), mDispatchChromeOnly(false)
 {
--- a/content/events/src/nsDOMBeforeUnloadEvent.cpp
+++ b/content/events/src/nsDOMBeforeUnloadEvent.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMBeforeUnloadEvent.h"
-#include "nsContentUtils.h"
 
 NS_IMPL_ADDREF_INHERITED(nsDOMBeforeUnloadEvent, nsDOMEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMBeforeUnloadEvent, nsDOMEvent)
 
 DOMCI_DATA(BeforeUnloadEvent, nsDOMBeforeUnloadEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMBeforeUnloadEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMBeforeUnloadEvent)
--- a/content/events/src/nsDOMCloseEvent.cpp
+++ b/content/events/src/nsDOMCloseEvent.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMCloseEvent.h"
-#include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
 
 NS_IMPL_ADDREF_INHERITED(nsDOMCloseEvent, nsDOMEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMCloseEvent, nsDOMEvent)
 
 DOMCI_DATA(CloseEvent, nsDOMCloseEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMCloseEvent)
--- a/content/events/src/nsDOMCommandEvent.cpp
+++ b/content/events/src/nsDOMCommandEvent.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMCommandEvent.h"
-#include "nsContentUtils.h"
 
 nsDOMCommandEvent::nsDOMCommandEvent(nsPresContext* aPresContext,
                                      nsCommandEvent* aEvent)
   : nsDOMEvent(aPresContext, aEvent ? aEvent :
                new nsCommandEvent(false, nsnull, nsnull, nsnull))
 {
   mEvent->time = PR_Now();
   if (aEvent) {
--- a/content/events/src/nsDOMCustomEvent.cpp
+++ b/content/events/src/nsDOMCustomEvent.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMCustomEvent.h"
-#include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMCustomEvent)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMCustomEvent, nsDOMEvent)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDetail)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
--- a/content/events/src/nsDOMDataContainerEvent.cpp
+++ b/content/events/src/nsDOMDataContainerEvent.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsDOMDataContainerEvent.h"
-
-#include "nsContentUtils.h"
+#include "nsDOMClassInfoID.h"
 
 nsDOMDataContainerEvent::nsDOMDataContainerEvent(nsPresContext *aPresContext,
                                                  nsEvent *aEvent)
   : nsDOMEvent(aPresContext, aEvent)
 {
   mData.Init();
 }
 
--- a/content/events/src/nsDOMDataTransfer.cpp
+++ b/content/events/src/nsDOMDataTransfer.cpp
@@ -21,16 +21,17 @@
 #include "nsIDragService.h"
 #include "nsIScriptableRegion.h"
 #include "nsContentUtils.h"
 #include "nsIContent.h"
 #include "nsCRT.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIWebNavigation.h"
 #include "nsIDocShellTreeItem.h"
+#include "nsIScriptContext.h"
 
 using namespace mozilla;
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMDataTransfer)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMDataTransfer)
   if (tmp->mFiles) {
     tmp->mFiles->Disconnect();
     NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFiles)
--- a/content/events/src/nsDOMDeviceLightEvent.cpp
+++ b/content/events/src/nsDOMDeviceLightEvent.cpp
@@ -1,14 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMDeviceLightEvent.h"
-#include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
 
 NS_IMPL_ADDREF_INHERITED(nsDOMDeviceLightEvent, nsDOMEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMDeviceLightEvent, nsDOMEvent)
 
 DOMCI_DATA(DeviceLightEvent, nsDOMDeviceLightEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMDeviceLightEvent)
--- a/content/events/src/nsDOMDeviceMotionEvent.cpp
+++ b/content/events/src/nsDOMDeviceMotionEvent.cpp
@@ -1,16 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMDeviceMotionEvent.h"
-#include "nsContentUtils.h"
-
-
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMDeviceMotionEvent)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMDeviceMotionEvent, nsDOMEvent)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mAcceleration)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mAccelerationIncludingGravity)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mRotationRate)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
--- a/content/events/src/nsDOMDeviceOrientationEvent.cpp
+++ b/content/events/src/nsDOMDeviceOrientationEvent.cpp
@@ -1,14 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMDeviceOrientationEvent.h"
-#include "nsContentUtils.h"
 
 NS_IMPL_ADDREF_INHERITED(nsDOMDeviceOrientationEvent, nsDOMEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMDeviceOrientationEvent, nsDOMEvent)
 
 DOMCI_DATA(DeviceOrientationEvent, nsDOMDeviceOrientationEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMDeviceOrientationEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMDeviceOrientationEvent)
--- a/content/events/src/nsDOMDeviceProximityEvent.cpp
+++ b/content/events/src/nsDOMDeviceProximityEvent.cpp
@@ -1,14 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMDeviceProximityEvent.h"
-#include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
 
 NS_IMPL_ADDREF_INHERITED(nsDOMDeviceProximityEvent, nsDOMEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMDeviceProximityEvent, nsDOMEvent)
 
 DOMCI_DATA(DeviceProximityEvent, nsDOMDeviceProximityEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMDeviceProximityEvent)
--- a/content/events/src/nsDOMDragEvent.h
+++ b/content/events/src/nsDOMDragEvent.h
@@ -3,19 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsDOMDragEvent_h__
 #define nsDOMDragEvent_h__
 
 #include "nsIDOMDragEvent.h"
 #include "nsDOMMouseEvent.h"
-#include "nsIDOMDataTransfer.h"
 
-class nsIContent;
 class nsEvent;
 
 class nsDOMDragEvent : public nsDOMMouseEvent,
                        public nsIDOMDragEvent
 {
 public:
   nsDOMDragEvent(nsPresContext* aPresContext, nsInputEvent* aEvent);
   virtual ~nsDOMDragEvent();
--- a/content/events/src/nsDOMHashChangeEvent.cpp
+++ b/content/events/src/nsDOMHashChangeEvent.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMHashChangeEvent.h"
-#include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
 
 NS_IMPL_ADDREF_INHERITED(nsDOMHashChangeEvent, nsDOMEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMHashChangeEvent, nsDOMEvent)
 
 DOMCI_DATA(HashChangeEvent, nsDOMHashChangeEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMHashChangeEvent)
--- a/content/events/src/nsDOMKeyboardEvent.cpp
+++ b/content/events/src/nsDOMKeyboardEvent.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsDOMKeyboardEvent.h"
-#include "nsContentUtils.h"
+#include "nsDOMClassInfoID.h"
 
 nsDOMKeyboardEvent::nsDOMKeyboardEvent(nsPresContext* aPresContext,
                                        nsKeyEvent* aEvent)
   : nsDOMUIEvent(aPresContext, aEvent ? aEvent :
                  new nsKeyEvent(false, 0, nsnull))
 {
   NS_ASSERTION(mEvent->eventStructType == NS_KEY_EVENT, "event type mismatch");
 
--- a/content/events/src/nsDOMMouseEvent.h
+++ b/content/events/src/nsDOMMouseEvent.h
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsDOMMouseEvent_h__
 #define nsDOMMouseEvent_h__
 
 #include "nsIDOMMouseEvent.h"
 #include "nsDOMUIEvent.h"
 
-class nsIContent;
 class nsEvent;
 
 class nsDOMMouseEvent : public nsDOMUIEvent,
                         public nsIDOMMouseEvent
 {
 public:
   nsDOMMouseEvent(nsPresContext* aPresContext, nsInputEvent* aEvent);
   virtual ~nsDOMMouseEvent();
--- a/content/events/src/nsDOMMouseScrollEvent.cpp
+++ b/content/events/src/nsDOMMouseScrollEvent.cpp
@@ -1,17 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsDOMMouseScrollEvent.h"
-#include "nsGUIEvent.h"
-#include "nsIContent.h"
-#include "nsContentUtils.h"
+#include "nsDOMClassInfoID.h"
 
 nsDOMMouseScrollEvent::nsDOMMouseScrollEvent(nsPresContext* aPresContext,
                                              nsInputEvent* aEvent)
   : nsDOMMouseEvent(aPresContext, aEvent ? aEvent :
                                   new nsMouseScrollEvent(false, 0, nsnull))
 {
   if (aEvent) {
     mEventIsInternal = false;
--- a/content/events/src/nsDOMMozTouchEvent.cpp
+++ b/content/events/src/nsDOMMozTouchEvent.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMMozTouchEvent.h"
-#include "nsGUIEvent.h"
-#include "nsContentUtils.h"
 
 nsDOMMozTouchEvent::nsDOMMozTouchEvent(nsPresContext* aPresContext, nsMozTouchEvent* aEvent)
   : nsDOMMouseEvent(aPresContext, aEvent ? aEvent : new nsMozTouchEvent(false, 0, nsnull, 0))
 {
   NS_ASSERTION(mEvent->eventStructType == NS_MOZTOUCH_EVENT, "event type mismatch NS_MOZTOUCH_EVENT");
 
   if (aEvent) {
     mEventIsInternal = false;
--- a/content/events/src/nsDOMMutationEvent.cpp
+++ b/content/events/src/nsDOMMutationEvent.cpp
@@ -1,17 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsCOMPtr.h"
+#include "nsDOMClassInfoID.h"
 #include "nsDOMMutationEvent.h"
 #include "nsMutationEvent.h"
-#include "nsContentUtils.h"
+
 
 class nsPresContext;
 
 nsDOMMutationEvent::nsDOMMutationEvent(nsPresContext* aPresContext,
                                        nsMutationEvent* aEvent)
   : nsDOMEvent(aPresContext, aEvent ? aEvent :
                new nsMutationEvent(false, 0))
 {
--- a/content/events/src/nsDOMMutationEvent.h
+++ b/content/events/src/nsDOMMutationEvent.h
@@ -1,20 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsDOMMutationEvent_h__
 #define nsDOMMutationEvent_h__
 
-#include "nsCOMPtr.h"
 #include "nsIDOMMutationEvent.h"
 #include "nsDOMEvent.h"
-#include "nsContentUtils.h"
 
 class nsDOMMutationEvent : public nsDOMEvent,
                            public nsIDOMMutationEvent
 {
 public:
   nsDOMMutationEvent(nsPresContext* aPresContext, nsMutationEvent* aEvent);
 
   virtual ~nsDOMMutationEvent();
--- a/content/events/src/nsDOMPageTransitionEvent.cpp
+++ b/content/events/src/nsDOMPageTransitionEvent.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMPageTransitionEvent.h"
-#include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
 
 DOMCI_DATA(PageTransitionEvent, nsDOMPageTransitionEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMPageTransitionEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMPageTransitionEvent)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(PageTransitionEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
--- a/content/events/src/nsDOMPopupBlockedEvent.cpp
+++ b/content/events/src/nsDOMPopupBlockedEvent.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMPopupBlockedEvent.h"
 #include "nsIURI.h"
-#include "nsContentUtils.h"
 
 NS_IMPL_ADDREF_INHERITED(nsDOMPopupBlockedEvent, nsDOMEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMPopupBlockedEvent, nsDOMEvent)
 
 DOMCI_DATA(PopupBlockedEvent, nsDOMPopupBlockedEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMPopupBlockedEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMPopupBlockedEvent)
--- a/content/events/src/nsDOMProgressEvent.cpp
+++ b/content/events/src/nsDOMProgressEvent.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMProgressEvent.h"
-#include "nsContentUtils.h"
-
 
 DOMCI_DATA(ProgressEvent, nsDOMProgressEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMProgressEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMProgressEvent)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ProgressEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
--- a/content/events/src/nsDOMSettingsEvent.cpp
+++ b/content/events/src/nsDOMSettingsEvent.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMSettingsEvent.h"
-#include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMozSettingsEvent)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMozSettingsEvent, nsDOMEvent)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mSettingValue)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
--- a/content/events/src/nsDOMSimpleGestureEvent.cpp
+++ b/content/events/src/nsDOMSimpleGestureEvent.cpp
@@ -1,17 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMSimpleGestureEvent.h"
-#include "nsGUIEvent.h"
-#include "nsContentUtils.h"
-
 
 nsDOMSimpleGestureEvent::nsDOMSimpleGestureEvent(nsPresContext* aPresContext, nsSimpleGestureEvent* aEvent)
   : nsDOMMouseEvent(aPresContext, aEvent ? aEvent : new nsSimpleGestureEvent(false, 0, nsnull, 0, 0.0))
 {
   NS_ASSERTION(mEvent->eventStructType == NS_SIMPLE_GESTURE_EVENT, "event type mismatch");
 
   if (aEvent) {
     mEventIsInternal = false;
--- a/content/events/src/nsDOMTextEvent.cpp
+++ b/content/events/src/nsDOMTextEvent.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 sw=2 et tw=78: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsDOMTextEvent.h"
-#include "nsContentUtils.h"
 #include "nsPrivateTextRange.h"
 
 nsDOMTextEvent::nsDOMTextEvent(nsPresContext* aPresContext,
                                nsTextEvent* aEvent)
   : nsDOMUIEvent(aPresContext, aEvent ? aEvent :
                  new nsTextEvent(false, 0, nsnull))
 {
   NS_ASSERTION(mEvent->eventStructType == NS_TEXT_EVENT, "event type mismatch");
--- a/content/events/src/nsDOMUserProximityEvent.cpp
+++ b/content/events/src/nsDOMUserProximityEvent.cpp
@@ -1,14 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMUserProximityEvent.h"
-#include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
 
 NS_IMPL_ADDREF_INHERITED(nsDOMUserProximityEvent, nsDOMEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMUserProximityEvent, nsDOMEvent)
 
 DOMCI_DATA(UserProximityEvent, nsDOMUserProximityEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMUserProximityEvent)
--- a/content/events/src/nsDOMXULCommandEvent.cpp
+++ b/content/events/src/nsDOMXULCommandEvent.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMXULCommandEvent.h"
-#include "nsContentUtils.h"
 
 nsDOMXULCommandEvent::nsDOMXULCommandEvent(nsPresContext* aPresContext,
                                            nsInputEvent* aEvent)
   : nsDOMUIEvent(aPresContext,
                  aEvent ? aEvent : new nsInputEvent(false, 0, nsnull))
 {
   if (aEvent) {
     mEventIsInternal = false;
--- a/content/events/src/nsEventListenerManager.h
+++ b/content/events/src/nsEventListenerManager.h
@@ -24,17 +24,16 @@ class nsIDOMEvent;
 class nsIAtom;
 class nsIWidget;
 struct nsPoint;
 struct EventTypeData;
 class nsEventTargetChainItem;
 class nsPIDOMWindow;
 class nsCxPusher;
 class nsIEventListenerInfo;
-class nsIDocument;
 
 typedef enum
 {
     eNativeListener = 0,
     eJSEventListener,
     eWrappedJSListener
 } nsListenerType;
 
--- a/content/events/src/nsXMLEventsManager.cpp
+++ b/content/events/src/nsXMLEventsManager.cpp
@@ -2,17 +2,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsIDOMMutationEvent.h"
 #include "nsXMLEventsManager.h"
 #include "nsGkAtoms.h"
 #include "nsIDOMElement.h"
-#include "nsIDOMDocument.h"
 #include "nsIDOMEventTarget.h"
 #include "nsNetUtil.h"
 #include "nsIURL.h"
 #include "nsIDOMEventListener.h"
 #include "nsINameSpaceManager.h"
 #include "nsINodeInfo.h"
 #include "mozilla/dom/Element.h"
 
--- a/content/html/content/public/nsHTMLCanvasElement.h
+++ b/content/html/content/public/nsHTMLCanvasElement.h
@@ -6,18 +6,16 @@
 #if !defined(nsHTMLCanvasElement_h__)
 #define nsHTMLCanvasElement_h__
 
 #include "nsIDOMHTMLCanvasElement.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsSize.h"
 #include "nsIFrame.h"
-#include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsDOMError.h"
 #include "nsNodeInfoManager.h"
 
 #include "nsICanvasElementExternal.h"
 #include "nsLayoutUtils.h"
 
 #include "Layers.h"
 
--- a/content/html/content/public/nsIFormControl.h
+++ b/content/html/content/public/nsIFormControl.h
@@ -3,17 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef nsIFormControl_h___
 #define nsIFormControl_h___
 
 #include "nsISupports.h"
 class nsIDOMHTMLFormElement;
 class nsPresState;
-class nsIContent;
 class nsString;
 class nsIFormProcessor;
 class nsFormSubmission;
 
 namespace mozilla {
 namespace dom {
 class Element;
 } // namespace dom
--- a/content/html/content/public/nsIHTMLCollection.h
+++ b/content/html/content/public/nsIHTMLCollection.h
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsIHTMLCollection_h___
 #define nsIHTMLCollection_h___
 
 #include "nsIDOMHTMLCollection.h"
 
 class nsINode;
-class nsIContent;
 class nsWrapperCache;
 
 // IID for the nsIHTMLCollection interface
 #define NS_IHTMLCOLLECTION_IID \
 { 0xdea91ad6, 0x57d1, 0x4e7a, \
  { 0xb5, 0x5a, 0xdb, 0xfc, 0x36, 0x7b, 0xc8, 0x22 } }
 
 /**
--- a/content/html/content/src/nsFormSubmission.cpp
+++ b/content/html/content/src/nsFormSubmission.cpp
@@ -8,17 +8,16 @@
 
 #include "nsFormSubmission.h"
 
 #include "nsCOMPtr.h"
 #include "nsIForm.h"
 #include "nsILinkHandler.h"
 #include "nsIDocument.h"
 #include "nsGkAtoms.h"
-#include "nsIHTMLDocument.h"
 #include "nsIFormControl.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsDOMError.h"
 #include "nsGenericHTMLElement.h"
 #include "nsISaveAsCharset.h"
 #include "nsIFile.h"
 #include "nsIDOMFile.h"
 #include "nsDirectoryServiceDefs.h"
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -72,34 +72,33 @@
 #include "nsContentCID.h"
 
 #include "nsDOMStringMap.h"
 
 #include "nsIEditor.h"
 #include "nsIEditorIMESupport.h"
 #include "nsEventDispatcher.h"
 #include "nsLayoutUtils.h"
-#include "nsContentCreatorFunctions.h"
 #include "mozAutoDocUpdate.h"
 #include "nsHtml5Module.h"
 #include "nsITextControlElement.h"
 #include "mozilla/dom/Element.h"
 #include "nsHTMLFieldSetElement.h"
 #include "nsHTMLMenuElement.h"
 #include "nsAsyncDOMEvent.h"
-#include "nsIScriptError.h"
 #include "nsDOMMutationObserver.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/FromParser.h"
 #include "mozilla/BloomFilter.h"
 
 #include "HTMLPropertiesCollection.h"
 #include "nsVariant.h"
 #include "nsDOMSettableTokenList.h"
 #include "nsThreadUtils.h"
+#include "nsTextFragment.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 class nsINodeInfo;
 class nsIDOMNodeList;
 class nsRuleWalker;
 
--- a/content/html/content/src/nsGenericHTMLFrameElement.cpp
+++ b/content/html/content/src/nsGenericHTMLFrameElement.cpp
@@ -1,25 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set tw=80 expandtab softtabstop=2 ts=2 sw=2: */
 
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsGenericHTMLFrameElement.h"
-#include "nsIWebProgress.h"
-#include "nsIDOMCustomEvent.h"
-#include "nsIVariant.h"
 #include "nsIInterfaceRequestorUtils.h"
-#include "nsWeakPtr.h"
-#include "nsVariant.h"
 #include "nsContentUtils.h"
-#include "nsEventDispatcher.h"
-#include "nsAsyncDOMEvent.h"
 #include "mozilla/Preferences.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsGenericHTMLFrameElement)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsGenericHTMLFrameElement,
                                                   nsGenericHTMLElement)
--- a/content/html/content/src/nsHTMLAnchorElement.cpp
+++ b/content/html/content/src/nsHTMLAnchorElement.cpp
@@ -6,18 +6,16 @@
 
 #include "nsGenericHTMLElement.h"
 #include "nsIDOMHTMLAnchorElement.h"
 #include "nsILink.h"
 #include "Link.h"
 
 #include "nsCOMPtr.h"
 #include "nsContentUtils.h"
-#include "nsReadableUtils.h"
-#include "nsUnicharUtils.h"
 #include "nsGkAtoms.h"
 #include "nsIPresShell.h"
 #include "nsIDocument.h"
 #include "nsPresContext.h"
 #include "nsHTMLDNSPrefetch.h"
 
 using namespace mozilla::dom;
 
--- a/content/html/content/src/nsHTMLAreaElement.cpp
+++ b/content/html/content/src/nsHTMLAreaElement.cpp
@@ -1,22 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set tw=80 expandtab softtabstop=2 ts=2 sw=2: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #include "nsIDOMHTMLAreaElement.h"
-#include "nsIDOMEventTarget.h"
 #include "nsGenericHTMLElement.h"
 #include "nsILink.h"
 #include "nsGkAtoms.h"
-#include "nsStyleConsts.h"
 #include "nsIURL.h"
-#include "nsNetUtil.h"
-#include "nsReadableUtils.h"
 #include "nsIDocument.h"
 
 #include "Link.h"
 using namespace mozilla::dom;
 
 class nsHTMLAreaElement : public nsGenericHTMLElement,
                           public nsIDOMHTMLAreaElement,
                           public nsILink,
--- a/content/html/content/src/nsHTMLAudioElement.cpp
+++ b/content/html/content/src/nsHTMLAudioElement.cpp
@@ -1,41 +1,19 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #include "nsIDOMHTMLAudioElement.h"
-#include "nsIDOMHTMLSourceElement.h"
 #include "nsHTMLAudioElement.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
-#include "nsSize.h"
-#include "nsIFrame.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
-#include "nsDOMError.h"
-#include "nsNodeInfoManager.h"
-#include "plbase64.h"
-#include "nsNetUtil.h"
-#include "prmem.h"
-#include "nsXPCOMStrings.h"
-#include "prlock.h"
-#include "nsThreadUtils.h"
-
-#include "nsIScriptSecurityManager.h"
-#include "nsIXPConnect.h"
-#include "jsapi.h"
 #include "jsfriendapi.h"
-#include "nsJSUtils.h"
-
-#include "nsITimer.h"
-
-#include "nsEventDispatcher.h"
-#include "nsIDOMProgressEvent.h"
 #include "nsContentUtils.h"
 
 using namespace mozilla::dom;
 
 nsGenericHTMLElement*
 NS_NewHTMLAudioElement(already_AddRefed<nsINodeInfo> aNodeInfo,
                        FromParser aFromParser)
 {
--- a/content/html/content/src/nsHTMLBodyElement.cpp
+++ b/content/html/content/src/nsHTMLBodyElement.cpp
@@ -3,26 +3,23 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Util.h"
 
 #include "nscore.h"
 #include "nsCOMPtr.h"
 #include "nsIDOMHTMLBodyElement.h"
-#include "nsIDOMEventTarget.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsIDocument.h"
-#include "nsIHTMLDocument.h"
 #include "nsHTMLStyleSheet.h"
-#include "nsIContentViewer.h"
 #include "nsIMarkupDocumentViewer.h"
 #include "nsMappedAttributes.h"
 #include "nsRuleData.h"
 #include "nsIFrame.h"
 #include "nsIDocShell.h"
 #include "nsIEditorDocShell.h"
 #include "nsRuleWalker.h"
 #include "jsapi.h"
--- a/content/html/content/src/nsHTMLCanvasElement.cpp
+++ b/content/html/content/src/nsHTMLCanvasElement.cpp
@@ -11,16 +11,17 @@
 #include "prmem.h"
 #include "nsDOMFile.h"
 
 #include "nsICanvasRenderingContextInternal.h"
 #include "nsIDOMCanvasRenderingContext2D.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIXPConnect.h"
 #include "jsapi.h"
+#include "jsfriendapi.h"
 #include "nsContentUtils.h"
 #include "nsJSUtils.h"
 #include "nsMathUtils.h"
 #include "nsStreamUtils.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 
 #include "nsFrameManager.h"
--- a/content/html/content/src/nsHTMLFontElement.cpp
+++ b/content/html/content/src/nsHTMLFontElement.cpp
@@ -9,17 +9,16 @@
 #include "nsIDOMHTMLFontElement.h"
 #include "nsIDOMEventTarget.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsMappedAttributes.h"
 #include "nsRuleData.h"
-#include "nsIDocument.h"
 #include "nsAlgorithm.h"
 #include "nsContentUtils.h"
 
 using namespace mozilla;
 
 class nsHTMLFontElement : public nsGenericHTMLElement,
                           public nsIDOMHTMLFontElement
 {
--- a/content/html/content/src/nsHTMLFrameElement.cpp
+++ b/content/html/content/src/nsHTMLFrameElement.cpp
@@ -3,20 +3,20 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Util.h"
 
 #include "nsIDOMHTMLFrameElement.h"
 #include "nsGenericHTMLFrameElement.h"
 #include "nsGkAtoms.h"
-#include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsDOMError.h"
 
+class nsIDOMDocument;
+
 using namespace mozilla;
 using namespace mozilla::dom;
 
 class nsHTMLFrameElement : public nsGenericHTMLFrameElement,
                            public nsIDOMHTMLFrameElement
 {
 public:
   nsHTMLFrameElement(already_AddRefed<nsINodeInfo> aNodeInfo,
--- a/content/html/content/src/nsHTMLFrameSetElement.h
+++ b/content/html/content/src/nsHTMLFrameSetElement.h
@@ -7,18 +7,16 @@
 #define nsHTMLFrameSetElement_h
 
 #include "nsISupports.h"
 #include "nsIDOMHTMLFrameSetElement.h"
 #include "nsIDOMEventTarget.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
-#include "nsIHTMLDocument.h"
-#include "nsIDocument.h"
 
 /**
  * The nsFramesetUnit enum is used to denote the type of each entry
  * in the row or column spec.
  */
 enum nsFramesetUnit {
   eFramesetUnit_Fixed = 0,
   eFramesetUnit_Percent,
--- a/content/html/content/src/nsHTMLIFrameElement.cpp
+++ b/content/html/content/src/nsHTMLIFrameElement.cpp
@@ -1,20 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Util.h"
 
 #include "nsHTMLIFrameElement.h"
-#include "nsIDOMDocument.h"
 #include "nsIDOMSVGDocument.h"
 #include "nsGkAtoms.h"
-#include "nsIDocument.h"
 #include "nsMappedAttributes.h"
 #include "nsDOMError.h"
 #include "nsRuleData.h"
 #include "nsStyleConsts.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
--- a/content/html/content/src/nsHTMLImageElement.cpp
+++ b/content/html/content/src/nsHTMLImageElement.cpp
@@ -8,17 +8,16 @@
 #include "nsHTMLImageElement.h"
 #include "nsIDOMEventTarget.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsMappedAttributes.h"
 #include "nsSize.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsIScriptContext.h"
 #include "nsIURL.h"
 #include "nsIIOService.h"
 #include "nsIServiceManager.h"
 #include "nsNetUtil.h"
 #include "nsContentUtils.h"
 #include "nsIFrame.h"
 #include "nsNodeInfoManager.h"
--- a/content/html/content/src/nsHTMLLabelElement.cpp
+++ b/content/html/content/src/nsHTMLLabelElement.cpp
@@ -10,17 +10,16 @@
 #include "nsCOMPtr.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIDOMEventTarget.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsIFormControl.h"
 #include "nsIForm.h"
-#include "nsIDOMDocument.h"
 #include "nsIDocument.h"
 #include "nsGUIEvent.h"
 #include "nsEventDispatcher.h"
 #include "nsPIDOMWindow.h"
 #include "nsFocusManager.h"
 
 // construction, destruction
 
--- a/content/html/content/src/nsHTMLMapElement.cpp
+++ b/content/html/content/src/nsHTMLMapElement.cpp
@@ -3,18 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #include "nsIDOMHTMLMapElement.h"
 #include "nsIDOMEventTarget.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsContentList.h"
-#include "nsIDocument.h"
-#include "nsIHTMLDocument.h"
 #include "nsCOMPtr.h"
 
 
 class nsHTMLMapElement : public nsGenericHTMLElement,
                          public nsIDOMHTMLMapElement
 {
 public:
   nsHTMLMapElement(already_AddRefed<nsINodeInfo> aNodeInfo);
--- a/content/html/content/src/nsHTMLOptGroupElement.cpp
+++ b/content/html/content/src/nsHTMLOptGroupElement.cpp
@@ -5,17 +5,16 @@
 #include "nsIDOMHTMLOptGroupElement.h"
 #include "nsIDOMEventTarget.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsIFrame.h"
 #include "nsIFormControlFrame.h"
 #include "nsEventStates.h"
-#include "nsIDocument.h"
 
 #include "nsEventDispatcher.h"
 #include "nsHTMLSelectElement.h"
 
 /**
  * The implementation of &lt;optgroup&gt;
  */
 class nsHTMLOptGroupElement : public nsGenericHTMLElement,
--- a/content/html/content/src/nsHTMLOptionElement.cpp
+++ b/content/html/content/src/nsHTMLOptionElement.cpp
@@ -20,17 +20,16 @@
 // Notify/query select frame for selected state
 #include "nsIFormControlFrame.h"
 #include "nsIDocument.h"
 #include "nsIFrame.h"
 #include "nsIDOMHTMLSelectElement.h"
 #include "nsNodeInfoManager.h"
 #include "nsCOMPtr.h"
 #include "nsEventStates.h"
-#include "nsIDOMDocument.h"
 #include "nsContentCreatorFunctions.h"
 #include "mozAutoDocUpdate.h"
 
 using namespace mozilla::dom;
 
 /**
  * Implementation of &lt;option&gt;
  */
--- a/content/html/content/src/nsHTMLScriptElement.cpp
+++ b/content/html/content/src/nsHTMLScriptElement.cpp
@@ -14,17 +14,16 @@
 #include "nsNetUtil.h"
 #include "nsContentUtils.h"
 #include "nsUnicharUtils.h"  // for nsCaseInsensitiveStringComparator()
 #include "jsapi.h"
 #include "nsIScriptContext.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIXPConnect.h"
 #include "nsServiceManagerUtils.h"
-#include "nsIDOMDocument.h"
 #include "nsContentErrors.h"
 #include "nsIArray.h"
 #include "nsTArray.h"
 #include "nsDOMJSUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
--- a/content/html/content/src/nsHTMLTableCellElement.cpp
+++ b/content/html/content/src/nsHTMLTableCellElement.cpp
@@ -12,17 +12,16 @@
 #include "nsIDOMEventTarget.h"
 #include "nsMappedAttributes.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsRuleData.h"
 #include "nsRuleWalker.h"
-#include "nsIDocument.h"
 #include "celldata.h"
 
 using namespace mozilla;
 
 class nsHTMLTableCellElement : public nsGenericHTMLElement,
                                public nsIDOMHTMLTableCellElement
 {
 public:
--- a/content/html/content/src/nsHTMLTableSectionElement.cpp
+++ b/content/html/content/src/nsHTMLTableSectionElement.cpp
@@ -10,17 +10,16 @@
 #include "nsMappedAttributes.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsHTMLParts.h"
 #include "nsStyleConsts.h"
 #include "nsContentList.h"
 #include "nsRuleData.h"
 #include "nsDOMError.h"
-#include "nsIDocument.h"
 #include "nsContentUtils.h"
 
 using namespace mozilla;
 
 // you will see the phrases "rowgroup" and "section" used interchangably
 
 class nsHTMLTableSectionElement : public nsGenericHTMLElement,
                                   public nsIDOMHTMLTableSectionElement
--- a/content/html/content/src/nsHTMLTitleElement.cpp
+++ b/content/html/content/src/nsHTMLTitleElement.cpp
@@ -2,17 +2,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #include "nsIDOMHTMLTitleElement.h"
 #include "nsIDOMEventTarget.h"
 #include "nsGenericHTMLElement.h"
 #include "nsStyleConsts.h"
 #include "nsIDocument.h"
-#include "nsIDOMHTMLDocument.h"
 #include "nsContentUtils.h"
 
 class nsHTMLTitleElement : public nsGenericHTMLElement,
                            public nsIDOMHTMLTitleElement,
                            public nsStubMutationObserver
 {
 public:
   using nsGenericElement::GetText;
--- a/content/html/content/src/nsHTMLVideoElement.cpp
+++ b/content/html/content/src/nsHTMLVideoElement.cpp
@@ -8,18 +8,16 @@
 
 #include "nsIDOMHTMLVideoElement.h"
 #include "nsIDOMHTMLSourceElement.h"
 #include "nsHTMLVideoElement.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsSize.h"
 #include "nsIFrame.h"
-#include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsDOMError.h"
 #include "nsNodeInfoManager.h"
 #include "plbase64.h"
 #include "nsNetUtil.h"
 #include "prmem.h"
 #include "nsXPCOMStrings.h"
 #include "prlock.h"
 #include "nsThreadUtils.h"
--- a/content/html/content/src/nsMediaError.cpp
+++ b/content/html/content/src/nsMediaError.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #include "nsMediaError.h"
-#include "nsContentUtils.h"
+#include "nsDOMClassInfoID.h"
 
 NS_IMPL_ADDREF(nsMediaError)
 NS_IMPL_RELEASE(nsMediaError)
 
 DOMCI_DATA(MediaError, nsMediaError)
 
 NS_INTERFACE_MAP_BEGIN(nsMediaError)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
--- a/content/html/content/src/nsRadioVisitor.cpp
+++ b/content/html/content/src/nsRadioVisitor.cpp
@@ -2,17 +2,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsRadioVisitor.h"
 #include "nsAutoPtr.h"
 #include "nsHTMLInputElement.h"
 #include "nsEventStates.h"
-#include "nsIDocument.h"
 #include "nsIConstraintValidation.h"
 
 
 NS_IMPL_ISUPPORTS1(nsRadioVisitor, nsIRadioVisitor)
 
 bool
 nsRadioSetCheckedChangedVisitor::Visit(nsIFormControl* aRadio)
 {
--- a/content/html/content/src/nsRadioVisitor.h
+++ b/content/html/content/src/nsRadioVisitor.h
@@ -4,18 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _nsRadioVisitor_h__
 #define _nsRadioVisitor_h__
 
 #include "nsIRadioVisitor.h"
 
 class nsIFormControl;
-class nsIDocument;
-
 
 /**
  * nsRadioVisitor is the base class implementing nsIRadioVisitor and inherited
  * by all radio visitors.
  */
 class nsRadioVisitor : public nsIRadioVisitor
 {
 public:
--- a/content/html/content/src/nsTimeRanges.cpp
+++ b/content/html/content/src/nsTimeRanges.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsTimeRanges.h"
+#include "nsDOMClassInfoID.h"
 #include "nsDOMError.h"
-#include "nsContentUtils.h"
 
 NS_IMPL_ADDREF(nsTimeRanges)
 NS_IMPL_RELEASE(nsTimeRanges)
 
 DOMCI_DATA(TimeRanges, nsTimeRanges)
 
 NS_INTERFACE_MAP_BEGIN(nsTimeRanges)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
--- a/content/html/document/src/nsHTMLDocument.h
+++ b/content/html/document/src/nsHTMLDocument.h
@@ -74,19 +74,16 @@ public:
 
   virtual void SetCompatibilityMode(nsCompatibility aMode);
 
   virtual bool IsWriting()
   {
     return mWriteLevel != PRUint32(0);
   }
 
-  virtual bool GetIsFrameset() { return mIsFrameset; }
-  virtual void SetIsFrameset(bool aFrameset) { mIsFrameset = aFrameset; }
-
   virtual NS_HIDDEN_(nsContentList*) GetForms();
  
   virtual NS_HIDDEN_(nsContentList*) GetFormControls();
  
   // nsIDOMDocument interface
   NS_FORWARD_NSIDOMDOCUMENT(nsDocument::)
 
   // nsIDOMNode interface
@@ -248,18 +245,16 @@ protected:
   // implicit or explicit). Note that if a write call writes out something which
   // would block the parser, then mWriteLevel will be incorrect until the parser
   // finishes processing that script.
   PRUint32 mWriteLevel;
 
   // Load flags of the document's channel
   PRUint32 mLoadFlags;
 
-  bool mIsFrameset;
-
   bool mTooDeepWriteRecursion;
 
   bool mDisableDocWrite;
 
   bool mWarnedWidthHeight;
 
   nsCOMPtr<nsIWyciwygChannel> mWyciwygChannel;
 
--- a/content/html/document/src/nsIHTMLDocument.h
+++ b/content/html/document/src/nsIHTMLDocument.h
@@ -12,18 +12,18 @@
 class nsIDOMHTMLFormElement;
 class nsIContent;
 class nsIScriptElement;
 class nsIEditor;
 class nsContentList;
 class nsWrapperCache;
 
 #define NS_IHTMLDOCUMENT_IID \
-{ 0xa921276f, 0x5e70, 0x42e0, \
-  { 0xb8, 0x36, 0x7e, 0x6a, 0xb8, 0x30, 0xb3, 0xc0 } }
+{ 0xcf814492, 0x303c, 0x4718, \
+  { 0x9a, 0x3e, 0x39, 0xbc, 0xd5, 0x2c, 0x10, 0xdb } }
 
 /**
  * HTML document extensions to nsIDocument.
  */
 class nsIHTMLDocument : public nsISupports
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTMLDOCUMENT_IID)
@@ -53,19 +53,16 @@ public:
    * without calling FlushPendingNotifications (bug 138892).
    */
   // XXXbz is this still needed now that we can flush just content,
   // not the rest?
   virtual PRInt32 GetNumFormsSynchronous() = 0;
   
   virtual bool IsWriting() = 0;
 
-  virtual bool GetIsFrameset() = 0;
-  virtual void SetIsFrameset(bool aFrameset) = 0;
-
   /**
    * Get the list of form elements in the document.
    */
   virtual nsContentList* GetForms() = 0;
 
   /**
    * Get the list of form controls in the document (all elements in
    * the document that are of type nsIContent::eHTML_FORM_CONTROL).
--- a/content/mathml/content/src/nsMathMLElementFactory.cpp
+++ b/content/mathml/content/src/nsMathMLElementFactory.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsContentCreatorFunctions.h"
 #include "nsGkAtoms.h"
-#include "nsIDocument.h"
 #include "nsMathMLElement.h"
 
 // MathML Element Factory (declared in nsContentCreatorFunctions.h)
 nsresult
 NS_NewMathMLElement(nsIContent** aResult, already_AddRefed<nsINodeInfo> aNodeInfo)
 {
   aNodeInfo.get()->SetIDAttributeAtom(nsGkAtoms::id);
 
--- a/content/media/MediaResource.cpp
+++ b/content/media/MediaResource.cpp
@@ -17,17 +17,16 @@
 #include "nsISeekableStream.h"
 #include "nsIInputStream.h"
 #include "nsIOutputStream.h"
 #include "nsIRequestObserver.h"
 #include "nsIStreamListener.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsCrossSiteListenerProxy.h"
 #include "nsHTMLMediaElement.h"
-#include "nsIDocument.h"
 #include "nsDOMError.h"
 #include "nsICachingChannel.h"
 #include "nsURILoader.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "mozilla/Util.h" // for DebugOnly
 #include "nsContentUtils.h"
 
 static const PRUint32 HTTP_OK_CODE = 200;
--- a/content/smil/nsSMILAnimationController.cpp
+++ b/content/smil/nsSMILAnimationController.cpp
@@ -2,19 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsSMILAnimationController.h"
 #include "nsSMILCompositor.h"
 #include "nsSMILCSSProperty.h"
 #include "nsCSSProps.h"
-#include "nsComponentManagerUtils.h"
 #include "nsITimer.h"
-#include "nsIContent.h"
 #include "mozilla/dom/Element.h"
 #include "nsIDocument.h"
 #include "nsISMILAnimationElement.h"
 #include "nsIDOMSVGAnimationElement.h"
 #include "nsSMILTimedElement.h"
 
 using namespace mozilla::dom;
 
--- a/content/smil/nsSMILCSSProperty.h
+++ b/content/smil/nsSMILCSSProperty.h
@@ -8,18 +8,16 @@
 #ifndef NS_SMILCSSPROPERTY_H_
 #define NS_SMILCSSPROPERTY_H_
 
 #include "nsISMILAttr.h"
 #include "nsIAtom.h"
 #include "nsCSSProperty.h"
 #include "nsCSSValue.h"
 
-class nsIContent;
-
 namespace mozilla {
 namespace dom {
 class Element;
 } // namespace dom
 } // namespace mozilla
 
 /**
  * nsSMILCSSProperty: Implements the nsISMILAttr interface for SMIL animations
--- a/content/smil/nsSMILMappedAttribute.cpp
+++ b/content/smil/nsSMILMappedAttribute.cpp
@@ -1,21 +1,19 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* representation of a SMIL-animatable mapped attribute on an element */
 #include "nsSMILMappedAttribute.h"
 #include "nsAttrValue.h"
-#include "nsPropertyTable.h"
 #include "nsContentErrors.h" // For NS_PROPTABLE_PROP_OVERWRITTEN
 #include "nsSMILValue.h"
 #include "nsSMILCSSValueType.h"
-#include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIPresShell.h"
 #include "nsCSSProps.h"
 #include "mozilla/dom/Element.h"
 
 // Callback function, for freeing string buffers stored in property table
 static void
 ReleaseStringBufferPropertyValue(void*    aObject,       /* unused */
--- a/content/smil/nsSMILTimeValueSpec.cpp
+++ b/content/smil/nsSMILTimeValueSpec.cpp
@@ -6,17 +6,16 @@
 #include "nsSMILTimeValueSpec.h"
 #include "nsSMILInterval.h"
 #include "nsSMILTimeContainer.h"
 #include "nsSMILTimeValue.h"
 #include "nsSMILTimedElement.h"
 #include "nsSMILInstanceTime.h"
 #include "nsSMILParserUtils.h"
 #include "nsISMILAnimationElement.h"
-#include "nsContentUtils.h"
 #include "nsEventListenerManager.h"
 #include "nsGUIEvent.h"
 #include "nsIDOMTimeEvent.h"
 #include "nsString.h"
 #include <limits>
 
 using namespace mozilla::dom;
 
--- a/content/svg/content/src/SVGLengthList.cpp
+++ b/content/svg/content/src/SVGLengthList.cpp
@@ -3,17 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SVGLengthList.h"
 #include "SVGAnimatedLengthList.h"
 #include "SVGLength.h"
 #include "nsSVGElement.h"
 #include "nsDOMError.h"
-#include "nsContentUtils.h"
 #include "nsString.h"
 #include "nsSVGUtils.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "string.h"
 
 namespace mozilla {
 
 nsresult
--- a/content/svg/content/src/SVGPathData.cpp
+++ b/content/svg/content/src/SVGPathData.cpp
@@ -1,19 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SVGPathData.h"
-#include "SVGAnimatedPathSegList.h"
 #include "SVGPathSegUtils.h"
 #include "nsSVGElement.h"
 #include "nsDOMError.h"
-#include "nsContentUtils.h"
 #include "nsString.h"
 #include "nsSVGUtils.h"
 #include "string.h"
 #include "nsSVGPathDataParser.h"
 #include "nsSVGPathGeometryElement.h" // for nsSVGMark
 #include "gfxPlatform.h"
 #include <stdarg.h>
 
--- a/content/svg/content/src/SVGPathSegUtils.cpp
+++ b/content/svg/content/src/SVGPathSegUtils.cpp
@@ -1,25 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SVGPathSegUtils.h"
-#include "nsSVGElement.h"
-#include "nsSVGSVGElement.h"
 #include "nsSVGPathDataParser.h"
-#include "nsString.h"
-#include "nsSVGUtils.h"
 #include "nsContentUtils.h"
 #include "nsTextFormatter.h"
-#include "prdtoa.h"
-#include <limits>
-#include "nsMathUtils.h"
-#include "prtypes.h"
 
 using namespace mozilla;
 
 static const float PATH_SEG_LENGTH_TOLERANCE = 0.0000001f;
 static const PRUint32 MAX_RECURSION = 10;
 
 
 /* static */ void
--- a/content/svg/content/src/SVGTransformListParser.cpp
+++ b/content/svg/content/src/SVGTransformListParser.cpp
@@ -6,19 +6,17 @@
 
 #include "mozilla/Util.h"
 
 #include "SVGTransformListParser.h"
 #include "SVGTransform.h"
 #include "prdtoa.h"
 #include "nsDOMError.h"
 #include "nsGkAtoms.h"
-#include "nsReadableUtils.h"
 #include "nsCRT.h"
-#include "nsContentUtils.h"
 #include "nsDOMClassInfoID.h"
 #include "nsIAtom.h"
 
 using namespace mozilla;
 
 //----------------------------------------------------------------------
 // private methods
 
--- a/content/svg/content/src/nsDOMSVGEvent.cpp
+++ b/content/svg/content/src/nsDOMSVGEvent.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsDOMClassInfoID.h"
 #include "nsDOMSVGEvent.h"
-#include "nsContentUtils.h"
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsDOMSVGEvent::nsDOMSVGEvent(nsPresContext* aPresContext,
                              nsEvent* aEvent)
   : nsDOMEvent(aPresContext,
                aEvent ? aEvent : new nsEvent(false, 0))
--- a/content/svg/content/src/nsDOMSVGZoomEvent.cpp
+++ b/content/svg/content/src/nsDOMSVGZoomEvent.cpp
@@ -1,20 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsDOMSVGZoomEvent.h"
-#include "nsContentUtils.h"
 #include "nsSVGRect.h"
 #include "DOMSVGPoint.h"
 #include "nsSVGSVGElement.h"
 #include "nsIDOMSVGSVGElement.h"
-#include "nsIContent.h"
 #include "nsIPresShell.h"
 #include "nsIDocument.h"
 #include "mozilla/dom/Element.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 //----------------------------------------------------------------------
--- a/content/svg/content/src/nsSVGElementFactory.cpp
+++ b/content/svg/content/src/nsSVGElementFactory.cpp
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsCOMPtr.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsIAtom.h"
 #include "nsINodeInfo.h"
 #include "nsGkAtoms.h"
 #include "nsContentDLF.h"
-#include "nsContentUtils.h"
 #include "nsSVGUtils.h"
 #include "nsDebug.h"
 
 using namespace mozilla::dom;
 
 nsresult
 NS_NewSVGAElement(nsIContent **aResult,
                   already_AddRefed<nsINodeInfo> aNodeInfo);
--- a/content/svg/content/src/nsSVGPathElement.cpp
+++ b/content/svg/content/src/nsSVGPathElement.cpp
@@ -5,24 +5,21 @@
 
 #include "mozilla/Util.h"
 
 #include "nsGkAtoms.h"
 #include "nsIDOMSVGPathSeg.h"
 #include "DOMSVGPathSeg.h"
 #include "DOMSVGPathSegList.h"
 #include "nsCOMPtr.h"
-#include "nsIFrame.h"
 #include "nsContentUtils.h"
-#include "nsSVGPathDataParser.h"
 #include "nsSVGPathElement.h"
 #include "nsSVGUtils.h"
 #include "DOMSVGPoint.h"
 #include "gfxContext.h"
-#include "gfxPlatform.h"
 
 using namespace mozilla;
 
 nsSVGElement::NumberInfo nsSVGPathElement::sNumberInfo = 
 { &nsGkAtoms::pathLength, 0, false };
 
 NS_IMPL_NS_NEW_SVG_ELEMENT(Path)
 
--- a/content/svg/content/src/nsSVGRect.cpp
+++ b/content/svg/content/src/nsSVGRect.cpp
@@ -1,20 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsSVGRect.h"
-#include "prdtoa.h"
 #include "nsTextFormatter.h"
-#include "nsCRT.h"
-#include "nsIDOMSVGLength.h"
 #include "nsContentUtils.h"