зеркало из https://github.com/mozilla/pjs.git
Reflow for screen size change when font.size.inflation.minTwips is set. (Bug 747231, patch 4) r=roc
--HG-- extra : transplant_source : %B2c%F2%B9%E0%1DL%DD%AF%A2%842R%F3%BB%60R%1B%9EI
This commit is contained in:
Родитель
f266722bf9
Коммит
9d531f6dc9
|
@ -78,6 +78,9 @@
|
|||
#include "nsDOMFile.h"
|
||||
#include "BasicLayers.h"
|
||||
#include "nsTArrayHelpers.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
|
||||
#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK2)
|
||||
#include <gdk/gdk.h>
|
||||
|
@ -283,6 +286,40 @@ static void DestroyNsRect(void* aObject, nsIAtom* aPropertyName,
|
|||
delete rect;
|
||||
}
|
||||
|
||||
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));
|
||||
nsIFrame *rootFrame = shell->GetRootFrame();
|
||||
if (rootFrame) {
|
||||
shell->FrameNeedsReflow(rootFrame, nsIPresShell::eResize,
|
||||
NS_FRAME_IS_DIRTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::SetDisplayPortForElement(float aXPx, float aYPx,
|
||||
float aWidthPx, float aHeightPx,
|
||||
|
@ -331,6 +368,14 @@ nsDOMWindowUtils::SetDisplayPortForElement(float aXPx, float aYPx,
|
|||
// We are setting a root displayport for a document.
|
||||
// The pres shell needs a special flag set.
|
||||
presShell->SetIgnoreViewportScrolling(true);
|
||||
|
||||
// When the "font.size.inflation.minTwips" preference is set, the
|
||||
// layout depends on the size of the screen. Since when the size
|
||||
// of the screen changes, the root displayport also changes, we
|
||||
// hook in the needed updates here rather than adding a
|
||||
// separate notification just for this change.
|
||||
nsPresContext* presContext = GetPresContext();
|
||||
MaybeReflowForInflationScreenWidthChange(presContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -132,8 +132,8 @@ bool nsLayoutUtils::gPreventAssertInCompareTreePosition = false;
|
|||
typedef gfxPattern::GraphicsFilter GraphicsFilter;
|
||||
typedef FrameMetrics::ViewID ViewID;
|
||||
|
||||
static PRUint32 sFontSizeInflationEmPerLine;
|
||||
static PRUint32 sFontSizeInflationMinTwips;
|
||||
/* static */ PRUint32 nsLayoutUtils::sFontSizeInflationEmPerLine;
|
||||
/* static */ PRUint32 nsLayoutUtils::sFontSizeInflationMinTwips;
|
||||
/* static */ PRUint32 nsLayoutUtils::sFontSizeInflationLineThreshold;
|
||||
|
||||
static ViewID sScrollIdCounter = FrameMetrics::START_SCROLL_ID;
|
||||
|
@ -4671,7 +4671,9 @@ nsReflowFrameRunnable::Run()
|
|||
static nscoord
|
||||
MinimumFontSizeFor(nsPresContext* aPresContext, nscoord aContainerWidth)
|
||||
{
|
||||
if (sFontSizeInflationEmPerLine == 0 && sFontSizeInflationMinTwips == 0) {
|
||||
PRUint32 emPerLine = nsLayoutUtils::FontSizeInflationEmPerLine();
|
||||
PRUint32 minTwips = nsLayoutUtils::FontSizeInflationMinTwips();
|
||||
if (emPerLine == 0 && minTwips == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -4680,17 +4682,17 @@ MinimumFontSizeFor(nsPresContext* aPresContext, nscoord aContainerWidth)
|
|||
nscoord effectiveContainerWidth = NS_MIN(iFrameWidth, aContainerWidth);
|
||||
|
||||
nscoord byLine = 0, byInch = 0;
|
||||
if (sFontSizeInflationEmPerLine != 0) {
|
||||
byLine = effectiveContainerWidth / sFontSizeInflationEmPerLine;
|
||||
if (emPerLine != 0) {
|
||||
byLine = effectiveContainerWidth / emPerLine;
|
||||
}
|
||||
if (sFontSizeInflationMinTwips != 0) {
|
||||
if (minTwips != 0) {
|
||||
// REVIEW: Is this giving us app units and sizes *not* counting
|
||||
// viewport scaling?
|
||||
float deviceWidthInches =
|
||||
aPresContext->ScreenWidthInchesForFontInflation();
|
||||
byInch = NSToCoordRound(effectiveContainerWidth /
|
||||
(deviceWidthInches * 1440 /
|
||||
sFontSizeInflationMinTwips ));
|
||||
minTwips ));
|
||||
}
|
||||
return NS_MAX(byLine, byInch);
|
||||
}
|
||||
|
|
|
@ -1567,6 +1567,22 @@ public:
|
|||
|
||||
static bool FontSizeInflationEnabled(nsPresContext *aPresContext);
|
||||
|
||||
/**
|
||||
* See comment above "font.size.inflation.emPerLine" in
|
||||
* modules/libpref/src/init/all.js .
|
||||
*/
|
||||
static PRUint32 FontSizeInflationEmPerLine() {
|
||||
return sFontSizeInflationEmPerLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* See comment above "font.size.inflation.minTwips" in
|
||||
* modules/libpref/src/init/all.js .
|
||||
*/
|
||||
static PRUint32 FontSizeInflationMinTwips() {
|
||||
return sFontSizeInflationMinTwips;
|
||||
}
|
||||
|
||||
/**
|
||||
* See comment above "font.size.inflation.lineThreshold" in
|
||||
* modules/libpref/src/init/all.js .
|
||||
|
@ -1655,6 +1671,8 @@ public:
|
|||
#endif
|
||||
|
||||
private:
|
||||
static PRUint32 sFontSizeInflationEmPerLine;
|
||||
static PRUint32 sFontSizeInflationMinTwips;
|
||||
static PRUint32 sFontSizeInflationLineThreshold;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче