Bug 960822 - Follow-up: use StringBeginsWith instead of Truncate+EqualsLiteral. r=dholbert
authorMats Palmgren <matspal@gmail.com>
Wed, 05 Feb 2014 15:45:59 +0000
changeset 184153 62a1d33b9fe0a3b9d566613333b09e717d69c83f
parent 184152 826d951bd6fa1e2b1159d68bc490ad14653ed2dc
child 184154 1ff2aed7f76fa6f6ae909b2f3e2f834c0273c844
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs960822
milestone30.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 960822 - Follow-up: use StringBeginsWith instead of Truncate+EqualsLiteral. r=dholbert
layout/printing/nsPrintEngine.cpp
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -2031,22 +2031,18 @@ nsPrintEngine::UpdateSelectionAndShrinkP
   // the furthest
   if (mPrt->mShrinkToFit && aDocumentIsTopLevel) {
     nsIPageSequenceFrame* pageSequence = aPO->mPresShell->GetPageSequenceFrame();
     NS_ENSURE_STATE(pageSequence);
     pageSequence->GetSTFPercent(aPO->mShrinkRatio);
     // Limit the shrink-to-fit scaling for some text-ish type of documents.
     nsAutoString contentType;
     aPO->mPresShell->GetDocument()->GetContentType(contentType);
-    bool applyLimit = contentType.EqualsLiteral("application/xhtml+xml");
-    if (contentType.Length() > 5) {
-      contentType.Truncate(5);
-    }
-    applyLimit = applyLimit || contentType.EqualsLiteral("text/");
-    if (applyLimit) {
+    if (contentType.EqualsLiteral("application/xhtml+xml") ||
+        StringBeginsWith(contentType, NS_LITERAL_STRING("text/"))) {
       int32_t limitPercent = 
         Preferences::GetInt("print.shrink-to-fit.scale-limit-percent", 20);
       limitPercent = std::max(0, limitPercent);
       limitPercent = std::min(100, limitPercent);
       float minShrinkRatio = float(limitPercent) / 100;
       aPO->mShrinkRatio = std::max(aPO->mShrinkRatio, minShrinkRatio);
     }
   }