Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: sky/engine/public/web/WebWidget.h

Issue 770223002: Remove lots of code from the WebWidget/WebView/WebFrame layer. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 class WebLayerTreeView; 47 class WebLayerTreeView;
48 class WebMouseEvent; 48 class WebMouseEvent;
49 class WebString; 49 class WebString;
50 struct WebPoint; 50 struct WebPoint;
51 struct WebRenderingStats; 51 struct WebRenderingStats;
52 template <typename T> class WebVector; 52 template <typename T> class WebVector;
53 53
54 class WebWidget { 54 class WebWidget {
55 public: 55 public:
56 // This method closes and deletes the WebWidget. 56 // This method closes and deletes the WebWidget.
57 virtual void close() { } 57 virtual void close() = 0;
58 58
59 // Returns the current size of the WebWidget. 59 // Returns the current size of the WebWidget.
60 virtual WebSize size() { return WebSize(); } 60 virtual WebSize size() = 0;
61
62 // Used to group a series of resize events. For example, if the user
63 // drags a resizer then willStartLiveResize will be called, followed by a
64 // sequence of resize events, ending with willEndLiveResize when the user
65 // lets go of the resizer.
66 virtual void willStartLiveResize() { }
67 61
68 // Called to resize the WebWidget. 62 // Called to resize the WebWidget.
69 virtual void resize(const WebSize&) { } 63 virtual void resize(const WebSize&) = 0;
70 64
71 // Ends a group of resize events that was started with a call to 65 virtual void beginFrame(const WebBeginFrameArgs& frameTime) = 0;
72 // willStartLiveResize.
73 virtual void willEndLiveResize() { }
74
75 // Called to notify the WebWidget of entering/exiting fullscreen mode. The
76 // resize method may be called between will{Enter,Exit}FullScreen and
77 // did{Enter,Exit}FullScreen.
78 virtual void willEnterFullScreen() { }
79 virtual void didEnterFullScreen() { }
80 virtual void willExitFullScreen() { }
81 virtual void didExitFullScreen() { }
82
83 // Called to update imperative animation state. This should be called before
84 // paint, although the client can rate-limit these calls.
85 // FIXME: Remove this function once Chrome side patch lands.
86 void animate(double monotonicFrameBeginTime)
87 {
88 beginFrame(WebBeginFrameArgs(monotonicFrameBeginTime));
89 }
90 virtual void beginFrame(const WebBeginFrameArgs& frameTime) { }
91
92 // Called to notify that a previously begun frame was finished and
93 // committed to the compositor. This is used to schedule lower priority
94 // work after tasks such as input processing and painting.
95 virtual void didCommitFrameToCompositor() { }
96 66
97 // Called to layout the WebWidget. This MUST be called before Paint, 67 // Called to layout the WebWidget. This MUST be called before Paint,
98 // and it may result in calls to WebWidgetClient::didInvalidateRect. 68 // and it may result in calls to WebWidgetClient::didInvalidateRect.
99 virtual void layout() { } 69 virtual void layout() = 0;
100 70
101 // Called to paint the rectangular region within the WebWidget 71 // Called to paint the rectangular region within the WebWidget
102 // onto the specified canvas at (viewPort.x,viewPort.y). You MUST call 72 // onto the specified canvas at (viewPort.x,viewPort.y). You MUST call
103 // Layout before calling this method. It is okay to call paint 73 // Layout before calling this method. It is okay to call paint
104 // multiple times once layout has been called, assuming no other 74 // multiple times once layout has been called, assuming no other
105 // changes are made to the WebWidget (e.g., once events are 75 // changes are made to the WebWidget (e.g., once events are
106 // processed, it should be assumed that another call to layout is 76 // processed, it should be assumed that another call to layout is
107 // warranted before painting again). 77 // warranted before painting again).
108 virtual void paint(WebCanvas*, const WebRect& viewPort) { } 78 virtual void paint(WebCanvas*, const WebRect& viewPort) = 0;
109 79
110 // Returns true if we've started tracking repaint rectangles. 80 // Returns true if we've started tracking repaint rectangles.
111 virtual bool isTrackingRepaints() const { return false; } 81 virtual bool isTrackingRepaints() const = 0;
112
113 // Indicates that the compositing surface associated with this WebWidget is
114 // ready to use.
115 virtual void setCompositorSurfaceReady() { }
116
117 // Called to inform the WebWidget of a change in theme.
118 // Implementors that cache rendered copies of widgets need to re-render
119 // on receiving this message
120 virtual void themeChanged() { }
121 82
122 // Called to inform the WebWidget of an input event. Returns true if 83 // Called to inform the WebWidget of an input event. Returns true if
123 // the event has been processed, false otherwise. 84 // the event has been processed, false otherwise.
124 virtual bool handleInputEvent(const WebInputEvent&) { return false; } 85 virtual bool handleInputEvent(const WebInputEvent&) = 0;
125 86
126 // Called to inform the WebWidget of the mouse cursor's visibility. 87 // Called to inform the WebWidget of the mouse cursor's visibility.
127 virtual void setCursorVisibilityState(bool isVisible) { } 88 virtual void setCursorVisibilityState(bool isVisible) = 0;
128 89
129 // Called to inform the WebWidget that mouse capture was lost. 90 // Called to inform the WebWidget that mouse capture was lost.
130 virtual void mouseCaptureLost() { } 91 virtual void mouseCaptureLost() = 0;
131 92
132 // Called to inform the WebWidget that it has gained or lost keyboard focus. 93 // Called to inform the WebWidget that it has gained or lost keyboard focus.
133 virtual void setFocus(bool) { } 94 virtual void setFocus(bool) = 0;
134 95
135 // Called to inform the WebWidget of a new composition text. 96 // Called to inform the WebWidget of a new composition text.
136 // If selectionStart and selectionEnd has the same value, then it indicates 97 // If selectionStart and selectionEnd has the same value, then it indicates
137 // the input caret position. If the text is empty, then the existing 98 // the input caret position. If the text is empty, then the existing
138 // composition text will be cancelled. 99 // composition text will be cancelled.
139 // Returns true if the composition text was set successfully. 100 // Returns true if the composition text was set successfully.
140 virtual bool setComposition( 101 virtual bool setComposition(
141 const WebString& text, 102 const WebString& text,
142 const WebVector<WebCompositionUnderline>& underlines, 103 const WebVector<WebCompositionUnderline>& underlines,
143 int selectionStart, 104 int selectionStart,
144 int selectionEnd) { return false; } 105 int selectionEnd) = 0;
145 106
146 enum ConfirmCompositionBehavior { 107 enum ConfirmCompositionBehavior {
147 DoNotKeepSelection, 108 DoNotKeepSelection,
148 KeepSelection, 109 KeepSelection,
149 }; 110 };
150 111
151 // Called to inform the WebWidget to confirm an ongoing composition. 112 // Called to inform the WebWidget to confirm an ongoing composition.
152 // This method is same as confirmComposition(WebString()); 113 // This method is same as confirmComposition(WebString());
153 // Returns true if there is an ongoing composition. 114 // Returns true if there is an ongoing composition.
154 virtual bool confirmComposition() { return false; } // Deprecated 115 virtual bool confirmComposition() = 0; // Deprecated
155 virtual bool confirmComposition(ConfirmCompositionBehavior selectionBehavior ) { return false; } 116 virtual bool confirmComposition(ConfirmCompositionBehavior selectionBehavior ) = 0;
156 117
157 // Called to inform the WebWidget to confirm an ongoing composition with a 118 // Called to inform the WebWidget to confirm an ongoing composition with a
158 // new composition text. If the text is empty then the current composition 119 // new composition text. If the text is empty then the current composition
159 // text is confirmed. If there is no ongoing composition, then deletes the 120 // text is confirmed. If there is no ongoing composition, then deletes the
160 // current selection and inserts the text. This method has no effect if 121 // current selection and inserts the text. This method has no effect if
161 // there is no ongoing composition and the text is empty. 122 // there is no ongoing composition and the text is empty.
162 // Returns true if there is an ongoing composition or the text is inserted. 123 // Returns true if there is an ongoing composition or the text is inserted.
163 virtual bool confirmComposition(const WebString& text) { return false; } 124 virtual bool confirmComposition(const WebString& text) = 0;
164 125
165 // Fetches the character range of the current composition, also called the 126 // Fetches the character range of the current composition, also called the
166 // "marked range." Returns true and fills the out-paramters on success; 127 // "marked range." Returns true and fills the out-paramters on success;
167 // returns false on failure. 128 // returns false on failure.
168 virtual bool compositionRange(size_t* location, size_t* length) { return fal se; } 129 virtual bool compositionRange(size_t* location, size_t* length) = 0;
169 130
170 // Returns information about the current text input of this WebWidget. 131 // Returns information about the current text input of this WebWidget.
171 virtual WebTextInputInfo textInputInfo() { return WebTextInputInfo(); } 132 virtual WebTextInputInfo textInputInfo() = 0;
172
173 // Returns the anchor and focus bounds of the current selection.
174 // If the selection range is empty, it returns the caret bounds.
175 virtual bool selectionBounds(WebRect& anchor, WebRect& focus) const { return false; }
176 133
177 // Called to notify that IME candidate window has changed its visibility or 134 // Called to notify that IME candidate window has changed its visibility or
178 // its appearance. These calls correspond to trigger 135 // its appearance. These calls correspond to trigger
179 // candidatewindow{show,update,hide} events defined in W3C IME API. 136 // candidatewindow{show,update,hide} events defined in W3C IME API.
180 virtual void didShowCandidateWindow() { } 137 virtual void didShowCandidateWindow() = 0;
181 virtual void didUpdateCandidateWindow() { } 138 virtual void didUpdateCandidateWindow() = 0;
182 virtual void didHideCandidateWindow() { } 139 virtual void didHideCandidateWindow() = 0;
183
184 // Returns the text direction at the start and end bounds of the current sel ection.
185 // If the selection range is empty, it returns false.
186 virtual bool selectionTextDirection(WebTextDirection& start, WebTextDirectio n& end) const { return false; }
187
188 // Returns true if the selection range is nonempty and its anchor is first
189 // (i.e its anchor is its start).
190 virtual bool isSelectionAnchorFirst() const { return false; }
191
192 // Fetch the current selection range of this WebWidget. If there is no
193 // selection, it will output a 0-length range with the location at the
194 // caret. Returns true and fills the out-paramters on success; returns false
195 // on failure.
196 virtual bool caretOrSelectionRange(size_t* location, size_t* length) { retur n false; }
197
198 // Changes the text direction of the selected input node.
199 virtual void setTextDirection(WebTextDirection) { }
200
201 // Calling WebWidgetClient::requestPointerLock() will result in one
202 // return call to didAcquirePointerLock() or didNotAcquirePointerLock().
203 virtual void didAcquirePointerLock() { }
204 virtual void didNotAcquirePointerLock() { }
205
206 // Pointer lock was held, but has been lost. This may be due to a
207 // request via WebWidgetClient::requestPointerUnlock(), or for other
208 // reasons such as the user exiting lock, window focus changing, etc.
209 virtual void didLosePointerLock() { }
210 140
211 // The page background color. Can be used for filling in areas without 141 // The page background color. Can be used for filling in areas without
212 // content. 142 // content.
213 virtual WebColor backgroundColor() const { return 0xFFFFFFFF; /* SK_ColorWHI TE */ } 143 virtual WebColor backgroundColor() const = 0;
214 144
215 protected: 145 protected:
216 ~WebWidget() { } 146 ~WebWidget() { }
217 }; 147 };
218 148
219 } // namespace blink 149 } // namespace blink
220 150
221 #endif // SKY_ENGINE_PUBLIC_WEB_WEBWIDGET_H_ 151 #endif // SKY_ENGINE_PUBLIC_WEB_WEBWIDGET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698