Title: [90223] trunk/Source/WebKit/mac
Revision
90223
Author
[email protected]
Date
2011-07-01 05:51:24 -0700 (Fri, 01 Jul 2011)

Log Message

2011-07-01  Andy Estes  <[email protected]>

        Reviewed by Mark Rowe.

        Simplify MailQuirksUserScript.js
        https://bugs.webkit.org/show_bug.cgi?id=63800
        
        MailQuirksUserScript.js is injected into WebViews in Mail.app on
        Leopard to resolve an incompatibility between it and the HTML5 parser.
        It did so by taking all nodes in the document between <html> and <body>
        and moving them to be children of <body>. This maintains Mail.app's
        assumption that document.firstChild.firstChild == document.body.
        
        While this script fixed a specific issue with the Signature panel in
        Mail.app, it caused regressions in other WebViews. Since the issue with
        the Signature panel is with the empty <head> node implicitly created by
        the parser, we can simplify this script by removing this implicit
        <head> in the case it has no attributes and no children. This fixes the
        Signature panel without affecting other WebViews that have non-trivial
        <head> nodes.

        * Misc/MailQuirksUserScript.js: If <head> exists but has no attributes
        and no children, remove it.

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (90222 => 90223)


--- trunk/Source/WebKit/mac/ChangeLog	2011-07-01 11:29:59 UTC (rev 90222)
+++ trunk/Source/WebKit/mac/ChangeLog	2011-07-01 12:51:24 UTC (rev 90223)
@@ -1,3 +1,27 @@
+2011-07-01  Andy Estes  <[email protected]>
+
+        Reviewed by Mark Rowe.
+
+        Simplify MailQuirksUserScript.js
+        https://bugs.webkit.org/show_bug.cgi?id=63800
+        
+        MailQuirksUserScript.js is injected into WebViews in Mail.app on
+        Leopard to resolve an incompatibility between it and the HTML5 parser.
+        It did so by taking all nodes in the document between <html> and <body>
+        and moving them to be children of <body>. This maintains Mail.app's
+        assumption that document.firstChild.firstChild == document.body.
+        
+        While this script fixed a specific issue with the Signature panel in
+        Mail.app, it caused regressions in other WebViews. Since the issue with
+        the Signature panel is with the empty <head> node implicitly created by
+        the parser, we can simplify this script by removing this implicit
+        <head> in the case it has no attributes and no children. This fixes the
+        Signature panel without affecting other WebViews that have non-trivial
+        <head> nodes.
+
+        * Misc/MailQuirksUserScript.js: If <head> exists but has no attributes
+        and no children, remove it.
+
 2011-06-30  Dan Bernstein  <[email protected]>
 
         Reviewed by Adele Peterson.

Modified: trunk/Source/WebKit/mac/Misc/MailQuirksUserScript.js (90222 => 90223)


--- trunk/Source/WebKit/mac/Misc/MailQuirksUserScript.js	2011-07-01 11:29:59 UTC (rev 90222)
+++ trunk/Source/WebKit/mac/Misc/MailQuirksUserScript.js	2011-07-01 12:51:24 UTC (rev 90223)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -29,29 +30,11 @@
  */
 
 (function() {
-    function childrenBefore(parent, stopAt)
-    {
-        var children = [];
-        for (var child = parent.firstChild; child != stopAt; child = child.nextSibling)
-            children.push(child);
-        return children;
-    }
-
-    // If html or body is missing, Mail.app's assumption that
-    // document.firstChild.firstChild == document.body is wrong anyway,
-    // so return null to not move anything.
-    if (!document.documentElement || !document.body)
-        return;
-
-    var children = childrenBefore(document, document.documentElement);
-    children = children.concat(childrenBefore(document.documentElement, document.body));
-
-    for (var i = children.length - 1; i >= 0; i--) {
-        var child = children[i];
-        // It's not possible to move doctype nodes into the body, so just remove them.
-        if (child.nodeType == child.DOCUMENT_TYPE_NODE)
-            child.parentNode.removeChild(child);
-        else
-            document.body.insertBefore(child, document.body.firstChild);
-    }
+    // The Mail.app signature panel makes the assumption that
+    // document.firstChild.firstChild == document.body. This is no longer true
+    // now that WebKit implements the HTML5 parser, which creates an implicit
+    // <head> node if not explicitly specified in content. Remove this implicit
+    // <head> so that Mail.app's assumption remains true.
+    if (document.head && !document.head.childNodes.length && !document.head.attributes.length)
+        document.documentElement.removeChild(document.head);
 })();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to