Files
palemoon27/gfx/layers/apz/util/ChromeProcessController.cpp
T
roytam1 6e2582b2b6 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1117087 Don't reset IM context when nsGtkIMContext receives selection change during dispatching compositionstart r=m_kato (0bbca7a4c)
- Bug 1155494 - Add a 'compressall' message flag. f=handyman r=billm (parts of this patch were written by handyman with r=billm) (5bb9ccd32)
- Bug 1167882 - Move a couple of static helpers functions higher up in TabChild.cpp. r=kats (75a880959)
- Bug 1167882 - Add utility functions MaxScaleRatio() and MinScaleRatio() to Units.h. r=kats (3604aa9e2)
- Bug 1167882 - Use the display size (includes scrollbar areas) rather than the root composition bounds (excludes scrollbar areas) to calculate the intrinsic scale. r=kats (8b6f2917c)
- Fix a potential null-deref in TabChild::HandlePossibleViewportChange. (bug 1156156, r=kats) (55e5e79f4)
- Bug 1164406 - Exclude the scrollbars from the composition bounds in TabChild::HandleCalculateViewportChange() when appropriate. r=kats (28a7efaad)
- Bug 1089090, e10s, support custom cursors, r=jmathies (6f005a600)
- Bug 1125325 - Make TabParent/TabChild UpdateDimensions messages aware of the display scale. r=kats (07ac774b2)
- Bug 1157248 - TabChild should initialize ServiceWorkerManager before starting the first loading, r=nsm (0eb50c148)
- Bug 1060643 - Give content the opportunity to block chrome keyhandlers. r=smaug (93cdd9608)
- Bug 1137555 - Add implementation of PuppetWidget::GetMaxTouchPoints(). r=smaug, r=jimm (d859fd19a)
- Bug 1164763 - Avoid one extra IPC round-trip when compositor-lru-size == 0. r=mattwoodrow,billm (19cfdf029)
- bug 1167295 - manage PDocAccessible with PBrowser instead of PContent r=smaug (5787cd60c)
- Bug 1161592 - If we don't get a target frame from the touch point try using the root scrollable frame. r=botond (c0d49d85f)
- Bug 1162648. When updating layout with the latest async values from the APZC do the scrolling last because it can flush layout. r=botond,kats (f8a354aab)
- Bug 1163572 - Modify UpdateRootFrame to automatically compute the nsIContent* and nsIPresShell* from the metrics. r=botond (9d7fda5c8)
- Bug 1163572 - Have ChromeProcessController also handle root-frame repaint requests. r=botond (67786ad9f)
- Bug 1163572 - Modify UpdateSubFrame to automatically figure out the nsIContent from the scrollId. r=botond (136aff8a1)
- Bug 1175383 TabChild should store PuppetWidget as is rather than as nsIWidget r=smaug (3e2bfd3ad)
- Bug 1158424 - Expose IsRootContent() in AsyncPanZoomController. r=kats (632ba6051)
- Bug 1158424 - Clean up uses of HasNoParentWithSameLayersId() related to zoom constraints. r=kats (c94b5f517)
- Bug 1166942 - Add logging code for gfx::Matrix. r=nical (5dc405fa6)
- Bug 1055557 - Move storage of ZoomConstraints from RemoteContentController to APZCTreeManager. r=botond (8e1056b71)
- Bug 1055557 - Add a ZoomConstraintsClient class to manage pushing zoom constraints updates to the APZ code. r=botond (69f1ae857)
- Bug 1055557 - Constify some methods. r=botond (b81ec32f9)
- Bug 1055557 - Ensure the right presShell resolution is used in ApplyCallbackTransform for fennec-apz scenarios. r=botond (6df0c30e7)
- Bug 1175217 - Fix non-unified (and some unified) builds for nsDisplayListInvalidation.cpp. r=mstange (cd0662dfa)
- Bug 1160421 - Replace nsThreadPool with a custom thread pool implementation in DecodePool. r=tn (66ae4fac2)
- Bug 1130935 part.1 Add a method to check if current IME supports vertical writing mode r=emk (056232715)
- Bug 1130935 part.2 Set proper composition font when writing mode is changed r=emk (e5cc07c43)
- Bug 1130935 part.3 Add hack for Japanist because its candidate window is broken with @System font r=emk (4e7587585)
- Bug 1130935 part.4 nsIMM32Handler::GetCharacterRectOfSelectedTextAt() should return wrting mode if it's necessary r=emk+smaug (92e76951a)
- Bug 1130935 part.5 nsIMM32Handler should compute candidate window position with writing mode r=emk (676e1c274)
- Bug 1130935 part.6 Selection change notification should have selection range and writing mode information r=smaug (a0e37af25)
2021-02-06 08:28:03 +08:00

