зеркало из https://github.com/mozilla/gecko-dev.git
Bug 847890 - paint flashing for content only. r=roc
This commit is contained in:
Родитель
f567819f9d
Коммит
b1db0cf9dc
|
@ -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,23 +759,12 @@ 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->SetColor(gfxRGBA(r, g, b, 0.4));
|
||||
aContext->Paint();
|
||||
}
|
||||
}
|
||||
|
||||
FrameLayerBuilder::DisplayItemData*
|
||||
FrameLayerBuilder::GetDisplayItemData(nsIFrame* aFrame, uint32_t aKey)
|
||||
|
@ -3361,7 +3350,10 @@ FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer,
|
|||
aContext->Restore();
|
||||
}
|
||||
|
||||
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>
|
Загрузка…
Ссылка в новой задаче