Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge the last PGO-green inbound changeset to m-c.

  • Loading branch information...
commit c4d52ce2d321fb9012af10611a8b9c3753d5ab86 2 parents eda85e3 + 48684a1
Ryan VanderMeulen rvandermeulen authored
Showing with 7,015 additions and 4,644 deletions.
  1. +1 −1  browser/base/content/browser-social.js
  2. +1 −1  browser/base/content/test/social/blocklist.xml
  3. +52 −41 browser/base/content/test/social/browser_addons.js
  4. +29 −23 browser/base/content/test/social/browser_blocklist.js
  5. +8 −0 browser/base/content/test/social/head.js
  6. +1 −1  browser/extensions/pdfjs/README.mozilla
  7. +155 −0 browser/extensions/pdfjs/components/PdfRedirector.js
  8. +15 −16 browser/extensions/pdfjs/components/PdfStreamConverter.js
  9. +23 −4 browser/extensions/pdfjs/content/PdfJs.jsm
  10. +260 −65 browser/extensions/pdfjs/content/build/pdf.js
  11. +5 −0 browser/extensions/pdfjs/content/web/viewer.css
  12. +46 −49 browser/extensions/pdfjs/content/web/viewer.js
  13. +1 −0  browser/extensions/pdfjs/extension-files
  14. +103 −64 browser/metro/base/content/contenthandlers/SelectionHandler.js
  15. +2 −2 browser/modules/Social.jsm
  16. +22 −6 build/mobile/sutagent/android/DoCommand.java
  17. +2 −3 configure.in
  18. +9 −0 content/base/public/nsContentUtils.h
  19. +6 −0 content/base/public/nsIDocument.h
  20. +1 −1  content/base/src/DocumentFragment.cpp
  21. +12 −0 content/base/src/DocumentFragment.h
  22. +36 −12 content/base/src/Element.cpp
  23. +22 −0 content/base/src/nsContentUtils.cpp
  24. +33 −0 content/base/src/nsDocument.cpp
  25. +6 −0 content/base/src/nsDocument.h
  26. +3 −1 content/base/src/nsDocumentEncoder.cpp
  27. +4 −2 content/base/src/nsINode.cpp
  28. +43 −0 content/base/src/nsNodeUtils.cpp
  29. +16 −0 content/base/src/nsNodeUtils.h
  30. +7 −2 content/html/content/public/nsITextControlElement.h
  31. +94 −0 content/html/content/src/HTMLTemplateElement.cpp
  32. +59 −0 content/html/content/src/HTMLTemplateElement.h
  33. +9 −0 content/html/content/src/HTMLTextAreaElement.cpp
  34. +1 −0  content/html/content/src/HTMLTextAreaElement.h
  35. +2 −0  content/html/content/src/Makefile.in
  36. +1 −0  content/html/content/src/nsGenericHTMLElement.h
  37. +14 −0 content/html/content/src/nsHTMLInputElement.cpp
  38. +1 −0  content/html/content/src/nsHTMLInputElement.h
  39. +3 −1 content/html/content/src/nsTextEditorState.cpp
  40. +2 −0  content/html/content/src/nsTextEditorState.h
  41. +1 −0  content/html/content/test/test_bug389797.html
  42. +53 −68 content/html/document/src/nsHTMLDocument.cpp
  43. +4 −4 content/html/document/src/nsHTMLDocument.h
  44. +3 −4 content/html/document/src/nsIHTMLDocument.h
  45. +1 −1  content/media/webaudio/AudioContext.cpp
  46. +1 −1  content/media/webaudio/test/test_delayNode.html
  47. +2 −2 db/sqlite3/README.MOZILLA
  48. +1,309 −614 db/sqlite3/src/sqlite3.c
  49. +14 −4 db/sqlite3/src/sqlite3.h
  50. +16 −13 dom/alarm/test/test_alarm_non_permitted_app.html
  51. +0 −1  dom/alarm/test/test_alarm_permitted_app.html
  52. +39 −10 dom/apps/src/FreeSpaceWatcher.jsm
  53. +4 −0 dom/apps/src/Webapps.js
  54. +40 −18 dom/apps/src/Webapps.jsm
  55. +4 −3 dom/base/nsDOMClassInfo.cpp
  56. +6 −0 dom/bindings/Bindings.conf
  57. +1 −0  dom/bluetooth/BluetoothOppManager.cpp
  58. +29 −19 dom/bluetooth/linux/BluetoothDBusService.cpp
  59. +17 −14 dom/mms/src/ril/MmsService.js
  60. +2 −1  dom/power/moz.build
  61. +5 −5 dom/power/test/test_power_basics.html
  62. +1 −0  dom/tests/browser/browser_bug396843.js
  63. +1 −0  dom/tests/mochitest/bugs/test_bug396843.html
  64. +1 −0  dom/tests/mochitest/webcomponents/Makefile.in
  65. +145 −0 dom/tests/mochitest/webcomponents/test_template.html
  66. +15 −0 dom/webidl/HTMLTemplateElement.webidl
  67. +1 −0  dom/webidl/WebIDL.mk
  68. +1 −0  editor/libeditor/html/nsHTMLEditUtils.cpp
  69. +2 −0  gfx/cairo/README
  70. +9 −1 gfx/cairo/cairo/src/cairo-xlib-surface.c
  71. +66 −0 gfx/cairo/xlib-flush-glyphs.patch
  72. +11 −1 gfx/thebes/gfxPlatform.cpp
  73. +1 −0  ipc/ipdl/ipdl/builtin.py
  74. +10 −3 ipc/ipdl/ipdl/lower.py
  75. +6 −2 js/public/MemoryMetrics.h
  76. +5 −5 js/src/Makefile.in
  77. +4 −4 js/src/builtin/ParallelArray.cpp
  78. +15 −0 js/src/configure.in
  79. +1 −1  js/src/frontend/Parser-inl.h
  80. +34 −11 js/src/frontend/Parser.cpp
  81. +10 −4 js/src/frontend/Parser.h
  82. +41 −1 js/src/frontend/TokenStream.h
  83. +1 −1  js/src/gc/Barrier.h
  84. +32 −0 js/src/jit-test/tests/asm.js/testBasic.js
  85. +1 −1  js/src/jit-test/tests/auto-regress/bug680797.js
  86. +6 −0 js/src/jit-test/tests/basic/bug854137.js
  87. +1 −1  js/src/jsfun.h
  88. +37 −0 js/src/jsobj.cpp
  89. +1 −1  js/src/jsobj.h
  90. +1 −36 js/src/jsobjinlines.h
  91. +0 −1  js/src/jstypedarray.cpp
  92. +23 −5 js/xpconnect/src/XPCJSRuntime.cpp
  93. 0  layout/base/crashtests/317934-1-inner.html
  94. 0  layout/forms/crashtests/317502-1.xhtml
  95. 0  layout/generic/crashtests/289864-1.html
  96. 0  layout/generic/crashtests/289864-1.jpg
  97. 0  layout/generic/crashtests/592118.html
  98. +48 −2 layout/generic/nsContainerFrame.cpp
  99. 0  layout/generic/test/file_bug514732_window.xul
  100. +1 −0  layout/moz.build
  101. 0  layout/reftests/backgrounds/green-circle-alpha-32x32.png
  102. 0  layout/reftests/fonts/sil/PigLatinBenchmark_v3.ttf
  103. 0  layout/reftests/fonts/sil/Scheherazade-R 2012-07-03c.ttf
  104. 0  layout/style/crashtests/592698-1.html
  105. +1 −1  layout/style/html.css
  106. 0  layout/svg/crashtests/322215-1.svg
  107. +4 −1 layout/svg/nsSVGTextFrame2.cpp
  108. 0  layout/tables/crashtests/308752-1-inner.html
  109. 0  layout/tables/crashtests/308752-2-inner.html
  110. 0  layout/tables/crashtests/316636-1.html
  111. +19 −0 layout/tools/recording/Makefile.in
  112. +4 −0 layout/tools/recording/jar.mn
  113. +6 −0 layout/tools/recording/moz.build
  114. +73 −0 layout/tools/recording/recording-cmdline.js
  115. +3 −0  layout/tools/recording/recording-cmdline.manifest
  116. +53 −0 layout/tools/recording/recording.js
  117. +22 −0 layout/tools/recording/recording.xul
  118. 0  layout/xul/grid/crashtests/311710-1.xul
  119. 0  layout/xul/grid/crashtests/312784-1.xul
  120. 0  layout/xul/grid/crashtests/313173-1-inner.xul
  121. +1 −1  media/libcubeb/README_MOZILLA
  122. +9 −3 media/libcubeb/src/cubeb_opensl.c
  123. +1 −1  media/libcubeb/update.sh
  124. +32 −10 media/mtransport/nricectx.cpp
  125. +3 −0  media/mtransport/nricectx.h
  126. +5 −4 media/mtransport/test/transport_unittests.cpp
  127. +90 −21 media/mtransport/transportflow.cpp
  128. +12 −5 media/mtransport/transportflow.h
  129. +23 −20 media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp
  130. +54 −40 media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
  131. +17 −13 media/webrtc/signaling/src/mediapipeline/MediaPipeline.h
  132. +19 −45 media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
  133. +2 −2 media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
  134. +99 −25 media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
  135. +34 −32 media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
  136. +20 −6 media/webrtc/signaling/test/mediapipeline_unittest.cpp
  137. +9 −25 media/webrtc/signaling/test/signaling_unittests.cpp
  138. +101 −76 mfbt/TypeTraits.h
  139. +19 −3 mobile/android/base/GeckoApp.java
  140. +10 −4 mobile/android/base/GeckoAppShell.java
  141. +3 −5 mobile/android/base/TextSelection.java
  142. +29 −18 mobile/android/base/WebAppAllocator.java
  143. +1 −1  mobile/android/build.mk
  144. +103 −0 mobile/android/chrome/content/ConsoleAPI.js
  145. +64 −0 mobile/android/chrome/content/MemoryObserver.js
  146. +55 −72 mobile/android/chrome/content/SelectionHandler.js
  147. +100 −0 mobile/android/chrome/content/WebrtcUI.js
  148. +104 −345 mobile/android/chrome/content/browser.js
  149. +3 −0  mobile/android/chrome/jar.mn
  150. +2 −0  mobile/android/installer/package-manifest.in
  151. +1 −1  netwerk/base/src/nsMediaFragmentURIParser.cpp
  152. +25 −1 netwerk/sctp/datachannel/DataChannel.cpp
  153. +10 −5 parser/html/javasrc/ElementName.java
  154. +6 −4 parser/html/javasrc/MetaScanner.java
  155. +6 −4 parser/html/javasrc/Tokenizer.java
  156. +399 −197 parser/html/javasrc/TreeBuilder.java
  157. +6 −0 parser/html/nsHtml5ArrayCopy.h
  158. +4 −4 parser/html/nsHtml5AtomList.h
  159. +1 −1  parser/html/nsHtml5AttributeName.cpp
  160. +83 −79 parser/html/nsHtml5ElementName.cpp
  161. +1 −0  parser/html/nsHtml5ElementName.h
  162. +4 −4 parser/html/nsHtml5MetaScanner.cpp
  163. +10 −10 parser/html/nsHtml5Tokenizer.cpp
  164. +302 −84 parser/html/nsHtml5TreeBuilder.cpp
  165. +25 −14 parser/html/nsHtml5TreeBuilder.h
  166. +10 −0 parser/html/nsHtml5TreeBuilderCppSupplement.h
  167. +2 −0  parser/html/nsHtml5TreeBuilderHSupplement.h
  168. +9 −0 parser/html/nsHtml5TreeOperation.cpp
  169. +1 −0  parser/html/nsHtml5TreeOperation.h
  170. +1 −0  parser/htmlparser/public/nsHTMLTagList.h
  171. +9 −0 parser/htmlparser/src/nsElementTable.cpp
  172. +2 −0  parser/htmlparser/src/nsHTMLTags.cpp
  173. +21 −15 security/manager/boot/src/nsSTSPreloadList.errors
  174. +33 −6 security/manager/boot/src/nsSTSPreloadList.inc
  175. +10 −6 services/datareporting/policy.jsm
  176. +2 −1  services/datareporting/tests/xpcshell/test_policy.js
  177. +3 −0  testing/mochitest/Makefile.in
  178. +0 −2  testing/mochitest/b2g.json
  179. +6 −6 toolkit/components/social/SocialService.jsm
  180. +0 −9 toolkit/content/widgets/textbox.xml
  181. +303 −0 tools/profiler/BreakpadSampler.cpp
  182. +14 −29 tools/profiler/GeckoProfilerFunc.h
  183. +14 −65 tools/profiler/GeckoProfilerImpl.h
  184. +3 −2 tools/profiler/Makefile.in
  185. +120 −38 tools/profiler/{ProfileEntry2.cpp → ProfileEntry.cpp}
  186. +29 −18 tools/profiler/{ProfileEntry2.h → ProfileEntry.h}
  187. +111 −0 tools/profiler/SaveProfileTask.h
  188. +19 −841 tools/profiler/TableTicker.cpp
  189. +105 −0 tools/profiler/TableTicker.h
  190. +0 −1,007 tools/profiler/TableTicker2.cpp
  191. +37 −37 tools/profiler/UnwinderThread2.cpp
  192. +4 −4 tools/profiler/UnwinderThread2.h
  193. +451 −0 tools/profiler/platform.cpp
  194. +17 −1 tools/profiler/platform.h
  195. +14 −0 uriloader/exthandler/nsExternalHelperAppService.cpp
  196. +1 −1  widget/xpwidgets/nsNativeTheme.h
  197. +363 −208 xpcom/base/nsCycleCollector.cpp
  198. +8 −1 xpcom/base/nsCycleCollector.h
  199. +8 −2 xpcom/build/nsXPComInit.cpp
