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