зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1055557 - Ensure the right presShell resolution is used in ApplyCallbackTransform for fennec-apz scenarios. r=botond
This commit is contained in:
Родитель
49c13c1c35
Коммит
d216c84c8b
|
@ -2108,8 +2108,7 @@ TabChild::RecvHandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifier
|
|||
|
||||
// Note: there is nothing to do with the modifiers here, as we are not
|
||||
// synthesizing any sort of mouse event.
|
||||
CSSPoint point = APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid,
|
||||
GetPresShellResolution());
|
||||
CSSPoint point = APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid);
|
||||
nsString data;
|
||||
data.AppendLiteral("{ \"x\" : ");
|
||||
data.AppendFloat(point.x);
|
||||
|
@ -2126,7 +2125,7 @@ bool
|
|||
TabChild::RecvHandleSingleTap(const CSSPoint& aPoint, const Modifiers& aModifiers, const ScrollableLayerGuid& aGuid)
|
||||
{
|
||||
if (mGlobal && mTabChildGlobal) {
|
||||
mAPZEventState->ProcessSingleTap(aPoint, aModifiers, aGuid, GetPresShellResolution());
|
||||
mAPZEventState->ProcessSingleTap(aPoint, aModifiers, aGuid);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2136,7 +2135,7 @@ TabChild::RecvHandleLongTap(const CSSPoint& aPoint, const Modifiers& aModifiers,
|
|||
{
|
||||
if (mGlobal && mTabChildGlobal) {
|
||||
mAPZEventState->ProcessLongTap(GetPresShell(), aPoint, aModifiers, aGuid,
|
||||
aInputBlockId, GetPresShellResolution());
|
||||
aInputBlockId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2381,17 +2380,6 @@ TabChild::CancelTapTracking()
|
|||
mTapHoldTimer = nullptr;
|
||||
}
|
||||
|
||||
float
|
||||
TabChild::GetPresShellResolution() const
|
||||
{
|
||||
nsCOMPtr<nsIDocument> document(GetDocument());
|
||||
nsIPresShell* shell = document->GetShell();
|
||||
if (!shell) {
|
||||
return 1.0f;
|
||||
}
|
||||
return shell->GetResolution();
|
||||
}
|
||||
|
||||
bool
|
||||
TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
|
@ -2404,7 +2392,7 @@ TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
|
|||
localEvent.widget = mPuppetWidget;
|
||||
|
||||
APZCCallbackHelper::ApplyCallbackTransform(localEvent, aGuid,
|
||||
mPuppetWidget->GetDefaultScale(), GetPresShellResolution());
|
||||
mPuppetWidget->GetDefaultScale());
|
||||
|
||||
if (localEvent.message == NS_TOUCH_START && AsyncPanZoomEnabled()) {
|
||||
if (gfxPrefs::TouchActionEnabled()) {
|
||||
|
|
|
@ -599,9 +599,6 @@ private:
|
|||
|
||||
bool HasValidInnerSize();
|
||||
|
||||
// Get the pres shell resolution of the document in this tab.
|
||||
float GetPresShellResolution() const;
|
||||
|
||||
void SetTabId(const TabId& aTabId);
|
||||
|
||||
ScreenIntRect GetOuterRect();
|
||||
|
|
|
@ -351,17 +351,49 @@ APZCCallbackHelper::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollI
|
|||
}
|
||||
}
|
||||
|
||||
static nsIPresShell*
|
||||
GetRootContentDocumentPresShellForContent(nsIContent* aContent)
|
||||
{
|
||||
nsIDocument* doc = aContent->GetComposedDoc();
|
||||
if (!doc) {
|
||||
return nullptr;
|
||||
}
|
||||
nsIPresShell* shell = doc->GetShell();
|
||||
if (!shell) {
|
||||
return nullptr;
|
||||
}
|
||||
nsPresContext* context = shell->GetPresContext();
|
||||
if (!context) {
|
||||
return nullptr;
|
||||
}
|
||||
context = context->GetToplevelContentDocumentPresContext();
|
||||
if (!context) {
|
||||
return nullptr;
|
||||
}
|
||||
return context->PresShell();
|
||||
}
|
||||
|
||||
CSSPoint
|
||||
APZCCallbackHelper::ApplyCallbackTransform(const CSSPoint& aInput,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
float aPresShellResolution)
|
||||
const ScrollableLayerGuid& aGuid)
|
||||
{
|
||||
// First, scale inversely by the pres shell resolution to cancel the
|
||||
// scale-to-resolution transform that the compositor adds to the layer with
|
||||
// the pres shell resolution. The points sent to Gecko by APZ don't have
|
||||
// this transform unapplied (unlike other compositor-side transforms)
|
||||
// because APZ doesn't know about it.
|
||||
CSSPoint input = aInput / aPresShellResolution;
|
||||
CSSPoint input = aInput;
|
||||
if (aGuid.mScrollId == FrameMetrics::NULL_SCROLL_ID) {
|
||||
return input;
|
||||
}
|
||||
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(aGuid.mScrollId);
|
||||
if (!content) {
|
||||
return input;
|
||||
}
|
||||
|
||||
// First, scale inversely by the root content document's pres shell
|
||||
// resolution to cancel the scale-to-resolution transform that the
|
||||
// compositor adds to the layer with the pres shell resolution. The points
|
||||
// sent to Gecko by APZ don't have this transform unapplied (unlike other
|
||||
// compositor-side transforms) because APZ doesn't know about it.
|
||||
if (nsIPresShell* shell = GetRootContentDocumentPresShellForContent(content)) {
|
||||
input = input / shell->GetResolution();
|
||||
}
|
||||
|
||||
// Now apply the callback-transform.
|
||||
// XXX: technically we need to walk all the way up the layer tree from the layer
|
||||
|
@ -374,16 +406,10 @@ APZCCallbackHelper::ApplyCallbackTransform(const CSSPoint& aInput,
|
|||
// some things transformed improperly. In practice we should rarely hit scenarios
|
||||
// where any of this matters, so I'm skipping it for now and just doing the single
|
||||
// transform for the layer that the input hit.
|
||||
|
||||
if (aGuid.mScrollId != FrameMetrics::NULL_SCROLL_ID) {
|
||||
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(aGuid.mScrollId);
|
||||
if (content) {
|
||||
void* property = content->GetProperty(nsGkAtoms::apzCallbackTransform);
|
||||
if (property) {
|
||||
CSSPoint delta = (*static_cast<CSSPoint*>(property));
|
||||
return input + delta;
|
||||
}
|
||||
}
|
||||
void* property = content->GetProperty(nsGkAtoms::apzCallbackTransform);
|
||||
if (property) {
|
||||
CSSPoint delta = (*static_cast<CSSPoint*>(property));
|
||||
input += delta;
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
@ -391,23 +417,21 @@ APZCCallbackHelper::ApplyCallbackTransform(const CSSPoint& aInput,
|
|||
LayoutDeviceIntPoint
|
||||
APZCCallbackHelper::ApplyCallbackTransform(const LayoutDeviceIntPoint& aPoint,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
const CSSToLayoutDeviceScale& aScale,
|
||||
float aPresShellResolution)
|
||||
const CSSToLayoutDeviceScale& aScale)
|
||||
{
|
||||
LayoutDevicePoint point = LayoutDevicePoint(aPoint.x, aPoint.y);
|
||||
point = ApplyCallbackTransform(point / aScale, aGuid, aPresShellResolution) * aScale;
|
||||
point = ApplyCallbackTransform(point / aScale, aGuid) * aScale;
|
||||
return gfx::RoundedToInt(point);
|
||||
}
|
||||
|
||||
void
|
||||
APZCCallbackHelper::ApplyCallbackTransform(WidgetTouchEvent& aEvent,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
const CSSToLayoutDeviceScale& aScale,
|
||||
float aPresShellResolution)
|
||||
const CSSToLayoutDeviceScale& aScale)
|
||||
{
|
||||
for (size_t i = 0; i < aEvent.touches.Length(); i++) {
|
||||
aEvent.touches[i]->mRefPoint = ApplyCallbackTransform(
|
||||
aEvent.touches[i]->mRefPoint, aGuid, aScale, aPresShellResolution);
|
||||
aEvent.touches[i]->mRefPoint, aGuid, aScale);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,8 +86,7 @@ public:
|
|||
pres shell resolution, to cancel out a compositor-side transform (added in
|
||||
bug 1076241) that APZ doesn't unapply. */
|
||||
static CSSPoint ApplyCallbackTransform(const CSSPoint& aInput,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
float aPresShellResolution);
|
||||
const ScrollableLayerGuid& aGuid);
|
||||
|
||||
/* Same as above, but operates on LayoutDeviceIntPoint.
|
||||
Requires an additonal |aScale| parameter to convert between CSS and
|
||||
|
@ -95,15 +94,13 @@ public:
|
|||
static mozilla::LayoutDeviceIntPoint
|
||||
ApplyCallbackTransform(const LayoutDeviceIntPoint& aPoint,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
const CSSToLayoutDeviceScale& aScale,
|
||||
float aPresShellResolution);
|
||||
const CSSToLayoutDeviceScale& aScale);
|
||||
|
||||
/* Convenience function for applying a callback transform to all touch
|
||||
* points of a touch event. */
|
||||
static void ApplyCallbackTransform(WidgetTouchEvent& aEvent,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
const CSSToLayoutDeviceScale& aScale,
|
||||
float aPresShellResolution);
|
||||
const CSSToLayoutDeviceScale& aScale);
|
||||
|
||||
/* Dispatch a widget event via the widget stored in the event, if any.
|
||||
* In a child process, allows the TabParent event-capture mechanism to
|
||||
|
|
|
@ -149,8 +149,7 @@ NS_IMPL_ISUPPORTS(DelayedFireSingleTapEvent, nsITimerCallback)
|
|||
void
|
||||
APZEventState::ProcessSingleTap(const CSSPoint& aPoint,
|
||||
Modifiers aModifiers,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
float aPresShellResolution)
|
||||
const ScrollableLayerGuid& aGuid)
|
||||
{
|
||||
APZES_LOG("Handling single tap at %s on %s with %d\n",
|
||||
Stringify(aPoint).c_str(), Stringify(aGuid).c_str(), mTouchEndCancelled);
|
||||
|
@ -165,7 +164,7 @@ APZEventState::ProcessSingleTap(const CSSPoint& aPoint,
|
|||
}
|
||||
|
||||
LayoutDevicePoint currentPoint =
|
||||
APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid, aPresShellResolution)
|
||||
APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid)
|
||||
* widget->GetDefaultScale();;
|
||||
if (!mActiveElementManager->ActiveElementUsesStyle()) {
|
||||
// If the active element isn't visually affected by the :active style, we
|
||||
|
@ -194,8 +193,7 @@ APZEventState::ProcessLongTap(const nsCOMPtr<nsIPresShell>& aPresShell,
|
|||
const CSSPoint& aPoint,
|
||||
Modifiers aModifiers,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
uint64_t aInputBlockId,
|
||||
float aPresShellResolution)
|
||||
uint64_t aInputBlockId)
|
||||
{
|
||||
APZES_LOG("Handling long tap at %s\n", Stringify(aPoint).c_str());
|
||||
|
||||
|
@ -212,7 +210,7 @@ APZEventState::ProcessLongTap(const nsCOMPtr<nsIPresShell>& aPresShell,
|
|||
// including in JS code, so it's not trivial to change.
|
||||
bool eventHandled =
|
||||
APZCCallbackHelper::DispatchMouseEvent(aPresShell, NS_LITERAL_STRING("contextmenu"),
|
||||
APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid, aPresShellResolution),
|
||||
APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid),
|
||||
2, 1, WidgetModifiersToDOMModifiers(aModifiers), true,
|
||||
nsIDOMMouseEvent::MOZ_SOURCE_TOUCH);
|
||||
|
||||
|
@ -221,7 +219,7 @@ APZEventState::ProcessLongTap(const nsCOMPtr<nsIPresShell>& aPresShell,
|
|||
// If no one handle context menu, fire MOZLONGTAP event
|
||||
if (!eventHandled) {
|
||||
LayoutDevicePoint currentPoint =
|
||||
APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid, aPresShellResolution)
|
||||
APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid)
|
||||
* widget->GetDefaultScale();
|
||||
int time = 0;
|
||||
nsEventStatus status =
|
||||
|
|
|
@ -51,14 +51,12 @@ public:
|
|||
|
||||
void ProcessSingleTap(const CSSPoint& aPoint,
|
||||
Modifiers aModifiers,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
float aPresShellResolution);
|
||||
const ScrollableLayerGuid& aGuid);
|
||||
void ProcessLongTap(const nsCOMPtr<nsIPresShell>& aUtils,
|
||||
const CSSPoint& aPoint,
|
||||
Modifiers aModifiers,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
uint64_t aInputBlockId,
|
||||
float aPresShellResolution);
|
||||
uint64_t aInputBlockId);
|
||||
void ProcessTouchEvent(const WidgetTouchEvent& aEvent,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
uint64_t aInputBlockId,
|
||||
|
|
|
@ -113,14 +113,6 @@ ChromeProcessController::Destroy()
|
|||
mWidget = nullptr;
|
||||
}
|
||||
|
||||
float
|
||||
ChromeProcessController::GetPresShellResolution() const
|
||||
{
|
||||
// The document in the chrome process cannot be zoomed, so its pres shell
|
||||
// resolution is 1.
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
nsIPresShell*
|
||||
ChromeProcessController::GetPresShell() const
|
||||
{
|
||||
|
@ -162,7 +154,7 @@ ChromeProcessController::HandleSingleTap(const CSSPoint& aPoint,
|
|||
return;
|
||||
}
|
||||
|
||||
mAPZEventState->ProcessSingleTap(aPoint, aModifiers, aGuid, GetPresShellResolution());
|
||||
mAPZEventState->ProcessSingleTap(aPoint, aModifiers, aGuid);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -179,7 +171,7 @@ ChromeProcessController::HandleLongTap(const mozilla::CSSPoint& aPoint, Modifier
|
|||
}
|
||||
|
||||
mAPZEventState->ProcessLongTap(GetPresShell(), aPoint, aModifiers, aGuid,
|
||||
aInputBlockId, GetPresShellResolution());
|
||||
aInputBlockId);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -62,7 +62,6 @@ private:
|
|||
MessageLoop* mUILoop;
|
||||
|
||||
void InitializeRoot();
|
||||
float GetPresShellResolution() const;
|
||||
nsIPresShell* GetPresShell() const;
|
||||
nsIDocument* GetDocument() const;
|
||||
already_AddRefed<nsIDOMWindowUtils> GetDOMWindowUtils() const;
|
||||
|
|
|
@ -1047,7 +1047,7 @@ nsBaseWidget::ProcessUntransformedAPZEvent(WidgetInputEvent* aEvent,
|
|||
// TODO: Do other types of events (than touch) need this?
|
||||
if (aEvent->AsTouchEvent() && aGuid.mLayersId == mCompositorParent->RootLayerTreeId()) {
|
||||
APZCCallbackHelper::ApplyCallbackTransform(*aEvent->AsTouchEvent(), aGuid,
|
||||
GetDefaultScale(), 1.0f);
|
||||
GetDefaultScale());
|
||||
}
|
||||
|
||||
nsEventStatus status;
|
||||
|
|
Загрузка…
Ссылка в новой задаче