From 05f20862d69509fb9158cf85068a2129dcb44f51 Mon Sep 17 00:00:00 2001 From: Thibault Malbranche Date: Mon, 21 Jan 2019 17:09:44 +0100 Subject: [PATCH 1/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 01a055d..5710a38 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-5-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)). From d3fc5e6cde979e865a776977331efa349c2a067f Mon Sep 17 00:00:00 2001 From: Margaret Date: Tue, 22 Jan 2019 17:21:10 +0800 Subject: [PATCH 2/4] feat(android props): Add `androidHardwareAccelerationDisabled` prop (#265) * add test code for disable hardware acceleration * add interface to disable android hardware acceleration * Update index.d.ts --- .../webview/RNCWebViewManager.java | 7 +++++++ docs/Reference.md | 11 +++++++++++ js/WebView.android.js | 2 ++ js/WebViewTypes.js | 7 +++++++ typings/index.d.ts | 7 +++++++ 5 files changed, 34 insertions(+) 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/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 From 1f80927c38d9e2a86e0ebe870f29b7d90e151712 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 22 Jan 2019 09:22:43 +0000 Subject: [PATCH 3/4] chore(release): 3.2.0 [skip ci] # [3.2.0](https://github.com/react-native-community/react-native-webview/compare/v3.1.3...v3.2.0) (2019-01-22) ### Features * **android props:** Add `androidHardwareAccelerationDisabled` prop ([#265](https://github.com/react-native-community/react-native-webview/issues/265)) ([d3fc5e6](https://github.com/react-native-community/react-native-webview/commit/d3fc5e6)) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", From 0fdd51de0e5d50079f2abbb07fd0c1c260220a43 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" Date: Tue, 22 Jan 2019 11:15:22 +0100 Subject: [PATCH 4/4] chore(readme): add YangXiaomei as a contributor (#268) Adds @YangXiaomei as a contributor for code, doc. This was requested by Titozzz [in this comment](https://github.com/react-native-community/react-native-webview/pull/265#issuecomment-456327682) --- .all-contributorsrc | 10 ++++++++++ README.md | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) 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 5710a38..d5142a0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # React Native WebView - a Modern, Cross-Platform WebView for React Native -[![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-5-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) +[![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!