Bug 655877 - Part 29: Don't underline links within SVG text by default. r=dbaron
authorCameron McCormack <cam@mcc.id.au>
Sun, 05 Aug 2012 11:01:19 +1000
changeset 101489 05848864b5f9f908b60d4bac8922291119c70091
parent 101488 6899651a0f096311cb8c1573b3854f81bb9a1ab7
child 101490 0e213ba77dca4032ddc876d788d83fa28eb48f49
push id23235
push userkhuey@mozilla.com
push dateSun, 05 Aug 2012 15:30:53 +0000
treeherdermozilla-central@6347710412a5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs655877
milestone17.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
Bug 655877 - Part 29: Don't underline links within SVG text by default. r=dbaron
layout/base/nsPresShell.cpp
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -1191,31 +1191,38 @@ PresShell::CreatePreferenceStyleSheet()
     mPrefStyleSheet = nullptr;
     return rv;
   }
   NS_ASSERTION(uri, "null but no error");
   mPrefStyleSheet->SetURIs(uri, uri, uri);
   mPrefStyleSheet->SetComplete();
   PRUint32 index;
   rv =
+    mPrefStyleSheet->InsertRuleInternal(NS_LITERAL_STRING("@namespace svg url(http://www.w3.org/2000/svg);"),
+                                        0, &index);
+  if (NS_FAILED(rv)) {
+    mPrefStyleSheet = nullptr;
+    return rv;
+  }
+  rv =
     mPrefStyleSheet->InsertRuleInternal(NS_LITERAL_STRING("@namespace url(http://www.w3.org/1999/xhtml);"),
                                         0, &index);
   if (NS_FAILED(rv)) {
     mPrefStyleSheet = nullptr;
     return rv;
   }
 
   mStyleSet->AppendStyleSheet(nsStyleSet::eUserSheet, mPrefStyleSheet);
   return NS_OK;
 }
 
-// XXX We want these after the @namespace rule.  Does order matter
+// XXX We want these after the @namespace rules.  Does order matter
 // for these rules, or can we call StyleRule::StyleRuleCount()
 // and just "append"?
-static PRUint32 sInsertPrefSheetRulesAt = 1;
+static PRUint32 sInsertPrefSheetRulesAt = 2;
 
 nsresult
 PresShell::SetPrefNoScriptRule()
 {
   NS_TIME_FUNCTION_MIN(1.0);
 
   nsresult rv = NS_OK;
 
@@ -1340,17 +1347,17 @@ nsresult PresShell::SetPrefLinkRules(voi
 
   if (underlineLinks) {
     // create a rule to make underlining happen
     //  '*|*:-moz-any-link {text-decoration:[underline|none];}'
     // no need for important, we want these to be overridable
     // NOTE: these must go in the agent stylesheet or they cannot be
     //       overridden by authors
     rv = mPrefStyleSheet->
-      InsertRuleInternal(NS_LITERAL_STRING("*|*:-moz-any-link{text-decoration:underline}"),
+      InsertRuleInternal(NS_LITERAL_STRING("*|*:-moz-any-link:not(svg|a){text-decoration:underline}"),
                          sInsertPrefSheetRulesAt, &index);
   } else {
     rv = mPrefStyleSheet->
       InsertRuleInternal(NS_LITERAL_STRING("*|*:-moz-any-link{text-decoration:none}"),
                          sInsertPrefSheetRulesAt, &index);
   }
 
   return rv;