Skip to content

Commit

Permalink
Merge commit '6a6a366031680829746b5d2362610b868fd9571a'
Browse files Browse the repository at this point in the history
  • Loading branch information
mineyoshikawasnow committed Feb 7, 2021
2 parents c4394bd + 6a6a366 commit 0b75129
Show file tree
Hide file tree
Showing 34 changed files with 811 additions and 690 deletions.
54 changes: 8 additions & 46 deletions dom/quota/ActorsParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5035,8 +5035,8 @@ QuotaManager::GetDirectoryMetadataWithQuotaInfo2(nsIFile* aDirectory) {
CreateDirectoryMetadata2(*aDirectory, timestamp, persisted, quotaInfo));
}

return GetDirectoryResultWithQuotaInfo{
{static_cast<int64_t>(timestamp), persisted}, std::move(quotaInfo)};
return GetDirectoryResultWithQuotaInfo{static_cast<int64_t>(timestamp),
persisted, std::move(quotaInfo)};
}

Result<QuotaManager::GetDirectoryResultWithQuotaInfo, nsresult>
Expand All @@ -5060,45 +5060,6 @@ QuotaManager::GetDirectoryMetadataWithQuotaInfo2WithRestore(nsIFile* aDirectory,
return maybeFirstAttemptResult.extract();
}

Result<QuotaManager::GetDirectoryResult, nsresult>
QuotaManager::GetDirectoryMetadata2(nsIFile* aDirectory) {
AssertIsOnIOThread();
MOZ_ASSERT(aDirectory);
MOZ_ASSERT(mStorageConnection);

QM_TRY_INSPECT(const auto& binaryStream,
GetBinaryInputStream(*aDirectory,
nsLiteralString(METADATA_V2_FILE_NAME)));

QM_TRY_INSPECT(const uint64_t& timestamp,
MOZ_TO_RESULT_INVOKE(binaryStream, Read64));

QM_TRY_INSPECT(const bool& persisted,
MOZ_TO_RESULT_INVOKE(binaryStream, ReadBoolean));

return GetDirectoryResult{static_cast<int64_t>(timestamp), persisted};
}

Result<QuotaManager::GetDirectoryResult, nsresult>
QuotaManager::GetDirectoryMetadata2WithRestore(nsIFile* aDirectory,
bool aPersistent) {
QM_TRY_UNWRAP(
auto maybeFirstAttemptResult,
([this, &aDirectory]() -> Result<Maybe<GetDirectoryResult>, nsresult> {
QM_TRY_RETURN(GetDirectoryMetadata2(aDirectory)
.map(Some<GetDirectoryResult, GetDirectoryResult>),
Maybe<GetDirectoryResult>{});
}()));

if (!maybeFirstAttemptResult) {
QM_TRY(RestoreDirectoryMetadata2(aDirectory, aPersistent));

QM_TRY_RETURN(GetDirectoryMetadata2(aDirectory));
}

return maybeFirstAttemptResult.extract();
}

