Cherry-pick "[Android] Don't hide text handles if they are being dragged"

From https://codereview.chromium.org/26491010/

Bug 10723151

Original Description:

In webview, hiding of text handles can be triggered by many events
(containing view being scrolled, capturePicture call, etc.). If the
user is dragging a handle, we don't actually want to hide it. Instead,
explicitly suppress hiding of text handles while they are being dragged.

BUG=b/10723151

Review URL: https://codereview.chromium.org/26491010

Change-Id: I254e12582c0ef3446756c2aa1d8b418639413f3c
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228728 0039d316-1c4b-4281-b951-d872f2087c98
Cherry-pick: [Android WebView] Do not throttle if need picture listener

Cherry-pick of Chromium crrev.com/r229116

BUG: 11230312

Original description:

Currently as implemented, this will ensure clearView can be
unset even if AwContents.onPause is called.

Should considering refactoring clearView such that this case
can be dealt with more sanely.

Change-Id: Id5f160d339eace1b58d7fdc3666fc1a9f5248ead
Revert "Fork: Read and skip glBindRenderbufferEXT if no change"

The corruption mentioned in the bug is gone even without this
workaround, so reverting the change.

> Skip calling glBindRenderbufferEXT if it's not changed from 0.
>
> Android WebView for now do not use this feature since we do not support
> WebGL and such. This is a workaround for what is suspected is a qualcomm
> driver bug.

BUG: 11061206

This reverts commit 8a5fbdacd4c28d4cd41276de73ca7205569fc2cf.
Cherry Pick [Android] Properly handle cancelled scroll events

Cherry pick of https://codereview.chromium.org/27220002/

Bug: 10892868

Original description:
[Android] Properly handle cancelled scroll events

If the gesture handler receives an ACTION_CANCEL event during a scroll,
it should tell native to end scrolling.

Adds tests that the proper events are sent to native in both the normal
scroll sequence and the cancelled sequence.

BUG=b/10892868

Committed:
https://src.chromium.org/viewvc/chrome?view=rev&revision=228583

Change-Id: If69ceeb2ebb3e991d9b7ec9422ad514345a50e46
Cherry pick [Android] Allow text handles to observe position of "parent" view

Cherry pick of https://codereview.chromium.org/24449007/

Bug: 10892868
Bug: 10562149
Bug: 10723151

Original description:

[Android] Allow text handles to observe position of "parent" view

This adds the class PositionObserver. This class provides a way to
listen for changes to the position of a particular view (and to query
that views current position).

Then, HandleView is updated to use a PositionObserver to keep its
PopupWindow's position up-to-date with the logical "parent" view (
HandleView is logically a child of some other view, but has to use
a PopupWindow outside of the logical parent's view hierarchy).

