我的应用程序使用了大量的网页视图,这些网页视图是由ViewPager保存的片段。
每当我滑动我的Galaxy Nexus上的应用程序,上面有果冻,我就会一次又一次地收到以下控制台消息:
08-23 13:44:03.374: E/webcoreglue(21690): Should not happen: no rect-based-test nodes found
谁能向我解释一下这里出了什么问题,以便我能够解决这个问题?
发布于 2013-04-19 09:38:28
这个问题的发生是因为在某些情况下,WebView没有注意到它的可视rect已经改变,所以就webkit而言,页面仍然不可见。因此,所有的触碰都落在窗口之外,并被拒绝。
最干净的修复方法是,当您知道WebView的可见性发生了变化时(例如响应视图分页程序中的setPrimaryItem回调),调用webview.onScrollChanged(webview.getScrollX(), webview.getScrollY());
您需要将webview子类化以将受保护的onScrollChanged提升为公共方法。
发布于 2012-09-07 19:51:24
我也面临着完全相同的问题。在我的应用程序中,我使用jquery bind()中的'touchend‘编码了点击事件,出现了这个错误,而且它过去从来不会响应点击(点击)。给人一种冰冻的感觉。所以我只是试着在bind()中用'click‘替换'touchend’,它起作用了!响应点击(点击),也未显示webcoreglue日志条目。
我还在Android的webview代码中找到了这段代码。
HTMLElement* WebViewCore::retrieveElement(int x, int y,
const QualifiedName& tagName)
{
HitTestResult hitTestResult = m_mainFrame->eventHandler()
->hitTestResultAtPoint(IntPoint(x, y), false, false,
DontHitTestScrollbars, HitTestRequest::Active | HitTestRequest::ReadOnly,
IntSize(1, 1));
if (!hitTestResult.innerNode() || !hitTestResult.innerNode()->inDocument()) {
LOGE("Should not happen: no in document Node found");
return 0;
}
const ListHashSet<RefPtr<Node> >& list = hitTestResult.rectBasedTestResult();
if (list.isEmpty()) {
LOGE("Should not happen: no rect-based-test nodes found");
return 0;
}
Node* node = hitTestResult.innerNode();
Node* element = node;
while (element && (!element->isElementNode()
|| !element->hasTagName(tagName))) {
element = element->parentNode();
}
DBG_NAV_LOGD("node=%p element=%p x=%d y=%d nodeName=%s tagName=%s", node,
element, x, y, node->nodeName().utf8().data(),
element ? ((Element*) element)->tagName().utf8().data() : "<none>");
return static_cast<WebCore::HTMLElement*>(element);
}
还有这个..。
// get the highlight rectangles for the touch point (x, y) with the slop
Vector<IntRect> WebViewCore::getTouchHighlightRects(int x, int y, int slop)
{
Vector<IntRect> rects;
m_mousePos = IntPoint(x - m_scrollOffsetX, y - m_scrollOffsetY);
HitTestResult hitTestResult = m_mainFrame->eventHandler()->hitTestResultAtPoint(IntPoint(x, y),
false, false, DontHitTestScrollbars, HitTestRequest::Active | HitTestRequest::ReadOnly, IntSize(slop, slop));
if (!hitTestResult.innerNode() || !hitTestResult.innerNode()->inDocument()) {
LOGE("Should not happen: no in document Node found");
return rects;
}
const ListHashSet<RefPtr<Node> >& list = hitTestResult.rectBasedTestResult();
if (list.isEmpty()) {
LOGE("Should not happen: no rect-based-test nodes found");
return rects;
}
//Rest of the part is omitted here...
注意到那里的日志消息了吗?我猜这段代码是用来识别在点击、点击或滑动时生成的x和y轴向量的。
发布于 2012-12-05 06:32:29
对于包含WebViews的JellyBean和ViewPager +片段也有同样的问题。在Android2.2上运行相同的代码都没问题,所以我认为这是JB WebView实现中的一个错误。
在JB上,只有第一个显示WebView的片段工作正常,没有错误“不应该发生..”在日志中,getHitTestResult()调用返回正确的值。滑动到下一页,我在日志中看到错误,getHitTestResult()只返回0和null值。
现在,我发现只有一种解决方案可以创建具有空容器的片段,并创建WebViews,设置它们并仅当当前片段在ViewPager中变为活动时才加载数据。在这种情况下,WebView根据需要工作。但是,不幸的是,这完全打破了在ViewPager中平滑滑动页面的想法。
有了最后一个想法,明天将尝试将ViewPager的片段替换为复合视图。可能性很小,但如果结果成功,我会让你知道的。
https://stackoverflow.com/questions/12090899
复制相似问题