Closed
Bug 1081742
Opened 10 years ago
Closed 9 years ago
Reader mode doesn't support RTL/bidi text (e.g., Arabic)
Categories
(Firefox for Android Graveyard :: Reader View, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 38
People
(Reporter: kafhaya66, Assigned: capella)
References
()
Details
Attachments
(2 files, 2 obsolete files)
527.21 KB,
image/png
|
Details | |
5.56 KB,
patch
|
bnicholson
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Android; Mobile; rv:32.0) Gecko/32.0 Firefox/32.0 Build ID: 20140923174357 Steps to reproduce: firefox support arabic font very good Actual results: but when i add some of arabic page to read later, font change to left and not support right text alignment in read later list and also when l want to convert this page to pdf Expected results: for arabic when add to read later it should to align right side of page and also when convert to pdf
Comment 1•10 years ago
|
||
Do you have an example page showcasing this? Maybe this is bug 828922.
Flags: needinfo?(kafhaya66)
Updated•10 years ago
|
Component: General → Reader Mode
Summary: right text alignment for arabic → right text alignment for arabic not adhered to in reader mode
Updated•10 years ago
|
Group: core-security
Comment 2•10 years ago
|
||
Spotted a user mentioning this in a review on Google Play.
Blocks: rtl-meta
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: right text alignment for arabic not adhered to in reader mode → Reader mode doesn't support RTL/bidi text (e.g., Arabic)
Comment 4•9 years ago
|
||
Just noting in here based on IRC conversation that I ran into a related problem where RTL text-selection in reader mode will unselect a first word in a sentence, e.g, http://cl.ly/1c3v2V24042x/video.mp4 (mentioned that perhaps element .direction is not maintained)
Assignee | ||
Comment 5•9 years ago
|
||
Test case I'm using ... https://www.dropbox.com/s/ik1ks4mhhe0js6k/test_bug1081742.html?dl=0
Assignee | ||
Comment 6•9 years ago
|
||
This seems to affect desktop too. I have a basic patch I threw together that seems to work for both platforms, but at this point it depends partially on backing out bug 785992. So I'll need discussion on why we did that, a way to have nsIParserUtils honor the text direction, or any other more obvious fix I'm unaware of. I've little experience in this area, so I'm asking bnicholson for feedback since I see his prior involvement with JSDOMParser, and I may have spotted a loosely (un)related issue in getStyle() / setStyle().
Attachment #8557405 -
Flags: feedback?(bnicholson)
Assignee | ||
Comment 7•9 years ago
|
||
before [1] / after [2] [1] https://www.dropbox.com/s/lfco29eosn946cc/bug1081742_noFix.png?dl=0 [2] https://www.dropbox.com/s/5pho43n3a4khjds/bug1081742_fix.png?dl=0
Assignee | ||
Comment 8•9 years ago
|
||
Tweaked during testing.
Assignee: nobody → markcapella
Attachment #8557405 -
Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #8557405 -
Flags: feedback?(bnicholson)
Attachment #8557515 -
Flags: review?(bnicholson)
Assignee | ||
Comment 9•9 years ago
|
||
Comment on attachment 8557515 [details] [diff] [review] bug1081742.diff Additional suggested reviewers ...
Attachment #8557515 -
Flags: review?(margaret.leibovic)
Attachment #8557515 -
Flags: review?(jaws)
Comment 10•9 years ago
|
||
Comment on attachment 8557515 [details] [diff] [review] bug1081742.diff Review of attachment 8557515 [details] [diff] [review]: ----------------------------------------------------------------- Removing jaws since Margaret and I are now peers of the Reader submodule (https://wiki.mozilla.org/Toolkit/Submodules). Shouldn't need 3 reviewers here. ::: toolkit/components/reader/AboutReader.jsm @@ -588,5 @@ > - let parserUtils = Cc["@mozilla.org/parserutils;1"].getService(Ci.nsIParserUtils); > - let contentFragment = parserUtils.parseFragment(article.content, Ci.nsIParserUtils.SanitizerDropForms, > - false, articleUri, this._contentElement); > - this._contentElement.innerHTML = ""; > - this._contentElement.appendChild(contentFragment); This wasn't working since the sanitizer strips styles by default. You should be able to fix this by adding the SanitizerAllowStyle flag [1]. [1] https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIParserUtils To answer your question, the sanitizer probably isn't essential since the reader content is sandboxed, and we already strip unwanted elements in Readability.js. It doesn't hurt to have it if we can, though, since it will purge anything we may have missed. ::: toolkit/components/reader/content/JSDOMParser.js @@ +578,5 @@ > let attr = this.node.getAttribute("style"); > if (!attr) > return undefined; > > + let styles = attr.split(";"); Ouch, nice catch. ::: toolkit/components/reader/content/Readability.js @@ +431,5 @@ > allElements[i]._index = i; > } > > /** > + * Readability returns static node lists, not live ones. When we remove I think this comment was correct before. JSDOMParser isn't a real standards-compliant parser; things like "document.getElementsByTagName(...)" return a static array instead of a live NodeList. That means if any of these elements are added/removed from the document, the result will not change. This is a limitation of JSDOMParser, not Readability. The latter can still be used without the former, in which case this comment wouldn't apply. @@ +913,4 @@ > e.removeAttribute('style'); > + if (textDirection !== undefined) { > + e.setAttribute("style", textDirection); > + } So what's happening here is: 1) You're getting the style from the node 2) The style is being removed from the node 3) The style from #1 is being applied to node In other words, this block isn't doing anything :) What you want is to keep the direction style while stripping everything else: let style = e.getStyle("direction"); e.removeAttribute("style"); if (style) { e.setStyle("direction", style); } @@ +926,4 @@ > cur.removeAttribute("style"); > + if (textDirection !== undefined) { > + cur.setAttribute("style", textDirection); > + } Same here. I'd recommend creating a _stripNonDirectionStyles() helper that can be called from both places.
Attachment #8557515 -
Flags: review?(jaws)
Attachment #8557515 -
Flags: review?(bnicholson)
Attachment #8557515 -
Flags: feedback+
Assignee | ||
Comment 11•9 years ago
|
||
Thanks for all that ! Not sure how that comment got changed, accidental find/replace I'm guessing. I'm not sure what you mean by |In other words, this block isn't doing anything|. Both out intent seems to be to save the |direction| style, remove any other style k:v pairs such as "display:foo", "margin;foo", etc. end reset the saved direction style. I'll look at your example closer, but adding a helper to JSDOMParser is "yeah let's!" :) I appreciate the info re: You should be able to fix this by adding the SanitizerAllowStyle flag. TIL moment, and no need to backout useful code.
Comment 12•9 years ago
|
||
(In reply to Mark Capella [:capella] from comment #11) > I'm not sure what you mean by |In other words, this block isn't doing > anything|. > Both out intent seems to be to save the |direction| style, remove any other > style k:v pairs such as "display:foo", "margin;foo", etc. end reset the > saved direction style. Yeah, I could see that was your intent, but I don't think it was quite working that way. `let textDirection = e.getAttribute("style");` gets *all* styles for the element, not just the direction style. So when you reset the style after removing it, you were restoring all other k:v pairs with it.
Assignee | ||
Comment 13•9 years ago
|
||
ooops, there it is.
Assignee | ||
Comment 14•9 years ago
|
||
Cleaner :)
Attachment #8557515 -
Attachment is obsolete: true
Attachment #8557515 -
Flags: review?(margaret.leibovic)
Attachment #8558275 -
Flags: review?(bnicholson)
Comment 16•9 years ago
|
||
Comment on attachment 8558275 [details] [diff] [review] bug1081742.diff Review of attachment 8558275 [details] [diff] [review]: ----------------------------------------------------------------- Looks OK to me! ::: toolkit/components/reader/content/Readability.js @@ +929,5 @@ > + * Remove all style atrributes, preserving RTL/LTR text direction styles. > + * > + * @param Element > + * @return void. > + */ Nit: whitespace
Attachment #8558275 -
Flags: review?(bnicholson) → review+
Assignee | ||
Comment 17•9 years ago
|
||
https://tbpl.mozilla.org/?tree=Try&rev=21a6344d76cd
Assignee | ||
Comment 18•9 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/efd053a1586c
Comment 19•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/efd053a1586c
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 38
Comment 20•9 years ago
|
||
It looks that desktop reader mode still doesn't support RTL on this page: http://hwzone.co.il/%D7%94%D7%A6%D7%A6%D7%94-%D7%9C%D7%9E%D7%95%D7%A6%D7%A8%D7%99-%D7%94%D7%A2%D7%99%D7%93%D7%9F-%D7%94%D7%97%D7%93%D7%A9-%D7%A9%D7%9C-amd-%D7%A9%D7%99%D7%92%D7%99%D7%A2%D7%95-%D7%91%D7%A9%D7%A0%D7%AA-201/ Kubuntu 15.04 64bit, Firefox 39. Should I open a new bug?
Flags: needinfo?(markcapella)
Comment 21•9 years ago
|
||
Works for me on a Nightly build. http://people.mozilla.org/~kbrosnan/tmp/1081742/rtl-reader.webm
Updated•9 years ago
|
Flags: needinfo?(markcapella)
Comment 22•9 years ago
|
||
(In reply to Kevin Brosnan [:kbrosnan] from comment #21) > Works for me on a Nightly build. > http://people.mozilla.org/~kbrosnan/tmp/1081742/rtl-reader.webm Kevin, it's that I get and it's wrong. The text should be aligned to right and RTL should be enabled (so the rows with both English and Hebrew text will appear in proper order).
Flags: needinfo?(kbrosnan)
Assignee | ||
Comment 23•9 years ago
|
||
mmm ... looks like maybe we had a conflict with the implementation of the new ReaderMode, when it moved to support desktop [0] bug 1134443 (?) My original patch changed AboutReader.jsm, JSDOMParse.js, and Readability.js. Bug 1134443 seems to have stepped on Readability.js changes ... looking further ... [0] http://hg.mozilla.org/mozilla-central/diff/2bbb4ac2a49e/toolkit/components/reader/content/Readability.js
Assignee | ||
Comment 24•9 years ago
|
||
The "lost code" in comment #23 is interesting, but seems un-related. This particular page seems to be setting the body direction via .css [1] I now recall an earlier irc conversation [2] for this issue, and a tracking bug [3] - "Reader View picks wrong direction for some RTL pages." [1] view-source:http://hwzone.co.il/wp-content/themes/HWzone%20Theme/style.css?v=0.0753 [2] http://logs.glob.uno/?c=mozilla%23introduction&s=10+Jun+2015&e=10+Jun+2015&h=bidi#c221144 [3] https://bugzilla.mozilla.org/show_bug.cgi?id=1173548
Updated•9 years ago
|
Flags: needinfo?(kbrosnan)
Updated•3 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•