layout/generic/nsFontInflationData.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 /* Per-block-formatting-context manager of font size inflation for pan and zoom UI. */
     8 #ifndef nsFontInflationData_h_
     9 #define nsFontInflationData_h_
    11 #include "nsIFrame.h"
    13 struct nsHTMLReflowState;
    15 class nsFontInflationData
    16 {
    17 public:
    19   static nsFontInflationData* FindFontInflationDataFor(const nsIFrame *aFrame);
    21   // Returns whether the effective width changed (which requires the
    22   // caller to mark its descendants dirty
    23   static bool
    24     UpdateFontInflationDataWidthFor(const nsHTMLReflowState& aReflowState);
    26   static void MarkFontInflationDataTextDirty(nsIFrame *aFrame);
    28   bool InflationEnabled() {
    29     if (mTextDirty) {
    30       ScanText();
    31     }
    32     return mInflationEnabled;
    33   }
    35   nscoord EffectiveWidth() const {
    36     return mNCAWidth;
    37   }
    39 private:
    41   nsFontInflationData(nsIFrame* aBFCFrame);
    43   nsFontInflationData(const nsFontInflationData&) MOZ_DELETE;
    44   void operator=(const nsFontInflationData&) MOZ_DELETE;
    46   void UpdateWidth(const nsHTMLReflowState &aReflowState);
    47   enum SearchDirection { eFromStart, eFromEnd };
    48   static nsIFrame* FindEdgeInflatableFrameIn(nsIFrame *aFrame,
    49                                              SearchDirection aDirection);
    51   void MarkTextDirty() { mTextDirty = true; }
    52   void ScanText();
    53   // Scan text in the subtree rooted at aFrame.  Increment mTextAmount
    54   // by multiplying the number of characters found by the font size
    55   // (yielding the width that would be occupied by the characters if
    56   // they were all em squares).  But stop scanning if mTextAmount
    57   // crosses mTextThreshold.
    58   void ScanTextIn(nsIFrame *aFrame);
    60   static const nsIFrame* FlowRootFor(const nsIFrame *aFrame)
    61   {
    62     while (!(aFrame->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT)) {
    63       aFrame = aFrame->GetParent();
    64     }
    65     return aFrame;
    66   }
    68   nsIFrame *mBFCFrame;
    69   nscoord mNCAWidth;
    70   nscoord mTextAmount, mTextThreshold;
    71   bool mInflationEnabled; // for this BFC
    72   bool mTextDirty;
    73 };
    75 #endif /* !defined(nsFontInflationData_h_) */

mercurial