• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2006, The Android Open Source Project
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *  * Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  *  * Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef WebViewCore_h
27 #define WebViewCore_h
28 
29 #include "DeviceMotionAndOrientationManager.h"
30 #include "DOMSelection.h"
31 #include "FileChooser.h"
32 #include "FocusDirection.h"
33 #include "GeolocationManager.h"
34 #include "HitTestResult.h"
35 #include "PicturePile.h"
36 #include "PlatformGraphicsContext.h"
37 #include "Position.h"
38 #include "ScrollTypes.h"
39 #include "SkColor.h"
40 #include "SkTDArray.h"
41 #include "SkRegion.h"
42 #include "Text.h"
43 #include "Timer.h"
44 #include "WebCoreRefObject.h"
45 #include "WebCoreJni.h"
46 #include "WebRequestContext.h"
47 #include "android_npapi.h"
48 #include "VisiblePosition.h"
49 #include "SelectText.h"
50 
51 #include <jni.h>
52 #include <androidfw/KeycodeLabels.h>
53 #include <ui/PixelFormat.h>
54 #include <utils/threads.h>
55 #include <wtf/Threading.h>
56 
57 namespace WebCore {
58     class Color;
59     class GraphicsOperationCollection;
60     class FrameView;
61     class HTMLAnchorElement;
62     class HTMLElement;
63     class HTMLImageElement;
64     class HTMLSelectElement;
65     class RenderPart;
66     class RenderText;
67     class Node;
68     class PlatformKeyboardEvent;
69     class QualifiedName;
70     class RenderTextControl;
71     class ScrollView;
72     class TimerBase;
73     class PageGroup;
74 }
75 
76 #if USE(ACCELERATED_COMPOSITING)
77 namespace WebCore {
78     class GraphicsLayerAndroid;
79     class LayerAndroid;
80 }
81 #endif
82 
83 namespace WebCore {
84     class BaseLayerAndroid;
85 }
86 
87 struct PluginWidgetAndroid;
88 class SkPicture;
89 class SkIRect;
90 
91 namespace android {
92 
93     enum Direction {
94         DIRECTION_BACKWARD = 0,
95         DIRECTION_FORWARD = 1
96     };
97 
98     enum NavigationAxis {
99         AXIS_CHARACTER = 0,
100         AXIS_WORD = 1,
101         AXIS_SENTENCE = 2,
102         AXIS_HEADING = 3,
103         AXIS_SIBLING = 4,
104         AXIS_PARENT_FIRST_CHILD = 5,
105         AXIS_DOCUMENT = 6
106     };
107 
108     class ListBoxReply;
109     class AndroidHitTestResult;
110 
111     class WebCoreReply : public WebCoreRefObject {
112     public:
~WebCoreReply()113         virtual ~WebCoreReply() {}
114 
replyInt(int value)115         virtual void replyInt(int value) {
116             SkDEBUGF(("WebCoreReply::replyInt(%d) not handled\n", value));
117         }
118 
replyIntArray(const int * array,int count)119         virtual void replyIntArray(const int* array, int count) {
120             SkDEBUGF(("WebCoreReply::replyIntArray() not handled\n"));
121         }
122             // add more replyFoo signatures as needed
123     };
124 
125     // one instance of WebViewCore per page for calling into Java's WebViewCore
126     class WebViewCore : public WebCoreRefObject, public WebCore::PicturePainter {
127     public:
128         /**
129          * Initialize the native WebViewCore with a JNI environment, a Java
130          * WebViewCore object and the main frame.
131          */
132         WebViewCore(JNIEnv* env, jobject javaView, WebCore::Frame* mainframe);
133         ~WebViewCore();
134 
135         // helper function
136         static WebViewCore* getWebViewCore(const WebCore::FrameView* view);
137         static WebViewCore* getWebViewCore(const WebCore::ScrollView* view);
138 
139         // Followings are called from native WebCore to Java
140 
141         void focusNodeChanged(WebCore::Node*);
142 
143         /**
144          * Scroll to an absolute position.
145          * @param x The x coordinate.
146          * @param y The y coordinate.
147          * @param animate If it is true, animate to the new scroll position
148          *
149          * This method calls Java to trigger a gradual scroll event.
150          */
151         void scrollTo(int x, int y, bool animate = false);
152 
153         /**
154          * Record the invalid rectangle
155          */
156         void contentInvalidate(const WebCore::IntRect &rect);
157         void contentInvalidateAll();
158 
159         /**
160          * Satisfy any outstanding invalidates, so that the current state
161          * of the DOM is drawn.
162          */
163         void contentDraw();
164 
165 #if USE(ACCELERATED_COMPOSITING)
166         WebCore::GraphicsLayerAndroid* graphicsRootLayer() const;
167 #endif
168 
169         /** Invalidate the view/screen, NOT the content/DOM, but expressed in
170          *  content/DOM coordinates (i.e. they need to eventually be scaled,
171          *  by webview into view.java coordinates
172          */
173         void viewInvalidate(const WebCore::IntRect& rect);
174 
175         /**
176          * Invalidate part of the content that may be offscreen at the moment
177          */
178         void offInvalidate(const WebCore::IntRect &rect);
179 
180         /**
181          * Called by webcore when the progress indicator is done
182          * used to rebuild and display any changes in focus
183          */
184         void notifyProgressFinished();
185 
186         /**
187          * Notify the view that WebCore did its first layout.
188          */
189         void didFirstLayout();
190 
191         /**
192          * Notify the view to update the viewport.
193          */
194         void updateViewport();
195 
196         /**
197          * Notify the view to restore the screen width, which in turn restores
198          * the scale. Also restore the scale for the text wrap.
199          */
200         void restoreScale(float scale, float textWrapScale);
201 
202         /**
203          * Tell the java side to update the focused textfield
204          * @param pointer   Pointer to the node for the input field.
205          * @param text  This is the new text that should go into the textfield.
206          */
207         void updateTextfield(WebCore::Node* pointer, const WTF::String& text);
208 
209         /**
210          * Tell the java side to update the current selection in the focused
211          * textfield to the WebTextView.  This function finds the currently
212          * focused textinput, and passes its selection to java.
213          * If there is no focus, or it is not a text input, this does nothing.
214          */
215         void updateTextSelection();
216 
217         /**
218          * Updates the java side with the node's content size and scroll
219          * position.
220          */
221         void updateTextSizeAndScroll(WebCore::Node* node);
222 
223         void clearTextEntry();
224         // JavaScript support
225         void jsAlert(const WTF::String& url, const WTF::String& text);
226         bool jsConfirm(const WTF::String& url, const WTF::String& text);
227         bool jsPrompt(const WTF::String& url, const WTF::String& message,
228                 const WTF::String& defaultValue, WTF::String& result);
229         bool jsUnload(const WTF::String& url, const WTF::String& message);
230         bool jsInterrupt();
231 
232         /**
233          * Posts a message to the UI thread to inform the Java side that the
234          * origin has exceeded its database quota.
235          * @param url The URL of the page that caused the quota overflow
236          * @param databaseIdentifier the id of the database that caused the
237          *     quota overflow.
238          * @param currentQuota The current quota for the origin
239          * @param estimatedSize The estimated size of the database
240          * @return Whether the message was successfully sent.
241          */
242         bool exceededDatabaseQuota(const WTF::String& url,
243                                    const WTF::String& databaseIdentifier,
244                                    const unsigned long long currentQuota,
245                                    const unsigned long long estimatedSize);
246 
247         /**
248          * Posts a message to the UI thread to inform the Java side that the
249          * appcache has exceeded its max size.
250          * @param spaceNeeded is the amount of disk space that would be needed
251          * in order for the last appcache operation to succeed.
252          * @return Whether the message was successfully sent.
253          */
254         bool reachedMaxAppCacheSize(const unsigned long long spaceNeeded);
255 
256         /**
257          * Set up the PageGroup's idea of which links have been visited,
258          * with the browser history.
259          * @param group the object to deliver the links to.
260          */
261         void populateVisitedLinks(WebCore::PageGroup*);
262 
263         /**
264          * Instruct the browser to show a Geolocation permission prompt for the
265          * specified origin.
266          * @param origin The origin of the frame requesting Geolocation
267          *     permissions.
268          */
269         void geolocationPermissionsShowPrompt(const WTF::String& origin);
270         /**
271          * Instruct the browser to hide the Geolocation permission prompt.
272          */
273         void geolocationPermissionsHidePrompt();
274 
275         jobject getDeviceMotionService();
276         jobject getDeviceOrientationService();
277 
278         void addMessageToConsole(const WTF::String& message, unsigned int lineNumber, const WTF::String& sourceID, int msgLevel);
279 
280         /**
281          * Tell the Java side of the scrollbar mode
282          */
283         void setScrollbarModes(WebCore::ScrollbarMode horizontalMode,
284                                WebCore::ScrollbarMode verticalMode);
285 
286         //
287         // Followings support calls from Java to native WebCore
288         //
289 
290         WTF::String retrieveHref(int x, int y);
291         WTF::String retrieveAnchorText(int x, int y);
292         WTF::String retrieveImageSource(int x, int y);
293         WTF::String requestLabel(WebCore::Frame* , WebCore::Node* );
294 
295         // If the focus is a textfield (<input>), textarea, or contentEditable,
296         // scroll the selection on screen (if necessary).
297         void revealSelection();
298 
299         void moveMouse(int x, int y, WebCore::HitTestResult* hoveredNode = 0,
300                        bool isClickCandidate = false);
301 
302         // set the scroll amount that webview.java is currently showing
303         void setScrollOffset(bool sendScrollEvent, int dx, int dy);
304 
305         void setGlobalBounds(int x, int y, int h, int v);
306 
307         void setSizeScreenWidthAndScale(int width, int height, int screenWidth,
308             float scale, int realScreenWidth, int screenHeight, int anchorX,
309             int anchorY, bool ignoreHeight);
310 
311         /**
312          * Handle key events from Java.
313          * @return Whether keyCode was handled by this class.
314          */
315         bool key(const WebCore::PlatformKeyboardEvent& event);
316         bool chromeCanTakeFocus(WebCore::FocusDirection direction);
317         void chromeTakeFocus(WebCore::FocusDirection direction);
318         void setInitialFocus(const WebCore::PlatformKeyboardEvent& event);
319 
320         /**
321          * Handle touch event
322          * Returns an int with the following flags:
323          * bit 0: hit an event handler
324          * bit 1: preventDefault was called
325          */
326         int handleTouchEvent(int action, WTF::Vector<int>& ids,
327                               WTF::Vector<WebCore::IntPoint>& points,
328                               int actionIndex, int metaState);
329 
330         /**
331          * Clicks the mouse at its current location
332          */
333         bool performMouseClick();
334 
335         /**
336          * Sets the index of the label from a popup
337          */
338         void popupReply(int index);
339         void popupReply(const int* array, int count);
340 
341         /**
342          *  Delete text from start to end in the focused textfield.
343          *  If start == end, set the selection, but perform no deletion.
344          *  If there is no focus, silently fail.
345          *  If start and end are out of order, swap them.
346          */
347         void deleteSelection(int start, int end, int textGeneration);
348 
349         /**
350          *  Set the selection of the currently focused textfield to (start, end).
351          *  If start and end are out of order, swap them.
352          */
353         void setSelection(int start, int end);
354 
355         /**
356          * Modifies the current selection.
357          *
358          * Note: Accessibility support.
359          *
360          * direction - The direction in which to alter the selection.
361          * granularity - The granularity of the selection modification.
362          *
363          * returns - The selected HTML as a WTF::String. This is not a well formed
364          *           HTML, rather the selection annotated with the tags of all
365          *           intermediary elements it crosses.
366          */
367         WTF::String modifySelection(const int direction, const int granularity);
368 
369         /**
370          * Moves the selection to the given node in a given frame i.e. selects that node.
371          *
372          * Note: Accessibility support.
373          *
374          * frame - The frame in which to select is the node to be selected.
375          * node - The node to be selected.
376          *
377          * returns - The selected HTML as a WTF::String. This is not a well formed
378          *           HTML, rather the selection annotated with the tags of all
379          *           intermediary elements it crosses.
380          */
381         WTF::String moveSelection(WebCore::Frame* frame, WebCore::Node* node);
382 
383         /**
384          *  In the currently focused textfield, replace the characters from oldStart to oldEnd
385          *  (if oldStart == oldEnd, this will be an insert at that position) with replace,
386          *  and set the selection to (start, end).
387          */
388         void replaceTextfieldText(int oldStart,
389             int oldEnd, const WTF::String& replace, int start, int end,
390             int textGeneration);
391         void passToJs(int generation,
392             const WTF::String& , const WebCore::PlatformKeyboardEvent& );
393         /**
394          * Scroll the focused textfield to (x, y) in document space
395          */
396         void scrollFocusedTextInput(float x, int y);
397         /**
398          * Set the FocusController's active and focused states, so that
399          * the caret will draw (true) or not.
400          */
401         void setFocusControllerActive(bool active);
402 
403         void saveDocumentState(WebCore::Frame* frame);
404 
405         void addVisitedLink(const UChar*, int);
406 
407         // TODO: I don't like this hack but I need to access the java object in
408         // order to send it as a parameter to java
409         AutoJObject getJavaObject();
410 
411         // Return the parent WebView Java object associated with this
412         // WebViewCore.
413         jobject getWebViewJavaObject();
414 
415         void setBackgroundColor(SkColor c);
416 
417         void dumpDomTree(bool);
418         void dumpRenderTree(bool);
419 
420         /*  We maintain a list of active plugins. The list is edited by the
421             pluginview itself. The list is used to service invals to the plugin
422             pageflipping bitmap.
423          */
424         void addPlugin(PluginWidgetAndroid*);
425         void removePlugin(PluginWidgetAndroid*);
426         // returns true if the pluginwidgit is in our active list
427         bool isPlugin(PluginWidgetAndroid*) const;
428         void invalPlugin(PluginWidgetAndroid*);
429         void drawPlugins();
430 
431         // send the current screen size/zoom to all of the plugins in our list
432         void sendPluginVisibleScreen();
433 
434         // notify plugin that a new drawing surface was created in the UI thread
435         void sendPluginSurfaceReady();
436 
437         // send onLoad event to plugins who are descendents of the given frame
438         void notifyPluginsOnFrameLoad(const WebCore::Frame*);
439 
440         // gets a rect representing the current on-screen portion of the document
441         void getVisibleScreen(ANPRectI&);
442 
443         // send this event to all of the plugins in our list
444         void sendPluginEvent(const ANPEvent&);
445 
446         // lookup the plugin widget struct given an NPP
447         PluginWidgetAndroid* getPluginWidget(NPP npp);
448 
449         // Notify the Java side whether it needs to pass down the touch events
450         void needTouchEvents(bool);
451 
452         void requestKeyboardWithSelection(const WebCore::Node*, int selStart, int selEnd);
453         // Notify the Java side that webkit is requesting a keyboard
454         void requestKeyboard(bool showKeyboard);
455 
456         // Generates a class loader that contains classes from the plugin's apk
457         jclass getPluginClass(const WTF::String& libName, const char* className);
458 
459         // Creates a full screen surface for a plugin
460         void showFullScreenPlugin(jobject webkitPlugin, int32_t orientation, NPP npp);
461 
462         // Instructs the UI thread to discard the plugin's full-screen surface
463         void hideFullScreenPlugin();
464 
465         // Creates a childView for the plugin but does not attach to the view hierarchy
466         jobject createSurface(jobject view);
467 
468         // Adds the plugin's view (aka surface) to the view hierarchy
469         jobject addSurface(jobject view, int x, int y, int width, int height);
470 
471         // Updates a Surface coordinates and dimensions for a plugin
472         void updateSurface(jobject childView, int x, int y, int width, int height);
473 
474         // Destroys a SurfaceView for a plugin
475         void destroySurface(jobject childView);
476 
477         // Returns the context (android.content.Context) of the WebView
478         jobject getContext();
479 
480         // Manages requests to keep the screen on while the WebView is visible
481         void keepScreenOn(bool screenOn);
482 
483         // Make the rect (left, top, width, height) visible. If it can be fully
484         // fit, center it on the screen. Otherwise make sure the point specified
485         // by (left + xPercentInDoc * width, top + yPercentInDoc * height)
486         // pinned at the screen position (xPercentInView, yPercentInView).
487         void showRect(int left, int top, int width, int height, int contentWidth,
488             int contentHeight, float xPercentInDoc, float xPercentInView,
489             float yPercentInDoc, float yPercentInView);
490 
491         // Scale the rect (x, y, width, height) to make it just fit and centered
492         // in the current view.
493         void centerFitRect(int x, int y, int width, int height);
494 
495         // return a list of rects matching the touch point (x, y) with the slop
496         WTF::Vector<WebCore::IntRect> getTouchHighlightRects(int x, int y, int slop,
497                 WebCore::Node** node, WebCore::HitTestResult* hitTestResult);
498         // This does a sloppy hit test
499         AndroidHitTestResult hitTestAtPoint(int x, int y, int slop, bool doMoveMouse = false);
500         static bool nodeIsClickableOrFocusable(WebCore::Node* node);
501 
502         // Open a file chooser for selecting a file to upload
503         void openFileChooser(PassRefPtr<WebCore::FileChooser> );
504 
505         // reset the picture set to empty
506         void clearContent();
507 
508         // record content in a new BaseLayerAndroid, copying the layer tree as well
509         WebCore::BaseLayerAndroid* recordContent(SkIPoint* );
510 
511         // This creates a new BaseLayerAndroid by copying the current m_content
512         // and doing a copy of the layers. The layers' content may be updated
513         // as we are calling layersSync().
514         WebCore::BaseLayerAndroid* createBaseLayer(GraphicsLayerAndroid* root);
515         bool updateLayers(WebCore::LayerAndroid*);
516         void notifyAnimationStarted();
517 
textWrapWidth()518         int textWrapWidth() const { return m_textWrapWidth; }
scale()519         float scale() const { return m_scale; }
textWrapScale()520         float textWrapScale() const { return m_screenWidth * m_scale / m_textWrapWidth; }
mainFrame()521         WebCore::Frame* mainFrame() const { return m_mainFrame; }
522         WebCore::Frame* focusedFrame() const;
523 
524         void deleteText(int startX, int startY, int endX, int endY);
525         WTF::String getText(int startX, int startY, int endX, int endY);
526         void insertText(const WTF::String &text);
527 
528         // find on page
529         void resetFindOnPage();
530         int findTextOnPage(const WTF::String &text);
531         int findNextOnPage(bool forward);
532         void updateMatchCount() const;
533 
534 #if ENABLE(VIDEO)
535         void enterFullscreenForVideoLayer();
536         void exitFullscreenVideo();
537 #endif
538 
539         void setWebTextViewAutoFillable(int queryId, const string16& previewSummary);
540 
deviceMotionAndOrientationManager()541         DeviceMotionAndOrientationManager* deviceMotionAndOrientationManager() { return &m_deviceMotionAndOrientationManager; }
geolocationManager()542         GeolocationManager* geolocationManager() { return &m_geolocationManager; }
543 
544         void listBoxRequest(WebCoreReply* reply, const uint16_t** labels,
545                 size_t count, const int enabled[], size_t enabledCount,
546                 bool multiple, const int selected[], size_t selectedCountOrSelection);
547         bool drawIsPaused() const;
548         // The actual content (without title bar) size in doc coordinate
screenWidth()549         int  screenWidth() const { return m_screenWidth; }
screenHeight()550         int  screenHeight() const { return m_screenHeight; }
551         void setWebRequestContextUserAgent();
552         void setWebRequestContextCacheMode(int mode);
553         WebRequestContext* webRequestContext();
554         // Attempts to scroll the layer to the x,y coordinates of rect. The
555         // layer is the id of the LayerAndroid.
556         void scrollRenderLayer(int layer, const SkRect& rect);
557         // call only from webkit thread (like add/remove), return true if inst
558         // is still alive
559         static bool isInstance(WebViewCore*);
560         // if there exists at least one WebViewCore instance then we return the
561         // application context, otherwise NULL is returned.
562         static jobject getApplicationContext();
563         // Check whether a media mimeType is supported in Android media framework.
564         static bool isSupportedMediaMimeType(const WTF::String& mimeType);
565 
566         /**
567          * Returns all text ranges consumed by the cursor points referred
568          * to by startX, startY, endX, and endY. The vector will be empty
569          * if no text is in the given area or if the positions are invalid.
570          */
571         Vector<WebCore::VisibleSelection> getTextRanges(
572                 int startX, int startY, int endX, int endY);
573         static int platformLayerIdFromNode(WebCore::Node* node,
574                                            WebCore::LayerAndroid** outLayer = 0);
575         void selectText(SelectText::HandleId handleId, int x, int y);
576         bool selectWordAt(int x, int y);
577 
578         // Converts from the global content coordinates that WebView sends
579         // to frame-local content coordinates using the focused frame
580         WebCore::IntPoint convertGlobalContentToFrameContent(const WebCore::IntPoint& point, WebCore::Frame* frame = 0);
581         static void layerToAbsoluteOffset(const WebCore::LayerAndroid* layer,
582                                           WebCore::IntPoint& offset);
583 
584         // Retrieves the current locale from system properties
585         void getLocale(String& language, WTF::String& region);
586 
587         // Handles changes in system locale
588         void updateLocale();
589 
590         // these members are shared with webview.cpp
591         int m_touchGeneration; // copy of state in WebViewNative triggered by touch
592         int m_lastGeneration; // last action using up to date cache
593         // end of shared members
594 
595         void setPrerenderingEnabled(bool enable);
596 
597         // internal functions
598     private:
599         enum InputType {
600             NONE = -1,
601             NORMAL_TEXT_FIELD = 0,
602             TEXT_AREA = 1,
603             PASSWORD = 2,
604             SEARCH = 3,
605             EMAIL = 4,
606             NUMBER = 5,
607             TELEPHONE = 6,
608             URL = 7,
609         };
610 
611         WebCore::Node* currentFocus();
612         void layout();
613         // Create a set of pictures to represent the drawn DOM, driven by
614         // the invalidated region and the time required to draw (used to draw)
615         void recordPicturePile();
616 
617         virtual void paintContents(WebCore::GraphicsContext* gc, WebCore::IntRect& dirty);
618         virtual SkCanvas* createPrerenderCanvas(WebCore::PrerenderedInval* prerendered);
619 #ifdef CONTEXT_RECORDING
620         WebCore::GraphicsOperationCollection* rebuildGraphicsOperationCollection(const SkIRect& inval);
621 #endif
622         void sendNotifyProgressFinished();
623         /*
624          * Handle a mouse click, either from a touch or trackball press.
625          * @param frame Pointer to the Frame containing the node that was clicked on.
626          * @param node Pointer to the Node that was clicked on.
627          * @param fake This is a fake mouse click, used to put a textfield into focus. Do not
628          *      open the IME.
629          */
630         WebCore::HTMLAnchorElement* retrieveAnchorElement(int x, int y);
631         WebCore::HTMLElement* retrieveElement(int x, int y,
632             const WebCore::QualifiedName& );
633         WebCore::HTMLImageElement* retrieveImageElement(int x, int y);
634         // below are members responsible for accessibility support
635         WTF::String modifySelectionTextNavigationAxis(WebCore::DOMSelection* selection,
636                                                  int direction, int granularity);
637         WTF::String modifySelectionDomNavigationAxis(WebCore::DOMSelection* selection,
638                                                 int direction, int granularity);
639         WebCore::Text* traverseNextContentTextNode(WebCore::Node* fromNode,
640                                                    WebCore::Node* toNode,
641                                                    int direction);
642         bool isVisible(WebCore::Node* node);
643         bool isHeading(WebCore::Node* node);
644         WTF::String formatMarkup(WebCore::DOMSelection* selection);
645         void selectAt(int x, int y);
646 
647         void scrollNodeIntoView(WebCore::Frame* frame, WebCore::Node* node);
648         bool isContentTextNode(WebCore::Node* node);
649         WebCore::Node* getIntermediaryInputElement(WebCore::Node* fromNode,
650                                                    WebCore::Node* toNode,
651                                                    int direction);
652         bool isContentInputElement(WebCore::Node* node);
653         bool isDescendantOf(WebCore::Node* parent, WebCore::Node* node);
654         void advanceAnchorNode(WebCore::DOMSelection* selection, int direction,
655                                WTF::String& markup, bool ignoreFirstNode,
656                                WebCore::ExceptionCode& ec);
657         WebCore::Node* getNextAnchorNode(WebCore::Node* anchorNode,
658                                          bool skipFirstHack, int direction);
659         WebCore::Node* getImplicitBoundaryNode(WebCore::Node* node,
660                                                unsigned offset, int direction);
661         jobject createTextFieldInitData(WebCore::Node* node);
662         /**
663          * Calls into java to reset the text edit field with the
664          * current contents and selection.
665          */
666         void initEditField(WebCore::Node* node);
667 
668         /**
669          * If node is not a text input field or if it explicitly requests
670          * not to have keyboard input, then the soft keyboard is closed. If
671          * it is a text input field then initEditField is called and
672          * auto-fill information is requested for HTML form input fields.
673          */
674         void initializeTextInput(WebCore::Node* node, bool fake);
675 
676         /**
677          * Gets the input type a Node. NONE is returned if it isn't an
678          * input field.
679          */
680         InputType getInputType(WebCore::Node* node);
681 
682         /**
683          * If node is an input field, the spellcheck value for the
684          * field is returned. Otherwise true is returned.
685          */
686         static bool isSpellCheckEnabled(WebCore::Node* node);
687 
688         /**
689          * Returns the offsets of the selection area for both normal text
690          * fields and content editable fields. start and end are modified
691          * by this method.
692          */
693         static void getSelectionOffsets(WebCore::Node* node, int& start, int& end);
694         /**
695          * Gets the plain text of the specified editable text field. node
696          * may be content-editable or a plain text fields.
697          */
698         static WTF::String getInputText(WebCore::Node* node);
699         /**
700          * Gets the RenderTextControl for the given node if it has one.
701          * If its renderer isn't a RenderTextControl, then NULL is returned.
702          */
703         static WebCore::RenderTextControl* toRenderTextControl(WebCore::Node *node);
704         /**
705          * Sets the selection for node's editable field to the offsets
706          * between start (inclusive) and end (exclusive).
707          */
708         static void setSelection(WebCore::Node* node, int start, int end);
709         /**
710          * Returns the Position for the given offset for an editable
711          * field. The offset is relative to the node start.
712          */
713         static WebCore::Position getPositionForOffset(WebCore::Node* node, int offset);
714 
715         WebCore::VisiblePosition visiblePositionForContentPoint(int x, int y);
716         WebCore::VisiblePosition visiblePositionForContentPoint(const WebCore::IntPoint& point);
717         bool selectWordAroundPosition(WebCore::Frame* frame,
718                                       WebCore::VisiblePosition pos);
719         SelectText* createSelectText(const WebCore::VisibleSelection&);
720         void setSelectionCaretInfo(SelectText* selectTextContainer,
721                 const WebCore::Position& position,
722                 const WebCore::IntPoint& frameOffset,
723                 SelectText::HandleId handleId, SelectText::HandleType handleType,
724                 int offset, EAffinity affinity);
725         static int getMaxLength(WebCore::Node* node);
726         static WTF::String getFieldName(WebCore::Node* node);
727         static bool isAutoCompleteEnabled(WebCore::Node* node);
728         WebCore::IntRect absoluteClientRect(WebCore::Node* node,
729                 WebCore::LayerAndroid* layer);
730         static WebCore::IntRect positionToTextRect(const WebCore::Position& position,
731                 WebCore::EAffinity affinity, const WebCore::IntPoint& offset,
732                 const WebCore::IntRect& caretRect);
733         static bool isLtr(const WebCore::Position& position);
734         static WebCore::VisiblePosition trimSelectionPosition(
735                 const WebCore::VisiblePosition& start,
736                 const WebCore::VisiblePosition& stop);
737 
738         // called from constructor, to add this to a global list
739         static void addInstance(WebViewCore*);
740         // called from destructor, to remove this from a global list
741         static void removeInstance(WebViewCore*);
742 
743         bool prerenderingEnabled();
744 
745         friend class ListBoxReply;
746         struct JavaGlue;
747         struct JavaGlue*       m_javaGlue;
748         struct TextFieldInitDataGlue;
749         struct TextFieldInitDataGlue* m_textFieldInitDataGlue;
750         WebCore::Frame*        m_mainFrame;
751         WebCoreReply*          m_popupReply;
752         WebCore::PicturePile m_content; // the set of pictures to draw
753         // Used in passToJS to avoid updating the UI text field until after the
754         // key event has been processed.
755         bool m_blockTextfieldUpdates;
756         bool m_skipContentDraw;
757         // Passed in with key events to know when they were generated.  Store it
758         // with the cache so that we can ignore stale text changes.
759         int m_textGeneration;
760         int m_maxXScroll;
761         int m_maxYScroll;
762         int m_scrollOffsetX; // webview.java's current scroll in X
763         int m_scrollOffsetY; // webview.java's current scroll in Y
764         double m_scrollSetTime; // when the scroll was last set
765         WebCore::IntPoint m_mousePos;
766         // This is the location at which we will click. This is tracked
767         // separately from m_mousePos, because m_mousePos may be updated
768         // in the interval between ACTION_UP and when the click fires since
769         // that occurs after a delay. This also works around potential hardware
770         // issues if we get onHoverEvents when using the touch screen, as that
771         // will nullify the slop checking we do in hitTest (aka, ACTION_DOWN)
772         WebCore::IntPoint m_mouseClickPos;
773         int m_screenWidth; // width of the visible rect in document coordinates
774         int m_screenHeight;// height of the visible rect in document coordinates
775         int m_textWrapWidth;
776         float m_scale;
777         WebCore::PageGroup* m_groupForVisitedLinks;
778         int m_cacheMode;
779         bool m_fullscreenVideoMode;
780 
781         // find on page data
782         WTF::String m_searchText;
783         int m_matchCount;
784         int m_activeMatchIndex;
785         RefPtr<WebCore::Range> m_activeMatch;
786 
787         SkTDArray<PluginWidgetAndroid*> m_plugins;
788         WebCore::Timer<WebViewCore> m_pluginInvalTimer;
pluginInvalTimerFired(WebCore::Timer<WebViewCore> *)789         void pluginInvalTimerFired(WebCore::Timer<WebViewCore>*) {
790             this->drawPlugins();
791         }
792 
793         int m_screenOnCounter;
794         WebCore::Node* m_currentNodeDomNavigationAxis;
795         DeviceMotionAndOrientationManager m_deviceMotionAndOrientationManager;
796         GeolocationManager m_geolocationManager;
797 
798 #if ENABLE(TOUCH_EVENTS)
799         bool m_forwardingTouchEvents;
800 #endif
801 
802         scoped_refptr<WebRequestContext> m_webRequestContext;
803 
804         WTF::Mutex m_prerenderLock;
805         bool m_prerenderEnabled;
806     };
807 
808 }   // namespace android
809 
810 #endif // WebViewCore_h
811