• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef WebWidget_h
32 #define WebWidget_h
33 
34 #include "WebCanvas.h"
35 #include "WebCommon.h"
36 #include "WebCompositionCommand.h"
37 #include "WebTextDirection.h"
38 
39 namespace WebKit {
40 
41 class WebInputEvent;
42 class WebString;
43 struct WebRect;
44 struct WebSize;
45 
46 class WebWidget {
47 public:
48     // This method closes and deletes the WebWidget.
49     virtual void close() = 0;
50 
51     // Returns the current size of the WebWidget.
52     virtual WebSize size() = 0;
53 
54     // Called to resize the WebWidget.
55     virtual void resize(const WebSize&) = 0;
56 
57     // Called to layout the WebWidget.  This MUST be called before Paint,
58     // and it may result in calls to WebWidgetClient::didInvalidateRect.
59     virtual void layout() = 0;
60 
61     // Called to paint the specified region of the WebWidget onto the given
62     // canvas.  You MUST call Layout before calling this method.  It is
63     // okay to call paint multiple times once layout has been called,
64     // assuming no other changes are made to the WebWidget (e.g., once
65     // events are processed, it should be assumed that another call to
66     // layout is warranted before painting again).
67     virtual void paint(WebCanvas*, const WebRect&) = 0;
68 
69     // Called to inform the WebWidget of an input event.  Returns true if
70     // the event has been processed, false otherwise.
71     virtual bool handleInputEvent(const WebInputEvent&) = 0;
72 
73     // Called to inform the WebWidget that mouse capture was lost.
74     virtual void mouseCaptureLost() = 0;
75 
76     // Called to inform the WebWidget that it has gained or lost keyboard focus.
77     virtual void setFocus(bool) = 0;
78 
79     // Called to inform the WebWidget of a composition event.
80     virtual bool handleCompositionEvent(WebCompositionCommand command,
81                                         int cursorPosition,
82                                         int targetStart,
83                                         int targetEnd,
84                                         const WebString& text) = 0;
85 
86     // Retrieve the status of this WebWidget required by IME APIs.  Upon
87     // success enabled and caretBounds are set.
88     virtual bool queryCompositionStatus(bool* enabled, WebRect* caretBounds) = 0;
89 
90     // Changes the text direction of the selected input node.
91     virtual void setTextDirection(WebTextDirection) = 0;
92 
93 protected:
~WebWidget()94     ~WebWidget() { }
95 };
96 
97 } // namespace WebKit
98 
99 #endif
100