mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 749186, Followup Patch 1: Cache font inflation settings in pres shell to prevent crash. [r=dbaron]
--HG-- extra : rebase_source : dc8b8f66bcd49c54ecefdf94793100b7901e6f3b
This commit is contained in:
parent
0f831b2029
commit
98bb59b964
@ -260,30 +260,32 @@ static void DestroyNsRect(void* aObject, nsIAtom* aPropertyName,
|
||||
static void
|
||||
MaybeReflowForInflationScreenWidthChange(nsPresContext *aPresContext)
|
||||
{
|
||||
if (aPresContext &&
|
||||
nsLayoutUtils::FontSizeInflationEnabled(aPresContext) &&
|
||||
nsLayoutUtils::FontSizeInflationMinTwips() != 0) {
|
||||
bool changed;
|
||||
aPresContext->ScreenWidthInchesForFontInflation(&changed);
|
||||
if (changed) {
|
||||
nsCOMPtr<nsISupports> container = aPresContext->GetContainer();
|
||||
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
|
||||
if (docShell) {
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
docShell->GetContentViewer(getter_AddRefs(cv));
|
||||
nsCOMPtr<nsIMarkupDocumentViewer> mudv = do_QueryInterface(cv);
|
||||
if (mudv) {
|
||||
nsTArray<nsCOMPtr<nsIMarkupDocumentViewer> > array;
|
||||
mudv->AppendSubtree(array);
|
||||
for (PRUint32 i = 0, iEnd = array.Length(); i < iEnd; ++i) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsCOMPtr<nsIContentViewer> cv = do_QueryInterface(array[i]);
|
||||
cv->GetPresShell(getter_AddRefs(shell));
|
||||
if (shell) {
|
||||
nsIFrame *rootFrame = shell->GetRootFrame();
|
||||
if (rootFrame) {
|
||||
shell->FrameNeedsReflow(rootFrame, nsIPresShell::eResize,
|
||||
NS_FRAME_IS_DIRTY);
|
||||
if (aPresContext) {
|
||||
nsIPresShell* presShell = aPresContext->GetPresShell();
|
||||
if (presShell && nsLayoutUtils::FontSizeInflationEnabled(aPresContext) &&
|
||||
presShell->FontSizeInflationMinTwips() != 0) {
|
||||
bool changed;
|
||||
aPresContext->ScreenWidthInchesForFontInflation(&changed);
|
||||
if (changed) {
|
||||
nsCOMPtr<nsISupports> container = aPresContext->GetContainer();
|
||||
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
|
||||
if (docShell) {
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
docShell->GetContentViewer(getter_AddRefs(cv));
|
||||
nsCOMPtr<nsIMarkupDocumentViewer> mudv = do_QueryInterface(cv);
|
||||
if (mudv) {
|
||||
nsTArray<nsCOMPtr<nsIMarkupDocumentViewer> > array;
|
||||
mudv->AppendSubtree(array);
|
||||
for (PRUint32 i = 0, iEnd = array.Length(); i < iEnd; ++i) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsCOMPtr<nsIContentViewer> cv = do_QueryInterface(array[i]);
|
||||
cv->GetPresShell(getter_AddRefs(shell));
|
||||
if (shell) {
|
||||
nsIFrame *rootFrame = shell->GetRootFrame();
|
||||
if (rootFrame) {
|
||||
shell->FrameNeedsReflow(rootFrame, nsIPresShell::eResize,
|
||||
NS_FRAME_IS_DIRTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1236,6 +1236,21 @@ public:
|
||||
size_t *aTextRunsSize,
|
||||
size_t *aPresContextSize) const = 0;
|
||||
|
||||
/**
|
||||
* Methods that retrieve the cached font inflation preferences.
|
||||
*/
|
||||
PRUint32 FontSizeInflationEmPerLine() const {
|
||||
return mFontSizeInflationEmPerLine;
|
||||
}
|
||||
|
||||
PRUint32 FontSizeInflationMinTwips() const {
|
||||
return mFontSizeInflationMinTwips;
|
||||
}
|
||||
|
||||
PRUint32 FontSizeInflationLineThreshold() const {
|
||||
return mFontSizeInflationLineThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh observer management.
|
||||
*/
|
||||
@ -1362,6 +1377,12 @@ protected:
|
||||
bool mScrollPositionClampingScrollPortSizeSet : 1;
|
||||
|
||||
static nsIContent* gKeyDownTarget;
|
||||
|
||||
// Cached font inflation values. This is done to prevent changing of font
|
||||
// inflation until a page is reloaded.
|
||||
PRUint32 mFontSizeInflationEmPerLine;
|
||||
PRUint32 mFontSizeInflationMinTwips;
|
||||
PRUint32 mFontSizeInflationLineThreshold;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -4707,8 +4707,10 @@ nsReflowFrameRunnable::Run()
|
||||
static nscoord
|
||||
MinimumFontSizeFor(nsPresContext* aPresContext, nscoord aContainerWidth)
|
||||
{
|
||||
PRUint32 emPerLine = nsLayoutUtils::FontSizeInflationEmPerLine();
|
||||
PRUint32 minTwips = nsLayoutUtils::FontSizeInflationMinTwips();
|
||||
nsIPresShell* presShell = aPresContext->PresShell();
|
||||
|
||||
PRUint32 emPerLine = presShell->FontSizeInflationEmPerLine();
|
||||
PRUint32 minTwips = presShell->FontSizeInflationMinTwips();
|
||||
if (emPerLine == 0 && minTwips == 0) {
|
||||
return 0;
|
||||
}
|
||||
@ -4859,8 +4861,11 @@ nsLayoutUtils::FontSizeInflationFor(const nsIFrame *aFrame)
|
||||
/* static */ bool
|
||||
nsLayoutUtils::FontSizeInflationEnabled(nsPresContext *aPresContext)
|
||||
{
|
||||
if ((sFontSizeInflationEmPerLine == 0 &&
|
||||
sFontSizeInflationMinTwips == 0) ||
|
||||
nsIPresShell* presShell = aPresContext->GetPresShell();
|
||||
|
||||
if (!presShell ||
|
||||
(presShell->FontSizeInflationEmPerLine() == 0 &&
|
||||
presShell->FontSizeInflationMinTwips() == 0) ||
|
||||
aPresContext->IsChrome()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -872,6 +872,9 @@ PresShell::Init(nsIDocument* aDocument,
|
||||
// Get our activeness from the docShell.
|
||||
QueryIsActive();
|
||||
|
||||
// Setup our font inflation preferences.
|
||||
SetupFontInflation();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -8957,3 +8960,11 @@ nsIPresShell::SetScrollPositionClampingScrollPortSize(nscoord aWidth, nscoord aH
|
||||
mScrollPositionClampingScrollPortSize.width = aWidth;
|
||||
mScrollPositionClampingScrollPortSize.height = aHeight;
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::SetupFontInflation()
|
||||
{
|
||||
mFontSizeInflationEmPerLine = nsLayoutUtils::FontSizeInflationEmPerLine();
|
||||
mFontSizeInflationMinTwips = nsLayoutUtils::FontSizeInflationMinTwips();
|
||||
mFontSizeInflationLineThreshold = nsLayoutUtils::FontSizeInflationLineThreshold();
|
||||
}
|
||||
|
@ -378,6 +378,15 @@ protected:
|
||||
// Helper for ScrollContentIntoView
|
||||
void DoScrollContentIntoView();
|
||||
|
||||
/**
|
||||
* Initialize cached font inflation preference values.
|
||||
*
|
||||
* @see nsLayoutUtils::sFontSizeInflationEmPerLine
|
||||
* @see nsLayoutUtils::sFontSizeInflationMinTwips
|
||||
* @see nsLayoutUtils::sFontSizeInflationLineThreshold
|
||||
*/
|
||||
void SetupFontInflation();
|
||||
|
||||
friend struct AutoRenderingStateSaveRestore;
|
||||
friend struct RenderingState;
|
||||
|
||||
|
@ -194,7 +194,8 @@ nsFontInflationData::UpdateWidth(const nsHTMLReflowState &aReflowState)
|
||||
|
||||
// See comment above "font.size.inflation.lineThreshold" in
|
||||
// modules/libpref/src/init/all.js .
|
||||
PRUint32 lineThreshold = nsLayoutUtils::FontSizeInflationLineThreshold();
|
||||
nsIPresShell* presShell = bfc->PresContext()->PresShell();
|
||||
PRUint32 lineThreshold = presShell->FontSizeInflationLineThreshold();
|
||||
nscoord newTextThreshold = (newNCAWidth * lineThreshold) / 100;
|
||||
|
||||
if (mTextThreshold <= mTextAmount && mTextAmount < newTextThreshold) {
|
||||
|
Loading…
Reference in New Issue
Block a user