OLD | NEW |
| (Empty) |
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 SKY_ENGINE_PUBLIC_WEB_WEBWIDGET_H_ | |
32 #define SKY_ENGINE_PUBLIC_WEB_WEBWIDGET_H_ | |
33 | |
34 #include "../platform/WebCanvas.h" | |
35 #include "../platform/WebCommon.h" | |
36 #include "../platform/WebRect.h" | |
37 #include "../platform/WebSize.h" | |
38 #include "sky/engine/public/web/WebBeginFrameArgs.h" | |
39 #include "sky/engine/public/web/WebCompositionUnderline.h" | |
40 #include "sky/engine/public/web/WebTextDirection.h" | |
41 #include "sky/engine/public/web/WebTextInputInfo.h" | |
42 | |
43 namespace blink { | |
44 | |
45 class WebInputEvent; | |
46 class WebLayerTreeView; | |
47 class WebString; | |
48 struct WebPoint; | |
49 struct WebRenderingStats; | |
50 template <typename T> class WebVector; | |
51 | |
52 class WebWidget { | |
53 public: | |
54 // This method closes and deletes the WebWidget. | |
55 virtual void close() = 0; | |
56 | |
57 // Returns the current size of the WebWidget. | |
58 virtual WebSize size() = 0; | |
59 | |
60 // Called to resize the WebWidget. | |
61 virtual void resize(const WebSize&) = 0; | |
62 | |
63 virtual void beginFrame(const WebBeginFrameArgs& frameTime) = 0; | |
64 | |
65 // Called to layout the WebWidget. This MUST be called before Paint. | |
66 virtual void layout() = 0; | |
67 | |
68 // Called to paint the rectangular region within the WebWidget | |
69 // onto the specified canvas at (viewPort.x,viewPort.y). You MUST call | |
70 // Layout before calling this method. It is okay to call paint | |
71 // multiple times once layout has been called, assuming no other | |
72 // changes are made to the WebWidget (e.g., once events are | |
73 // processed, it should be assumed that another call to layout is | |
74 // warranted before painting again). | |
75 virtual void paint(WebCanvas*, const WebRect& viewPort) = 0; | |
76 | |
77 // Called to inform the WebWidget of an input event. Returns true if | |
78 // the event has been processed, false otherwise. | |
79 virtual bool handleInputEvent(const WebInputEvent&) = 0; | |
80 | |
81 // Called to inform the WebWidget that it has gained or lost keyboard focus. | |
82 virtual void setFocus(bool) = 0; | |
83 | |
84 // Called to inform the WebWidget of a new composition text. | |
85 // If selectionStart and selectionEnd has the same value, then it indicates | |
86 // the input caret position. If the text is empty, then the existing | |
87 // composition text will be cancelled. | |
88 // Returns true if the composition text was set successfully. | |
89 virtual bool setComposition( | |
90 const WebString& text, | |
91 const WebVector<WebCompositionUnderline>& underlines, | |
92 int selectionStart, | |
93 int selectionEnd) = 0; | |
94 | |
95 enum ConfirmCompositionBehavior { | |
96 DoNotKeepSelection, | |
97 KeepSelection, | |
98 }; | |
99 | |
100 // Called to inform the WebWidget to confirm an ongoing composition. | |
101 // This method is same as confirmComposition(WebString()); | |
102 // Returns true if there is an ongoing composition. | |
103 virtual bool confirmComposition() = 0; // Deprecated | |
104 virtual bool confirmComposition(ConfirmCompositionBehavior selectionBehavior
) = 0; | |
105 | |
106 // Called to inform the WebWidget to confirm an ongoing composition with a | |
107 // new composition text. If the text is empty then the current composition | |
108 // text is confirmed. If there is no ongoing composition, then deletes the | |
109 // current selection and inserts the text. This method has no effect if | |
110 // there is no ongoing composition and the text is empty. | |
111 // Returns true if there is an ongoing composition or the text is inserted. | |
112 virtual bool confirmComposition(const WebString& text) = 0; | |
113 | |
114 // Returns information about the current text input of this WebWidget. | |
115 virtual WebTextInputInfo textInputInfo() = 0; | |
116 | |
117 protected: | |
118 ~WebWidget() { } | |
119 }; | |
120 | |
121 } // namespace blink | |
122 | |
123 #endif // SKY_ENGINE_PUBLIC_WEB_WEBWIDGET_H_ | |
OLD | NEW |