Skip to content

Commit

Permalink
fix: list view item missing when touch context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
edmond-l-20230331 committed Nov 12, 2024
1 parent 18c94b7 commit 28f2a68
Show file tree
Hide file tree
Showing 14 changed files with 249 additions and 34 deletions.
1 change: 1 addition & 0 deletions bridge/third_party/quickjs/compat/win32/pthread-win32
Submodule pthread-win32 added at 3309f4
2 changes: 1 addition & 1 deletion bridge/third_party/quickjs/vendor/mimalloc
Submodule mimalloc updated 166 files
21 changes: 12 additions & 9 deletions webf/example/assets/bundle.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@
</style>
</head>
<body>
<div class="container">
<!-- <div class="container">
<img class="logo" src="./webf.png" />
</div>
<div class="icons">
<svg class="icon" viewBox="0 0 1024 1024"><path d="M64 512c0 195.2 124.8 361.6 300.8 422.4 22.4 6.4 19.2-9.6 19.2-22.4v-76.8c-134.4 16-140.8-73.6-150.4-89.6-19.2-32-60.8-38.4-48-54.4 32-16 64 3.2 99.2 57.6 25.6 38.4 76.8 32 105.6 25.6 6.4-22.4 19.2-44.8 35.2-60.8-144-22.4-201.6-108.8-201.6-211.2 0-48 16-96 48-131.2-22.4-60.8 0-115.2 3.2-121.6 57.6-6.4 118.4 41.6 124.8 44.8 32-9.6 70.4-12.8 112-12.8 41.6 0 80 6.4 112 12.8 12.8-9.6 67.2-48 121.6-44.8 3.2 6.4 25.6 57.6 6.4 118.4 32 38.4 48 83.2 48 131.2 0 102.4-57.6 188.8-201.6 214.4 22.4 22.4 38.4 54.4 38.4 92.8v112c0 9.6 0 19.2 16 19.2C832 876.8 960 710.4 960 512c0-246.4-201.6-448-448-448S64 265.6 64 512z" fill="#040000" p-id="3824"></path></svg>
<svg class="icon" viewBox="0 0 1024 1024"><path d="M63.5 63.5h897v897h-897v-897zM887 746.6c-6.5-40.9-33.2-75.3-112.2-107.4-27.5-12.9-58.1-21.9-67.2-42.6-3.4-12.3-3.9-19.1-1.7-26.4 5.6-24.1 34.2-31.4 56.6-24.7 14.6 4.5 28 15.7 36.5 33.6 38.6-25.3 38.6-25.3 65.6-42-10.1-15.7-15.1-22.5-21.9-29.2-23.5-26.3-54.9-39.8-105.9-38.6l-26.4 3.3c-25.3 6.2-49.3 19.6-63.9 37.6-42.6 48.3-30.3 132.3 21.3 167.1 51 38.1 125.6 46.5 135.2 82.4 9 43.7-32.5 57.7-73.5 52.7-30.3-6.7-47.1-21.9-65.6-49.9l-68.4 39.3c7.8 17.9 16.8 25.8 30.3 41.4 65 65.6 227.6 62.3 256.8-37.5 1.1-3.4 9-26.4 2.8-61.7l1.6 2.6zM551.3 475.8h-84c0 72.4-0.3 144.4-0.3 217 0 46 2.4 88.3-5.2 101.3-12.3 25.8-44.1 22.5-58.5 17.9-14.8-7.3-22.3-17.4-31-32-2.4-3.9-4.1-7.3-4.7-7.3l-68.2 42c11.4 23.5 28 43.8 49.5 56.7 32 19.1 74.9 25.2 119.9 15.1 29.3-8.4 54.5-25.8 67.7-52.7 19.1-34.8 15-77.4 14.8-125.1 0.4-76.8 0-153.6 0-230.9v-2z" fill="#F5DD1E" p-id="4254"></path></svg>
<svg class="icon" viewBox="0 0 1024 1024"><path d="M89.088 59.392l62.464 803.84c1.024 12.288 9.216 22.528 20.48 25.6L502.784 993.28c6.144 2.048 12.288 2.048 18.432 0l330.752-104.448c11.264-4.096 19.456-14.336 20.48-25.6l62.464-803.84c1.024-17.408-12.288-31.744-29.696-31.744H118.784c-17.408 0-31.744 14.336-29.696 31.744z" fill="#FC490B" p-id="5421"></path><path d="M774.144 309.248h-409.6l12.288 113.664h388.096l-25.6 325.632-227.328 71.68-227.328-71.68-13.312-169.984h118.784v82.944l124.928 33.792 123.904-33.792 10.24-132.096H267.264L241.664 204.8h540.672z" fill="#FFFFFF" p-id="5422"></path></svg>
</div>
<script>
</div> -->
123123123123123
<listview class="icons">
<div>11111</div>
<div>11111</div>
<div>11111</div>
<div>11111</div>
<div>11111</div>
</listview>
<!-- <script>
console.log('Welcome to webf!');
</script>
<script src="./bundle.js"></script>
<script src="./bundle.js"></script> -->
</body>
</html>
6 changes: 3 additions & 3 deletions webf/example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -429,7 +429,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -478,7 +478,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
187 changes: 187 additions & 0 deletions webf/example/rust_builder/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webf/ios/Frameworks/quickjs.xcframework
2 changes: 1 addition & 1 deletion webf/ios/Frameworks/webf_bridge.xcframework
6 changes: 3 additions & 3 deletions webf/lib/src/css/position.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ mixin CSSPositionMixin on RenderStyle {

void _markNeedsSort() {
if (renderBoxModel?.parentData is RenderLayoutParentData) {
AbstractNode? parent = renderBoxModel!.parent;
RenderObject? parent = renderBoxModel!.parent;
if (parent is RenderLayoutBox) {
parent.markChildrenNeedsSort();
}
Expand All @@ -122,7 +122,7 @@ mixin CSSPositionMixin on RenderStyle {
if (renderBoxModel?.parentData is RenderLayoutParentData) {
RenderStyle renderStyle = renderBoxModel!.renderStyle;
if (force || renderStyle.position != DEFAULT_POSITION_TYPE) {
AbstractNode? parent = renderBoxModel!.parent;
RenderObject? parent = renderBoxModel!.parent;
if (parent is RenderObject) {
parent.markNeedsLayout();
}
Expand All @@ -141,7 +141,7 @@ mixin CSSPositionMixin on RenderStyle {
if (renderStyle.position != DEFAULT_POSITION_TYPE ||
parentRenderStyle?.effectiveDisplay == CSSDisplay.flex ||
parentRenderStyle?.effectiveDisplay == CSSDisplay.inlineFlex) {
AbstractNode? parent = renderBoxModel!.parent;
RenderObject? parent = renderBoxModel!.parent;
if (parent is RenderObject) {
parent.markNeedsPaint();
}
Expand Down
2 changes: 1 addition & 1 deletion webf/lib/src/css/positioned.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'package:webf/rendering.dart';
// We need to reset these offset to keep positioned elements render at their original position.
// @NOTE: Attention that renderObjects in tree may not all subtype of RenderBoxModel, use `is` to identify.
Offset? _getRenderPositionHolderScrollOffset(RenderPositionPlaceholder holder, RenderObject root) {
AbstractNode? current = holder.parent;
RenderObject? current = holder.parent;
while (current != null && current != root) {
if (current is RenderBoxModel) {
if (current.clipX || current.clipY) {
Expand Down
2 changes: 1 addition & 1 deletion webf/lib/src/css/values/length.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class CSSLengthValue {
RenderBoxModel? renderBoxModel = renderStyle!.renderBoxModel;
// Should access the renderStyle of renderBoxModel parent but not renderStyle parent
// cause the element of renderStyle parent may not equal to containing block.
AbstractNode? containerRenderBox = renderBoxModel?.parent;
RenderObject? containerRenderBox = renderBoxModel?.parent;
CSSRenderStyle? parentRenderStyle;
while (containerRenderBox != null) {
if (containerRenderBox is RenderBoxModel && (_isPercentageRelativeContainer(containerRenderBox))) {
Expand Down
27 changes: 25 additions & 2 deletions webf/lib/src/html/listview.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:webf/webf.dart';

Expand Down Expand Up @@ -25,8 +26,30 @@ class FlutterListViewElement extends WidgetElement {

@override
Widget build(BuildContext context, List<Widget> children) {
return ListView(
children: children,
return ListView.builder(
itemBuilder: (BuildContext context, int index) {
return CupertinoContextMenu.builder(
actions: [
CupertinoContextMenuAction(
child: Text('Action 1'),
onPressed: () {
Navigator.pop(context);
print('1111');
},
),
CupertinoContextMenuAction(
child: Text('Action 2'),
onPressed: () {
Navigator.pop(context);
print('2222');
},
),
],
builder: (BuildContext context, Animation<double> animation) {
return children[index];
}
);
},
padding: const EdgeInsets.all(0),
controller: controller,
physics: const AlwaysScrollableScrollPhysics(),
Expand Down
8 changes: 4 additions & 4 deletions webf/lib/src/rendering/box_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ class RenderBoxModel extends RenderBox
// child has percentage length and parent's size can not be calculated by style
// thus parent needs relayout for its child calculate percentage length.
void markParentNeedsRelayout() {
AbstractNode? parent = this.parent;
RenderObject? parent = this.parent;
if (parent is RenderBoxModel) {
parent.needsRelayout = true;
}
Expand Down Expand Up @@ -865,7 +865,7 @@ class RenderBoxModel extends RenderBox
/// Mark children needs layout when drop child as Flutter did
///
@override
void dropChild(RenderBox child) {
void dropChild(RenderObject child) {
super.dropChild(child);
// Loop to mark all the children to needsLayout as flutter did
_syncChildNeedsLayoutFlag(child);
Expand Down Expand Up @@ -1098,7 +1098,7 @@ class RenderBoxModel extends RenderBox
/// Find scroll container
RenderBoxModel? findScrollContainer() {
RenderBoxModel? scrollContainer;
AbstractNode? parent = this.parent;
RenderObject? parent = this.parent;

while (parent != null && parent is RenderLayoutBox) {
if (parent.isScrollingContentBox && parent.parent is RenderLayoutBox) {
Expand Down Expand Up @@ -1453,7 +1453,7 @@ class RenderBoxModel extends RenderBox
Offset getTotalScrollOffset() {
double top = scrollTop;
double left = scrollLeft;
AbstractNode? parentNode = parent;
RenderObject? parentNode = parent;
while (parentNode is RenderBoxModel) {
top += parentNode.scrollTop;
left += parentNode.scrollLeft;
Expand Down
2 changes: 1 addition & 1 deletion webf/lib/src/rendering/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mixin RenderEventListenerMixin on RenderBox {
HandleGetEventTarget? getEventTarget;

GestureDispatcher? get gestureDispatcher {
AbstractNode? p = parent;
RenderObject? p = parent;
while(p != null) {
if (p is RenderViewportBox) {
return p.gestureDispatcher;
Expand Down
Loading

0 comments on commit 28f2a68

Please sign in to comment.