Initialize Flutter Beta (flutter-3.32-candidate.0) (#166783)

Closes https://github.com/flutter/flutter/issues/166811.

```sh
$ dev/conductor/bin/conductor start \
  --candidate-branch=flutter-3.32-candidate.0 \
  --release-channel=beta \
  --github-username=matanlurey \
  --dart-revision=0d6811928830b87e36a0f49eb7fe554c308d3699 
```
This commit is contained in:
Matan Lurey
2025-04-09 15:57:49 -07:00
committed by GitHub
parent e2dea95082
commit 72ee26e314
62 changed files with 1258 additions and 631 deletions

View File

@@ -1,4 +1,4 @@
Signature: 7582ce3fcdf2e515db0132d7c32bf1b3
Signature: c96f6439e1d3cadfbb6adc790efdcc37
====================================================================================================
LIBRARY: dart
@@ -4862,7 +4862,7 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.
You may obtain a copy of this library's Source Code Form from: https://dart.googlesource.com/sdk/+/4293d50dd30d5469fac05af7470148977327bbe8
You may obtain a copy of this library's Source Code Form from: https://dart.googlesource.com/sdk/+/0d6811928830b87e36a0f49eb7fe554c308d3699
/third_party/fallback_root_certificates/
====================================================================================================

View File

@@ -1,4 +1,4 @@
Signature: cc16851918508797c4c52f81aeae260a
Signature: 6385fd7cd2f7be2e7ceee9d4b05eaf04
====================================================================================================
LIBRARY: etc1

View File

@@ -938,6 +938,7 @@ TEST_P(AiksTest, ImageColorSourceEffectTransform) {
// Scale
{
builder.Save();
builder.Translate(100, 0);
builder.Scale(100, 100);
DlPaint paint;
@@ -948,6 +949,23 @@ TEST_P(AiksTest, ImageColorSourceEffectTransform) {
DlImageSampling::kNearestNeighbor, &matrix));
builder.DrawRect(DlRect::MakeLTRB(0, 0, 1, 1), paint);
builder.Restore();
}
// Perspective
{
builder.Save();
builder.Translate(150, 150);
DlPaint paint;
DlMatrix matrix =
DlMatrix::MakePerspective(Radians{0.5}, ISize{200, 200}, 0.05, 1);
paint.setColorSource(DlColorSource::MakeImage(
texture, DlTileMode::kRepeat, DlTileMode::kRepeat,
DlImageSampling::kNearestNeighbor, &matrix));
builder.DrawRect(DlRect::MakeLTRB(0, 0, 200, 200), paint);
builder.Restore();
}
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));

View File