This is similar to, and influenced by, Android's Editor.java
(https://android.googlesource.com/platform/frameworks/base/+/android-4.3_r3.1/core/java/android/widget/Editor.java).

BUG=b/10562149

Committed:
https://src.chromium.org/viewvc/chrome?view=rev&revision=228594

Change-Id: Ifb8508628a716ee518227a289d89486d191cdced
Cherry pick [Android] Hide handles when the containing view moves

Cherry pick of https://codereview.chromium.org/26575006/

Bug: 10892868

Original description:
[Android] Hide handles when the containing view moves

We temporarily hide handles when there is a scroll or zoom in the
content area. When the containing view is moved, we should also hide
the handles. This is particularly important for webview where scrolling
is often handled outside of the webview itself (and is sometimes mixed
between the two).

BUG=b/10892868

Change-Id: I79e5238f3c61d7fee725f4eab8fe29363409b80d
Android WebView: use IO thread for cookie manager.

Instead of posting tasks to the FILE thread, use the IO thread to match
the rest of Chromium (which normally only calls CookieMonster on the IO
thread). This is a workaround for a possible thread safety issue in
CookieMonster (see http://crbug.com/308589), but it's fine to change
this permanently as the original choice of the FILE thread was not
significant.

Bug: 11265317
Change-Id: I0f54d9ce9408d17312e312d4b919b542dcac4828
[android_webview] Fix crash in testCreateDestroy.

Cherry-pick of http://crrev.com/28923005

> The onSizeChanged callback was arriving after the AwContents was destroyed.
> Ignoring the setFixedLayoutSize call is fine since the AwContents is going
> away anyway.
>
> BUG=308497
> R=mnaganov@chromium.org
>
> Review URL: https://codereview.chromium.org/28923005
>
> git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229798 0039d316-1c4b-4281-b951-d872f2087c98

BUG: 11316652
Change-Id: I6e29e143aa5b14389df3d55756fc8bda315f245d
Do not exclude background images/colors when printing

Bug: 10969979

When we implemented printing, we used the default values from Chrome
which by default does not enable background colors and images. In
Chrome, such settings are enabled via GUI. Without this setting,
some pages look broken.
Since Webview does not provide an API for this setting,
not excluding background images seems the more reasonable approach.

Change-Id: If038e960e297bdc8f2e54ec7d946fd2157c71009
Prevent log spam in autofill

Bug: 11267456
Change-Id: Ied852024f58582fa96cf073a10ab39a2acae32ff
Cherry-pick "Dynamically enable spatial navigation based on events"

Bug: 11144676

Taken from already-landed chromium r230304

Original description:

As currently implemented spatial navigation and touch event handling
have some unexpected interactions (see bug link) so instead:
1/ make a better-guess initial value based on presence of touchscreen
2/ dynamically enable spatnav when a DPAD event is received, and disable
   it when touch down event received.

BUG=309425

Review URL: https://codereview.chromium.org/33823005

Change-Id: I8ae9c798794e8f46f79c97b8f404def5146553ae
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230304 0039d316-1c4b-4281-b951-d872f2087c98
Cherry-pick with modification: cc: PictureLayerImpl with empty bounds should not have tiles

Cherry-pick of Chromium crrev.com/r230368.

Removed changes to add new test to avoid gyp/mk churn.

BUG: 11288267

Original description:

If a PictureLayer bounds is set to from non-empty to empty,
PictureLayer::Update is skipped so the picture pile is not
updated. In this case, the PictureLayerImpl should not have
tilings.

Change-Id: Ib022c99a34d2933dd2aba37bffd616fa114eaf42
Disable NOTIMPLEMENTED() in release branch.

Compile out NOTIMPLEMENTED() in the release branch as the logcat
messages generated are not actionable by developers.

Bug: 10126462
Change-Id: I32527223b938762883ba4e910b42e0e6239949d1
Cherry-pick with modification: cc: Fix CHECK failure in PictureLayerImpl::UpdateTilePriorities

Cherry-pick of Chromium crrev.com/r230735

Removed the test due to conflict.

BUG: 11265055

Original description:

The should_update_tile_priorities_ in UpdateTilePriorities my fail and
here's the sequence of events:

* Context loss while layer is invisible, which clears
should_update_tile_priorities_
* CalculateContentsScale is skipped because layer is invisible
* Layer becomes visible in next commit, and active layer SyncTiling
during the commit will fail the check.

Any condition that causes CalculateContentsScale on the layer works as
well.

Change-Id: Ia92de26d27a37c3a6af487d92e6869a495cfbd3e
Cherry-pick "Reject rather than abort client certificates"

Bug 11375270

Taken from https://codereview.chromium.org/42583002/ PS2

Original description:

Reject rather than abort client certificates

The default behavior in the existing implementation was to reject the
client cert request but allow the SSL connection to proceed (so allowing
the server to choose policy on how to handle this scenario). Implement
the content callbacks to acheive the same.

Change-Id: Id9b091a876b9e1ed2f7092876511987cd1fa4a74
Cherry-pick "Android should be able to copy HTML snippets to the system clipboard."

Bug 10863973

Taken from upstream CL 9e7f61b8c (http://crrev.com/231337)

Original description:

Currently the only clipboard data we actually push to the Android system
clipboard is plain-text data, so any formatting and links will be removed
when someone pastes content from Chromium to, for example, Gmail.

In order to push HTML data on the Android clipboard, we do need to know
the plain-text representation so that non-HTML consumers can still use
what's on there (there only is one primary clip). For that reason, we only
push HTML to the Android system clipboard if there also is a plain-text
representation available in the ClipboardMap.

There are a few situations in which we end up calling Clipboard::WriteHTML.
Android doesn't care about Pepper and drag and drop data right now. The
WebClipboardImpl::writeImage() method will write a HTML snippet, but we'll
ignore that because no plain-text data will be pasted. The fourth case is
WebClipboardImpl::writeHTML(), used for DOM fragments and rich content,
which will work fine after this patch.

BUG=214200

Review URL: https://codereview.chromium.org/25668005

Change-Id: I340c9befd8580e6f3de8d308053759054b9a8858
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231337 0039d316-1c4b-4281-b951-d872f2087c98
Set a fixed layout size only if the container view has a WRAP_CONTENT layout mode.

Cherry pick http://crrev.com/35403002

> Using the measureSpec from the onMeasure callback to decide whether to set a
> fixed layout size or not has proven to be a bit unpredictable. Changing the
> code to look at the LayoutParams instead.
>
> BUG=None
> TEST=AndroidWebViewTest
> // android_webview-only, trybots were happy.
> NOTRY=true
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=231815

BUG: 11128702
Change-Id: I08093b50965148632ca7ed8298decb55d4a6b505
Fork: Skip gralloc unbind on all except NVIDIA

Also add system property ro.sys.gralloc_unbind (set to
either 1 or 0) to override this behavior.

BUG: 11392857

Change-Id: Id85642e9f9fefd392bc66874f395c1a7b128331c
[android] Fire accessibility events when scrolling sublayers.

Cherry-pick http://crrev.com/48973004

> This enables the Android WebView to fire accessibility events for
> sub-layer scrolling. Currently this is only limited to touch-driven
> scrolling (JavaScript-initiated scrolling only works for the root
> layer at the moment).
>
> BUG=312318
> android-only change, trybots are happy
> NOTRY=true
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=232097

BUG: 10969501
Change-Id: I53fef2b655ff5e77e0924c4edc529e44f5b626ec
Cherry-pick: CC: Cap the size of the SOON_BIN.

Cherry-pick of Chromium crrev.com/r227711.

Conflicts:
	cc/resources/tile_manager.cc

BUG: 11446261

Original Description:

ALLOW_PREPAINT_ONLY is used to reduce memory usage, but
currently the SOON_BIN can still grow to an unbounded size
because we will schedule rasters for the entire SOON_BIN,
even though our paint rate is what truly determines if we
see checkerboard.

Minus raster tasks spikes seen in http://crbug.com/303397,
this keeps memory usage well below the limit when using
ALLOW_PREPAINT_ONLY.

Change-Id: I0c7677a45f9afb11177ec4dbb99ef7ca4a56b5c7