/src/mozilla-central/layout/generic/nsFontInflationData.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | /* Per-block-formatting-context manager of font size inflation for pan and zoom UI. */ |
8 | | |
9 | | #ifndef nsFontInflationData_h_ |
10 | | #define nsFontInflationData_h_ |
11 | | |
12 | | #include "nsContainerFrame.h" |
13 | | |
14 | | class nsFontInflationData |
15 | | { |
16 | | using ReflowInput = mozilla::ReflowInput; |
17 | | |
18 | | public: |
19 | | |
20 | | static nsFontInflationData* FindFontInflationDataFor(const nsIFrame *aFrame); |
21 | | |
22 | | // Returns whether the effective width changed (which requires the |
23 | | // caller to mark its descendants dirty |
24 | | static bool |
25 | | UpdateFontInflationDataISizeFor(const ReflowInput& aReflowInput); |
26 | | |
27 | | static void MarkFontInflationDataTextDirty(nsIFrame *aFrame); |
28 | | |
29 | 0 | bool InflationEnabled() { |
30 | 0 | if (mTextDirty) { |
31 | 0 | ScanText(); |
32 | 0 | } |
33 | 0 | return mInflationEnabled; |
34 | 0 | } |
35 | | |
36 | 0 | nscoord EffectiveISize() const { |
37 | 0 | return mNCAISize; |
38 | 0 | } |
39 | | |
40 | | private: |
41 | | |
42 | | explicit nsFontInflationData(nsIFrame* aBFCFrame); |
43 | | |
44 | | nsFontInflationData(const nsFontInflationData&) = delete; |
45 | | void operator=(const nsFontInflationData&) = delete; |
46 | | |
47 | | void UpdateISize(const ReflowInput &aReflowInput); |
48 | | enum SearchDirection { eFromStart, eFromEnd }; |
49 | | static nsIFrame* FindEdgeInflatableFrameIn(nsIFrame *aFrame, |
50 | | SearchDirection aDirection); |
51 | | |
52 | 0 | void MarkTextDirty() { mTextDirty = true; } |
53 | | void ScanText(); |
54 | | // Scan text in the subtree rooted at aFrame. Increment mTextAmount |
55 | | // by multiplying the number of characters found by the font size |
56 | | // (yielding the inline-size that would be occupied by the characters if |
57 | | // they were all em squares). But stop scanning if mTextAmount |
58 | | // crosses mTextThreshold. |
59 | | void ScanTextIn(nsIFrame *aFrame); |
60 | | |
61 | | static const nsIFrame* FlowRootFor(const nsIFrame *aFrame) |
62 | 0 | { |
63 | 0 | while (!(aFrame->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT)) { |
64 | 0 | aFrame = aFrame->GetParent(); |
65 | 0 | } |
66 | 0 | return aFrame; |
67 | 0 | } |
68 | | |
69 | | nsIFrame *mBFCFrame; |
70 | | nscoord mNCAISize; |
71 | | nscoord mTextAmount, mTextThreshold; |
72 | | bool mInflationEnabled; // for this BFC |
73 | | bool mTextDirty; |
74 | | }; |
75 | | |
76 | | #endif /* !defined(nsFontInflationData_h_) */ |