diff --git a/.all-contributorsrc b/.all-contributorsrc index e9a9146..a935068 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -73,6 +73,16 @@ "code", "doc" ] + }, + { + "login": "YangXiaomei", + "name": "Margaret", + "avatar_url": "https://avatars0.githubusercontent.com/u/8221990?v=4", + "profile": "https://github.com/YangXiaomei", + "contributions": [ + "code", + "doc" + ] } ], "contributorsPerLine": 7 diff --git a/README.md b/README.md index 01a055d..d5142a0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # React Native WebView - a Modern, Cross-Platform WebView for React Native -[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors) +[![star this repo](http://githubbadges.com/star.svg?user=react-native-community&repo=react-native-webview&style=flat)](https://github.com/react-native-community/react-native-webview) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors) [![Known Vulnerabilities](https://snyk.io/test/github/react-native-community/react-native-webview/badge.svg?style=flat-square)](https://snyk.io/test/github/react-native-community/react-native-webview) **React Native WebView** is a modern, well-supported, and cross-platform WebView for React Native. It is intended to be a replacement for the built-in WebView (which will be [removed from core](https://github.com/react-native-community/discussions-and-proposals/pull/3)). @@ -84,8 +84,8 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/all-contri -| [Thibault Malbranche
Thibault Malbranche](https://twitter.com/titozzz)
[💻](https://github.com/react-native-community/react-native-webview/commits?author=titozzz "Code") [🤔](#ideas-titozzz "Ideas, Planning, & Feedback") [👀](#review-titozzz "Reviewed Pull Requests") [📖](https://github.com/react-native-community/react-native-webview/commits?author=titozzz "Documentation") [🚧](#maintenance-titozzz "Maintenance") [⚠️](https://github.com/react-native-community/react-native-webview/commits?author=titozzz "Tests") [🚇](#infra-titozzz "Infrastructure (Hosting, Build-Tools, etc)") [💬](#question-titozzz "Answering Questions") | [Jamon Holmgren
Jamon Holmgren](https://jamonholmgren.com)
[💻](https://github.com/react-native-community/react-native-webview/commits?author=jamonholmgren "Code") [🤔](#ideas-jamonholmgren "Ideas, Planning, & Feedback") [👀](#review-jamonholmgren "Reviewed Pull Requests") [📖](https://github.com/react-native-community/react-native-webview/commits?author=jamonholmgren "Documentation") [🚧](#maintenance-jamonholmgren "Maintenance") [⚠️](https://github.com/react-native-community/react-native-webview/commits?author=jamonholmgren "Tests") [💡](#example-jamonholmgren "Examples") [💬](#question-jamonholmgren "Answering Questions") | [Andrei Pfeiffer
Andrei Pfeiffer](https://github.com/andreipfeiffer)
[💻](https://github.com/react-native-community/react-native-webview/commits?author=andreipfeiffer "Code") [👀](#review-andreipfeiffer "Reviewed Pull Requests") [🤔](#ideas-andreipfeiffer "Ideas, Planning, & Feedback") | [Michael Diarmid
Michael Diarmid](https://twitter.com/mikediarmid)
[💻](https://github.com/react-native-community/react-native-webview/commits?author=Salakar "Code") [👀](#review-Salakar "Reviewed Pull Requests") [🤔](#ideas-Salakar "Ideas, Planning, & Feedback") [🔧](#tool-Salakar "Tools") | [Scott Mathson
Scott Mathson](http://smathson.github.io)
[💻](https://github.com/react-native-community/react-native-webview/commits?author=smathson "Code") [📖](https://github.com/react-native-community/react-native-webview/commits?author=smathson "Documentation") | -| :---: | :---: | :---: | :---: | :---: | +| [Thibault Malbranche
Thibault Malbranche](https://twitter.com/titozzz)
[💻](https://github.com/react-native-community/react-native-webview/commits?author=titozzz "Code") [🤔](#ideas-titozzz "Ideas, Planning, & Feedback") [👀](#review-titozzz "Reviewed Pull Requests") [📖](https://github.com/react-native-community/react-native-webview/commits?author=titozzz "Documentation") [🚧](#maintenance-titozzz "Maintenance") [⚠️](https://github.com/react-native-community/react-native-webview/commits?author=titozzz "Tests") [🚇](#infra-titozzz "Infrastructure (Hosting, Build-Tools, etc)") [💬](#question-titozzz "Answering Questions") | [Jamon Holmgren
Jamon Holmgren](https://jamonholmgren.com)
[💻](https://github.com/react-native-community/react-native-webview/commits?author=jamonholmgren "Code") [🤔](#ideas-jamonholmgren "Ideas, Planning, & Feedback") [👀](#review-jamonholmgren "Reviewed Pull Requests") [📖](https://github.com/react-native-community/react-native-webview/commits?author=jamonholmgren "Documentation") [🚧](#maintenance-jamonholmgren "Maintenance") [⚠️](https://github.com/react-native-community/react-native-webview/commits?author=jamonholmgren "Tests") [💡](#example-jamonholmgren "Examples") [💬](#question-jamonholmgren "Answering Questions") | [Andrei Pfeiffer
Andrei Pfeiffer](https://github.com/andreipfeiffer)
[💻](https://github.com/react-native-community/react-native-webview/commits?author=andreipfeiffer "Code") [👀](#review-andreipfeiffer "Reviewed Pull Requests") [🤔](#ideas-andreipfeiffer "Ideas, Planning, & Feedback") | [Michael Diarmid
Michael Diarmid](https://twitter.com/mikediarmid)
[💻](https://github.com/react-native-community/react-native-webview/commits?author=Salakar "Code") [👀](#review-Salakar "Reviewed Pull Requests") [🤔](#ideas-Salakar "Ideas, Planning, & Feedback") [🔧](#tool-Salakar "Tools") | [Scott Mathson
Scott Mathson](http://smathson.github.io)
[💻](https://github.com/react-native-community/react-native-webview/commits?author=smathson "Code") [📖](https://github.com/react-native-community/react-native-webview/commits?author=smathson "Documentation") | [Margaret
Margaret](https://github.com/YangXiaomei)
[💻](https://github.com/react-native-community/react-native-webview/commits?author=YangXiaomei "Code") [📖](https://github.com/react-native-community/react-native-webview/commits?author=YangXiaomei "Documentation") | +| :---: | :---: | :---: | :---: | :---: | :---: | This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! diff --git a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java index c1c3163..663416c 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java +++ b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java @@ -529,6 +529,13 @@ public class RNCWebViewManager extends SimpleViewManager { view.getSettings().setJavaScriptEnabled(enabled); } + @ReactProp(name = "androidHardwareAccelerationDisabled") + public void setHardwareAccelerationDisabled(WebView view, boolean disabled) { + if (disabled) { + view.setLayerType(View.LAYER_TYPE_SOFTWARE, null); + } + } + @ReactProp(name = "overScrollMode") public void setOverScrollMode(WebView view, String overScrollModeString) { Integer overScrollMode; diff --git a/docs/Reference.md b/docs/Reference.md index f1f1bc2..c829232 100644 --- a/docs/Reference.md +++ b/docs/Reference.md @@ -28,6 +28,7 @@ This document lays out the current public properties and methods for the React N - [`decelerationRate`](Reference.md#decelerationrate) - [`domStorageEnabled`](Reference.md#domstorageenabled) - [`javaScriptEnabled`](Reference.md#javascriptenabled) +- [`androidHardwareAccelerationDisabled`](Reference.md#androidHardwareAccelerationDisabled) - [`mixedContentMode`](Reference.md#mixedcontentmode) - [`thirdPartyCookiesEnabled`](Reference.md#thirdpartycookiesenabled) - [`userAgent`](Reference.md#useragent) @@ -319,6 +320,16 @@ Boolean value to enable JavaScript in the `WebView`. Used on Android only as Jav --- +### `androidHardwareAccelerationDisabled` + +Boolean value to disable Hardware Acceleration in the `WebView`. Used on Android only as Hardware Acceleration is a feature only for Android. The default value is `false`. + +| Type | Required | Platform | +| ---- | -------- | -------- | +| bool | No | Android | + +--- + ### `mixedContentMode` Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin. diff --git a/js/WebView.android.js b/js/WebView.android.js index 3e6aefd..cd30afa 100644 --- a/js/WebView.android.js +++ b/js/WebView.android.js @@ -67,6 +67,7 @@ class WebView extends React.Component { scalesPageToFit: true, allowFileAccess: false, saveFormDataDisabled: false, + androidHardwareAccelerationDisabled: false, originWhitelist: defaultOriginWhitelist, }; @@ -150,6 +151,7 @@ class WebView extends React.Component { injectedJavaScript={this.props.injectedJavaScript} userAgent={this.props.userAgent} javaScriptEnabled={this.props.javaScriptEnabled} + androidHardwareAccelerationDisabled={this.props.androidHardwareAccelerationDisabled} thirdPartyCookiesEnabled={this.props.thirdPartyCookiesEnabled} domStorageEnabled={this.props.domStorageEnabled} messagingEnabled={typeof this.props.onMessage === 'function'} diff --git a/js/WebViewTypes.js b/js/WebViewTypes.js index 46ca05e..eb672d0 100644 --- a/js/WebViewTypes.js +++ b/js/WebViewTypes.js @@ -313,6 +313,13 @@ export type AndroidWebViewProps = $ReadOnly<{| */ javaScriptEnabled?: ?boolean, + /** + * Boolean value to disable Hardware Acceleration in the `WebView`. Used on Android only + * as Hardware Acceleration is a feature only for Android. The default value is `false`. + * @platform android + */ + androidHardwareAccelerationDisabled?: ?boolean, + /** * Boolean value to enable third party cookies in the `WebView`. Used on * Android Lollipop and above only as third party cookies are enabled by diff --git a/package.json b/package.json index 6e43c0b..99f06e1 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "Thibault Malbranche " ], "license": "MIT", - "version": "3.1.3", + "version": "3.2.0", "homepage": "https://github.com/react-native-community/react-native-webview#readme", "scripts": { "test:ios:flow": "flow check", diff --git a/typings/index.d.ts b/typings/index.d.ts index 4fa7640..39ea30a 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -287,6 +287,13 @@ export interface AndroidWebViewProps { */ javaScriptEnabled?: boolean; + /** + * Boolean value to disable Hardware Acceleration in the `WebView`. Used on Android only + * as Hardware Acceleration is a feature only for Android. The default value is `false`. + * @platform android + */ + androidHardwareAccelerationDisabled?: boolean; + /** * Boolean value to enable third party cookies in the `WebView`. Used on * Android Lollipop and above only as third party cookies are enabled by