changeset 5 | 10e98eab6f85 |
parent 1 | 7c90e6132015 |
child 10 | a359256acfc6 |
1:7c90e6132015 | 5:10e98eab6f85 |
---|---|
57 #include "WebPageScrollHandler.h" |
57 #include "WebPageScrollHandler.h" |
58 #include "WebPopupDrawer.h" |
58 #include "WebPopupDrawer.h" |
59 #include "PluginSkin.h" |
59 #include "PluginSkin.h" |
60 #include "PluginWin.h" |
60 #include "PluginWin.h" |
61 #include "PluginPlayer.h" |
61 #include "PluginPlayer.h" |
62 #include "WebKitLogger.h" |
|
62 |
63 |
63 |
64 |
64 #include "Page.h" |
65 #include "Page.h" |
65 #include "Settings.h" |
66 #include "Settings.h" |
66 #include "Frame.h" |
67 #include "Frame.h" |
81 #include "FocusController.h" |
82 #include "FocusController.h" |
82 #include "WebUtil.h" |
83 #include "WebUtil.h" |
83 #include "WidgetExtension.h" |
84 #include "WidgetExtension.h" |
84 #include "Cache.h" |
85 #include "Cache.h" |
85 #include "RenderWidget.h" |
86 #include "RenderWidget.h" |
87 #include "HTMLNames.h" |
|
88 #include "HTMLInputElement.h" |
|
89 |
|
90 using namespace HTMLNames; |
|
86 |
91 |
87 #include <AknUtils.h> |
92 #include <AknUtils.h> |
88 #include <CUserAgent.h> |
93 #include <CUserAgent.h> |
89 #include "WebPageZoomHandler.h" |
94 #include "WebPageZoomHandler.h" |
90 |
95 |
96 |
101 |
97 using namespace WebCore; |
102 using namespace WebCore; |
98 |
103 |
99 const int KRepaintDelayLoading = 500*1000; // dont do repaints more often than this during loading (0.5s) |
104 const int KRepaintDelayLoading = 500*1000; // dont do repaints more often than this during loading (0.5s) |
100 const int KRepaintDelayComplete = 100*1000; // faster updates after load so dynamic scripts etc have better frame rate (0.1s) |
105 const int KRepaintDelayComplete = 100*1000; // faster updates after load so dynamic scripts etc have better frame rate (0.1s) |
106 const int KRepaintDelayNavNone = 70*1000; |
|
101 const int KNormalScrollRange = 60; |
107 const int KNormalScrollRange = 60; |
102 |
108 |
103 const int KPanningStartSpeed = 30; |
109 const int KPanningStartSpeed = 30; |
104 const int KPanningStartTime = 900; |
110 const int KPanningStartTime = 900; |
105 const int KPanningPageScalerStart = 1300; |
111 const int KPanningPageScalerStart = 1300; |
183 , m_minZoomLevel(KZoomLevelMinValue) |
189 , m_minZoomLevel(KZoomLevelMinValue) |
184 , m_defaultZoomLevel(KZoomLevelDefaultValue) |
190 , m_defaultZoomLevel(KZoomLevelDefaultValue) |
185 , m_pageFullScreenHandler(NULL) |
191 , m_pageFullScreenHandler(NULL) |
186 , m_viewIsScrolling(false) |
192 , m_viewIsScrolling(false) |
187 , m_ptrbuffer(0) |
193 , m_ptrbuffer(0) |
188 , m_pluginActivated(false) |
|
189 , m_showCursor(false) |
194 , m_showCursor(false) |
190 , m_allowRepaints(true) |
195 , m_allowRepaints(true) |
191 { |
196 { |
192 } |
197 } |
193 |
198 |
197 // WebView--a circular dependency) so it must be deleted before |
202 // WebView--a circular dependency) so it must be deleted before |
198 // the WebView object is destroyed because in its destructor it |
203 // the WebView object is destroyed because in its destructor it |
199 // operates on the WebView object |
204 // operates on the WebView object |
200 delete m_pageZoomHandler; |
205 delete m_pageZoomHandler; |
201 m_pageZoomHandler = NULL; |
206 m_pageZoomHandler = NULL; |
207 |
|
208 m_zoomLevelArray.Close(); |
|
202 |
209 |
203 // prevent frameViews to access members when topView is |
210 // prevent frameViews to access members when topView is |
204 // closing down. |
211 // closing down. |
205 m_isClosing = true; |
212 m_isClosing = true; |
206 m_page->setGroupName(String()); |
213 m_page->setGroupName(String()); |
227 delete m_fepTimer; |
234 delete m_fepTimer; |
228 delete m_popupDrawer; |
235 delete m_popupDrawer; |
229 delete m_tabbedNavigation; |
236 delete m_tabbedNavigation; |
230 delete m_userAgent; |
237 delete m_userAgent; |
231 delete m_pageFullScreenHandler; |
238 delete m_pageFullScreenHandler; |
239 delete m_bridge; |
|
240 delete m_frameView; |
|
232 } |
241 } |
233 |
242 |
234 // ----------------------------------------------------------------------------- |
243 // ----------------------------------------------------------------------------- |
235 // WebView::ConstructL |
244 // WebView::ConstructL |
236 // Private Class Method |
245 // Private Class Method |
240 { |
249 { |
241 SetContainerWindowL(parent); |
250 SetContainerWindowL(parent); |
242 |
251 |
243 CCoeControl::MakeVisible(ETrue); |
252 CCoeControl::MakeVisible(ETrue); |
244 |
253 |
245 WebFrameView *frameView = new WebFrameView(); |
254 m_frameView = new WebFrameView(); |
246 m_page = new Page(new WebChromeClient(this), new WebContextMenuClient(), new WebEditorClient(this), new WebDragClient(), new WebInspectorClient()); |
255 m_page = new Page(new WebChromeClient(this), new WebContextMenuClient(), new WebEditorClient(this), new WebDragClient(), new WebInspectorClient()); |
247 m_page->backForwardList()->setCapacity(0); |
256 m_page->backForwardList()->setCapacity(0); |
248 m_page->setGroupName("com.s60.browser"); |
257 m_page->setGroupName("com.s60.browser"); |
249 // |
258 // |
250 WebCore::Settings* settings = m_page->settings(); |
259 WebCore::Settings* settings = m_page->settings(); |
259 settings->setJavaScriptCanOpenWindowsAutomatically(true); |
268 settings->setJavaScriptCanOpenWindowsAutomatically(true); |
260 settings->setPluginsEnabled(true); |
269 settings->setPluginsEnabled(true); |
261 |
270 |
262 m_tabbedNavigation = new WebTabbedNavigation(this); |
271 m_tabbedNavigation = new WebTabbedNavigation(this); |
263 |
272 |
264 WebFrameBridge* bridge = new WebFrameBridge(); |
273 m_bridge = new WebFrameBridge(); |
265 bridge->initMainFrameWithPage(m_page, "", frameView); |
274 m_bridge->initMainFrameWithPage(m_page, "", m_frameView); |
266 |
275 |
267 // Create and offscreen device and context |
276 // Create and offscreen device and context |
268 m_bitmapdevice = CFbsBitmapDevice::NewL( StaticObjectsContainer::instance()->webSurface()->offscreenBitmap() ); |
277 m_bitmapdevice = CFbsBitmapDevice::NewL( StaticObjectsContainer::instance()->webSurface()->offscreenBitmap() ); |
269 m_webcorecontext = WebCoreGraphicsContext::NewL( m_bitmapdevice, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), mainFrame()->frameView()); |
278 m_webcorecontext = WebCoreGraphicsContext::NewL( m_bitmapdevice, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), mainFrame()->frameView()); |
270 // |
279 // |
362 // WebView::Draw ( from CCoeControl ) |
371 // WebView::Draw ( from CCoeControl ) |
363 // BitBlts the offscreen bitmap to the GraphicsContext |
372 // BitBlts the offscreen bitmap to the GraphicsContext |
364 //------------------------------------------------------------------------------- |
373 //------------------------------------------------------------------------------- |
365 void WebView::Draw( const TRect& rect ) const |
374 void WebView::Draw( const TRect& rect ) const |
366 { |
375 { |
367 if (m_pluginFullscreen) return; |
376 if (StaticObjectsContainer::instance()->isPluginFullscreen()) return; |
368 |
377 |
369 CWindowGc& gc = SystemGc(); |
378 CWindowGc& gc = SystemGc(); |
370 CEikBorderedControl::Draw( rect ); |
379 CEikBorderedControl::Draw( rect ); |
371 |
380 |
372 // put offscreen bitmap onto the screen |
381 // put offscreen bitmap onto the screen |
547 |
556 |
548 if (!IsVisible()) { |
557 if (!IsVisible()) { |
549 return; |
558 return; |
550 } |
559 } |
551 |
560 |
552 if (isPluginFullscreen()) return; |
561 if (StaticObjectsContainer::instance()->isPluginFullscreen()) return; |
553 CFbsBitGc& gc = m_webcorecontext->gc(); |
562 CFbsBitGc& gc = m_webcorecontext->gc(); |
554 gc.Reset(); |
563 gc.Reset(); |
555 |
564 |
556 TRect viewRect( mainFrame()->frameView()->visibleRect() ); |
565 TRect viewRect( mainFrame()->frameView()->visibleRect() ); |
557 TPoint p( mainFrame()->frameView()->contentPos()); |
566 TPoint p( mainFrame()->frameView()->contentPos()); |
558 Frame* f = m_page->mainFrame(); |
567 Frame* f = m_page->mainFrame(); |
559 bool layoutPending = false; |
568 bool layoutPending = false; |
560 while (f && !layoutPending) { |
569 while (f && !layoutPending) { |
561 layoutPending = f->view()->layoutPending(); |
570 layoutPending = f->view()->layoutPending(); |
562 f = f->tree()->traverseNext(); |
571 f = f->tree()->traverseNext(); |
572 } |
|
573 |
|
574 if (layoutPending && m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone) { |
|
575 Frame* f = m_page->mainFrame(); |
|
576 while ( f ) { |
|
577 f->view()->layout(); |
|
578 f = f->tree()->traverseNext(); |
|
579 } |
|
580 layoutPending = false; |
|
563 } |
581 } |
564 if (!layoutPending) { |
582 if (!layoutPending) { |
565 bool needsDraw = false; |
583 bool needsDraw = false; |
566 m_repaints.Tidy(); |
584 m_repaints.Tidy(); |
567 for (int i=0; i<m_repaints.Count(); ++i) { |
585 for (int i=0; i<m_repaints.Count(); ++i) { |
586 } |
604 } |
587 m_repainttimer->Cancel(); |
605 m_repainttimer->Cancel(); |
588 // tot:fixme TBool complete = iWebkitControl->IsProgressComplete(); && CImageRendererFactory::Instance()->DecodeCount()==0; |
606 // tot:fixme TBool complete = iWebkitControl->IsProgressComplete(); && CImageRendererFactory::Instance()->DecodeCount()==0; |
589 |
607 |
590 TBool complete = ETrue; |
608 TBool complete = ETrue; |
609 int timeout = complete ? KRepaintDelayComplete : KRepaintDelayLoading; |
|
610 if (complete && m_brctl->settings() && m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone) |
|
611 timeout = KRepaintDelayNavNone; |
|
591 if ( !m_pageZoomHandler->isActive() && m_allowRepaints){ |
612 if ( !m_pageZoomHandler->isActive() && m_allowRepaints){ |
592 m_repainttimer->Start(complete ? KRepaintDelayComplete : KRepaintDelayLoading, |
613 m_repainttimer->Start(timeout, |
593 0, TCallBack( &doRepaintCb, this ) ); |
614 0, TCallBack( &doRepaintCb, this ) ); |
594 } |
615 } |
595 // need to draw formfill popup here. |
616 // need to draw formfill popup here. |
596 if (m_webFormFillPopup && m_webFormFillPopup->IsVisible()) { |
617 if (m_webFormFillPopup && m_webFormFillPopup->IsVisible()) { |
597 m_webFormFillPopup->reDraw(); |
618 m_webFormFillPopup->reDraw(); |
631 // WebView::collectOffscreenbitmap |
652 // WebView::collectOffscreenbitmap |
632 // Get offscreen bitmap |
653 // Get offscreen bitmap |
633 //------------------------------------------------------------------------------- |
654 //------------------------------------------------------------------------------- |
634 void WebView::collectOffscreenbitmapL(CFbsBitmap& snapshot) |
655 void WebView::collectOffscreenbitmapL(CFbsBitmap& snapshot) |
635 { |
656 { |
636 |
657 if ( snapshot.Handle() == 0) { |
637 (snapshot).Create(m_brctl->Size(), StaticObjectsContainer::instance()->webSurface()->displayMode()); |
658 // Create bitmap only once |
638 |
659 (snapshot).Create(m_brctl->Size(), StaticObjectsContainer::instance()->webSurface()->displayMode()); |
660 } |
|
639 CFbsBitmapDevice* device = CFbsBitmapDevice::NewL( &snapshot); |
661 CFbsBitmapDevice* device = CFbsBitmapDevice::NewL( &snapshot); |
640 CleanupStack::PushL(device); |
662 CleanupStack::PushL(device); |
641 |
663 |
642 WebCoreGraphicsContext* gc = WebCoreGraphicsContext::NewL( device, &snapshot, mainFrame()->frameView()); |
664 WebCoreGraphicsContext* gc = WebCoreGraphicsContext::NewL( device, &snapshot, mainFrame()->frameView()); |
643 CleanupStack::PushL(gc); |
665 CleanupStack::PushL(gc); |
644 |
666 |
667 if( snapshot.Handle() != 0 ){ |
|
668 // Clear previous offscreen bitmap |
|
669 // frameView->draw might clear the bitmap. |
|
670 gc->gc().Clear(); |
|
671 } else if (snapshot.SizeInPixels()!=m_brctl->Size()){ |
|
672 snapshot.Resize(m_brctl->Size()); |
|
673 } |
|
645 mainFrame()->frameView()->draw( *gc, mainFrame()->frameView()->visibleRect() ); |
674 mainFrame()->frameView()->draw( *gc, mainFrame()->frameView()->visibleRect() ); |
646 |
675 |
647 CleanupStack::PopAndDestroy(2); |
676 CleanupStack::PopAndDestroy(2); |
648 |
677 |
649 } |
678 } |
671 } |
700 } |
672 } |
701 } |
673 |
702 |
674 void WebView::pageLoadFinished() |
703 void WebView::pageLoadFinished() |
675 { |
704 { |
676 |
705 if (m_brctl->settings()) { |
677 if (m_brctl->settings() && m_brctl->settings()->getTabbedNavigation()) { |
706 switch (m_brctl->settings()->getNavigationType()) { |
678 m_tabbedNavigation->initializeForPage(); |
707 case SettingsContainer::NavigationTypeTabbed: |
679 } |
708 m_tabbedNavigation->initializeForPage(); |
680 else { |
709 break; |
681 |
710 case SettingsContainer::NavigationTypeNone: |
682 // Temp solution to fix a problem with scrolling large pages: |
711 break; |
683 // if user starts scrolling while loading a page - at the end of the load we should not restore |
712 case SettingsContainer::NavigationTypeCursor: |
684 // the content position from the history controller |
713 { |
685 // As of now scroll events are not passed to WebCore and this will be changed in future |
714 |
686 // then this code should be replaces with the commented one below |
715 // Temp solution to fix a problem with scrolling large pages: |
687 |
716 // if user starts scrolling while loading a page - at the end of the load we should not restore |
688 TPoint ptInit(0,0); |
717 // the content position from the history controller |
689 TPoint ptFromHistory = m_brctl->historyHandler()->historyController()->currentEntryPosition(); |
718 // As of now scroll events are not passed to WebCore and this will be changed in future |
690 TPoint ptCurr = mainFrame()->frameView()->contentPos(); |
719 // then this code should be replaces with the commented one below |
691 |
720 |
692 if ( ptCurr != ptFromHistory ) { |
721 TPoint ptInit(0,0); |
693 if ( ptInit == ptCurr ) { |
722 TPoint ptFromHistory = m_brctl->historyHandler()->historyController()->currentEntryPosition(); |
694 mainFrame()->frameView()->scrollTo(ptFromHistory); |
723 TPoint ptCurr = mainFrame()->frameView()->contentPos(); |
724 |
|
725 if ( ptCurr != ptFromHistory ) { |
|
726 if ( ptInit == ptCurr ) { |
|
727 mainFrame()->frameView()->scrollTo(ptFromHistory); |
|
728 } |
|
729 else { |
|
730 m_brctl->historyHandler()->historyController()->updateCurrentEntryPositionIfNeeded(); |
|
731 } |
|
732 } |
|
733 /* |
|
734 if ( !core(mainFrame())->view()->wasScrolledByUser()) |
|
735 mainFrame()->frameView()->scrollTo(m_brctl->historyHandler()->historyController()->currentEntryPosition());*/ |
|
736 break; |
|
695 } |
737 } |
696 else { |
738 } |
697 m_brctl->historyHandler()->historyController()->updateCurrentEntryPositionIfNeeded(); |
|
698 } |
|
699 } |
|
700 /* |
|
701 if ( !core(mainFrame())->view()->wasScrolledByUser()) |
|
702 mainFrame()->frameView()->scrollTo(m_brctl->historyHandler()->historyController()->currentEntryPosition());*/ |
|
703 |
|
704 } |
739 } |
705 |
740 |
706 if (FrameLoadTypeStandard == core( mainFrame())->loader()->loadType()){ |
741 if (FrameLoadTypeStandard == core( mainFrame())->loader()->loadType()){ |
707 if (m_brctl->capabilities()&TBrCtlDefs::ECapabilityFitToScreen){ |
742 if (m_brctl->capabilities()&TBrCtlDefs::ECapabilityFitToScreen){ |
708 updateMinZoomLevel( mainFrame()->frameView()->contentSize()); |
743 updateMinZoomLevel( mainFrame()->frameView()->contentSize()); |
784 if ( aIndex == 0) |
819 if ( aIndex == 0) |
785 if ( m_webFormFillPopup && m_webFormFillPopup->IsVisible()) rv = m_webFormFillPopup; |
820 if ( m_webFormFillPopup && m_webFormFillPopup->IsVisible()) rv = m_webFormFillPopup; |
786 |
821 |
787 return rv; |
822 return rv; |
788 } |
823 } |
824 |
|
825 |
|
789 |
826 |
790 bool WebView::isNaviKey(const TKeyEvent& keyevent) |
827 bool WebView::isNaviKey(const TKeyEvent& keyevent) |
791 { |
828 { |
792 return ( keyevent.iCode == EKeyUpArrow // North |
829 return ( keyevent.iCode == EKeyUpArrow // North |
793 || keyevent.iCode == EKeyRightUpArrow // Northeast |
830 || keyevent.iCode == EKeyRightUpArrow // Northeast |
798 || keyevent.iCode == EKeyDownArrow // South |
835 || keyevent.iCode == EKeyDownArrow // South |
799 || keyevent.iCode == EKeyLeftDownArrow // Southwest |
836 || keyevent.iCode == EKeyLeftDownArrow // Southwest |
800 || keyevent.iCode == EStdKeyDevice13 // : Extra KeyEvent supports diagonal event simulator wedge |
837 || keyevent.iCode == EStdKeyDevice13 // : Extra KeyEvent supports diagonal event simulator wedge |
801 || keyevent.iCode == EKeyLeftArrow // West |
838 || keyevent.iCode == EKeyLeftArrow // West |
802 || keyevent.iCode == EKeyLeftUpArrow // Northwest |
839 || keyevent.iCode == EKeyLeftUpArrow // Northwest |
803 || keyevent.iCode == EStdKeyDevice10); |
840 || keyevent.iCode == EStdKeyDevice10); |
804 } |
841 } |
805 |
842 |
806 bool WebView::handleEditable(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame ) |
843 bool WebView::handleEditable(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame ) |
807 { |
844 { |
808 bool consumed = false; |
845 bool consumed = false; |
846 if (eventcode == EEventKeyDown) |
|
847 return false; |
|
809 consumed = frame->eventHandler()->keyEvent(PlatformKeyboardEvent(keyevent,eventcode)); |
848 consumed = frame->eventHandler()->keyEvent(PlatformKeyboardEvent(keyevent,eventcode)); |
810 // exit input on up/down key |
849 // exit input on up/down key |
811 // EXCEPT on touch-enabled devices. We'll just consume in that case |
850 // EXCEPT on touch-enabled devices. We'll just consume in that case |
812 if ( !consumed && isNaviKey(keyevent) ) { |
851 if ( !consumed && isNaviKey(keyevent) ) { |
813 if (m_webfeptexteditor->validateTextFormat() ) { |
852 if (m_webfeptexteditor->validateTextFormat() ) { |
814 setFocusNone(); |
853 setFocusNone(); |
815 } |
854 } |
816 else { |
855 else { |
817 consumed = true; |
856 consumed = true; |
818 } |
857 } |
819 } |
858 } |
820 |
859 |
821 return consumed; |
860 return consumed; |
822 } |
861 } |
823 |
862 |
824 |
863 |
825 bool WebView::handleEventKeyDown(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame) |
864 bool WebView::handleEventKeyDown(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame) |
834 { |
873 { |
835 TPointerEvent event; |
874 TPointerEvent event; |
836 event.iPosition = pos; |
875 event.iPosition = pos; |
837 event.iModifiers = 0; |
876 event.iModifiers = 0; |
838 event.iType = eventType; |
877 event.iType = eventType; |
839 |
878 |
840 switch (eventType) { |
879 switch (eventType) { |
841 case TPointerEvent::EButton1Down: |
880 case TPointerEvent::EButton1Down: |
842 { |
881 { |
843 frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event)); |
882 frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event)); |
844 break; |
883 break; |
845 } |
884 } |
846 |
885 |
847 case TPointerEvent::EButton1Up: |
886 case TPointerEvent::EButton1Up: |
848 { |
887 { |
849 frame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event)); |
888 frame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event)); |
850 break; |
889 break; |
851 } |
890 } |
852 |
891 |
853 case TPointerEvent::EMove: |
892 case TPointerEvent::EMove: |
854 { |
893 { |
855 frame->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event)); |
894 frame->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event)); |
856 break; |
895 break; |
857 } |
896 } |
858 }; |
897 }; |
859 } |
898 } |
860 |
899 |
873 { |
912 { |
874 WebCursor* cursor = StaticObjectsContainer::instance()->webCursor(); |
913 WebCursor* cursor = StaticObjectsContainer::instance()->webCursor(); |
875 bool consumed = false; |
914 bool consumed = false; |
876 |
915 |
877 TKeyEvent oldKeyEvent(m_currentEventKey); |
916 TKeyEvent oldKeyEvent(m_currentEventKey); |
917 oldKeyEvent.iCode = keyevent.iCode; |
|
918 TEventCode oldKeyCode = m_currentEventCode; |
|
878 bool downEventConsumed = false; |
919 bool downEventConsumed = false; |
879 if (m_currentEventCode == EEventKeyDown && |
|
880 keyevent.iCode != EKeyDevice3 ){ |
|
881 sendKeyEventToEngine(oldKeyEvent, EEventKeyDown, frame); |
|
882 } |
|
883 m_currentEventKey = keyevent; |
920 m_currentEventKey = keyevent; |
884 m_currentEventCode = eventcode; |
921 m_currentEventCode = eventcode; |
885 if (keyevent.iCode == EKeyDevice3) { |
922 |
886 // pass it to webcore |
923 if (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone) { |
887 sendMouseEventToEngine(TPointerEvent::EButton1Down, |
924 consumed = handleInputElement(keyevent, eventcode, frame); |
888 cursor->position(), frame); |
925 if (!consumed) |
889 |
926 consumed = sendKeyEventToEngine(keyevent, eventcode, frame); |
890 // mimic ccb's behavior of onFocus |
927 } |
891 setFocusedNode(frame); |
928 else { |
892 |
929 if (keyevent.iCode == EKeyDevice3) { |
893 // Toolbar is activated on long key press only if the element |
930 // pass it to webcore |
894 // type is EElementNone during EEventKeyDown and EEventKey. |
931 sendMouseEventToEngine(TPointerEvent::EButton1Down, |
895 // This prevents toolbar from popping up in DHTML pages. Also, |
932 cursor->position(), frame); |
896 // toolbar is activated when the user is not in fast scroll |
933 |
897 // mode, or in page overview mode, or on wml page. |
934 // mimic ccb's behavior of onFocus |
898 if ( ( m_focusedElementType == TBrCtlDefs::EElementNone || |
935 setFocusedNode(frame); |
899 m_focusedElementType == TBrCtlDefs::EElementBrokenImage ) && |
936 |
900 keyevent.iRepeats && !m_brctl->wmlMode() ) { |
937 // Toolbar is activated on long key press only if the element |
901 launchToolBarL(); |
938 // type is EElementNone during EEventKeyDown and EEventKey. |
902 } |
939 // This prevents toolbar from popping up in DHTML pages. Also, |
903 consumed = true; |
940 // toolbar is activated when the user is not in fast scroll |
904 } |
941 // mode, or in page overview mode, or on wml page. |
905 else if (isNaviKey(keyevent)) { |
942 if ( ( m_focusedElementType == TBrCtlDefs::EElementNone || |
906 if (m_brctl->settings()->getTabbedNavigation()) { |
943 m_focusedElementType == TBrCtlDefs::EElementBrokenImage ) && |
907 consumed = downEventConsumed || handleTabbedNavigation(keyevent, eventcode); |
944 keyevent.iRepeats && !m_brctl->wmlMode() ) { |
908 } |
945 launchToolBarL(); |
909 else { |
946 } |
910 consumed = handleKeyNavigation(keyevent, eventcode, frame); |
947 consumed = true; |
911 } |
948 } |
912 } // if (m_brctl->settings()->getTabbedNavigation() |
949 else if (isNaviKey(keyevent)) { |
913 else { // Not an arrow key.. |
950 |
914 // activate hovered input element by just start typing |
951 if (oldKeyCode == EEventKeyDown){ |
915 consumed = handleInputElement(keyevent, eventcode, frame); |
952 // Keydown event is automatically generated before each keypress event, but in this case |
916 } |
953 // we don't send a keypress event, so send a keydown event explicitly. |
917 |
954 downEventConsumed = sendKeyEventToEngine(oldKeyEvent, EEventKeyDown, frame); |
918 if (!consumed) { |
955 } |
919 consumed = sendKeyEventToEngine(keyevent, eventcode, frame); |
956 |
920 } |
957 |
958 if (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed) { |
|
959 consumed = downEventConsumed || handleTabbedNavigation(keyevent, eventcode); |
|
960 } |
|
961 else { |
|
962 consumed = handleKeyNavigation(keyevent, eventcode, frame); |
|
963 } |
|
964 } // if (m_brctl->settings()->getNavigationType() |
|
965 else { // Not an arrow key.. |
|
966 // activate hovered input element by just start typing |
|
967 consumed = handleInputElement(keyevent, eventcode, frame); |
|
968 } |
|
969 if (!consumed && !(m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed && isNaviKey(keyevent))) { |
|
970 consumed = sendKeyEventToEngine(keyevent, eventcode, frame); |
|
971 } |
|
972 } |
|
921 return consumed; |
973 return consumed; |
922 } |
974 } |
923 |
975 |
924 |
976 |
925 bool WebView::handleInputElement(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame) |
977 bool WebView::handleInputElement(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame) |
926 { |
978 { |
927 WebCursor* cursor = StaticObjectsContainer::instance()->webCursor(); |
979 WebCursor* cursor = StaticObjectsContainer::instance()->webCursor(); |
928 if (m_focusedElementType == TBrCtlDefs::EElementInputBox || |
980 bool sendMousedEvent = false; |
929 m_focusedElementType == TBrCtlDefs::EElementSelectBox || |
981 if (m_focusedElementType == TBrCtlDefs::EElementInputBox || |
930 m_focusedElementType == TBrCtlDefs::EElementSelectMultiBox || |
|
931 m_focusedElementType == TBrCtlDefs::EElementTextAreaBox) { |
982 m_focusedElementType == TBrCtlDefs::EElementTextAreaBox) { |
932 |
983 sendMousedEvent = true; |
984 } |
|
985 else if (m_focusedElementType == TBrCtlDefs::EElementSelectBox || |
|
986 m_focusedElementType == TBrCtlDefs::EElementSelectMultiBox) { |
|
987 if (m_brctl->settings()->getNavigationType() != SettingsContainer::NavigationTypeNone || keyevent.iCode == EKeyDevice3) { |
|
988 sendMousedEvent = true; |
|
989 } |
|
990 } |
|
991 if (sendMousedEvent) { |
|
933 sendMouseEventToEngine(TPointerEvent::EButton1Down, cursor->position(), frame); |
992 sendMouseEventToEngine(TPointerEvent::EButton1Down, cursor->position(), frame); |
934 sendMouseEventToEngine(TPointerEvent::EButton1Up, cursor->position(), frame); |
993 sendMouseEventToEngine(TPointerEvent::EButton1Up, cursor->position(), frame); |
935 |
994 |
936 if (m_focusedElementType == TBrCtlDefs::EElementInputBox || |
995 if (m_focusedElementType == TBrCtlDefs::EElementInputBox || |
937 m_focusedElementType == TBrCtlDefs::EElementTextAreaBox) { |
996 m_focusedElementType == TBrCtlDefs::EElementTextAreaBox) { |
938 if (!m_fepTimer) { |
997 if (!m_fepTimer) { |
939 m_fepTimer = new WebCore::Timer<WebView>(this, &WebView::fepTimerFired); |
998 m_fepTimer = new WebCore::Timer<WebView>(this, &WebView::fepTimerFired); |
940 } |
999 } |
941 |
1000 |
942 m_fepTimer->startOneShot(0.2f); |
1001 m_fepTimer->startOneShot(0.2f); |
943 setEditable(true); |
1002 setEditable(true); |
944 } |
1003 } |
945 m_keyevent = keyevent; |
1004 m_keyevent = keyevent; |
946 m_eventcode = eventcode; |
1005 m_eventcode = eventcode; |
947 } |
1006 return true; |
948 return true; |
1007 } |
1008 return false; // not input element |
|
949 } |
1009 } |
950 |
1010 |
951 |
1011 |
952 bool WebView::handleKeyNavigation(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame) |
1012 bool WebView::handleKeyNavigation(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame) |
953 { |
1013 { |
958 // start fast scrolling |
1018 // start fast scrolling |
959 m_showCursor = true; |
1019 m_showCursor = true; |
960 if (!cursor->isVisible()) { |
1020 if (!cursor->isVisible()) { |
961 cursor->cursorUpdate(true); |
1021 cursor->cursorUpdate(true); |
962 } |
1022 } |
963 |
1023 |
964 m_savedPosition = mainFrame()->frameView()->contentPos(); |
1024 m_savedPosition = mainFrame()->frameView()->contentPos(); |
965 cursor->scrollAndMoveCursor(keyevent.iCode, m_scrollingSpeed, fastscroll); |
1025 cursor->scrollAndMoveCursor(keyevent.iCode, m_scrollingSpeed, fastscroll); |
966 updateScrollbars(); |
1026 updateScrollbars(); |
967 if (!fastscroll) { |
1027 if (!fastscroll) { |
968 m_fastScrollTimer->Start(KCursorInitialDelay,KCursorUpdateFrquency,TCallBack(&scrollTimerCb,this)); |
1028 m_fastScrollTimer->Start(KCursorInitialDelay,KCursorUpdateFrquency,TCallBack(&scrollTimerCb,this)); |
973 consumed = handleMinimapNavigation(); |
1033 consumed = handleMinimapNavigation(); |
974 |
1034 |
975 if (!fastscroll) { |
1035 if (!fastscroll) { |
976 sendMouseEventToEngine(TPointerEvent::EMove, cursor->position(), frame); |
1036 sendMouseEventToEngine(TPointerEvent::EMove, cursor->position(), frame); |
977 } |
1037 } |
978 |
1038 |
979 consumed = true; |
1039 consumed = true; |
980 return consumed; |
1040 return consumed; |
981 } |
1041 } |
982 |
1042 |
983 |
1043 |
984 bool WebView::handleMinimapNavigation() |
1044 bool WebView::handleMinimapNavigation() |
985 { |
1045 { |
986 int scrollingTime = millisecondsScrolled(); |
1046 int scrollingTime = millisecondsScrolled(); |
987 if (!AknLayoutUtils::PenEnabled() && m_pageScalerEnabled && |
1047 if (!AknLayoutUtils::PenEnabled() && m_pageScalerEnabled && |
988 m_pageScaler && !isSmallPage() && |
1048 m_pageScaler && !isSmallPage() && |
989 m_brctl->settings()->brctlSetting(TBrCtlDefs::ESettingsPageOverview) && |
1049 m_brctl->settings()->brctlSetting(TBrCtlDefs::ESettingsPageOverview) && |
990 (scrollingTime > KPanningPageScalerStart || m_pageScaler->Visible())) { |
1050 (scrollingTime > KPanningPageScalerStart || m_pageScaler->Visible())) { |
991 m_pageScaler->SetVisibleUntil(KScalerVisibilityTime); |
1051 m_pageScaler->SetVisibleUntil(KScalerVisibilityTime); |
992 } |
1052 } |
1049 bool WebView::handleEventKeyUp(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame) |
1109 bool WebView::handleEventKeyUp(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame) |
1050 { |
1110 { |
1051 bool consumed = false; |
1111 bool consumed = false; |
1052 TInt delay = 2 * KCursorInitialDelay; |
1112 TInt delay = 2 * KCursorInitialDelay; |
1053 WebCursor* cursor = StaticObjectsContainer::instance()->webCursor(); |
1113 WebCursor* cursor = StaticObjectsContainer::instance()->webCursor(); |
1114 |
|
1054 m_fastScrollTimer->Cancel(); |
1115 m_fastScrollTimer->Cancel(); |
1055 m_scrollingSpeed = KNormalScrollRange*100/scalingFactor(); |
1116 m_scrollingSpeed = KNormalScrollRange*100/scalingFactor(); |
1056 |
1117 |
1057 if (viewIsFastScrolling()) { |
1118 if (viewIsFastScrolling()) { |
1058 setViewIsFastScrolling(false); |
1119 setViewIsFastScrolling(false); |
1062 delay = 0; |
1123 delay = 0; |
1063 } |
1124 } |
1064 } |
1125 } |
1065 m_pageScrollHandler->scrollbarDrawer()->fadeScrollbar(delay); |
1126 m_pageScrollHandler->scrollbarDrawer()->fadeScrollbar(delay); |
1066 |
1127 |
1067 if ( (keyevent.iScanCode == EStdKeyDevice3) || |
1128 if ( (keyevent.iScanCode == EStdKeyDevice3) || |
1068 (keyevent.iScanCode == EStdKeyEnter) ) { |
1129 (keyevent.iScanCode == EStdKeyEnter) ) { |
1069 // pass it to webcore |
1130 // pass it to webcore |
1070 |
1131 |
1071 if (m_focusedElementType == TBrCtlDefs::EElementInputBox || |
1132 if (m_focusedElementType == TBrCtlDefs::EElementInputBox || |
1072 m_focusedElementType == TBrCtlDefs::EElementTextAreaBox) { |
1133 m_focusedElementType == TBrCtlDefs::EElementTextAreaBox) { |
1073 setEditable(true); |
1134 setEditable(true); |
1074 } |
1135 } |
1075 sendMouseEventToEngine(TPointerEvent::EButton1Up, cursor->position(), frame); |
1136 if (m_brctl->settings()->getNavigationType() != SettingsContainer::NavigationTypeNone) { |
1076 consumed = true; |
1137 sendMouseEventToEngine(TPointerEvent::EButton1Up, cursor->position(), frame); |
1077 } |
1138 consumed = true; |
1078 if (!consumed) { |
1139 } |
1079 sendKeyEventToEngine(keyevent, eventcode, frame); |
1140 } |
1080 } |
1141 |
1081 m_currentEventKey = KNullKeyEvent; |
1142 if (!consumed) { |
1082 m_currentEventCode = EEventNull; |
1143 |
1144 TKeyEvent correctedKeyEvent(keyevent); |
|
1145 correctedKeyEvent.iCode = m_currentEventKey.iCode; |
|
1146 sendKeyEventToEngine(correctedKeyEvent, eventcode, frame); |
|
1147 } |
|
1148 m_currentEventKey = KNullKeyEvent; |
|
1149 m_currentEventCode = EEventNull; |
|
1083 return consumed; |
1150 return consumed; |
1084 } |
1151 } |
1085 |
1152 |
1086 |
1153 |
1087 bool WebView::sendKeyEventToEngine(const TKeyEvent& keyevent, |
1154 bool WebView::sendKeyEventToEngine(const TKeyEvent& keyevent, |
1088 TEventCode eventcode, Frame* frame) |
1155 TEventCode eventcode, Frame* frame) |
1089 { |
1156 { |
1090 bool consumed = frame->eventHandler()->keyEvent(PlatformKeyboardEvent(keyevent,eventcode)); |
1157 bool consumed = frame->eventHandler()->keyEvent(PlatformKeyboardEvent(keyevent,eventcode)); |
1091 |
1158 if (!consumed && eventcode == EEventKey && |
1092 if (!consumed && eventcode == EEventKey && |
|
1093 (m_brctl->capabilities() & TBrCtlDefs::ECapabilityAccessKeys)) { |
1159 (m_brctl->capabilities() & TBrCtlDefs::ECapabilityAccessKeys)) { |
1094 |
|
1095 TKeyEvent ke = keyevent; |
1160 TKeyEvent ke = keyevent; |
1096 TChar c(ke.iCode); |
1161 TChar c(ke.iCode); |
1097 // Not consumed by WebCore, is alphanumeric and does not have any modifier |
1162 // Not consumed by WebCore, is alphanumeric and does not have any modifier |
1098 if (c.IsAlphaDigit() && |
1163 if (c.IsAlphaDigit() && |
1099 !(ke.iModifiers & (EModifierCtrl | EModifierAlt | EModifierShift))) { |
1164 !(ke.iModifiers & (EModifierCtrl | EModifierAlt | EModifierShift))) { |
1100 ke.iModifiers = EModifierCtrl; |
1165 ke.iModifiers = EModifierCtrl; |
1101 frame->eventHandler()->keyEvent(PlatformKeyboardEvent(ke,EEventKeyDown)); |
1166 frame->eventHandler()->keyEvent(PlatformKeyboardEvent(ke,EEventKeyDown)); |
1102 consumed = true; |
1167 consumed = true; |
1103 } |
1168 } |
1128 bool consumed = false; |
1193 bool consumed = false; |
1129 Frame* coreFrame = core(mainFrame()); |
1194 Frame* coreFrame = core(mainFrame()); |
1130 if (!coreFrame) |
1195 if (!coreFrame) |
1131 return EKeyWasNotConsumed; |
1196 return EKeyWasNotConsumed; |
1132 coreFrame = page()->focusController()->focusedOrMainFrame(); |
1197 coreFrame = page()->focusController()->focusedOrMainFrame(); |
1133 |
1198 |
1134 // edit events |
1199 // edit events |
1135 if (m_isEditable) { |
1200 if (m_isEditable) { |
1136 consumed = handleEditable(keyevent, eventcode, coreFrame); |
1201 consumed = handleEditable(keyevent, eventcode, coreFrame); |
1137 } |
1202 } |
1138 |
1203 |
1139 // scroll events |
1204 // scroll events |
1140 if (!consumed) { |
1205 if (!consumed) { |
1141 switch( eventcode ) { |
1206 switch( eventcode ) { |
1142 case EEventKeyDown: |
1207 case EEventKeyDown: |
1143 handleEventKeyDown(keyevent, eventcode, coreFrame); |
1208 handleEventKeyDown(keyevent, eventcode, coreFrame); |
1160 { |
1225 { |
1161 m_brctl->updateScrollbars((documentHeight * scalingFactor()) / 100, Rect().Height(), |
1226 m_brctl->updateScrollbars((documentHeight * scalingFactor()) / 100, Rect().Height(), |
1162 (displayPosY * scalingFactor()) / 100, (documentWidth * scalingFactor()) / 100, Rect().Width(), |
1227 (displayPosY * scalingFactor()) / 100, (documentWidth * scalingFactor()) / 100, Rect().Width(), |
1163 (displayPosX * scalingFactor()) / 100); |
1228 (displayPosX * scalingFactor()) / 100); |
1164 } |
1229 } |
1230 |
|
1231 |
|
1165 void WebView::updateScrollbars() |
1232 void WebView::updateScrollbars() |
1166 { |
1233 { |
1167 TPoint scrollDelta = mainFrame()->frameView()->contentPos() - m_savedPosition; |
1234 TPoint scrollDelta = mainFrame()->frameView()->contentPos() - m_savedPosition; |
1168 scrollDelta.iX *= 100; |
1235 scrollDelta.iX *= 100; |
1169 scrollDelta.iY *= 100; |
1236 scrollDelta.iY *= 100; |
1174 else { |
1241 else { |
1175 m_pageScrollHandler->scrollbarDrawer()->drawScrollbar(this, scrollDelta); |
1242 m_pageScrollHandler->scrollbarDrawer()->drawScrollbar(this, scrollDelta); |
1176 } |
1243 } |
1177 } |
1244 } |
1178 } |
1245 } |
1246 |
|
1179 |
1247 |
1180 void WebView::openPageViewL() |
1248 void WebView::openPageViewL() |
1181 { |
1249 { |
1182 // don't show pageview if we are in lite mode |
1250 // don't show pageview if we are in lite mode |
1183 if ( m_brctl->capabilities() & TBrCtlDefs::ECapabilityWebKitLite ) |
1251 if ( m_brctl->capabilities() & TBrCtlDefs::ECapabilityWebKitLite ) |
1402 return m_webfeptexteditor->InputCapabilities(); |
1470 return m_webfeptexteditor->InputCapabilities(); |
1403 } |
1471 } |
1404 |
1472 |
1405 void WebView::FocusChanged(TDrawNow aDrawNow) |
1473 void WebView::FocusChanged(TDrawNow aDrawNow) |
1406 { |
1474 { |
1407 if (m_isPluginsVisible && !m_pluginActivated) { |
|
1408 Frame* coreFrame =core(mainFrame()); |
|
1409 MWebCoreObjectWidget* view = NULL; |
|
1410 TBool focus(IsFocused()); |
|
1411 for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) { |
|
1412 PassRefPtr<HTMLCollection> objects = frame->document()->objects(); |
|
1413 for (Node* n = objects->firstItem(); n; n = objects->nextItem()) { |
|
1414 view = widget(n); |
|
1415 if (view) { |
|
1416 static_cast<PluginSkin*>(view)->viewFocusChanged(focus); |
|
1417 } |
|
1418 } |
|
1419 |
|
1420 PassRefPtr<HTMLCollection> embeds = frame->document()->embeds(); |
|
1421 for (Node* n = embeds->firstItem(); n; n = embeds->nextItem()) { |
|
1422 view = widget(n); |
|
1423 if (view) { |
|
1424 static_cast<PluginSkin*>(view)->viewFocusChanged(focus); |
|
1425 } |
|
1426 } |
|
1427 } |
|
1428 } |
|
1429 if (m_pageFullScreenHandler && m_pageFullScreenHandler->isFullScreenMode()) { |
1475 if (m_pageFullScreenHandler && m_pageFullScreenHandler->isFullScreenMode()) { |
1430 if (IsFocused()) m_pageFullScreenHandler->showEscBtnL(); |
1476 if (IsFocused()) m_pageFullScreenHandler->showEscBtnL(); |
1431 else m_pageFullScreenHandler->hideEscBtnL(); |
1477 else m_pageFullScreenHandler->hideEscBtnL(); |
1432 } |
1478 } |
1433 } |
1479 } |
1445 m_webFormFill->updatePopupView(); |
1491 m_webFormFill->updatePopupView(); |
1446 } |
1492 } |
1447 if (m_pageFullScreenHandler) { |
1493 if (m_pageFullScreenHandler) { |
1448 m_pageFullScreenHandler->SizeChanged(); |
1494 m_pageFullScreenHandler->SizeChanged(); |
1449 } |
1495 } |
1450 if (m_viewIsScrolling) { |
1496 |
1497 if (m_pageScrollHandler) { |
|
1451 m_pageScrollHandler->scrollbarDrawer()->redrawScrollbar(); |
1498 m_pageScrollHandler->scrollbarDrawer()->redrawScrollbar(); |
1452 } |
1499 } |
1500 |
|
1453 } |
1501 } |
1454 |
1502 |
1455 TSize WebView::maxBidiSize() const |
1503 TSize WebView::maxBidiSize() const |
1456 { |
1504 { |
1457 return TSize((Rect().Size().iWidth-20),(Rect().Size().iHeight-20)); |
1505 return TSize((Rect().Size().iWidth-20),(Rect().Size().iHeight-20)); |
1580 |
1628 |
1581 int WebView::searchAgain(bool forward) |
1629 int WebView::searchAgain(bool forward) |
1582 { |
1630 { |
1583 if (!m_findKeyword) { |
1631 if (!m_findKeyword) { |
1584 WebFrame* frame = mainFrame()->findFrameWithSelection(); |
1632 WebFrame* frame = mainFrame()->findFrameWithSelection(); |
1585 if (frame) { |
1633 if(frame) { |
1586 frame->clearSelection(); |
1634 frame->clearSelection(); |
1587 } |
1635 } |
1588 return TBrCtlDefs::EFindNoMatches; |
1636 return TBrCtlDefs::EFindNoMatches; |
1589 } |
1637 } |
1590 return search(*m_findKeyword, forward, true); |
1638 return search(*m_findKeyword, forward, true); |
1591 } |
1639 } |
1592 |
1640 |
1679 { |
1727 { |
1680 memset(m_ptrbuffer,0,256*sizeof(TPoint)); |
1728 memset(m_ptrbuffer,0,256*sizeof(TPoint)); |
1681 TPtr8 ptr((TUint8 *)m_ptrbuffer,256*sizeof(TPoint)); |
1729 TPtr8 ptr((TUint8 *)m_ptrbuffer,256*sizeof(TPoint)); |
1682 |
1730 |
1683 TInt numPnts = Window().RetrievePointerMoveBuffer(ptr); |
1731 TInt numPnts = Window().RetrievePointerMoveBuffer(ptr); |
1684 |
1732 int i = 0; |
1685 for (int i = 0; i < numPnts; i++) { |
1733 if (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone) { |
1734 if (numPnts > 20) |
|
1735 i = numPnts - 20; |
|
1736 } |
|
1737 for (; i < numPnts; i++) { |
|
1686 TPointerEvent pe; |
1738 TPointerEvent pe; |
1687 pe.iType = TPointerEvent::EDrag; |
1739 pe.iType = TPointerEvent::EDrag; |
1688 pe.iPosition = m_ptrbuffer[i]; |
1740 pe.iPosition = m_ptrbuffer[i]; |
1689 m_webpointerEventHandler->HandlePointerEventL(pe); |
1741 m_webpointerEventHandler->HandlePointerEventL(pe); |
1690 } |
1742 } |
1701 |
1753 |
1702 void WebView::notifyMetaData(String& name, String& value) |
1754 void WebView::notifyMetaData(String& name, String& value) |
1703 { |
1755 { |
1704 if (name == "navigation") { |
1756 if (name == "navigation") { |
1705 if (value == "tabbed") { |
1757 if (value == "tabbed") { |
1706 m_brctl->settings()->setTabbedNavigation(true); |
1758 m_brctl->settings()->setNavigationType(SettingsContainer::NavigationTypeTabbed); |
1707 StaticObjectsContainer::instance()->webCursor()->cursorUpdate(true); |
1759 StaticObjectsContainer::instance()->webCursor()->cursorUpdate(true); |
1760 } |
|
1761 else if (value == "none") { |
|
1762 m_brctl->settings()->setNavigationType(SettingsContainer::NavigationTypeNone); |
|
1708 } |
1763 } |
1709 } |
1764 } |
1710 } |
1765 } |
1711 |
1766 |
1712 //------------------------------------------------------------------------------- |
1767 //------------------------------------------------------------------------------- |
1882 //------------------------------------------------------------------------------- |
1937 //------------------------------------------------------------------------------- |
1883 // WebView::resetZoomLevel |
1938 // WebView::resetZoomLevel |
1884 //------------------------------------------------------------------------------- |
1939 //------------------------------------------------------------------------------- |
1885 void WebView::resetZoomLevel(void) |
1940 void WebView::resetZoomLevel(void) |
1886 { |
1941 { |
1887 if( m_widgetextension && m_widgetextension->IsWidgetPublising()) { |
1942 if( m_widgetextension ) { |
1888 return ; |
1943 return ; |
1889 } |
1944 } |
1890 if (m_historyLoad) { |
1945 if (m_historyLoad) { |
1891 int zoomLevel = m_brctl->historyHandler()->historyController()->currentEntryZoomLevel(); |
1946 int zoomLevel = m_brctl->historyHandler()->historyController()->currentEntryZoomLevel(); |
1892 if (!zoomLevel) zoomLevel = KZoomLevelDefaultValue; |
1947 if (!zoomLevel) zoomLevel = KZoomLevelDefaultValue; |
1960 |
2015 |
1961 if (m_minZoomLevel != newMinZoomLevel) |
2016 if (m_minZoomLevel != newMinZoomLevel) |
1962 { |
2017 { |
1963 m_minZoomLevel = newMinZoomLevel; |
2018 m_minZoomLevel = newMinZoomLevel; |
1964 if (m_pageZoomHandler->isActive()) { |
2019 if (m_pageZoomHandler->isActive()) { |
2020 TRAP_IGNORE( |
|
1965 m_pageZoomHandler->hideZoomSliderL(); |
2021 m_pageZoomHandler->hideZoomSliderL(); |
1966 m_pageZoomHandler->showZoomSliderL(); |
2022 m_pageZoomHandler->showZoomSliderL(); |
2023 ); |
|
1967 } |
2024 } |
1968 else { |
2025 else { |
1969 UpdateZoomArray(); //for non-touch |
2026 UpdateZoomArray(); //for non-touch |
1970 } |
2027 } |
1971 } //endof if (m_minZoomLevel != newMinZoomLevel) |
2028 } //endof if (m_minZoomLevel != newMinZoomLevel) |
2095 { |
2152 { |
2096 int zoomLevel = KZoomLevelDefaultValue; |
2153 int zoomLevel = KZoomLevelDefaultValue; |
2097 |
2154 |
2098 // Double Tap Zooming: it toggles between default, maxiZoomLevel. |
2155 // Double Tap Zooming: it toggles between default, maxiZoomLevel. |
2099 // Depending on the current zoom level: |
2156 // Depending on the current zoom level: |
2100 // A. If the current is already the max, it zooms to the max |
2157 // A. If the current is already the max, it zooms to the max |
2101 // B. If the current is bigger than/equal to the default zoom level zooms to the default, it zooms to the max |
2158 // B. If the current is bigger than/equal to the default zoom level zooms to the default, it zooms to the max |
2102 // C. Otherwise it zooms to the default level first. |
2159 // C. Otherwise it zooms to the default level first. |
2103 // For the mobile pages, such as google.com and cnn.com, minimum zoom level equals |
2160 // For the mobile pages, such as google.com and cnn.com, minimum zoom level equals |
2104 // to the default zoom level. Zooming is only possible between default and maximum |
2161 // to the default zoom level. Zooming is only possible between default and maximum |
2105 // zoom level, double tap only won't reach logic C |
2162 // zoom level, double tap only won't reach logic C |
2106 // |
2163 // |
2107 // For both mobile and non-mobile pages, it creates the same end user double tap |
2164 // For both mobile and non-mobile pages, it creates the same end user double tap |
2108 // experiences |
2165 // experiences |
2109 |
2166 |
2110 if (m_currentZoomLevel == m_maxZoomLevel ) { |
2167 if (m_currentZoomLevel == m_maxZoomLevel ) { |
2111 zoomLevel = KZoomLevelDefaultValue; |
2168 zoomLevel = KZoomLevelDefaultValue; |
2112 } |
2169 } |
2113 else if (m_currentZoomLevel >= KZoomLevelDefaultValue ) { |
2170 else if (m_currentZoomLevel >= KZoomLevelDefaultValue ) { |
2114 zoomLevel = m_maxZoomLevel; |
2171 zoomLevel = m_maxZoomLevel; |
2115 } |
2172 } |
2116 else { |
2173 else { |
2117 zoomLevel = KZoomLevelDefaultValue; |
2174 zoomLevel = KZoomLevelDefaultValue; |
2118 } |
2175 } |
2119 |
2176 |
2120 // move the content |
2177 // move the content |
2121 WebFrameView* view = mainFrame()->frameView(); |
2178 WebFrameView* view = mainFrame()->frameView(); |
2122 if (!view) return; |
2179 if (!view) return; |
2123 WebCursor* cursor = StaticObjectsContainer::instance()->webCursor(); |
2180 WebCursor* cursor = StaticObjectsContainer::instance()->webCursor(); |
2137 setZoomLevel(zoomLevel); |
2194 setZoomLevel(zoomLevel); |
2138 mainFrame()->notifyPluginsOfScrolling(); |
2195 mainFrame()->notifyPluginsOfScrolling(); |
2139 } |
2196 } |
2140 |
2197 |
2141 //------------------------------------------------------------------------------- |
2198 //------------------------------------------------------------------------------- |
2142 // WebView::openPluginPlayer |
2199 // WebView::openPluginPlayerL |
2143 // Called when user clicks a plugin which is able to accept user input, |
2200 // Called when user clicks a plugin which is able to accept user input, |
2144 // this feature is only used in US build |
2201 // this feature is only used in US build |
2145 //------------------------------------------------------------------------------- |
2202 //------------------------------------------------------------------------------- |
2146 void WebView::openPluginPlayer(PluginWin* plugin) |
2203 void WebView::openPluginPlayerL(PluginWin* plugin) |
2147 { |
2204 { |
2148 if (!m_pluginplayer) { |
2205 if (!m_pluginplayer) { |
2149 PluginSkin* pluginskin = mainFrame()->focusedPlugin(); |
2206 PluginSkin* pluginskin = mainFrame()->focusedPlugin(); |
2150 |
2207 |
2151 if ( !pluginskin || !pluginskin->isInteractive() ) return; |
2208 if ( !pluginskin || !pluginskin->isInteractive() ) return; |
2192 #if USE(LOW_BANDWIDTH_DISPLAY) |
2249 #if USE(LOW_BANDWIDTH_DISPLAY) |
2193 m_page->mainFrame()->loader()->setUseLowBandwidthDisplay(false); |
2250 m_page->mainFrame()->loader()->setUseLowBandwidthDisplay(false); |
2194 #endif |
2251 #endif |
2195 } |
2252 } |
2196 |
2253 |
2254 //Widgets dont need memory cache for dead objects. hence set it to 0 |
|
2255 cache()->setCapacities(0, 0, 0); |
|
2197 return m_widgetextension; |
2256 return m_widgetextension; |
2198 } |
2257 } |
2199 |
2258 |
2200 //------------------------------------------------------------------------------- |
2259 //------------------------------------------------------------------------------- |
2201 // WebView::forceLayoutAndResize |
2260 // WebView::forceLayoutAndResize |
2325 StaticObjectsContainer::instance()->setFullScreenMode(false); |
2384 StaticObjectsContainer::instance()->setFullScreenMode(false); |
2326 } |
2385 } |
2327 } |
2386 } |
2328 |
2387 |
2329 //------------------------------------------------------------------------------- |
2388 //------------------------------------------------------------------------------- |
2330 // WebView::notifyFullscreenModeChangeL |
2389 // WebView::nootifyFullscreenModeChangeL |
2331 //------------------------------------------------------------------------------- |
2390 //------------------------------------------------------------------------------- |
2332 void WebView::notifyFullscreenModeChangeL(bool mode) |
2391 void WebView::notifyFullscreenModeChangeL(bool mode) |
2333 { |
2392 { |
2334 if (m_pageFullScreenHandler ) |
2393 if (m_pageFullScreenHandler ) |
2335 m_brctl->reportStateChanged(TBrCtlDefs::EStateFullscreenBrowsing, mode ); |
2394 m_brctl->reportStateChanged(TBrCtlDefs::EStateFullscreenBrowsing, mode ); |
2386 void WebView::setHistoryLoad(bool value) { |
2445 void WebView::setHistoryLoad(bool value) { |
2387 m_historyLoad = value; |
2446 m_historyLoad = value; |
2388 } |
2447 } |
2389 void WebView::setRedirectWithLockedHistory(bool value) { |
2448 void WebView::setRedirectWithLockedHistory(bool value) { |
2390 m_redirectWithLockedHistory = value; |
2449 m_redirectWithLockedHistory = value; |
2391 } |
|
2392 //------------------------------------------------------------------------------- |
|
2393 // WebView::notifyPlugins |
|
2394 // Webview notifies plugins to handle play/pause of .swf files when user switches to menu/another application |
|
2395 //------------------------------------------------------------------------------- |
|
2396 void WebView::notifyPlugins(TBool focus) |
|
2397 { |
|
2398 Frame* coreFrame =core(mainFrame()); |
|
2399 MWebCoreObjectWidget* view = NULL; |
|
2400 for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) { |
|
2401 PassRefPtr<HTMLCollection> objects = frame->document()->objects(); |
|
2402 for (Node* n = objects->firstItem(); n; n = objects->nextItem()) { |
|
2403 view = widget(n); |
|
2404 if (view) { |
|
2405 static_cast<PluginSkin*>(view)->handlePluginForeground(focus); |
|
2406 } |
|
2407 } |
|
2408 |
|
2409 PassRefPtr<HTMLCollection> embeds = frame->document()->embeds(); |
|
2410 for (Node* n = embeds->firstItem(); n; n = embeds->nextItem()) { |
|
2411 view = widget(n); |
|
2412 if (view) { |
|
2413 static_cast<PluginSkin*>(view)->handlePluginForeground(focus); |
|
2414 } |
|
2415 } |
|
2416 } |
|
2417 } |
2450 } |
2418 |
2451 |
2419 |
2452 |
2420 void WebView::setFastScrollingMode(bool fastScrolling) |
2453 void WebView::setFastScrollingMode(bool fastScrolling) |
2421 { |
2454 { |
2517 { |
2550 { |
2518 m_showCursor = showCursor; |
2551 m_showCursor = showCursor; |
2519 StaticObjectsContainer::instance()->webCursor()->setCursorVisible(showCursor); |
2552 StaticObjectsContainer::instance()->webCursor()->setCursorVisible(showCursor); |
2520 } |
2553 } |
2521 |
2554 |
2555 void WebView::focusedElementChanged(Element* element) |
|
2556 { |
|
2557 Frame* frame = element->document()->frame(); |
|
2558 WebFrameView* fv = kit(frame)->frameView(); |
|
2559 if (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed || m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone) { |
|
2560 if (!element || !element->document() ||!element->renderer()) return; |
|
2561 if (element->hasTagName(textareaTag) || (element->hasTagName(inputTag) && (reinterpret_cast<HTMLInputElement*>(element))->isTextField())) { |
|
2562 TPoint point = TRect(element->getRect()).iTl; |
|
2563 point = fv->frameCoordsInViewCoords(point); |
|
2564 StaticObjectsContainer::instance()->webCursor()->setPosition(point); |
|
2565 TPointerEvent event; |
|
2566 event.iPosition = StaticObjectsContainer::instance()->webCursor()->position(); |
|
2567 event.iModifiers = 0; |
|
2568 event.iType = TPointerEvent::EMove; |
|
2569 core(mainFrame())->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event)); |
|
2570 |
|
2571 } |
|
2572 else { |
|
2573 int x, y; |
|
2574 element->renderer()->absolutePosition(x, y); |
|
2575 Vector<IntRect> rects; |
|
2576 element->renderer()->absoluteRects(rects, x, y); |
|
2577 TPoint point; |
|
2578 if (rects.size() > 0) { |
|
2579 point = TPoint(rects[0].x(), rects[0].y()); |
|
2580 point = fv->frameCoordsInViewCoords(point); |
|
2581 StaticObjectsContainer::instance()->webCursor()->setPosition(point); |
|
2582 TPointerEvent event; |
|
2583 event.iPosition = StaticObjectsContainer::instance()->webCursor()->position(); |
|
2584 event.iModifiers = 0; |
|
2585 event.iType = TPointerEvent::EMove; |
|
2586 core(mainFrame())->eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event)); |
|
2587 } |
|
2588 } |
|
2589 |
|
2590 if (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed) { |
|
2591 m_tabbedNavigation->focusedElementChanged(element); |
|
2592 } |
|
2593 // onload event on the first page could happen before the view becomes visible |
|
2594 m_savedCursorPosition = StaticObjectsContainer::instance()->webCursor()->position(); |
|
2595 m_focusedElementType = nodeTypeB(element, frame); |
|
2596 } |
|
2597 } |
|
2598 |
|
2599 void WebView::windowObjectCleared() const |
|
2600 { |
|
2601 if (m_widgetextension) { |
|
2602 WebView* that = const_cast<WebView*>(this); |
|
2603 that->m_widgetextension->windowObjectCleared(); |
|
2604 } |
|
2605 } |
|
2606 |
|
2522 // END OF FILE |
2607 // END OF FILE |