Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsIWidget_h__ |
michael@0 | 7 | #define nsIWidget_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsISupports.h" |
michael@0 | 10 | #include "nsColor.h" |
michael@0 | 11 | #include "nsRect.h" |
michael@0 | 12 | #include "nsStringGlue.h" |
michael@0 | 13 | |
michael@0 | 14 | #include "nsCOMPtr.h" |
michael@0 | 15 | #include "nsAutoPtr.h" |
michael@0 | 16 | #include "nsWidgetInitData.h" |
michael@0 | 17 | #include "nsTArray.h" |
michael@0 | 18 | #include "nsITimer.h" |
michael@0 | 19 | #include "nsXULAppAPI.h" |
michael@0 | 20 | #include "mozilla/EventForwards.h" |
michael@0 | 21 | #include "mozilla/layers/LayersTypes.h" |
michael@0 | 22 | #include "mozilla/RefPtr.h" |
michael@0 | 23 | #include "mozilla/TimeStamp.h" |
michael@0 | 24 | #include "Units.h" |
michael@0 | 25 | |
michael@0 | 26 | // forward declarations |
michael@0 | 27 | class nsFontMetrics; |
michael@0 | 28 | class nsRenderingContext; |
michael@0 | 29 | class nsDeviceContext; |
michael@0 | 30 | struct nsFont; |
michael@0 | 31 | class nsIRollupListener; |
michael@0 | 32 | class imgIContainer; |
michael@0 | 33 | class gfxASurface; |
michael@0 | 34 | class nsIContent; |
michael@0 | 35 | class ViewWrapper; |
michael@0 | 36 | class nsIWidgetListener; |
michael@0 | 37 | class nsIntRegion; |
michael@0 | 38 | |
michael@0 | 39 | namespace mozilla { |
michael@0 | 40 | namespace dom { |
michael@0 | 41 | class TabChild; |
michael@0 | 42 | } |
michael@0 | 43 | namespace layers { |
michael@0 | 44 | class Composer2D; |
michael@0 | 45 | class CompositorChild; |
michael@0 | 46 | class LayerManager; |
michael@0 | 47 | class LayerManagerComposite; |
michael@0 | 48 | class PLayerTransactionChild; |
michael@0 | 49 | } |
michael@0 | 50 | namespace gfx { |
michael@0 | 51 | class DrawTarget; |
michael@0 | 52 | } |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | /** |
michael@0 | 56 | * Callback function that processes events. |
michael@0 | 57 | * |
michael@0 | 58 | * The argument is actually a subtype (subclass) of WidgetEvent which carries |
michael@0 | 59 | * platform specific information about the event. Platform specific code |
michael@0 | 60 | * knows how to deal with it. |
michael@0 | 61 | * |
michael@0 | 62 | * The return value determines whether or not the default action should take |
michael@0 | 63 | * place. |
michael@0 | 64 | */ |
michael@0 | 65 | typedef nsEventStatus (* EVENT_CALLBACK)(mozilla::WidgetGUIEvent* aEvent); |
michael@0 | 66 | |
michael@0 | 67 | // Hide the native window system's real window type so as to avoid |
michael@0 | 68 | // including native window system types and APIs. This is necessary |
michael@0 | 69 | // to ensure cross-platform code. |
michael@0 | 70 | typedef void* nsNativeWidget; |
michael@0 | 71 | |
michael@0 | 72 | /** |
michael@0 | 73 | * Flags for the getNativeData function. |
michael@0 | 74 | * See getNativeData() |
michael@0 | 75 | */ |
michael@0 | 76 | #define NS_NATIVE_WINDOW 0 |
michael@0 | 77 | #define NS_NATIVE_GRAPHIC 1 |
michael@0 | 78 | #define NS_NATIVE_TMP_WINDOW 2 |
michael@0 | 79 | #define NS_NATIVE_WIDGET 3 |
michael@0 | 80 | #define NS_NATIVE_DISPLAY 4 |
michael@0 | 81 | #define NS_NATIVE_REGION 5 |
michael@0 | 82 | #define NS_NATIVE_OFFSETX 6 |
michael@0 | 83 | #define NS_NATIVE_OFFSETY 7 |
michael@0 | 84 | #define NS_NATIVE_PLUGIN_PORT 8 |
michael@0 | 85 | #define NS_NATIVE_SCREEN 9 |
michael@0 | 86 | // The toplevel GtkWidget containing this nsIWidget: |
michael@0 | 87 | #define NS_NATIVE_SHELLWIDGET 10 |
michael@0 | 88 | // Has to match to NPNVnetscapeWindow, and shareable across processes |
michael@0 | 89 | // HWND on Windows and XID on X11 |
michael@0 | 90 | #define NS_NATIVE_SHAREABLE_WINDOW 11 |
michael@0 | 91 | #ifdef XP_MACOSX |
michael@0 | 92 | #define NS_NATIVE_PLUGIN_PORT_QD 100 |
michael@0 | 93 | #define NS_NATIVE_PLUGIN_PORT_CG 101 |
michael@0 | 94 | #endif |
michael@0 | 95 | #ifdef XP_WIN |
michael@0 | 96 | #define NS_NATIVE_TSF_THREAD_MGR 100 |
michael@0 | 97 | #define NS_NATIVE_TSF_CATEGORY_MGR 101 |
michael@0 | 98 | #define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102 |
michael@0 | 99 | #define NS_NATIVE_ICOREWINDOW 103 // winrt specific |
michael@0 | 100 | #endif |
michael@0 | 101 | |
michael@0 | 102 | #define NS_IWIDGET_IID \ |
michael@0 | 103 | { 0x87d80888, 0x9917, 0x4bfb, \ |
michael@0 | 104 | { 0x81, 0xa9, 0x1c, 0x5e, 0x30, 0x9c, 0x78, 0xb4 } } |
michael@0 | 105 | |
michael@0 | 106 | /* |
michael@0 | 107 | * Window shadow styles |
michael@0 | 108 | * Also used for the -moz-window-shadow CSS property |
michael@0 | 109 | */ |
michael@0 | 110 | |
michael@0 | 111 | #define NS_STYLE_WINDOW_SHADOW_NONE 0 |
michael@0 | 112 | #define NS_STYLE_WINDOW_SHADOW_DEFAULT 1 |
michael@0 | 113 | #define NS_STYLE_WINDOW_SHADOW_MENU 2 |
michael@0 | 114 | #define NS_STYLE_WINDOW_SHADOW_TOOLTIP 3 |
michael@0 | 115 | #define NS_STYLE_WINDOW_SHADOW_SHEET 4 |
michael@0 | 116 | |
michael@0 | 117 | /** |
michael@0 | 118 | * Transparency modes |
michael@0 | 119 | */ |
michael@0 | 120 | |
michael@0 | 121 | enum nsTransparencyMode { |
michael@0 | 122 | eTransparencyOpaque = 0, // Fully opaque |
michael@0 | 123 | eTransparencyTransparent, // Parts of the window may be transparent |
michael@0 | 124 | eTransparencyGlass, // Transparent parts of the window have Vista AeroGlass effect applied |
michael@0 | 125 | eTransparencyBorderlessGlass // As above, but without a border around the opaque areas when there would otherwise be one with eTransparencyGlass |
michael@0 | 126 | }; |
michael@0 | 127 | |
michael@0 | 128 | /** |
michael@0 | 129 | * Cursor types. |
michael@0 | 130 | */ |
michael@0 | 131 | |
michael@0 | 132 | enum nsCursor { ///(normal cursor, usually rendered as an arrow) |
michael@0 | 133 | eCursor_standard, |
michael@0 | 134 | ///(system is busy, usually rendered as a hourglass or watch) |
michael@0 | 135 | eCursor_wait, |
michael@0 | 136 | ///(Selecting something, usually rendered as an IBeam) |
michael@0 | 137 | eCursor_select, |
michael@0 | 138 | ///(can hyper-link, usually rendered as a human hand) |
michael@0 | 139 | eCursor_hyperlink, |
michael@0 | 140 | ///(north/south/west/east edge sizing) |
michael@0 | 141 | eCursor_n_resize, |
michael@0 | 142 | eCursor_s_resize, |
michael@0 | 143 | eCursor_w_resize, |
michael@0 | 144 | eCursor_e_resize, |
michael@0 | 145 | ///(corner sizing) |
michael@0 | 146 | eCursor_nw_resize, |
michael@0 | 147 | eCursor_se_resize, |
michael@0 | 148 | eCursor_ne_resize, |
michael@0 | 149 | eCursor_sw_resize, |
michael@0 | 150 | eCursor_crosshair, |
michael@0 | 151 | eCursor_move, |
michael@0 | 152 | eCursor_help, |
michael@0 | 153 | eCursor_copy, // CSS3 |
michael@0 | 154 | eCursor_alias, |
michael@0 | 155 | eCursor_context_menu, |
michael@0 | 156 | eCursor_cell, |
michael@0 | 157 | eCursor_grab, |
michael@0 | 158 | eCursor_grabbing, |
michael@0 | 159 | eCursor_spinning, |
michael@0 | 160 | eCursor_zoom_in, |
michael@0 | 161 | eCursor_zoom_out, |
michael@0 | 162 | eCursor_not_allowed, |
michael@0 | 163 | eCursor_col_resize, |
michael@0 | 164 | eCursor_row_resize, |
michael@0 | 165 | eCursor_no_drop, |
michael@0 | 166 | eCursor_vertical_text, |
michael@0 | 167 | eCursor_all_scroll, |
michael@0 | 168 | eCursor_nesw_resize, |
michael@0 | 169 | eCursor_nwse_resize, |
michael@0 | 170 | eCursor_ns_resize, |
michael@0 | 171 | eCursor_ew_resize, |
michael@0 | 172 | eCursor_none, |
michael@0 | 173 | // This one better be the last one in this list. |
michael@0 | 174 | eCursorCount |
michael@0 | 175 | }; |
michael@0 | 176 | |
michael@0 | 177 | enum nsTopLevelWidgetZPlacement { // for PlaceBehind() |
michael@0 | 178 | eZPlacementBottom = 0, // bottom of the window stack |
michael@0 | 179 | eZPlacementBelow, // just below another widget |
michael@0 | 180 | eZPlacementTop // top of the window stack |
michael@0 | 181 | }; |
michael@0 | 182 | |
michael@0 | 183 | /** |
michael@0 | 184 | * Before the OS goes to sleep, this topic is notified. |
michael@0 | 185 | */ |
michael@0 | 186 | #define NS_WIDGET_SLEEP_OBSERVER_TOPIC "sleep_notification" |
michael@0 | 187 | |
michael@0 | 188 | /** |
michael@0 | 189 | * After the OS wakes up, this topic is notified. |
michael@0 | 190 | */ |
michael@0 | 191 | #define NS_WIDGET_WAKE_OBSERVER_TOPIC "wake_notification" |
michael@0 | 192 | |
michael@0 | 193 | /** |
michael@0 | 194 | * Before the OS suspends the current process, this topic is notified. Some |
michael@0 | 195 | * OS will kill processes that are suspended instead of resuming them. |
michael@0 | 196 | * For that reason this topic may be useful to safely close down resources. |
michael@0 | 197 | */ |
michael@0 | 198 | #define NS_WIDGET_SUSPEND_PROCESS_OBSERVER_TOPIC "suspend_process_notification" |
michael@0 | 199 | |
michael@0 | 200 | /** |
michael@0 | 201 | * After the current process resumes from being suspended, this topic is |
michael@0 | 202 | * notified. |
michael@0 | 203 | */ |
michael@0 | 204 | #define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification" |
michael@0 | 205 | |
michael@0 | 206 | /** |
michael@0 | 207 | * Preference for receiving IME updates |
michael@0 | 208 | * |
michael@0 | 209 | * If mWantUpdates is not NOTIFY_NOTHING, nsTextStateManager will observe text |
michael@0 | 210 | * change and/or selection change and call nsIWidget::NotifyIME() with |
michael@0 | 211 | * NOTIFY_IME_OF_SELECTION_CHANGE and/or NOTIFY_IME_OF_TEXT_CHANGE. |
michael@0 | 212 | * Please note that the text change observing cost is very expensive especially |
michael@0 | 213 | * on an HTML editor has focus. |
michael@0 | 214 | * If the IME implementation on a particular platform doesn't care about |
michael@0 | 215 | * NOTIFY_IME_OF_SELECTION_CHANGE and/or NOTIFY_IME_OF_TEXT_CHANGE, |
michael@0 | 216 | * they should set mWantUpdates to NOTIFY_NOTHING to avoid the cost. |
michael@0 | 217 | * If the IME implementation needs notifications even while our process is |
michael@0 | 218 | * deactive, it should also set NOTIFY_DURING_DEACTIVE. |
michael@0 | 219 | */ |
michael@0 | 220 | struct nsIMEUpdatePreference { |
michael@0 | 221 | |
michael@0 | 222 | typedef uint8_t Notifications; |
michael@0 | 223 | |
michael@0 | 224 | enum MOZ_ENUM_TYPE(Notifications) |
michael@0 | 225 | { |
michael@0 | 226 | NOTIFY_NOTHING = 0, |
michael@0 | 227 | NOTIFY_SELECTION_CHANGE = 1 << 0, |
michael@0 | 228 | NOTIFY_TEXT_CHANGE = 1 << 1, |
michael@0 | 229 | NOTIFY_POSITION_CHANGE = 1 << 2, |
michael@0 | 230 | // Following values indicate when widget needs or doesn't need notification. |
michael@0 | 231 | NOTIFY_CHANGES_CAUSED_BY_COMPOSITION = 1 << 6, |
michael@0 | 232 | // NOTE: NOTIFY_DURING_DEACTIVE isn't supported in environments where two |
michael@0 | 233 | // or more compositions are possible. E.g., Mac and Linux (GTK). |
michael@0 | 234 | NOTIFY_DURING_DEACTIVE = 1 << 7, |
michael@0 | 235 | // Changes are notified in following conditions if the instance is |
michael@0 | 236 | // just constructed. If some platforms don't need change notifications |
michael@0 | 237 | // in some of following conditions, the platform should remove following |
michael@0 | 238 | // flags before returing the instance from nsIWidget::GetUpdatePreference(). |
michael@0 | 239 | DEFAULT_CONDITIONS_OF_NOTIFYING_CHANGES = |
michael@0 | 240 | NOTIFY_CHANGES_CAUSED_BY_COMPOSITION |
michael@0 | 241 | }; |
michael@0 | 242 | |
michael@0 | 243 | nsIMEUpdatePreference() |
michael@0 | 244 | : mWantUpdates(DEFAULT_CONDITIONS_OF_NOTIFYING_CHANGES) |
michael@0 | 245 | { |
michael@0 | 246 | } |
michael@0 | 247 | |
michael@0 | 248 | nsIMEUpdatePreference(Notifications aWantUpdates) |
michael@0 | 249 | : mWantUpdates(aWantUpdates | DEFAULT_CONDITIONS_OF_NOTIFYING_CHANGES) |
michael@0 | 250 | { |
michael@0 | 251 | } |
michael@0 | 252 | |
michael@0 | 253 | void DontNotifyChangesCausedByComposition() |
michael@0 | 254 | { |
michael@0 | 255 | mWantUpdates &= ~DEFAULT_CONDITIONS_OF_NOTIFYING_CHANGES; |
michael@0 | 256 | } |
michael@0 | 257 | |
michael@0 | 258 | bool WantSelectionChange() const |
michael@0 | 259 | { |
michael@0 | 260 | return !!(mWantUpdates & NOTIFY_SELECTION_CHANGE); |
michael@0 | 261 | } |
michael@0 | 262 | |
michael@0 | 263 | bool WantTextChange() const |
michael@0 | 264 | { |
michael@0 | 265 | return !!(mWantUpdates & NOTIFY_TEXT_CHANGE); |
michael@0 | 266 | } |
michael@0 | 267 | |
michael@0 | 268 | bool WantPositionChanged() const |
michael@0 | 269 | { |
michael@0 | 270 | return !!(mWantUpdates & NOTIFY_POSITION_CHANGE); |
michael@0 | 271 | } |
michael@0 | 272 | |
michael@0 | 273 | bool WantChanges() const |
michael@0 | 274 | { |
michael@0 | 275 | return WantSelectionChange() || WantTextChange(); |
michael@0 | 276 | } |
michael@0 | 277 | |
michael@0 | 278 | bool WantChangesCausedByComposition() const |
michael@0 | 279 | { |
michael@0 | 280 | return WantChanges() && |
michael@0 | 281 | !!(mWantUpdates & NOTIFY_CHANGES_CAUSED_BY_COMPOSITION); |
michael@0 | 282 | } |
michael@0 | 283 | |
michael@0 | 284 | bool WantDuringDeactive() const |
michael@0 | 285 | { |
michael@0 | 286 | return !!(mWantUpdates & NOTIFY_DURING_DEACTIVE); |
michael@0 | 287 | } |
michael@0 | 288 | |
michael@0 | 289 | Notifications mWantUpdates; |
michael@0 | 290 | }; |
michael@0 | 291 | |
michael@0 | 292 | |
michael@0 | 293 | /* |
michael@0 | 294 | * Contains IMEStatus plus information about the current |
michael@0 | 295 | * input context that the IME can use as hints if desired. |
michael@0 | 296 | */ |
michael@0 | 297 | |
michael@0 | 298 | namespace mozilla { |
michael@0 | 299 | namespace widget { |
michael@0 | 300 | |
michael@0 | 301 | struct IMEState { |
michael@0 | 302 | /** |
michael@0 | 303 | * IME enabled states, the mEnabled value of |
michael@0 | 304 | * SetInputContext()/GetInputContext() should be one value of following |
michael@0 | 305 | * values. |
michael@0 | 306 | * |
michael@0 | 307 | * WARNING: If you change these values, you also need to edit: |
michael@0 | 308 | * nsIDOMWindowUtils.idl |
michael@0 | 309 | * nsContentUtils::GetWidgetStatusFromIMEStatus |
michael@0 | 310 | */ |
michael@0 | 311 | enum Enabled { |
michael@0 | 312 | /** |
michael@0 | 313 | * 'Disabled' means the user cannot use IME. So, the IME open state should |
michael@0 | 314 | * be 'closed' during 'disabled'. |
michael@0 | 315 | */ |
michael@0 | 316 | DISABLED, |
michael@0 | 317 | /** |
michael@0 | 318 | * 'Enabled' means the user can use IME. |
michael@0 | 319 | */ |
michael@0 | 320 | ENABLED, |
michael@0 | 321 | /** |
michael@0 | 322 | * 'Password' state is a special case for the password editors. |
michael@0 | 323 | * E.g., on mac, the password editors should disable the non-Roman |
michael@0 | 324 | * keyboard layouts at getting focus. Thus, the password editor may have |
michael@0 | 325 | * special rules on some platforms. |
michael@0 | 326 | */ |
michael@0 | 327 | PASSWORD, |
michael@0 | 328 | /** |
michael@0 | 329 | * This state is used when a plugin is focused. |
michael@0 | 330 | * When a plug-in is focused content, we should send native events |
michael@0 | 331 | * directly. Because we don't process some native events, but they may |
michael@0 | 332 | * be needed by the plug-in. |
michael@0 | 333 | */ |
michael@0 | 334 | PLUGIN |
michael@0 | 335 | }; |
michael@0 | 336 | Enabled mEnabled; |
michael@0 | 337 | |
michael@0 | 338 | /** |
michael@0 | 339 | * IME open states the mOpen value of SetInputContext() should be one value of |
michael@0 | 340 | * OPEN, CLOSE or DONT_CHANGE_OPEN_STATE. GetInputContext() should return |
michael@0 | 341 | * OPEN, CLOSE or OPEN_STATE_NOT_SUPPORTED. |
michael@0 | 342 | */ |
michael@0 | 343 | enum Open { |
michael@0 | 344 | /** |
michael@0 | 345 | * 'Unsupported' means the platform cannot return actual IME open state. |
michael@0 | 346 | * This value is used only by GetInputContext(). |
michael@0 | 347 | */ |
michael@0 | 348 | OPEN_STATE_NOT_SUPPORTED, |
michael@0 | 349 | /** |
michael@0 | 350 | * 'Don't change' means the widget shouldn't change IME open state when |
michael@0 | 351 | * SetInputContext() is called. |
michael@0 | 352 | */ |
michael@0 | 353 | DONT_CHANGE_OPEN_STATE = OPEN_STATE_NOT_SUPPORTED, |
michael@0 | 354 | /** |
michael@0 | 355 | * 'Open' means that IME should compose in its primary language (or latest |
michael@0 | 356 | * input mode except direct ASCII character input mode). Even if IME is |
michael@0 | 357 | * opened by this value, users should be able to close IME by theirselves. |
michael@0 | 358 | * Web contents can specify this value by |ime-mode: active;|. |
michael@0 | 359 | */ |
michael@0 | 360 | OPEN, |
michael@0 | 361 | /** |
michael@0 | 362 | * 'Closed' means that IME shouldn't handle key events (or should handle |
michael@0 | 363 | * as ASCII character inputs on mobile device). Even if IME is closed by |
michael@0 | 364 | * this value, users should be able to open IME by theirselves. |
michael@0 | 365 | * Web contents can specify this value by |ime-mode: inactive;|. |
michael@0 | 366 | */ |
michael@0 | 367 | CLOSED |
michael@0 | 368 | }; |
michael@0 | 369 | Open mOpen; |
michael@0 | 370 | |
michael@0 | 371 | IMEState() : mEnabled(ENABLED), mOpen(DONT_CHANGE_OPEN_STATE) { } |
michael@0 | 372 | |
michael@0 | 373 | IMEState(Enabled aEnabled, Open aOpen = DONT_CHANGE_OPEN_STATE) : |
michael@0 | 374 | mEnabled(aEnabled), mOpen(aOpen) |
michael@0 | 375 | { |
michael@0 | 376 | } |
michael@0 | 377 | }; |
michael@0 | 378 | |
michael@0 | 379 | struct InputContext { |
michael@0 | 380 | InputContext() : mNativeIMEContext(nullptr) {} |
michael@0 | 381 | |
michael@0 | 382 | bool IsPasswordEditor() const |
michael@0 | 383 | { |
michael@0 | 384 | return mHTMLInputType.LowerCaseEqualsLiteral("password"); |
michael@0 | 385 | } |
michael@0 | 386 | |
michael@0 | 387 | IMEState mIMEState; |
michael@0 | 388 | |
michael@0 | 389 | /* The type of the input if the input is a html input field */ |
michael@0 | 390 | nsString mHTMLInputType; |
michael@0 | 391 | |
michael@0 | 392 | /* The type of the inputmode */ |
michael@0 | 393 | nsString mHTMLInputInputmode; |
michael@0 | 394 | |
michael@0 | 395 | /* A hint for the action that is performed when the input is submitted */ |
michael@0 | 396 | nsString mActionHint; |
michael@0 | 397 | |
michael@0 | 398 | /* Native IME context for the widget. This doesn't come from the argument of |
michael@0 | 399 | SetInputContext(). If there is only one context in the process, this may |
michael@0 | 400 | be nullptr. */ |
michael@0 | 401 | void* mNativeIMEContext; |
michael@0 | 402 | }; |
michael@0 | 403 | |
michael@0 | 404 | struct InputContextAction { |
michael@0 | 405 | /** |
michael@0 | 406 | * mCause indicates what action causes calling nsIWidget::SetInputContext(). |
michael@0 | 407 | * It must be one of following values. |
michael@0 | 408 | */ |
michael@0 | 409 | enum Cause { |
michael@0 | 410 | // The cause is unknown but originated from content. Focus might have been |
michael@0 | 411 | // changed by content script. |
michael@0 | 412 | CAUSE_UNKNOWN, |
michael@0 | 413 | // The cause is unknown but originated from chrome. Focus might have been |
michael@0 | 414 | // changed by chrome script. |
michael@0 | 415 | CAUSE_UNKNOWN_CHROME, |
michael@0 | 416 | // The cause is user's keyboard operation. |
michael@0 | 417 | CAUSE_KEY, |
michael@0 | 418 | // The cause is user's mouse operation. |
michael@0 | 419 | CAUSE_MOUSE |
michael@0 | 420 | }; |
michael@0 | 421 | Cause mCause; |
michael@0 | 422 | |
michael@0 | 423 | /** |
michael@0 | 424 | * mFocusChange indicates what happened for focus. |
michael@0 | 425 | */ |
michael@0 | 426 | enum FocusChange { |
michael@0 | 427 | FOCUS_NOT_CHANGED, |
michael@0 | 428 | // A content got focus. |
michael@0 | 429 | GOT_FOCUS, |
michael@0 | 430 | // Focused content lost focus. |
michael@0 | 431 | LOST_FOCUS, |
michael@0 | 432 | // Menu got pseudo focus that means focused content isn't changed but |
michael@0 | 433 | // keyboard events will be handled by menu. |
michael@0 | 434 | MENU_GOT_PSEUDO_FOCUS, |
michael@0 | 435 | // Menu lost pseudo focus that means focused content will handle keyboard |
michael@0 | 436 | // events. |
michael@0 | 437 | MENU_LOST_PSEUDO_FOCUS |
michael@0 | 438 | }; |
michael@0 | 439 | FocusChange mFocusChange; |
michael@0 | 440 | |
michael@0 | 441 | bool ContentGotFocusByTrustedCause() const { |
michael@0 | 442 | return (mFocusChange == GOT_FOCUS && |
michael@0 | 443 | mCause != CAUSE_UNKNOWN); |
michael@0 | 444 | } |
michael@0 | 445 | |
michael@0 | 446 | bool UserMightRequestOpenVKB() const { |
michael@0 | 447 | return (mFocusChange == FOCUS_NOT_CHANGED && |
michael@0 | 448 | mCause == CAUSE_MOUSE); |
michael@0 | 449 | } |
michael@0 | 450 | |
michael@0 | 451 | InputContextAction() : |
michael@0 | 452 | mCause(CAUSE_UNKNOWN), mFocusChange(FOCUS_NOT_CHANGED) |
michael@0 | 453 | { |
michael@0 | 454 | } |
michael@0 | 455 | |
michael@0 | 456 | InputContextAction(Cause aCause, |
michael@0 | 457 | FocusChange aFocusChange = FOCUS_NOT_CHANGED) : |
michael@0 | 458 | mCause(aCause), mFocusChange(aFocusChange) |
michael@0 | 459 | { |
michael@0 | 460 | } |
michael@0 | 461 | }; |
michael@0 | 462 | |
michael@0 | 463 | /** |
michael@0 | 464 | * Size constraints for setting the minimum and maximum size of a widget. |
michael@0 | 465 | * Values are in device pixels. |
michael@0 | 466 | */ |
michael@0 | 467 | struct SizeConstraints { |
michael@0 | 468 | SizeConstraints() |
michael@0 | 469 | : mMaxSize(NS_MAXSIZE, NS_MAXSIZE) |
michael@0 | 470 | { |
michael@0 | 471 | } |
michael@0 | 472 | |
michael@0 | 473 | SizeConstraints(nsIntSize aMinSize, |
michael@0 | 474 | nsIntSize aMaxSize) |
michael@0 | 475 | : mMinSize(aMinSize), |
michael@0 | 476 | mMaxSize(aMaxSize) |
michael@0 | 477 | { |
michael@0 | 478 | } |
michael@0 | 479 | |
michael@0 | 480 | nsIntSize mMinSize; |
michael@0 | 481 | nsIntSize mMaxSize; |
michael@0 | 482 | }; |
michael@0 | 483 | |
michael@0 | 484 | // IMEMessage is shared by IMEStateManager and TextComposition. |
michael@0 | 485 | // Update values in GeckoEditable.java if you make changes here. |
michael@0 | 486 | // XXX Negative values are used in Android... |
michael@0 | 487 | enum IMEMessage MOZ_ENUM_TYPE(int8_t) |
michael@0 | 488 | { |
michael@0 | 489 | // XXX We should replace NOTIFY_IME_OF_CURSOR_POS_CHANGED with |
michael@0 | 490 | // NOTIFY_IME_OF_SELECTION_CHANGE later. |
michael@0 | 491 | NOTIFY_IME_OF_CURSOR_POS_CHANGED, |
michael@0 | 492 | // An editable content is getting focus |
michael@0 | 493 | NOTIFY_IME_OF_FOCUS, |
michael@0 | 494 | // An editable content is losing focus |
michael@0 | 495 | NOTIFY_IME_OF_BLUR, |
michael@0 | 496 | // Selection in the focused editable content is changed |
michael@0 | 497 | NOTIFY_IME_OF_SELECTION_CHANGE, |
michael@0 | 498 | // Text in the focused editable content is changed |
michael@0 | 499 | NOTIFY_IME_OF_TEXT_CHANGE, |
michael@0 | 500 | // Composition string has been updated |
michael@0 | 501 | NOTIFY_IME_OF_COMPOSITION_UPDATE, |
michael@0 | 502 | // Position or size of focused element may be changed. |
michael@0 | 503 | NOTIFY_IME_OF_POSITION_CHANGE, |
michael@0 | 504 | // Request to commit current composition to IME |
michael@0 | 505 | // (some platforms may not support) |
michael@0 | 506 | REQUEST_TO_COMMIT_COMPOSITION, |
michael@0 | 507 | // Request to cancel current composition to IME |
michael@0 | 508 | // (some platforms may not support) |
michael@0 | 509 | REQUEST_TO_CANCEL_COMPOSITION |
michael@0 | 510 | }; |
michael@0 | 511 | |
michael@0 | 512 | struct IMENotification |
michael@0 | 513 | { |
michael@0 | 514 | IMENotification(IMEMessage aMessage) |
michael@0 | 515 | : mMessage(aMessage) |
michael@0 | 516 | { |
michael@0 | 517 | switch (aMessage) { |
michael@0 | 518 | case NOTIFY_IME_OF_SELECTION_CHANGE: |
michael@0 | 519 | mSelectionChangeData.mCausedByComposition = false; |
michael@0 | 520 | break; |
michael@0 | 521 | case NOTIFY_IME_OF_TEXT_CHANGE: |
michael@0 | 522 | mTextChangeData.mStartOffset = 0; |
michael@0 | 523 | mTextChangeData.mOldEndOffset = 0; |
michael@0 | 524 | mTextChangeData.mNewEndOffset = 0; |
michael@0 | 525 | mTextChangeData.mCausedByComposition = false; |
michael@0 | 526 | break; |
michael@0 | 527 | default: |
michael@0 | 528 | break; |
michael@0 | 529 | } |
michael@0 | 530 | } |
michael@0 | 531 | |
michael@0 | 532 | IMEMessage mMessage; |
michael@0 | 533 | |
michael@0 | 534 | union |
michael@0 | 535 | { |
michael@0 | 536 | // NOTIFY_IME_OF_SELECTION_CHANGE specific data |
michael@0 | 537 | struct |
michael@0 | 538 | { |
michael@0 | 539 | bool mCausedByComposition; |
michael@0 | 540 | } mSelectionChangeData; |
michael@0 | 541 | |
michael@0 | 542 | // NOTIFY_IME_OF_TEXT_CHANGE specific data |
michael@0 | 543 | struct |
michael@0 | 544 | { |
michael@0 | 545 | uint32_t mStartOffset; |
michael@0 | 546 | uint32_t mOldEndOffset; |
michael@0 | 547 | uint32_t mNewEndOffset; |
michael@0 | 548 | |
michael@0 | 549 | bool mCausedByComposition; |
michael@0 | 550 | |
michael@0 | 551 | uint32_t OldLength() const { return mOldEndOffset - mStartOffset; } |
michael@0 | 552 | uint32_t NewLength() const { return mNewEndOffset - mStartOffset; } |
michael@0 | 553 | int32_t AdditionalLength() const |
michael@0 | 554 | { |
michael@0 | 555 | return static_cast<int32_t>(mNewEndOffset - mOldEndOffset); |
michael@0 | 556 | } |
michael@0 | 557 | bool IsInInt32Range() const |
michael@0 | 558 | { |
michael@0 | 559 | return mStartOffset <= INT32_MAX && |
michael@0 | 560 | mOldEndOffset <= INT32_MAX && |
michael@0 | 561 | mNewEndOffset <= INT32_MAX; |
michael@0 | 562 | } |
michael@0 | 563 | } mTextChangeData; |
michael@0 | 564 | }; |
michael@0 | 565 | |
michael@0 | 566 | bool IsCausedByComposition() const |
michael@0 | 567 | { |
michael@0 | 568 | switch (mMessage) { |
michael@0 | 569 | case NOTIFY_IME_OF_SELECTION_CHANGE: |
michael@0 | 570 | return mSelectionChangeData.mCausedByComposition; |
michael@0 | 571 | case NOTIFY_IME_OF_TEXT_CHANGE: |
michael@0 | 572 | return mTextChangeData.mCausedByComposition; |
michael@0 | 573 | default: |
michael@0 | 574 | return false; |
michael@0 | 575 | } |
michael@0 | 576 | } |
michael@0 | 577 | |
michael@0 | 578 | private: |
michael@0 | 579 | IMENotification(); |
michael@0 | 580 | }; |
michael@0 | 581 | |
michael@0 | 582 | } // namespace widget |
michael@0 | 583 | } // namespace mozilla |
michael@0 | 584 | |
michael@0 | 585 | /** |
michael@0 | 586 | * The base class for all the widgets. It provides the interface for |
michael@0 | 587 | * all basic and necessary functionality. |
michael@0 | 588 | */ |
michael@0 | 589 | class nsIWidget : public nsISupports { |
michael@0 | 590 | protected: |
michael@0 | 591 | typedef mozilla::dom::TabChild TabChild; |
michael@0 | 592 | |
michael@0 | 593 | public: |
michael@0 | 594 | typedef mozilla::layers::Composer2D Composer2D; |
michael@0 | 595 | typedef mozilla::layers::CompositorChild CompositorChild; |
michael@0 | 596 | typedef mozilla::layers::LayerManager LayerManager; |
michael@0 | 597 | typedef mozilla::layers::LayerManagerComposite LayerManagerComposite; |
michael@0 | 598 | typedef mozilla::layers::LayersBackend LayersBackend; |
michael@0 | 599 | typedef mozilla::layers::PLayerTransactionChild PLayerTransactionChild; |
michael@0 | 600 | typedef mozilla::widget::IMEMessage IMEMessage; |
michael@0 | 601 | typedef mozilla::widget::IMENotification IMENotification; |
michael@0 | 602 | typedef mozilla::widget::IMEState IMEState; |
michael@0 | 603 | typedef mozilla::widget::InputContext InputContext; |
michael@0 | 604 | typedef mozilla::widget::InputContextAction InputContextAction; |
michael@0 | 605 | typedef mozilla::widget::SizeConstraints SizeConstraints; |
michael@0 | 606 | |
michael@0 | 607 | // Used in UpdateThemeGeometries. |
michael@0 | 608 | struct ThemeGeometry { |
michael@0 | 609 | // The -moz-appearance value for the themed widget |
michael@0 | 610 | uint8_t mWidgetType; |
michael@0 | 611 | // The device-pixel rect within the window for the themed widget |
michael@0 | 612 | nsIntRect mRect; |
michael@0 | 613 | |
michael@0 | 614 | ThemeGeometry(uint8_t aWidgetType, const nsIntRect& aRect) |
michael@0 | 615 | : mWidgetType(aWidgetType) |
michael@0 | 616 | , mRect(aRect) |
michael@0 | 617 | { } |
michael@0 | 618 | }; |
michael@0 | 619 | |
michael@0 | 620 | NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWIDGET_IID) |
michael@0 | 621 | |
michael@0 | 622 | nsIWidget() |
michael@0 | 623 | : mLastChild(nullptr) |
michael@0 | 624 | , mPrevSibling(nullptr) |
michael@0 | 625 | , mOnDestroyCalled(false) |
michael@0 | 626 | , mWindowType(eWindowType_child) |
michael@0 | 627 | , mZIndex(0) |
michael@0 | 628 | |
michael@0 | 629 | { |
michael@0 | 630 | ClearNativeTouchSequence(); |
michael@0 | 631 | } |
michael@0 | 632 | |
michael@0 | 633 | |
michael@0 | 634 | /** |
michael@0 | 635 | * Create and initialize a widget. |
michael@0 | 636 | * |
michael@0 | 637 | * All the arguments can be null in which case a top level window |
michael@0 | 638 | * with size 0 is created. The event callback function has to be |
michael@0 | 639 | * provided only if the caller wants to deal with the events this |
michael@0 | 640 | * widget receives. The event callback is basically a preprocess |
michael@0 | 641 | * hook called synchronously. The return value determines whether |
michael@0 | 642 | * the event goes to the default window procedure or it is hidden |
michael@0 | 643 | * to the os. The assumption is that if the event handler returns |
michael@0 | 644 | * false the widget does not see the event. The widget should not |
michael@0 | 645 | * automatically clear the window to the background color. The |
michael@0 | 646 | * calling code must handle paint messages and clear the background |
michael@0 | 647 | * itself. |
michael@0 | 648 | * |
michael@0 | 649 | * In practice at least one of aParent and aNativeParent will be null. If |
michael@0 | 650 | * both are null the widget isn't parented (e.g. context menus or |
michael@0 | 651 | * independent top level windows). |
michael@0 | 652 | * |
michael@0 | 653 | * The dimensions given in aRect are specified in the parent's |
michael@0 | 654 | * coordinate system, or for parentless widgets such as top-level |
michael@0 | 655 | * windows, in global CSS pixels. |
michael@0 | 656 | * |
michael@0 | 657 | * @param aParent parent nsIWidget |
michael@0 | 658 | * @param aNativeParent native parent widget |
michael@0 | 659 | * @param aRect the widget dimension |
michael@0 | 660 | * @param aContext |
michael@0 | 661 | * @param aInitData data that is used for widget initialization |
michael@0 | 662 | * |
michael@0 | 663 | */ |
michael@0 | 664 | NS_IMETHOD Create(nsIWidget *aParent, |
michael@0 | 665 | nsNativeWidget aNativeParent, |
michael@0 | 666 | const nsIntRect &aRect, |
michael@0 | 667 | nsDeviceContext *aContext, |
michael@0 | 668 | nsWidgetInitData *aInitData = nullptr) = 0; |
michael@0 | 669 | |
michael@0 | 670 | /** |
michael@0 | 671 | * Allocate, initialize, and return a widget that is a child of |
michael@0 | 672 | * |this|. The returned widget (if nonnull) has gone through the |
michael@0 | 673 | * equivalent of CreateInstance(widgetCID) + Create(...). |
michael@0 | 674 | * |
michael@0 | 675 | * |CreateChild()| lets widget backends decide whether to parent |
michael@0 | 676 | * the new child widget to this, nonnatively parent it, or both. |
michael@0 | 677 | * This interface exists to support the PuppetWidget backend, |
michael@0 | 678 | * which is entirely non-native. All other params are the same as |
michael@0 | 679 | * for |Create()|. |
michael@0 | 680 | * |
michael@0 | 681 | * |aForceUseIWidgetParent| forces |CreateChild()| to only use the |
michael@0 | 682 | * |nsIWidget*| this, not its native widget (if it exists), when |
michael@0 | 683 | * calling |Create()|. This is a timid hack around poorly |
michael@0 | 684 | * understood code, and shouldn't be used in new code. |
michael@0 | 685 | */ |
michael@0 | 686 | virtual already_AddRefed<nsIWidget> |
michael@0 | 687 | CreateChild(const nsIntRect &aRect, |
michael@0 | 688 | nsDeviceContext *aContext, |
michael@0 | 689 | nsWidgetInitData *aInitData = nullptr, |
michael@0 | 690 | bool aForceUseIWidgetParent = false) = 0; |
michael@0 | 691 | |
michael@0 | 692 | /** |
michael@0 | 693 | * Attach to a top level widget. |
michael@0 | 694 | * |
michael@0 | 695 | * In cases where a top level chrome widget is being used as a content |
michael@0 | 696 | * container, attach a secondary listener and update the device |
michael@0 | 697 | * context. The primary widget listener will continue to be called for |
michael@0 | 698 | * notifications relating to the top-level window, whereas other |
michael@0 | 699 | * notifications such as painting and events will instead be called via |
michael@0 | 700 | * the attached listener. SetAttachedWidgetListener should be used to |
michael@0 | 701 | * assign the attached listener. |
michael@0 | 702 | * |
michael@0 | 703 | * aUseAttachedEvents if true, events are sent to the attached listener |
michael@0 | 704 | * instead of the normal listener. |
michael@0 | 705 | * aContext The new device context for the view |
michael@0 | 706 | */ |
michael@0 | 707 | NS_IMETHOD AttachViewToTopLevel(bool aUseAttachedEvents, |
michael@0 | 708 | nsDeviceContext *aContext) = 0; |
michael@0 | 709 | |
michael@0 | 710 | /** |
michael@0 | 711 | * Accessor functions to get and set the attached listener. Used by |
michael@0 | 712 | * nsView in connection with AttachViewToTopLevel above. |
michael@0 | 713 | */ |
michael@0 | 714 | virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) = 0; |
michael@0 | 715 | virtual nsIWidgetListener* GetAttachedWidgetListener() = 0; |
michael@0 | 716 | |
michael@0 | 717 | /** |
michael@0 | 718 | * Accessor functions to get and set the listener which handles various |
michael@0 | 719 | * actions for the widget. |
michael@0 | 720 | */ |
michael@0 | 721 | //@{ |
michael@0 | 722 | virtual nsIWidgetListener* GetWidgetListener() = 0; |
michael@0 | 723 | virtual void SetWidgetListener(nsIWidgetListener* alistener) = 0; |
michael@0 | 724 | //@} |
michael@0 | 725 | |
michael@0 | 726 | /** |
michael@0 | 727 | * Close and destroy the internal native window. |
michael@0 | 728 | * This method does not delete the widget. |
michael@0 | 729 | */ |
michael@0 | 730 | |
michael@0 | 731 | NS_IMETHOD Destroy(void) = 0; |
michael@0 | 732 | |
michael@0 | 733 | /** |
michael@0 | 734 | * Destroyed() returns true if Destroy() has been called already. |
michael@0 | 735 | * Otherwise, false. |
michael@0 | 736 | */ |
michael@0 | 737 | bool Destroyed() const { return mOnDestroyCalled; } |
michael@0 | 738 | |
michael@0 | 739 | |
michael@0 | 740 | /** |
michael@0 | 741 | * Reparent a widget |
michael@0 | 742 | * |
michael@0 | 743 | * Change the widget's parent. Null parents are allowed. |
michael@0 | 744 | * |
michael@0 | 745 | * @param aNewParent new parent |
michael@0 | 746 | */ |
michael@0 | 747 | NS_IMETHOD SetParent(nsIWidget* aNewParent) = 0; |
michael@0 | 748 | |
michael@0 | 749 | NS_IMETHOD RegisterTouchWindow() = 0; |
michael@0 | 750 | NS_IMETHOD UnregisterTouchWindow() = 0; |
michael@0 | 751 | |
michael@0 | 752 | /** |
michael@0 | 753 | * Return the parent Widget of this Widget or nullptr if this is a |
michael@0 | 754 | * top level window |
michael@0 | 755 | * |
michael@0 | 756 | * @return the parent widget or nullptr if it does not have a parent |
michael@0 | 757 | * |
michael@0 | 758 | */ |
michael@0 | 759 | virtual nsIWidget* GetParent(void) = 0; |
michael@0 | 760 | |
michael@0 | 761 | /** |
michael@0 | 762 | * Return the top level Widget of this Widget |
michael@0 | 763 | * |
michael@0 | 764 | * @return the top level widget |
michael@0 | 765 | */ |
michael@0 | 766 | virtual nsIWidget* GetTopLevelWidget() = 0; |
michael@0 | 767 | |
michael@0 | 768 | /** |
michael@0 | 769 | * Return the top (non-sheet) parent of this Widget if it's a sheet, |
michael@0 | 770 | * or nullptr if this isn't a sheet (or some other error occurred). |
michael@0 | 771 | * Sheets are only supported on some platforms (currently only OS X). |
michael@0 | 772 | * |
michael@0 | 773 | * @return the top (non-sheet) parent widget or nullptr |
michael@0 | 774 | * |
michael@0 | 775 | */ |
michael@0 | 776 | virtual nsIWidget* GetSheetWindowParent(void) = 0; |
michael@0 | 777 | |
michael@0 | 778 | /** |
michael@0 | 779 | * Return the physical DPI of the screen containing the window ... |
michael@0 | 780 | * the number of device pixels per inch. |
michael@0 | 781 | */ |
michael@0 | 782 | virtual float GetDPI() = 0; |
michael@0 | 783 | |
michael@0 | 784 | /** |
michael@0 | 785 | * Return the default scale factor for the window. This is the |
michael@0 | 786 | * default number of device pixels per CSS pixel to use. This should |
michael@0 | 787 | * depend on OS/platform settings such as the Mac's "UI scale factor" |
michael@0 | 788 | * or Windows' "font DPI". This will take into account Gecko preferences |
michael@0 | 789 | * overriding the system setting. |
michael@0 | 790 | */ |
michael@0 | 791 | mozilla::CSSToLayoutDeviceScale GetDefaultScale(); |
michael@0 | 792 | |
michael@0 | 793 | /** |
michael@0 | 794 | * Return the Gecko override of the system default scale, if any; |
michael@0 | 795 | * returns <= 0.0 if the system scale should be used as-is. |
michael@0 | 796 | * nsIWidget::GetDefaultScale() [above] takes this into account. |
michael@0 | 797 | * It is exposed here so that code that wants to check for a |
michael@0 | 798 | * default-scale override without having a widget on hand can |
michael@0 | 799 | * easily access the same value. |
michael@0 | 800 | * Note that any scale override is a browser-wide value, whereas |
michael@0 | 801 | * the default GetDefaultScale value (when no override is present) |
michael@0 | 802 | * may vary between widgets (or screens). |
michael@0 | 803 | */ |
michael@0 | 804 | static double DefaultScaleOverride(); |
michael@0 | 805 | |
michael@0 | 806 | /** |
michael@0 | 807 | * Return the first child of this widget. Will return null if |
michael@0 | 808 | * there are no children. |
michael@0 | 809 | */ |
michael@0 | 810 | nsIWidget* GetFirstChild() const { |
michael@0 | 811 | return mFirstChild; |
michael@0 | 812 | } |
michael@0 | 813 | |
michael@0 | 814 | /** |
michael@0 | 815 | * Return the last child of this widget. Will return null if |
michael@0 | 816 | * there are no children. |
michael@0 | 817 | */ |
michael@0 | 818 | nsIWidget* GetLastChild() const { |
michael@0 | 819 | return mLastChild; |
michael@0 | 820 | } |
michael@0 | 821 | |
michael@0 | 822 | /** |
michael@0 | 823 | * Return the next sibling of this widget |
michael@0 | 824 | */ |
michael@0 | 825 | nsIWidget* GetNextSibling() const { |
michael@0 | 826 | return mNextSibling; |
michael@0 | 827 | } |
michael@0 | 828 | |
michael@0 | 829 | /** |
michael@0 | 830 | * Set the next sibling of this widget |
michael@0 | 831 | */ |
michael@0 | 832 | void SetNextSibling(nsIWidget* aSibling) { |
michael@0 | 833 | mNextSibling = aSibling; |
michael@0 | 834 | } |
michael@0 | 835 | |
michael@0 | 836 | /** |
michael@0 | 837 | * Return the previous sibling of this widget |
michael@0 | 838 | */ |
michael@0 | 839 | nsIWidget* GetPrevSibling() const { |
michael@0 | 840 | return mPrevSibling; |
michael@0 | 841 | } |
michael@0 | 842 | |
michael@0 | 843 | /** |
michael@0 | 844 | * Set the previous sibling of this widget |
michael@0 | 845 | */ |
michael@0 | 846 | void SetPrevSibling(nsIWidget* aSibling) { |
michael@0 | 847 | mPrevSibling = aSibling; |
michael@0 | 848 | } |
michael@0 | 849 | |
michael@0 | 850 | /** |
michael@0 | 851 | * Show or hide this widget |
michael@0 | 852 | * |
michael@0 | 853 | * @param aState true to show the Widget, false to hide it |
michael@0 | 854 | * |
michael@0 | 855 | */ |
michael@0 | 856 | NS_IMETHOD Show(bool aState) = 0; |
michael@0 | 857 | |
michael@0 | 858 | /** |
michael@0 | 859 | * Make the window modal |
michael@0 | 860 | * |
michael@0 | 861 | */ |
michael@0 | 862 | NS_IMETHOD SetModal(bool aModal) = 0; |
michael@0 | 863 | |
michael@0 | 864 | /** |
michael@0 | 865 | * The maximum number of simultaneous touch contacts supported by the device. |
michael@0 | 866 | * In the case of devices with multiple digitizers (e.g. multiple touch screens), |
michael@0 | 867 | * the value will be the maximum of the set of maximum supported contacts by |
michael@0 | 868 | * each individual digitizer. |
michael@0 | 869 | */ |
michael@0 | 870 | virtual uint32_t GetMaxTouchPoints() const = 0; |
michael@0 | 871 | |
michael@0 | 872 | /** |
michael@0 | 873 | * Returns whether the window is visible |
michael@0 | 874 | * |
michael@0 | 875 | */ |
michael@0 | 876 | virtual bool IsVisible() const = 0; |
michael@0 | 877 | |
michael@0 | 878 | /** |
michael@0 | 879 | * Perform platform-dependent sanity check on a potential window position. |
michael@0 | 880 | * This is guaranteed to work only for top-level windows. |
michael@0 | 881 | * |
michael@0 | 882 | * @param aAllowSlop: if true, allow the window to slop offscreen; |
michael@0 | 883 | * the window should be partially visible. if false, |
michael@0 | 884 | * force the entire window onscreen (or at least |
michael@0 | 885 | * the upper-left corner, if it's too large). |
michael@0 | 886 | * @param aX in: an x position expressed in screen coordinates. |
michael@0 | 887 | * out: the x position constrained to fit on the screen(s). |
michael@0 | 888 | * @param aY in: an y position expressed in screen coordinates. |
michael@0 | 889 | * out: the y position constrained to fit on the screen(s). |
michael@0 | 890 | * @return vapid success indication. but see also the parameters. |
michael@0 | 891 | * |
michael@0 | 892 | **/ |
michael@0 | 893 | NS_IMETHOD ConstrainPosition(bool aAllowSlop, |
michael@0 | 894 | int32_t *aX, |
michael@0 | 895 | int32_t *aY) = 0; |
michael@0 | 896 | |
michael@0 | 897 | /** |
michael@0 | 898 | * NOTE: |
michael@0 | 899 | * |
michael@0 | 900 | * For a top-level window widget, the "parent's coordinate system" is the |
michael@0 | 901 | * "global" display pixel coordinate space, *not* device pixels (which |
michael@0 | 902 | * may be inconsistent between multiple screens, at least in the Mac OS |
michael@0 | 903 | * case with mixed hi-dpi and lo-dpi displays). This applies to all the |
michael@0 | 904 | * following Move and Resize widget APIs. |
michael@0 | 905 | * |
michael@0 | 906 | * The display-/device-pixel distinction becomes important for (at least) |
michael@0 | 907 | * Mac OS X with Hi-DPI (retina) displays, and Windows when the UI scale |
michael@0 | 908 | * factor is set to other than 100%. |
michael@0 | 909 | * |
michael@0 | 910 | * The Move and Resize methods take floating-point parameters, rather than |
michael@0 | 911 | * integer ones. This is important when manipulating top-level widgets, |
michael@0 | 912 | * where the coordinate system may not be an integral multiple of the |
michael@0 | 913 | * device-pixel space. |
michael@0 | 914 | **/ |
michael@0 | 915 | |
michael@0 | 916 | /** |
michael@0 | 917 | * Move this widget. |
michael@0 | 918 | * |
michael@0 | 919 | * Coordinates refer to the top-left of the widget. For toplevel windows |
michael@0 | 920 | * with decorations, this is the top-left of the titlebar and frame . |
michael@0 | 921 | * |
michael@0 | 922 | * @param aX the new x position expressed in the parent's coordinate system |
michael@0 | 923 | * @param aY the new y position expressed in the parent's coordinate system |
michael@0 | 924 | * |
michael@0 | 925 | **/ |
michael@0 | 926 | NS_IMETHOD Move(double aX, double aY) = 0; |
michael@0 | 927 | |
michael@0 | 928 | /** |
michael@0 | 929 | * Reposition this widget so that the client area has the given offset. |
michael@0 | 930 | * |
michael@0 | 931 | * @param aX the new x offset of the client area expressed as an |
michael@0 | 932 | * offset from the origin of the client area of the parent |
michael@0 | 933 | * widget (for root widgets and popup widgets it is in |
michael@0 | 934 | * screen coordinates) |
michael@0 | 935 | * @param aY the new y offset of the client area expressed as an |
michael@0 | 936 | * offset from the origin of the client area of the parent |
michael@0 | 937 | * widget (for root widgets and popup widgets it is in |
michael@0 | 938 | * screen coordinates) |
michael@0 | 939 | * |
michael@0 | 940 | **/ |
michael@0 | 941 | NS_IMETHOD MoveClient(double aX, double aY) = 0; |
michael@0 | 942 | |
michael@0 | 943 | /** |
michael@0 | 944 | * Resize this widget. Any size constraints set for the window by a |
michael@0 | 945 | * previous call to SetSizeConstraints will be applied. |
michael@0 | 946 | * |
michael@0 | 947 | * @param aWidth the new width expressed in the parent's coordinate system |
michael@0 | 948 | * @param aHeight the new height expressed in the parent's coordinate system |
michael@0 | 949 | * @param aRepaint whether the widget should be repainted |
michael@0 | 950 | * |
michael@0 | 951 | */ |
michael@0 | 952 | NS_IMETHOD Resize(double aWidth, |
michael@0 | 953 | double aHeight, |
michael@0 | 954 | bool aRepaint) = 0; |
michael@0 | 955 | |
michael@0 | 956 | /** |
michael@0 | 957 | * Move or resize this widget. Any size constraints set for the window by |
michael@0 | 958 | * a previous call to SetSizeConstraints will be applied. |
michael@0 | 959 | * |
michael@0 | 960 | * @param aX the new x position expressed in the parent's coordinate system |
michael@0 | 961 | * @param aY the new y position expressed in the parent's coordinate system |
michael@0 | 962 | * @param aWidth the new width expressed in the parent's coordinate system |
michael@0 | 963 | * @param aHeight the new height expressed in the parent's coordinate system |
michael@0 | 964 | * @param aRepaint whether the widget should be repainted if the size changes |
michael@0 | 965 | * |
michael@0 | 966 | */ |
michael@0 | 967 | NS_IMETHOD Resize(double aX, |
michael@0 | 968 | double aY, |
michael@0 | 969 | double aWidth, |
michael@0 | 970 | double aHeight, |
michael@0 | 971 | bool aRepaint) = 0; |
michael@0 | 972 | |
michael@0 | 973 | /** |
michael@0 | 974 | * Resize the widget so that the inner client area has the given size. |
michael@0 | 975 | * |
michael@0 | 976 | * @param aWidth the new width of the client area. |
michael@0 | 977 | * @param aHeight the new height of the client area. |
michael@0 | 978 | * @param aRepaint whether the widget should be repainted |
michael@0 | 979 | * |
michael@0 | 980 | */ |
michael@0 | 981 | NS_IMETHOD ResizeClient(double aWidth, |
michael@0 | 982 | double aHeight, |
michael@0 | 983 | bool aRepaint) = 0; |
michael@0 | 984 | |
michael@0 | 985 | /** |
michael@0 | 986 | * Resize and reposition the widget so tht inner client area has the given |
michael@0 | 987 | * offset and size. |
michael@0 | 988 | * |
michael@0 | 989 | * @param aX the new x offset of the client area expressed as an |
michael@0 | 990 | * offset from the origin of the client area of the parent |
michael@0 | 991 | * widget (for root widgets and popup widgets it is in |
michael@0 | 992 | * screen coordinates) |
michael@0 | 993 | * @param aY the new y offset of the client area expressed as an |
michael@0 | 994 | * offset from the origin of the client area of the parent |
michael@0 | 995 | * widget (for root widgets and popup widgets it is in |
michael@0 | 996 | * screen coordinates) |
michael@0 | 997 | * @param aWidth the new width of the client area. |
michael@0 | 998 | * @param aHeight the new height of the client area. |
michael@0 | 999 | * @param aRepaint whether the widget should be repainted |
michael@0 | 1000 | * |
michael@0 | 1001 | */ |
michael@0 | 1002 | NS_IMETHOD ResizeClient(double aX, |
michael@0 | 1003 | double aY, |
michael@0 | 1004 | double aWidth, |
michael@0 | 1005 | double aHeight, |
michael@0 | 1006 | bool aRepaint) = 0; |
michael@0 | 1007 | |
michael@0 | 1008 | /** |
michael@0 | 1009 | * Sets the widget's z-index. |
michael@0 | 1010 | */ |
michael@0 | 1011 | virtual void SetZIndex(int32_t aZIndex) = 0; |
michael@0 | 1012 | |
michael@0 | 1013 | /** |
michael@0 | 1014 | * Gets the widget's z-index. |
michael@0 | 1015 | */ |
michael@0 | 1016 | int32_t GetZIndex() |
michael@0 | 1017 | { |
michael@0 | 1018 | return mZIndex; |
michael@0 | 1019 | } |
michael@0 | 1020 | |
michael@0 | 1021 | /** |
michael@0 | 1022 | * Position this widget just behind the given widget. (Used to |
michael@0 | 1023 | * control z-order for top-level widgets. Get/SetZIndex by contrast |
michael@0 | 1024 | * control z-order for child widgets of other widgets.) |
michael@0 | 1025 | * @param aPlacement top, bottom, or below a widget |
michael@0 | 1026 | * (if top or bottom, param aWidget is ignored) |
michael@0 | 1027 | * @param aWidget widget to place this widget behind |
michael@0 | 1028 | * (only if aPlacement is eZPlacementBelow). |
michael@0 | 1029 | * null is equivalent to aPlacement of eZPlacementTop |
michael@0 | 1030 | * @param aActivate true to activate the widget after placing it |
michael@0 | 1031 | */ |
michael@0 | 1032 | NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, |
michael@0 | 1033 | nsIWidget *aWidget, bool aActivate) = 0; |
michael@0 | 1034 | |
michael@0 | 1035 | /** |
michael@0 | 1036 | * Minimize, maximize or normalize the window size. |
michael@0 | 1037 | * Takes a value from nsSizeMode (see nsIWidgetListener.h) |
michael@0 | 1038 | */ |
michael@0 | 1039 | NS_IMETHOD SetSizeMode(int32_t aMode) = 0; |
michael@0 | 1040 | |
michael@0 | 1041 | /** |
michael@0 | 1042 | * Return size mode (minimized, maximized, normalized). |
michael@0 | 1043 | * Returns a value from nsSizeMode (see nsIWidgetListener.h) |
michael@0 | 1044 | */ |
michael@0 | 1045 | virtual int32_t SizeMode() = 0; |
michael@0 | 1046 | |
michael@0 | 1047 | /** |
michael@0 | 1048 | * Enable or disable this Widget |
michael@0 | 1049 | * |
michael@0 | 1050 | * @param aState true to enable the Widget, false to disable it. |
michael@0 | 1051 | * |
michael@0 | 1052 | */ |
michael@0 | 1053 | NS_IMETHOD Enable(bool aState) = 0; |
michael@0 | 1054 | |
michael@0 | 1055 | /** |
michael@0 | 1056 | * Ask whether the widget is enabled |
michael@0 | 1057 | */ |
michael@0 | 1058 | virtual bool IsEnabled() const = 0; |
michael@0 | 1059 | |
michael@0 | 1060 | /** |
michael@0 | 1061 | * Request activation of this window or give focus to this widget. |
michael@0 | 1062 | * |
michael@0 | 1063 | * @param aRaise If true, this function requests activation of this |
michael@0 | 1064 | * widget's toplevel window. |
michael@0 | 1065 | * If false, the appropriate toplevel window (which in |
michael@0 | 1066 | * the case of popups may not be this widget's toplevel |
michael@0 | 1067 | * window) is already active. |
michael@0 | 1068 | */ |
michael@0 | 1069 | NS_IMETHOD SetFocus(bool aRaise = false) = 0; |
michael@0 | 1070 | |
michael@0 | 1071 | /** |
michael@0 | 1072 | * Get this widget's outside dimensions relative to its parent widget. For |
michael@0 | 1073 | * popup widgets the returned rect is in screen coordinates and not |
michael@0 | 1074 | * relative to its parent widget. |
michael@0 | 1075 | * |
michael@0 | 1076 | * @param aRect On return it holds the x, y, width and height of |
michael@0 | 1077 | * this widget. |
michael@0 | 1078 | */ |
michael@0 | 1079 | NS_IMETHOD GetBounds(nsIntRect &aRect) = 0; |
michael@0 | 1080 | |
michael@0 | 1081 | /** |
michael@0 | 1082 | * Get this widget's outside dimensions in global coordinates. This |
michael@0 | 1083 | * includes any title bar on the window. |
michael@0 | 1084 | * |
michael@0 | 1085 | * @param aRect On return it holds the x, y, width and height of |
michael@0 | 1086 | * this widget. |
michael@0 | 1087 | */ |
michael@0 | 1088 | NS_IMETHOD GetScreenBounds(nsIntRect &aRect) = 0; |
michael@0 | 1089 | |
michael@0 | 1090 | /** |
michael@0 | 1091 | * Get this widget's client area bounds, if the window has a 3D border |
michael@0 | 1092 | * appearance this returns the area inside the border. The position is the |
michael@0 | 1093 | * position of the client area relative to the client area of the parent |
michael@0 | 1094 | * widget (for root widgets and popup widgets it is in screen coordinates). |
michael@0 | 1095 | * |
michael@0 | 1096 | * @param aRect On return it holds the x. y, width and height of |
michael@0 | 1097 | * the client area of this widget. |
michael@0 | 1098 | */ |
michael@0 | 1099 | NS_IMETHOD GetClientBounds(nsIntRect &aRect) = 0; |
michael@0 | 1100 | |
michael@0 | 1101 | /** |
michael@0 | 1102 | * Get the non-client area dimensions of the window. |
michael@0 | 1103 | * |
michael@0 | 1104 | */ |
michael@0 | 1105 | NS_IMETHOD GetNonClientMargins(nsIntMargin &margins) = 0; |
michael@0 | 1106 | |
michael@0 | 1107 | /** |
michael@0 | 1108 | * Sets the non-client area dimensions of the window. Pass -1 to restore |
michael@0 | 1109 | * the system default frame size for that border. Pass zero to remove |
michael@0 | 1110 | * a border, or pass a specific value adjust a border. Units are in |
michael@0 | 1111 | * pixels. (DPI dependent) |
michael@0 | 1112 | * |
michael@0 | 1113 | * Platform notes: |
michael@0 | 1114 | * Windows: shrinking top non-client height will remove application |
michael@0 | 1115 | * icon and window title text. Glass desktops will refuse to set |
michael@0 | 1116 | * dimensions between zero and size < system default. |
michael@0 | 1117 | * |
michael@0 | 1118 | */ |
michael@0 | 1119 | NS_IMETHOD SetNonClientMargins(nsIntMargin &margins) = 0; |
michael@0 | 1120 | |
michael@0 | 1121 | /** |
michael@0 | 1122 | * Get the client offset from the window origin. |
michael@0 | 1123 | * |
michael@0 | 1124 | * @return the x and y of the offset. |
michael@0 | 1125 | * |
michael@0 | 1126 | */ |
michael@0 | 1127 | virtual nsIntPoint GetClientOffset() = 0; |
michael@0 | 1128 | |
michael@0 | 1129 | /** |
michael@0 | 1130 | * Set the background color for this widget |
michael@0 | 1131 | * |
michael@0 | 1132 | * @param aColor the new background color |
michael@0 | 1133 | * |
michael@0 | 1134 | */ |
michael@0 | 1135 | |
michael@0 | 1136 | virtual void SetBackgroundColor(const nscolor &aColor) { } |
michael@0 | 1137 | |
michael@0 | 1138 | /** |
michael@0 | 1139 | * Get the cursor for this widget. |
michael@0 | 1140 | * |
michael@0 | 1141 | * @return this widget's cursor. |
michael@0 | 1142 | */ |
michael@0 | 1143 | |
michael@0 | 1144 | virtual nsCursor GetCursor(void) = 0; |
michael@0 | 1145 | |
michael@0 | 1146 | /** |
michael@0 | 1147 | * Set the cursor for this widget |
michael@0 | 1148 | * |
michael@0 | 1149 | * @param aCursor the new cursor for this widget |
michael@0 | 1150 | */ |
michael@0 | 1151 | |
michael@0 | 1152 | NS_IMETHOD SetCursor(nsCursor aCursor) = 0; |
michael@0 | 1153 | |
michael@0 | 1154 | /** |
michael@0 | 1155 | * Sets an image as the cursor for this widget. |
michael@0 | 1156 | * |
michael@0 | 1157 | * @param aCursor the cursor to set |
michael@0 | 1158 | * @param aX the X coordinate of the hotspot (from left). |
michael@0 | 1159 | * @param aY the Y coordinate of the hotspot (from top). |
michael@0 | 1160 | * @retval NS_ERROR_NOT_IMPLEMENTED if setting images as cursors is not |
michael@0 | 1161 | * supported |
michael@0 | 1162 | */ |
michael@0 | 1163 | NS_IMETHOD SetCursor(imgIContainer* aCursor, |
michael@0 | 1164 | uint32_t aHotspotX, uint32_t aHotspotY) = 0; |
michael@0 | 1165 | |
michael@0 | 1166 | /** |
michael@0 | 1167 | * Get the window type of this widget. |
michael@0 | 1168 | */ |
michael@0 | 1169 | nsWindowType WindowType() { return mWindowType; } |
michael@0 | 1170 | |
michael@0 | 1171 | /** |
michael@0 | 1172 | * Set the transparency mode of the top-level window containing this widget. |
michael@0 | 1173 | * So, e.g., if you call this on the widget for an IFRAME, the top level |
michael@0 | 1174 | * browser window containing the IFRAME actually gets set. Be careful. |
michael@0 | 1175 | * |
michael@0 | 1176 | * This can fail if the platform doesn't support |
michael@0 | 1177 | * transparency/glass. By default widgets are not |
michael@0 | 1178 | * transparent. This will also fail if the toplevel window is not |
michael@0 | 1179 | * a Mozilla window, e.g., if the widget is in an embedded |
michael@0 | 1180 | * context. |
michael@0 | 1181 | * |
michael@0 | 1182 | * After transparency/glass has been enabled, the initial alpha channel |
michael@0 | 1183 | * value for all pixels is 1, i.e., opaque. |
michael@0 | 1184 | * If the window is resized then the alpha channel values for |
michael@0 | 1185 | * all pixels are reset to 1. |
michael@0 | 1186 | * Pixel RGB color values are already premultiplied with alpha channel values. |
michael@0 | 1187 | */ |
michael@0 | 1188 | virtual void SetTransparencyMode(nsTransparencyMode aMode) = 0; |
michael@0 | 1189 | |
michael@0 | 1190 | /** |
michael@0 | 1191 | * Get the transparency mode of the top-level window that contains this |
michael@0 | 1192 | * widget. |
michael@0 | 1193 | */ |
michael@0 | 1194 | virtual nsTransparencyMode GetTransparencyMode() = 0; |
michael@0 | 1195 | |
michael@0 | 1196 | /** |
michael@0 | 1197 | * This represents a command to set the bounds and clip region of |
michael@0 | 1198 | * a child widget. |
michael@0 | 1199 | */ |
michael@0 | 1200 | struct Configuration { |
michael@0 | 1201 | nsIWidget* mChild; |
michael@0 | 1202 | nsIntRect mBounds; |
michael@0 | 1203 | nsTArray<nsIntRect> mClipRegion; |
michael@0 | 1204 | }; |
michael@0 | 1205 | |
michael@0 | 1206 | /** |
michael@0 | 1207 | * Sets the clip region of each mChild (which must actually be a child |
michael@0 | 1208 | * of this widget) to the union of the pixel rects given in |
michael@0 | 1209 | * mClipRegion, all relative to the top-left of the child |
michael@0 | 1210 | * widget. Clip regions are not implemented on all platforms and only |
michael@0 | 1211 | * need to actually work for children that are plugins. |
michael@0 | 1212 | * |
michael@0 | 1213 | * Also sets the bounds of each child to mBounds. |
michael@0 | 1214 | * |
michael@0 | 1215 | * This will invalidate areas of the children that have changed, but |
michael@0 | 1216 | * does not need to invalidate any part of this widget. |
michael@0 | 1217 | * |
michael@0 | 1218 | * Children should be moved in the order given; the array is |
michael@0 | 1219 | * sorted so to minimize unnecessary invalidation if children are |
michael@0 | 1220 | * moved in that order. |
michael@0 | 1221 | */ |
michael@0 | 1222 | virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) = 0; |
michael@0 | 1223 | |
michael@0 | 1224 | /** |
michael@0 | 1225 | * Appends to aRects the rectangles constituting this widget's clip |
michael@0 | 1226 | * region. If this widget is not clipped, appends a single rectangle |
michael@0 | 1227 | * (0, 0, bounds.width, bounds.height). |
michael@0 | 1228 | */ |
michael@0 | 1229 | virtual void GetWindowClipRegion(nsTArray<nsIntRect>* aRects) = 0; |
michael@0 | 1230 | |
michael@0 | 1231 | /** |
michael@0 | 1232 | * Set the shadow style of the window. |
michael@0 | 1233 | * |
michael@0 | 1234 | * Ignored on child widgets and on non-Mac platforms. |
michael@0 | 1235 | */ |
michael@0 | 1236 | NS_IMETHOD SetWindowShadowStyle(int32_t aStyle) = 0; |
michael@0 | 1237 | |
michael@0 | 1238 | /* |
michael@0 | 1239 | * On Mac OS X, this method shows or hides the pill button in the titlebar |
michael@0 | 1240 | * that's used to collapse the toolbar. |
michael@0 | 1241 | * |
michael@0 | 1242 | * Ignored on child widgets and on non-Mac platforms. |
michael@0 | 1243 | */ |
michael@0 | 1244 | virtual void SetShowsToolbarButton(bool aShow) = 0; |
michael@0 | 1245 | |
michael@0 | 1246 | /* |
michael@0 | 1247 | * On Mac OS X Lion, this method shows or hides the full screen button in |
michael@0 | 1248 | * the titlebar that handles native full screen mode. |
michael@0 | 1249 | * |
michael@0 | 1250 | * Ignored on child widgets, non-Mac platforms, & pre-Lion Mac. |
michael@0 | 1251 | */ |
michael@0 | 1252 | virtual void SetShowsFullScreenButton(bool aShow) = 0; |
michael@0 | 1253 | |
michael@0 | 1254 | enum WindowAnimationType { |
michael@0 | 1255 | eGenericWindowAnimation, |
michael@0 | 1256 | eDocumentWindowAnimation |
michael@0 | 1257 | }; |
michael@0 | 1258 | |
michael@0 | 1259 | /** |
michael@0 | 1260 | * Sets the kind of top-level window animation this widget should have. On |
michael@0 | 1261 | * Mac OS X, this causes a particular kind of animation to be shown when the |
michael@0 | 1262 | * window is first made visible. |
michael@0 | 1263 | * |
michael@0 | 1264 | * Ignored on child widgets and on non-Mac platforms. |
michael@0 | 1265 | */ |
michael@0 | 1266 | virtual void SetWindowAnimationType(WindowAnimationType aType) = 0; |
michael@0 | 1267 | |
michael@0 | 1268 | /** |
michael@0 | 1269 | * Specifies whether the window title should be drawn even if the window |
michael@0 | 1270 | * contents extend into the titlebar. Ignored on windows that don't draw |
michael@0 | 1271 | * in the titlebar. Only implemented on OS X. |
michael@0 | 1272 | */ |
michael@0 | 1273 | virtual void SetDrawsTitle(bool aDrawTitle) {} |
michael@0 | 1274 | |
michael@0 | 1275 | /** |
michael@0 | 1276 | * Hide window chrome (borders, buttons) for this widget. |
michael@0 | 1277 | * |
michael@0 | 1278 | */ |
michael@0 | 1279 | NS_IMETHOD HideWindowChrome(bool aShouldHide) = 0; |
michael@0 | 1280 | |
michael@0 | 1281 | /** |
michael@0 | 1282 | * Put the toplevel window into or out of fullscreen mode. |
michael@0 | 1283 | * |
michael@0 | 1284 | */ |
michael@0 | 1285 | NS_IMETHOD MakeFullScreen(bool aFullScreen) = 0; |
michael@0 | 1286 | |
michael@0 | 1287 | /** |
michael@0 | 1288 | * Invalidate a specified rect for a widget so that it will be repainted |
michael@0 | 1289 | * later. |
michael@0 | 1290 | */ |
michael@0 | 1291 | NS_IMETHOD Invalidate(const nsIntRect & aRect) = 0; |
michael@0 | 1292 | |
michael@0 | 1293 | enum LayerManagerPersistence |
michael@0 | 1294 | { |
michael@0 | 1295 | LAYER_MANAGER_CURRENT = 0, |
michael@0 | 1296 | LAYER_MANAGER_PERSISTENT |
michael@0 | 1297 | }; |
michael@0 | 1298 | |
michael@0 | 1299 | /** |
michael@0 | 1300 | * Return the widget's LayerManager. The layer tree for that |
michael@0 | 1301 | * LayerManager is what gets rendered to the widget. |
michael@0 | 1302 | * |
michael@0 | 1303 | * @param aAllowRetaining an outparam that states whether the returned |
michael@0 | 1304 | * layer manager should be used for retained layers |
michael@0 | 1305 | */ |
michael@0 | 1306 | inline LayerManager* GetLayerManager(bool* aAllowRetaining = nullptr) |
michael@0 | 1307 | { |
michael@0 | 1308 | return GetLayerManager(nullptr, mozilla::layers::LayersBackend::LAYERS_NONE, |
michael@0 | 1309 | LAYER_MANAGER_CURRENT, aAllowRetaining); |
michael@0 | 1310 | } |
michael@0 | 1311 | |
michael@0 | 1312 | inline LayerManager* GetLayerManager(LayerManagerPersistence aPersistence, |
michael@0 | 1313 | bool* aAllowRetaining = nullptr) |
michael@0 | 1314 | { |
michael@0 | 1315 | return GetLayerManager(nullptr, mozilla::layers::LayersBackend::LAYERS_NONE, |
michael@0 | 1316 | aPersistence, aAllowRetaining); |
michael@0 | 1317 | } |
michael@0 | 1318 | |
michael@0 | 1319 | /** |
michael@0 | 1320 | * Like GetLayerManager(), but prefers creating a layer manager of |
michael@0 | 1321 | * type |aBackendHint| instead of what would normally be created. |
michael@0 | 1322 | * LayersBackend::LAYERS_NONE means "no hint". |
michael@0 | 1323 | */ |
michael@0 | 1324 | virtual LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager, |
michael@0 | 1325 | LayersBackend aBackendHint, |
michael@0 | 1326 | LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT, |
michael@0 | 1327 | bool* aAllowRetaining = nullptr) = 0; |
michael@0 | 1328 | |
michael@0 | 1329 | /** |
michael@0 | 1330 | * Called before each layer manager transaction to allow any preparation |
michael@0 | 1331 | * for DrawWindowUnderlay/Overlay that needs to be on the main thread. |
michael@0 | 1332 | * |
michael@0 | 1333 | * Always called on the main thread. |
michael@0 | 1334 | */ |
michael@0 | 1335 | virtual void PrepareWindowEffects() = 0; |
michael@0 | 1336 | |
michael@0 | 1337 | /** |
michael@0 | 1338 | * Called when shutting down the LayerManager to clean-up any cached resources. |
michael@0 | 1339 | * |
michael@0 | 1340 | * Always called from the compositing thread, which may be the main-thread if |
michael@0 | 1341 | * OMTC is not enabled. |
michael@0 | 1342 | */ |
michael@0 | 1343 | virtual void CleanupWindowEffects() = 0; |
michael@0 | 1344 | |
michael@0 | 1345 | /** |
michael@0 | 1346 | * Called before rendering using OMTC. Returns false when the widget is |
michael@0 | 1347 | * not ready to be rendered (for example while the window is closed). |
michael@0 | 1348 | * |
michael@0 | 1349 | * Always called from the compositing thread, which may be the main-thread if |
michael@0 | 1350 | * OMTC is not enabled. |
michael@0 | 1351 | */ |
michael@0 | 1352 | virtual bool PreRender(LayerManagerComposite* aManager) = 0; |
michael@0 | 1353 | |
michael@0 | 1354 | /** |
michael@0 | 1355 | * Called after rendering using OMTC. Not called when rendering was |
michael@0 | 1356 | * cancelled by a negative return value from PreRender. |
michael@0 | 1357 | * |
michael@0 | 1358 | * Always called from the compositing thread, which may be the main-thread if |
michael@0 | 1359 | * OMTC is not enabled. |
michael@0 | 1360 | */ |
michael@0 | 1361 | virtual void PostRender(LayerManagerComposite* aManager) = 0; |
michael@0 | 1362 | |
michael@0 | 1363 | /** |
michael@0 | 1364 | * Called before the LayerManager draws the layer tree. |
michael@0 | 1365 | * |
michael@0 | 1366 | * Always called from the compositing thread. |
michael@0 | 1367 | */ |
michael@0 | 1368 | virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, nsIntRect aRect) = 0; |
michael@0 | 1369 | |
michael@0 | 1370 | /** |
michael@0 | 1371 | * Called after the LayerManager draws the layer tree |
michael@0 | 1372 | * |
michael@0 | 1373 | * Always called from the compositing thread. |
michael@0 | 1374 | */ |
michael@0 | 1375 | virtual void DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect) = 0; |
michael@0 | 1376 | |
michael@0 | 1377 | /** |
michael@0 | 1378 | * Return a DrawTarget for the window which can be composited into. |
michael@0 | 1379 | * |
michael@0 | 1380 | * Called by BasicCompositor on the compositor thread for OMTC drawing |
michael@0 | 1381 | * before each composition. |
michael@0 | 1382 | */ |
michael@0 | 1383 | virtual mozilla::TemporaryRef<mozilla::gfx::DrawTarget> StartRemoteDrawing() = 0; |
michael@0 | 1384 | |
michael@0 | 1385 | /** |
michael@0 | 1386 | * Ensure that what was painted into the DrawTarget returned from |
michael@0 | 1387 | * StartRemoteDrawing reaches the screen. |
michael@0 | 1388 | * |
michael@0 | 1389 | * Called by BasicCompositor on the compositor thread for OMTC drawing |
michael@0 | 1390 | * after each composition. |
michael@0 | 1391 | */ |
michael@0 | 1392 | virtual void EndRemoteDrawing() = 0; |
michael@0 | 1393 | |
michael@0 | 1394 | /** |
michael@0 | 1395 | * Clean up any resources used by Start/EndRemoteDrawing. |
michael@0 | 1396 | * |
michael@0 | 1397 | * Called by BasicCompositor on the compositor thread for OMTC drawing |
michael@0 | 1398 | * when the compositor is destroyed. |
michael@0 | 1399 | */ |
michael@0 | 1400 | virtual void CleanupRemoteDrawing() = 0; |
michael@0 | 1401 | |
michael@0 | 1402 | /** |
michael@0 | 1403 | * Called when Gecko knows which themed widgets exist in this window. |
michael@0 | 1404 | * The passed array contains an entry for every themed widget of the right |
michael@0 | 1405 | * type (currently only NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR and |
michael@0 | 1406 | * NS_THEME_TOOLBAR) within the window, except for themed widgets which are |
michael@0 | 1407 | * transformed or have effects applied to them (e.g. CSS opacity or |
michael@0 | 1408 | * filters). |
michael@0 | 1409 | * This could sometimes be called during display list construction |
michael@0 | 1410 | * outside of painting. |
michael@0 | 1411 | * If called during painting, it will be called before we actually |
michael@0 | 1412 | * paint anything. |
michael@0 | 1413 | */ |
michael@0 | 1414 | virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) = 0; |
michael@0 | 1415 | |
michael@0 | 1416 | /** |
michael@0 | 1417 | * Informs the widget about the region of the window that is opaque. |
michael@0 | 1418 | * |
michael@0 | 1419 | * @param aOpaqueRegion the region of the window that is opaque. |
michael@0 | 1420 | */ |
michael@0 | 1421 | virtual void UpdateOpaqueRegion(const nsIntRegion &aOpaqueRegion) {} |
michael@0 | 1422 | |
michael@0 | 1423 | /** |
michael@0 | 1424 | * Internal methods |
michael@0 | 1425 | */ |
michael@0 | 1426 | |
michael@0 | 1427 | //@{ |
michael@0 | 1428 | virtual void AddChild(nsIWidget* aChild) = 0; |
michael@0 | 1429 | virtual void RemoveChild(nsIWidget* aChild) = 0; |
michael@0 | 1430 | virtual void* GetNativeData(uint32_t aDataType) = 0; |
michael@0 | 1431 | virtual void FreeNativeData(void * data, uint32_t aDataType) = 0;//~~~ |
michael@0 | 1432 | |
michael@0 | 1433 | // GetDeviceContext returns a weak pointer to this widget's device context |
michael@0 | 1434 | virtual nsDeviceContext* GetDeviceContext() = 0; |
michael@0 | 1435 | |
michael@0 | 1436 | //@} |
michael@0 | 1437 | |
michael@0 | 1438 | /** |
michael@0 | 1439 | * Set the widget's title. |
michael@0 | 1440 | * Must be called after Create. |
michael@0 | 1441 | * |
michael@0 | 1442 | * @param aTitle string displayed as the title of the widget |
michael@0 | 1443 | */ |
michael@0 | 1444 | |
michael@0 | 1445 | NS_IMETHOD SetTitle(const nsAString& aTitle) = 0; |
michael@0 | 1446 | |
michael@0 | 1447 | /** |
michael@0 | 1448 | * Set the widget's icon. |
michael@0 | 1449 | * Must be called after Create. |
michael@0 | 1450 | * |
michael@0 | 1451 | * @param anIconSpec string specifying the icon to use; convention is to pass |
michael@0 | 1452 | * a resource: URL from which a platform-dependent resource |
michael@0 | 1453 | * file name will be constructed |
michael@0 | 1454 | */ |
michael@0 | 1455 | |
michael@0 | 1456 | NS_IMETHOD SetIcon(const nsAString& anIconSpec) = 0; |
michael@0 | 1457 | |
michael@0 | 1458 | /** |
michael@0 | 1459 | * Return this widget's origin in screen coordinates. |
michael@0 | 1460 | * |
michael@0 | 1461 | * @return screen coordinates stored in the x,y members |
michael@0 | 1462 | */ |
michael@0 | 1463 | |
michael@0 | 1464 | virtual nsIntPoint WidgetToScreenOffset() = 0; |
michael@0 | 1465 | |
michael@0 | 1466 | /** |
michael@0 | 1467 | * Given the specified client size, return the corresponding window size, |
michael@0 | 1468 | * which includes the area for the borders and titlebar. This method |
michael@0 | 1469 | * should work even when the window is not yet visible. |
michael@0 | 1470 | */ |
michael@0 | 1471 | virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize) = 0; |
michael@0 | 1472 | |
michael@0 | 1473 | /** |
michael@0 | 1474 | * Dispatches an event to the widget |
michael@0 | 1475 | * |
michael@0 | 1476 | */ |
michael@0 | 1477 | NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* event, |
michael@0 | 1478 | nsEventStatus & aStatus) = 0; |
michael@0 | 1479 | |
michael@0 | 1480 | /** |
michael@0 | 1481 | * Enables the dropping of files to a widget (XXX this is temporary) |
michael@0 | 1482 | * |
michael@0 | 1483 | */ |
michael@0 | 1484 | NS_IMETHOD EnableDragDrop(bool aEnable) = 0; |
michael@0 | 1485 | |
michael@0 | 1486 | /** |
michael@0 | 1487 | * Enables/Disables system mouse capture. |
michael@0 | 1488 | * @param aCapture true enables mouse capture, false disables mouse capture |
michael@0 | 1489 | * |
michael@0 | 1490 | */ |
michael@0 | 1491 | NS_IMETHOD CaptureMouse(bool aCapture) = 0; |
michael@0 | 1492 | |
michael@0 | 1493 | /** |
michael@0 | 1494 | * Classify the window for the window manager. Mostly for X11. |
michael@0 | 1495 | */ |
michael@0 | 1496 | NS_IMETHOD SetWindowClass(const nsAString& xulWinType) = 0; |
michael@0 | 1497 | |
michael@0 | 1498 | /** |
michael@0 | 1499 | * Enables/Disables system capture of any and all events that would cause a |
michael@0 | 1500 | * popup to be rolled up. aListener should be set to a non-null value for |
michael@0 | 1501 | * any popups that are not managed by the popup manager. |
michael@0 | 1502 | * @param aDoCapture true enables capture, false disables capture |
michael@0 | 1503 | * |
michael@0 | 1504 | */ |
michael@0 | 1505 | NS_IMETHOD CaptureRollupEvents(nsIRollupListener* aListener, bool aDoCapture) = 0; |
michael@0 | 1506 | |
michael@0 | 1507 | /** |
michael@0 | 1508 | * Bring this window to the user's attention. This is intended to be a more |
michael@0 | 1509 | * gentle notification than popping the window to the top or putting up an |
michael@0 | 1510 | * alert. See, for example, Win32 FlashWindow or the NotificationManager on |
michael@0 | 1511 | * the Mac. The notification should be suppressed if the window is already |
michael@0 | 1512 | * in the foreground and should be dismissed when the user brings this window |
michael@0 | 1513 | * to the foreground. |
michael@0 | 1514 | * @param aCycleCount Maximum number of times to animate the window per system |
michael@0 | 1515 | * conventions. If set to -1, cycles indefinitely until |
michael@0 | 1516 | * window is brought into the foreground. |
michael@0 | 1517 | */ |
michael@0 | 1518 | NS_IMETHOD GetAttention(int32_t aCycleCount) = 0; |
michael@0 | 1519 | |
michael@0 | 1520 | /** |
michael@0 | 1521 | * Ask whether there user input events pending. All input events are |
michael@0 | 1522 | * included, including those not targeted at this nsIwidget instance. |
michael@0 | 1523 | */ |
michael@0 | 1524 | virtual bool HasPendingInputEvent() = 0; |
michael@0 | 1525 | |
michael@0 | 1526 | /** |
michael@0 | 1527 | * Set the background color of the window titlebar for this widget. On Mac, |
michael@0 | 1528 | * for example, this will remove the grey gradient and bottom border and |
michael@0 | 1529 | * instead show a single, solid color. |
michael@0 | 1530 | * |
michael@0 | 1531 | * Ignored on any platform that does not support it. Ignored by widgets that |
michael@0 | 1532 | * do not represent windows. |
michael@0 | 1533 | * |
michael@0 | 1534 | * @param aColor The color to set the title bar background to. Alpha values |
michael@0 | 1535 | * other than fully transparent (0) are respected if possible |
michael@0 | 1536 | * on the platform. An alpha of 0 will cause the window to |
michael@0 | 1537 | * draw with the default style for the platform. |
michael@0 | 1538 | * |
michael@0 | 1539 | * @param aActive Whether the color should be applied to active or inactive |
michael@0 | 1540 | * windows. |
michael@0 | 1541 | */ |
michael@0 | 1542 | NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, bool aActive) = 0; |
michael@0 | 1543 | |
michael@0 | 1544 | /** |
michael@0 | 1545 | * If set to true, the window will draw its contents into the titlebar |
michael@0 | 1546 | * instead of below it. |
michael@0 | 1547 | * |
michael@0 | 1548 | * Ignored on any platform that does not support it. Ignored by widgets that |
michael@0 | 1549 | * do not represent windows. |
michael@0 | 1550 | * May result in a resize event, so should only be called from places where |
michael@0 | 1551 | * reflow and painting is allowed. |
michael@0 | 1552 | * |
michael@0 | 1553 | * @param aState Whether drawing into the titlebar should be activated. |
michael@0 | 1554 | */ |
michael@0 | 1555 | virtual void SetDrawsInTitlebar(bool aState) = 0; |
michael@0 | 1556 | |
michael@0 | 1557 | /* |
michael@0 | 1558 | * Determine whether the widget shows a resize widget. If it does, |
michael@0 | 1559 | * aResizerRect returns the resizer's rect. |
michael@0 | 1560 | * |
michael@0 | 1561 | * Returns false on any platform that does not support it. |
michael@0 | 1562 | * |
michael@0 | 1563 | * @param aResizerRect The resizer's rect in device pixels. |
michael@0 | 1564 | * @return Whether a resize widget is shown. |
michael@0 | 1565 | */ |
michael@0 | 1566 | virtual bool ShowsResizeIndicator(nsIntRect* aResizerRect) = 0; |
michael@0 | 1567 | |
michael@0 | 1568 | /** |
michael@0 | 1569 | * Get the Thebes surface associated with this widget. |
michael@0 | 1570 | */ |
michael@0 | 1571 | virtual gfxASurface *GetThebesSurface() = 0; |
michael@0 | 1572 | |
michael@0 | 1573 | /** |
michael@0 | 1574 | * Return the popup that was last rolled up, or null if there isn't one. |
michael@0 | 1575 | */ |
michael@0 | 1576 | virtual nsIContent* GetLastRollup() = 0; |
michael@0 | 1577 | |
michael@0 | 1578 | /** |
michael@0 | 1579 | * Begin a window resizing drag, based on the event passed in. |
michael@0 | 1580 | */ |
michael@0 | 1581 | NS_IMETHOD BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent, |
michael@0 | 1582 | int32_t aHorizontal, |
michael@0 | 1583 | int32_t aVertical) = 0; |
michael@0 | 1584 | |
michael@0 | 1585 | /** |
michael@0 | 1586 | * Begin a window moving drag, based on the event passed in. |
michael@0 | 1587 | */ |
michael@0 | 1588 | NS_IMETHOD BeginMoveDrag(mozilla::WidgetMouseEvent* aEvent) = 0; |
michael@0 | 1589 | |
michael@0 | 1590 | enum Modifiers { |
michael@0 | 1591 | CAPS_LOCK = 0x01, // when CapsLock is active |
michael@0 | 1592 | NUM_LOCK = 0x02, // when NumLock is active |
michael@0 | 1593 | SHIFT_L = 0x0100, |
michael@0 | 1594 | SHIFT_R = 0x0200, |
michael@0 | 1595 | CTRL_L = 0x0400, |
michael@0 | 1596 | CTRL_R = 0x0800, |
michael@0 | 1597 | ALT_L = 0x1000, // includes Option |
michael@0 | 1598 | ALT_R = 0x2000, |
michael@0 | 1599 | COMMAND_L = 0x4000, |
michael@0 | 1600 | COMMAND_R = 0x8000, |
michael@0 | 1601 | HELP = 0x10000, |
michael@0 | 1602 | FUNCTION = 0x100000, |
michael@0 | 1603 | NUMERIC_KEY_PAD = 0x01000000 // when the key is coming from the keypad |
michael@0 | 1604 | }; |
michael@0 | 1605 | /** |
michael@0 | 1606 | * Utility method intended for testing. Dispatches native key events |
michael@0 | 1607 | * to this widget to simulate the press and release of a key. |
michael@0 | 1608 | * @param aNativeKeyboardLayout a *platform-specific* constant. |
michael@0 | 1609 | * On Mac, this is the resource ID for a 'uchr' or 'kchr' resource. |
michael@0 | 1610 | * On Windows, it is converted to a hex string and passed to |
michael@0 | 1611 | * LoadKeyboardLayout, see |
michael@0 | 1612 | * http://msdn.microsoft.com/en-us/library/ms646305(VS.85).aspx |
michael@0 | 1613 | * @param aNativeKeyCode a *platform-specific* keycode. |
michael@0 | 1614 | * On Windows, this is the virtual key code. |
michael@0 | 1615 | * @param aModifiers some combination of the above 'Modifiers' flags; |
michael@0 | 1616 | * not all flags will apply to all platforms. Mac ignores the _R |
michael@0 | 1617 | * modifiers. Windows ignores COMMAND, NUMERIC_KEY_PAD, HELP and |
michael@0 | 1618 | * FUNCTION. |
michael@0 | 1619 | * @param aCharacters characters that the OS would decide to generate |
michael@0 | 1620 | * from the event. On Windows, this is the charCode passed by |
michael@0 | 1621 | * WM_CHAR. |
michael@0 | 1622 | * @param aUnmodifiedCharacters characters that the OS would decide |
michael@0 | 1623 | * to generate from the event if modifier keys (other than shift) |
michael@0 | 1624 | * were assumed inactive. Needed on Mac, ignored on Windows. |
michael@0 | 1625 | * @return NS_ERROR_NOT_AVAILABLE to indicate that the keyboard |
michael@0 | 1626 | * layout is not supported and the event was not fired |
michael@0 | 1627 | */ |
michael@0 | 1628 | virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout, |
michael@0 | 1629 | int32_t aNativeKeyCode, |
michael@0 | 1630 | uint32_t aModifierFlags, |
michael@0 | 1631 | const nsAString& aCharacters, |
michael@0 | 1632 | const nsAString& aUnmodifiedCharacters) = 0; |
michael@0 | 1633 | |
michael@0 | 1634 | /** |
michael@0 | 1635 | * Utility method intended for testing. Dispatches native mouse events |
michael@0 | 1636 | * may even move the mouse cursor. On Mac the events are guaranteed to |
michael@0 | 1637 | * be sent to the window containing this widget, but on Windows they'll go |
michael@0 | 1638 | * to whatever's topmost on the screen at that position, so for |
michael@0 | 1639 | * cross-platform testing ensure that your window is at the top of the |
michael@0 | 1640 | * z-order. |
michael@0 | 1641 | * @param aPoint screen location of the mouse, in device |
michael@0 | 1642 | * pixels, with origin at the top left |
michael@0 | 1643 | * @param aNativeMessage *platform-specific* event type (e.g. on Mac, |
michael@0 | 1644 | * NSMouseMoved; on Windows, MOUSEEVENTF_MOVE, MOUSEEVENTF_LEFTDOWN etc) |
michael@0 | 1645 | * @param aModifierFlags *platform-specific* modifier flags (ignored |
michael@0 | 1646 | * on Windows) |
michael@0 | 1647 | */ |
michael@0 | 1648 | virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint, |
michael@0 | 1649 | uint32_t aNativeMessage, |
michael@0 | 1650 | uint32_t aModifierFlags) = 0; |
michael@0 | 1651 | |
michael@0 | 1652 | /** |
michael@0 | 1653 | * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native message. |
michael@0 | 1654 | * aPoint is location in device pixels to which the mouse pointer moves to. |
michael@0 | 1655 | */ |
michael@0 | 1656 | virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint) = 0; |
michael@0 | 1657 | |
michael@0 | 1658 | /** |
michael@0 | 1659 | * Utility method intended for testing. Dispatching native mouse scroll |
michael@0 | 1660 | * events may move the mouse cursor. |
michael@0 | 1661 | * |
michael@0 | 1662 | * @param aPoint Mouse cursor position in screen coordinates. |
michael@0 | 1663 | * In device pixels, the origin at the top left of |
michael@0 | 1664 | * the primary display. |
michael@0 | 1665 | * @param aNativeMessage Platform native message. |
michael@0 | 1666 | * @param aDeltaX The delta value for X direction. If the native |
michael@0 | 1667 | * message doesn't indicate X direction scrolling, |
michael@0 | 1668 | * this may be ignored. |
michael@0 | 1669 | * @param aDeltaY The delta value for Y direction. If the native |
michael@0 | 1670 | * message doesn't indicate Y direction scrolling, |
michael@0 | 1671 | * this may be ignored. |
michael@0 | 1672 | * @param aDeltaZ The delta value for Z direction. If the native |
michael@0 | 1673 | * message doesn't indicate Z direction scrolling, |
michael@0 | 1674 | * this may be ignored. |
michael@0 | 1675 | * @param aModifierFlags Must be values of Modifiers, or zero. |
michael@0 | 1676 | * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their |
michael@0 | 1677 | * document. |
michael@0 | 1678 | */ |
michael@0 | 1679 | virtual nsresult SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint, |
michael@0 | 1680 | uint32_t aNativeMessage, |
michael@0 | 1681 | double aDeltaX, |
michael@0 | 1682 | double aDeltaY, |
michael@0 | 1683 | double aDeltaZ, |
michael@0 | 1684 | uint32_t aModifierFlags, |
michael@0 | 1685 | uint32_t aAdditionalFlags) = 0; |
michael@0 | 1686 | |
michael@0 | 1687 | /* |
michael@0 | 1688 | * TouchPointerState states for SynthesizeNativeTouchPoint. Match |
michael@0 | 1689 | * touch states in nsIDOMWindowUtils.idl. |
michael@0 | 1690 | */ |
michael@0 | 1691 | enum TouchPointerState { |
michael@0 | 1692 | // The pointer is in a hover state above the digitizer |
michael@0 | 1693 | TOUCH_HOVER = 0x01, |
michael@0 | 1694 | // The pointer is in contact with the digitizer |
michael@0 | 1695 | TOUCH_CONTACT = 0x02, |
michael@0 | 1696 | // The pointer has been removed from the digitizer detection area |
michael@0 | 1697 | TOUCH_REMOVE = 0x04, |
michael@0 | 1698 | // The pointer has been canceled. Will cancel any pending os level |
michael@0 | 1699 | // gestures that would triggered as a result of completion of the |
michael@0 | 1700 | // input sequence. This may not cancel moz platform related events |
michael@0 | 1701 | // that might get tirggered by input already delivered. |
michael@0 | 1702 | TOUCH_CANCEL = 0x08 |
michael@0 | 1703 | }; |
michael@0 | 1704 | |
michael@0 | 1705 | /* |
michael@0 | 1706 | * Create a new or update an existing touch pointer on the digitizer. |
michael@0 | 1707 | * To trigger os level gestures, individual touch points should |
michael@0 | 1708 | * transition through a complete set of touch states which should be |
michael@0 | 1709 | * sent as individual messages. |
michael@0 | 1710 | * |
michael@0 | 1711 | * @param aPointerId The touch point id to create or update. |
michael@0 | 1712 | * @param aPointerState one or more of the touch states listed above |
michael@0 | 1713 | * @param aScreenX, aScreenY screen coords of this event |
michael@0 | 1714 | * @param aPressure 0.0 -> 1.0 float val indicating pressure |
michael@0 | 1715 | * @param aOrientation 0 -> 359 degree value indicating the |
michael@0 | 1716 | * orientation of the pointer. Use 90 for normal taps. |
michael@0 | 1717 | */ |
michael@0 | 1718 | virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId, |
michael@0 | 1719 | TouchPointerState aPointerState, |
michael@0 | 1720 | nsIntPoint aPointerScreenPoint, |
michael@0 | 1721 | double aPointerPressure, |
michael@0 | 1722 | uint32_t aPointerOrientation) = 0; |
michael@0 | 1723 | |
michael@0 | 1724 | /* |
michael@0 | 1725 | * Cancels all active simulated touch input points and pending long taps. |
michael@0 | 1726 | * Native widgets should track existing points such that they can clear the |
michael@0 | 1727 | * digitizer state when this call is made. |
michael@0 | 1728 | */ |
michael@0 | 1729 | virtual nsresult ClearNativeTouchSequence(); |
michael@0 | 1730 | |
michael@0 | 1731 | /* |
michael@0 | 1732 | * Helper for simulating a simple tap event with one touch point. When |
michael@0 | 1733 | * aLongTap is true, simulates a native long tap with a duration equal to |
michael@0 | 1734 | * ui.click_hold_context_menus.delay. This pref is compatible with the |
michael@0 | 1735 | * apzc long tap duration. Defaults to 1.5 seconds. |
michael@0 | 1736 | */ |
michael@0 | 1737 | nsresult SynthesizeNativeTouchTap(nsIntPoint aPointerScreenPoint, |
michael@0 | 1738 | bool aLongTap); |
michael@0 | 1739 | |
michael@0 | 1740 | private: |
michael@0 | 1741 | class LongTapInfo |
michael@0 | 1742 | { |
michael@0 | 1743 | public: |
michael@0 | 1744 | LongTapInfo(int32_t aPointerId, nsIntPoint& aPoint, |
michael@0 | 1745 | mozilla::TimeDuration aDuration) : |
michael@0 | 1746 | mPointerId(aPointerId), |
michael@0 | 1747 | mPosition(aPoint), |
michael@0 | 1748 | mDuration(aDuration), |
michael@0 | 1749 | mStamp(mozilla::TimeStamp::Now()) |
michael@0 | 1750 | { |
michael@0 | 1751 | } |
michael@0 | 1752 | |
michael@0 | 1753 | int32_t mPointerId; |
michael@0 | 1754 | nsIntPoint mPosition; |
michael@0 | 1755 | mozilla::TimeDuration mDuration; |
michael@0 | 1756 | mozilla::TimeStamp mStamp; |
michael@0 | 1757 | }; |
michael@0 | 1758 | |
michael@0 | 1759 | static void OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure); |
michael@0 | 1760 | |
michael@0 | 1761 | nsAutoPtr<LongTapInfo> mLongTapTouchPoint; |
michael@0 | 1762 | nsCOMPtr<nsITimer> mLongTapTimer; |
michael@0 | 1763 | static int32_t sPointerIdCounter; |
michael@0 | 1764 | |
michael@0 | 1765 | public: |
michael@0 | 1766 | /** |
michael@0 | 1767 | * Activates a native menu item at the position specified by the index |
michael@0 | 1768 | * string. The index string is a string of positive integers separated |
michael@0 | 1769 | * by the "|" (pipe) character. The last integer in the string represents |
michael@0 | 1770 | * the item index in a submenu located using the integers preceding it. |
michael@0 | 1771 | * |
michael@0 | 1772 | * Example: 1|0|4 |
michael@0 | 1773 | * In this string, the first integer represents the top-level submenu |
michael@0 | 1774 | * in the native menu bar. Since the integer is 1, it is the second submeu |
michael@0 | 1775 | * in the native menu bar. Within that, the first item (index 0) is a |
michael@0 | 1776 | * submenu, and we want to activate the 5th item within that submenu. |
michael@0 | 1777 | */ |
michael@0 | 1778 | virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) = 0; |
michael@0 | 1779 | |
michael@0 | 1780 | /** |
michael@0 | 1781 | * This is used for native menu system testing. |
michael@0 | 1782 | * |
michael@0 | 1783 | * Updates a native menu at the position specified by the index string. |
michael@0 | 1784 | * The index string is a string of positive integers separated by the "|" |
michael@0 | 1785 | * (pipe) character. |
michael@0 | 1786 | * |
michael@0 | 1787 | * Example: 1|0|4 |
michael@0 | 1788 | * In this string, the first integer represents the top-level submenu |
michael@0 | 1789 | * in the native menu bar. Since the integer is 1, it is the second submeu |
michael@0 | 1790 | * in the native menu bar. Within that, the first item (index 0) is a |
michael@0 | 1791 | * submenu, and we want to update submenu at index 4 within that submenu. |
michael@0 | 1792 | * |
michael@0 | 1793 | * If this is called with an empty string it forces a full reload of the |
michael@0 | 1794 | * menu system. |
michael@0 | 1795 | */ |
michael@0 | 1796 | virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) = 0; |
michael@0 | 1797 | |
michael@0 | 1798 | /** |
michael@0 | 1799 | * Notify IME of the specified notification. |
michael@0 | 1800 | */ |
michael@0 | 1801 | NS_IMETHOD NotifyIME(const IMENotification& aIMENotification) = 0; |
michael@0 | 1802 | |
michael@0 | 1803 | /* |
michael@0 | 1804 | * Notifies the input context changes. |
michael@0 | 1805 | */ |
michael@0 | 1806 | NS_IMETHOD_(void) SetInputContext(const InputContext& aContext, |
michael@0 | 1807 | const InputContextAction& aAction) = 0; |
michael@0 | 1808 | |
michael@0 | 1809 | /* |
michael@0 | 1810 | * Get current input context. |
michael@0 | 1811 | */ |
michael@0 | 1812 | NS_IMETHOD_(InputContext) GetInputContext() = 0; |
michael@0 | 1813 | |
michael@0 | 1814 | /* |
michael@0 | 1815 | * Given a WidgetKeyboardEvent, this method synthesizes a corresponding |
michael@0 | 1816 | * native (OS-level) event for it. This method allows tests to simulate |
michael@0 | 1817 | * keystrokes that trigger native key bindings (which require a native |
michael@0 | 1818 | * event). |
michael@0 | 1819 | */ |
michael@0 | 1820 | NS_IMETHOD AttachNativeKeyEvent(mozilla::WidgetKeyboardEvent& aEvent) = 0; |
michael@0 | 1821 | |
michael@0 | 1822 | /* |
michael@0 | 1823 | * Execute native key bindings for aType. |
michael@0 | 1824 | */ |
michael@0 | 1825 | typedef void (*DoCommandCallback)(mozilla::Command, void*); |
michael@0 | 1826 | enum NativeKeyBindingsType |
michael@0 | 1827 | { |
michael@0 | 1828 | NativeKeyBindingsForSingleLineEditor, |
michael@0 | 1829 | NativeKeyBindingsForMultiLineEditor, |
michael@0 | 1830 | NativeKeyBindingsForRichTextEditor |
michael@0 | 1831 | }; |
michael@0 | 1832 | NS_IMETHOD_(bool) ExecuteNativeKeyBinding( |
michael@0 | 1833 | NativeKeyBindingsType aType, |
michael@0 | 1834 | const mozilla::WidgetKeyboardEvent& aEvent, |
michael@0 | 1835 | DoCommandCallback aCallback, |
michael@0 | 1836 | void* aCallbackData) = 0; |
michael@0 | 1837 | |
michael@0 | 1838 | /** |
michael@0 | 1839 | * Set layers acceleration to 'True' or 'False' |
michael@0 | 1840 | */ |
michael@0 | 1841 | NS_IMETHOD SetLayersAcceleration(bool aEnabled) = 0; |
michael@0 | 1842 | |
michael@0 | 1843 | /* |
michael@0 | 1844 | * Get toggled key states. |
michael@0 | 1845 | * aKeyCode should be NS_VK_CAPS_LOCK or NS_VK_NUM_LOCK or |
michael@0 | 1846 | * NS_VK_SCROLL_LOCK. |
michael@0 | 1847 | * aLEDState is the result for current LED state of the key. |
michael@0 | 1848 | * If the LED is 'ON', it returns TRUE, otherwise, FALSE. |
michael@0 | 1849 | * If the platform doesn't support the LED state (or we cannot get the |
michael@0 | 1850 | * state), this method returns NS_ERROR_NOT_IMPLEMENTED. |
michael@0 | 1851 | */ |
michael@0 | 1852 | NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) = 0; |
michael@0 | 1853 | |
michael@0 | 1854 | /* |
michael@0 | 1855 | * Retrieves preference for IME updates |
michael@0 | 1856 | */ |
michael@0 | 1857 | virtual nsIMEUpdatePreference GetIMEUpdatePreference() = 0; |
michael@0 | 1858 | |
michael@0 | 1859 | /* |
michael@0 | 1860 | * Call this method when a dialog is opened which has a default button. |
michael@0 | 1861 | * The button's rectangle should be supplied in aButtonRect. |
michael@0 | 1862 | */ |
michael@0 | 1863 | NS_IMETHOD OnDefaultButtonLoaded(const nsIntRect &aButtonRect) = 0; |
michael@0 | 1864 | |
michael@0 | 1865 | /** |
michael@0 | 1866 | * Compute the overridden system mouse scroll speed on the root content of |
michael@0 | 1867 | * web pages. The widget may set the same value as aOriginalDelta. E.g., |
michael@0 | 1868 | * when the system scrolling settings were customized, widget can respect |
michael@0 | 1869 | * the will of the user. |
michael@0 | 1870 | * |
michael@0 | 1871 | * This is called only when the mouse wheel event scrolls the root content |
michael@0 | 1872 | * of the web pages by line. In other words, this isn't called when the |
michael@0 | 1873 | * mouse wheel event is used for zoom, page scroll and other special |
michael@0 | 1874 | * actions. And also this isn't called when the user doesn't use the |
michael@0 | 1875 | * system wheel speed settings. |
michael@0 | 1876 | * |
michael@0 | 1877 | * @param aOriginalDeltaX The X delta value of the current mouse wheel |
michael@0 | 1878 | * scrolling event. |
michael@0 | 1879 | * @param aOriginalDeltaX The Y delta value of the current mouse wheel |
michael@0 | 1880 | * scrolling event. |
michael@0 | 1881 | * @param aOverriddenDeltaX The overridden mouse scrolling speed along X |
michael@0 | 1882 | * axis. This value may be same as aOriginalDeltaX. |
michael@0 | 1883 | * @param aOverriddenDeltaY The overridden mouse scrolling speed along Y |
michael@0 | 1884 | * axis. This value may be same as aOriginalDeltaY. |
michael@0 | 1885 | */ |
michael@0 | 1886 | NS_IMETHOD OverrideSystemMouseScrollSpeed(double aOriginalDeltaX, |
michael@0 | 1887 | double aOriginalDeltaY, |
michael@0 | 1888 | double& aOverriddenDeltaX, |
michael@0 | 1889 | double& aOverriddenDeltaY) = 0; |
michael@0 | 1890 | |
michael@0 | 1891 | /** |
michael@0 | 1892 | * Return true if this process shouldn't use platform widgets, and |
michael@0 | 1893 | * so should use PuppetWidgets instead. If this returns true, the |
michael@0 | 1894 | * result of creating and using a platform widget is undefined, |
michael@0 | 1895 | * and likely to end in crashes or other buggy behavior. |
michael@0 | 1896 | */ |
michael@0 | 1897 | static bool |
michael@0 | 1898 | UsePuppetWidgets() |
michael@0 | 1899 | { |
michael@0 | 1900 | return XRE_GetProcessType() == GeckoProcessType_Content; |
michael@0 | 1901 | } |
michael@0 | 1902 | |
michael@0 | 1903 | /** |
michael@0 | 1904 | * Allocate and return a "puppet widget" that doesn't directly |
michael@0 | 1905 | * correlate to a platform widget; platform events and data must |
michael@0 | 1906 | * be fed to it. Currently used in content processes. NULL is |
michael@0 | 1907 | * returned if puppet widgets aren't supported in this build |
michael@0 | 1908 | * config, on this platform, or for this process type. |
michael@0 | 1909 | * |
michael@0 | 1910 | * This function is called "Create" to match CreateInstance(). |
michael@0 | 1911 | * The returned widget must still be nsIWidget::Create()d. |
michael@0 | 1912 | */ |
michael@0 | 1913 | static already_AddRefed<nsIWidget> |
michael@0 | 1914 | CreatePuppetWidget(TabChild* aTabChild); |
michael@0 | 1915 | |
michael@0 | 1916 | /** |
michael@0 | 1917 | * Reparent this widget's native widget. |
michael@0 | 1918 | * @param aNewParent the native widget of aNewParent is the new native |
michael@0 | 1919 | * parent widget |
michael@0 | 1920 | */ |
michael@0 | 1921 | NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent) = 0; |
michael@0 | 1922 | |
michael@0 | 1923 | /** |
michael@0 | 1924 | * Return the internal format of the default framebuffer for this |
michael@0 | 1925 | * widget. |
michael@0 | 1926 | */ |
michael@0 | 1927 | virtual uint32_t GetGLFrameBufferFormat() { return 0; /*GL_NONE*/ } |
michael@0 | 1928 | |
michael@0 | 1929 | /** |
michael@0 | 1930 | * Return true if widget has it's own GL context |
michael@0 | 1931 | */ |
michael@0 | 1932 | virtual bool HasGLContext() { return false; } |
michael@0 | 1933 | |
michael@0 | 1934 | /** |
michael@0 | 1935 | * Returns true to indicate that this widget paints an opaque background |
michael@0 | 1936 | * that we want to be visible under the page, so layout should not force |
michael@0 | 1937 | * a default background. |
michael@0 | 1938 | */ |
michael@0 | 1939 | virtual bool WidgetPaintsBackground() { return false; } |
michael@0 | 1940 | |
michael@0 | 1941 | virtual bool NeedsPaint() { |
michael@0 | 1942 | if (!IsVisible()) { |
michael@0 | 1943 | return false; |
michael@0 | 1944 | } |
michael@0 | 1945 | nsIntRect bounds; |
michael@0 | 1946 | nsresult rv = GetBounds(bounds); |
michael@0 | 1947 | NS_ENSURE_SUCCESS(rv, false); |
michael@0 | 1948 | return !bounds.IsEmpty(); |
michael@0 | 1949 | } |
michael@0 | 1950 | |
michael@0 | 1951 | /** |
michael@0 | 1952 | * Get the natural bounds of this widget. This method is only |
michael@0 | 1953 | * meaningful for widgets for which Gecko implements screen |
michael@0 | 1954 | * rotation natively. When this is the case, GetBounds() returns |
michael@0 | 1955 | * the widget bounds taking rotation into account, and |
michael@0 | 1956 | * GetNaturalBounds() returns the bounds *not* taking rotation |
michael@0 | 1957 | * into account. |
michael@0 | 1958 | * |
michael@0 | 1959 | * No code outside of the composition pipeline should know or care |
michael@0 | 1960 | * about this. If you're not an agent of the compositor, you |
michael@0 | 1961 | * probably shouldn't call this method. |
michael@0 | 1962 | */ |
michael@0 | 1963 | virtual nsIntRect GetNaturalBounds() { |
michael@0 | 1964 | nsIntRect bounds; |
michael@0 | 1965 | GetBounds(bounds); |
michael@0 | 1966 | return bounds; |
michael@0 | 1967 | } |
michael@0 | 1968 | |
michael@0 | 1969 | /** |
michael@0 | 1970 | * Set size constraints on the window size such that it is never less than |
michael@0 | 1971 | * the specified minimum size and never larger than the specified maximum |
michael@0 | 1972 | * size. The size constraints are sizes of the outer rectangle including |
michael@0 | 1973 | * the window frame and title bar. Use 0 for an unconstrained minimum size |
michael@0 | 1974 | * and NS_MAXSIZE for an unconstrained maximum size. Note that this method |
michael@0 | 1975 | * does not necessarily change the size of a window to conform to this size, |
michael@0 | 1976 | * thus Resize should be called afterwards. |
michael@0 | 1977 | * |
michael@0 | 1978 | * @param aConstraints: the size constraints in device pixels |
michael@0 | 1979 | */ |
michael@0 | 1980 | virtual void SetSizeConstraints(const SizeConstraints& aConstraints) = 0; |
michael@0 | 1981 | |
michael@0 | 1982 | /** |
michael@0 | 1983 | * Return the size constraints currently observed by the widget. |
michael@0 | 1984 | * |
michael@0 | 1985 | * @return the constraints in device pixels |
michael@0 | 1986 | */ |
michael@0 | 1987 | virtual const SizeConstraints& GetSizeConstraints() const = 0; |
michael@0 | 1988 | |
michael@0 | 1989 | /** |
michael@0 | 1990 | * If this is owned by a TabChild, return that. Otherwise return |
michael@0 | 1991 | * null. |
michael@0 | 1992 | */ |
michael@0 | 1993 | virtual TabChild* GetOwningTabChild() { return nullptr; } |
michael@0 | 1994 | |
michael@0 | 1995 | /** |
michael@0 | 1996 | * If this isn't directly compositing to its window surface, |
michael@0 | 1997 | * return the compositor which is doing that on our behalf. |
michael@0 | 1998 | */ |
michael@0 | 1999 | virtual CompositorChild* GetRemoteRenderer() |
michael@0 | 2000 | { return nullptr; } |
michael@0 | 2001 | |
michael@0 | 2002 | /** |
michael@0 | 2003 | * If this widget has a more efficient composer available for its |
michael@0 | 2004 | * native framebuffer, return it. |
michael@0 | 2005 | * |
michael@0 | 2006 | * This can be called from a non-main thread, but that thread must |
michael@0 | 2007 | * hold a strong reference to this. |
michael@0 | 2008 | */ |
michael@0 | 2009 | virtual Composer2D* GetComposer2D() |
michael@0 | 2010 | { return nullptr; } |
michael@0 | 2011 | |
michael@0 | 2012 | /** |
michael@0 | 2013 | * Some platforms (only cocoa right now) round widget coordinates to the |
michael@0 | 2014 | * nearest even pixels (see bug 892994), this function allows us to |
michael@0 | 2015 | * determine how widget coordinates will be rounded. |
michael@0 | 2016 | */ |
michael@0 | 2017 | virtual int32_t RoundsWidgetCoordinatesTo() { return 1; } |
michael@0 | 2018 | |
michael@0 | 2019 | protected: |
michael@0 | 2020 | /** |
michael@0 | 2021 | * Like GetDefaultScale, but taking into account only the system settings |
michael@0 | 2022 | * and ignoring Gecko preferences. |
michael@0 | 2023 | */ |
michael@0 | 2024 | virtual double GetDefaultScaleInternal() { return 1.0; } |
michael@0 | 2025 | |
michael@0 | 2026 | // keep the list of children. We also keep track of our siblings. |
michael@0 | 2027 | // The ownership model is as follows: parent holds a strong ref to |
michael@0 | 2028 | // the first element of the list, and each element holds a strong |
michael@0 | 2029 | // ref to the next element in the list. The prevsibling and |
michael@0 | 2030 | // lastchild pointers are weak, which is fine as long as they are |
michael@0 | 2031 | // maintained properly. |
michael@0 | 2032 | nsCOMPtr<nsIWidget> mFirstChild; |
michael@0 | 2033 | nsIWidget* mLastChild; |
michael@0 | 2034 | nsCOMPtr<nsIWidget> mNextSibling; |
michael@0 | 2035 | nsIWidget* mPrevSibling; |
michael@0 | 2036 | // When Destroy() is called, the sub class should set this true. |
michael@0 | 2037 | bool mOnDestroyCalled; |
michael@0 | 2038 | nsWindowType mWindowType; |
michael@0 | 2039 | int32_t mZIndex; |
michael@0 | 2040 | }; |
michael@0 | 2041 | |
michael@0 | 2042 | NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget, NS_IWIDGET_IID) |
michael@0 | 2043 | |
michael@0 | 2044 | #endif // nsIWidget_h__ |