Merge m-c and m-i
authorJustin Wood <Callek@gmail.com>
Mon, 21 Nov 2011 11:55:08 -0500
changeset 80576 75404dfd5ba5167bc968ae78f5adecbcf6611b00
parent 80557 9276e3274f18d69c840df1fa44f8b5b32d0e567a (current diff)
parent 80575 35b60f8565a7f97bb07b87672201ef66261177b7 (diff)
child 80577 069e4da44a5f8a5cbcec5fb1f82d62e8e0c412d1
push id21511
push userbmo@edmorley.co.uk
push dateTue, 22 Nov 2011 02:38:00 +0000
treeherdermozilla-central@b8955ff00aae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge m-c and m-i
--- a/configure.in
+++ b/configure.in
@@ -2345,17 +2345,20 @@ case "$target" in
     esac
     ;;
 
 *-darwin*)
     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
     MOZ_OPTIMIZE_FLAGS="-O3"
     _PEDANTIC=
-    MOZ_MEMORY=1
+    # Statically disable jemalloc on 10.5 and 32-bit 10.6.  See bug 702250.
+    if test "$HAVE_64BIT_OS"; then
+        MOZ_MEMORY=1
+    fi
     CFLAGS="$CFLAGS -fno-common"
     CXXFLAGS="$CXXFLAGS -fno-common"
     DLL_SUFFIX=".dylib"
     DSO_LDOPTS=''
     STRIP="$STRIP -x -S"
     # Check whether we're targeting OS X or iOS
     AC_CACHE_CHECK(for iOS target,
                    ac_cv_ios_target,
--- a/content/base/public/Element.h
+++ b/content/base/public/Element.h
@@ -83,26 +83,33 @@ enum {
   ELEMENT_TYPE_SPECIFIC_BITS_OFFSET = NODE_TYPE_SPECIFIC_BITS_OFFSET + 4
 };
 
 namespace mozilla {
 namespace dom {
 
 class Link;
 
+// IID for the dom::Element interface
+#define NS_ELEMENT_IID      \
+{ 0xa1588efb, 0x5a84, 0x49cd, \
+  { 0x99, 0x1a, 0xac, 0x84, 0x9d, 0x92, 0x05, 0x0f } }
+
 class Element : public nsIContent
 {
 public:
 #ifdef MOZILLA_INTERNAL_API
   Element(already_AddRefed<nsINodeInfo> aNodeInfo) :
     nsIContent(aNodeInfo),
     mState(NS_EVENT_STATE_MOZ_READONLY)
   {}
 #endif // MOZILLA_INTERNAL_API
 
+  NS_DECLARE_STATIC_IID_ACCESSOR(NS_ELEMENT_IID)
+
   NS_DECL_AND_IMPL_DOM_MEMORY_REPORTER_SIZEOF(Element, nsIContent)
 
   /**
    * Method to get the full state of this element.  See nsEventStates.h for
    * the possible bits that could be set here.
    */
   nsEventStates State() const {
     // mState is maintained by having whoever might have changed it
@@ -182,16 +189,18 @@ private:
                     "Should only be removing ESM-managed states here");
     RemoveStatesSilently(aStates);
     NotifyStateChange(aStates);
   }
 
   nsEventStates mState;
 };
 
+NS_DEFINE_STATIC_IID_ACCESSOR(Element, NS_ELEMENT_IID)
+
 } // namespace dom
 } // namespace mozilla
 
 inline mozilla::dom::Element* nsINode::AsElement() {
   NS_ASSERTION(IsElement(), "Not an element?");
   return static_cast<mozilla::dom::Element*>(this);
 }
 
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -4338,16 +4338,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
     }
   }
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 
 NS_INTERFACE_MAP_BEGIN(nsGenericElement)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsGenericElement)