@@ -1253,57 +1253,6 @@ TEST_P(AiksTest, BlurredRectangleWithShader) {
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
TEST_P(AiksTest, GaussianBlurWithoutDecalSupport) {
if (GetParam() != PlaygroundBackend::kMetal) {
GTEST_SKIP()
<< "This backend doesn't yet support setting device capabilities.";
}
if (!WillRenderSomething()) {
// Sometimes these tests are run without playgrounds enabled which is
// pointless for this test since we are asserting that
// `SupportsDecalSamplerAddressMode` is called.
GTEST_SKIP() << "This test requires playgrounds.";
}
std::shared_ptr<const Capabilities> old_capabilities =
GetContext()->GetCapabilities();
auto mock_capabilities = std::make_shared<MockCapabilities>();
EXPECT_CALL(*mock_capabilities, SupportsDecalSamplerAddressMode())
.Times(::testing::AtLeast(1))
.WillRepeatedly(::testing::Return(false));
FLT_FORWARD(mock_capabilities, old_capabilities, GetDefaultColorFormat);
FLT_FORWARD(mock_capabilities, old_capabilities, GetDefaultStencilFormat);
FLT_FORWARD(mock_capabilities, old_capabilities,
GetDefaultDepthStencilFormat);
FLT_FORWARD(mock_capabilities, old_capabilities, SupportsOffscreenMSAA);
FLT_FORWARD(mock_capabilities, old_capabilities,
SupportsImplicitResolvingMSAA);
FLT_FORWARD(mock_capabilities, old_capabilities, SupportsReadFromResolve);
FLT_FORWARD(mock_capabilities, old_capabilities, SupportsFramebufferFetch);
FLT_FORWARD(mock_capabilities, old_capabilities, SupportsSSBO);
FLT_FORWARD(mock_capabilities, old_capabilities, SupportsCompute);
FLT_FORWARD(mock_capabilities, old_capabilities,
SupportsTextureToTextureBlits);
FLT_FORWARD(mock_capabilities, old_capabilities, GetDefaultGlyphAtlasFormat);
FLT_FORWARD(mock_capabilities, old_capabilities, SupportsTriangleFan);
FLT_FORWARD(mock_capabilities, old_capabilities, SupportsPrimitiveRestart);
ASSERT_TRUE(SetCapabilities(mock_capabilities).ok());
auto texture = DlImageImpeller::Make(CreateTextureForFixture("boston.jpg"));
DisplayListBuilder builder;
builder.Scale(GetContentScale().x * 0.5, GetContentScale().y * 0.5);
DlPaint paint;
paint.setColor(DlColor::kBlack());
builder.DrawPaint(paint);
auto blur_filter = DlImageFilter::MakeBlur(20, 20, DlTileMode::kDecal);
paint.setImageFilter(blur_filter);
builder.DrawImage(texture, DlPoint(200, 200), {}, &paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
// This addresses a bug where tiny blurs could result in mip maps that beyond
// the limits for the textures used for blurring.
// See also: b/323402168

View File

@@ -197,7 +197,8 @@ std::shared_ptr<ColorSourceContents> Paint::CreateContents() const {
image_color_source->vertical_tile_mode());
auto sampler_descriptor =
skia_conversions::ToSamplerDescriptor(image_color_source->sampling());
auto effect_transform = image_color_source->matrix();
// See https://github.com/flutter/flutter/issues/165205
flutter::DlMatrix effect_transform = image_color_source->matrix().To3x3();
auto contents = std::make_shared<TiledTextureContents>();
contents->SetOpacityFactor(color.alpha);

View File

@@ -247,6 +247,19 @@ struct Matrix {
// clang-format on
}
// Converts the second row/col to identity to make this an equivalent
// to a Skia 3x3 Matrix.
constexpr Matrix To3x3() const {
// clang-format off
return Matrix(
m[0], m[1], 0, m[3],
m[4], m[5], 0, m[7],
0, 0, 1, 0,
m[12], m[13], 0, m[15]
);
// clang-format on
}
constexpr Matrix Translate(const Vector3& t) const {
// clang-format off
return Matrix(m[0], m[1], m[2], m[3],

View File

@@ -313,5 +313,14 @@ TEST(MatrixTest, MakeScaleTranslate) {
Matrix::MakeTranslation({0, 0, 0}) * Matrix::MakeScale({0, 0, 0})));
}
TEST(MatrixTest, To3x3) {
Matrix x(1.0, 0.0, 4.0, 0.0, //
0.0, 1.0, 4.0, 0.0, //
6.0, 5.0, 111.0, 7.0, //
0.0, 0.0, 9.0, 1.0);
EXPECT_TRUE(MatrixNear(x.To3x3(), Matrix()));
}
} // namespace testing
} // namespace impeller

View File

@@ -5,6 +5,7 @@
#include "impeller/renderer/backend/vulkan/allocator_vk.h"
#include <memory>
#include <utility>
#include "flutter/fml/memory/ref_ptr.h"
#include "flutter/fml/trace_event.h"
@@ -12,6 +13,7 @@
#include "impeller/core/formats.h"
#include "impeller/renderer/backend/vulkan/capabilities_vk.h"
#include "impeller/renderer/backend/vulkan/device_buffer_vk.h"
#include "impeller/renderer/backend/vulkan/device_holder_vk.h"
#include "impeller/renderer/backend/vulkan/formats_vk.h"
#include "impeller/renderer/backend/vulkan/texture_vk.h"
#include "vulkan/vulkan_enums.hpp"
@@ -405,9 +407,10 @@ class AllocatedTextureSourceVK final : public TextureSourceVK {
return;
}
resource_.Swap(ImageResource(ImageVMA{allocator, allocation, image},
std::move(image_view),
std::move(rt_image_view)));
resource_.Swap(ImageResource(
ImageVMA{allocator, allocation, image}, std::move(image_view),
std::move(rt_image_view), context.GetResourceAllocator(),
context.GetDeviceHolder()));
is_valid_ = true;
}
@@ -429,6 +432,8 @@ class AllocatedTextureSourceVK final : public TextureSourceVK {
private:
struct ImageResource {
std::shared_ptr<DeviceHolderVK> device_holder;
std::shared_ptr<Allocator> allocator;
UniqueImageVMA image;
vk::UniqueImageView image_view;
vk::UniqueImageView rt_image_view;
@@ -437,8 +442,12 @@ class AllocatedTextureSourceVK final : public TextureSourceVK {
ImageResource(ImageVMA p_image,
vk::UniqueImageView p_image_view,
vk::UniqueImageView p_rt_image_view)
: image(p_image),
vk::UniqueImageView p_rt_image_view,
std::shared_ptr<Allocator> allocator,
std::shared_ptr<DeviceHolderVK> device_holder)
: device_holder(std::move(device_holder)),
allocator(std::move(allocator)),
image(p_image),
image_view(std::move(p_image_view)),
rt_image_view(std::move(p_rt_image_view)) {}

View File

@@ -5,6 +5,7 @@
#include "flutter/testing/testing.h" // IWYU pragma: keep
#include "gtest/gtest.h"
#include "impeller/base/allocation_size.h"
#include "impeller/core/allocator.h"
#include "impeller/core/device_buffer.h"
#include "impeller/core/device_buffer_descriptor.h"
#include "impeller/core/formats.h"
@@ -73,6 +74,25 @@ TEST(AllocatorVKTest, MemoryTypeSelectionTwoHeap) {
EXPECT_EQ(AllocatorVK::FindMemoryTypeIndex(4, properties), -1);
}
TEST(AllocatorVKTest, ImageResourceKeepsVulkanDeviceAlive) {
std::shared_ptr<Texture> texture;
std::weak_ptr<Allocator> weak_allocator;
{
auto const context = MockVulkanContextBuilder().Build();
weak_allocator = context->GetResourceAllocator();
auto allocator = context->GetResourceAllocator();
texture = allocator->CreateTexture(TextureDescriptor{
.storage_mode = StorageMode::kDevicePrivate,
.format = PixelFormat::kR8G8B8A8UNormInt,
.size = {1, 1},
});
context->Shutdown();
}
ASSERT_TRUE(weak_allocator.lock());
}
#ifdef IMPELLER_DEBUG
TEST(AllocatorVKTest, RecreateSwapchainWhenSizeChanges) {

View File

@@ -12,7 +12,6 @@
#include "impeller/renderer/backend/vulkan/shared_object_vk.h"
#include "impeller/renderer/backend/vulkan/vk.h"
#include "impeller/renderer/backend/vulkan/yuv_conversion_vk.h"
#include "vulkan/vulkan_handles.hpp"
namespace impeller {

View File

@@ -1,6 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:typed_data';
import 'package:meta/meta.dart';
import 'package:ui/src/engine.dart';
@@ -9,20 +10,10 @@ import 'package:ui/ui.dart' as ui;
/// Implements vertical and horizontal scrolling functionality for semantics
/// objects.
///
/// Scrolling is implemented using a "joystick" method. The absolute value of
/// "scrollTop" in HTML is not important. We only need to know in whether the
/// value changed in the positive or negative direction. If it changes in the
/// positive direction we send a [ui.SemanticsAction.scrollUp]. Otherwise, we
/// send [ui.SemanticsAction.scrollDown]. The actual scrolling is then handled
/// by the framework and we receive a [ui.SemanticsUpdate] containing the new
/// [scrollPosition] and child positions.
///
/// "scrollTop" or "scrollLeft" is always reset to an arbitrarily chosen non-
/// zero "neutral" scroll position value. This is done so we have a
/// predictable range of DOM scroll position values. When the amount of
/// contents is less than the size of the viewport the browser snaps
/// "scrollTop" back to zero. If there is more content than available in the
/// viewport "scrollTop" may take positive values.
/// Scrolling is controlled by sending the current DOM scroll position in a
/// [ui.SemanticsAction.scrollToOffset] to the framework where it applies the
/// value to its scrollable and the engine receives a [ui.SemanticsUpdate]
/// containing the new [SemanticsObject.scrollPosition] and child positions.
class SemanticScrollable extends SemanticRole {
SemanticScrollable(SemanticsObject semanticsObject)
: super.withBasics(
@@ -39,81 +30,61 @@ class SemanticScrollable extends SemanticRole {
/// Disables browser-driven scrolling in the presence of pointer events.
GestureModeCallback? _gestureModeListener;
/// DOM element used as a workaround for: https://github.com/flutter/flutter/issues/104036
///
/// When the assistive technology gets to the last element of the scrollable
/// list, the browser thinks the scrollable area doesn't have any more content,
/// so it overrides the value of "scrollTop"/"scrollLeft" with zero. As a result,
/// the user can't scroll back up/left.
///
/// As a workaround, we add this DOM element and set its size to
/// [canonicalNeutralScrollPosition] so the browser believes
/// that the scrollable area still has some more content, and doesn't override
/// scrollTop/scrollLetf with zero.
/// DOM element used to indicate to the browser the total quantity of available
/// content under this scrollable area. This element is sized based on the
/// total scroll extent calculated by scrollExtentMax - scrollExtentMin + rect.height
/// of the [SemanticsObject] managed by this scrollable.
final DomElement _scrollOverflowElement = createDomElement('flt-semantics-scroll-overflow');
/// Listens to HTML "scroll" gestures detected by the browser.
///
/// This gesture is converted to [ui.SemanticsAction.scrollUp] or
/// [ui.SemanticsAction.scrollDown], depending on the direction.
/// When the browser detects a "scroll" gesture we send the updated DOM scroll position
/// to the framework in a [ui.SemanticsAction.scrollToOffset].
@visibleForTesting
DomEventListener? scrollListener;
/// The value of the "scrollTop" or "scrollLeft" property of this object's
/// [element] that has zero offset relative to the [scrollPosition].
int _effectiveNeutralScrollPosition = 0;
/// Whether this scrollable can scroll vertically or horizontally.
bool get _canScroll =>
semanticsObject.isVerticalScrollContainer || semanticsObject.isHorizontalScrollContainer;
/// The previous value of the "scrollTop" or "scrollLeft" property of this object's
/// [element], used to determine if the content was scrolled.
int _previousDomScrollPosition = 0;
/// Responds to browser-detected "scroll" gestures.
void _recomputeScrollPosition() {
if (_domScrollPosition != _effectiveNeutralScrollPosition) {
if (_domScrollPosition != _previousDomScrollPosition) {
if (!EngineSemantics.instance.shouldAcceptBrowserGesture('scroll')) {
return;
}
final bool doScrollForward = _domScrollPosition > _effectiveNeutralScrollPosition;
_neutralizeDomScrollPosition();
_previousDomScrollPosition = _domScrollPosition;
_updateScrollableState();
semanticsObject.recomputePositionAndSize();
semanticsObject.updateChildrenPositionAndSize();
final int semanticsId = semanticsObject.id;
if (doScrollForward) {
if (semanticsObject.isVerticalScrollContainer) {
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(
viewId,
semanticsId,
ui.SemanticsAction.scrollUp,
null,
);
} else {
assert(semanticsObject.isHorizontalScrollContainer);
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(
viewId,
semanticsId,
ui.SemanticsAction.scrollLeft,
null,
);
}
final Float64List offsets = Float64List(2);
// Either SemanticsObject.isVerticalScrollContainer or
// SemanticsObject.isHorizontalScrollContainer should be
// true otherwise scrollToOffset cannot be called.
if (semanticsObject.isVerticalScrollContainer) {
offsets[0] = 0.0;
offsets[1] = element.scrollTop;
} else {
if (semanticsObject.isVerticalScrollContainer) {
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(
viewId,
semanticsId,
ui.SemanticsAction.scrollDown,
null,
);
} else {
assert(semanticsObject.isHorizontalScrollContainer);
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(
viewId,
semanticsId,
ui.SemanticsAction.scrollRight,
null,
);
}
assert(semanticsObject.isHorizontalScrollContainer);
offsets[0] = element.scrollLeft;
offsets[1] = 0.0;
}
final ByteData? message = const StandardMessageCodec().encodeMessage(offsets);
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(
viewId,
semanticsId,
ui.SemanticsAction.scrollToOffset,
message,
);
}
}
@@ -122,6 +93,22 @@ class SemanticScrollable extends SemanticRole {
// Scrolling is controlled by setting overflow-y/overflow-x to 'scroll`. The
// default overflow = "visible" needs to be unset.
semanticsObject.element.style.overflow = '';
// On macOS the scrollbar behavior which can be set in the settings application
// may sometimes insert scrollbars into an application when a peripheral like a
// mouse or keyboard is plugged in. This causes the clientHeight or clientWidth
// of the scrollable DOM element to be offset by the width of the scrollbar.
// This causes issues in the vertical scrolling context because the max scroll
// extent is calculated by the element's scrollHeight - clientHeight, so when
// the clientHeight is offset by scrollbar width the browser may there is
// a greater scroll extent then what is actually available.
//
// The scrollbar is already made transparent in SemanticsRole._initElement so here
// set scrollbar-width to "none" to prevent it from affecting the max scroll extent.
//
// Support for scrollbar-width was only added to Safari v18.2+, so versions before
// that may still experience overscroll issues when macOS inserts scrollbars
// into the application.
semanticsObject.element.style.scrollbarWidth = 'none';
_scrollOverflowElement.style
..position = 'absolute'
@@ -136,7 +123,15 @@ class SemanticScrollable extends SemanticRole {
super.update();
semanticsObject.owner.addOneTimePostUpdateCallback(() {
_neutralizeDomScrollPosition();
if (_canScroll) {
final double? scrollPosition = semanticsObject.scrollPosition;
assert(scrollPosition != null);
if (scrollPosition != _domScrollPosition) {
element.scrollTop = scrollPosition!;
_previousDomScrollPosition = _domScrollPosition;
}
}
_updateScrollableState();
semanticsObject.recomputePositionAndSize();
semanticsObject.updateChildrenPositionAndSize();
});
@@ -183,56 +178,38 @@ class SemanticScrollable extends SemanticRole {
}
}
/// Resets the scroll position (top or left) to the neutral value.
///
/// The scroll position of the scrollable HTML node that's considered to
/// have zero offset relative to Flutter's notion of scroll position is
/// referred to as "neutral scroll position".
///
/// We always set the scroll position to a non-zero value in order to
/// be able to scroll in the negative direction. When scrollTop/scrollLeft is
/// zero the browser will refuse to scroll back even when there is more
/// content available.
void _neutralizeDomScrollPosition() {
void _updateScrollableState() {
// This value is arbitrary.
const int canonicalNeutralScrollPosition = 10;
final ui.Rect? rect = semanticsObject.rect;
if (rect == null) {
printWarning('Warning! the rect attribute of semanticsObject is null');
return;
}
final double? scrollExtentMax = semanticsObject.scrollExtentMax;
final double? scrollExtentMin = semanticsObject.scrollExtentMin;
assert(scrollExtentMax != null);
assert(scrollExtentMin != null);
final double scrollExtentTotal =
scrollExtentMax! -
scrollExtentMin! +
(semanticsObject.isVerticalScrollContainer ? rect.height : rect.width);
// Place the _scrollOverflowElement at the beginning of the content
// and size it based on the total scroll extent so the browser
// knows how much scrollable content there is.
if (semanticsObject.isVerticalScrollContainer) {
// Place the _scrollOverflowElement at the end of the content and
// make sure that when we neutralize the scrolling position,
// it doesn't scroll into the visible area.
final int verticalOffset = rect.height.ceil() + canonicalNeutralScrollPosition;
_scrollOverflowElement.style
..transform = 'translate(0px,${verticalOffset}px)'
..width = '${rect.width.round()}px'
..height = '${canonicalNeutralScrollPosition}px';
element.scrollTop = canonicalNeutralScrollPosition.toDouble();
// Read back because the effective value depends on the amount of content.
_effectiveNeutralScrollPosition = element.scrollTop.toInt();
..width = '0px'
..height = '${scrollExtentTotal.toStringAsFixed(1)}px';
semanticsObject
..verticalScrollAdjustment = _effectiveNeutralScrollPosition.toDouble()
..verticalScrollAdjustment = element.scrollTop
..horizontalScrollAdjustment = 0.0;
} else if (semanticsObject.isHorizontalScrollContainer) {
// Place the _scrollOverflowElement at the end of the content and
// make sure that when we neutralize the scrolling position,
// it doesn't scroll into the visible area.
final int horizontalOffset = rect.width.ceil() + canonicalNeutralScrollPosition;
_scrollOverflowElement.style
..transform = 'translate(${horizontalOffset}px,0px)'
..width = '${canonicalNeutralScrollPosition}px'
..height = '${rect.height.round()}px';
element.scrollLeft = canonicalNeutralScrollPosition.toDouble();
// Read back because the effective value depends on the amount of content.
_effectiveNeutralScrollPosition = element.scrollLeft.toInt();
..width = '${scrollExtentTotal.toStringAsFixed(1)}px'
..height = '0px';
semanticsObject
..verticalScrollAdjustment = 0.0
..horizontalScrollAdjustment = _effectiveNeutralScrollPosition.toDouble();
..horizontalScrollAdjustment = element.scrollLeft;
} else {
_scrollOverflowElement.style
..transform = 'translate(0px,0px)'
@@ -240,7 +217,6 @@ class SemanticScrollable extends SemanticRole {
..height = '0px';
element.scrollLeft = 0.0;
element.scrollTop = 0.0;
_effectiveNeutralScrollPosition = 0;
semanticsObject
..verticalScrollAdjustment = 0.0
..horizontalScrollAdjustment = 0.0;

View File

@@ -1612,7 +1612,7 @@ void _testVerticalScrolling() {
</sem>''');
final DomElement scrollable = findScrollable(owner());
expect(scrollable.scrollTop, isPositive);
expect(scrollable.scrollTop, 0);
semantics().semanticsEnabled = false;
});
@@ -1649,8 +1649,8 @@ void _testVerticalScrolling() {
expect(scrollable, isNotNull);
// When there's less content than the available size the neutral scrollTop
// is still a positive number.
expect(scrollable.scrollTop, isPositive);
// is 0.
expect(scrollable.scrollTop, 0);
semantics().semanticsEnabled = false;
});
@@ -1703,18 +1703,7 @@ void _testVerticalScrolling() {
final DomElement scrollable = owner().debugSemanticsTree![0]!.element;
expect(scrollable, isNotNull);
// When there's more content than the available size the neutral scrollTop
// is greater than 0 with a maximum of 10 or 9.
int browserMaxScrollDiff = 0;
// The max scroll value varies between `9` and `10` for Safari desktop
// browsers.
if (ui_web.browser.browserEngine == ui_web.BrowserEngine.webkit &&
ui_web.browser.operatingSystem == ui_web.OperatingSystem.macOs) {
browserMaxScrollDiff = 1;
}
expect(scrollable.scrollTop >= (10 - browserMaxScrollDiff), isTrue);
expect(scrollable.scrollTop, 0);
Future<ui.SemanticsActionEvent> capturedEventFuture = captureSemanticsEvent();
scrollable.scrollTop = 20;
@@ -1722,21 +1711,44 @@ void _testVerticalScrolling() {
ui.SemanticsActionEvent capturedEvent = await capturedEventFuture;
expect(capturedEvent.nodeId, 0);
expect(capturedEvent.type, ui.SemanticsAction.scrollUp);
expect(capturedEvent.arguments, isNull);
// Engine semantics returns scroll top back to neutral.
expect(scrollable.scrollTop >= (10 - browserMaxScrollDiff), isTrue);
expect(capturedEvent.type, ui.SemanticsAction.scrollToOffset);
expect(capturedEvent.arguments, isNotNull);
final Float64List expectedOffset = Float64List(2);
expectedOffset[0] = 0.0;
expectedOffset[1] = 20.0;
Float64List message =
const StandardMessageCodec().decodeMessage(capturedEvent.arguments! as ByteData)
as Float64List;
expect(message, expectedOffset);
// Update scrollPosition to scrollTop value.
final ui.SemanticsUpdateBuilder builder2 = ui.SemanticsUpdateBuilder();
updateNode(
builder2,
scrollPosition: 20.0,
flags: 0 | ui.SemanticsFlag.hasImplicitScrolling.index,
actions: 0 | ui.SemanticsAction.scrollUp.index | ui.SemanticsAction.scrollDown.index,
transform: Matrix4.identity().toFloat64(),
rect: const ui.Rect.fromLTRB(0, 0, 50, 100),
childrenInHitTestOrder: Int32List.fromList(<int>[1, 2, 3]),
childrenInTraversalOrder: Int32List.fromList(<int>[1, 2, 3]),
);
owner().updateSemantics(builder2.build());
capturedEventFuture = captureSemanticsEvent();
scrollable.scrollTop = 5;
capturedEvent = await capturedEventFuture;
expect(scrollable.scrollTop >= (5 - browserMaxScrollDiff), isTrue);
expect(scrollable.scrollTop, 5);
expect(capturedEvent.nodeId, 0);
expect(capturedEvent.type, ui.SemanticsAction.scrollDown);
expect(capturedEvent.arguments, isNull);
// Engine semantics returns scroll top back to neutral.
expect(scrollable.scrollTop >= (10 - browserMaxScrollDiff), isTrue);
expect(capturedEvent.type, ui.SemanticsAction.scrollToOffset);
expect(capturedEvent.arguments, isNotNull);
expectedOffset[0] = 0.0;
expectedOffset[1] = 5.0;
message =
const StandardMessageCodec().decodeMessage(capturedEvent.arguments! as ByteData)
as Float64List;
expect(message, expectedOffset);
});
test('scrollable switches to pointer event mode on a wheel event', () async {
@@ -1783,27 +1795,22 @@ void _testVerticalScrolling() {
final DomElement scrollable = owner().debugSemanticsTree![0]!.element;
expect(scrollable, isNotNull);
void expectNeutralPosition() {
// Browsers disagree on the exact value, but it's always close to 10.
expect((scrollable.scrollTop - 10).abs(), lessThan(2));
}
// Initially, starting with a neutral scroll position, everything should be
// Initially, starting at "scrollTop" 0, everything should be
// in browser gesture mode, react to DOM scroll events, and generate
// semantic actions.
expectNeutralPosition();
expect(scrollable.scrollTop, 0);
expect(semantics().gestureMode, GestureMode.browserGestures);
scrollable.scrollTop = 20;
expect(scrollable.scrollTop, 20);
await Future<void>.delayed(const Duration(milliseconds: 100));
expect(actionLog, hasLength(1));
final capturedEvent = actionLog.removeLast();
expect(capturedEvent.type, ui.SemanticsAction.scrollUp);
expect(capturedEvent.type, ui.SemanticsAction.scrollToOffset);
// Now, starting with a neutral mode, observing a DOM "wheel" event should
// Now, starting at the "scrollTop" 20 we set, observing a DOM "wheel" event should
// swap into pointer event mode, and the scrollable becomes a plain clip,
// i.e. `overflow: hidden`.
expectNeutralPosition();
expect(scrollable.scrollTop, 20);
expect(semantics().gestureMode, GestureMode.browserGestures);
expect(scrollable.style.overflowY, 'scroll');
@@ -1870,8 +1877,8 @@ void _testHorizontalScrolling() {
expect(scrollable, isNotNull);
// When there's less content than the available size the neutral
// scrollLeft is still a positive number.
expect(scrollable.scrollLeft, isPositive);
// scrollLeft is still 0.
expect(scrollable.scrollLeft, 0);
semantics().semanticsEnabled = false;
});
@@ -1924,17 +1931,7 @@ void _testHorizontalScrolling() {
final DomElement scrollable = findScrollable(owner());
expect(scrollable, isNotNull);
// When there's more content than the available size the neutral scrollTop
// is greater than 0 with a maximum of 10.
int browserMaxScrollDiff = 0;
// The max scroll value varies between `9` and `10` for Safari desktop
// browsers.
if (ui_web.browser.browserEngine == ui_web.BrowserEngine.webkit &&
ui_web.browser.operatingSystem == ui_web.OperatingSystem.macOs) {
browserMaxScrollDiff = 1;
}
expect(scrollable.scrollLeft >= (10 - browserMaxScrollDiff), isTrue);
expect(scrollable.scrollLeft, 0);
Future<ui.SemanticsActionEvent> capturedEventFuture = captureSemanticsEvent();
scrollable.scrollLeft = 20;
@@ -1942,21 +1939,44 @@ void _testHorizontalScrolling() {
ui.SemanticsActionEvent capturedEvent = await capturedEventFuture;
expect(capturedEvent.nodeId, 0);
expect(capturedEvent.type, ui.SemanticsAction.scrollLeft);
expect(capturedEvent.arguments, isNull);
// Engine semantics returns scroll position back to neutral.
expect(scrollable.scrollLeft >= (10 - browserMaxScrollDiff), isTrue);
expect(capturedEvent.type, ui.SemanticsAction.scrollToOffset);
expect(capturedEvent.arguments, isNotNull);
final Float64List expectedOffset = Float64List(2);
expectedOffset[0] = 20.0;
expectedOffset[1] = 0.0;
Float64List message =
const StandardMessageCodec().decodeMessage(capturedEvent.arguments! as ByteData)
as Float64List;
expect(message, expectedOffset);
// Update scrollPosition to scrollLeft value.
final ui.SemanticsUpdateBuilder builder2 = ui.SemanticsUpdateBuilder();
updateNode(
builder2,
scrollPosition: 20.0,
flags: 0 | ui.SemanticsFlag.hasImplicitScrolling.index,
actions: 0 | ui.SemanticsAction.scrollLeft.index | ui.SemanticsAction.scrollRight.index,
transform: Matrix4.identity().toFloat64(),
rect: const ui.Rect.fromLTRB(0, 0, 50, 100),
childrenInHitTestOrder: Int32List.fromList(<int>[1, 2, 3]),
childrenInTraversalOrder: Int32List.fromList(<int>[1, 2, 3]),
);
owner().updateSemantics(builder2.build());
capturedEventFuture = captureSemanticsEvent();
scrollable.scrollLeft = 5;
capturedEvent = await capturedEventFuture;
expect(scrollable.scrollLeft >= (5 - browserMaxScrollDiff), isTrue);
expect(scrollable.scrollLeft, 5);
expect(capturedEvent.nodeId, 0);
expect(capturedEvent.type, ui.SemanticsAction.scrollRight);
expect(capturedEvent.arguments, isNull);
// Engine semantics returns scroll top back to neutral.
expect(scrollable.scrollLeft >= (10 - browserMaxScrollDiff), isTrue);
expect(capturedEvent.type, ui.SemanticsAction.scrollToOffset);
expect(capturedEvent.arguments, isNotNull);
expectedOffset[0] = 5.0;
expectedOffset[1] = 0.0;
message =
const StandardMessageCodec().decodeMessage(capturedEvent.arguments! as ByteData)
as Float64List;
expect(message, expectedOffset);
});
}

View File

@@ -166,8 +166,6 @@ dependency_overrides:
path: ./third_party/pkg/googleapis/discoveryapis_commons
_fe_analyzer_shared:
path: ./third_party/dart/pkg/_fe_analyzer_shared
_macros:
path: ./third_party/dart/pkg/_macros
analyzer:
path: ./third_party/dart/pkg/analyzer
archive:
@@ -222,8 +220,6 @@ dependency_overrides:
path: ./third_party/dart/pkg/kernel
logging:
path: ./third_party/dart/third_party/pkg/core/pkgs/logging
macros:
path: ./third_party/dart/pkg/macros
matcher:
path: ./third_party/dart/third_party/pkg/test/pkgs/matcher
meta:

View File

@@ -18,8 +18,6 @@ dev_dependencies:
dependency_overrides: # Must include all transitive dependencies from the "any" packages above.
_fe_analyzer_shared:
path: ../third_party/dart/pkg/_fe_analyzer_shared
_macros:
path: ../third_party/dart/pkg/_macros
analyzer:
path: ../third_party/dart/pkg/analyzer
args:
@@ -38,8 +36,6 @@ dependency_overrides: # Must include all transitive dependencies from the "any"
path: ../third_party/dart/third_party/pkg/tools/pkgs/file
glob:
path: ../third_party/dart/third_party/pkg/tools/pkgs/glob
macros:
path: ../third_party/dart/pkg/macros
meta:
path: ../third_party/dart/pkg/meta
package_config: