mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Implement Media Queries, part 4: infrastructure for dynamic change handling at the pres context level. (Bug 156716) r+sr=bzbarsky
This commit is contained in:
parent
8cd01e114a
commit
2e85f85f78
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
@ -728,6 +729,7 @@ nsPresContext::PreferenceChanged(const char* aPrefName)
|
||||
nscoord height = NSToCoordRound(oldHeightDevPixels*AppUnitsPerDevPixel());
|
||||
vm->SetWindowDimensions(width, height);
|
||||
|
||||
MediaFeatureValuesChanged(PR_TRUE);
|
||||
RebuildAllStyleData(NS_STYLE_HINT_REFLOW);
|
||||
}
|
||||
return;
|
||||
@ -1163,6 +1165,7 @@ nsPresContext::SetFullZoom(float aZoom)
|
||||
mFullZoom = aZoom;
|
||||
GetViewManager()->SetWindowDimensions(NSToCoordRound(oldWidthDevPixels * AppUnitsPerDevPixel()),
|
||||
NSToCoordRound(oldHeightDevPixels * AppUnitsPerDevPixel()));
|
||||
MediaFeatureValuesChanged(PR_TRUE);
|
||||
RebuildAllStyleData(NS_STYLE_HINT_REFLOW);
|
||||
|
||||
mSupressResizeReflow = PR_FALSE;
|
||||
@ -1445,6 +1448,39 @@ nsPresContext::PostRebuildAllStyleDataEvent()
|
||||
mShell->FrameConstructor()->PostRebuildAllStyleDataEvent();
|
||||
}
|
||||
|
||||
void
|
||||
nsPresContext::MediaFeatureValuesChanged(PRBool aCallerWillRebuildStyleData)
|
||||
{
|
||||
mPendingMediaFeatureValuesChanged = PR_FALSE;
|
||||
if (mShell->StyleSet()->MediumFeaturesChanged(this) &&
|
||||
!aCallerWillRebuildStyleData) {
|
||||
RebuildAllStyleData(nsChangeHint(0));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsPresContext::PostMediaFeatureValuesChangedEvent()
|
||||
{
|
||||
if (!mPendingMediaFeatureValuesChanged) {
|
||||
nsCOMPtr<nsIRunnable> ev =
|
||||
new nsRunnableMethod<nsPresContext>(this,
|
||||
&nsPresContext::HandleMediaFeatureValuesChangedEvent);
|
||||
if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) {
|
||||
mPendingMediaFeatureValuesChanged = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsPresContext::HandleMediaFeatureValuesChangedEvent()
|
||||
{
|
||||
// Null-check mShell in case the shell has been destroyed (and the
|
||||
// event is the only thing holding the pres context alive).
|
||||
if (mPendingMediaFeatureValuesChanged && mShell) {
|
||||
MediaFeatureValuesChanged(PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsPresContext::SetPaginatedScrolling(PRBool aPaginated)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
@ -209,6 +210,14 @@ public:
|
||||
void RebuildAllStyleData(nsChangeHint aExtraHint);
|
||||
void PostRebuildAllStyleDataEvent();
|
||||
|
||||
void MediaFeatureValuesChanged(PRBool aCallerWillRebuildStyleData);
|
||||
void PostMediaFeatureValuesChangedEvent();
|
||||
NS_HIDDEN_(void) HandleMediaFeatureValuesChangedEvent();
|
||||
void FlushPendingMediaFeatureValuesChanged() {
|
||||
if (mPendingMediaFeatureValuesChanged)
|
||||
MediaFeatureValuesChanged(PR_FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Access compatibility mode for this context. This is the same as
|
||||
* our document's compatibility mode.
|
||||
@ -421,7 +430,10 @@ public:
|
||||
* Set the currently visible area. The units for r are standard
|
||||
* nscoord units (as scaled by the device context).
|
||||
*/
|
||||
void SetVisibleArea(const nsRect& r) { mVisibleArea = r; }
|
||||
void SetVisibleArea(const nsRect& r) {
|
||||
mVisibleArea = r;
|
||||
PostMediaFeatureValuesChangedEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this presentation context is a paginated
|
||||
@ -889,6 +901,7 @@ protected:
|
||||
unsigned mPrefScrollbarSide : 2;
|
||||
unsigned mPendingSysColorChanged : 1;
|
||||
unsigned mPendingThemeChanged : 1;
|
||||
unsigned mPendingMediaFeatureValuesChanged : 1;
|
||||
unsigned mPrefChangePendingNeedsReflow : 1;
|
||||
unsigned mRenderedPositionVaryingContent : 1;
|
||||
|
||||
|
@ -4555,6 +4555,8 @@ PresShell::DoFlushPendingNotifications(mozFlushType aType,
|
||||
// Process pending restyles, since any flush of the presshell wants
|
||||
// up-to-date style data.
|
||||
if (!mIsDestroying) {
|
||||
mPresContext->FlushPendingMediaFeatureValuesChanged();
|
||||
|
||||
mFrameConstructor->ProcessPendingRestyles();
|
||||
}
|
||||
|
||||
|
@ -224,6 +224,15 @@ GetGrid(nsPresContext* aPresContext, nsCSSValue& aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adding new media features requires (1) adding the new feature to this
|
||||
* array, with appropriate entries (and potentially any new code needed
|
||||
* to support new types in these entries and (2) ensuring that either
|
||||
* nsPresContext::MediaFeatureValuesChanged or
|
||||
* nsPresContext::PostMediaFeatureValuesChangedEvent is called when the
|
||||
* value that would be returned by the entry's mGetter changes.
|
||||
*/
|
||||
|
||||
/* static */ const nsMediaFeature
|
||||
nsMediaFeatures::features[] = {
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user