mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 09:15:35 +00:00
Bug 1417837 - Part 2: Preserve class names in readerized output that we use in aboutReader.css. r=Gijs
MozReview-Commit-ID: 7qV2SRHeeOJ --HG-- extra : rebase_source : ca8b15ef9ceb95da5f7b1d985ba60cfb594bfd3e
This commit is contained in:
parent
33f3ce5cd6
commit
f5a4439064
@ -18,6 +18,19 @@ const PARSE_ERROR_TOO_MANY_ELEMENTS = 1;
|
||||
const PARSE_ERROR_WORKER = 2;
|
||||
const PARSE_ERROR_NO_ARTICLE = 3;
|
||||
|
||||
// Class names to preserve in the readerized output. We preserve these class
|
||||
// names so that rules in aboutReader.css can match them.
|
||||
const CLASSES_TO_PRESERVE = [
|
||||
"caption",
|
||||
"hidden",
|
||||
"invisble",
|
||||
"sr-only",
|
||||
"visually-hidden",
|
||||
"visuallyhidden",
|
||||
"wp-caption",
|
||||
"wp-caption-text",
|
||||
];
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
@ -453,9 +466,13 @@ this.ReaderMode = {
|
||||
createInstance(Ci.nsIDOMSerializer);
|
||||
let serializedDoc = serializer.serializeToString(doc);
|
||||
|
||||
let options = {
|
||||
classesToPreserve: CLASSES_TO_PRESERVE,
|
||||
};
|
||||
|
||||
let article = null;
|
||||
try {
|
||||
article = await ReaderWorker.post("parseDocument", [uriParam, serializedDoc]);
|
||||
article = await ReaderWorker.post("parseDocument", [uriParam, serializedDoc, options]);
|
||||
} catch (e) {
|
||||
Cu.reportError("Error in ReaderWorker: " + e);
|
||||
histogram.add(PARSE_ERROR_WORKER);
|
||||
|
@ -42,11 +42,12 @@ var Agent = {
|
||||
*
|
||||
* @param {object} uri URI data for the document.
|
||||
* @param {string} serializedDoc The serialized document.
|
||||
* @param {object} options Options object to pass to Readability.
|
||||
*
|
||||
* @return {object} Article object returned from Readability.
|
||||
*/
|
||||
parseDocument(uri, serializedDoc) {
|
||||
parseDocument(uri, serializedDoc, options) {
|
||||
let doc = new JSDOMParser().parse(serializedDoc);
|
||||
return new Readability(uri, doc).parse();
|
||||
return new Readability(uri, doc, options).parse();
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user