Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[embedlite] Take scroll events from ScrollAreaEvent with the new API.…
… Contributes to JB#49550
  • Loading branch information
Aleksey authored and atatarov committed Apr 28, 2020
1 parent add2b8b commit 4b377a9
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions embedding/embedlite/utils/WebBrowserChrome.cpp
Expand Up @@ -31,6 +31,7 @@
#include "nsIBaseWindow.h"
#include "ScriptSettings.h" // for AutoNoJSAPI
#include "TabChildHelper.h"
#include "mozilla/ContentEvents.h" // for InternalScrollAreaEvent

// Duplicated from EventNameList.h
#define MOZ_MozAfterPaint "MozAfterPaint"
Expand Down Expand Up @@ -424,20 +425,19 @@ WebBrowserChrome::HandleEvent(nsIDOMEvent* aEvent)
// ignore changes to width and height contributed by growth in page
// quadrants other than x > 0 && y > 0.
nsIntPoint scrollOffset = GetScrollOffset(docWin);
nsCOMPtr<nsIDOMScrollAreaEvent> scrollEvent = do_QueryInterface(aEvent);
#if 0
float evX, evY, evW, evH;
scrollEvent->GetX(&evX);
scrollEvent->GetY(&evY);
scrollEvent->GetWidth(&evW);
scrollEvent->GetHeight(&evH);
float x = evX + scrollOffset.x;
float y = evY + scrollOffset.y;
uint32_t width = evW + (x < 0 ? x : 0);
uint32_t height = evH + (y < 0 ? y : 0);
mListener->OnScrolledAreaChanged(width, height);
#endif

if (aEvent) {
InternalScrollAreaEvent *internalEvent = aEvent->WidgetEventPtr()->AsScrollAreaEvent();
RefPtr<DOMRect> mClientArea = new DOMRect(nullptr);
mClientArea->SetLayoutRect(internalEvent->mArea);

const float x = mClientArea->Left() + scrollOffset.x;
const float y = mClientArea->Top() + scrollOffset.y;
const uint32_t width = mClientArea->Width() + (x < 0 ? x : 0);
const uint32_t height = mClientArea->Height() + (y < 0 ? y : 0);
mListener->OnScrolledAreaChanged(width, height);
}

nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(window->GetChromeEventHandler());
target->AddEventListener(NS_LITERAL_STRING(MOZ_MozAfterPaint), this, PR_FALSE);
} else if (type.EqualsLiteral(MOZ_pagehide)) {
Expand Down

0 comments on commit 4b377a9

Please sign in to comment.