Changeset 91239 in webkit


Ignore:
Timestamp:
Jul 18, 2011 10:33:10 PM (13 years ago)
Author:
aestes@apple.com
Message:

Solar Walk app-specific hack accidentally strips stylesheets from the document.
https://bugs.webkit.org/show_bug.cgi?id=64777

Reviewed by Adam Barth.

Solar Walk uses a self-closed title tag in its documents ("<title />").
The HTML5 parser does not recognize this as a valid self-closing tag,
so it treats the remainder of the document as title text.

We work around this in WebKit by injecting a script that calls
document.write() on the contents of document.title, thereby restoring
the contents of the document. Unfortunately this overwrote several
<style> tags that existed before the <title>, thereby causing the
document to not have the intended styling.

Fix this by having the injected script concatenate document.title to
the document instead of overwriting it during document.write(). We can
also take the opportunity to remove document.title since it does not
contain useful information.

  • Misc/SolarWalkQuirksUserScript.js:
Location:
trunk/Source/WebKit/mac
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/mac/ChangeLog

    r91232 r91239  
     12011-07-18  Andy Estes  <aestes@apple.com>
     2
     3        Solar Walk app-specific hack accidentally strips stylesheets from the document.
     4        https://bugs.webkit.org/show_bug.cgi?id=64777
     5
     6        Reviewed by Adam Barth.
     7       
     8        Solar Walk uses a self-closed title tag in its documents ("<title />").
     9        The HTML5 parser does not recognize this as a valid self-closing tag,
     10        so it treats the remainder of the document as title text.
     11       
     12        We work around this in WebKit by injecting a script that calls
     13        document.write() on the contents of document.title, thereby restoring
     14        the contents of the document. Unfortunately this overwrote several
     15        <style> tags that existed before the <title>, thereby causing the
     16        document to not have the intended styling.
     17       
     18        Fix this by having the injected script concatenate document.title to
     19        the document instead of overwriting it during document.write(). We can
     20        also take the opportunity to remove document.title since it does not
     21        contain useful information.
     22
     23        * Misc/SolarWalkQuirksUserScript.js:
     24
    1252011-07-18  Dean Jackson  <dino@apple.com>
    226
  • trunk/Source/WebKit/mac/Misc/SolarWalkQuirksUserScript.js

    r86407 r91239  
    2929        // Solar Walk uses a self closing title tag, so to match the behavior of the old parser,
    3030        // we write the contents of the title element to the end of the document so it can be re-parsed.
    31         document.write(document.title);
     31        document.write(document.documentElement.outerHTML + document.title);
     32       
     33        // Remove <title> since SolarWalk intended it to be empty.
     34        document.head.removeChild(document.title);
    3235    }
    3336
Note: See TracChangeset for help on using the changeset viewer.