|
1 /* |
|
2 * Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <Browser_platform_variant.hrh> |
|
19 #include "config.h" |
|
20 #include "../../bidi.h" |
|
21 #include <AknUtils.h> |
|
22 #ifdef BRDO_TOUCH_ENABLED_FF |
|
23 #include <touchfeedback.h> |
|
24 #endif // BRDO_TOUCH_ENABLED_FF |
|
25 #include "brctl.h" |
|
26 #include "BrCtlDefs.h" |
|
27 #include "WebPointerEventHandler.h" |
|
28 #include "WebView.h" |
|
29 #include "WebFrame.h" |
|
30 #include "WebFrameView.h" |
|
31 #include "WebCursor.h" |
|
32 #include "WebPopupDrawer.h" |
|
33 #include "WebFormFillPopup.h" |
|
34 #include "WebPageScrollHandler.h" |
|
35 #include "WebFepTextEditor.h" |
|
36 #include "WebCoreFrameBridge.h" |
|
37 #include "StaticObjectsContainer.h" |
|
38 #include "PluginSkin.h" |
|
39 #include "WebUtil.h" |
|
40 #include "Element.h" |
|
41 #include "Document.h" |
|
42 #include "Frame.h" |
|
43 #include "FrameView.h" |
|
44 #include "EventHandler.h" |
|
45 #include "EventNames.h" |
|
46 #include "HitTestResult.h" |
|
47 #include "MouseEvent.h" |
|
48 #include "WebPageFullScreenHandler.h" |
|
49 #include "PluginSkin.h" |
|
50 #include "PluginWin.h" |
|
51 #include "WebFrameBridge.h" |
|
52 #include "Page.h" |
|
53 #include "Chrome.h" |
|
54 #include "ChromeClient.h" |
|
55 #include "FocusController.h" |
|
56 |
|
57 |
|
58 #include "WebKitLogger.h" |
|
59 using namespace WebCore; |
|
60 using namespace EventNames; |
|
61 using namespace RT_GestureHelper; |
|
62 |
|
63 static const int KMinScrollAndTapInterval = 200000; // 200 ms |
|
64 static const int KDoubleTapMinActivationInterval = 100000; // 100 ms |
|
65 static const int KDoubleTapMaxActivationInterval = 500000; // 500 ms |
|
66 static const int KDoubleTapIdleInterval = 700000; // 700 ms, to prevent triple-tap effects |
|
67 |
|
68 //----------------------------------------------------------------------------- |
|
69 // WebPointerEventHandler::NewL |
|
70 //----------------------------------------------------------------------------- |
|
71 WebPointerEventHandler* WebPointerEventHandler::NewL(WebView* view) |
|
72 { |
|
73 WebPointerEventHandler* self = new (ELeave) WebPointerEventHandler(view); |
|
74 CleanupStack::PushL( self ); |
|
75 self->ConstructL(); |
|
76 CleanupStack::Pop(); |
|
77 return self; |
|
78 } |
|
79 |
|
80 //----------------------------------------------------------------------------- |
|
81 // WebPointerEventHandler::WebPointerEventHandler |
|
82 //----------------------------------------------------------------------------- |
|
83 WebPointerEventHandler::WebPointerEventHandler(WebView* view) |
|
84 : m_webview(view), |
|
85 m_isHighlighted(false), |
|
86 m_highlightedNode(NULL), |
|
87 m_buttonDownTimer( this, &WebPointerEventHandler::buttonDownTimerCB ), |
|
88 m_ignoreTap(false) |
|
89 { |
|
90 } |
|
91 |
|
92 //----------------------------------------------------------------------------- |
|
93 // WebPointerEventHandler::~WebPointerEventHandler |
|
94 //----------------------------------------------------------------------------- |
|
95 WebPointerEventHandler::~WebPointerEventHandler() |
|
96 { |
|
97 delete m_gestureHelper; |
|
98 delete m_waiter; |
|
99 } |
|
100 |
|
101 //----------------------------------------------------------------------------- |
|
102 // WebPointerEventHandler::ConstructL |
|
103 //----------------------------------------------------------------------------- |
|
104 void WebPointerEventHandler::ConstructL() |
|
105 { |
|
106 #ifdef BRDO_USE_GESTURE_HELPER |
|
107 m_gestureHelper = CGestureHelper::NewL( *this ); |
|
108 m_gestureHelper->SetDoubleTapEnabled(true); |
|
109 m_gestureHelper->SetHoldingEnabled(false); |
|
110 #else |
|
111 m_gestureHelper = NULL; |
|
112 #endif |
|
113 m_waiter = new(ELeave) CActiveSchedulerWait(); |
|
114 } |
|
115 /** |
|
116 * EGestureStart is sent on touch down |
|
117 * EGestureReleased is sent on touch up |
|
118 * EGestureTap = touch down + touch up - events sent: EGestureStart, EGestureTap |
|
119 * EGestureReleased |
|
120 * EGestureDrag = touch down + "move" - events sent: EGestureStart, EGestureDrag |
|
121 * EGestureDoubleTap = 2 * (touch down + touch up) - events sent EGestureStart, |
|
122 * EGestureDoubleTap, EGestureReleased |
|
123 * EGestureLongTap = touch down + "long touch" - events sent: EGestureStart, |
|
124 * EGestureLongTap |
|
125 * EGestureSwipe<Up/Down/Left/Right> - drag + touch up, where movements is |
|
126 * close to particular direction - event sent: EGestureSwipe, |
|
127 * EGestureReleased |
|
128 * EGestureFlick - "fast" drag + touch up - events sent: EGestureFlick, |
|
129 * EGestureReleased |
|
130 * EGestureDrop - drag + touch up, !(EGestureSwipe || EGestureFlick) - events |
|
131 * sent: EGestureDrop, EGestureReleased |
|
132 */ |
|
133 void WebPointerEventHandler::HandleGestureL( const MGestureEvent& aEvent ) |
|
134 { |
|
135 TGestureCode gtype = const_cast<MGestureEvent&>(aEvent).Code(MGestureEvent::EAxisBoth); |
|
136 updateCursor(aEvent.CurrentPos()); |
|
137 |
|
138 switch (gtype) { |
|
139 // sent on touch down |
|
140 case EGestureStart: |
|
141 { |
|
142 if (m_webview->viewIsScrolling()) { |
|
143 m_ignoreTap = true; |
|
144 m_webview->pageScrollHandler()->handleTouchDownGH(aEvent); |
|
145 } |
|
146 else { |
|
147 handleTouchDownL(aEvent); |
|
148 } |
|
149 break; |
|
150 } |
|
151 |
|
152 // sent on tap |
|
153 case EGestureTap: |
|
154 { |
|
155 if (!m_ignoreTap) { |
|
156 handleTapL(aEvent); |
|
157 } |
|
158 break; |
|
159 } |
|
160 |
|
161 // sent on double tap |
|
162 case EGestureDoubleTap: |
|
163 { |
|
164 handleDoubleTap(aEvent); |
|
165 break; |
|
166 } |
|
167 |
|
168 // sent on long tap |
|
169 case EGestureLongTap: |
|
170 { |
|
171 break; |
|
172 } |
|
173 |
|
174 // sent on touch up after drag |
|
175 case EGestureDrop: |
|
176 case EGestureFlick: |
|
177 case EGestureSwipeLeft: |
|
178 case EGestureSwipeRight: |
|
179 case EGestureSwipeUp: |
|
180 case EGestureSwipeDown: |
|
181 { |
|
182 m_ignoreTap = false; |
|
183 handleTouchUp(aEvent); |
|
184 break; |
|
185 } |
|
186 // sent on move |
|
187 case EGestureDrag: |
|
188 { |
|
189 handleMove(aEvent); |
|
190 break; |
|
191 } |
|
192 |
|
193 // sent on touch up after tap double tap and long tap |
|
194 case EGestureReleased: |
|
195 { |
|
196 m_ignoreTap = false; |
|
197 handleTouchUp(aEvent); |
|
198 break; |
|
199 } |
|
200 } |
|
201 } |
|
202 |
|
203 |
|
204 // ====================================================================== |
|
205 // WebPointerEventHandler::handleTap |
|
206 // ====================================================================== |
|
207 void WebPointerEventHandler::handleTapL(const MGestureEvent& aEvent) |
|
208 { |
|
209 m_buttonDownTimer.stop(); |
|
210 m_lastTapEvent = m_currentEvent; |
|
211 if(!m_webview->inPageViewMode()){ |
|
212 doTapL(); |
|
213 } |
|
214 } |
|
215 // ====================================================================== |
|
216 // WebPointerEventHandler::handleDoubleTap |
|
217 //====================================================================== |
|
218 void WebPointerEventHandler::handleDoubleTap(const MGestureEvent& aEvent) |
|
219 { |
|
220 if ( !m_webview->viewIsScrolling() && |
|
221 (m_webview->brCtl()->capabilities() & TBrCtlDefs::ECapabilityFitToScreen)) { |
|
222 if (m_isHighlighted){ |
|
223 dehighlight(); |
|
224 } |
|
225 m_webview->setZoomLevelAdaptively(); |
|
226 } |
|
227 else { |
|
228 m_webview->resetLastZoomLevelIfNeeded(); |
|
229 } |
|
230 } |
|
231 |
|
232 // ====================================================================== |
|
233 // WebPointerEventHandler::handleTouchDownL |
|
234 //====================================================================== |
|
235 void WebPointerEventHandler::handleTouchDownL(const MGestureEvent& aEvent) |
|
236 { |
|
237 TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType(); |
|
238 m_buttonDownEvent = m_currentEvent; |
|
239 m_highlightPos = aEvent.CurrentPos(); |
|
240 |
|
241 if ( !m_buttonDownTimer.isActive() && !m_webview->inPageViewMode() ){ |
|
242 m_buttonDownTimer.startOneShot(0.1f); |
|
243 } |
|
244 |
|
245 m_webview->pageScrollHandler()->handleTouchDownGH(aEvent); |
|
246 |
|
247 if ( TBrCtlDefs::EElementActivatedObjectBox == elType) { |
|
248 PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin(); |
|
249 if (plugin && plugin->pluginWin()) { |
|
250 if (!plugin->getClipRect().Contains(m_buttonDownEvent.iPosition)) { |
|
251 plugin->deActivate(); |
|
252 } |
|
253 else { |
|
254 plugin->pluginWin()->HandlePointerEventL(m_buttonDownEvent); |
|
255 } |
|
256 } |
|
257 } |
|
258 /* |
|
259 * After introducing "link selection" pointer down action is done in |
|
260 * buttondown timer callback. When "down" gesture event is arrived we start |
|
261 * timer end exit, so gesture helper is ready to deliver next gesture event. |
|
262 * Meanwhile the processing of the first gesture event hasn't been finished yet. |
|
263 * The gesture helper doesn't "know" about our plans to handle the event inside |
|
264 * timer callback and only way for us to "tell" about this is to stop RunL() |
|
265 * of CGestureEventSender (HandleGestureL() is inside it) and finish buttondown |
|
266 * timer callback first. |
|
267 */ |
|
268 if ( m_buttonDownTimer.isActive()){ |
|
269 m_waiter->Start(); |
|
270 } |
|
271 } |
|
272 |
|
273 // ====================================================================== |
|
274 // WebPointerEventHandler::handleTouchUp |
|
275 // ====================================================================== |
|
276 void WebPointerEventHandler::handleTouchUp(const MGestureEvent& aEvent) |
|
277 { |
|
278 m_highlightPos = TPoint(-1,-1); |
|
279 m_highlightedNode = NULL; |
|
280 |
|
281 m_webview->pageScrollHandler()->handleTouchUpGH(aEvent); |
|
282 } |
|
283 |
|
284 // ====================================================================== |
|
285 // WebPointerEventHandler::handleMoveL |
|
286 // ====================================================================== |
|
287 void WebPointerEventHandler::handleMove(const MGestureEvent& aEvent) |
|
288 { |
|
289 TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType(); |
|
290 TPoint curPos = aEvent.CurrentPos(); |
|
291 |
|
292 m_buttonDownTimer.stop(); |
|
293 HandleHighlightChange(curPos); |
|
294 |
|
295 if (elType == TBrCtlDefs::EElementActivatedObjectBox) { |
|
296 PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin(); |
|
297 if (plugin) { |
|
298 plugin->deActivate(); |
|
299 } |
|
300 } |
|
301 |
|
302 m_webview->pageScrollHandler()->handleScrollingGH(aEvent); |
|
303 } |
|
304 |
|
305 |
|
306 // ====================================================================== |
|
307 // WebPointerEventHandler::HandlePointerEventL |
|
308 // ====================================================================== |
|
309 void WebPointerEventHandler::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
310 { |
|
311 m_currentEvent = aPointerEvent; |
|
312 |
|
313 if (m_webview->isSynchRequestPending()) { |
|
314 return; |
|
315 } |
|
316 |
|
317 // Handle graphical history - should never happen, as HistoryView handles this event by itself |
|
318 if ( m_webview->brCtl()->historyHandler()->historyController()->historyView()) { |
|
319 return; |
|
320 } |
|
321 |
|
322 // Handle FormFill popup |
|
323 if (m_webview->formFillPopup() && m_webview->formFillPopup()->IsVisible()) { |
|
324 m_webview->formFillPopup()->HandlePointerEventL(aPointerEvent); |
|
325 return; |
|
326 } |
|
327 |
|
328 if (!m_webview->inPageViewMode()) { |
|
329 if (aPointerEvent.iType == TPointerEvent::EButton1Down) { |
|
330 m_webview->GetContainerWindow().EnablePointerMoveBuffer(); |
|
331 } |
|
332 else if (aPointerEvent.iType == TPointerEvent::EButton1Up) { |
|
333 m_webview->GetContainerWindow().DisablePointerMoveBuffer(); |
|
334 } |
|
335 } |
|
336 |
|
337 #ifdef BRDO_USE_GESTURE_HELPER |
|
338 m_gestureHelper->HandlePointerEventL(aPointerEvent); |
|
339 #endif |
|
340 } |
|
341 |
|
342 //----------------------------------------------------------------------------- |
|
343 // WebPointerEventHandler::HandleHighlightChange |
|
344 //----------------------------------------------------------------------------- |
|
345 void WebPointerEventHandler::HandleHighlightChange(const TPoint &aPoint) |
|
346 { |
|
347 if (!m_highlightedNode || !m_isHighlighted) return; |
|
348 |
|
349 if (!canDehighlight(aPoint)) return; |
|
350 |
|
351 dehighlight(); |
|
352 } |
|
353 |
|
354 //----------------------------------------------------------------------------- |
|
355 // WebPointerEventHandler::checkForEventListener |
|
356 //----------------------------------------------------------------------------- |
|
357 bool WebPointerEventHandler::checkForEventListener(WebCore::Node* node) |
|
358 { |
|
359 EventTargetNode* etnfound = NULL; |
|
360 for (Node* np = node; np; np = np->parentNode()) { |
|
361 //check for a mouseover event listener |
|
362 if (np->isEventTargetNode()) { |
|
363 if (m_webview->page()->chrome()->client()->elementVisibilityChanged()) { |
|
364 return true; |
|
365 } |
|
366 } |
|
367 } |
|
368 return false; |
|
369 } |
|
370 |
|
371 |
|
372 //----------------------------------------------------------------------------- |
|
373 // WebPointerEventHandler::highlitableElement |
|
374 //----------------------------------------------------------------------------- |
|
375 TBrCtlDefs::TBrCtlElementType WebPointerEventHandler::highlitableElement() |
|
376 { |
|
377 TRect elRect; |
|
378 TBrCtlDefs::TBrCtlElementType elType = TBrCtlDefs::EElementNone; |
|
379 Frame* coreFrame = core(m_webview->mainFrame()); |
|
380 WebCursor* cursor = StaticObjectsContainer::instance()->webCursor(); |
|
381 m_webview->page()->chrome()->client()->setElementVisibilityChanged(false); |
|
382 HitTestResult htresult(cursor->position()); |
|
383 TPointerEvent event; |
|
384 TPoint pos = cursor->position(); |
|
385 event.iPosition = pos; |
|
386 event.iModifiers = 0; |
|
387 event.iType = TPointerEvent::EMove; |
|
388 coreFrame->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event),&htresult); |
|
389 WebFrame* frm = cursor->getFrameUnderCursor(); |
|
390 TPoint pt(frm->frameView()->viewCoordsInFrameCoords(pos)); |
|
391 TPoint nodePoint; |
|
392 |
|
393 m_highlightedNode = NULL; |
|
394 |
|
395 cursor->navigableNodeUnderCursor(*(frm), pt, elType, elRect); |
|
396 if (elType == TBrCtlDefs::EElementNone) { |
|
397 |
|
398 Node* n = frm->getClosestAnchorElement(cursor->position(), pos); |
|
399 if (n) { |
|
400 htresult = HitTestResult(pos); |
|
401 event.iPosition = pos; |
|
402 coreFrame->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event),&htresult); |
|
403 coreFrame->bridge()->getTypeFromElement(htresult.innerNode(), elType, elRect); |
|
404 TPoint nodePoint = n->getRect().Rect().Center(); |
|
405 m_offset = (pt.iX- nodePoint.iX)*(pt.iX- nodePoint.iX) + |
|
406 (pt.iY- nodePoint.iY)*(pt.iY- nodePoint.iY); |
|
407 |
|
408 |
|
409 } |
|
410 } |
|
411 m_highlightedNode = htresult.innerNode(); |
|
412 if (m_highlightedNode) { |
|
413 m_highlightPos = pos; |
|
414 m_buttonDownEvent.iPosition = m_highlightPos; |
|
415 } |
|
416 m_webview->setFocusedElementType(elType); |
|
417 return elType; |
|
418 } |
|
419 |
|
420 // ====================================================================== |
|
421 // WebPointerEventHandler::isHighlitableElement |
|
422 // ====================================================================== |
|
423 bool WebPointerEventHandler::isHighlitableElement(TBrCtlDefs::TBrCtlElementType& elType) |
|
424 { |
|
425 return (elType == TBrCtlDefs::EElementAnchor |
|
426 || elType == TBrCtlDefs::EElementInputBox |
|
427 || elType == TBrCtlDefs::EElementActivatedInputBox |
|
428 || elType == TBrCtlDefs::EElementButton |
|
429 || elType == TBrCtlDefs::EElementCheckBoxChecked |
|
430 || elType == TBrCtlDefs::EElementCheckBoxUnChecked |
|
431 || elType == TBrCtlDefs::EElementTextAreaBox |
|
432 || elType == TBrCtlDefs::EElementRadioButtonSelected |
|
433 || elType == TBrCtlDefs::EElementRadioButtonUnSelected |
|
434 || elType == TBrCtlDefs::EElementTelAnchor |
|
435 || elType == TBrCtlDefs::EElementMailtoAnchor |
|
436 || elType == TBrCtlDefs::EElementSmartLinkTel |
|
437 || elType == TBrCtlDefs::EElementSmartLinkEmail |
|
438 || elType == TBrCtlDefs::EElementSmartLinkVoip); |
|
439 } |
|
440 |
|
441 |
|
442 //----------------------------------------------------------------------------- |
|
443 // WebPointerEventHandler::doTapL |
|
444 //----------------------------------------------------------------------------- |
|
445 void WebPointerEventHandler::doTapL() |
|
446 { |
|
447 TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType(); |
|
448 Frame* coreFrame = core(m_webview->mainFrame()); |
|
449 |
|
450 #ifdef BRDO_TOUCH_ENABLED_FF |
|
451 if (m_isHighlighted) |
|
452 { |
|
453 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
454 if (feedback) |
|
455 { |
|
456 feedback->InstantFeedback(ETouchFeedbackBasic); |
|
457 } |
|
458 } |
|
459 #endif // BRDO_TOUCH_ENABLED_FF |
|
460 |
|
461 |
|
462 // We assume that if element visibility has been changed |
|
463 // between "up" and "down" that means that some node event |
|
464 // listener (onMouseOver etc) handling happened and we don't |
|
465 // want to send a click (mouse press + mouse release) event. |
|
466 if (m_webview->page()->chrome()->client()->elementVisibilityChanged()) { |
|
467 return; |
|
468 } |
|
469 |
|
470 m_lastTapEvent.iPosition = m_buttonDownEvent.iPosition; |
|
471 m_lastTapEvent.iType = TPointerEvent::EButton1Up; |
|
472 m_lastTapEvent.iModifiers = 0; |
|
473 |
|
474 // don't pass the event if the text input is not in valid format |
|
475 if (isHighlitableElement(elType) || m_webview->fepTextEditor()->validateTextFormat()) { |
|
476 // because of scrolling we delay sending EButton1Down till we get EButton1Up event and if the content is not scrolling |
|
477 coreFrame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(m_buttonDownEvent)); |
|
478 coreFrame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(m_lastTapEvent)); |
|
479 } |
|
480 |
|
481 // special handling for broken image (why is this here??) |
|
482 if (m_webview->focusedElementType() == TBrCtlDefs::EElementBrokenImage) { |
|
483 loadFocusedImage(m_webview); |
|
484 } |
|
485 else if (elType == TBrCtlDefs::EElementActivatedObjectBox) { |
|
486 PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin(); |
|
487 if(plugin && plugin->pluginWin() && plugin->getClipRect().Contains(m_lastTapEvent.iPosition)){ |
|
488 plugin->pluginWin()->HandlePointerEventL(m_lastTapEvent); |
|
489 } |
|
490 } |
|
491 else { |
|
492 m_webview->activateVirtualKeyboard(); |
|
493 } |
|
494 } |
|
495 |
|
496 |
|
497 //----------------------------------------------------------------------------- |
|
498 // WebPointerEventHandler::deHighlight |
|
499 //----------------------------------------------------------------------------- |
|
500 void WebPointerEventHandler::dehighlight() |
|
501 { |
|
502 // send dehighlight event to engine by passing -1, -1 |
|
503 // sending any other pointer value may result in highligh of other links |
|
504 m_highlightPos = TPoint(-1, -1); |
|
505 m_isHighlighted = EFalse; |
|
506 TPointerEvent event; |
|
507 event.iType = TPointerEvent::EMove; |
|
508 event.iPosition = m_highlightPos; |
|
509 event.iModifiers = 0; |
|
510 |
|
511 Frame* coreFrame = core(m_webview->mainFrame()); |
|
512 Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame(); |
|
513 frm->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event)); |
|
514 |
|
515 |
|
516 m_highlightedNode = NULL; |
|
517 |
|
518 m_webview->syncRepaint(); |
|
519 } |
|
520 |
|
521 |
|
522 //----------------------------------------------------------------------------- |
|
523 // WebPointerEventHandler::canDehighlight |
|
524 //----------------------------------------------------------------------------- |
|
525 bool WebPointerEventHandler::canDehighlight(const TPoint &aPoint) |
|
526 { |
|
527 TBool checkDehighlight = true; |
|
528 |
|
529 if (!m_webview->viewIsScrolling()) |
|
530 { |
|
531 WebFrame* frm = StaticObjectsContainer::instance()->webCursor()->getFrameUnderCursor(); |
|
532 IntPoint framePoint = frm->frameView()->viewCoordsInFrameCoords(aPoint); |
|
533 if (m_highlightedNode->getRect().contains(framePoint)) { |
|
534 checkDehighlight = false; |
|
535 } // check if new points are coming towards closest element |
|
536 else if(m_offset) { |
|
537 //Calculate the new offset |
|
538 IntPoint nodePoint = m_highlightedNode->getRect().Rect().Center(); |
|
539 TInt newoffset = (framePoint.x()- nodePoint.x())*(framePoint.x()- nodePoint.x()) + (framePoint.y()- nodePoint.y())*(framePoint.y()- nodePoint.y()); |
|
540 |
|
541 if(newoffset <= m_offset ) { |
|
542 m_offset = newoffset; |
|
543 checkDehighlight = false; |
|
544 } |
|
545 else { |
|
546 m_offset =0; |
|
547 checkDehighlight = true; |
|
548 } |
|
549 } |
|
550 } |
|
551 |
|
552 return checkDehighlight; |
|
553 } |
|
554 |
|
555 |
|
556 //----------------------------------------------------------------------------- |
|
557 // WebPointerEventHandler::buttonDownTimerCallback |
|
558 //----------------------------------------------------------------------------- |
|
559 void WebPointerEventHandler::buttonDownTimerCB(Timer<WebPointerEventHandler>* t) |
|
560 { |
|
561 m_buttonDownTimer.stop(); |
|
562 |
|
563 WebCursor* cursor = StaticObjectsContainer::instance()->webCursor(); |
|
564 |
|
565 Frame* coreFrame = core(m_webview->mainFrame()); |
|
566 TPointerEvent event; |
|
567 |
|
568 TBrCtlDefs::TBrCtlElementType elType = highlitableElement(); |
|
569 |
|
570 if (!isHighlitableElement(elType)) { |
|
571 elType = TBrCtlDefs::EElementNone; |
|
572 } |
|
573 m_isHighlighted = (m_highlightedNode != NULL) && (elType != TBrCtlDefs::EElementNone) ; |
|
574 |
|
575 event.iPosition = m_highlightPos; |
|
576 event.iModifiers = 0; |
|
577 event.iType = TPointerEvent::EMove; |
|
578 |
|
579 coreFrame->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event)); |
|
580 m_waiter->AsyncStop(); |
|
581 } |
|
582 |
|
583 |
|
584 //----------------------------------------------------------------------------- |
|
585 // WebPointerEventHandler::updateCursor |
|
586 //---------------------------------------------------------------------------- |
|
587 void WebPointerEventHandler::updateCursor(const TPoint& pos) |
|
588 { |
|
589 WebCursor* cursor = StaticObjectsContainer::instance()->webCursor(); |
|
590 if (cursor) { |
|
591 if (pos != TPoint(0, 0)) { |
|
592 cursor->setPosition(pos); |
|
593 } |
|
594 if (m_webview->showCursor()) { |
|
595 cursor->resetTransparency(); |
|
596 m_webview->setShowCursor(false); |
|
597 cursor->cursorUpdate(false); |
|
598 } |
|
599 } |
|
600 } |