Bug 847890 - paint flashing for content only. r=roc

This commit is contained in:
Paul Rouget 2013-03-12 11:01:00 -07:00
Родитель 2da2846e19
Коммит 3262a13c83
7 изменённых файлов: 89 добавлений и 17 удалений

Просмотреть файл

@ -3210,6 +3210,35 @@ nsDOMWindowUtils::IsNodeDisabledForEvents(nsIDOMNode* aNode, bool* aRetVal)
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::SetPaintFlashing(bool aPaintFlashing)
{
nsPresContext* presContext = GetPresContext();
if (presContext) {
presContext->RefreshDriver()->SetPaintFlashing(aPaintFlashing);
// Clear paint flashing colors
nsIPresShell* presShell = GetPresShell();
if (!aPaintFlashing && presShell) {
nsIFrame* rootFrame = presShell->GetRootFrame();
if (rootFrame) {
rootFrame->InvalidateFrameSubtree();
}
}
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetPaintFlashing(bool* aRetVal)
{
*aRetVal = false;
nsPresContext* presContext = GetPresContext();
if (presContext) {
*aRetVal = presContext->RefreshDriver()->GetPaintFlashing();
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::DispatchEventToChromeOnly(nsIDOMEventTarget* aTarget,
nsIDOMEvent* aEvent,

Просмотреть файл

@ -1349,4 +1349,9 @@ interface nsIDOMWindowUtils : nsISupports {
* attribute or -moz-user-input: none/disabled.
*/
boolean isNodeDisabledForEvents(in nsIDOMNode aNode);
/**
* Setting paintFlashing to true will flash newly painted area.
*/
attribute boolean paintFlashing;
};

Просмотреть файл

@ -759,22 +759,11 @@ FrameLayerBuilder::Init(nsDisplayListBuilder* aBuilder, LayerManager* aManager)
void
FrameLayerBuilder::FlashPaint(gfxContext *aContext)
{
static bool sPaintFlashingEnabled;
static bool sPaintFlashingPrefCached = false;
if (!sPaintFlashingPrefCached) {
sPaintFlashingPrefCached = true;
mozilla::Preferences::AddBoolVarCache(&sPaintFlashingEnabled,
"nglayout.debug.paint_flashing");
}
if (sPaintFlashingEnabled) {
float r = float(rand()) / RAND_MAX;
float g = float(rand()) / RAND_MAX;
float b = float(rand()) / RAND_MAX;
aContext->SetColor(gfxRGBA(r, g, b, 0.2));
aContext->Paint();
}
float r = float(rand()) / RAND_MAX;
float g = float(rand()) / RAND_MAX;
float b = float(rand()) / RAND_MAX;
aContext->SetColor(gfxRGBA(r, g, b, 0.4));
aContext->Paint();
}
FrameLayerBuilder::DisplayItemData*
@ -3361,7 +3350,10 @@ FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer,
aContext->Restore();
}
FlashPaint(aContext);
if (presContext->RefreshDriver()->GetPaintFlashing()) {
FlashPaint(aContext);
}
if (!aRegionToInvalidate.IsEmpty()) {
aLayer->AddInvalidRect(aRegionToInvalidate.GetBounds());
}

Просмотреть файл

@ -528,6 +528,8 @@ nsRefreshDriver::nsRefreshDriver(nsPresContext* aPresContext)
mMostRecentRefreshEpochTime = JS_Now();
mMostRecentRefresh = TimeStamp::Now();
mPaintFlashing = Preferences::GetBool("nglayout.debug.paint_flashing");
mRequests.Init();
}

Просмотреть файл

@ -229,6 +229,17 @@ public:
*/
static int32_t DefaultInterval();
/**
* Enable/disable paint flashing.
*/
void SetPaintFlashing(bool aPaintFlashing) {
mPaintFlashing = aPaintFlashing;
}
bool GetPaintFlashing() {
return mPaintFlashing;
}
private:
typedef nsTObserverArray<nsARefreshObserver*> ObserverArray;
typedef nsTHashtable<nsISupportsHashKey> RequestTable;
@ -265,6 +276,7 @@ private:
bool mTestControllingRefreshes;
bool mViewManagerFlushIsPending;
bool mRequestedHighPrecision;
bool mPaintFlashing;
int64_t mMostRecentRefreshEpochTime;
mozilla::TimeStamp mMostRecentRefresh;

Просмотреть файл

@ -51,6 +51,7 @@ MOCHITEST_CHROME_FILES = \
test_passpointerevents.html \
passpointerevents_window.html \
test_bug812817.xul \
test_bug847890_paintFlashing.html \
$(NULL)
ifdef MOZ_DEBUG

Просмотреть файл

@ -0,0 +1,31 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Tests for paint flashing</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
function startTest() {
waitForAllPaintsFlushed(function () {
var before = snapshotWindow(window, false);
SpecialPowers.getDOMWindowUtils(window).paintFlashing = true;
document.body.innerHTML = "bar";
waitForAllPaintsFlushed(function () {
document.body.innerHTML = "foo";
waitForAllPaintsFlushed(function () {
var after = snapshotWindow(window, false);
ok(compareSnapshots(before, after, false)[0], "windows are different");
SpecialPowers.getDOMWindowUtils(window).paintFlashing = false;
SimpleTest.finish();
});
});
});
}
</script>
</head>
<body onload="startTest()">foo</body>
</html>