Bug 410857 part 3 - Cache the PresContext instead of fetching it for every paragraph. r=jfkthame
authorMats Palmgren <mats@mozilla.com>
Mon, 20 Feb 2017 17:43:08 +0100
changeset 343873 f7605fcc9b38cea88d2ed0b05324886cb7f7354b
parent 343872 76f8f7b04aa8f13e0559d15925173e405d263a9b
child 343874 4993c79562fe6f593a3027d14f8defeef36d74ef
push id87209
push usermpalmgren@mozilla.com
push dateMon, 20 Feb 2017 16:43:18 +0000
treeherdermozilla-inbound@5ef786064180 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs410857
milestone54.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 410857 part 3 - Cache the PresContext instead of fetching it for every paragraph. r=jfkthame
layout/base/nsBidiPresUtils.cpp
--- a/layout/base/nsBidiPresUtils.cpp
+++ b/layout/base/nsBidiPresUtils.cpp
@@ -128,29 +128,32 @@ GetBidiControl(nsStyleContext* aStyleCon
 
 struct MOZ_STACK_CLASS BidiParagraphData
 {
   nsAutoString        mBuffer;
   AutoTArray<char16_t, 16> mEmbeddingStack;
   AutoTArray<nsIFrame*, 16> mLogicalFrames;
   AutoTArray<nsLineBox*, 16> mLinePerFrame;
   nsDataHashtable<nsISupportsHashKey, int32_t> mContentToFrameIndex;
+  // Cached presentation context for the frames we're processing.
+  nsPresContext*      mPresContext;
   bool                mIsVisual;
   nsBidiLevel         mParaLevel;
   nsIContent*         mPrevContent;
   nsBidi              mBidiEngine;
   nsIFrame*           mPrevFrame;
 
-  void Init(nsBlockFrame *aBlockFrame)
+  void Init(nsBlockFrame* aBlockFrame)
   {
     mPrevContent = nullptr;
 
     mParaLevel = nsBidiPresUtils::BidiLevelFromStyle(aBlockFrame->StyleContext());
 
-    mIsVisual = aBlockFrame->PresContext()->IsVisualMode();
+    mPresContext = aBlockFrame->PresContext();
+    mIsVisual = mPresContext->IsVisualMode();
     if (mIsVisual) {
       /**
        * Drill up in content to detect whether this is an element that needs to
        * be rendered with logical order even on visual pages.
        *
        * We always use logical order on form controls, firstly so that text
        * entry will be in logical order, but also because visual pages were
        * written with the assumption that even if the browser had no support
@@ -708,18 +711,16 @@ nsBidiPresUtils::Resolve(nsBlockFrame* a
 
   return ResolveParagraph(aBlockFrame, &bpd);
 }
 
 nsresult
 nsBidiPresUtils::ResolveParagraph(nsBlockFrame* aBlockFrame,
                                   BidiParagraphData* aBpd)
 {
-  nsPresContext *presContext = aBlockFrame->PresContext();
-
   if (aBpd->BufferLength() < 1) {
     return NS_OK;
   }
   aBpd->mBuffer.ReplaceChar(kSeparators, kSpace);
 
   int32_t runCount;
 
   nsresult rv = aBpd->SetPara();
@@ -737,17 +738,17 @@ nsBidiPresUtils::ResolveParagraph(nsBloc
   int32_t     frameIndex     = -1;  // index to the frames in mLogicalFrames
   int32_t     frameCount     = aBpd->FrameCount();
   int32_t     contentOffset  = 0;   // offset of current frame in its content node
   bool        isTextFrame    = false;
   nsIFrame*   frame = nullptr;
   nsIContent* content = nullptr;
   int32_t     contentTextLength = 0;
 
-  FramePropertyTable *propTable = presContext->PropertyTable();
+  FramePropertyTable* propTable = aBpd->mPresContext->PropertyTable();
   nsLineBox* currentLine = nullptr;
   
 #ifdef DEBUG
 #ifdef NOISY_BIDI
   printf("Before Resolve(), aBlockFrame=0x%p, mBuffer='%s', frameCount=%d, runCount=%d\n",
          (void*)aBlockFrame, NS_ConvertUTF16toUTF8(aBpd->mBuffer).get(), frameCount, runCount);
 #ifdef REALLY_NOISY_BIDI
   printf(" block frame tree=:\n");