forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '6a6a366031680829746b5d2362610b868fd9571a'
- Loading branch information
Showing
34 changed files
with
811 additions
and
690 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
gfx/layers/apz/test/mochitest/helper_touch_action_ordering_block.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width; initial-scale=1.0"> | ||
<title>Touch-action with sorted element</title> | ||
<script type="application/javascript" src="apz_test_native_event_utils.js"></script> | ||
<script type="application/javascript" src="apz_test_utils.js"></script> | ||
<script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script> | ||
<script type="application/javascript"> | ||
function* test(testDriver) { | ||
var target = document.getElementById("target"); | ||
document.body.addEventListener("touchend", testDriver, { passive: true }); | ||
|
||
// drag the page up to scroll down by 50px | ||
yield ok(synthesizeNativeTouchDrag(target, 10, 100, 0, -50), | ||
"Synthesized native vertical drag, waiting for touch-end event..."); | ||
|
||
yield flushApzRepaints(testDriver); | ||
|
||
is(window.scrollX, 0, "X scroll offset didn't change"); | ||
is(window.scrollY, 50, "Y scroll offset changed"); | ||
} | ||
|
||
waitUntilApzStable() | ||
.then(test) | ||
.then(subtestDone); | ||
</script> | ||
</head> | ||
<body style="border: solid 1px green"> | ||
<div id="spacer" style="height: 2000px"> | ||
<div style="width:200px; height:200px; background-color:blue"> | ||
<span id="target" style="display:inline-block; width:200px; height:200px; background-color:red;"></span> | ||
</div> | ||
<div style="width:200px; height:200px; background-color:orange; touch-action:none; margin-top:-200px;"></div> | ||
</div> | ||
</body> | ||
</html> |
36 changes: 36 additions & 0 deletions
36
gfx/layers/apz/test/mochitest/helper_touch_action_ordering_zindex.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width; initial-scale=1.0"> | ||
<title>Touch-action with sorted element</title> | ||
<script type="application/javascript" src="apz_test_native_event_utils.js"></script> | ||
<script type="application/javascript" src="apz_test_utils.js"></script> | ||
<script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script> | ||
<script type="application/javascript"> | ||
function* test(testDriver) { | ||
var target = document.getElementById("target"); | ||
document.body.addEventListener("touchend", testDriver, { passive: true }); | ||
|
||
// drag the page up to scroll down by 50px | ||
yield ok(synthesizeNativeTouchDrag(target, 10, 100, 0, -50), | ||
"Synthesized native vertical drag, waiting for touch-end event..."); | ||
|
||
yield flushApzRepaints(testDriver); | ||
|
||
is(window.scrollX, 0, "X scroll offset didn't change"); | ||
is(window.scrollY, 50, "Y scroll offset changed"); | ||
} | ||
|
||
waitUntilApzStable() | ||
.then(test) | ||
.then(subtestDone); | ||
</script> | ||
</head> | ||
<body style="border: solid 1px green"> | ||
<div id="spacer" style="height:2000px"> | ||
<div id="target" style="width:200px; height:200px; background-color:blue;"></div> | ||
<div style="position: relative; width:200px; height:200px; background-color:red; touch-action:none; margin-top:-200px; z-index: -1;"></div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Tests for bug 1534549</title> | ||
<script src="/tests/SimpleTest/SimpleTest.js"></script> | ||
<script type="application/javascript" src="apz_test_native_event_utils.js"></script> | ||
<script type="application/javascript" src="apz_test_utils.js"></script> | ||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> | ||
<script type="application/javascript"> | ||
var touch_action_prefs = getPrefs("TOUCH_ACTION"); | ||
|
||
var subtests = [ | ||
// Tests that z-index ordering is respected by hit-test info. | ||
{ "file": "helper_touch_action_ordering_zindex.html", "prefs": touch_action_prefs }, | ||
// Tests that complex block/inline background ordering is respected by hit-test info. | ||
{ "file": "helper_touch_action_ordering_block.html", "prefs": touch_action_prefs }, | ||
]; | ||
|
||
if (isApzEnabled()) { | ||
ok(window.TouchEvent, "Check if TouchEvent is supported (it should be, the test harness forces it on everywhere)"); | ||
if (getPlatform() == "android") { | ||
// This has a lot of subtests, and Android emulators are slow. | ||
SimpleTest.requestLongerTimeout(2); | ||
} | ||
|
||
SimpleTest.waitForExplicitFinish(); | ||
window.onload = function() { | ||
runSubtestsSeriallyInFreshWindows(subtests) | ||
.then(SimpleTest.finish, SimpleTest.finishWithFailure); | ||
}; | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | ||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */ | ||
/* 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 "HitTestInfoManager.h" | ||
#include "HitTestInfo.h" | ||
|
||
#include "nsDisplayList.h" | ||
|
||
#define DEBUG_HITTEST_INFO 0 | ||
#if DEBUG_HITTEST_INFO | ||
# define HITTEST_INFO_LOG(...) printf_stderr(__VA_ARGS__) | ||
#else | ||
# define HITTEST_INFO_LOG(...) | ||
#endif | ||
|
||
namespace mozilla::layers { | ||
|
||
using ViewID = ScrollableLayerGuid::ViewID; | ||
|
||
/** | ||
* TODO(miko): This used to be a performance bottle-neck, but it does not show | ||
* up in profiles anymore, see bugs 1424637 and 1424968. | ||
* A better way of doing this would be to store current app units per dev pixel | ||
* in wr::DisplayListBuilder, and update it whenever display items that separate | ||
* presshell boundaries are encountered. | ||
*/ | ||
static int32_t GetAppUnitsFromDisplayItem(nsDisplayItem* aItem) { | ||
nsIFrame* frame = aItem->Frame(); | ||
MOZ_ASSERT(frame); | ||
return frame->PresContext()->AppUnitsPerDevPixel(); | ||
} | ||
|
||
static void CreateWebRenderCommands(wr::DisplayListBuilder& aBuilder, | ||
nsDisplayItem* aItem, const nsRect& aArea, | ||
const gfx::CompositorHitTestInfo& aFlags, | ||
const ViewID& aViewId) { | ||
const Maybe<SideBits> sideBits = | ||
aBuilder.GetContainingFixedPosSideBits(aItem->GetActiveScrolledRoot()); | ||
|
||
const LayoutDeviceRect devRect = | ||
LayoutDeviceRect::FromAppUnits(aArea, GetAppUnitsFromDisplayItem(aItem)); | ||
const wr::LayoutRect rect = wr::ToLayoutRect(devRect); | ||
|
||
aBuilder.PushHitTest(rect, rect, !aItem->BackfaceIsHidden(), aViewId, aFlags, | ||
sideBits.valueOr(SideBits::eNone)); | ||
} | ||
|
||
void HitTestInfoManager::Reset() { | ||
mArea = nsRect(); | ||
mFlags = gfx::CompositorHitTestInvisibleToHit; | ||
HITTEST_INFO_LOG("* HitTestInfoManager::Reset\n"); | ||
} | ||
|
||
void HitTestInfoManager::ProcessItem( | ||
nsDisplayItem* aItem, wr::DisplayListBuilder& aBuilder, | ||
nsDisplayListBuilder* aDisplayListBuilder) { | ||
MOZ_ASSERT(aItem); | ||
|
||
if (!aItem->HasHitTestInfo()) { | ||
return; | ||
} | ||
|
||
const HitTestInfo& hitTestInfo = aItem->GetHitTestInfo(); | ||
const nsRect& area = hitTestInfo.Area(); | ||
const gfx::CompositorHitTestInfo& flags = hitTestInfo.Info(); | ||
|
||
if (flags == gfx::CompositorHitTestInvisibleToHit || area.IsEmpty()) { | ||
return; | ||
} | ||
|
||
const auto viewId = | ||
hitTestInfo.GetViewId(aBuilder, aItem->GetActiveScrolledRoot()); | ||
const auto spaceAndClipChain = aBuilder.CurrentSpaceAndClipChain(); | ||
|
||
if (!Update(area, flags, viewId, spaceAndClipChain)) { | ||
// The previous hit test information is still valid. | ||
return; | ||
} | ||
|
||
HITTEST_INFO_LOG("+ [%d, %d, %d, %d]: flags: 0x%x, viewId: %llu\n", area.x, | ||
area.y, area.width, area.height, flags.serialize(), viewId); | ||
|
||
CreateWebRenderCommands(aBuilder, aItem, area, flags, viewId); | ||
} | ||
|
||
/** | ||
* Updates the current hit testing information if necessary. | ||
* Returns true if the the hit testing information was changed. | ||
*/ | ||
bool HitTestInfoManager::Update(const nsRect& aArea, | ||
const gfx::CompositorHitTestInfo& aFlags, | ||
const ViewID& aViewId, | ||
const wr::WrSpaceAndClipChain& aSpaceAndClip) { | ||
if (mViewId == aViewId && mFlags == aFlags && mArea.Contains(aArea) && | ||
mSpaceAndClipChain == aSpaceAndClip) { | ||
// The previous hit testing information can be reused. | ||
HITTEST_INFO_LOG("s [%d, %d, %d, %d]: flags: 0x%x, viewId: %llu\n", aArea.x, | ||
aArea.y, aArea.width, aArea.height, aFlags.serialize(), | ||
aViewId); | ||
return false; | ||
} | ||
|
||
mArea = aArea; | ||
mFlags = aFlags; | ||
mViewId = aViewId; | ||
mSpaceAndClipChain = aSpaceAndClip; | ||
return true; | ||
} | ||
|
||
} // namespace mozilla::layers |
Oops, something went wrong.