Bug 898126 - Cache client hit test values, r=jimm

This commit is contained in:
Markus Stange 2013-07-29 13:19:34 +02:00
Родитель 28eed8a448
Коммит 86cead439b
2 изменённых файлов: 36 добавлений и 13 удалений

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

@ -280,6 +280,12 @@ static const int32_t kResizableBorderMinSize = 3;
// this, other hardware we expect to report correctly in D3D9.
#define MAX_ACCELERATED_DIMENSION 8192
// On window open (as well as after), Windows has an unfortunate habit of
// sending rather a lot of WM_NCHITTEST messages. Because we have to do point
// to DOM target conversions for these, we cache responses for a given
// coordinate this many milliseconds:
#define HITTEST_CACHE_LIFETIME_MS 50
/**************************************************************
**************************************************************
@ -338,6 +344,10 @@ nsWindow::nsWindow() : nsWindowBase()
mLastKeyboardLayout = 0;
mBlurSuppressLevel = 0;
mLastPaintEndTime = TimeStamp::Now();
mCachedHitTestPoint.x = 0;
mCachedHitTestPoint.y = 0;
mCachedHitTestTime = TimeStamp::Now();
mCachedHitTestResult = 0;
#ifdef MOZ_XUL
mTransparentSurface = nullptr;
mMemoryDC = nullptr;
@ -5559,22 +5569,30 @@ nsWindow::ClientMarginHitTestPoint(int32_t mx, int32_t my)
}
if (!sIsInMouseCapture && allowContentOverride) {
nsMouseEvent event(true, NS_MOUSE_MOZHITTEST, this, nsMouseEvent::eReal,
nsMouseEvent::eNormal);
POINT pt = { mx, my };
::ScreenToClient(mWnd, &pt);
event.refPoint = nsIntPoint(pt.x, pt.y);
event.inputSource = MOUSE_INPUT_SOURCE();
event.mFlags.mOnlyChromeDispatch = true;
bool result = DispatchWindowEvent(&event);
if (result) {
// The mouse is over a blank area
testResult = testResult == HTCLIENT ? HTCAPTION : testResult;
if (pt.x == mCachedHitTestPoint.x && pt.y == mCachedHitTestPoint.y &&
TimeStamp::Now() - mCachedHitTestTime < TimeDuration::FromMilliseconds(HITTEST_CACHE_LIFETIME_MS)) {
testResult = mCachedHitTestResult;
} else {
// There's content over the mouse pointer. Set HTCLIENT
// to possibly override a resizer border.
testResult = HTCLIENT;
nsMouseEvent event(true, NS_MOUSE_MOZHITTEST, this, nsMouseEvent::eReal,
nsMouseEvent::eNormal);
event.refPoint = nsIntPoint(pt.x, pt.y);
event.inputSource = MOUSE_INPUT_SOURCE();
event.mFlags.mOnlyChromeDispatch = true;
bool result = DispatchWindowEvent(&event);
if (result) {
// The mouse is over a blank area
testResult = testResult == HTCLIENT ? HTCAPTION : testResult;
} else {
// There's content over the mouse pointer. Set HTCLIENT
// to possibly override a resizer border.
testResult = HTCLIENT;
}
mCachedHitTestPoint = pt;
mCachedHitTestTime = TimeStamp::Now();
mCachedHitTestResult = testResult;
}
}

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

@ -539,6 +539,11 @@ protected:
// painting too rapidly in response to frequent input events.
TimeStamp mLastPaintEndTime;
// Caching for hit test results
POINT mCachedHitTestPoint;
TimeStamp mCachedHitTestTime;
int32_t mCachedHitTestResult;
static bool sNeedsToInitMouseWheelSettings;
static void InitMouseWheelScrollData();
};