diff options
author | Cary Clark <cary@android.com> | 2010-11-11 10:14:14 -0500 |
---|---|---|
committer | Cary Clark <cary@android.com> | 2010-11-11 13:00:17 -0500 |
commit | 2b36633c8e1183d3b024dea63d958eaff71bdc64 (patch) | |
tree | 47056c594121600289392f2951ccac4ed600aad1 /WebKit/android/nav/SelectText.cpp | |
parent | 5d93c28b5a1fcbe16e88da9bc1260a75054f7992 (diff) | |
download | external_webkit-2b36633c8e1183d3b024dea63d958eaff71bdc64.zip external_webkit-2b36633c8e1183d3b024dea63d958eaff71bdc64.tar.gz external_webkit-2b36633c8e1183d3b024dea63d958eaff71bdc64.tar.bz2 |
use layer id to maintain selection
The pictures used to draw the page content can change
in response to refreshes, as the selection is moved or
as the screen is scrolled or zoomed.
Track the layer id, instead of the picture pointer,
to find the picture that contains the current selection.
Before, the selection would disappear as the screen
was pinched, or the highlight might disappear even
though the anchors draw, or the highlight and anchors
might be drawn offset from the screen data. This change
eliminates this class of bugs.
Change-Id: Ifc440b8aa0c9d6d232e298e42c4c544a41629442
http://b/3183492
Diffstat (limited to 'WebKit/android/nav/SelectText.cpp')
-rw-r--r-- | WebKit/android/nav/SelectText.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/WebKit/android/nav/SelectText.cpp b/WebKit/android/nav/SelectText.cpp index e606f62..f6548cf 100644 --- a/WebKit/android/nav/SelectText.cpp +++ b/WebKit/android/nav/SelectText.cpp @@ -1290,8 +1290,12 @@ SelectText::~SelectText() void SelectText::draw(SkCanvas* canvas, LayerAndroid* layer) { - if (!m_picture || m_picture != layer->picture()) + if (m_layerId != layer->uniqueId()) return; + // reset m_picture to match m_layerId + m_picture->safeUnref(); + m_picture = layer->picture(); + m_picture->safeRef(); DBG_NAV_LOGD("m_extendSelection=%d m_drawPointer=%d layer [%d]", m_extendSelection, m_drawPointer, layer->uniqueId()); if (m_extendSelection) @@ -1330,6 +1334,8 @@ void SelectText::drawSelectionPointer(SkCanvas* canvas) void SelectText::drawSelectionRegion(SkCanvas* canvas) { + if (!m_picture) + return; m_selRegion.setEmpty(); SkIRect ivisBounds = m_visibleRect; ivisBounds.join(m_selStart); @@ -1512,6 +1518,7 @@ void SelectText::reset() m_startSelection = false; m_picture->safeUnref(); m_picture = 0; + m_layerId = 0; } void SelectText::selectAll() @@ -1548,7 +1555,7 @@ bool SelectText::startSelection(const CachedRoot* root, const IntRect& vis, { m_startOffset.set(x, y); m_picture->safeUnref(); - m_picture = root->pictureAt(&x, &y); + m_picture = root->pictureAt(&x, &y, &m_layerId); if (!m_picture) { DBG_NAV_LOG("picture==0"); return false; |