nsresult QuotaManager::InitializeRepository(PersistenceType aPersistenceType) {
MOZ_ASSERT(aPersistenceType == PERSISTENCE_TYPE_TEMPORARY ||
aPersistenceType == PERSISTENCE_TYPE_DEFAULT);
Expand Down Expand Up @@ -6471,9 +6432,10 @@ QuotaManager::EnsurePersistentOriginIsInitialized(const QuotaInfo& aQuotaInfo) {
}

// Get the metadata. We only use the timestamp.
QM_TRY_INSPECT(const auto& metadata, GetDirectoryMetadata2WithRestore(
directory,
/* aPersistent */ true));
QM_TRY_INSPECT(const auto& metadata,
GetDirectoryMetadataWithQuotaInfo2WithRestore(
directory,
/* aPersistent */ true));

MOZ_ASSERT(metadata.mTimestamp <= PR_Now());

Expand Down Expand Up @@ -9597,7 +9559,7 @@ nsresult PersistedOp::DoDirectoryWork(QuotaManager& aQuotaManager) {
if (exists) {
// Get the metadata. We only use the persisted flag.
QM_TRY_INSPECT(const auto& metadata,
aQuotaManager.GetDirectoryMetadata2WithRestore(
aQuotaManager.GetDirectoryMetadataWithQuotaInfo2WithRestore(
directory,
/* aPersistent */ false));

Expand Down Expand Up @@ -9664,7 +9626,7 @@ nsresult PersistOp::DoDirectoryWork(QuotaManager& aQuotaManager) {
// Get the metadata (restore the metadata file if necessary). We only use
// the persisted flag.
QM_TRY_INSPECT(const auto& metadata,
aQuotaManager.GetDirectoryMetadata2WithRestore(
aQuotaManager.GetDirectoryMetadataWithQuotaInfo2WithRestore(
directory,
/* aPersistent */ false));

Expand Down
11 changes: 1 addition & 10 deletions dom/quota/QuotaManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,9 @@ class QuotaManager final : public BackgroundThreadObject {

nsresult RestoreDirectoryMetadata2(nsIFile* aDirectory, bool aPersistent);

struct GetDirectoryResult {
struct GetDirectoryResultWithQuotaInfo {
int64_t mTimestamp;
bool mPersisted;
};

struct GetDirectoryResultWithQuotaInfo : GetDirectoryResult {
QuotaInfo mQuotaInfo;
};

Expand All @@ -283,12 +280,6 @@ class QuotaManager final : public BackgroundThreadObject {
GetDirectoryMetadataWithQuotaInfo2WithRestore(nsIFile* aDirectory,
bool aPersistent);

Result<GetDirectoryResult, nsresult> GetDirectoryMetadata2(
nsIFile* aDirectory);

Result<GetDirectoryResult, nsresult> GetDirectoryMetadata2WithRestore(
nsIFile* aDirectory, bool aPersistent);

// This is the main entry point into the QuotaManager API.
// Any storage API implementation (quota client) that participates in
// centralized quota and storage handling should call this method to get
Expand Down
8 changes: 4 additions & 4 deletions gfx/layers/apz/test/mochitest/helper_check_dp_size.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@
ok(innerdp.h > 30, outputprefix + " innerdiv display port should be larger than innerdiv");

let outerdp = getLastContentDisplayportFor("outerdiv");
is(outerdp.x, 0, outputprefix + " outerdiv display port should zero margin x");
is(outerdp.y, 0, outputprefix + " outerdiv display port should zero margin y");
is(outerdp.w, 50, outputprefix + " outerdiv display port should zero margin w");
ok(outerdp.h < theheight * allowedscalefactor, outputprefix + " outerdiv display port should zero margin h");
is(outerdp.x, 0, outputprefix + " outerdiv display port should be relatively bounded x");
is(outerdp.y, 0, outputprefix + " outerdiv display port should be relatively bounded y");
ok(outerdp.w <= 50, outputprefix + " outerdiv display port should relatively bounded w");
ok(outerdp.h < theheight * allowedscalefactor, outputprefix + " outerdiv display port should be relatively bounded h");

ok(true, "innerdp " + JSON.stringify(innerdp));
ok(true, "outerdp " + JSON.stringify(outerdp));
Expand Down
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>
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>
2 changes: 2 additions & 0 deletions gfx/layers/apz/test/mochitest/mochitest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,5 @@
skip-if =
debug || (os != 'mac' && os != 'win') || !e10s || verify || webrender
true # Don't run in CI yet, see bug 1657477
[test_group_bug1534549.html]
skip-if = !webrender # FLB still suffers from bug 1534549
37 changes: 37 additions & 0 deletions gfx/layers/apz/test/mochitest/test_group_bug1534549.html
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>
2 changes: 2 additions & 0 deletions gfx/layers/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ EXPORTS.mozilla.layers += [
"wr/AsyncImagePipelineManager.h",
"wr/ClipManager.h",
"wr/DisplayItemCache.h",
"wr/HitTestInfoManager.h",
"wr/IpcResourceUpdateQueue.h",
"wr/OMTAController.h",
"wr/OMTASampler.h",
Expand Down Expand Up @@ -545,6 +546,7 @@ UNIFIED_SOURCES += [
"wr/AsyncImagePipelineManager.cpp",
"wr/ClipManager.cpp",
"wr/DisplayItemCache.cpp",
"wr/HitTestInfoManager.cpp",
"wr/IpcResourceUpdateQueue.cpp",
"wr/OMTAController.cpp",
"wr/OMTASampler.cpp",
Expand Down
113 changes: 113 additions & 0 deletions gfx/layers/wr/HitTestInfoManager.cpp
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
Loading

0 comments on commit 0b75129

Please sign in to comment.