2  browser/base/content/browser-social.js
View
@@ -226,7 +226,7 @@ let SocialUI = {
return;
}
}
- Social.installProvider(targetDoc.location.href, data, function(manifest) {
+ Social.installProvider(targetDoc, data, function(manifest) {
this.doActivation(manifest.origin);
}.bind(this));
},
2  browser/base/content/test/social/blocklist.xml
View
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
<emItems>
- <emItem blockID="s1" id="bad.com@services.mozilla.org"></emItem>
+ <emItem blockID="s1" id="test1.example.com@services.mozilla.org"></emItem>
</emItems>
</blocklist>
93 browser/base/content/test/social/browser_addons.js
View
@@ -17,10 +17,10 @@ let manifest = { // normal provider
};
let manifest2 = { // used for testing install
name: "provider 2",
- origin: "https://example1.com",
- sidebarURL: "https://example1.com/browser/browser/base/content/test/social/social_sidebar.html",
- workerURL: "https://example1.com/browser/browser/base/content/test/social/social_worker.js",
- iconURL: "https://example1.com/browser/browser/base/content/test/moz.png"
+ origin: "https://test1.example.com",
+ sidebarURL: "https://test1.example.com/browser/browser/base/content/test/social/social_sidebar.html",
+ workerURL: "https://test1.example.com/browser/browser/base/content/test/social/social_worker.js",
+ iconURL: "https://test1.example.com/browser/browser/base/content/test/moz.png"
};
function test() {
@@ -174,62 +174,73 @@ var tests = {
// we expect the addon install dialog to appear, we need to accept the
// install from the dialog.
- let windowListener = {
+ info("Waiting for install dialog");
+ Services.wm.addListener({
onWindowTitleChange: function() {},
onCloseWindow: function() {},
- onOpenWindow: function(window) {
- var domwindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ onOpenWindow: function(xulwindow) {
+ Services.wm.removeListener(this);
+ var domwindow = xulwindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindow);
- var self = this;
waitForFocus(function() {
- self.windowReady(domwindow);
- }, domwindow);
- },
- windowReady: function(window) {
- if (window.document.location.href == XPINSTALL_URL) {
+ info("Saw install dialog");
+ is(domwindow.document.location.href, XPINSTALL_URL, "Should have seen the right window open");
// Initially the accept button is disabled on a countdown timer
- var button = window.document.documentElement.getButton("accept");
+ var button = domwindow.document.documentElement.getButton("accept");
button.disabled = false;
- window.document.documentElement.acceptDialog();
- Services.wm.removeListener(windowListener);
- }
+ domwindow.document.documentElement.acceptDialog();
+ }, domwindow);
}
- };
- Services.wm.addListener(windowListener);
-
- let installFrom = "https://example1.com";
- Services.prefs.setCharPref("social.whitelist", "");
- is(SocialService.getOriginActivationType(installFrom), "foreign", "testing foriegn install");
- Social.installProvider(installFrom, manifest2, function(addonManifest) {
- Services.prefs.clearUserPref("social.whitelist");
- SocialService.addBuiltinProvider(addonManifest.origin, function(provider) {
- Social.uninstallProvider(addonManifest.origin);
+ });
+
+ let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
+ addTab(activationURL, function(tab) {
+ let doc = tab.linkedBrowser.contentDocument;
+ let installFrom = doc.nodePrincipal.origin;
+ Services.prefs.setCharPref("social.whitelist", "");
+ is(SocialService.getOriginActivationType(installFrom), "foreign", "testing foriegn install");
+ Social.installProvider(doc, manifest2, function(addonManifest) {
+ Services.prefs.clearUserPref("social.whitelist");
+ SocialService.addBuiltinProvider(addonManifest.origin, function(provider) {
+ Social.uninstallProvider(addonManifest.origin);
+ gBrowser.removeTab(tab);
+ });
});
});
},
testWhitelistInstall: function(next) {
AddonManager.addAddonListener(installListener(next));
- let installFrom = "https://example1.com";
- Services.prefs.setCharPref("social.whitelist", installFrom);
- is(SocialService.getOriginActivationType(installFrom), "whitelist", "testing whitelist install");
- Social.installProvider(installFrom, manifest2, function(addonManifest) {
- Services.prefs.clearUserPref("social.whitelist");
- SocialService.addBuiltinProvider(addonManifest.origin, function(provider) {
- Social.uninstallProvider(addonManifest.origin);
+ let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
+ addTab(activationURL, function(tab) {
+ let doc = tab.linkedBrowser.contentDocument;
+ let installFrom = doc.nodePrincipal.origin;
+ Services.prefs.setCharPref("social.whitelist", installFrom);
+ is(SocialService.getOriginActivationType(installFrom), "whitelist", "testing whitelist install");
+ Social.installProvider(doc, manifest2, function(addonManifest) {
+ Services.prefs.clearUserPref("social.whitelist");
+ SocialService.addBuiltinProvider(addonManifest.origin, function(provider) {
+ Social.uninstallProvider(addonManifest.origin);
+ gBrowser.removeTab(tab);
+ });
});
});
},
testDirectoryInstall: function(next) {
AddonManager.addAddonListener(installListener(next));
- let installFrom = "https://addons.allizom.org";
- Services.prefs.setCharPref("social.directories", installFrom);
- is(SocialService.getOriginActivationType(installFrom), "directory", "testing directory install");
- Social.installProvider(installFrom, manifest2, function(addonManifest) {
- Services.prefs.clearUserPref("social.directories");
- SocialService.addBuiltinProvider(addonManifest.origin, function(provider) {
- Social.uninstallProvider(addonManifest.origin);
+ let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
+ addTab(activationURL, function(tab) {
+ let doc = tab.linkedBrowser.contentDocument;
+ let installFrom = doc.nodePrincipal.origin;
+ Services.prefs.setCharPref("social.directories", installFrom);
+ is(SocialService.getOriginActivationType(installFrom), "directory", "testing directory install");
+ Social.installProvider(doc, manifest2, function(addonManifest) {
+ Services.prefs.clearUserPref("social.directories");
+ SocialService.addBuiltinProvider(addonManifest.origin, function(provider) {
+ Social.uninstallProvider(addonManifest.origin);
+ gBrowser.removeTab(tab);
+ });
});
});
}
52 browser/base/content/test/social/browser_blocklist.js
View
@@ -11,18 +11,18 @@ let blocklistURL = "http://test:80/browser/browser/base/content/test/social/bloc
let blocklistEmpty = "http://test:80/browser/browser/base/content/test/social/blocklistEmpty.xml";
let manifest = { // normal provider
- name: "provider 1",
+ name: "provider ok",
origin: "https://example.com",
sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",
workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
iconURL: "https://example.com/browser/browser/base/content/test/moz.png"
};
let manifest_bad = { // normal provider
- name: "provider 1",
- origin: "https://bad.com",
- sidebarURL: "https://bad.com/browser/browser/base/content/test/social/social_sidebar.html",
- workerURL: "https://bad.com/browser/browser/base/content/test/social/social_worker.js",
- iconURL: "https://bad.com/browser/browser/base/content/test/moz.png"
+ name: "provider blocked",
+ origin: "https://test1.example.com",
+ sidebarURL: "https://test1.example.com/browser/browser/base/content/test/social/social_sidebar.html",
+ workerURL: "https://test1.example.com/browser/browser/base/content/test/social/social_worker.js",
+ iconURL: "https://test1.example.com/browser/browser/base/content/test/moz.png"
};
function test() {
@@ -40,10 +40,10 @@ var tests = {
var blocklist = Components.classes["@mozilla.org/extensions/blocklist;1"]
.getService(Components.interfaces.nsIBlocklistService);
setAndUpdateBlocklist(blocklistURL, function() {
- ok(blocklist.isAddonBlocklisted("bad.com@services.mozilla.org", "0", "0", "0"), "blocking 'blocked'");
- ok(!blocklist.isAddonBlocklisted("good.cpm@services.mozilla.org", "0", "0", "0"), "not blocking 'good'");
+ ok(blocklist.isAddonBlocklisted("test1.example.com@services.mozilla.org", "0", "0", "0"), "blocking 'blocked'");
+ ok(!blocklist.isAddonBlocklisted("example.com@services.mozilla.org", "0", "0", "0"), "not blocking 'good'");
setAndUpdateBlocklist(blocklistEmpty, function() {
- ok(!blocklist.isAddonBlocklisted("bad.com@services.mozilla.org", "0", "0", "0"), "blocklist cleared");
+ ok(!blocklist.isAddonBlocklisted("test1.example.com@services.mozilla.org", "0", "0", "0"), "blocklist cleared");
next();
});
});
@@ -102,20 +102,26 @@ var tests = {
Services.prefs.clearUserPref("social.whitelist");
setAndUpdateBlocklist(blocklistEmpty, next);
}
- let installFrom = "https://bad.com";
- // whitelist to avoid the 3rd party install dialog, we only want to test
- // the blocklist inside installProvider.
- Services.prefs.setCharPref("social.whitelist", installFrom);
- setAndUpdateBlocklist(blocklistURL, function() {
- try {
- // expecting an exception when attempting to install a hard blocked
- // provider
- Social.installProvider(installFrom, manifest_bad, function(addonManifest) {
- finish(false);
- });
- } catch(e) {
- finish(true);
- }
+ let activationURL = manifest_bad.origin + "/browser/browser/base/content/test/social/social_activate.html"
+ addTab(activationURL, function(tab) {
+ let doc = tab.linkedBrowser.contentDocument;
+ let installFrom = doc.nodePrincipal.origin;
+ // whitelist to avoid the 3rd party install dialog, we only want to test
+ // the blocklist inside installProvider.
+ Services.prefs.setCharPref("social.whitelist", installFrom);
+ setAndUpdateBlocklist(blocklistURL, function() {
+ try {
+ // expecting an exception when attempting to install a hard blocked
+ // provider
+ Social.installProvider(doc, manifest_bad, function(addonManifest) {
+ gBrowser.removeTab(tab);
+ finish(false);
+ });
+ } catch(e) {
+ gBrowser.removeTab(tab);
+ finish(true);
+ }
+ });
});
},
testBlockingExistingProvider: function(next) {
8 browser/base/content/test/social/head.js
View
@@ -251,3 +251,11 @@ function addWindowListener(aURL, aCallback) {
onWindowTitleChange: function(aXULWindow, aNewTitle) { }
});
}
+
+function addTab(url, callback) {
+ let tab = gBrowser.selectedTab = gBrowser.addTab(url, {skipAnimation: true});
+ tab.linkedBrowser.addEventListener("load", function tabLoad(event) {
+ tab.linkedBrowser.removeEventListener("load", tabLoad, true);
+ executeSoon(function() {callback(tab)});
+ }, true);
+}
2  browser/extensions/pdfjs/README.mozilla
View
@@ -1,4 +1,4 @@
This is the pdf.js project output, https://github.com/mozilla/pdf.js
-Current extension version is: 0.7.337
+Current extension version is: 0.7.390
155 browser/extensions/pdfjs/components/PdfRedirector.js
View
@@ -0,0 +1,155 @@
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
+/* Copyright 2012 Mozilla Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/* jshint esnext:true */
+/* globals Components, Services, XPCOMUtils, NetUtil, dump */
+
+'use strict';
+
+var EXPORTED_SYMBOLS = ['PdfRedirector'];
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cr = Components.results;
+const Cu = Components.utils;
+
+const PDF_CONTENT_TYPE = 'application/pdf';
+const FIREFOX_ID = '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}';
+
+Cu.import('resource://gre/modules/XPCOMUtils.jsm');
+Cu.import('resource://gre/modules/Services.jsm');
+Cu.import('resource://gre/modules/NetUtil.jsm');
+
+
+function getDOMWindow(aChannel) {
+ var requestor = aChannel.notificationCallbacks ?
+ aChannel.notificationCallbacks :
+ aChannel.loadGroup.notificationCallbacks;
+ var win = requestor.getInterface(Components.interfaces.nsIDOMWindow);
+ return win;
+}
+
+function getObjectUrl(window) {
+ var url;
+ var element = window.frameElement;
+ var isOverlay = false;
+ var params = {};
+ if (element) {
+ var tagName = element.nodeName;
+ while (tagName != 'EMBED' && tagName != 'OBJECT') {
+ // plugin overlay skipping until the target plugin is found
+ isOverlay = true;
+ element = element.parentNode;
+ if (!element)
+ throw 'Plugin element is not found';
+ tagName = element.nodeName;
+ }
+ if (tagName == 'EMBED') {
+ for (var i = 0; i < element.attributes.length; ++i) {
+ params[element.attributes[i].localName] = element.attributes[i].value;
+ }
+ url = params.src;
+ } else {
+ for (var i = 0; i < element.childNodes.length; ++i) {
+ var paramElement = element.childNodes[i];
+ if (paramElement.nodeType != Ci.nsIDOMNode.ELEMENT_NODE ||
+ paramElement.nodeName != 'PARAM') {
+ continue;
+ }
+
+ params[paramElement.getAttribute('name')] =
+ paramElement.getAttribute('value');
+ }
+ var dataAttribute = element.getAttribute('data');
+ url = dataAttribute || params.movie || params.src;
+ }
+ }
+ if (!url) {
+ return url; // src is not specified
+ }
+
+ var element = window.frameElement;
+ // XXX base uri?
+ var baseUri = !element ? null :
+ Services.io.newURI(element.ownerDocument.location.href, null, null);
+
+ return Services.io.newURI(url, null, baseUri).spec;
+}
+
+function PdfRedirector() {
+}
+
+PdfRedirector.prototype = {
+
+ // properties required for XPCOM registration:
+ classID: Components.ID('{8cbfd8d0-2042-4976-b3ef-d9dee1efb975}'),
+ classDescription: 'pdf.js Redirector',
+ contractID:
+ '@mozilla.org/streamconv;1?from=application/x-moz-playpreview-pdfjs&to=*/*',
+
+ QueryInterface: XPCOMUtils.generateQI([
+ Ci.nsIStreamConverter,
+ Ci.nsIStreamListener,
+ Ci.nsIRequestObserver
+ ]),
+
+ // nsIStreamConverter::convert
+ convert: function(aFromStream, aFromType, aToType, aCtxt) {
+ throw Cr.NS_ERROR_NOT_IMPLEMENTED;
+ },
+
+ // nsIStreamConverter::asyncConvertData
+ asyncConvertData: function(aFromType, aToType, aListener, aCtxt) {
+ // Store the listener passed to us
+ this.listener = aListener;
+ },
+
+ // nsIStreamListener::onDataAvailable
+ onDataAvailable: function(aRequest, aContext, aInputStream, aOffset, aCount) {
+ // Do nothing since all the data loading is handled by the viewer.
+ },
+
+ // nsIRequestObserver::onStartRequest
+ onStartRequest: function(aRequest, aContext) {
+ // Setup the request so we can use it below.
+ aRequest.QueryInterface(Ci.nsIChannel);
+ // Cancel the request so the viewer can handle it.
+ aRequest.cancel(Cr.NS_BINDING_ABORTED);
+
+ var domWindow = getDOMWindow(aRequest);
+ var pdfUrl = getObjectUrl(domWindow);
+ if (!pdfUrl) {
+ Services.console.logStringMessage(
+ 'PdfRedirector.js: PDF location is not specified for OBJECT/EMBED tag');
+ return;
+ }
+
+ // Create a new channel that is viewer loaded as a resource.
+ var ioService = Services.io;
+ var channel = ioService.newChannel(pdfUrl, null, null);
+
+ channel.loadGroup = aRequest.loadGroup;
+
+ channel.asyncOpen(this.listener, aContext);
+ },
+
+ // nsIRequestObserver::onStopRequest
+ onStopRequest: function(aRequest, aContext, aStatusCode) {
+ // Do nothing
+ }
+};
+
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([PdfRedirector]);
31 browser/extensions/pdfjs/components/PdfStreamConverter.js
View
@@ -337,6 +337,7 @@ ChromeActions.prototype = {
}, '*');
};
+ var self = this;
this.dataListener.oncomplete =
function ChromeActions_dataListenerComplete(data, errorCode) {
@@ -346,7 +347,7 @@ ChromeActions.prototype = {
errorCode: errorCode
}, '*');
- delete this.dataListener;
+ delete self.dataListener;
};
return true;
@@ -385,21 +386,19 @@ ChromeActions.prototype = {
var message = getLocalizedString(strings, 'unsupported_feature');
var notificationBox = null;
- // Multiple browser windows can be opened, finding one for notification box
- var windowsEnum = Services.wm
- .getZOrderDOMWindowEnumerator('navigator:browser', true);
- while (windowsEnum.hasMoreElements()) {
- var win = windowsEnum.getNext();
- if (win.closed)
- continue;
- var browser = win.gBrowser.getBrowserForDocument(domWindow.top.document);
- if (browser) {
- // right window/browser is found, getting the notification box
- notificationBox = win.gBrowser.getNotificationBox(browser);
- break;
- }
- }
- if (!notificationBox) {
+ try {
+ // Based on MDN's "Working with windows in chrome code"
+ var mainWindow = domWindow
+ .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIWebNavigation)
+ .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
+ .rootTreeItem
+ .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIDOMWindow);
+ var browser = mainWindow.gBrowser
+ .getBrowserForDocument(domWindow.top.document);
+ notificationBox = mainWindow.gBrowser.getNotificationBox(browser);
+ } catch (e) {
log('Unable to get a notification box for the fallback message');
return;
}
27 browser/extensions/pdfjs/content/PdfJs.jsm
View
@@ -33,11 +33,15 @@ const PDF_CONTENT_TYPE = 'application/pdf';
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://pdf.js.components/PdfStreamConverter.js');
+Cu.import('resource://pdf.js.components/PdfRedirector.js');
let Svc = {};
XPCOMUtils.defineLazyServiceGetter(Svc, 'mime',
'@mozilla.org/mime;1',
'nsIMIMEService');
+XPCOMUtils.defineLazyServiceGetter(Svc, 'pluginHost',
+ '@mozilla.org/plugin/host;1',
+ 'nsIPluginHost');
function getBoolPref(aPref, aDefaultValue) {
try {
@@ -55,8 +59,10 @@ function getIntPref(aPref, aDefaultValue) {
}
}
-// Register/unregister a constructor as a component.
-let Factory = {
+// Factory that registers/unregisters a constructor as a component.
+function Factory() {}
+
+Factory.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory]),
_targetConstructor: null,
@@ -193,7 +199,14 @@ let PdfJs = {
if (this._registered)
return;
- Factory.register(PdfStreamConverter);
+ this._pdfStreamConverterFactory = new Factory();
+ this._pdfStreamConverterFactory.register(PdfStreamConverter);
+
+ this._pdfRedirectorFactory = new Factory();
+ this._pdfRedirectorFactory.register(PdfRedirector);
+ Svc.pluginHost.registerPlayPreviewMimeType('application/pdf', true,
+ 'data:application/x-moz-playpreview-pdfjs;,');
+
this._registered = true;
},
@@ -201,7 +214,13 @@ let PdfJs = {
if (!this._registered)
return;
- Factory.unregister();
+ this._pdfStreamConverterFactory.unregister();
+ delete this._pdfStreamConverterFactory;
+
+ this._pdfRedirectorFactory.unregister;
+ delete this._pdfRedirectorFactory;
+ Svc.pluginHost.unregisterPlayPreviewMimeType('application/pdf');
+
this._registered = false;
}
};
325 browser/extensions/pdfjs/content/build/pdf.js
View
@@ -16,8 +16,8 @@
*/
var PDFJS = {};
-PDFJS.version = '0.7.337';
-PDFJS.build = 'f58aee1';
+PDFJS.version = '0.7.390';
+PDFJS.build = '921f321';
(function pdfjsWrapper() {
// Use strict in our context only - users might not want it
@@ -832,6 +832,23 @@ var Util = PDFJS.Util = (function UtilClosure() {
return [xt, yt];
};
+ // Applies the transform to the rectangle and finds the minimum axially
+ // aligned bounding box.
+ Util.getAxialAlignedBoundingBox =
+ function Util_getAxialAlignedBoundingBox(r, m) {
+
+ var p1 = Util.applyTransform(r, m);
+ var p2 = Util.applyTransform(r.slice(2, 4), m);
+ var p3 = Util.applyTransform([r[0], r[3]], m);
+ var p4 = Util.applyTransform([r[2], r[1]], m);
+ return [
+ Math.min(p1[0], p2[0], p3[0], p4[0]),
+ Math.min(p1[1], p2[1], p3[1], p4[1]),
+ Math.max(p1[0], p2[0], p3[0], p4[0]),
+ Math.max(p1[1], p2[1], p3[1], p4[1])
+ ];
+ };
+
Util.inverseTransform = function Util_inverseTransform(m) {
var d = m[0] * m[3] - m[1] * m[2];
return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d,
@@ -2260,6 +2277,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.objs = objs;
this.textLayer = textLayer;
this.imageLayer = imageLayer;
+ this.groupStack = [];
if (canvasCtx) {
addContextCurrentTransform(canvasCtx);
}
@@ -2392,6 +2410,25 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
return tmpCanvas;
}
+ function copyCtxState(sourceCtx, destCtx) {
+ var properties = ['strokeStyle', 'fillStyle', 'fillRule', 'globalAlpha',
+ 'lineWidth', 'lineCap', 'lineJoin', 'miterLimit',
+ 'globalCompositeOperation', 'font'];
+ for (var i = 0, ii = properties.length; i < ii; i++) {
+ var property = properties[i];
+ if (property in sourceCtx) {
+ destCtx[property] = sourceCtx[property];
+ }
+ }
+ if ('setLineDash' in sourceCtx) {
+ destCtx.setLineDash(sourceCtx.getLineDash());
+ destCtx.lineDashOffset = sourceCtx.lineDashOffset;
+ } else if ('mozDash' in sourceCtx) {
+ destCtx.mozDash = sourceCtx.mozDash;
+ destCtx.mozDashOffset = sourceCtx.mozDashOffset;
+ }
+ }
+
var LINE_CAP_STYLES = ['butt', 'round', 'square'];
var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
var NORMAL_CLIP = {};
@@ -2596,6 +2633,22 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.current.fillAlpha = state[1];
this.ctx.globalAlpha = state[1];
break;
+ case 'BM':
+ if (value && value.name && (value.name !== 'Normal')) {
+ var mode = value.name.replace(/([A-Z])/g,
+ function(c) {
+ return '-' + c.toLowerCase();
+ }
+ ).substring(1);
+ this.ctx.globalCompositeOperation = mode;
+ if (this.ctx.globalCompositeOperation !== mode) {
+ warn('globalCompositeOperation "' + mode +
+ '" is not supported');
+ }
+ } else {
+ this.ctx.globalCompositeOperation = 'source-over';
+ }
+ break;
}
}
},
@@ -3008,7 +3061,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var character = glyph.fontChar;
var vmetric = glyph.vmetric || defaultVMetrics;
if (vertical) {
- var vx = vmetric[1] * fontSize * current.fontMatrix[0];
+ var vx = glyph.vmetric ? vmetric[1] : glyph.width * 0.5;
+ vx = -vx * fontSize * current.fontMatrix[0];
var vy = vmetric[2] * fontSize * current.fontMatrix[0];
}
var width = vmetric ? -vmetric[0] : glyph.width;
@@ -3083,7 +3137,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
geom.canvasWidth = canvasWidth;
if (vertical) {
var vmetric = font.defaultVMetrics;
- geom.x -= vmetric[1] * fontSize * current.fontMatrix[0] /
+ geom.x += vmetric[1] * fontSize * current.fontMatrix[0] /
fontSizeScale * geom.hScale;
geom.y += vmetric[2] * fontSize * current.fontMatrix[0] /
fontSizeScale * geom.vScale;
@@ -3144,7 +3198,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (vertical) {
var fontSizeScale = current.fontSizeScale;
var vmetric = font.defaultVMetrics;
- geom.x -= vmetric[1] * fontSize * current.fontMatrix[0] /
+ geom.x += vmetric[1] * fontSize * current.fontMatrix[0] /
fontSizeScale * geom.hScale;
geom.y += vmetric[2] * fontSize * current.fontMatrix[0] /
fontSizeScale * geom.vScale;
@@ -3365,6 +3419,89 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
} while (this.current.paintFormXObjectDepth >= depth);
},
+ beginGroup: function CanvasGraphics_beginGroup(group) {
+ this.save();
+ var currentCtx = this.ctx;
+ // TODO non-isolated groups - according to Rik at adobe non-isolated
+ // group results aren't usually that different and they even have tools
+ // that ignore this setting. Notes from Rik on implmenting:
+ // - When you encounter an transparency group, create a new canvas with
+ // the dimensions of the bbox
+ // - copy the content from the previous canvas to the new canvas
+ // - draw as usual
+ // - remove the backdrop alpha:
+ // alphaNew = 1 - (1 - alpha)/(1 - alphaBackdrop) with 'alpha' the alpha
+ // value of your transparency group and 'alphaBackdrop' the alpha of the
+ // backdrop
+ // - remove background color:
+ // colorNew = color - alphaNew *colorBackdrop /(1 - alphaNew)
+ if (!group.isolated) {
+ TODO('Support non-isolated groups.');
+ }
+
+ // TODO knockout - supposedly possible with the clever use of compositing
+ // modes.
+ if (group.knockout) {
+ TODO('Support knockout groups.');
+ }
+
+ var currentTransform = currentCtx.mozCurrentTransform;
+ if (group.matrix) {
+ currentCtx.transform.apply(currentCtx, group.matrix);
+ }
+ assert(group.bbox, 'Bounding box is required.');
+
+ // Based on the current transform figure out how big the bounding box
+ // will actually be.
+ var bounds = Util.getAxialAlignedBoundingBox(
+ group.bbox,
+ currentCtx.mozCurrentTransform);
+ // Use ceil in case we're between sizes so we don't create canvas that is
+ // too small.
+ var drawnWidth = Math.ceil(bounds[2] - bounds[0]);
+ var drawnHeight = Math.ceil(bounds[3] - bounds[1]);
+ var scratchCanvas = createScratchCanvas(drawnWidth, drawnHeight);
+ var groupCtx = scratchCanvas.getContext('2d');
+ addContextCurrentTransform(groupCtx);
+ // Since we created a new canvas that is just the size of the bounding box
+ // we have to translate the group ctx.
+ var offsetX = bounds[0];
+ var offsetY = bounds[1];
+ groupCtx.translate(-offsetX, -offsetY);
+ groupCtx.transform.apply(groupCtx, currentTransform);
+
+ // Setup the current ctx so when the group is popped we draw it the right
+ // location.
+ currentCtx.setTransform(1, 0, 0, 1, 0, 0);
+ currentCtx.translate(offsetX, offsetY);
+
+ // The transparency group inherits all off the current graphics state
+ // except the blend mode, soft mask, and alpha constants.
+ copyCtxState(currentCtx, groupCtx);
+ this.ctx = groupCtx;
+ this.setGState([
+ ['SMask', 'None'],
+ ['BM', 'Normal'],
+ ['ca', 1],
+ ['CA', 1]
+ ]);
+ this.groupStack.push(currentCtx);
+ },
+
+ endGroup: function CanvasGraphics_endGroup(group) {
+ var groupCtx = this.ctx;
+ this.ctx = this.groupStack.pop();
+ // Turn off image smoothing to avoid sub pixel interpolation which can
+ // look kind of blurry for some pdfs.
+ if ('imageSmoothingEnabled' in this.ctx) {
+ this.ctx.imageSmoothingEnabled = false;
+ } else {
+ this.ctx.mozImageSmoothingEnabled = false;
+ }
+ this.ctx.drawImage(groupCtx.canvas, 0, 0);
+ this.restore();
+ },
+
paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
var domImage = this.objs.get(objId);
if (!domImage) {
@@ -3920,7 +4057,7 @@ var Catalog = (function CatalogClosure() {
if (isStream(js)) {
js = bytesToString(js.getBytes());
}
- javaScript.push(js);
+ javaScript.push(stringToPDFString(js));
}
}
return shadow(this, 'javaScript', javaScript);
@@ -4385,6 +4522,9 @@ var NameTree = (function NameTreeClosure() {
while (queue.length > 0) {
var i, n;
var obj = xref.fetchIfRef(queue.shift());
+ if (!isDict(obj)) {
+ continue;
+ }
if (obj.has('Kids')) {
var kids = obj.get('Kids');
for (i = 0, n = kids.length; i < n; i++) {
@@ -14652,6 +14792,60 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return loadedName;
}
+ function buildFormXObject(xobj, smask) {
+ var matrix = xobj.dict.get('Matrix');
+ var bbox = xobj.dict.get('BBox');
+ var group = xobj.dict.get('Group');
+ if (group) {
+ var groupOptions = {
+ matrix: matrix,
+ bbox: bbox,
+ smask: !!smask,
+ isolated: false,
+ knockout: false
+ };
+
+ var groupSubtype = group.get('S');
+ if (isName(groupSubtype) && groupSubtype.name === 'Transparency') {
+ groupOptions.isolated = group.get('I') || false;
+ groupOptions.knockout = group.get('K') || false;
+ // There is also a group colorspace, but since we put everything in
+ // RGB I'm not sure we need it.
+ }
+ fnArray.push('beginGroup');
+ argsArray.push([groupOptions]);
+ }
+
+ fnArray.push('paintFormXObjectBegin');
+ argsArray.push([matrix, bbox]);
+
+ // This adds the operatorList of the xObj to the current queue.
+ var depIdx = dependencyArray.length;
+
+ // Pass in the current `queue` object. That means the `fnArray`
+ // and the `argsArray` in this scope is reused and new commands
+ // are added to them.
+ self.getOperatorList(xobj,
+ xobj.dict.get('Resources') || resources,
+ dependencyArray, queue);
+
+ self.getOperatorList(xobj,
+ xobj.dict.get('Resources') || resources,
+ dependencyArray, queue);
+
+ // Add the dependencies that are required to execute the
+ // operatorList.
+ insertDependency(dependencyArray.slice(depIdx));
+
+ fnArray.push('paintFormXObjectEnd');
+ argsArray.push([]);
+
+ if (group) {
+ fnArray.push('endGroup');
+ argsArray.push([groupOptions]);
+ }
+ }
+
function buildPaintImageXObject(image, inline) {
var dict = image.dict;
var w = dict.get('Width', 'W');
@@ -14825,28 +15019,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
);
if ('Form' == type.name) {
- var matrix = xobj.dict.get('Matrix');
- var bbox = xobj.dict.get('BBox');
-
- fnArray.push('paintFormXObjectBegin');
- argsArray.push([matrix, bbox]);
-
- // This adds the operatorList of the xObj to the current queue.
- var depIdx = dependencyArray.length;
-
- // Pass in the current `queue` object. That means the `fnArray`
- // and the `argsArray` in this scope is reused and new commands
- // are added to them.
- this.getOperatorList(xobj,
- xobj.dict.get('Resources') || resources,
- dependencyArray, queue);
-
- // Add the dependencies that are required to execute the
- // operatorList.
- insertDependency(dependencyArray.slice(depIdx));
-
- fn = 'paintFormXObjectEnd';
+ buildFormXObject(xobj);
args = [];
+ continue;
} else if ('Image' == type.name) {
buildPaintImageXObject(xobj, false);
} else {
@@ -14905,6 +15080,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
case 'FL':
case 'CA':
case 'ca':
+ case 'BM':
gsStateObj.push([key, value]);
break;
case 'Font':
@@ -14914,11 +15090,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
value[1]
]);
break;
- case 'BM':
- // We support the default so don't trigger the TODO.
- if (!isName(value) || value.name != 'Normal')
- TODO('graphic state operator ' + key);
- break;
case 'SMask':
// We support the default so don't trigger the TODO.
if (!isName(value) || value.name != 'None')
@@ -15459,7 +15630,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
if (properties.vertical) {
var vmetrics = dict.get('DW2') || [880, -1000];
- defaultVMetrics = [vmetrics[1], vmetrics[1] / 2, vmetrics[0]];
+ defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
vmetrics = dict.get('W2');
if (vmetrics) {
for (var i = 0, ii = vmetrics.length; i < ii; i++) {
@@ -16073,7 +16244,23 @@ var nonStdFontMap = {
'LucidaConsole': 'Courier',
'LucidaConsole-Bold': 'Courier-Bold',
'LucidaConsole-BoldItalic': 'Courier-BoldOblique',
- 'LucidaConsole-Italic': 'Courier-Oblique'
+ 'LucidaConsole-Italic': 'Courier-Oblique',
+ 'MS-Gothic': 'MS Gothic',
+ 'MS-Gothic-Bold': 'MS Gothic-Bold',
+ 'MS-Gothic-BoldItalic': 'MS Gothic-BoldItalic',
+ 'MS-Gothic-Italic': 'MS Gothic-Italic',
+ 'MS-Mincho': 'MS Mincho',
+ 'MS-Mincho-Bold': 'MS Mincho-Bold',
+ 'MS-Mincho-BoldItalic': 'MS Mincho-BoldItalic',
+ 'MS-Mincho-Italic': 'MS Mincho-Italic',
+ 'MS-PGothic': 'MS PGothic',
+ 'MS-PGothic-Bold': 'MS PGothic-Bold',
+ 'MS-PGothic-BoldItalic': 'MS PGothic-BoldItalic',
+ 'MS-PGothic-Italic': 'MS PGothic-Italic',
+ 'MS-PMincho': 'MS PMincho',
+ 'MS-PMincho-Bold': 'MS PMincho-Bold',
+ 'MS-PMincho-BoldItalic': 'MS PMincho-BoldItalic',
+ 'MS-PMincho-Italic': 'MS PMincho-Italic',
};
var serifFonts = {
@@ -16139,6 +16326,7 @@ var CMapConverterList = {
'90msp-RKSJ-H': sjisToUnicode,
'90msp-RKSJ-V': sjisToUnicode,
'GBK-EUC-H': gbkToUnicode,
+ 'B5pc-H': big5ToUnicode,
'ETenms-B5-H': big5ToUnicode,
'ETenms-B5-V': big5ToUnicode,
};
@@ -18164,8 +18352,8 @@ var Font = (function FontClosure() {
}
var bmpLength = i + 1;
- var trailingRangesCount = ranges[bmpLength - 1][1] < 0xFFFF ? 1 : 0;
- var segCount = bmpLength + trailingRangesCount;
+ if (ranges[i][1] === 0xFFFF) { ranges[i][1] = 0xFFFE; }
+ var segCount = bmpLength + 1;
var segCount2 = segCount * 2;
var searchRange = getMaxPower2(segCount) * 2;
var searchEntry = Math.log(segCount) / Math.log(2);
@@ -18210,12 +18398,10 @@ var Font = (function FontClosure() {
}
}
- if (trailingRangesCount > 0) {
- endCount += '\xFF\xFF';
- startCount += '\xFF\xFF';
- idDeltas += '\x00\x01';
- idRangeOffsets += '\x00\x00';
- }
+ endCount += '\xFF\xFF';
+ startCount += '\xFF\xFF';
+ idDeltas += '\x00\x01';
+ idRangeOffsets += '\x00\x00';
var format314 = '\x00\x00' + // language
string16(segCount2) +
@@ -18302,6 +18488,14 @@ var Font = (function FontClosure() {
if (firstChar > lastChar) {
return false;
}
+ stream.getBytes(6); // skipping sTypoAscender/Descender/LineGap
+ var usWinAscent = int16(stream.getBytes(2));
+ if (usWinAscent === 0) { // makes font unreadable by windows
+ return false;
+ }
+
+ // OS/2 appears to be valid, resetting some fields
+ os2.data[8] = os2.data[9] = 0; // IE rejects fonts if fsType != 0
return true;
}
@@ -19151,16 +19345,6 @@ var Font = (function FontClosure() {
return names;
}
- function isOS2Valid(os2Table) {
- var data = os2Table.data;
- // usWinAscent == 0 makes font unreadable by windows
- var usWinAscent = (data[74] << 8) | data[75];
- if (usWinAscent === 0)
- return false;
-
- return true;
- }
-
var TTOpsStackDeltas = [
0, 0, 0, 0, 0, 0, 0, 0, -2, -2, -2, -2, 0, 0, -2, -5,
-1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, -1, -1, -1, -1,
@@ -19355,12 +19539,6 @@ var Font = (function FontClosure() {
// of missing tables
createOpenTypeHeader(header.version, ttf, numTables);
- // Invalid OS/2 can break the font for the Windows
- if (os2 && !isOS2Valid(os2)) {
- tables.splice(tables.indexOf(os2), 1);
- os2 = null;
- }
-
// Ensure the hmtx table contains the advance width and
// sidebearings information for numGlyphs in the maxp table
font.pos = (font.start || 0) + maxp.offset;
@@ -21658,10 +21836,19 @@ var CFFParser = (function CFFParserClosure() {
}
return { charStrings: charStrings, seacs: seacs };
},
+ emptyPrivateDictionary:
+ function CFFParser_emptyPrivateDictionary(parentDict) {
+ var privateDict = this.createDict(CFFPrivateDict, [],
+ parentDict.strings);
+ parentDict.setByKey(18, [0, 0]);
+ parentDict.privateDict = privateDict;
+ },
parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
// no private dict, do nothing
- if (!parentDict.hasName('Private'))
+ if (!parentDict.hasName('Private')) {
+ this.emptyPrivateDictionary(parentDict);
return;
+ }
var privateOffset = parentDict.getByName('Private');
// make sure the params are formatted correctly
if (!isArray(privateOffset) || privateOffset.length !== 2) {
@@ -21672,7 +21859,7 @@ var CFFParser = (function CFFParserClosure() {
var offset = privateOffset[1];
// remove empty dicts or ones that refer to invalid location
if (size === 0 || offset >= this.bytes.length) {
- parentDict.removeByName('Private');
+ this.emptyPrivateDictionary(parentDict);
return;
}
@@ -21690,7 +21877,7 @@ var CFFParser = (function CFFParserClosure() {
var relativeOffset = offset + subrsOffset;
// Validate the offset.
if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
- privateDict.removeByName('Subrs');
+ this.emptyPrivateDictionary(parentDict);
return;
}
var subrsIndex = this.parseIndex(relativeOffset);
@@ -22371,15 +22558,23 @@ var CFFCompiler = (function CFFCompilerClosure() {
output) {
for (var i = 0, ii = dicts.length; i < ii; ++i) {
var fontDict = dicts[i];
- if (!fontDict.privateDict || !fontDict.hasName('Private'))
- continue;
+ assert(fontDict.privateDict && fontDict.hasName('Private'),
+ 'There must be an private dictionary.');
var privateDict = fontDict.privateDict;
var privateDictTracker = new CFFOffsetTracker();
var privateDictData = this.compileDict(privateDict, privateDictTracker);
- privateDictTracker.offset(output.length);
+ var outputLength = output.length;
+ privateDictTracker.offset(outputLength);
+ if (!privateDictData.length) {
+ // The private dictionary was empty, set the output length to zero to
+ // ensure the offset length isn't out of bounds in the eyes of the
+ // sanitizer.
+ outputLength = 0;
+ }
+
trackers[i].setEntryLocation('Private',
- [privateDictData.length, output.length],
+ [privateDictData.length, outputLength],
output);
output.add(privateDictData);
5 browser/extensions/pdfjs/content/web/viewer.css
View
@@ -826,6 +826,11 @@ html[dir='rtl'] .toolbarButton.pageDown::before {
padding-top: 4px;
}
+#viewBookmark[href='#'] {
+ opacity: .5;
+ pointer-events: none;
+}
+
.toolbarButton.bookmark::before {
content: url(images/toolbarButton-bookmark.png);
}
95 browser/extensions/pdfjs/content/web/viewer.js
View
@@ -1290,6 +1290,7 @@ var PDFView = {
if (PDFView.supportsPrinting) {
pdfDocument.getJavaScript().then(function(javaScript) {
if (javaScript.length) {
+ console.warn('Warning: JavaScript is not supported');
PDFView.fallback();
}
// Hack to support auto printing.
@@ -1363,7 +1364,7 @@ var PDFView = {
self.setTitle(pdfTitle + ' - ' + document.title);
if (info.IsAcroFormPresent) {
- // AcroForm/XFA was found
+ console.warn('Warning: AcroForm/XFA is not supported');
PDFView.fallback();
}
});
@@ -1565,55 +1566,52 @@ var PDFView = {
},
getVisiblePages: function pdfViewGetVisiblePages() {
- return this.getVisibleElements(this.container,
- this.pages, true);
+ if (!this.isFullscreen) {
+ return this.getVisibleElements(this.container, this.pages, true);
+ } else {
+ // The algorithm in getVisibleElements is broken in fullscreen mode.
+ var visible = [], page = this.page;
+ var currentPage = this.pages[page - 1];
+ visible.push({ id: currentPage.id, view: currentPage });
+
+ return { first: currentPage, last: currentPage, views: visible};
+ }
},
getVisibleThumbs: function pdfViewGetVisibleThumbs() {
- return this.getVisibleElements(this.thumbnailContainer,
- this.thumbnails);
+ return this.getVisibleElements(this.thumbnailContainer, this.thumbnails);
},
// Generic helper to find out what elements are visible within a scroll pane.
getVisibleElements: function pdfViewGetVisibleElements(
scrollEl, views, sortByVisibility) {
- var currentHeight = 0, view;
- var top = scrollEl.scrollTop;
-
- for (var i = 1, ii = views.length; i <= ii; ++i) {
- view = views[i - 1];
+ var top = scrollEl.scrollTop, bottom = top + scrollEl.clientHeight;
+ var left = scrollEl.scrollLeft, right = left + scrollEl.clientWidth;
+
+ var visible = [], view;
+ var currentHeight, viewHeight, hiddenHeight, percentHeight;
+ var currentWidth, viewWidth;
+ for (var i = 0, ii = views.length; i < ii; ++i) {
+ view = views[i];
currentHeight = view.el.offsetTop + view.el.clientTop;
- if (currentHeight + view.el.clientHeight > top)
+ viewHeight = view.el.clientHeight;
+ if ((currentHeight + viewHeight) < top) {
+ continue;
+ }
+ if (currentHeight > bottom) {
break;
- currentHeight += view.el.clientHeight;
- }
-
- var visible = [];
-
- // Algorithm broken in fullscreen mode
- if (this.isFullscreen) {
- var currentPage = this.pages[this.page - 1];
- visible.push({
- id: currentPage.id,
- view: currentPage
- });
-
- return { first: currentPage, last: currentPage, views: visible};
- }
+ }
+ currentWidth = view.el.offsetLeft + view.el.clientLeft;
+ viewWidth = view.el.clientWidth;
+ if ((currentWidth + viewWidth) < left || currentWidth > right) {
+ continue;
+ }
+ hiddenHeight = Math.max(0, top - currentHeight) +
+ Math.max(0, currentHeight + viewHeight - bottom);
+ percentHeight = ((viewHeight - hiddenHeight) * 100 / viewHeight) | 0;
- var bottom = top + scrollEl.clientHeight;
- var nextHeight, hidden, percent, viewHeight;
- for (; i <= ii && currentHeight < bottom; ++i) {
- view = views[i - 1];
- viewHeight = view.el.clientHeight;
- currentHeight = view.el.offsetTop + view.el.clientTop;
- nextHeight = currentHeight + viewHeight;
- hidden = Math.max(0, top - currentHeight) +
- Math.max(0, nextHeight - bottom);
- percent = Math.floor((viewHeight - hidden) * 100.0 / viewHeight);
visible.push({ id: view.id, y: currentHeight,
- view: view, percent: percent });
- currentHeight = nextHeight;
+ view: view, percent: percentHeight });
}
var first = visible[0];
@@ -1622,13 +1620,12 @@ var PDFView = {
if (sortByVisibility) {
visible.sort(function(a, b) {
var pc = a.percent - b.percent;
- if (Math.abs(pc) > 0.001)
+ if (Math.abs(pc) > 0.001) {
return -pc;
-
+ }
return a.id - b.id; // ensure stability
});
}
-
return {first: first, last: last, views: visible};
},
@@ -1704,6 +1701,10 @@ var PDFView = {
this.page = this.page;
this.clearMouseScrollState();
this.hidePresentationControls();
+
+ // Ensure that the thumbnail of the current page is visible
+ // when exiting fullscreen mode.
+ scrollIntoView(document.getElementById('thumbnailContainer' + this.page));
},
showPresentationControls: function pdfViewShowPresentationControls() {
@@ -2086,7 +2087,6 @@ var PageView = function pageView(container, pdfPage, id, scale,
var canvas = document.createElement('canvas');
canvas.id = 'page' + this.id;
- canvas.mozOpaque = true;
div.appendChild(canvas);
this.canvas = canvas;
@@ -2116,13 +2116,10 @@ var PageView = function pageView(container, pdfPage, id, scale,
}
var ctx = canvas.getContext('2d');
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
// TODO(mack): use data attributes to store these
ctx._scaleX = outputScale.sx;
ctx._scaleY = outputScale.sy;
- ctx.save();
- ctx.fillStyle = 'rgb(255, 255, 255)';
- ctx.fillRect(0, 0, canvas.width, canvas.height);
- ctx.restore();
if (outputScale.scaled) {
ctx.scale(outputScale.sx, outputScale.sy);
}
@@ -2337,7 +2334,6 @@ var ThumbnailView = function thumbnailView(container, pdfPage, id) {
function getPageDrawContext() {
var canvas = document.createElement('canvas');
canvas.id = 'thumbnail' + id;
- canvas.mozOpaque = true;
canvas.width = canvasWidth;
canvas.height = canvasHeight;
@@ -2599,7 +2595,7 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) {
var textDiv = document.createElement('div');
// vScale and hScale already contain the scaling to pixel units
- var fontHeight = geom.fontSize * geom.vScale;
+ var fontHeight = geom.fontSize * Math.abs(geom.vScale);
textDiv.dataset.canvasWidth = geom.canvasWidth * geom.hScale;
textDiv.dataset.fontName = geom.fontName;
@@ -3250,7 +3246,8 @@ window.addEventListener('keydown', function keydown(evt) {
// First, handle the key bindings that are independent whether an input
// control is selected or not.
- if (cmd == 1 || cmd == 8) { // either CTRL or META key.
+ if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
+ // either CTRL or META key with optional SHIFT.
switch (evt.keyCode) {
case 70:
if (!PDFView.supportsIntegratedFind) {
1  browser/extensions/pdfjs/extension-files
View
@@ -1,4 +1,5 @@
chrome.manifest
+components/PdfRedirector.js
components/PdfStreamConverter.js
content/build/pdf.js
content/PdfJs.jsm
167 browser/metro/base/content/contenthandlers/SelectionHandler.js
View
@@ -45,7 +45,6 @@ var SelectionHandler = {
_contentOffset: { x:0, y:0 },
_domWinUtils: null,
_selectionMoveActive: false,
- _lastMarker: "",
_debugOptions: { dumpRanges: false, displayRanges: false },
_snap: true,
@@ -189,6 +188,14 @@ var SelectionHandler = {
// We bail if things get out of sync here implying we missed a message.
this._selectionMoveActive = true;
+ if (this._targetIsEditable) {
+ // If we're coming out of an out-of-bounds scroll, the node the user is
+ // trying to drag may be hidden (the monocle will be pegged to the edge
+ // of the edit). Make sure the node the user wants to move is visible
+ // and has focus.
+ this._updateInputFocus(aMsg.change);
+ }
+
// Update the position of our selection monocles
this._updateSelectionUI(true, true);
},
@@ -594,71 +601,77 @@ var SelectionHandler = {
}
// Adjust our y position up such that we are sending coordinates on
- // the text line vs. below it where the monocle is positioned. This
- // applies to free floating text areas. For text inputs we'll constrain
- // coordinates further below.
+ // the text line vs. below it where the monocle is positioned.
let halfLineHeight = this._queryHalfLineHeight(aMarker, selection);
clientPoint.yPos -= halfLineHeight;
+ // Modify selection based on monocle movement
if (this._targetIsEditable) {
- // Check to see if we are beyond the bounds of selection in a input
- // control. If we are we want to add selection and scroll the added
- // selection into view.
- let result = this.updateTextEditSelection(clientPoint);
-
- // If we're targeting a text input of any kind, make sure clientPoint
- // is contained within the bounds of the text control. For example, if
- // a user drags up too close to an upper bounds, selectAtPoint might
- // select the content above the control. This looks crappy and breaks
- // our selection rect management.
- clientPoint =
- this._constrainPointWithinControl(clientPoint, halfLineHeight);
-
- // If result.trigger is true, the monocle is outside the bounds of the
- // control. If it's false, fall through to our additive text selection
- // below.
- if (result.trigger) {
- // _handleSelectionPoint is triggered by input movement, so if we've
- // tested positive for out-of-bounds scrolling here, we need to set a
- // recurring timer to keep the expected selection behavior going as
- // long as the user keeps the monocle out of bounds.
- if (!this._scrollTimer)
- this._scrollTimer = new Util.Timeout();
- this._setTextEditUpdateInterval(result.speed);
-
- // Smooth the selection
- this._setContinuousSelection();
-
- // Update the other monocle's position if we've dragged off to one side
- this._updateSelectionUI(result.start, result.end);
-
- return;
- }
+ this._adjustEditableSelection(aMarker, clientPoint,
+ halfLineHeight, aEndOfSelection);
+ } else {
+ this._adjustSelection(aMarker, clientPoint, aEndOfSelection);
}
+ },
- this._lastMarker = aMarker;
+ /*
+ * _handleSelectionPoint helper methods
+ */
- // If we aren't out-of-bounds, clear the scroll timer if it exists.
- this._clearTimers();
+ /*
+ * _adjustEditableSelection
+ *
+ * Based on a monocle marker and position, adds or subtracts from the
+ * existing selection in editable controls. Handles auto-scroll as well.
+ *
+ * @param the marker currently being manipulated
+ * @param aAdjustedClientPoint client point adjusted for line height.
+ * @param aHalfLineHeight half line height in pixels
+ * @param aEndOfSelection indicates if this is the end of a selection
+ * move, in which case we may want to snap to the end of a word or
+ * sentence.
+ */
+ _adjustEditableSelection: function _adjustEditableSelection(aMarker,
+ aAdjustedClientPoint,
+ aHalfLineHeight,
+ aEndOfSelection) {
+ // Test to see if we need to handle auto-scroll in cases where the
+ // monocle is outside the bounds of the control. This also handles
+ // adjusting selection if out-of-bounds is true.
+ let result = this.updateTextEditSelection(aAdjustedClientPoint);
+
+ // If result.trigger is true, the monocle is outside the bounds of the
+ // control.
+ if (result.trigger) {
+ // _handleSelectionPoint is triggered by input movement, so if we've
+ // tested positive for out-of-bounds scrolling here, we need to set a
+ // recurring timer to keep the expected selection behavior going as
+ // long as the user keeps the monocle out of bounds.
+ this._setTextEditUpdateInterval(result.speed);
- // Adjusts the selection based on monocle movement
- this._adjustSelection(aMarker, clientPoint, aEndOfSelection);
+ // Smooth the selection
+ this._setContinuousSelection();
- // Update the other monocle's position. We do this because the dragging
- // monocle may reset the static monocle to a new position if the dragging
- // monocle drags ahead or behind the other.
- if (aMarker == "start") {
- this._updateSelectionUI(false, true);
+ // Update the other monocle's position if we've dragged off to one side
+ this._updateSelectionUI(result.start, result.end);
} else {
- this._updateSelectionUI(true, false);
+ // If we aren't out-of-bounds, clear the scroll timer if it exists.
+ this._clearTimers();
+
+ // Restrict the client point to the interior of the control. Prevents
+ // _adjustSelection from accidentally selecting content outside the
+ // control.
+ let constrainedPoint =
+ this._constrainPointWithinControl(aAdjustedClientPoint, aHalfLineHeight);
+
+ // Add or subtract selection
+ this._adjustSelection(aMarker, constrainedPoint, aEndOfSelection);
}
},
/*
- * _handleSelectionPoint helper methods
- */
-
- /*
+ * _adjustSelection
+ *
* Based on a monocle marker and position, adds or subtracts from the
* existing selection.
*
@@ -707,6 +720,15 @@ var SelectionHandler = {
// Smooth over the selection between all existing ranges.
this._setContinuousSelection();
+
+ // Update the other monocle's position. We do this because the dragging
+ // monocle may reset the static monocle to a new position if the dragging
+ // monocle drags ahead or behind the other.
+ if (aMarker == "start") {
+ this._updateSelectionUI(false, true);
+ } else {
+ this._updateSelectionUI(true, false);
+ }
},
/*
@@ -780,9 +802,9 @@ var SelectionHandler = {
/*
* updateTextEditSelection(aPoint, aClientPoint)
*
- * Checks to see if the monocle point is outside the bounds of the
- * target edit. If so, use the selection controller to select and
- * scroll the edit appropriately.
+ * Checks to see if the monocle point is outside the bounds of the target
+ * edit. If so, use the selection controller to select and scroll the edit
+ * appropriately.
*
* @param aClientPoint raw pointer position
* @return { speed: 0.0 -> 1.0,
@@ -823,6 +845,8 @@ var SelectionHandler = {
_setTextEditUpdateInterval: function _setTextEditUpdateInterval(aSpeedValue) {
let timeout = (75 - (aSpeedValue * 75));
+ if (!this._scrollTimer)
+ this._scrollTimer = new Util.Timeout();
this._scrollTimer.interval(timeout, this.scrollTimerCallback);
},
@@ -836,7 +860,6 @@ var SelectionHandler = {
* _addEditSelection - selection control call wrapper for text inputs.
* Adds selection on the anchor or focus side of selection in a text
* input. Scrolls the location into view as well.
- * (TBD: anchor side scrolling is currently broken, see bug 848594)
*
* @param const selection node identifier
*/
@@ -844,16 +867,32 @@ var SelectionHandler = {
let selCtrl = this._getSelectController();
try {
if (aLocation == kSelectionNodeAnchor) {
- this._targetElement.selectionStart = this._targetElement.selectionStart - 1;
- selCtrl.scrollSelectionIntoView(Ci.nsISelectionController.SELECTION_NORMAL,
- Ci.nsISelectionController.SELECTION_ANCHOR_REGION,
- Ci.nsISelectionController.SCROLL_SYNCHRONOUS);
+ let start = Math.max(this._targetElement.selectionStart - 1, 0);
+ this._targetElement.setSelectionRange(start, this._targetElement.selectionEnd,
+ "backward");
} else {
- this._targetElement.selectionEnd = this._targetElement.selectionEnd + 1;
- selCtrl.scrollSelectionIntoView(Ci.nsISelectionController.SELECTION_NORMAL,
- Ci.nsISelectionController.SELECTION_FOCUS_REGION,
- Ci.nsISelectionController.SCROLL_SYNCHRONOUS);
+ let end = Math.min(this._targetElement.selectionEnd + 1,
+ this._targetElement.textLength);
+ this._targetElement.setSelectionRange(this._targetElement.selectionStart,
+ end,
+ "forward");
}
+ selCtrl.scrollSelectionIntoView(Ci.nsISelectionController.SELECTION_NORMAL,
+ Ci.nsISelectionController.SELECTION_FOCUS_REGION,
+ Ci.nsISelectionController.SCROLL_SYNCHRONOUS);
+ } catch (ex) { Util.dumpLn(ex);}
+ },
+
+ _updateInputFocus: function _updateInputFocus(aMarker) {
+ try {
+ let selCtrl = this._getSelectController();
+ this._targetElement.setSelectionRange(this._targetElement.selectionStart,
+ this._targetElement.selectionEnd,
+ aMarker == "start" ?
+ "backward" : "forward");
+ selCtrl.scrollSelectionIntoView(Ci.nsISelectionController.SELECTION_NORMAL,
+ Ci.nsISelectionController.SELECTION_FOCUS_REGION,
+ Ci.nsISelectionController.SCROLL_SYNCHRONOUS);
} catch (ex) {}
},
4 browser/modules/Social.jsm
View
@@ -178,8 +178,8 @@ this.Social = {
return null;
},
- installProvider: function(origin ,sourceURI, data, installCallback) {
- SocialService.installProvider(origin ,sourceURI, data, installCallback);
+ installProvider: function(doc, data, installCallback) {
+ SocialService.installProvider(doc, data, installCallback);
},
uninstallProvider: function(origin) {
28 build/mobile/sutagent/android/DoCommand.java
View
@@ -441,6 +441,12 @@ public String processCommand(String theCmdLine, PrintWriter out, BufferedInputSt
strReturn += GetProcessInfo();
strReturn += "\n";
strReturn += GetSutUserInfo();
+ strReturn += "\n";
+ strReturn += GetDiskInfo("/data");
+ strReturn += "\n";
+ strReturn += GetDiskInfo("/system");
+ strReturn += "\n";
+ strReturn += GetDiskInfo("/mnt/sdcard");
}
else
{
@@ -495,6 +501,15 @@ public String processCommand(String theCmdLine, PrintWriter out, BufferedInputSt
strReturn += GetTemperatureInfo();
break;
+ case DISK:
+ strReturn += "\n";
+ strReturn += GetDiskInfo("/data");
+ strReturn += "\n";
+ strReturn += GetDiskInfo("/system");
+ strReturn += "\n";
+ strReturn += GetDiskInfo("/mnt/sdcard");
+ break;
+
default:
break;
}
@@ -2670,18 +2685,19 @@ public String GetTemperatureInfo()
return "Temperature: " + sTempVal;
}
- // todo
public String GetDiskInfo(String sPath)
{
String sRet = "";
StatFs statFS = new StatFs(sPath);
- int nBlockCount = statFS.getBlockCount();
- int nBlockSize = statFS.getBlockSize();
- int nBlocksAvail = statFS.getAvailableBlocks();
- int nBlocksFree = statFS.getFreeBlocks();
+ long nBlockCount = statFS.getBlockCount();
+ long nBlockSize = statFS.getBlockSize();
+ long nBlocksAvail = statFS.getAvailableBlocks();
+ // Free is often the same as Available, but can include reserved
+ // blocks that are not available to normal applications.
+ // long nBlocksFree = statFS.getFreeBlocks();
- sRet = "total: " + (nBlockCount * nBlockSize) + "\nfree: " + (nBlocksFree * nBlockSize) + "\navailable: " + (nBlocksAvail * nBlockSize);
+ sRet = sPath + ": " + (nBlockCount * nBlockSize) + " total, " + (nBlocksAvail * nBlockSize) + " available";
return (sRet);
}
5 configure.in
View
@@ -70,7 +70,7 @@ GCONF_VERSION=1.2.1
GIO_VERSION=2.20
STARTUP_NOTIFICATION_VERSION=0.8
DBUS_VERSION=0.60
-SQLITE_VERSION=3.7.15.2
+SQLITE_VERSION=3.7.16
MSMANIFEST_TOOL=
@@ -6121,8 +6121,7 @@ dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
dnl it doesn't exist or we have too old of a version.
if test -n "$LIBJPEG_TURBO_X86_ASM" -o -n "$LIBJPEG_TURBO_X64_ASM" ; then
- AC_MSG_CHECKING([for Yasm assembler])
- AC_CHECK_PROGS(LIBJPEG_TURBO_AS, yasm, "")
+ LIBJPEG_TURBO_AS=$YASM
if test -z "$LIBJPEG_TURBO_AS" ; then
AC_MSG_ERROR([Yasm is required to build with libjpeg-turbo's optimized JPEG decoding routines, but you do not appear to have Yasm installed. Either install it or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder. See https://developer.mozilla.org/en/YASM for more details.])
9 content/base/public/nsContentUtils.h
View
@@ -210,6 +210,15 @@ class nsContentUtils
const nsINode* aPossibleAncestor);
/**
+ * Similar to ContentIsDescendantOf, except will treat an HTMLTemplateElement
+ * or ShadowRoot as an ancestor of things in the corresponding DocumentFragment.
+ * See the concept of "host-including inclusive ancestor" in the DOM
+ * specification.
+ */
+ static bool ContentIsHostIncludingDescendantOf(
+ const nsINode* aPossibleDescendant, const nsINode* aPossibleAncestor);
+
+ /**
* Similar to ContentIsDescendantOf except it crosses document boundaries.
*/
static bool ContentIsCrossDocDescendantOf(nsINode* aPossibleDescendant,
6 content/base/public/nsIDocument.h
View
@@ -1631,6 +1631,12 @@ class nsIDocument : public nsINode
}
/**
+ * Returns the template content owner document that owns the content of
+ * HTMLTemplateElement.
+ */
+ virtual nsIDocument* GetTemplateContentsOwner() = 0;
+
+ /**
* true when this document is a static clone of a normal document.
* For example print preview and printing use static documents.
*/
2  content/base/src/DocumentFragment.cpp
View
@@ -55,7 +55,7 @@ namespace mozilla {
namespace dom {
DocumentFragment::DocumentFragment(already_AddRefed<nsINodeInfo> aNodeInfo)
- : FragmentOrElement(aNodeInfo)
+ : FragmentOrElement(aNodeInfo), mHost(nullptr)
{
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() ==
nsIDOMNode::DOCUMENT_FRAGMENT_NODE &&
12 content/base/src/DocumentFragment.h
View
@@ -20,6 +20,7 @@ namespace mozilla {
namespace dom {
class Element;
+class HTMLTemplateElement;
class DocumentFragment : public FragmentOrElement,
public nsIDOMDocumentFragment
@@ -101,6 +102,16 @@ class DocumentFragment : public FragmentOrElement,
return nullptr;
}
+ HTMLTemplateElement* GetHost() const
+ {
+ return mHost;
+ }
+
+ void SetHost(HTMLTemplateElement* aHost)
+ {
+ mHost = aHost;
+ }
+
#ifdef DEBUG
virtual void List(FILE* out, int32_t aIndent) const;
virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const;
@@ -108,6 +119,7 @@ class DocumentFragment : public FragmentOrElement,
protected:
nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+ mozilla::dom::HTMLTemplateElement* mHost; // Weak
};
} // namespace dom
48 content/base/src/Element.cpp
View
@@ -101,6 +101,7 @@
#include "nsRuleProcessorData.h"
#include "nsAsyncDOMEvent.h"
#include "nsTextNode.h"
+#include "mozilla/dom/HTMLTemplateElement.h"
#ifdef MOZ_XUL
#include "nsIXULDocument.h"
@@ -3106,7 +3107,9 @@ IsVoidTag(Element* aElement)
static bool
Serialize(Element* aRoot, bool aDescendentsOnly, nsAString& aOut)
{
- nsINode* current = aDescendentsOnly ? aRoot->GetFirstChild() : aRoot;
+ nsINode* current = aDescendentsOnly ?
+ nsNodeUtils::GetFirstChildOfTemplateOrNode(aRoot) : aRoot;
+
if (!current) {
return true;
}
@@ -3120,7 +3123,8 @@ Serialize(Element* aRoot, bool aDescendentsOnly, nsAString& aOut)
Element* elem = current->AsElement();
StartElement(elem, builder);
isVoid = IsVoidTag(elem);
- if (!isVoid && (next = current->GetFirstChild())) {
+ if (!isVoid &&
+ (next = nsNodeUtils::GetFirstChildOfTemplateOrNode(current))) {
current = next;
continue;
}
@@ -3186,6 +3190,17 @@ Serialize(Element* aRoot, bool aDescendentsOnly, nsAString& aOut)
}
current = current->GetParentNode();
+
+ // Template case, if we are in a template's content, then the parent
+ // should be the host template element.
+ if (current->NodeType() == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) {
+ DocumentFragment* frag = static_cast<DocumentFragment*>(current);
+ HTMLTemplateElement* fragHost = frag->GetHost();
+ if (fragHost) {
+ current = fragHost;
+ }
+ }
+
if (aDescendentsOnly && current == aRoot) {
return builder.ToString(aOut);
}
@@ -3292,30 +3307,39 @@ Element::GetInnerHTML(nsAString& aInnerHTML, ErrorResult& aError)
void
Element::SetInnerHTML(const nsAString& aInnerHTML, ErrorResult& aError)
{
- nsIDocument* doc = OwnerDoc();
+ FragmentOrElement* target = this;
+ // Handle template case.
+ if (nsNodeUtils::IsTemplateElement(target)) {
+ DocumentFragment* frag =
+ static_cast<HTMLTemplateElement*>(target)->Content();
+ MOZ_ASSERT(frag);
+ target = frag;
+ }
+
+ nsIDocument* doc = target->OwnerDoc();
// Batch possible DOMSubtreeModified events.
mozAutoSubtreeModified subtree(doc, nullptr);
- FireNodeRemovedForChildren();
+ target->FireNodeRemovedForChildren();
// Needed when innerHTML is used in combination with contenteditable
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, true);
// Remove childnodes.
- uint32_t childCount = GetChildCount();
- nsAutoMutationBatch mb(this, true, false);
+ uint32_t childCount = target->GetChildCount();
+ nsAutoMutationBatch mb(target, true, false);
for (uint32_t i = 0; i < childCount; ++i) {
- RemoveChildAt(0, true);
+ target->RemoveChildAt(0, true);
}
mb.RemovalDone();
nsAutoScriptLoaderDisabler sld(doc);
if (doc->IsHTML()) {
- int32_t oldChildCount = GetChildCount();
+ int32_t oldChildCount = target->GetChildCount();
aError = nsContentUtils::ParseFragmentHTML(aInnerHTML,
- this,
+ target,
Tag(),
GetNameSpaceID(),
doc->GetCompatibilityMode() ==
@@ -3323,10 +3347,10 @@ Element::SetInnerHTML(const nsAString& aInnerHTML, ErrorResult& aError)
true);
mb.NodesAdded();
// HTML5 parser has notified, but not fired mutation events.
- FireMutationEventsForDirectParsing(doc, this, oldChildCount);
+ FireMutationEventsForDirectParsing(doc, target, oldChildCount);
} else {
nsCOMPtr<nsIDOMDocumentFragment> df;
- aError = nsContentUtils::CreateContextualFragment(this, aInnerHTML,
+ aError = nsContentUtils::CreateContextualFragment(target, aInnerHTML,
true,
getter_AddRefs(df));
nsCOMPtr<nsINode> fragment = do_QueryInterface(df);
@@ -3336,7 +3360,7 @@ Element::SetInnerHTML(const nsAString& aInnerHTML, ErrorResult& aError)
// listeners on the fragment that comes from the parser.
nsAutoScriptBlockerSuppressNodeRemoved scriptBlocker;
- static_cast<nsINode*>(this)->AppendChild(*fragment, aError);
+ static_cast<nsINode*>(target)->AppendChild(*fragment, aError);
mb.NodesAdded();
}
}
22 content/base/src/nsContentUtils.cpp
View
@@ -30,6 +30,7 @@
#include "mozilla/DebugOnly.h"
#include "mozilla/dom/DocumentFragment.h"
#include "mozilla/dom/Element.h"
+#include "mozilla/dom/HTMLTemplateElement.h"
#include "mozilla/dom/TextDecoderBase.h"
#include "mozilla/Likely.h"
#include "mozilla/Preferences.h"
@@ -1854,6 +1855,27 @@ nsContentUtils::ContentIsDescendantOf(const nsINode* aPossibleDescendant,
return false;
}
+bool
+nsContentUtils::ContentIsHostIncludingDescendantOf(
+ const nsINode* aPossibleDescendant, const nsINode* aPossibleAncestor)
+{
+ NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!");
+ NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!");
+
+ do {
+ if (aPossibleDescendant == aPossibleAncestor)
+ return true;
+ if (aPossibleDescendant->NodeType() == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) {
+ aPossibleDescendant =
+ static_cast<const DocumentFragment*>(aPossibleDescendant)->GetHost();
+ } else {
+ aPossibleDescendant = aPossibleDescendant->GetParentNode();
+ }
+ } while (aPossibleDescendant);
+
+ return false;
+}
+
// static
bool
nsContentUtils::ContentIsCrossDocDescendantOf(nsINode* aPossibleDescendant,
33 content/base/src/nsDocument.cpp
View
@@ -1708,6 +1708,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCachedEncoder)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStateObjectCached)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mUndoManager)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTemplateContentsOwner)
// Traverse all our nsCOMArrays.
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStyleSheets)
@@ -1784,6 +1785,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOriginalDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCachedEncoder)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mUndoManager)
+ NS_IMPL_CYCLE_COLLECTION_UNLINK(mTemplateContentsOwner)
tmp->mParentDocument = nullptr;
@@ -8536,6 +8538,37 @@ nsDocument::GetCurrentContentSink()
return mParser ? mParser->GetContentSink() : nullptr;
}
+nsIDocument*
+nsDocument::GetTemplateContentsOwner()
+{
+ if (!mTemplateContentsOwner) {
+ bool hasHadScriptObject = true;
+ nsIScriptGlobalObject* scriptObject =
+ GetScriptHandlingObject(hasHadScriptObject);
+ NS_ENSURE_TRUE(scriptObject || !hasHadScriptObject, nullptr);
+
+ nsCOMPtr<nsIDOMDocument> domDocument;
+ nsresult rv = NS_NewDOMDocument(getter_AddRefs(domDocument),
+ EmptyString(), // aNamespaceURI
+ EmptyString(), // aQualifiedName
+ nullptr, // aDoctype
+ nsIDocument::GetDocumentURI(),
+ nsIDocument::GetDocBaseURI(),
+ NodePrincipal(),
+ true, // aLoadedAsData
+ scriptObject, // aEventObject
+ DocumentFlavorHTML);
+ NS_ENSURE_SUCCESS(rv, nullptr);
+
+ mTemplateContentsOwner = do_QueryInterface(domDocument);
+ NS_ENSURE_TRUE(mTemplateContentsOwner, nullptr);
+
+ mTemplateContentsOwner->SetScriptHandlingObject(scriptObject);
+ }
+
+ return mTemplateContentsOwner;
+}
+
void
nsDocument::RegisterHostObjectUri(const nsACString& aUri)
{
6 content/base/src/nsDocument.h
View
@@ -864,6 +864,8 @@ class nsDocument : public nsIDocument,
MaybeRescheduleAnimationFrameNotifications();
}
+ virtual nsIDocument* GetTemplateContentsOwner();
+
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDocument,
nsIDocument)
@@ -1291,6 +1293,10 @@ class nsDocument : public nsIDocument,
nsCOMPtr<nsIChannel> mChannel;
nsRefPtr<nsHTMLCSSStyleSheet> mStyleAttrStyleSheet;
+ // A document "without a browsing context" that owns the content of
+ // HTMLTemplateElement.
+ nsCOMPtr<nsIDocument> mTemplateContentsOwner;
+
// Our update nesting level
uint32_t mUpdateNestLevel;
4 content/base/src/nsDocumentEncoder.cpp
View
@@ -42,6 +42,7 @@
#include "nsISelectionPrivate.h"
#include "nsITransferable.h" // for kUnicodeMime
#include "nsContentUtils.h"
+#include "nsNodeUtils.h"
#include "nsUnicharUtils.h"
#include "nsReadableUtils.h"
#include "nsTArray.h"
@@ -495,7 +496,8 @@ nsDocumentEncoder::SerializeToStringRecursive(nsINode* aNode,
nsINode* node = serializeClonedChildren ? maybeFixedNode : aNode;
- for (nsINode* child = node->GetFirstChild(); child;
+ for (nsINode* child = nsNodeUtils::GetFirstChildOfTemplateOrNode(node);
+ child;
child = child->GetNextSibling()) {
rv = SerializeToStringRecursive(child, aStr, false);
NS_ENSURE_SUCCESS(rv, rv);
6 content/base/src/nsINode.cpp
View
@@ -1420,8 +1420,10 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
// actually equal to each other. Fast-path that case, since aParent
// could be pretty deep in the DOM tree.
if (aNewChild == aParent ||
- (aNewChild->GetFirstChild() &&
- nsContentUtils::ContentIsDescendantOf(aParent, aNewChild))) {
+ ((aNewChild->GetFirstChild() ||
+ aNewChild->Tag() == nsGkAtoms::_template) &&