//----------------------------------------------------------------------------- // WebPointerEventHandler::canDehighlight //----------------------------------------------------------------------------- bool WebPointerEventHandler::canDehighlight(const TPoint &aPoint) { TBool checkDehighlight = true; if (!m_webview->viewIsScrolling()) { WebFrame* frm = StaticObjectsContainer::instance()->webCursor()->getFrameUnderCursor(); IntPoint framePoint = frm->frameView()->viewCoordsInFrameCoords(aPoint); if (m_highlightedNode->getRect().contains(framePoint)) { checkDehighlight = false; } // check if new points are coming towards closest element else if(m_offset) { //Calculate the new offset IntPoint nodePoint = m_highlightedNode->getRect().Rect().Center(); TInt newoffset = (framePoint.x()- nodePoint.x())*(framePoint.x()- nodePoint.x()) + (framePoint.y()- nodePoint.y())*(framePoint.y()- nodePoint.y()); if(newoffset <= m_offset ) { m_offset = newoffset; checkDehighlight = false; } else { m_offset =0; checkDehighlight = true; } } } return checkDehighlight; }
//----------------------------------------------------------------------------- // WebPointerEventHandler::highlitableElement //----------------------------------------------------------------------------- TBrCtlDefs::TBrCtlElementType WebPointerEventHandler::highlitableElement() { TRect elRect; TBrCtlDefs::TBrCtlElementType elType = TBrCtlDefs::EElementNone; Frame* coreFrame = core(m_webview->mainFrame()); WebCursor* cursor = StaticObjectsContainer::instance()->webCursor(); TPointerEvent event; TPoint pos = cursor->position(); WebFrame* wfrm = cursor->getFrameAtPoint(pos); Frame* frm = core(wfrm); TPoint pt(wfrm->frameView()->viewCoordsInFrameCoords(pos)); TPoint nodePoint; Element* eventNode = frm->document()->elementFromPoint(pos.iX, pos.iY); m_highlightedNode = NULL; Node* retNode = 0; frm->bridge()->getTypeFromElement(eventNode, elType, elRect, retNode); if (elType == TBrCtlDefs::EElementNone) { Node* n = wfrm->getClosestAnchorElement(cursor->position(), pos); if (n) { wfrm = cursor->getFrameAtPoint(pos); frm = core(wfrm); eventNode = frm->document()->elementFromPoint(pos.iX, pos.iY); frm->bridge()->getTypeFromElement(eventNode, elType, elRect, retNode); TPoint nodePoint = n->getRect().Rect().Center(); m_offset = (pt.iX- nodePoint.iX)*(pt.iX- nodePoint.iX) + (pt.iY- nodePoint.iY)*(pt.iY- nodePoint.iY); } } m_highlightedNode = eventNode; if (m_highlightedNode) { m_highlightPos = pos; m_buttonDownEvent.iPosition = m_highlightPos; } m_webview->setFocusedElementType(elType); return elType; }