2012-04-17 02:32:12 +04:00
|
|
|
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2012-04-17 02:32:12 +04:00
|
|
|
|
|
|
|
/* Per-block-formatting-context manager of font size inflation for pan and zoom UI. */
|
|
|
|
|
|
|
|
#include "nsFontInflationData.h"
|
2017-05-27 14:36:00 +03:00
|
|
|
#include "FrameProperties.h"
|
2012-05-05 17:24:45 +04:00
|
|
|
#include "nsTextControlFrame.h"
|
|
|
|
#include "nsListControlFrame.h"
|
|
|
|
#include "nsComboboxControlFrame.h"
|
2016-07-21 13:36:34 +03:00
|
|
|
#include "mozilla/ReflowInput.h"
|
2012-04-17 02:32:12 +04:00
|
|
|
#include "nsTextFrameUtils.h"
|
2012-04-17 02:32:12 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2012-04-17 02:32:12 +04:00
|
|
|
using namespace mozilla::layout;
|
2012-04-17 02:32:12 +04:00
|
|
|
|
2016-01-28 06:23:59 +03:00
|
|
|
NS_DECLARE_FRAME_PROPERTY_DELETABLE(FontInflationDataProperty,
|
|
|
|
nsFontInflationData)
|
2012-04-17 02:32:12 +04:00
|
|
|
|
|
|
|
/* static */ nsFontInflationData*
|
|
|
|
nsFontInflationData::FindFontInflationDataFor(const nsIFrame *aFrame)
|
|
|
|
{
|
|
|
|
// We have one set of font inflation data per block formatting context.
|
|
|
|
const nsIFrame *bfc = FlowRootFor(aFrame);
|
2012-04-17 02:32:12 +04:00
|
|
|
NS_ASSERTION(bfc->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT,
|
|
|
|
"should have found a flow root");
|
2012-04-17 02:32:12 +04:00
|
|
|
|
2017-05-27 14:36:00 +03:00
|
|
|
return bfc->GetProperty(FontInflationDataProperty());
|
2012-04-17 02:32:12 +04:00
|
|
|
}
|
2012-04-17 02:32:12 +04:00
|
|
|
|
2012-06-12 00:57:35 +04:00
|
|
|
/* static */ bool
|
2016-07-21 13:36:39 +03:00
|
|
|
nsFontInflationData::UpdateFontInflationDataISizeFor(const ReflowInput& aReflowInput)
|
2012-04-17 02:32:12 +04:00
|
|
|
{
|
2016-07-21 13:36:39 +03:00
|
|
|
nsIFrame *bfc = aReflowInput.mFrame;
|
2012-04-17 02:32:12 +04:00
|
|
|
NS_ASSERTION(bfc->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT,
|
|
|
|
"should have been given a flow root");
|
2017-05-27 14:36:00 +03:00
|
|
|
nsFontInflationData *data = bfc->GetProperty(FontInflationDataProperty());
|
2012-06-12 00:57:35 +04:00
|
|
|
bool oldInflationEnabled;
|
2015-03-10 17:28:23 +03:00
|
|
|
nscoord oldNCAISize;
|
2012-06-12 00:57:35 +04:00
|
|
|
if (data) {
|
2015-03-10 17:28:23 +03:00
|
|
|
oldNCAISize = data->mNCAISize;
|
2012-06-12 00:57:35 +04:00
|
|
|
oldInflationEnabled = data->mInflationEnabled;
|
|
|
|
} else {
|
2012-04-17 02:32:12 +04:00
|
|
|
data = new nsFontInflationData(bfc);
|
2017-05-27 14:36:00 +03:00
|
|
|
bfc->SetProperty(FontInflationDataProperty(), data);
|
2015-03-10 17:28:23 +03:00
|
|
|
oldNCAISize = -1;
|
2012-06-12 00:57:35 +04:00
|
|
|
oldInflationEnabled = true; /* not relevant */
|
2012-04-17 02:32:12 +04:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
data->UpdateISize(aReflowInput);
|
2012-06-12 00:57:35 +04:00
|
|
|
|
2012-09-28 23:38:33 +04:00
|
|
|
if (oldInflationEnabled != data->mInflationEnabled)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return oldInflationEnabled &&
|
2015-03-10 17:28:23 +03:00
|
|
|
oldNCAISize != data->mNCAISize;
|
2012-04-17 02:32:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
nsFontInflationData::MarkFontInflationDataTextDirty(nsIFrame *aBFCFrame)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aBFCFrame->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT,
|
|
|
|
"should have been given a flow root");
|
|
|
|
|
2017-05-27 14:36:00 +03:00
|
|
|
nsFontInflationData *data = aBFCFrame->GetProperty(FontInflationDataProperty());
|
2012-04-17 02:32:12 +04:00
|
|
|
if (data) {
|
|
|
|
data->MarkTextDirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsFontInflationData::nsFontInflationData(nsIFrame *aBFCFrame)
|
|
|
|
: mBFCFrame(aBFCFrame)
|
2015-03-10 17:28:23 +03:00
|
|
|
, mNCAISize(0)
|
2012-04-17 02:32:12 +04:00
|
|
|
, mTextAmount(0)
|
|
|
|
, mTextThreshold(0)
|
|
|
|
, mInflationEnabled(false)
|
|
|
|
, mTextDirty(true)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the closest common ancestor between aFrame1 and aFrame2, except
|
|
|
|
* treating the parent of a frame as the first-in-flow of its parent (so
|
|
|
|
* the result doesn't change when breaking changes).
|
|
|
|
*
|
|
|
|
* aKnownCommonAncestor is a known common ancestor of both.
|
|
|
|
*/
|
|
|
|
static nsIFrame*
|
|
|
|
NearestCommonAncestorFirstInFlow(nsIFrame *aFrame1, nsIFrame *aFrame2,
|
|
|
|
nsIFrame *aKnownCommonAncestor)
|
|
|
|
{
|
2013-09-25 15:42:34 +04:00
|
|
|
aFrame1 = aFrame1->FirstInFlow();
|
|
|
|
aFrame2 = aFrame2->FirstInFlow();
|
|
|
|
aKnownCommonAncestor = aKnownCommonAncestor->FirstInFlow();
|
2012-04-17 02:32:12 +04:00
|
|
|
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<nsIFrame*, 32> ancestors1, ancestors2;
|
2012-04-17 02:32:12 +04:00
|
|
|
for (nsIFrame *f = aFrame1; f != aKnownCommonAncestor;
|
2013-09-25 15:42:34 +04:00
|
|
|
(f = f->GetParent()) && (f = f->FirstInFlow())) {
|
2012-04-17 02:32:12 +04:00
|
|
|
ancestors1.AppendElement(f);
|
|
|
|
}
|
|
|
|
for (nsIFrame *f = aFrame2; f != aKnownCommonAncestor;
|
2013-09-25 15:42:34 +04:00
|
|
|
(f = f->GetParent()) && (f = f->FirstInFlow())) {
|
2012-04-17 02:32:12 +04:00
|
|
|
ancestors2.AppendElement(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame *result = aKnownCommonAncestor;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t i1 = ancestors1.Length(),
|
2012-04-17 02:32:12 +04:00
|
|
|
i2 = ancestors2.Length();
|
|
|
|
while (i1-- != 0 && i2-- != 0) {
|
|
|
|
if (ancestors1[i1] != ancestors2[i2]) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
result = ancestors1[i1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nscoord
|
2016-07-21 13:36:39 +03:00
|
|
|
ComputeDescendantISize(const ReflowInput& aAncestorReflowInput,
|
2012-04-17 02:32:12 +04:00
|
|
|
nsIFrame *aDescendantFrame)
|
|
|
|
{
|
2016-07-21 13:36:39 +03:00
|
|
|
nsIFrame *ancestorFrame = aAncestorReflowInput.mFrame->FirstInFlow();
|
2012-04-17 02:32:12 +04:00
|
|
|
if (aDescendantFrame == ancestorFrame) {
|
2016-07-21 13:36:39 +03:00
|
|
|
return aAncestorReflowInput.ComputedISize();
|
2012-04-17 02:32:12 +04:00
|
|
|
}
|
|
|
|
|
2016-02-02 18:36:31 +03:00
|
|
|
AutoTArray<nsIFrame*, 16> frames;
|
2012-04-17 02:32:12 +04:00
|
|
|
for (nsIFrame *f = aDescendantFrame; f != ancestorFrame;
|
2013-09-25 15:42:34 +04:00
|
|
|
f = f->GetParent()->FirstInFlow()) {
|
2012-04-17 02:32:12 +04:00
|
|
|
frames.AppendElement(f);
|
|
|
|
}
|
|
|
|
|
2015-03-10 17:28:23 +03:00
|
|
|
// This ignores the inline-size contributions made by scrollbars, though in
|
2012-06-06 06:13:41 +04:00
|
|
|
// reality we don't have any scrollbars on the sorts of devices on
|
|
|
|
// which we use font inflation, so it's not a problem. But it may
|
|
|
|
// occasionally cause problems when writing tests on desktop.
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t len = frames.Length();
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowInput *reflowInputs = static_cast<ReflowInput*>
|
2016-07-21 13:36:35 +03:00
|
|
|
(moz_xmalloc(sizeof(ReflowInput) * len));
|
2012-04-17 02:32:12 +04:00
|
|
|
nsPresContext *presContext = aDescendantFrame->PresContext();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < len; ++i) {
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput &parentReflowInput =
|
|
|
|
(i == 0) ? aAncestorReflowInput : reflowInputs[i - 1];
|
2012-04-17 02:32:12 +04:00
|
|
|
nsIFrame *frame = frames[len - i - 1];
|
2014-07-24 12:28:46 +04:00
|
|
|
WritingMode wm = frame->GetWritingMode();
|
2016-07-21 13:36:39 +03:00
|
|
|
LogicalSize availSize = parentReflowInput.ComputedSize(wm);
|
2014-07-24 12:28:46 +04:00
|
|
|
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(frame->GetParent()->FirstInFlow() ==
|
2016-07-21 13:36:39 +03:00
|
|
|
parentReflowInput.mFrame->FirstInFlow(),
|
2015-02-10 01:34:50 +03:00
|
|
|
"bad logic in this function");
|
2016-07-21 13:36:39 +03:00
|
|
|
new (reflowInputs + i) ReflowInput(presContext, parentReflowInput,
|
2012-04-17 02:32:12 +04:00
|
|
|
frame, availSize);
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
MOZ_ASSERT(reflowInputs[len - 1].mFrame == aDescendantFrame,
|
2015-02-10 01:34:50 +03:00
|
|
|
"bad logic in this function");
|
2016-07-21 13:36:39 +03:00
|
|
|
nscoord result = reflowInputs[len - 1].ComputedISize();
|
2012-04-17 02:32:12 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = len; i-- != 0; ) {
|
2016-07-21 13:36:39 +03:00
|
|
|
reflowInputs[i].~ReflowInput();
|
2012-04-17 02:32:12 +04:00
|
|
|
}
|
2016-07-21 13:36:39 +03:00
|
|
|
free(reflowInputs);
|
2012-04-17 02:32:12 +04:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-07-21 13:36:39 +03:00
|
|
|
nsFontInflationData::UpdateISize(const ReflowInput &aReflowInput)
|
2012-04-17 02:32:12 +04:00
|
|
|
{
|
2016-07-21 13:36:39 +03:00
|
|
|
nsIFrame *bfc = aReflowInput.mFrame;
|
2012-04-17 02:32:12 +04:00
|
|
|
NS_ASSERTION(bfc->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT,
|
|
|
|
"must be block formatting context");
|
|
|
|
|
|
|
|
nsIFrame *firstInflatableDescendant =
|
|
|
|
FindEdgeInflatableFrameIn(bfc, eFromStart);
|
|
|
|
if (!firstInflatableDescendant) {
|
|
|
|
mTextAmount = 0;
|
|
|
|
mTextThreshold = 0; // doesn't matter
|
|
|
|
mTextDirty = false;
|
|
|
|
mInflationEnabled = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsIFrame *lastInflatableDescendant =
|
|
|
|
FindEdgeInflatableFrameIn(bfc, eFromEnd);
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!firstInflatableDescendant == !lastInflatableDescendant,
|
|
|
|
"null-ness should match; NearestCommonAncestorFirstInFlow"
|
|
|
|
" will crash when passed null");
|
2012-04-17 02:32:12 +04:00
|
|
|
|
2015-03-10 17:28:23 +03:00
|
|
|
// Particularly when we're computing for the root BFC, the inline-size of
|
|
|
|
// nca might differ significantly for the inline-size of bfc.
|
2012-04-17 02:32:12 +04:00
|
|
|
nsIFrame *nca = NearestCommonAncestorFirstInFlow(firstInflatableDescendant,
|
|
|
|
lastInflatableDescendant,
|
|
|
|
bfc);
|
2013-10-01 01:26:04 +04:00
|
|
|
while (!nca->IsContainerForFontSizeInflation()) {
|
2013-09-25 15:42:34 +04:00
|
|
|
nca = nca->GetParent()->FirstInFlow();
|
2012-04-17 02:32:12 +04:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
nscoord newNCAISize = ComputeDescendantISize(aReflowInput, nca);
|
2012-04-17 02:32:12 +04:00
|
|
|
|
|
|
|
// See comment above "font.size.inflation.lineThreshold" in
|
|
|
|
// modules/libpref/src/init/all.js .
|
2012-06-06 07:47:33 +04:00
|
|
|
nsIPresShell* presShell = bfc->PresContext()->PresShell();
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t lineThreshold = presShell->FontSizeInflationLineThreshold();
|
2015-03-10 17:28:23 +03:00
|
|
|
nscoord newTextThreshold = (newNCAISize * lineThreshold) / 100;
|
2012-04-17 02:32:12 +04:00
|
|
|
|
|
|
|
if (mTextThreshold <= mTextAmount && mTextAmount < newTextThreshold) {
|
|
|
|
// Because we truncate our scan when we hit sufficient text, we now
|
|
|
|
// need to rescan.
|
|
|
|
mTextDirty = true;
|
|
|
|
}
|
|
|
|
|
2015-03-10 17:28:23 +03:00
|
|
|
mNCAISize = newNCAISize;
|
2012-04-17 02:32:12 +04:00
|
|
|
mTextThreshold = newTextThreshold;
|
|
|
|
mInflationEnabled = mTextAmount >= mTextThreshold;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ nsIFrame*
|
|
|
|
nsFontInflationData::FindEdgeInflatableFrameIn(nsIFrame* aFrame,
|
|
|
|
SearchDirection aDirection)
|
|
|
|
{
|
|
|
|
// NOTE: This function has a similar structure to ScanTextIn!
|
|
|
|
|
|
|
|
// FIXME: Should probably only scan the text that's actually going to
|
|
|
|
// be inflated!
|
|
|
|
|
|
|
|
nsIFormControlFrame* fcf = do_QueryFrame(aFrame);
|
|
|
|
if (fcf) {
|
|
|
|
return aFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: aDirection!
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<FrameChildList, 4> lists;
|
2012-04-17 02:32:12 +04:00
|
|
|
aFrame->GetChildLists(&lists);
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0, len = lists.Length(); i < len; ++i) {
|
2012-04-17 02:32:12 +04:00
|
|
|
const nsFrameList& list =
|
|
|
|
lists[(aDirection == eFromStart) ? i : len - i - 1].mList;
|
|
|
|
for (nsIFrame *kid = (aDirection == eFromStart) ? list.FirstChild()
|
|
|
|
: list.LastChild();
|
|
|
|
kid;
|
|
|
|
kid = (aDirection == eFromStart) ? kid->GetNextSibling()
|
|
|
|
: kid->GetPrevSibling()) {
|
|
|
|
if (kid->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT) {
|
|
|
|
// Goes in a different set of inflation data.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-04-30 18:30:08 +03:00
|
|
|
if (kid->IsTextFrame()) {
|
2012-04-17 02:32:12 +04:00
|
|
|
nsIContent *content = kid->GetContent();
|
|
|
|
if (content && kid == content->GetPrimaryFrame()) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t len = nsTextFrameUtils::
|
2012-04-17 02:32:12 +04:00
|
|
|
ComputeApproximateLengthWithWhitespaceCompression(
|
2013-02-17 01:51:02 +04:00
|
|
|
content, kid->StyleText());
|
2012-04-17 02:32:12 +04:00
|
|
|
if (len != 0) {
|
|
|
|
return kid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
nsIFrame *kidResult =
|
|
|
|
FindEdgeInflatableFrameIn(kid, aDirection);
|
|
|
|
if (kidResult) {
|
|
|
|
return kidResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2012-04-17 02:32:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsFontInflationData::ScanText()
|
|
|
|
{
|
|
|
|
mTextDirty = false;
|
|
|
|
mTextAmount = 0;
|
|
|
|
ScanTextIn(mBFCFrame);
|
|
|
|
mInflationEnabled = mTextAmount >= mTextThreshold;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint32_t
|
2012-05-05 17:24:45 +04:00
|
|
|
DoCharCountOfLargestOption(nsIFrame *aContainer)
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t result = 0;
|
2015-06-29 23:02:21 +03:00
|
|
|
for (nsIFrame* option : aContainer->PrincipalChildList()) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t optionResult;
|
2015-03-03 14:08:59 +03:00
|
|
|
if (option->GetContent()->IsHTMLElement(nsGkAtoms::optgroup)) {
|
2012-05-05 17:24:45 +04:00
|
|
|
optionResult = DoCharCountOfLargestOption(option);
|
|
|
|
} else {
|
|
|
|
// REVIEW: Check the frame structure for this!
|
|
|
|
optionResult = 0;
|
2015-06-29 23:02:21 +03:00
|
|
|
for (nsIFrame* optionChild : option->PrincipalChildList()) {
|
2017-04-30 18:30:08 +03:00
|
|
|
if (optionChild->IsTextFrame()) {
|
2012-05-05 17:24:45 +04:00
|
|
|
optionResult += nsTextFrameUtils::
|
|
|
|
ComputeApproximateLengthWithWhitespaceCompression(
|
2013-02-17 01:51:02 +04:00
|
|
|
optionChild->GetContent(), optionChild->StyleText());
|
2012-05-05 17:24:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (optionResult > result) {
|
|
|
|
result = optionResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint32_t
|
2012-05-05 17:24:45 +04:00
|
|
|
CharCountOfLargestOption(nsIFrame *aListControlFrame)
|
|
|
|
{
|
|
|
|
return DoCharCountOfLargestOption(
|
|
|
|
static_cast<nsListControlFrame*>(aListControlFrame)->GetOptionsContainer());
|
|
|
|
}
|
|
|
|
|
2012-04-17 02:32:12 +04:00
|
|
|
void
|
|
|
|
nsFontInflationData::ScanTextIn(nsIFrame *aFrame)
|
|
|
|
{
|
|
|
|
// NOTE: This function has a similar structure to FindEdgeInflatableFrameIn!
|
|
|
|
|
|
|
|
// FIXME: Should probably only scan the text that's actually going to
|
|
|
|
// be inflated!
|
|
|
|
|
|
|
|
nsIFrame::ChildListIterator lists(aFrame);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator kids(lists.CurrentList());
|
|
|
|
for (; !kids.AtEnd(); kids.Next()) {
|
|
|
|
nsIFrame *kid = kids.get();
|
|
|
|
if (kid->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT) {
|
|
|
|
// Goes in a different set of inflation data.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-05-01 20:32:52 +03:00
|
|
|
LayoutFrameType fType = kid->Type();
|
|
|
|
if (fType == LayoutFrameType::Text) {
|
2012-04-17 02:32:12 +04:00
|
|
|
nsIContent *content = kid->GetContent();
|
|
|
|
if (content && kid == content->GetPrimaryFrame()) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t len = nsTextFrameUtils::
|
2012-04-17 02:32:12 +04:00
|
|
|
ComputeApproximateLengthWithWhitespaceCompression(
|
2013-02-17 01:51:02 +04:00
|
|
|
content, kid->StyleText());
|
2012-04-17 02:32:12 +04:00
|
|
|
if (len != 0) {
|
2013-02-17 01:51:02 +04:00
|
|
|
nscoord fontSize = kid->StyleFont()->mFont.size;
|
2012-04-17 02:32:12 +04:00
|
|
|
if (fontSize > 0) {
|
|
|
|
mTextAmount += fontSize * len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-05-01 20:32:52 +03:00
|
|
|
} else if (fType == LayoutFrameType::TextInput) {
|
2012-05-05 17:24:45 +04:00
|
|
|
// We don't want changes to the amount of text in a text input
|
|
|
|
// to change what we count towards inflation.
|
2013-02-17 01:51:02 +04:00
|
|
|
nscoord fontSize = kid->StyleFont()->mFont.size;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t charCount = static_cast<nsTextControlFrame*>(kid)->GetCols();
|
2012-05-05 17:24:45 +04:00
|
|
|
mTextAmount += charCount * fontSize;
|
2017-05-01 20:32:52 +03:00
|
|
|
} else if (fType == LayoutFrameType::ComboboxControl) {
|
2012-05-05 17:24:45 +04:00
|
|
|
// See textInputFrame above (with s/amount of text/selected option/).
|
|
|
|
// Don't just recurse down to the list control inside, since we
|
|
|
|
// need to exclude the display frame.
|
2013-02-17 01:51:02 +04:00
|
|
|
nscoord fontSize = kid->StyleFont()->mFont.size;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t charCount = CharCountOfLargestOption(
|
2012-05-05 17:24:45 +04:00
|
|
|
static_cast<nsComboboxControlFrame*>(kid)->GetDropDown());
|
|
|
|
mTextAmount += charCount * fontSize;
|
2017-05-01 20:32:52 +03:00
|
|
|
} else if (fType == LayoutFrameType::ListControl) {
|
2012-05-05 17:24:45 +04:00
|
|
|
// See textInputFrame above (with s/amount of text/selected option/).
|
2013-02-17 01:51:02 +04:00
|
|
|
nscoord fontSize = kid->StyleFont()->mFont.size;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t charCount = CharCountOfLargestOption(kid);
|
2012-05-05 17:24:45 +04:00
|
|
|
mTextAmount += charCount * fontSize;
|
2012-04-17 02:32:12 +04:00
|
|
|
} else {
|
|
|
|
// recursive step
|
|
|
|
ScanTextIn(kid);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mTextAmount >= mTextThreshold) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|