summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2010-12-28 09:23:04 -0500
committerCary Clark <cary@android.com>2010-12-28 09:58:15 -0500
commit4bea34f0eef8075bbcd898a711b02d74a1d7e675 (patch)
treeae797a10532af3d00d2bf8e9537742df93c4ec62 /WebKit
parentb956b5febfa4032d920377884b2a5fb0c11daad0 (diff)
downloadexternal_webkit-4bea34f0eef8075bbcd898a711b02d74a1d7e675.zip
external_webkit-4bea34f0eef8075bbcd898a711b02d74a1d7e675.tar.gz
external_webkit-4bea34f0eef8075bbcd898a711b02d74a1d7e675.tar.bz2
join rects without gaps
While analyzing cursor rings, regions are built from text, rects, and bitmaps to determine the areas inside and outside the rings. These areas determine if the rings are fully visible, and if they can be expanded into a larger bounds. Empty input areas are defined only by rects drawn as their background. In general, rects may be drawn as pieces that need to be stitched together. Unlike glyphs, the stitching should not allow gaps between rects. By detecting gaps, and treating each unjoined rect as its own area, a page with multiple successive input fields correctly computes cursor rect bounds. bug:3116242 Change-Id: If702b692c99c96c0188b42a638f750da12af6df4
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/android/nav/CachedRoot.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/WebKit/android/nav/CachedRoot.cpp b/WebKit/android/nav/CachedRoot.cpp
index 0c92498..d529a00 100644
--- a/WebKit/android/nav/CachedRoot.cpp
+++ b/WebKit/android/nav/CachedRoot.cpp
@@ -898,7 +898,11 @@ protected:
&& mType != kDrawSprite_Type && mType != kDrawBitmap_Type)
return false;
if (mLayerTypes.isEmpty() || mLayerTypes.last() != mType
- || !mAppendLikeTypes) {
+ || !mAppendLikeTypes
+ // if the last was a rect, and the current one is also a rect,
+ // but the two rects have a gap between, don't join them -- push
+ // an empty between them
+ || (mType == kDrawRect_Type && !joinable(rect))) {
push(mType, mEmpty);
}
DBG_NAV_LOGD("RingCheck join %s (%d,%d,r=%d,b=%d) '%c'",
@@ -995,6 +999,20 @@ private:
}
}
+ bool joinable(const SkIRect& rect)
+ {
+ SkRegion region = mLayers.last();
+ if (!region.isRect())
+ return false;
+ const SkIRect& bounds1 = region.getBounds();
+ int area1 = bounds1.width() * bounds1.height();
+ area1 += rect.width() * rect.height();
+ region.op(rect, SkRegion::kUnion_Op);
+ const SkIRect& bounds2 = region.getBounds();
+ int area2 = bounds2.width() * bounds2.height();
+ return area2 <= area1;
+ }
+
void popEmpty()
{
if (mLayerTypes.size() == 0)