diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index af40e5e1d814..3f31ccca8e1e 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -2227,6 +2227,29 @@ HasDescendantWindowOutsideRect(DWORD aThisThreadID, HWND aWnd, return PR_FALSE; } +static void +InvalidateRgnInWindowSubtree(HWND aWnd, HRGN aRgn, HRGN aTmpRgn) +{ + RECT clientRect; + ::GetClientRect(aWnd, &clientRect); + ::SetRectRgn(aTmpRgn, clientRect.left, clientRect.top, + clientRect.right, clientRect.bottom); + if (::CombineRgn(aTmpRgn, aTmpRgn, aRgn, RGN_AND) == NULLREGION) { + return; + } + + ::InvalidateRgn(aWnd, aTmpRgn, FALSE); + + for (HWND child = ::GetWindow(aWnd, GW_CHILD); child; + child = ::GetWindow(child, GW_HWNDNEXT)) { + POINT pt = { 0, 0 }; + ::MapWindowPoints(child, aWnd, &pt, 1); + ::OffsetRgn(aRgn, -pt.x, -pt.y); + InvalidateRgnInWindowSubtree(child, aRgn, aTmpRgn); + ::OffsetRgn(aRgn, pt.x, pt.y); + } +} + void nsWindow::Scroll(const nsIntPoint& aDelta, const nsTArray& aDestRects, @@ -2362,7 +2385,11 @@ nsWindow::Scroll(const nsIntPoint& aDelta, // it. ::SetRectRgn(destRgn, destRect.x, destRect.y, destRect.XMost(), destRect.YMost()); ::CombineRgn(updateRgn, updateRgn, destRgn, RGN_AND); - ::InvalidateRgn(mWnd, updateRgn, FALSE); + if (flags & SW_SCROLLCHILDREN) { + InvalidateRgnInWindowSubtree(mWnd, updateRgn, destRgn); + } else { + ::InvalidateRgn(mWnd, updateRgn, FALSE); + } } ::DeleteObject((HGDIOBJ)updateRgn);