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 "nsContainerFrame.h"
13 struct nsHTMLReflowState
;
15 class nsFontInflationData
19 static nsFontInflationData
* FindFontInflationDataFor(const nsIFrame
*aFrame
);
21 // Returns whether the effective width changed (which requires the
22 // caller to mark its descendants dirty
24 UpdateFontInflationDataWidthFor(const nsHTMLReflowState
& aReflowState
);
26 static void MarkFontInflationDataTextDirty(nsIFrame
*aFrame
);
28 bool InflationEnabled() {
32 return mInflationEnabled
;
35 nscoord
EffectiveWidth() const {
41 explicit 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; }
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
)
62 while (!(aFrame
->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT
)) {
63 aFrame
= aFrame
->GetParent();
70 nscoord mTextAmount
, mTextThreshold
;
71 bool mInflationEnabled
; // for this BFC
75 #endif /* !defined(nsFontInflationData_h_) */