203 lines
6.0 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ChromeProcessController.h"
#include "MainThreadUtils.h" // for NS_IsMainThread()
#include "base/message_loop.h" // for MessageLoop
#include "mozilla/dom/Element.h"
#include "mozilla/layers/CompositorParent.h"
#include "mozilla/layers/APZCCallbackHelper.h"
#include "mozilla/layers/APZEventState.h"
#include "nsIDocument.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIPresShell.h"
#include "nsLayoutUtils.h"
#include "nsView.h"
using namespace mozilla;
using namespace mozilla::layers;
using namespace mozilla::widget;
ChromeProcessController::ChromeProcessController(nsIWidget* aWidget,
APZEventState* aAPZEventState)
: mWidget(aWidget)
, mAPZEventState(aAPZEventState)
, mUILoop(MessageLoop::current())
{
// Otherwise we're initializing mUILoop incorrectly.
MOZ_ASSERT(NS_IsMainThread());
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ChromeProcessController::InitializeRoot));
}
void
ChromeProcessController::InitializeRoot()
{
// Create a view-id and set a zero-margin displayport for the root element
// of the root document in the chrome process. This ensures that the scroll
// frame for this element gets an APZC, which in turn ensures that all content
// in the chrome processes is covered by an APZC.
// The displayport is zero-margin because this element is generally not
// actually scrollable (if it is, APZC will set proper margins when it's
// scrolled).
nsIPresShell* presShell = GetPresShell();
if (!presShell) {
return;
}
MOZ_ASSERT(presShell->GetDocument());
nsIContent* content = presShell->GetDocument()->GetDocumentElement();
if (!content) {
return;
}
uint32_t presShellId;
FrameMetrics::ViewID viewId;
if (APZCCallbackHelper::GetOrCreateScrollIdentifiers(content, &presShellId, &viewId)) {
nsLayoutUtils::SetDisplayPortMargins(content, presShell, ScreenMargin(), 0,
nsLayoutUtils::RepaintMode::DoNotRepaint);
}
}
void
ChromeProcessController::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
{
MOZ_ASSERT(NS_IsMainThread());
FrameMetrics metrics = aFrameMetrics;
if (metrics.IsRootContent()) {
APZCCallbackHelper::UpdateRootFrame(metrics);
} else {
APZCCallbackHelper::UpdateSubFrame(metrics);
}
}
void
ChromeProcessController::PostDelayedTask(Task* aTask, int aDelayMs)
{
MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs);
}
void
ChromeProcessController::RequestFlingSnap(const FrameMetrics::ViewID& aScrollId,
const mozilla::CSSPoint& aDestination)
{
APZCCallbackHelper::RequestFlingSnap(aScrollId, aDestination);
}
void
ChromeProcessController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
const uint32_t& aScrollGeneration)
{
APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration);
}
void
ChromeProcessController::Destroy()
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ChromeProcessController::Destroy));
return;
}
MOZ_ASSERT(MessageLoop::current() == mUILoop);
mWidget = nullptr;
}
nsIPresShell*
ChromeProcessController::GetPresShell() const
{
if (nsView* view = nsView::GetViewFor(mWidget)) {
return view->GetPresShell();
}
return nullptr;
}
nsIDocument*
ChromeProcessController::GetDocument() const
{
if (nsIPresShell* presShell = GetPresShell()) {
return presShell->GetDocument();
}
return nullptr;
}
already_AddRefed<nsIDOMWindowUtils>
ChromeProcessController::GetDOMWindowUtils() const
{
if (nsIDocument* doc = GetDocument()) {
nsCOMPtr<nsIDOMWindowUtils> result = do_GetInterface(doc->GetWindow());
return result.forget();
}
return nullptr;
}
void
ChromeProcessController::HandleSingleTap(const CSSPoint& aPoint,
Modifiers aModifiers,
const ScrollableLayerGuid& aGuid)
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ChromeProcessController::HandleSingleTap,
aPoint, aModifiers, aGuid));
return;
}
mAPZEventState->ProcessSingleTap(aPoint, aModifiers, aGuid);
}
void
ChromeProcessController::HandleLongTap(const mozilla::CSSPoint& aPoint, Modifiers aModifiers,
const ScrollableLayerGuid& aGuid,
uint64_t aInputBlockId)
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ChromeProcessController::HandleLongTap,
aPoint, aModifiers, aGuid, aInputBlockId));
return;
}
mAPZEventState->ProcessLongTap(GetPresShell(), aPoint, aModifiers, aGuid,
aInputBlockId);
}
void
ChromeProcessController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
APZStateChange aChange,
int aArg)
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ChromeProcessController::NotifyAPZStateChange,
aGuid, aChange, aArg));
return;
}
mAPZEventState->ProcessAPZStateChange(GetDocument(), aGuid.mScrollId, aChange, aArg);
}
void
ChromeProcessController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent)
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ChromeProcessController::NotifyMozMouseScrollEvent, aScrollId, aEvent));
return;
}
APZCCallbackHelper::NotifyMozMouseScrollEvent(aScrollId, aEvent);
}