Changeset 90223 in webkit
- Timestamp:
- Jul 1, 2011, 5:51:24 AM (15 years ago)
- Location:
- trunk/Source/WebKit/mac
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
Misc/MailQuirksUserScript.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/mac/ChangeLog
r90129 r90223 1 2011-07-01 Andy Estes <aestes@apple.com> 2 3 Reviewed by Mark Rowe. 4 5 Simplify MailQuirksUserScript.js 6 https://bugs.webkit.org/show_bug.cgi?id=63800 7 8 MailQuirksUserScript.js is injected into WebViews in Mail.app on 9 Leopard to resolve an incompatibility between it and the HTML5 parser. 10 It did so by taking all nodes in the document between <html> and <body> 11 and moving them to be children of <body>. This maintains Mail.app's 12 assumption that document.firstChild.firstChild == document.body. 13 14 While this script fixed a specific issue with the Signature panel in 15 Mail.app, it caused regressions in other WebViews. Since the issue with 16 the Signature panel is with the empty <head> node implicitly created by 17 the parser, we can simplify this script by removing this implicit 18 <head> in the case it has no attributes and no children. This fixes the 19 Signature panel without affecting other WebViews that have non-trivial 20 <head> nodes. 21 22 * Misc/MailQuirksUserScript.js: If <head> exists but has no attributes 23 and no children, remove it. 24 1 25 2011-06-30 Dan Bernstein <mitz@apple.com> 2 26 -
trunk/Source/WebKit/mac/Misc/MailQuirksUserScript.js
r69622 r90223 1 1 /* 2 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 30 31 31 32 (function() { 32 function childrenBefore(parent, stopAt) 33 { 34 var children = []; 35 for (var child = parent.firstChild; child != stopAt; child = child.nextSibling) 36 children.push(child); 37 return children; 38 } 39 40 // If html or body is missing, Mail.app's assumption that 41 // document.firstChild.firstChild == document.body is wrong anyway, 42 // so return null to not move anything. 43 if (!document.documentElement || !document.body) 44 return; 45 46 var children = childrenBefore(document, document.documentElement); 47 children = children.concat(childrenBefore(document.documentElement, document.body)); 48 49 for (var i = children.length - 1; i >= 0; i--) { 50 var child = children[i]; 51 // It's not possible to move doctype nodes into the body, so just remove them. 52 if (child.nodeType == child.DOCUMENT_TYPE_NODE) 53 child.parentNode.removeChild(child); 54 else 55 document.body.insertBefore(child, document.body.firstChild); 56 } 33 // The Mail.app signature panel makes the assumption that 34 // document.firstChild.firstChild == document.body. This is no longer true 35 // now that WebKit implements the HTML5 parser, which creates an implicit 36 // <head> node if not explicitly specified in content. Remove this implicit 37 // <head> so that Mail.app's assumption remains true. 38 if (document.head && !document.head.childNodes.length && !document.head.attributes.length) 39 document.documentElement.removeChild(document.head); 57 40 })();
Note:
See TracChangeset
for help on using the changeset viewer.