+  NS_INTERFACE_MAP_ENTRY(Element)
   NS_INTERFACE_MAP_ENTRY(nsIContent)
   NS_INTERFACE_MAP_ENTRY(nsINode)
   NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
   NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSElement, new nsNSElementTearoff(this))
   NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
                                  new nsNodeSupportsWeakRefTearoff(this))
   NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNodeSelector,
                                  new nsNodeSelectorTearoff(this))
--- a/memory/jemalloc/jemalloc.c
+++ b/memory/jemalloc/jemalloc.c
@@ -984,20 +984,20 @@ struct arena_bin_s {
 
 #ifdef MALLOC_STATS
 	/* Bin statistics. */
 	malloc_bin_stats_t stats;
 #endif
 };
 
 struct arena_s {
-#ifdef MALLOC_DEBUG
+	/* For bug 703087, we're temporarily adding arena.magic to release
+	   builds. */
 	uint32_t		magic;
 #  define ARENA_MAGIC 0x947d3d24
-#endif
 
 	/* All operations on this arena require that lock be locked. */
 #ifdef MOZ_MEMORY
 	malloc_spinlock_t	lock;
 #else
 	pthread_mutex_t		lock;
 #endif
 
@@ -4327,17 +4327,25 @@ isalloc_validate(const void *ptr)
 	chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr);
 	if (chunk == NULL)
 		return (0);
 
 	if (malloc_rtree_get(chunk_rtree, (uintptr_t)chunk) == NULL)
 		return (0);
 
 	if (chunk != ptr) {
-		assert(chunk->arena->magic == ARENA_MAGIC);
+		/* For bug 703087, we've temporarily made what is normally a
+		   debug-only assertion here into a fatal assertion. */
+		if (chunk->arena->magic != ARENA_MAGIC) {
+			char* boom = (char*) 0;
+			_malloc_message("isalloc_validate called with invalid pointer. "
+			                "Crashing...\n", "", "", "");
+			*boom = 1;
+		}
+
 		return (arena_salloc(ptr));
 	} else {
 		size_t ret;
 		extent_node_t *node;
 		extent_node_t key;
 
 		/* Chunk. */
 		key.addr = (void *)chunk;
@@ -4837,20 +4845,19 @@ arena_new(arena_t *arena)
 
 		prev_run_size = arena_bin_run_size_calc(bin, prev_run_size);
 
 #ifdef MALLOC_STATS
 		memset(&bin->stats, 0, sizeof(malloc_bin_stats_t));
 #endif
 	}
 
-#ifdef MALLOC_DEBUG
+        /* For bug 703087, we're temporarily adding arena->magic for release
+           builds. */
 	arena->magic = ARENA_MAGIC;
