|
1 /* |
|
2 * Copyright (c) 2006 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: Implemetation of CWebKitView |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef WEBKITVIEW_H |
|
20 #define WEBKITVIEW_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <eikscrlb.h> |
|
25 #include "platform/Shared.h" |
|
26 #include "BrCtlDefs.h" |
|
27 #include "PageScaler.h" |
|
28 #include "Timer.h" |
|
29 #include "MemoryManager.h" |
|
30 |
|
31 namespace WebCore |
|
32 { |
|
33 class String; |
|
34 class Page; |
|
35 class DOMDocument; |
|
36 class FormState; |
|
37 class Element; |
|
38 } |
|
39 |
|
40 class CPluginHandler; |
|
41 class WebPreferences; |
|
42 class WebBackForwardList; |
|
43 class WebScriptObject; |
|
44 class WebHistoryItem; |
|
45 class WebFrame; |
|
46 class CBrCtl; |
|
47 class WebCoreGraphicsContext; |
|
48 class CWebFepTextEditor; |
|
49 class CPeriodic; |
|
50 class CPageView; |
|
51 class WebFormFill; |
|
52 class WebFormFillPopup; |
|
53 class CToolBar; |
|
54 class WebToolBarInterface; |
|
55 class WebPageScrollHandler; |
|
56 class WebPopupDrawer; |
|
57 class TBrCtlImageCarrier; |
|
58 class PluginPlayer; |
|
59 class PluginWin; |
|
60 class CWidgetExtension; |
|
61 class MWidgetCallback; |
|
62 class WebTabbedNavigation; |
|
63 class WebPageZoomHandler; |
|
64 class WebPointerEventHandler; |
|
65 class WebPageFullScreenHandler; |
|
66 |
|
67 class WebView : public CEikBorderedControl, public WebCore::Shared<WebView>, private MPageScalerCallback, public MOOMStopper |
|
68 { |
|
69 public: |
|
70 /** |
|
71 * Two-phased constructor. |
|
72 */ |
|
73 static WebView* NewL( CCoeControl& aParent, CBrCtl* brctl ); |
|
74 |
|
75 /** |
|
76 * Destructor. |
|
77 */ |
|
78 virtual ~WebView(); |
|
79 |
|
80 void MakeVisible(TBool visible); |
|
81 void MakeViewVisible(TBool visible); |
|
82 |
|
83 WebFrame* mainFrame(); |
|
84 |
|
85 WebFrame* selectedFrame(); |
|
86 |
|
87 void setMainFrameUrlL(TDesC& url); |
|
88 |
|
89 TDesC& mainFrameUrl(); |
|
90 |
|
91 WebCore::DOMDocument* mainFrameDocument(); |
|
92 |
|
93 TDesC& mainFrameTitle(); |
|
94 |
|
95 WebCore::Page* page(); |
|
96 |
|
97 bool isMIMETypeRegisteredAsPlugin(const WebCore::String& MIMEType); |
|
98 |
|
99 CPluginHandler* pluginForExtension(const WebCore::String& pluginExtension); |
|
100 |
|
101 void loadBackForwardListFromOtherView(WebView* otherView); |
|
102 |
|
103 void updateWebCoreSettingsFromPreferences(WebPreferences* preferences); |
|
104 |
|
105 TBool defersCallbacks(); |
|
106 |
|
107 void setDefersCallbacks(TBool defer); |
|
108 |
|
109 WebBackForwardList* backForwardList(); |
|
110 |
|
111 void setMaintainsBackForwardList(TBool flag); |
|
112 |
|
113 TBool goBack(); |
|
114 |
|
115 TBool goForward(); |
|
116 |
|
117 TBool goToBackForwardItem(WebHistoryItem* item); |
|
118 |
|
119 void setTextSizeMultiplier(TInt multiplier); |
|
120 |
|
121 TInt textSizeMultiplier(); |
|
122 |
|
123 WebScriptObject* windowScriptObject(); |
|
124 |
|
125 void setGroupName(TDesC& groupName); |
|
126 |
|
127 TDesC& groupName(); |
|
128 |
|
129 TInt estimatedProgress(); |
|
130 |
|
131 TBool shouldClose(); |
|
132 |
|
133 TBool isLoading(); |
|
134 TBool showCursor() const {return m_showCursor;} |
|
135 void setShowCursor(TBool showCursor); |
|
136 |
|
137 // repainting |
|
138 void syncRepaint(const TRect& rect); |
|
139 void scheduleRepaint(const TRect& rect); |
|
140 void syncRepaint(); |
|
141 void doRepaint(); |
|
142 void pageLoadFinished(); |
|
143 void updatePageScaler(); |
|
144 void doLayout(); |
|
145 |
|
146 |
|
147 TSize maxBidiSize() const; |
|
148 void clearOffScreenBitmap(); |
|
149 void scrollBuffer(TPoint aTo, TPoint aFrom, TBool aMayUseCopyScroll); |
|
150 TRect offscreenRect() const {return m_offscreenrect;} |
|
151 CPageScaler* pageScaler() const{ return m_pageScaler; } |
|
152 //void updateScrollBarsL(CEikScrollBar::TOrientation aOrientation, const TInt aThumbPos, const int aScrollSpan); |
|
153 int scalingFactor() const; |
|
154 void openUrl(const TDesC& url); |
|
155 CBrCtl* brCtl() const { return m_brctl; } |
|
156 CWebFepTextEditor* fepTextEditor() { return m_webfeptexteditor; } |
|
157 WebFormFillPopup* formFillPopup() { return m_webFormFillPopup; } |
|
158 void setFormFillPopup(WebFormFillPopup* popup) { m_webFormFillPopup = popup; } |
|
159 WebFormFill* formFill() { return m_webFormFill; } |
|
160 void setEditable(TBool aEditable); |
|
161 bool isEditable() const { return m_isEditable; } |
|
162 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aEventCode ); |
|
163 void setFocusedElementType(TBrCtlDefs::TBrCtlElementType focusedElementType_) { m_focusedElementType = focusedElementType_; } |
|
164 TBrCtlDefs::TBrCtlElementType focusedElementType() const { return m_focusedElementType; } |
|
165 WebPageScrollHandler* pageScrollHandler() { return m_pageScrollHandler;} |
|
166 WebPageFullScreenHandler* pageFullScreenHandler() { return m_pageFullScreenHandler;} |
|
167 WebPointerEventHandler* pointerEventHandler() { return m_webpointerEventHandler; } |
|
168 void updateScrollbars(int documentHeight, int displayPosY, |
|
169 int documentWidth, int displayPosX); |
|
170 void openPageViewL(); |
|
171 void closePageView(); |
|
172 void cancelPageView(); |
|
173 CPageView* pageView() const { return m_pageView; } |
|
174 bool inPageViewMode() const { return m_pageView != NULL; } |
|
175 int searchFor(const TPtrC& keyword); |
|
176 int searchAgain(bool forward); |
|
177 void exitFindState(); |
|
178 bool inFindState() const { return m_inFindState; } |
|
179 bool pageScalerEnabled() const { return m_pageScalerEnabled; } |
|
180 bool isSmallPage(); |
|
181 void willSubmitForm(WebCore::FormState* formState); |
|
182 |
|
183 PluginPlayer* pluginPlayer() { return m_pluginplayer; } |
|
184 void closePluginPlayer(); |
|
185 void openPluginPlayer(PluginWin* plugin); |
|
186 |
|
187 void setAccessPointId(TUint32 apid) {m_apid = apid;} |
|
188 TUint32 accessPointId() { return m_apid; } |
|
189 |
|
190 CWidgetExtension* createWidgetExtension(MWidgetCallback &aWidgetCallback); |
|
191 CWidgetExtension* widgetExtension() { return m_widgetextension; } |
|
192 |
|
193 void activateVirtualKeyboard(); |
|
194 void setFocusNone(); |
|
195 |
|
196 /** |
|
197 * Display a popup with the url of an anchor |
|
198 */ |
|
199 void handleShowAnchorHrefL(); |
|
200 |
|
201 /** |
|
202 * Return the image that is under the cursor |
|
203 */ |
|
204 TBrCtlImageCarrier* focusedImageLC(); |
|
205 |
|
206 /** |
|
207 * Load the image that is under the cursor |
|
208 */ |
|
209 void loadFocusedImageL(); |
|
210 |
|
211 /** |
|
212 * Get the popupDrawer |
|
213 */ |
|
214 WebPopupDrawer* popupDrawer() { return m_popupDrawer; } |
|
215 |
|
216 /** |
|
217 * Delete the popupDrawer |
|
218 */ |
|
219 void removePopup(); |
|
220 |
|
221 RArray<TUint>* zoomLevels(); |
|
222 |
|
223 /** |
|
224 * |
|
225 * Zooming new interface |
|
226 * @since 5.0 |
|
227 * @param |
|
228 * @return |
|
229 */ |
|
230 void setZoomLevel( int ); |
|
231 |
|
232 int zoomLevel() const { return m_currentZoomLevel; } |
|
233 void restoreZoomLevel(int zoomLevel); |
|
234 |
|
235 void setBitmapZoomLevel(int zoomLevel); |
|
236 |
|
237 void showZoomSliderL(); |
|
238 |
|
239 void hideZoomSliderL(); |
|
240 |
|
241 void notifyZoomSliderModeChangeL(bool); |
|
242 |
|
243 int maxZoomLevel(); |
|
244 |
|
245 int minZoomLevel(); |
|
246 |
|
247 void updateZoomLevel(TBrCtlDefs::TBrCtlSettings setting, unsigned int value); |
|
248 |
|
249 void checkForZoomChange(); |
|
250 |
|
251 void updateMinZoomLevel( TSize size ); |
|
252 |
|
253 void resetZoomLevel(); |
|
254 |
|
255 bool historyLoad(){ return m_historyLoad;} |
|
256 |
|
257 void setHistoryLoad(bool value); |
|
258 |
|
259 bool redirectWithLockedHistory(){ return m_redirectWithLockedHistory;} |
|
260 |
|
261 void setRedirectWithLockedHistory(bool value); |
|
262 |
|
263 |
|
264 /** |
|
265 * |
|
266 * Fullscreen Escape Interface |
|
267 * |
|
268 */ |
|
269 void EnterFullscreenBrowsingL(void); |
|
270 void LeaveFullscreenBrowsingL(void); |
|
271 void notifyFullscreenModeChangeL(bool); |
|
272 |
|
273 |
|
274 void setZoomLevelAdaptively(); |
|
275 void setZoomCursorPosition(TBool isZoomIn); |
|
276 void resetLastZoomLevelIfNeeded(); |
|
277 |
|
278 /** |
|
279 * Toolbar |
|
280 **/ |
|
281 |
|
282 void launchToolBarL(); |
|
283 |
|
284 void closeToolBarL(); |
|
285 |
|
286 /** |
|
287 * HandlePointerBufferReadyL |
|
288 * From CCoeControl |
|
289 * |
|
290 */ |
|
291 void HandlePointerBufferReadyL(); |
|
292 |
|
293 /** |
|
294 * HandlePointerEventL |
|
295 * From CCoeControl |
|
296 * |
|
297 */ |
|
298 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
299 |
|
300 /** |
|
301 * Set flag if the user is currently scrolling |
|
302 * |
|
303 * |
|
304 */ |
|
305 void setViewIsScrolling(bool scrolling) { m_viewIsScrolling = scrolling; }; |
|
306 |
|
307 /** |
|
308 * Return if the user is currently scrolling |
|
309 * |
|
310 * |
|
311 */ |
|
312 bool viewIsScrolling() { return m_viewIsScrolling; } |
|
313 |
|
314 |
|
315 void setViewIsFastScrolling(bool fastScrolling) { m_viewIsFastScrolling = fastScrolling; }; |
|
316 |
|
317 void setFastScrollingMode(bool fastScrolling); |
|
318 |
|
319 bool viewIsFastScrolling() { return m_viewIsFastScrolling; } |
|
320 |
|
321 void toggleRepaintTimer(bool on); |
|
322 |
|
323 WebTabbedNavigation* tabbedNavigation() { return m_tabbedNavigation; } |
|
324 void notifyMetaData(WebCore::String& name, WebCore::String& value); |
|
325 void forceLayoutAndResize(WebFrame* frame); |
|
326 const TPtrC userAgent() { return *m_userAgent; } |
|
327 void adjustOffscreenRect(); |
|
328 |
|
329 /** |
|
330 * Handle to container Window |
|
331 */ |
|
332 RWindow& GetContainerWindow() {return Window();} |
|
333 |
|
334 // from OOMStopper |
|
335 void Stop(); |
|
336 TOOMPriority Priority() { return EOOM_PriorityHigh; } |
|
337 |
|
338 /** |
|
339 * Collects offscreen bitmap |
|
340 */ |
|
341 void collectOffscreenbitmapL(CFbsBitmap& snapshot); |
|
342 |
|
343 public: // from MPageScalerCallback |
|
344 /** |
|
345 * |
|
346 * @since 3.1 |
|
347 * @param |
|
348 * @return |
|
349 */ |
|
350 void DrawDocumentPart(CFbsBitGc& aGc, CFbsBitmap* aBitmap, const TRect& aDocumentAreaToDraw); |
|
351 |
|
352 /** |
|
353 * |
|
354 * @since 3.1 |
|
355 * @param |
|
356 * @return |
|
357 */ |
|
358 TRect DocumentViewport() ; |
|
359 |
|
360 /** |
|
361 * |
|
362 * @since 3.1 |
|
363 * @param |
|
364 * @return |
|
365 */ |
|
366 void ScaledPageChanged(const TRect& aArea, TBool aFullScreen, TBool aScroll); |
|
367 |
|
368 /** |
|
369 * |
|
370 * @since 3.1 |
|
371 * @param |
|
372 * @return |
|
373 */ |
|
374 TSize DocumentSize(); |
|
375 |
|
376 /** |
|
377 * |
|
378 * @since 3.2 |
|
379 * @param |
|
380 * @return |
|
381 */ |
|
382 TBool TouchScrolling() ; |
|
383 |
|
384 CCoeControl& PageControlView(); |
|
385 void notifyPlugins(TBool focus); |
|
386 |
|
387 protected: // From CCoeControl |
|
388 |
|
389 /** |
|
390 * FocusChanged |
|
391 * From CCoeControl |
|
392 * |
|
393 */ |
|
394 void FocusChanged(TDrawNow aDrawNow); |
|
395 |
|
396 /** |
|
397 * From CCoeControl |
|
398 * Handle changes in size of the display. |
|
399 */ |
|
400 void SizeChanged(); |
|
401 |
|
402 /** |
|
403 * From CCoeControl |
|
404 * Handle changes in size of the display. |
|
405 */ |
|
406 void Draw(const TRect& aRect) const; |
|
407 |
|
408 /** |
|
409 * From CCoeControl |
|
410 * Get the number of controls in the Browser Control |
|
411 */ |
|
412 TInt CountComponentControls() const; |
|
413 |
|
414 /** |
|
415 * From CCoeControl |
|
416 * Get a specified control with a given index |
|
417 */ |
|
418 CCoeControl* ComponentControl(TInt aIndex) const; |
|
419 |
|
420 /** |
|
421 * From CCoeControl |
|
422 * Fep integration for inline editing |
|
423 */ |
|
424 TCoeInputCapabilities InputCapabilities() const; |
|
425 |
|
426 |
|
427 private: |
|
428 WebView( CBrCtl* brctl ); |
|
429 |
|
430 /** |
|
431 * By default Symbian 2nd phase constructor is private. |
|
432 */ |
|
433 void ConstructL( CCoeControl& aParent ); |
|
434 void initializePageScalerL(); |
|
435 |
|
436 // |
|
437 static TInt scrollTimerCb(TAny* aAny); |
|
438 void autoScroll(); |
|
439 int millisecondsScrolled() const; |
|
440 int search(TPtrC keyword, bool forward, bool wrapFlag); |
|
441 void zoomLevelChanged(int newZoomLevel); |
|
442 void UpdateZoomArray(); |
|
443 TInt FindCurrentZoomIndex(TInt aCurrentZoomLevel); |
|
444 |
|
445 public: |
|
446 void fepTimerFired(WebCore::Timer<WebView>*); |
|
447 void fepVKBTimerFired(WebCore::Timer<WebView>*); |
|
448 bool isClosing() const { return m_isClosing; } |
|
449 void synchRequestPending(bool); |
|
450 bool isSynchRequestPending() const { return m_synchRequestPending; } |
|
451 |
|
452 void setPluginFullscreen(bool val) { m_pluginFullscreen = val; } |
|
453 bool isPluginFullscreen() { return m_pluginFullscreen; } |
|
454 void setPluginActivated(bool option) {m_pluginActivated = option;} |
|
455 TInt getWidgetId(); |
|
456 private: |
|
457 WebCore::Page* m_page; |
|
458 CBrCtl* m_brctl; |
|
459 RRegion m_repaints; |
|
460 CPeriodic* m_repainttimer; |
|
461 WebCoreGraphicsContext* m_webcorecontext; // owned |
|
462 CFbsBitmapDevice* m_bitmapdevice; // onwed |
|
463 TRect m_offscreenrect; |
|
464 |
|
465 bool m_isEditable; |
|
466 CWebFepTextEditor* m_webfeptexteditor; |
|
467 CToolBar* m_toolbar; |
|
468 WebToolBarInterface* m_toolbarinterface; |
|
469 |
|
470 WebFormFillPopup* m_webFormFillPopup; // not owned |
|
471 WebPageScrollHandler* m_pageScrollHandler; // owned |
|
472 WebPopupDrawer* m_popupDrawer; // owned |
|
473 PluginPlayer* m_pluginplayer; //owned |
|
474 WebPointerEventHandler* m_webpointerEventHandler; //owned |
|
475 |
|
476 TTime m_scrollingStartTime; |
|
477 TKeyEvent m_currentEventKey; |
|
478 CPeriodic* m_fastScrollTimer; |
|
479 int m_scrollingSpeed; |
|
480 TBrCtlDefs::TBrCtlElementType m_focusedElementType; |
|
481 CPageScaler* m_pageScaler; |
|
482 bool m_pageScalerEnabled; |
|
483 bool m_inFindState; |
|
484 CPageView* m_pageView; |
|
485 TPoint m_savedPosition; // contentPosition |
|
486 TPoint m_savedCursorPosition; |
|
487 HBufC* m_findKeyword; |
|
488 WebTabbedNavigation* m_tabbedNavigation; |
|
489 WebFormFill* m_webFormFill; // owned |
|
490 |
|
491 // for fep editor |
|
492 WebCore::Timer<WebView>* m_fepTimer; |
|
493 TKeyEvent m_keyevent; |
|
494 TEventCode m_eventcode; |
|
495 |
|
496 RArray<TUint> m_zoomLevelArray; |
|
497 int m_currentZoomLevelIndex; |
|
498 TUint32 m_apid; |
|
499 |
|
500 bool m_isClosing; |
|
501 CWidgetExtension* m_widgetextension; |
|
502 HBufC* m_userAgent; |
|
503 bool m_isdialogLaunched; |
|
504 |
|
505 |
|
506 WebPageZoomHandler* m_pageZoomHandler; // owned |
|
507 int m_currentZoomLevel; |
|
508 int m_lastZoomLevel; |
|
509 int m_maxZoomLevel; |
|
510 int m_minZoomLevel; |
|
511 int m_defaultZoomLevel; |
|
512 |
|
513 // dirty zooming specific |
|
514 TRect m_srcRectForZooming; |
|
515 TRect m_destRectForZooming; |
|
516 int m_startZoomLevel; |
|
517 bool m_dirtyZoomMode; |
|
518 bool m_zoomLevelChangedByUser; |
|
519 bool m_isPluginsVisible; |
|
520 bool m_historyLoad; |
|
521 bool m_redirectWithLockedHistory; |
|
522 // full screen mode |
|
523 WebPageFullScreenHandler* m_pageFullScreenHandler; // owned |
|
524 bool m_viewIsScrolling; |
|
525 bool m_viewIsFastScrolling; |
|
526 TPoint* m_ptrbuffer; |
|
527 |
|
528 // synchronous requests |
|
529 bool m_synchRequestPending; |
|
530 bool m_pluginFullscreen; |
|
531 //Indicates any plugin is activated/deactivated |
|
532 bool m_pluginActivated; |
|
533 bool m_showCursor; |
|
534 bool m_allowRepaints; |
|
535 }; |
|
536 |
|
537 #endif |
|
538 |
|
539 |
|
540 |