MantisBT - NetSurf
View Issue Details
0002409NetSurfLayoutpublic2016-01-01 03:352016-02-02 15:50
ReporterHarriet Bazley 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformIyonix AriaOSRISC OSOS Version5.22
Product Version 
Target VersionFixed in Version 
Fixed in CI build #
Reported in CI build #3244
URL of problem pagehttps://www.fanfiction.net/s/9480915/1/White-Light
Summary0002409: All text is displayed centred on fanfiction.net
DescriptionEvery chapter on www.fanfiction.net gets displayed with the main body text centred; long paragraphs of centred text are hard to read.
The same pages when viewed on the mobile site display as intended, i.e. left-aligned paragraphs.
Steps To ReproduceView any story on the site, e.g. https://www.fanfiction.net/s/9480915/1/White-Light
Compare with the mobile version: https://m.fanfiction.net/s/9480915/1/White-Light
 
 
Additional InformationI've noticed this bug over a long range of NetSurf versions going back a couple of years at least.
TagsNo tags attached.
Attached Files

Notes
(0001136)
Dave Higton   
2016-01-04 21:26   
It appears that a Javascript document.write() statement is not being obeyed.
(0001182)
Michael Drake   
2016-02-02 11:57   
(Last edited: 2016-02-02 11:59)
It's centred in the markup, and then JavaScript adds a STYLE element to the document which left aligns it. I have no idea why anyone would do that.

So it will never be left-aligned with JS off. With JS on, we need support for JS writing STYLE elements into the document.

Test case:

<!DOCTYPE html>
<html>
<body>
<script>
document.write('<style>p#foo { color: green; background: #dfd; }</style>');
</script>
<p id="foo">JS makes me green!


</body>
</html>

Edit: Note: Mantis swallows the P element close tag in the above.

(0001183)
Michael Drake   
2016-02-02 12:09   
It seems that the dom_default_action_DOMSubtreeModified_cb() is not called for STYLE elements added by JavaScript, which is what prevents us from ever adding the new stylesheet data.
(0001184)
Michael Drake   
2016-02-02 13:14   
In fact, the STYLE node is never added to the DOM.
(0001185)
Michael Drake   
2016-02-02 15:50   
Actually, there's more to it. We do add STYLE nodes to the DOM and that works.

The problem seems to be with some XCOOKIE library that the JS uses. Due to that failing, it never manages to write out the crucial "text-align: left;".

document.write('<style> .storytext { max-height: 999999px; width: '+XCOOKIE.read_width+'%; font-size:' + XCOOKIE.read_font_size + 'em; font-family: "'+XCOOKIE.read_font+'"; line-height: '+XCOOKIE.read_line_height+'; text-align: left;} </style>');

Issue History
2016-01-01 03:35Harriet BazleyNew Issue
2016-01-04 21:26Dave HigtonNote Added: 0001136
2016-01-04 21:27Dave HigtonStatusnew => acknowledged
2016-02-02 11:57Michael DrakeNote Added: 0001182
2016-02-02 11:57Michael DrakeNote Edited: 0001182bug_revision_view_page.php?bugnote_id=1182#r1757
2016-02-02 11:58Michael DrakeNote Edited: 0001182bug_revision_view_page.php?bugnote_id=1182#r1758
2016-02-02 11:59Michael DrakeNote Edited: 0001182bug_revision_view_page.php?bugnote_id=1182#r1759
2016-02-02 12:09Michael DrakeNote Added: 0001183
2016-02-02 13:14Michael DrakeNote Added: 0001184
2016-02-02 15:50Michael DrakeNote Added: 0001185