-#endif
-
 	return (false);
 }
 
 /* Create a new arena and insert it into the arenas array at index ind. */
 static arena_t *
 arenas_extend(unsigned ind)
 {
 	arena_t *ret;
@@ -6058,23 +6065,26 @@ MALLOC_OUT:
 
 #ifdef MOZ_MEMORY_DARWIN
 	/*
 	* Overwrite the default memory allocator to use jemalloc everywhere.
 	*/
 	default_zone = malloc_default_zone();
 
 	/*
-	 * We only use jemalloc with versions of MacOS we've seen (10.5, 10.6, and
-	 * 10.7).  We'll have to update our code to work with newer versions,
-	 * because the malloc zone layout is likely to change.
+	 * We only use jemalloc with MacOS 10.6 and 10.7.  jemalloc is disabled
+	 * on 32-bit builds (10.5 and 32-bit 10.6) due to bug 702250, an
+	 * apparent MacOS bug.  In fact, this code isn't even compiled on
+	 * 32-bit builds.
+	 *
+	 * We'll have to update our code to work with newer versions, because
+	 * the malloc zone layout is likely to change.
 	 */
 
-	osx_use_jemalloc = (default_zone->version == LEOPARD_MALLOC_ZONE_T_VERSION ||
-			    default_zone->version == SNOW_LEOPARD_MALLOC_ZONE_T_VERSION ||
+	osx_use_jemalloc = (default_zone->version == SNOW_LEOPARD_MALLOC_ZONE_T_VERSION ||
 			    default_zone->version == LION_MALLOC_ZONE_T_VERSION);
 
 	/* Allow us dynamically turn off jemalloc for testing. */
 	if (getenv("NO_MAC_JEMALLOC")) {
 		osx_use_jemalloc = false;
 #ifdef __i386__
 		malloc_printf("Warning: NO_MAC_JEMALLOC has no effect on "
 			      "i386 machines (such as this one).\n");
--- a/netwerk/dns/effective_tld_names.dat
+++ b/netwerk/dns/effective_tld_names.dat
@@ -691,22 +691,24 @@ org.co
 rec.co
 web.co
 
 // com : http://en.wikipedia.org/wiki/.com
 com
 
 // CentralNic names : http://www.centralnic.com/names/domains
 // Confirmed by registry <gavin.brown@centralnic.com> 2008-06-09
+// Updated by registry <gavin.brown@centralnic.com> 2011-05-27
 ar.com
 br.com
 cn.com
 de.com
 eu.com
 gb.com
+gr.com
 hu.com
 jpn.com
 kr.com
 no.com
 qc.com
 ru.com
 sa.com
 se.com
@@ -757,16 +759,20 @@ gov.cx
 // cz : http://en.wikipedia.org/wiki/.cz
 cz
 
 // de : http://en.wikipedia.org/wiki/.de
 // Confirmed by registry <ops@denic.de> (with technical
 // reservations) 2008-07-01
 de
 
+// CentralNic names : http://www.centralnic.com/names/domains
+// Submitted by registry <gavin.brown@centralnic.com> 2011-05-27
+com.de
+
 // dj : http://en.wikipedia.org/wiki/.dj
 dj
 
 // dk : http://en.wikipedia.org/wiki/.dk
 // Confirmed by registry <robert@dk-hostmaster.dk> 2008-06-17
 dk
 
 // dm : http://en.wikipedia.org/wiki/.dm
@@ -3486,17 +3492,19 @@ nu
 !songfest.om
 !statecouncil.om
 
 // org : http://en.wikipedia.org/wiki/.org
 org
 
 // CentralNic names : http://www.centralnic.com/names/domains
 // Submitted by registry <gavin.brown@centralnic.com> 2008-06-17
+// Updated by registry <gavin.brown@centralnic.com> 2011-05-27
 ae.org
+us.org
 
 // ZaNiC names : http://www.za.net/
 // Confirmed by registry <hostmaster@nic.za.net> 2009-10-03
 za.org
 
 // pa : http://www.nic.pa/
 // Some additional second level "domains" resolve directly as hostnames, such as
 // pannet.pa, so we add a rule for "pa".
--- a/parser/html/javasrc/ElementName.java
+++ b/parser/html/javasrc/ElementName.java
@@ -365,16 +365,18 @@ public final class ElementName
 //            case TreeBuilder.MGLYPH_OR_MALIGNMARK:
 //                return "MGLYPH_OR_MALIGNMARK";
 //            case TreeBuilder.MI_MO_MN_MS_MTEXT:
 //                return "MI_MO_MN_MS_MTEXT";
 //            case TreeBuilder.ANNOTATION_XML:
 //                return "ANNOTATION_XML";
 //            case TreeBuilder.FOREIGNOBJECT_OR_DESC:
 //                return "FOREIGNOBJECT_OR_DESC";
+//            case TreeBuilder.MENUITEM:
+//                return "MENUITEM";
 //        }
 //        return null;
 //    }
 //
 //    /**
 //     * Regenerate self
 //     * 
 //     * @param args
@@ -708,16 +710,17 @@ public final class ElementName
     public static final ElementName GLYPHREF = new ElementName("glyphref", "glyphRef", TreeBuilder.OTHER);
     public static final ElementName INTERVAL = new ElementName("interval", "interval", TreeBuilder.OTHER);
     public static final ElementName INTEGERS = new ElementName("integers", "integers", TreeBuilder.OTHER);
     public static final ElementName INFINITY = new ElementName("infinity", "infinity", TreeBuilder.OTHER);
     public static final ElementName LISTENER = new ElementName("listener", "listener", TreeBuilder.OTHER);
     public static final ElementName LOWLIMIT = new ElementName("lowlimit", "lowlimit", TreeBuilder.OTHER);
     public static final ElementName METADATA = new ElementName("metadata", "metadata", TreeBuilder.OTHER);
     public static final ElementName MENCLOSE = new ElementName("menclose", "menclose", TreeBuilder.OTHER);
+    public static final ElementName MENUITEM = new ElementName("menuitem", "menuitem", TreeBuilder.MENUITEM | SPECIAL);
     public static final ElementName MPHANTOM = new ElementName("mphantom", "mphantom", TreeBuilder.OTHER);
     public static final ElementName NOFRAMES = new ElementName("noframes", "noframes", TreeBuilder.NOFRAMES | SPECIAL);
     public static final ElementName NOSCRIPT = new ElementName("noscript", "noscript", TreeBuilder.NOSCRIPT | SPECIAL);
     public static final ElementName OPTGROUP = new ElementName("optgroup", "optgroup", TreeBuilder.OPTGROUP | SPECIAL | OPTIONAL_END_TAG);
     public static final ElementName POLYLINE = new ElementName("polyline", "polyline", TreeBuilder.OTHER);
     public static final ElementName PREFETCH = new ElementName("prefetch", "prefetch", TreeBuilder.OTHER);
     public static final ElementName PROGRESS = new ElementName("progress", "progress", TreeBuilder.OTHER);
     public static final ElementName PRSUBSET = new ElementName("prsubset", "prsubset", TreeBuilder.OTHER);
@@ -1100,16 +1103,17 @@ public final class ElementName
     GLYPHREF,
     INTERVAL,
     INTEGERS,
     INFINITY,
     LISTENER,
     LOWLIMIT,
     METADATA,
     MENCLOSE,
+    MENUITEM,
     MPHANTOM,
     NOFRAMES,
     NOSCRIPT,
     OPTGROUP,
     POLYLINE,
     PREFETCH,
     PROGRESS,
     PRSUBSET,
@@ -1493,16 +1497,17 @@ public final class ElementName
     275977800,
     278267602,
     278513831,
     278712622,
     281613765,
     281683369,
     282120228,
     282250732,
+    282498697,
     282508942,
     283743649,
     283787570,
     284710386,
     285391148,
     285478533,
     285854898,
     285873762,
--- a/parser/html/javasrc/Tokenizer.java
+++ b/parser/html/javasrc/Tokenizer.java
@@ -1199,18 +1199,20 @@ public class Tokenizer implements Locato
                     if (html4ModeCompatibleWithXhtml1Schemata) {
                         attributes.addAttribute(attributeName,
                                 attributeName.getLocal(AttributeName.HTML),
                                 xmlnsPolicy);
                     } else {
                         attributes.addAttribute(attributeName, "", xmlnsPolicy);
                     }
                 } else {
-                    err("Attribute value omitted for a non-boolean attribute. (HTML4-only error.)");
-                    attributes.addAttribute(attributeName, "", xmlnsPolicy);
+                    if (AttributeName.BORDER != attributeName) {
+                        err("Attribute value omitted for a non-boolean attribute. (HTML4-only error.)");
+                        attributes.addAttribute(attributeName, "", xmlnsPolicy);
+                    }
                 }
             } else {
                 if (AttributeName.SRC == attributeName
                         || AttributeName.HREF == attributeName) {
                     warn("Attribute \u201C"
                             + attributeName.getLocal(AttributeName.HTML)
                             + "\u201D without an explicit value seen. The attribute may be dropped by IE7.");
                 }
@@ -6753,19 +6755,17 @@ public class Tokenizer implements Locato
             attributeName.release();
         }
         if (other.attributeName == null) {
             attributeName = null;
         } else {
             attributeName = other.attributeName.cloneAttributeName(interner);
         }
 
-        if (attributes != null) {
-            Portability.delete(attributes);
-        }
+        Portability.delete(attributes);
         if (other.attributes == null) {
             attributes = null;
         } else {
             attributes = other.attributes.cloneAttributes(interner);
         }
     }
 
     public void initializeWithoutStarting() throws SAXException {
--- a/parser/html/javasrc/TreeBuilder.java
+++ b/parser/html/javasrc/TreeBuilder.java
@@ -50,16 +50,17 @@ import nu.validator.htmlparser.annotatio
 import nu.validator.htmlparser.common.DoctypeExpectation;
 import nu.validator.htmlparser.common.DocumentMode;
 import nu.validator.htmlparser.common.DocumentModeHandler;
 import nu.validator.htmlparser.common.Interner;
 import nu.validator.htmlparser.common.TokenHandler;
 import nu.validator.htmlparser.common.XmlViolationPolicy;
 
 import org.xml.sax.ErrorHandler;
+import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
 public abstract class TreeBuilder<T> implements TokenHandler,
         TreeBuilderState<T> {
     
     /**
      * Array version of U+FFFD.
@@ -193,16 +194,18 @@ public abstract class TreeBuilder<T> imp
     final static int OUTPUT_OR_LABEL = 62;
 
     final static int OBJECT = 63;
 
     final static int FONT = 64;
 
     final static int KEYGEN = 65;
 
+    final static int MENUITEM = 66;
+
     // start insertion modes
 
     private static final int INITIAL = 0;
 
     private static final int BEFORE_HTML = 1;
 
     private static final int BEFORE_HEAD = 2;
 
@@ -335,17 +338,17 @@ public abstract class TreeBuilder<T> imp
             "-//w3o//dtd w3 html 3.0//", "-//webtechs//dtd mozilla html 2.0//",
             "-//webtechs//dtd mozilla html//" };
 
     private static final int NOT_FOUND_ON_STACK = Integer.MAX_VALUE;
 
     // [NOCPP[
 
     private static final @Local String HTML_LOCAL = "html";
-
+    
     // ]NOCPP]
 
     private int mode = INITIAL;
 
     private int originalMode = INITIAL;
     
     /**
      * Used only when moving back to IN_BODY.
@@ -357,16 +360,18 @@ public abstract class TreeBuilder<T> imp
     // [NOCPP[
 
     protected ErrorHandler errorHandler;
 
     private DocumentModeHandler documentModeHandler;
 
     private DoctypeExpectation doctypeExpectation = DoctypeExpectation.HTML;
 
+    private LocatorImpl firstCommentLocation;
+    
     // ]NOCPP]
 
     private boolean scriptingEnabled = false;
 
     private boolean needToDropLF;
 
     // [NOCPP[
 
@@ -514,16 +519,31 @@ public abstract class TreeBuilder<T> imp
     final void warn(String message) throws SAXException {
         if (errorHandler == null) {
             return;
         }
         SAXParseException spe = new SAXParseException(message, tokenizer);
         errorHandler.warning(spe);
     }
 
+    /**
+     * Reports a warning with an explicit locator
+     * 
+     * @param message
+     *            the message
+     * @throws SAXException
+     */
+    final void warn(String message, Locator locator) throws SAXException {
+        if (errorHandler == null) {
+            return;
+        }
+        SAXParseException spe = new SAXParseException(message, locator);
+        errorHandler.warning(spe);
+    }
+
     // ]NOCPP]
     
     @SuppressWarnings("unchecked") public final void startTokenization(Tokenizer self) throws SAXException {
         tokenizer = self;
         stack = new StackNode[64];
         listOfActiveFormattingElements = new StackNode[64];
         needToDropLF = false;
         originalMode = INITIAL;
@@ -531,16 +551,17 @@ public abstract class TreeBuilder<T> imp
         listPtr = -1;
         formPointer = null;
         headPointer = null;
         deepTreeSurrogateParent = null;
         // [NOCPP[
         html4 = false;
         idLocations.clear();
         wantingComments = wantsComments();
+        firstCommentLocation = null;
         // ]NOCPP]
         start(fragment);
         charBufferLen = 0;
         charBuffer = new char[1024];
         framesetOk = true;
         if (fragment) {
             T elt;
             if (contextNode != null) {
@@ -614,23 +635,31 @@ public abstract class TreeBuilder<T> imp
                             if (isQuirky(name, publicIdentifier,
                                     systemIdentifier, forceQuirks)) {
                                 errQuirkyDoctype();
                                 documentModeInternal(DocumentMode.QUIRKS_MODE,
                                         publicIdentifier, systemIdentifier,
                                         false);
                             } else if (isAlmostStandards(publicIdentifier,
                                     systemIdentifier)) {
+                                // [NOCPP[
+                                if (firstCommentLocation != null) {
+                                    warn("Comments seen before doctype. Internet Explorer will go into the quirks mode.", firstCommentLocation);
+                                }
+                                // ]NOCPP]
                                 errAlmostStandardsDoctype();
                                 documentModeInternal(
                                         DocumentMode.ALMOST_STANDARDS_MODE,
                                         publicIdentifier, systemIdentifier,
                                         false);
                             } else {
                                 // [NOCPP[
+                                if (firstCommentLocation != null) {
+                                    warn("Comments seen before doctype. Internet Explorer will go into the quirks mode.", firstCommentLocation);
+                                }
                                 if ((Portability.literalEqualsString(
                                         "-//W3C//DTD HTML 4.0//EN",
                                         publicIdentifier) && (systemIdentifier == null || Portability.literalEqualsString(
                                         "http://www.w3.org/TR/REC-html40/strict.dtd",
                                         systemIdentifier)))
                                         || (Portability.literalEqualsString(
                                                 "-//W3C//DTD HTML 4.01//EN",
                                                 publicIdentifier) && (systemIdentifier == null || Portability.literalEqualsString(
@@ -667,22 +696,28 @@ public abstract class TreeBuilder<T> imp
                             if (isQuirky(name, publicIdentifier,
                                     systemIdentifier, forceQuirks)) {
                                 err("Quirky doctype. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
                                 documentModeInternal(DocumentMode.QUIRKS_MODE,
                                         publicIdentifier, systemIdentifier,
                                         true);
                             } else if (isAlmostStandards(publicIdentifier,
                                     systemIdentifier)) {
+                                if (firstCommentLocation != null) {
+                                    warn("Comments seen before doctype. Internet Explorer will go into the quirks mode.", firstCommentLocation);
+                                }
                                 err("Almost standards mode doctype. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
                                 documentModeInternal(
                                         DocumentMode.ALMOST_STANDARDS_MODE,
                                         publicIdentifier, systemIdentifier,
                                         true);
                             } else {
+                                if (firstCommentLocation != null) {
+                                    warn("Comments seen before doctype. Internet Explorer will go into the quirks mode.", firstCommentLocation);
+                                }
                                 if ("-//W3C//DTD HTML 4.01//EN".equals(publicIdentifier)) {
                                     if (!"http://www.w3.org/TR/html4/strict.dtd".equals(systemIdentifier)) {
                                         warn("The doctype did not contain the system identifier prescribed by the HTML 4.01 specification. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
                                     }
                                 } else {
                                     err("The doctype was not the HTML 4.01 Strict doctype. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
                                 }
                                 documentModeInternal(
@@ -697,29 +732,35 @@ public abstract class TreeBuilder<T> imp
                             if (isQuirky(name, publicIdentifier,
                                     systemIdentifier, forceQuirks)) {
                                 err("Quirky doctype. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\u201D.");
                                 documentModeInternal(DocumentMode.QUIRKS_MODE,
                                         publicIdentifier, systemIdentifier,
                                         true);
                             } else if (isAlmostStandards(publicIdentifier,
                                     systemIdentifier)) {
+                                if (firstCommentLocation != null) {
+                                    warn("Comments seen before doctype. Internet Explorer will go into the quirks mode.", firstCommentLocation);
+                                }
                                 if ("-//W3C//DTD HTML 4.01 Transitional//EN".equals(publicIdentifier)
                                         && systemIdentifier != null) {
                                     if (!"http://www.w3.org/TR/html4/loose.dtd".equals(systemIdentifier)) {
                                         warn("The doctype did not contain the system identifier prescribed by the HTML 4.01 specification. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\u201D.");
                                     }
                                 } else {
                                     err("The doctype was not a non-quirky HTML 4.01 Transitional doctype. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\u201D.");
                                 }
                                 documentModeInternal(
                                         DocumentMode.ALMOST_STANDARDS_MODE,
                                         publicIdentifier, systemIdentifier,
                                         true);
                             } else {
+                                if (firstCommentLocation != null) {
+                                    warn("Comments seen before doctype. Internet Explorer will go into the quirks mode.", firstCommentLocation);
+                                }
                                 err("The doctype was not the HTML 4.01 Transitional doctype. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\u201D.");
                                 documentModeInternal(
                                         DocumentMode.STANDARDS_MODE,
                                         publicIdentifier, systemIdentifier,
                                         true);
                             }
                             break;
                         case AUTO:
@@ -730,28 +771,34 @@ public abstract class TreeBuilder<T> imp
                             if (isQuirky(name, publicIdentifier,
                                     systemIdentifier, forceQuirks)) {
                                 err("Quirky doctype. Expected e.g. \u201C<!DOCTYPE html>\u201D.");
                                 documentModeInternal(DocumentMode.QUIRKS_MODE,
                                         publicIdentifier, systemIdentifier,
                                         html4);
                             } else if (isAlmostStandards(publicIdentifier,
                                     systemIdentifier)) {
+                                if (firstCommentLocation != null) {
+                                    warn("Comments seen before doctype. Internet Explorer will go into the quirks mode.", firstCommentLocation);
+                                }
                                 if ("-//W3C//DTD HTML 4.01 Transitional//EN".equals(publicIdentifier)) {
                                     if (!"http://www.w3.org/TR/html4/loose.dtd".equals(systemIdentifier)) {
                                         warn("The doctype did not contain the system identifier prescribed by the HTML 4.01 specification. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\u201D.");
                                     }
                                 } else {
                                     err("Almost standards mode doctype. Expected e.g. \u201C<!DOCTYPE html>\u201D.");
                                 }
                                 documentModeInternal(
                                         DocumentMode.ALMOST_STANDARDS_MODE,
                                         publicIdentifier, systemIdentifier,
                                         html4);
                             } else {
+                                if (firstCommentLocation != null) {
+                                    warn("Comments seen before doctype. Internet Explorer will go into the quirks mode.", firstCommentLocation);
+                                }
                                 if ("-//W3C//DTD HTML 4.01//EN".equals(publicIdentifier)) {
                                     if (!"http://www.w3.org/TR/html4/strict.dtd".equals(systemIdentifier)) {
                                         warn("The doctype did not contain the system identifier prescribed by the HTML 4.01 specification. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
                                     }
                                 } else {
                                     if (!(publicIdentifier == null && systemIdentifier == null)) {
                                         err("Legacy doctype. Expected e.g. \u201C<!DOCTYPE html>\u201D.");
                                     }
@@ -817,16 +864,19 @@ public abstract class TreeBuilder<T> imp
     }
 
     // ]NOCPP]
 
     public final void comment(@NoLength char[] buf, int start, int length)
             throws SAXException {
         needToDropLF = false;
         // [NOCPP[
+        if (firstCommentLocation == null) {
+            firstCommentLocation = new LocatorImpl(tokenizer);
+        }
         if (!wantingComments) {
             return;
         }
         // ]NOCPP]
         if (!isInForeign()) {
             switch (mode) {
                 case INITIAL:
                 case BEFORE_HTML:
@@ -2052,16 +2102,17 @@ public abstract class TreeBuilder<T> imp
                                 mode = IN_TABLE;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case BR:
                             case EMBED_OR_IMG:
                             case AREA_OR_WBR:
                                 reconstructTheActiveFormattingElements();
                                 // FALL THROUGH to PARAM_OR_SOURCE_OR_TRACK
+                            // CPPONLY: case MENUITEM:
                             case PARAM_OR_SOURCE_OR_TRACK:
                                 appendVoidElementToCurrentMayFoster(
                                         elementName,
                                         attributes);
                                 selfClosing = false;
                                 attributes = null; // CPP
                                 break starttagloop;
                             case HR:
@@ -3512,16 +3563,17 @@ public abstract class TreeBuilder<T> imp
                                 }
                             }
                             reconstructTheActiveFormattingElements();
                             appendVoidElementToCurrentMayFoster(
                                     elementName,
                                     HtmlAttributes.EMPTY_ATTRIBUTES);
                             break endtagloop;
                         case AREA_OR_WBR:
+                        // CPPONLY: case MENUITEM:
                         case PARAM_OR_SOURCE_OR_TRACK:
                         case EMBED_OR_IMG:
                         case IMAGE:
                         case INPUT:
                         case KEYGEN: // XXX??
                         case HR:
                         case ISINDEX:
                         case IFRAME:
@@ -4678,20 +4730,20 @@ public abstract class TreeBuilder<T> imp
                     if (!"http://www.w3.org/1999/xlink".equals(xmlns)) {
                         err("Bad value \u201C"
                                 + xmlns
                                 + "\u201D for the attribute \u201Cxmlns:link\u201D (only \u201Chttp://www.w3.org/1999/xlink\u201D permitted here).");
                         switch (namePolicy) {
                             case ALTER_INFOSET:
                                 // fall through
                             case ALLOW:
-                                warn("Attribute \u201Cxmlns:xlink\u201D with the value \u201Chttp://www.w3org/1999/xlink\u201D is not serializable as XML 1.0 without changing document semantics.");
+                                warn("Attribute \u201Cxmlns:xlink\u201D with a value other than \u201Chttp://www.w3.org/1999/xlink\u201D is not serializable as XML 1.0 without changing document semantics.");
                                 break;
                             case FATAL:
-                                fatal("Attribute \u201Cxmlns:xlink\u201D with the value \u201Chttp://www.w3org/1999/xlink\u201D is not serializable as XML 1.0 without changing document semantics.");
+                                fatal("Attribute \u201Cxmlns:xlink\u201D with a value other than \u201Chttp://www.w3.org/1999/xlink\u201D is not serializable as XML 1.0 without changing document semantics.");
                                 break;
                         }
                     }
                 } else {
                     err("Attribute \u201C" + attributes.getXmlnsLocalName(i)
                             + "\u201D not allowed here.");
                     switch (namePolicy) {
                         case ALTER_INFOSET:
--- a/parser/html/javasrc/UTF16Buffer.java
+++ b/parser/html/javasrc/UTF16Buffer.java
@@ -46,32 +46,36 @@ public final class UTF16Buffer {
 
     /**
      * The index of the slot immediately after the last character in the backing
      * buffer that is part of the logical content of this
      * <code>UTF16Buffer</code>.
      */
     private int end;
 
+    //[NOCPP[
+    
     /**
      * Constructor for wrapping an existing UTF-16 code unit array.
      * 
      * @param buffer
      *            the backing buffer
      * @param start
      *            the index of the first character to consume
      * @param end
      *            the index immediately after the last character to consume
      */
     public UTF16Buffer(@NoLength char[] buffer, int start, int end) {
         this.buffer = buffer;
         this.start = start;
         this.end = end;
     }
 
+    // ]NOCPP]
+    
     /**
      * Returns the start index.
      * 
      * @return the start index
      */
     public int getStart() {
         return start;
     }