2012-04-16 22:32:12 +00:00
|
|
|
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
2012-05-21 11:12:37 +00: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-16 22:32:12 +00:00
|
|
|
|
|
|
|
/* Per-block-formatting-context manager of font size inflation for pan and zoom UI. */
|
|
|
|
|
|
|
|
#include "nsFontInflationData.h"
|
|
|
|
#include "FramePropertyTable.h"
|
2012-05-05 13:24:45 +00:00
|
|
|
#include "nsTextControlFrame.h"
|
|
|
|
#include "nsListControlFrame.h"
|
|
|
|
#include "nsComboboxControlFrame.h"
|
2012-04-16 22:32:12 +00:00
|
|
|
#include "nsHTMLReflowState.h"
|
|
|
|
#include "nsTextFrameUtils.h"
|
2012-04-16 22:32:12 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2012-04-16 22:32:12 +00:00
|
|
|
using namespace mozilla::layout;
|
2012-04-16 22:32:12 +00:00
|
|
|
|
2015-02-04 23:22:27 +00:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(FontInflationDataProperty,
|
|
|
|
DeleteValue<nsFontInflationData>)
|
2012-04-16 22:32:12 +00: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-16 22:32:12 +00:00
|
|
|
NS_ASSERTION(bfc->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT,
|
|
|
|
"should have found a flow root");
|
2012-04-16 22:32:12 +00:00
|
|
|
|
|
|
|
return static_cast<nsFontInflationData*>(
|
|
|
|
bfc->Properties().Get(FontInflationDataProperty()));
|
|
|
|
}
|
2012-04-16 22:32:12 +00:00
|
|
|
|
2012-06-11 20:57:35 +00:00
|
|
|
/* static */ bool
|
2015-03-10 14:28:23 +00:00
|
|
|
nsFontInflationData::UpdateFontInflationDataISizeFor(const nsHTMLReflowState& aReflowState)
|
2012-04-16 22:32:12 +00:00
|
|
|
{
|
|
|
|
nsIFrame *bfc = aReflowState.frame;
|
|
|
|
NS_ASSERTION(bfc->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT,
|
|
|
|
"should have been given a flow root");
|
|
|
|
FrameProperties bfcProps(bfc->Properties());
|
|
|
|
nsFontInflationData *data = static_cast<nsFontInflationData*>(
|
|
|
|
bfcProps.Get(FontInflationDataProperty()));
|
2012-06-11 20:57:35 +00:00
|
|
|
bool oldInflationEnabled;
|
2015-03-10 14:28:23 +00:00
|
|
|
nscoord oldNCAISize;
|
2012-06-11 20:57:35 +00:00
|
|
|
if (data) {
|
2015-03-10 14:28:23 +00:00
|
|
|
oldNCAISize = data->mNCAISize;
|
2012-06-11 20:57:35 +00:00
|
|
|
oldInflationEnabled = data->mInflationEnabled;
|
|
|
|
} else {
|
2012-04-16 22:32:12 +00:00
|
|
|
data = new nsFontInflationData(bfc);
|
|
|
|
bfcProps.Set(FontInflationDataProperty(), data);
|
2015-03-10 14:28:23 +00:00
|
|
|
oldNCAISize = -1;
|
2012-06-11 20:57:35 +00:00
|
|
|
oldInflationEnabled = true; /* not relevant */
|
2012-04-16 22:32:12 +00:00
|
|
|
}
|
|
|
|
|
2015-03-10 14:28:23 +00:00
|
|
|
data->UpdateISize(aReflowState);
|
2012-06-11 20:57:35 +00:00
|
|
|
|
2012-09-28 19:38:33 +00:00
|
|
|
if (oldInflationEnabled != data->mInflationEnabled)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return oldInflationEnabled &&
|
2015-03-10 14:28:23 +00:00
|
|
|
oldNCAISize != data->mNCAISize;
|
2012-04-16 22:32:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
nsFontInflationData::MarkFontInflationDataTextDirty(nsIFrame *aBFCFrame)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aBFCFrame->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT,
|
|
|
|
"should have been given a flow root");
|
|
|
|
|
|
|
|
FrameProperties bfcProps(aBFCFrame->Properties());
|
|
|
|
nsFontInflationData *data = static_cast<nsFontInflationData*>(
|
|
|
|
bfcProps.Get(FontInflationDataProperty()));
|
|
|
|
if (data) {
|
|
|
|
data->MarkTextDirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsFontInflationData::nsFontInflationData(nsIFrame *aBFCFrame)
|
|
|
|
: mBFCFrame(aBFCFrame)
|
2015-03-10 14:28:23 +00:00
|
|
|
, mNCAISize(0)
|
2012-04-16 22:32:12 +00: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 11:42:34 +00:00
|
|
|
aFrame1 = aFrame1->FirstInFlow();
|
|
|
|
aFrame2 = aFrame2->FirstInFlow();
|
|
|
|
aKnownCommonAncestor = aKnownCommonAncestor->FirstInFlow();
|
2012-04-16 22:32:12 +00:00
|
|
|
|
|
|
|
nsAutoTArray<nsIFrame*, 32> ancestors1, ancestors2;
|
|
|
|
for (nsIFrame *f = aFrame1; f != aKnownCommonAncestor;
|
2013-09-25 11:42:34 +00:00
|
|
|
(f = f->GetParent()) && (f = f->FirstInFlow())) {
|
2012-04-16 22:32:12 +00:00
|
|
|
ancestors1.AppendElement(f);
|
|
|
|
}
|
|
|
|
for (nsIFrame *f = aFrame2; f != aKnownCommonAncestor;
|
2013-09-25 11:42:34 +00:00
|
|
|
(f = f->GetParent()) && (f = f->FirstInFlow())) {
|
2012-04-16 22:32:12 +00:00
|
|
|
ancestors2.AppendElement(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame *result = aKnownCommonAncestor;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t i1 = ancestors1.Length(),
|
2012-04-16 22:32:12 +00:00
|
|
|
i2 = ancestors2.Length();
|
|
|
|
while (i1-- != 0 && i2-- != 0) {
|
|
|
|
if (ancestors1[i1] != ancestors2[i2]) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
result = ancestors1[i1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nscoord
|
2015-03-10 14:28:23 +00:00
|
|
|
ComputeDescendantISize(const nsHTMLReflowState& aAncestorReflowState,
|
2012-04-16 22:32:12 +00:00
|
|
|
nsIFrame *aDescendantFrame)
|
|
|
|
{
|
2013-09-25 11:42:34 +00:00
|
|
|
nsIFrame *ancestorFrame = aAncestorReflowState.frame->FirstInFlow();
|
2012-04-16 22:32:12 +00:00
|
|
|
if (aDescendantFrame == ancestorFrame) {
|
2015-03-10 14:28:23 +00:00
|
|
|
return aAncestorReflowState.ComputedISize();
|
2012-04-16 22:32:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AutoInfallibleTArray<nsIFrame*, 16> frames;
|
|
|
|
for (nsIFrame *f = aDescendantFrame; f != ancestorFrame;
|
2013-09-25 11:42:34 +00:00
|
|
|
f = f->GetParent()->FirstInFlow()) {
|
2012-04-16 22:32:12 +00:00
|
|
|
frames.AppendElement(f);
|
|
|
|
}
|
|
|
|
|
2015-03-10 14:28:23 +00:00
|
|
|
// This ignores the inline-size contributions made by scrollbars, though in
|
2012-06-06 02:13:41 +00: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 15:56:38 +00:00
|
|
|
uint32_t len = frames.Length();
|
2012-04-16 22:32:12 +00:00
|
|
|
nsHTMLReflowState *reflowStates = static_cast<nsHTMLReflowState*>
|
|
|
|
(moz_xmalloc(sizeof(nsHTMLReflowState) * len));
|
|
|
|
nsPresContext *presContext = aDescendantFrame->PresContext();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < len; ++i) {
|
2012-04-16 22:32:12 +00:00
|
|
|
const nsHTMLReflowState &parentReflowState =
|
|
|
|
(i == 0) ? aAncestorReflowState : reflowStates[i - 1];
|
|
|
|
nsIFrame *frame = frames[len - i - 1];
|
2014-07-24 08:28:46 +00:00
|
|
|
WritingMode wm = frame->GetWritingMode();
|
|
|
|
LogicalSize availSize = parentReflowState.ComputedSize(wm);
|
|
|
|
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(frame->GetParent()->FirstInFlow() ==
|
|
|
|
parentReflowState.frame->FirstInFlow(),
|
|
|
|
"bad logic in this function");
|
2012-04-16 22:32:12 +00:00
|
|
|
new (reflowStates + i) nsHTMLReflowState(presContext, parentReflowState,
|
|
|
|
frame, availSize);
|
|
|
|
}
|
|
|
|
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(reflowStates[len - 1].frame == aDescendantFrame,
|
|
|
|
"bad logic in this function");
|
2015-03-10 14:28:23 +00:00
|
|
|
nscoord result = reflowStates[len - 1].ComputedISize();
|
2012-04-16 22:32:12 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = len; i-- != 0; ) {
|
2012-04-16 22:32:12 +00:00
|
|
|
reflowStates[i].~nsHTMLReflowState();
|
|
|
|
}
|
2015-02-19 04:51:06 +00:00
|
|
|
free(reflowStates);
|
2012-04-16 22:32:12 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-03-10 14:28:23 +00:00
|
|
|
nsFontInflationData::UpdateISize(const nsHTMLReflowState &aReflowState)
|
2012-04-16 22:32:12 +00:00
|
|
|
{
|
|
|
|
nsIFrame *bfc = aReflowState.frame;
|
|
|
|
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-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(!firstInflatableDescendant == !lastInflatableDescendant,
|
|
|
|
"null-ness should match; NearestCommonAncestorFirstInFlow"
|
|
|
|
" will crash when passed null");
|
2012-04-16 22:32:12 +00:00
|
|
|
|
2015-03-10 14:28:23 +00: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-16 22:32:12 +00:00
|
|
|
nsIFrame *nca = NearestCommonAncestorFirstInFlow(firstInflatableDescendant,
|
|
|
|
lastInflatableDescendant,
|
|
|
|
bfc);
|
2013-09-30 21:26:04 +00:00
|
|
|
while (!nca->IsContainerForFontSizeInflation()) {
|
2013-09-25 11:42:34 +00:00
|
|
|
nca = nca->GetParent()->FirstInFlow();
|
2012-04-16 22:32:12 +00:00
|
|
|
}
|
|
|
|
|
2015-03-10 14:28:23 +00:00
|
|
|
nscoord newNCAISize = ComputeDescendantISize(aReflowState, nca);
|
2012-04-16 22:32:12 +00:00
|
|
|
|
|
|
|
// See comment above "font.size.inflation.lineThreshold" in
|
|
|
|
// modules/libpref/src/init/all.js .
|
2012-06-06 03:47:33 +00:00
|
|
|
nsIPresShell* presShell = bfc->PresContext()->PresShell();
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t lineThreshold = presShell->FontSizeInflationLineThreshold();
|
2015-03-10 14:28:23 +00:00
|
|
|
nscoord newTextThreshold = (newNCAISize * lineThreshold) / 100;
|
2012-04-16 22:32:12 +00: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 14:28:23 +00:00
|
|
|
mNCAISize = newNCAISize;
|
2012-04-16 22:32:12 +00: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!
|
|
|
|
nsAutoTArray<FrameChildList, 4> lists;
|
|
|
|
aFrame->GetChildLists(&lists);
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0, len = lists.Length(); i < len; ++i) {
|
2012-04-16 22:32:12 +00: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (kid->GetType() == nsGkAtoms::textFrame) {
|
|
|
|
nsIContent *content = kid->GetContent();
|
|
|
|
if (content && kid == content->GetPrimaryFrame()) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t len = nsTextFrameUtils::
|
2012-04-16 22:32:12 +00:00
|
|
|
ComputeApproximateLengthWithWhitespaceCompression(
|
2013-02-16 21:51:02 +00:00
|
|
|
content, kid->StyleText());
|
2012-04-16 22:32:12 +00:00
|
|
|
if (len != 0) {
|
|
|
|
return kid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
nsIFrame *kidResult =
|
|
|
|
FindEdgeInflatableFrameIn(kid, aDirection);
|
|
|
|
if (kidResult) {
|
|
|
|
return kidResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2012-04-16 22:32:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsFontInflationData::ScanText()
|
|
|
|
{
|
|
|
|
mTextDirty = false;
|
|
|
|
mTextAmount = 0;
|
|
|
|
ScanTextIn(mBFCFrame);
|
|
|
|
mInflationEnabled = mTextAmount >= mTextThreshold;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static uint32_t
|
2012-05-05 13:24:45 +00:00
|
|
|
DoCharCountOfLargestOption(nsIFrame *aContainer)
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t result = 0;
|
2015-06-29 20:02:21 +00:00
|
|
|
for (nsIFrame* option : aContainer->PrincipalChildList()) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t optionResult;
|
2015-03-03 11:08:59 +00:00
|
|
|
if (option->GetContent()->IsHTMLElement(nsGkAtoms::optgroup)) {
|
2012-05-05 13:24:45 +00:00
|
|
|
optionResult = DoCharCountOfLargestOption(option);
|
|
|
|
} else {
|
|
|
|
// REVIEW: Check the frame structure for this!
|
|
|
|
optionResult = 0;
|
2015-06-29 20:02:21 +00:00
|
|
|
for (nsIFrame* optionChild : option->PrincipalChildList()) {
|
2012-05-05 13:24:45 +00:00
|
|
|
if (optionChild->GetType() == nsGkAtoms::textFrame) {
|
|
|
|
optionResult += nsTextFrameUtils::
|
|
|
|
ComputeApproximateLengthWithWhitespaceCompression(
|
2013-02-16 21:51:02 +00:00
|
|
|
optionChild->GetContent(), optionChild->StyleText());
|
2012-05-05 13:24:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (optionResult > result) {
|
|
|
|
result = optionResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static uint32_t
|
2012-05-05 13:24:45 +00:00
|
|
|
CharCountOfLargestOption(nsIFrame *aListControlFrame)
|
|
|
|
{
|
|
|
|
return DoCharCountOfLargestOption(
|
|
|
|
static_cast<nsListControlFrame*>(aListControlFrame)->GetOptionsContainer());
|
|
|
|
}
|
|
|
|
|
2012-04-16 22:32:12 +00: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;
|
|
|
|
}
|
|
|
|
|
2012-05-05 13:24:45 +00:00
|
|
|
nsIAtom *fType = kid->GetType();
|
|
|
|
if (fType == nsGkAtoms::textFrame) {
|
2012-04-16 22:32:12 +00:00
|
|
|
nsIContent *content = kid->GetContent();
|
|
|
|
if (content && kid == content->GetPrimaryFrame()) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t len = nsTextFrameUtils::
|
2012-04-16 22:32:12 +00:00
|
|
|
ComputeApproximateLengthWithWhitespaceCompression(
|
2013-02-16 21:51:02 +00:00
|
|
|
content, kid->StyleText());
|
2012-04-16 22:32:12 +00:00
|
|
|
if (len != 0) {
|
2013-02-16 21:51:02 +00:00
|
|
|
nscoord fontSize = kid->StyleFont()->mFont.size;
|
2012-04-16 22:32:12 +00:00
|
|
|
if (fontSize > 0) {
|
|
|
|
mTextAmount += fontSize * len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-05-05 13:24:45 +00:00
|
|
|
} else if (fType == nsGkAtoms::textInputFrame) {
|
|
|
|
// We don't want changes to the amount of text in a text input
|
|
|
|
// to change what we count towards inflation.
|
2013-02-16 21:51:02 +00:00
|
|
|
nscoord fontSize = kid->StyleFont()->mFont.size;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t charCount = static_cast<nsTextControlFrame*>(kid)->GetCols();
|
2012-05-05 13:24:45 +00:00
|
|
|
mTextAmount += charCount * fontSize;
|
|
|
|
} else if (fType == nsGkAtoms::comboboxControlFrame) {
|
|
|
|
// 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-16 21:51:02 +00:00
|
|
|
nscoord fontSize = kid->StyleFont()->mFont.size;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t charCount = CharCountOfLargestOption(
|
2012-05-05 13:24:45 +00:00
|
|
|
static_cast<nsComboboxControlFrame*>(kid)->GetDropDown());
|
|
|
|
mTextAmount += charCount * fontSize;
|
|
|
|
} else if (fType == nsGkAtoms::listControlFrame) {
|
|
|
|
// See textInputFrame above (with s/amount of text/selected option/).
|
2013-02-16 21:51:02 +00:00
|
|
|
nscoord fontSize = kid->StyleFont()->mFont.size;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t charCount = CharCountOfLargestOption(kid);
|
2012-05-05 13:24:45 +00:00
|
|
|
mTextAmount += charCount * fontSize;
|
2012-04-16 22:32:12 +00:00
|
|
|
} else {
|
|
|
|
// recursive step
|
|
|
|
ScanTextIn(kid);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mTextAmount >= mTextThreshold) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|