mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This stops the context menu from showing up when you right click on an image that is backed by an <img> element. Fixes internal issue ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
149 lines
4.9 KiB
Dart
149 lines
4.9 KiB
Dart
// Copyright 2014 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.
|
|
|
|
// This code is copied from `package:web` which still needs its own
|
|
// documentation for public members. Since this is a shim that users should not
|
|
// use, we ignore this lint for this file.
|
|
// ignore_for_file: public_member_api_docs
|
|
|
|
/// A stripped down version of `package:web` to avoid pinning that repo in
|
|
/// Flutter as a dependency.
|
|
///
|
|
/// These are manually copied over from `package:web` as needed, and should stay
|
|
/// in sync with the latest package version as much as possible.
|
|
///
|
|
/// If missing members are needed, copy them over into the corresponding
|
|
/// extension or interface. If missing interfaces/types are needed, copy them
|
|
/// over while excluding unnecessary inheritance to make the copy minimal. These
|
|
/// types are erased at runtime, so excluding supertypes is safe. If a member is
|
|
/// needed that belongs to a supertype, then add the necessary `implements`
|
|
/// clause to the subtype when you add that supertype. Keep extensions next to
|
|
/// the interface they extend.
|
|
library;
|
|
|
|
import 'dart:js_interop';
|
|
|
|
typedef EventListener = JSFunction;
|
|
typedef XMLHttpRequestResponseType = String;
|
|
|
|
@JS()
|
|
external Document get document;
|
|
|
|
@JS()
|
|
external Window get window;
|
|
|
|
extension type CSSStyleDeclaration._(JSObject _) implements JSObject {
|
|
external set backgroundColor(String value);
|
|
external String get backgroundColor;
|
|
external set border(String value);
|
|
external String get border;
|
|
external set height(String value);
|
|
external String get height;
|
|
external set width(String value);
|
|
external String get width;
|
|
external set pointerEvents(String value);
|
|
external String get pointerEvents;
|
|
}
|
|
|
|
extension type CSSStyleSheet._(JSObject _) implements JSObject {
|
|
external int insertRule(String rule, [int index]);
|
|
}
|
|
|
|
extension type Document._(JSObject _) implements JSObject {
|
|
external Element createElement(String localName, [JSAny options]);
|
|
external Range createRange();
|
|
external HTMLHeadElement? get head;
|
|
}
|
|
|
|
extension type DOMTokenList._(JSObject _) implements JSObject {
|
|
external void add(String tokens);
|
|
}
|
|
|
|
extension type Element._(JSObject _) implements Node, JSObject {
|
|
external DOMTokenList get classList;
|
|
external void append(JSAny nodes);
|
|
external void remove();
|
|
}
|
|
|
|
extension type Event._(JSObject _) implements JSObject {}
|
|
|
|
extension type EventTarget._(JSObject _) implements JSObject {
|
|
external void addEventListener(String type, EventListener? callback, [JSAny options]);
|
|
}
|
|
|
|
extension type HTMLElement._(JSObject _) implements Element, JSObject {
|
|
external String get innerText;
|
|
external set innerText(String value);
|
|
external CSSStyleDeclaration get style;
|
|
external HTMLElement cloneNode(bool deep);
|
|
}
|
|
|
|
extension type HTMLHeadElement._(JSObject _) implements HTMLElement, JSObject {}
|
|
|
|
extension type HTMLStyleElement._(JSObject _) implements HTMLElement, JSObject {
|
|
external CSSStyleSheet? get sheet;
|
|
}
|
|
|
|
extension type HTMLImageElement._(JSObject _) implements HTMLElement, JSObject {
|
|
external String get src;
|
|
external set src(String value);
|
|
external num get naturalWidth;
|
|
external num get naturalHeight;
|
|
external JSPromise<JSAny?> decode();
|
|
}
|
|
|
|
extension type HTMLCanvasElement._(JSObject _) implements HTMLElement, JSObject {
|
|
external int get width;
|
|
external set width(int value);
|
|
external int get height;
|
|
external set height(int value);
|
|
external String toDataURL();
|
|
}
|
|
|
|
extension type MediaQueryList._(JSObject _) implements EventTarget, JSObject {
|
|
external bool get matches;
|
|
}
|
|
|
|
extension type MouseEvent._(JSObject _) implements JSObject {
|
|
external num get offsetX;
|
|
external num get offsetY;
|
|
external int get button;
|
|
external void preventDefault();
|
|
}
|
|
|
|
extension type Navigator._(JSObject _) implements JSObject {
|
|
external String get platform;
|
|
}
|
|
|
|
extension type Node._(JSObject _) implements EventTarget, JSObject {}
|
|
|
|
extension type Range._(JSObject _) implements JSObject {
|
|
external void selectNode(Node node);
|
|
}
|
|
|
|
extension type Selection._(JSObject _) implements JSObject {
|
|
external void addRange(Range range);
|
|
external void removeAllRanges();
|
|
}
|
|
|
|
extension type Window._(JSObject _) implements EventTarget, JSObject {
|
|
external Navigator get navigator;
|
|
external MediaQueryList matchMedia(String query);
|
|
external Selection? getSelection();
|
|
external String get origin;
|
|
}
|
|
|
|
extension type XMLHttpRequest._(JSObject _) implements XMLHttpRequestEventTarget, JSObject {
|
|
external factory XMLHttpRequest();
|
|
external void open(String method, String url, [bool async, String? username, String? password]);
|
|
external void setRequestHeader(String name, String value);
|
|
external void send([JSAny? body]);
|
|
external int get status;
|
|
external set responseType(XMLHttpRequestResponseType value);
|
|
external XMLHttpRequestResponseType get responseType;
|
|
external JSAny? get response;
|
|
}
|
|
|
|
extension type XMLHttpRequestEventTarget._(JSObject _) implements EventTarget, JSObject {}
|