1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/nsIWidget.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,2044 @@ 1.4 +/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsIWidget_h__ 1.10 +#define nsIWidget_h__ 1.11 + 1.12 +#include "nsISupports.h" 1.13 +#include "nsColor.h" 1.14 +#include "nsRect.h" 1.15 +#include "nsStringGlue.h" 1.16 + 1.17 +#include "nsCOMPtr.h" 1.18 +#include "nsAutoPtr.h" 1.19 +#include "nsWidgetInitData.h" 1.20 +#include "nsTArray.h" 1.21 +#include "nsITimer.h" 1.22 +#include "nsXULAppAPI.h" 1.23 +#include "mozilla/EventForwards.h" 1.24 +#include "mozilla/layers/LayersTypes.h" 1.25 +#include "mozilla/RefPtr.h" 1.26 +#include "mozilla/TimeStamp.h" 1.27 +#include "Units.h" 1.28 + 1.29 +// forward declarations 1.30 +class nsFontMetrics; 1.31 +class nsRenderingContext; 1.32 +class nsDeviceContext; 1.33 +struct nsFont; 1.34 +class nsIRollupListener; 1.35 +class imgIContainer; 1.36 +class gfxASurface; 1.37 +class nsIContent; 1.38 +class ViewWrapper; 1.39 +class nsIWidgetListener; 1.40 +class nsIntRegion; 1.41 + 1.42 +namespace mozilla { 1.43 +namespace dom { 1.44 +class TabChild; 1.45 +} 1.46 +namespace layers { 1.47 +class Composer2D; 1.48 +class CompositorChild; 1.49 +class LayerManager; 1.50 +class LayerManagerComposite; 1.51 +class PLayerTransactionChild; 1.52 +} 1.53 +namespace gfx { 1.54 +class DrawTarget; 1.55 +} 1.56 +} 1.57 + 1.58 +/** 1.59 + * Callback function that processes events. 1.60 + * 1.61 + * The argument is actually a subtype (subclass) of WidgetEvent which carries 1.62 + * platform specific information about the event. Platform specific code 1.63 + * knows how to deal with it. 1.64 + * 1.65 + * The return value determines whether or not the default action should take 1.66 + * place. 1.67 + */ 1.68 +typedef nsEventStatus (* EVENT_CALLBACK)(mozilla::WidgetGUIEvent* aEvent); 1.69 + 1.70 +// Hide the native window system's real window type so as to avoid 1.71 +// including native window system types and APIs. This is necessary 1.72 +// to ensure cross-platform code. 1.73 +typedef void* nsNativeWidget; 1.74 + 1.75 +/** 1.76 + * Flags for the getNativeData function. 1.77 + * See getNativeData() 1.78 + */ 1.79 +#define NS_NATIVE_WINDOW 0 1.80 +#define NS_NATIVE_GRAPHIC 1 1.81 +#define NS_NATIVE_TMP_WINDOW 2 1.82 +#define NS_NATIVE_WIDGET 3 1.83 +#define NS_NATIVE_DISPLAY 4 1.84 +#define NS_NATIVE_REGION 5 1.85 +#define NS_NATIVE_OFFSETX 6 1.86 +#define NS_NATIVE_OFFSETY 7 1.87 +#define NS_NATIVE_PLUGIN_PORT 8 1.88 +#define NS_NATIVE_SCREEN 9 1.89 +// The toplevel GtkWidget containing this nsIWidget: 1.90 +#define NS_NATIVE_SHELLWIDGET 10 1.91 +// Has to match to NPNVnetscapeWindow, and shareable across processes 1.92 +// HWND on Windows and XID on X11 1.93 +#define NS_NATIVE_SHAREABLE_WINDOW 11 1.94 +#ifdef XP_MACOSX 1.95 +#define NS_NATIVE_PLUGIN_PORT_QD 100 1.96 +#define NS_NATIVE_PLUGIN_PORT_CG 101 1.97 +#endif 1.98 +#ifdef XP_WIN 1.99 +#define NS_NATIVE_TSF_THREAD_MGR 100 1.100 +#define NS_NATIVE_TSF_CATEGORY_MGR 101 1.101 +#define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102 1.102 +#define NS_NATIVE_ICOREWINDOW 103 // winrt specific 1.103 +#endif 1.104 + 1.105 +#define NS_IWIDGET_IID \ 1.106 +{ 0x87d80888, 0x9917, 0x4bfb, \ 1.107 + { 0x81, 0xa9, 0x1c, 0x5e, 0x30, 0x9c, 0x78, 0xb4 } } 1.108 + 1.109 +/* 1.110 + * Window shadow styles 1.111 + * Also used for the -moz-window-shadow CSS property 1.112 + */ 1.113 + 1.114 +#define NS_STYLE_WINDOW_SHADOW_NONE 0 1.115 +#define NS_STYLE_WINDOW_SHADOW_DEFAULT 1 1.116 +#define NS_STYLE_WINDOW_SHADOW_MENU 2 1.117 +#define NS_STYLE_WINDOW_SHADOW_TOOLTIP 3 1.118 +#define NS_STYLE_WINDOW_SHADOW_SHEET 4 1.119 + 1.120 +/** 1.121 + * Transparency modes 1.122 + */ 1.123 + 1.124 +enum nsTransparencyMode { 1.125 + eTransparencyOpaque = 0, // Fully opaque 1.126 + eTransparencyTransparent, // Parts of the window may be transparent 1.127 + eTransparencyGlass, // Transparent parts of the window have Vista AeroGlass effect applied 1.128 + eTransparencyBorderlessGlass // As above, but without a border around the opaque areas when there would otherwise be one with eTransparencyGlass 1.129 +}; 1.130 + 1.131 +/** 1.132 + * Cursor types. 1.133 + */ 1.134 + 1.135 +enum nsCursor { ///(normal cursor, usually rendered as an arrow) 1.136 + eCursor_standard, 1.137 + ///(system is busy, usually rendered as a hourglass or watch) 1.138 + eCursor_wait, 1.139 + ///(Selecting something, usually rendered as an IBeam) 1.140 + eCursor_select, 1.141 + ///(can hyper-link, usually rendered as a human hand) 1.142 + eCursor_hyperlink, 1.143 + ///(north/south/west/east edge sizing) 1.144 + eCursor_n_resize, 1.145 + eCursor_s_resize, 1.146 + eCursor_w_resize, 1.147 + eCursor_e_resize, 1.148 + ///(corner sizing) 1.149 + eCursor_nw_resize, 1.150 + eCursor_se_resize, 1.151 + eCursor_ne_resize, 1.152 + eCursor_sw_resize, 1.153 + eCursor_crosshair, 1.154 + eCursor_move, 1.155 + eCursor_help, 1.156 + eCursor_copy, // CSS3 1.157 + eCursor_alias, 1.158 + eCursor_context_menu, 1.159 + eCursor_cell, 1.160 + eCursor_grab, 1.161 + eCursor_grabbing, 1.162 + eCursor_spinning, 1.163 + eCursor_zoom_in, 1.164 + eCursor_zoom_out, 1.165 + eCursor_not_allowed, 1.166 + eCursor_col_resize, 1.167 + eCursor_row_resize, 1.168 + eCursor_no_drop, 1.169 + eCursor_vertical_text, 1.170 + eCursor_all_scroll, 1.171 + eCursor_nesw_resize, 1.172 + eCursor_nwse_resize, 1.173 + eCursor_ns_resize, 1.174 + eCursor_ew_resize, 1.175 + eCursor_none, 1.176 + // This one better be the last one in this list. 1.177 + eCursorCount 1.178 + }; 1.179 + 1.180 +enum nsTopLevelWidgetZPlacement { // for PlaceBehind() 1.181 + eZPlacementBottom = 0, // bottom of the window stack 1.182 + eZPlacementBelow, // just below another widget 1.183 + eZPlacementTop // top of the window stack 1.184 +}; 1.185 + 1.186 +/** 1.187 + * Before the OS goes to sleep, this topic is notified. 1.188 + */ 1.189 +#define NS_WIDGET_SLEEP_OBSERVER_TOPIC "sleep_notification" 1.190 + 1.191 +/** 1.192 + * After the OS wakes up, this topic is notified. 1.193 + */ 1.194 +#define NS_WIDGET_WAKE_OBSERVER_TOPIC "wake_notification" 1.195 + 1.196 +/** 1.197 + * Before the OS suspends the current process, this topic is notified. Some 1.198 + * OS will kill processes that are suspended instead of resuming them. 1.199 + * For that reason this topic may be useful to safely close down resources. 1.200 + */ 1.201 +#define NS_WIDGET_SUSPEND_PROCESS_OBSERVER_TOPIC "suspend_process_notification" 1.202 + 1.203 +/** 1.204 + * After the current process resumes from being suspended, this topic is 1.205 + * notified. 1.206 + */ 1.207 +#define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification" 1.208 + 1.209 +/** 1.210 + * Preference for receiving IME updates 1.211 + * 1.212 + * If mWantUpdates is not NOTIFY_NOTHING, nsTextStateManager will observe text 1.213 + * change and/or selection change and call nsIWidget::NotifyIME() with 1.214 + * NOTIFY_IME_OF_SELECTION_CHANGE and/or NOTIFY_IME_OF_TEXT_CHANGE. 1.215 + * Please note that the text change observing cost is very expensive especially 1.216 + * on an HTML editor has focus. 1.217 + * If the IME implementation on a particular platform doesn't care about 1.218 + * NOTIFY_IME_OF_SELECTION_CHANGE and/or NOTIFY_IME_OF_TEXT_CHANGE, 1.219 + * they should set mWantUpdates to NOTIFY_NOTHING to avoid the cost. 1.220 + * If the IME implementation needs notifications even while our process is 1.221 + * deactive, it should also set NOTIFY_DURING_DEACTIVE. 1.222 + */ 1.223 +struct nsIMEUpdatePreference { 1.224 + 1.225 + typedef uint8_t Notifications; 1.226 + 1.227 + enum MOZ_ENUM_TYPE(Notifications) 1.228 + { 1.229 + NOTIFY_NOTHING = 0, 1.230 + NOTIFY_SELECTION_CHANGE = 1 << 0, 1.231 + NOTIFY_TEXT_CHANGE = 1 << 1, 1.232 + NOTIFY_POSITION_CHANGE = 1 << 2, 1.233 + // Following values indicate when widget needs or doesn't need notification. 1.234 + NOTIFY_CHANGES_CAUSED_BY_COMPOSITION = 1 << 6, 1.235 + // NOTE: NOTIFY_DURING_DEACTIVE isn't supported in environments where two 1.236 + // or more compositions are possible. E.g., Mac and Linux (GTK). 1.237 + NOTIFY_DURING_DEACTIVE = 1 << 7, 1.238 + // Changes are notified in following conditions if the instance is 1.239 + // just constructed. If some platforms don't need change notifications 1.240 + // in some of following conditions, the platform should remove following 1.241 + // flags before returing the instance from nsIWidget::GetUpdatePreference(). 1.242 + DEFAULT_CONDITIONS_OF_NOTIFYING_CHANGES = 1.243 + NOTIFY_CHANGES_CAUSED_BY_COMPOSITION 1.244 + }; 1.245 + 1.246 + nsIMEUpdatePreference() 1.247 + : mWantUpdates(DEFAULT_CONDITIONS_OF_NOTIFYING_CHANGES) 1.248 + { 1.249 + } 1.250 + 1.251 + nsIMEUpdatePreference(Notifications aWantUpdates) 1.252 + : mWantUpdates(aWantUpdates | DEFAULT_CONDITIONS_OF_NOTIFYING_CHANGES) 1.253 + { 1.254 + } 1.255 + 1.256 + void DontNotifyChangesCausedByComposition() 1.257 + { 1.258 + mWantUpdates &= ~DEFAULT_CONDITIONS_OF_NOTIFYING_CHANGES; 1.259 + } 1.260 + 1.261 + bool WantSelectionChange() const 1.262 + { 1.263 + return !!(mWantUpdates & NOTIFY_SELECTION_CHANGE); 1.264 + } 1.265 + 1.266 + bool WantTextChange() const 1.267 + { 1.268 + return !!(mWantUpdates & NOTIFY_TEXT_CHANGE); 1.269 + } 1.270 + 1.271 + bool WantPositionChanged() const 1.272 + { 1.273 + return !!(mWantUpdates & NOTIFY_POSITION_CHANGE); 1.274 + } 1.275 + 1.276 + bool WantChanges() const 1.277 + { 1.278 + return WantSelectionChange() || WantTextChange(); 1.279 + } 1.280 + 1.281 + bool WantChangesCausedByComposition() const 1.282 + { 1.283 + return WantChanges() && 1.284 + !!(mWantUpdates & NOTIFY_CHANGES_CAUSED_BY_COMPOSITION); 1.285 + } 1.286 + 1.287 + bool WantDuringDeactive() const 1.288 + { 1.289 + return !!(mWantUpdates & NOTIFY_DURING_DEACTIVE); 1.290 + } 1.291 + 1.292 + Notifications mWantUpdates; 1.293 +}; 1.294 + 1.295 + 1.296 +/* 1.297 + * Contains IMEStatus plus information about the current 1.298 + * input context that the IME can use as hints if desired. 1.299 + */ 1.300 + 1.301 +namespace mozilla { 1.302 +namespace widget { 1.303 + 1.304 +struct IMEState { 1.305 + /** 1.306 + * IME enabled states, the mEnabled value of 1.307 + * SetInputContext()/GetInputContext() should be one value of following 1.308 + * values. 1.309 + * 1.310 + * WARNING: If you change these values, you also need to edit: 1.311 + * nsIDOMWindowUtils.idl 1.312 + * nsContentUtils::GetWidgetStatusFromIMEStatus 1.313 + */ 1.314 + enum Enabled { 1.315 + /** 1.316 + * 'Disabled' means the user cannot use IME. So, the IME open state should 1.317 + * be 'closed' during 'disabled'. 1.318 + */ 1.319 + DISABLED, 1.320 + /** 1.321 + * 'Enabled' means the user can use IME. 1.322 + */ 1.323 + ENABLED, 1.324 + /** 1.325 + * 'Password' state is a special case for the password editors. 1.326 + * E.g., on mac, the password editors should disable the non-Roman 1.327 + * keyboard layouts at getting focus. Thus, the password editor may have 1.328 + * special rules on some platforms. 1.329 + */ 1.330 + PASSWORD, 1.331 + /** 1.332 + * This state is used when a plugin is focused. 1.333 + * When a plug-in is focused content, we should send native events 1.334 + * directly. Because we don't process some native events, but they may 1.335 + * be needed by the plug-in. 1.336 + */ 1.337 + PLUGIN 1.338 + }; 1.339 + Enabled mEnabled; 1.340 + 1.341 + /** 1.342 + * IME open states the mOpen value of SetInputContext() should be one value of 1.343 + * OPEN, CLOSE or DONT_CHANGE_OPEN_STATE. GetInputContext() should return 1.344 + * OPEN, CLOSE or OPEN_STATE_NOT_SUPPORTED. 1.345 + */ 1.346 + enum Open { 1.347 + /** 1.348 + * 'Unsupported' means the platform cannot return actual IME open state. 1.349 + * This value is used only by GetInputContext(). 1.350 + */ 1.351 + OPEN_STATE_NOT_SUPPORTED, 1.352 + /** 1.353 + * 'Don't change' means the widget shouldn't change IME open state when 1.354 + * SetInputContext() is called. 1.355 + */ 1.356 + DONT_CHANGE_OPEN_STATE = OPEN_STATE_NOT_SUPPORTED, 1.357 + /** 1.358 + * 'Open' means that IME should compose in its primary language (or latest 1.359 + * input mode except direct ASCII character input mode). Even if IME is 1.360 + * opened by this value, users should be able to close IME by theirselves. 1.361 + * Web contents can specify this value by |ime-mode: active;|. 1.362 + */ 1.363 + OPEN, 1.364 + /** 1.365 + * 'Closed' means that IME shouldn't handle key events (or should handle 1.366 + * as ASCII character inputs on mobile device). Even if IME is closed by 1.367 + * this value, users should be able to open IME by theirselves. 1.368 + * Web contents can specify this value by |ime-mode: inactive;|. 1.369 + */ 1.370 + CLOSED 1.371 + }; 1.372 + Open mOpen; 1.373 + 1.374 + IMEState() : mEnabled(ENABLED), mOpen(DONT_CHANGE_OPEN_STATE) { } 1.375 + 1.376 + IMEState(Enabled aEnabled, Open aOpen = DONT_CHANGE_OPEN_STATE) : 1.377 + mEnabled(aEnabled), mOpen(aOpen) 1.378 + { 1.379 + } 1.380 +}; 1.381 + 1.382 +struct InputContext { 1.383 + InputContext() : mNativeIMEContext(nullptr) {} 1.384 + 1.385 + bool IsPasswordEditor() const 1.386 + { 1.387 + return mHTMLInputType.LowerCaseEqualsLiteral("password"); 1.388 + } 1.389 + 1.390 + IMEState mIMEState; 1.391 + 1.392 + /* The type of the input if the input is a html input field */ 1.393 + nsString mHTMLInputType; 1.394 + 1.395 + /* The type of the inputmode */ 1.396 + nsString mHTMLInputInputmode; 1.397 + 1.398 + /* A hint for the action that is performed when the input is submitted */ 1.399 + nsString mActionHint; 1.400 + 1.401 + /* Native IME context for the widget. This doesn't come from the argument of 1.402 + SetInputContext(). If there is only one context in the process, this may 1.403 + be nullptr. */ 1.404 + void* mNativeIMEContext; 1.405 +}; 1.406 + 1.407 +struct InputContextAction { 1.408 + /** 1.409 + * mCause indicates what action causes calling nsIWidget::SetInputContext(). 1.410 + * It must be one of following values. 1.411 + */ 1.412 + enum Cause { 1.413 + // The cause is unknown but originated from content. Focus might have been 1.414 + // changed by content script. 1.415 + CAUSE_UNKNOWN, 1.416 + // The cause is unknown but originated from chrome. Focus might have been 1.417 + // changed by chrome script. 1.418 + CAUSE_UNKNOWN_CHROME, 1.419 + // The cause is user's keyboard operation. 1.420 + CAUSE_KEY, 1.421 + // The cause is user's mouse operation. 1.422 + CAUSE_MOUSE 1.423 + }; 1.424 + Cause mCause; 1.425 + 1.426 + /** 1.427 + * mFocusChange indicates what happened for focus. 1.428 + */ 1.429 + enum FocusChange { 1.430 + FOCUS_NOT_CHANGED, 1.431 + // A content got focus. 1.432 + GOT_FOCUS, 1.433 + // Focused content lost focus. 1.434 + LOST_FOCUS, 1.435 + // Menu got pseudo focus that means focused content isn't changed but 1.436 + // keyboard events will be handled by menu. 1.437 + MENU_GOT_PSEUDO_FOCUS, 1.438 + // Menu lost pseudo focus that means focused content will handle keyboard 1.439 + // events. 1.440 + MENU_LOST_PSEUDO_FOCUS 1.441 + }; 1.442 + FocusChange mFocusChange; 1.443 + 1.444 + bool ContentGotFocusByTrustedCause() const { 1.445 + return (mFocusChange == GOT_FOCUS && 1.446 + mCause != CAUSE_UNKNOWN); 1.447 + } 1.448 + 1.449 + bool UserMightRequestOpenVKB() const { 1.450 + return (mFocusChange == FOCUS_NOT_CHANGED && 1.451 + mCause == CAUSE_MOUSE); 1.452 + } 1.453 + 1.454 + InputContextAction() : 1.455 + mCause(CAUSE_UNKNOWN), mFocusChange(FOCUS_NOT_CHANGED) 1.456 + { 1.457 + } 1.458 + 1.459 + InputContextAction(Cause aCause, 1.460 + FocusChange aFocusChange = FOCUS_NOT_CHANGED) : 1.461 + mCause(aCause), mFocusChange(aFocusChange) 1.462 + { 1.463 + } 1.464 +}; 1.465 + 1.466 +/** 1.467 + * Size constraints for setting the minimum and maximum size of a widget. 1.468 + * Values are in device pixels. 1.469 + */ 1.470 +struct SizeConstraints { 1.471 + SizeConstraints() 1.472 + : mMaxSize(NS_MAXSIZE, NS_MAXSIZE) 1.473 + { 1.474 + } 1.475 + 1.476 + SizeConstraints(nsIntSize aMinSize, 1.477 + nsIntSize aMaxSize) 1.478 + : mMinSize(aMinSize), 1.479 + mMaxSize(aMaxSize) 1.480 + { 1.481 + } 1.482 + 1.483 + nsIntSize mMinSize; 1.484 + nsIntSize mMaxSize; 1.485 +}; 1.486 + 1.487 +// IMEMessage is shared by IMEStateManager and TextComposition. 1.488 +// Update values in GeckoEditable.java if you make changes here. 1.489 +// XXX Negative values are used in Android... 1.490 +enum IMEMessage MOZ_ENUM_TYPE(int8_t) 1.491 +{ 1.492 + // XXX We should replace NOTIFY_IME_OF_CURSOR_POS_CHANGED with 1.493 + // NOTIFY_IME_OF_SELECTION_CHANGE later. 1.494 + NOTIFY_IME_OF_CURSOR_POS_CHANGED, 1.495 + // An editable content is getting focus 1.496 + NOTIFY_IME_OF_FOCUS, 1.497 + // An editable content is losing focus 1.498 + NOTIFY_IME_OF_BLUR, 1.499 + // Selection in the focused editable content is changed 1.500 + NOTIFY_IME_OF_SELECTION_CHANGE, 1.501 + // Text in the focused editable content is changed 1.502 + NOTIFY_IME_OF_TEXT_CHANGE, 1.503 + // Composition string has been updated 1.504 + NOTIFY_IME_OF_COMPOSITION_UPDATE, 1.505 + // Position or size of focused element may be changed. 1.506 + NOTIFY_IME_OF_POSITION_CHANGE, 1.507 + // Request to commit current composition to IME 1.508 + // (some platforms may not support) 1.509 + REQUEST_TO_COMMIT_COMPOSITION, 1.510 + // Request to cancel current composition to IME 1.511 + // (some platforms may not support) 1.512 + REQUEST_TO_CANCEL_COMPOSITION 1.513 +}; 1.514 + 1.515 +struct IMENotification 1.516 +{ 1.517 + IMENotification(IMEMessage aMessage) 1.518 + : mMessage(aMessage) 1.519 + { 1.520 + switch (aMessage) { 1.521 + case NOTIFY_IME_OF_SELECTION_CHANGE: 1.522 + mSelectionChangeData.mCausedByComposition = false; 1.523 + break; 1.524 + case NOTIFY_IME_OF_TEXT_CHANGE: 1.525 + mTextChangeData.mStartOffset = 0; 1.526 + mTextChangeData.mOldEndOffset = 0; 1.527 + mTextChangeData.mNewEndOffset = 0; 1.528 + mTextChangeData.mCausedByComposition = false; 1.529 + break; 1.530 + default: 1.531 + break; 1.532 + } 1.533 + } 1.534 + 1.535 + IMEMessage mMessage; 1.536 + 1.537 + union 1.538 + { 1.539 + // NOTIFY_IME_OF_SELECTION_CHANGE specific data 1.540 + struct 1.541 + { 1.542 + bool mCausedByComposition; 1.543 + } mSelectionChangeData; 1.544 + 1.545 + // NOTIFY_IME_OF_TEXT_CHANGE specific data 1.546 + struct 1.547 + { 1.548 + uint32_t mStartOffset; 1.549 + uint32_t mOldEndOffset; 1.550 + uint32_t mNewEndOffset; 1.551 + 1.552 + bool mCausedByComposition; 1.553 + 1.554 + uint32_t OldLength() const { return mOldEndOffset - mStartOffset; } 1.555 + uint32_t NewLength() const { return mNewEndOffset - mStartOffset; } 1.556 + int32_t AdditionalLength() const 1.557 + { 1.558 + return static_cast<int32_t>(mNewEndOffset - mOldEndOffset); 1.559 + } 1.560 + bool IsInInt32Range() const 1.561 + { 1.562 + return mStartOffset <= INT32_MAX && 1.563 + mOldEndOffset <= INT32_MAX && 1.564 + mNewEndOffset <= INT32_MAX; 1.565 + } 1.566 + } mTextChangeData; 1.567 + }; 1.568 + 1.569 + bool IsCausedByComposition() const 1.570 + { 1.571 + switch (mMessage) { 1.572 + case NOTIFY_IME_OF_SELECTION_CHANGE: 1.573 + return mSelectionChangeData.mCausedByComposition; 1.574 + case NOTIFY_IME_OF_TEXT_CHANGE: 1.575 + return mTextChangeData.mCausedByComposition; 1.576 + default: 1.577 + return false; 1.578 + } 1.579 + } 1.580 + 1.581 +private: 1.582 + IMENotification(); 1.583 +}; 1.584 + 1.585 +} // namespace widget 1.586 +} // namespace mozilla 1.587 + 1.588 +/** 1.589 + * The base class for all the widgets. It provides the interface for 1.590 + * all basic and necessary functionality. 1.591 + */ 1.592 +class nsIWidget : public nsISupports { 1.593 + protected: 1.594 + typedef mozilla::dom::TabChild TabChild; 1.595 + 1.596 + public: 1.597 + typedef mozilla::layers::Composer2D Composer2D; 1.598 + typedef mozilla::layers::CompositorChild CompositorChild; 1.599 + typedef mozilla::layers::LayerManager LayerManager; 1.600 + typedef mozilla::layers::LayerManagerComposite LayerManagerComposite; 1.601 + typedef mozilla::layers::LayersBackend LayersBackend; 1.602 + typedef mozilla::layers::PLayerTransactionChild PLayerTransactionChild; 1.603 + typedef mozilla::widget::IMEMessage IMEMessage; 1.604 + typedef mozilla::widget::IMENotification IMENotification; 1.605 + typedef mozilla::widget::IMEState IMEState; 1.606 + typedef mozilla::widget::InputContext InputContext; 1.607 + typedef mozilla::widget::InputContextAction InputContextAction; 1.608 + typedef mozilla::widget::SizeConstraints SizeConstraints; 1.609 + 1.610 + // Used in UpdateThemeGeometries. 1.611 + struct ThemeGeometry { 1.612 + // The -moz-appearance value for the themed widget 1.613 + uint8_t mWidgetType; 1.614 + // The device-pixel rect within the window for the themed widget 1.615 + nsIntRect mRect; 1.616 + 1.617 + ThemeGeometry(uint8_t aWidgetType, const nsIntRect& aRect) 1.618 + : mWidgetType(aWidgetType) 1.619 + , mRect(aRect) 1.620 + { } 1.621 + }; 1.622 + 1.623 + NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWIDGET_IID) 1.624 + 1.625 + nsIWidget() 1.626 + : mLastChild(nullptr) 1.627 + , mPrevSibling(nullptr) 1.628 + , mOnDestroyCalled(false) 1.629 + , mWindowType(eWindowType_child) 1.630 + , mZIndex(0) 1.631 + 1.632 + { 1.633 + ClearNativeTouchSequence(); 1.634 + } 1.635 + 1.636 + 1.637 + /** 1.638 + * Create and initialize a widget. 1.639 + * 1.640 + * All the arguments can be null in which case a top level window 1.641 + * with size 0 is created. The event callback function has to be 1.642 + * provided only if the caller wants to deal with the events this 1.643 + * widget receives. The event callback is basically a preprocess 1.644 + * hook called synchronously. The return value determines whether 1.645 + * the event goes to the default window procedure or it is hidden 1.646 + * to the os. The assumption is that if the event handler returns 1.647 + * false the widget does not see the event. The widget should not 1.648 + * automatically clear the window to the background color. The 1.649 + * calling code must handle paint messages and clear the background 1.650 + * itself. 1.651 + * 1.652 + * In practice at least one of aParent and aNativeParent will be null. If 1.653 + * both are null the widget isn't parented (e.g. context menus or 1.654 + * independent top level windows). 1.655 + * 1.656 + * The dimensions given in aRect are specified in the parent's 1.657 + * coordinate system, or for parentless widgets such as top-level 1.658 + * windows, in global CSS pixels. 1.659 + * 1.660 + * @param aParent parent nsIWidget 1.661 + * @param aNativeParent native parent widget 1.662 + * @param aRect the widget dimension 1.663 + * @param aContext 1.664 + * @param aInitData data that is used for widget initialization 1.665 + * 1.666 + */ 1.667 + NS_IMETHOD Create(nsIWidget *aParent, 1.668 + nsNativeWidget aNativeParent, 1.669 + const nsIntRect &aRect, 1.670 + nsDeviceContext *aContext, 1.671 + nsWidgetInitData *aInitData = nullptr) = 0; 1.672 + 1.673 + /** 1.674 + * Allocate, initialize, and return a widget that is a child of 1.675 + * |this|. The returned widget (if nonnull) has gone through the 1.676 + * equivalent of CreateInstance(widgetCID) + Create(...). 1.677 + * 1.678 + * |CreateChild()| lets widget backends decide whether to parent 1.679 + * the new child widget to this, nonnatively parent it, or both. 1.680 + * This interface exists to support the PuppetWidget backend, 1.681 + * which is entirely non-native. All other params are the same as 1.682 + * for |Create()|. 1.683 + * 1.684 + * |aForceUseIWidgetParent| forces |CreateChild()| to only use the 1.685 + * |nsIWidget*| this, not its native widget (if it exists), when 1.686 + * calling |Create()|. This is a timid hack around poorly 1.687 + * understood code, and shouldn't be used in new code. 1.688 + */ 1.689 + virtual already_AddRefed<nsIWidget> 1.690 + CreateChild(const nsIntRect &aRect, 1.691 + nsDeviceContext *aContext, 1.692 + nsWidgetInitData *aInitData = nullptr, 1.693 + bool aForceUseIWidgetParent = false) = 0; 1.694 + 1.695 + /** 1.696 + * Attach to a top level widget. 1.697 + * 1.698 + * In cases where a top level chrome widget is being used as a content 1.699 + * container, attach a secondary listener and update the device 1.700 + * context. The primary widget listener will continue to be called for 1.701 + * notifications relating to the top-level window, whereas other 1.702 + * notifications such as painting and events will instead be called via 1.703 + * the attached listener. SetAttachedWidgetListener should be used to 1.704 + * assign the attached listener. 1.705 + * 1.706 + * aUseAttachedEvents if true, events are sent to the attached listener 1.707 + * instead of the normal listener. 1.708 + * aContext The new device context for the view 1.709 + */ 1.710 + NS_IMETHOD AttachViewToTopLevel(bool aUseAttachedEvents, 1.711 + nsDeviceContext *aContext) = 0; 1.712 + 1.713 + /** 1.714 + * Accessor functions to get and set the attached listener. Used by 1.715 + * nsView in connection with AttachViewToTopLevel above. 1.716 + */ 1.717 + virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) = 0; 1.718 + virtual nsIWidgetListener* GetAttachedWidgetListener() = 0; 1.719 + 1.720 + /** 1.721 + * Accessor functions to get and set the listener which handles various 1.722 + * actions for the widget. 1.723 + */ 1.724 + //@{ 1.725 + virtual nsIWidgetListener* GetWidgetListener() = 0; 1.726 + virtual void SetWidgetListener(nsIWidgetListener* alistener) = 0; 1.727 + //@} 1.728 + 1.729 + /** 1.730 + * Close and destroy the internal native window. 1.731 + * This method does not delete the widget. 1.732 + */ 1.733 + 1.734 + NS_IMETHOD Destroy(void) = 0; 1.735 + 1.736 + /** 1.737 + * Destroyed() returns true if Destroy() has been called already. 1.738 + * Otherwise, false. 1.739 + */ 1.740 + bool Destroyed() const { return mOnDestroyCalled; } 1.741 + 1.742 + 1.743 + /** 1.744 + * Reparent a widget 1.745 + * 1.746 + * Change the widget's parent. Null parents are allowed. 1.747 + * 1.748 + * @param aNewParent new parent 1.749 + */ 1.750 + NS_IMETHOD SetParent(nsIWidget* aNewParent) = 0; 1.751 + 1.752 + NS_IMETHOD RegisterTouchWindow() = 0; 1.753 + NS_IMETHOD UnregisterTouchWindow() = 0; 1.754 + 1.755 + /** 1.756 + * Return the parent Widget of this Widget or nullptr if this is a 1.757 + * top level window 1.758 + * 1.759 + * @return the parent widget or nullptr if it does not have a parent 1.760 + * 1.761 + */ 1.762 + virtual nsIWidget* GetParent(void) = 0; 1.763 + 1.764 + /** 1.765 + * Return the top level Widget of this Widget 1.766 + * 1.767 + * @return the top level widget 1.768 + */ 1.769 + virtual nsIWidget* GetTopLevelWidget() = 0; 1.770 + 1.771 + /** 1.772 + * Return the top (non-sheet) parent of this Widget if it's a sheet, 1.773 + * or nullptr if this isn't a sheet (or some other error occurred). 1.774 + * Sheets are only supported on some platforms (currently only OS X). 1.775 + * 1.776 + * @return the top (non-sheet) parent widget or nullptr 1.777 + * 1.778 + */ 1.779 + virtual nsIWidget* GetSheetWindowParent(void) = 0; 1.780 + 1.781 + /** 1.782 + * Return the physical DPI of the screen containing the window ... 1.783 + * the number of device pixels per inch. 1.784 + */ 1.785 + virtual float GetDPI() = 0; 1.786 + 1.787 + /** 1.788 + * Return the default scale factor for the window. This is the 1.789 + * default number of device pixels per CSS pixel to use. This should 1.790 + * depend on OS/platform settings such as the Mac's "UI scale factor" 1.791 + * or Windows' "font DPI". This will take into account Gecko preferences 1.792 + * overriding the system setting. 1.793 + */ 1.794 + mozilla::CSSToLayoutDeviceScale GetDefaultScale(); 1.795 + 1.796 + /** 1.797 + * Return the Gecko override of the system default scale, if any; 1.798 + * returns <= 0.0 if the system scale should be used as-is. 1.799 + * nsIWidget::GetDefaultScale() [above] takes this into account. 1.800 + * It is exposed here so that code that wants to check for a 1.801 + * default-scale override without having a widget on hand can 1.802 + * easily access the same value. 1.803 + * Note that any scale override is a browser-wide value, whereas 1.804 + * the default GetDefaultScale value (when no override is present) 1.805 + * may vary between widgets (or screens). 1.806 + */ 1.807 + static double DefaultScaleOverride(); 1.808 + 1.809 + /** 1.810 + * Return the first child of this widget. Will return null if 1.811 + * there are no children. 1.812 + */ 1.813 + nsIWidget* GetFirstChild() const { 1.814 + return mFirstChild; 1.815 + } 1.816 + 1.817 + /** 1.818 + * Return the last child of this widget. Will return null if 1.819 + * there are no children. 1.820 + */ 1.821 + nsIWidget* GetLastChild() const { 1.822 + return mLastChild; 1.823 + } 1.824 + 1.825 + /** 1.826 + * Return the next sibling of this widget 1.827 + */ 1.828 + nsIWidget* GetNextSibling() const { 1.829 + return mNextSibling; 1.830 + } 1.831 + 1.832 + /** 1.833 + * Set the next sibling of this widget 1.834 + */ 1.835 + void SetNextSibling(nsIWidget* aSibling) { 1.836 + mNextSibling = aSibling; 1.837 + } 1.838 + 1.839 + /** 1.840 + * Return the previous sibling of this widget 1.841 + */ 1.842 + nsIWidget* GetPrevSibling() const { 1.843 + return mPrevSibling; 1.844 + } 1.845 + 1.846 + /** 1.847 + * Set the previous sibling of this widget 1.848 + */ 1.849 + void SetPrevSibling(nsIWidget* aSibling) { 1.850 + mPrevSibling = aSibling; 1.851 + } 1.852 + 1.853 + /** 1.854 + * Show or hide this widget 1.855 + * 1.856 + * @param aState true to show the Widget, false to hide it 1.857 + * 1.858 + */ 1.859 + NS_IMETHOD Show(bool aState) = 0; 1.860 + 1.861 + /** 1.862 + * Make the window modal 1.863 + * 1.864 + */ 1.865 + NS_IMETHOD SetModal(bool aModal) = 0; 1.866 + 1.867 + /** 1.868 + * The maximum number of simultaneous touch contacts supported by the device. 1.869 + * In the case of devices with multiple digitizers (e.g. multiple touch screens), 1.870 + * the value will be the maximum of the set of maximum supported contacts by 1.871 + * each individual digitizer. 1.872 + */ 1.873 + virtual uint32_t GetMaxTouchPoints() const = 0; 1.874 + 1.875 + /** 1.876 + * Returns whether the window is visible 1.877 + * 1.878 + */ 1.879 + virtual bool IsVisible() const = 0; 1.880 + 1.881 + /** 1.882 + * Perform platform-dependent sanity check on a potential window position. 1.883 + * This is guaranteed to work only for top-level windows. 1.884 + * 1.885 + * @param aAllowSlop: if true, allow the window to slop offscreen; 1.886 + * the window should be partially visible. if false, 1.887 + * force the entire window onscreen (or at least 1.888 + * the upper-left corner, if it's too large). 1.889 + * @param aX in: an x position expressed in screen coordinates. 1.890 + * out: the x position constrained to fit on the screen(s). 1.891 + * @param aY in: an y position expressed in screen coordinates. 1.892 + * out: the y position constrained to fit on the screen(s). 1.893 + * @return vapid success indication. but see also the parameters. 1.894 + * 1.895 + **/ 1.896 + NS_IMETHOD ConstrainPosition(bool aAllowSlop, 1.897 + int32_t *aX, 1.898 + int32_t *aY) = 0; 1.899 + 1.900 + /** 1.901 + * NOTE: 1.902 + * 1.903 + * For a top-level window widget, the "parent's coordinate system" is the 1.904 + * "global" display pixel coordinate space, *not* device pixels (which 1.905 + * may be inconsistent between multiple screens, at least in the Mac OS 1.906 + * case with mixed hi-dpi and lo-dpi displays). This applies to all the 1.907 + * following Move and Resize widget APIs. 1.908 + * 1.909 + * The display-/device-pixel distinction becomes important for (at least) 1.910 + * Mac OS X with Hi-DPI (retina) displays, and Windows when the UI scale 1.911 + * factor is set to other than 100%. 1.912 + * 1.913 + * The Move and Resize methods take floating-point parameters, rather than 1.914 + * integer ones. This is important when manipulating top-level widgets, 1.915 + * where the coordinate system may not be an integral multiple of the 1.916 + * device-pixel space. 1.917 + **/ 1.918 + 1.919 + /** 1.920 + * Move this widget. 1.921 + * 1.922 + * Coordinates refer to the top-left of the widget. For toplevel windows 1.923 + * with decorations, this is the top-left of the titlebar and frame . 1.924 + * 1.925 + * @param aX the new x position expressed in the parent's coordinate system 1.926 + * @param aY the new y position expressed in the parent's coordinate system 1.927 + * 1.928 + **/ 1.929 + NS_IMETHOD Move(double aX, double aY) = 0; 1.930 + 1.931 + /** 1.932 + * Reposition this widget so that the client area has the given offset. 1.933 + * 1.934 + * @param aX the new x offset of the client area expressed as an 1.935 + * offset from the origin of the client area of the parent 1.936 + * widget (for root widgets and popup widgets it is in 1.937 + * screen coordinates) 1.938 + * @param aY the new y offset of the client area expressed as an 1.939 + * offset from the origin of the client area of the parent 1.940 + * widget (for root widgets and popup widgets it is in 1.941 + * screen coordinates) 1.942 + * 1.943 + **/ 1.944 + NS_IMETHOD MoveClient(double aX, double aY) = 0; 1.945 + 1.946 + /** 1.947 + * Resize this widget. Any size constraints set for the window by a 1.948 + * previous call to SetSizeConstraints will be applied. 1.949 + * 1.950 + * @param aWidth the new width expressed in the parent's coordinate system 1.951 + * @param aHeight the new height expressed in the parent's coordinate system 1.952 + * @param aRepaint whether the widget should be repainted 1.953 + * 1.954 + */ 1.955 + NS_IMETHOD Resize(double aWidth, 1.956 + double aHeight, 1.957 + bool aRepaint) = 0; 1.958 + 1.959 + /** 1.960 + * Move or resize this widget. Any size constraints set for the window by 1.961 + * a previous call to SetSizeConstraints will be applied. 1.962 + * 1.963 + * @param aX the new x position expressed in the parent's coordinate system 1.964 + * @param aY the new y position expressed in the parent's coordinate system 1.965 + * @param aWidth the new width expressed in the parent's coordinate system 1.966 + * @param aHeight the new height expressed in the parent's coordinate system 1.967 + * @param aRepaint whether the widget should be repainted if the size changes 1.968 + * 1.969 + */ 1.970 + NS_IMETHOD Resize(double aX, 1.971 + double aY, 1.972 + double aWidth, 1.973 + double aHeight, 1.974 + bool aRepaint) = 0; 1.975 + 1.976 + /** 1.977 + * Resize the widget so that the inner client area has the given size. 1.978 + * 1.979 + * @param aWidth the new width of the client area. 1.980 + * @param aHeight the new height of the client area. 1.981 + * @param aRepaint whether the widget should be repainted 1.982 + * 1.983 + */ 1.984 + NS_IMETHOD ResizeClient(double aWidth, 1.985 + double aHeight, 1.986 + bool aRepaint) = 0; 1.987 + 1.988 + /** 1.989 + * Resize and reposition the widget so tht inner client area has the given 1.990 + * offset and size. 1.991 + * 1.992 + * @param aX the new x offset of the client area expressed as an 1.993 + * offset from the origin of the client area of the parent 1.994 + * widget (for root widgets and popup widgets it is in 1.995 + * screen coordinates) 1.996 + * @param aY the new y offset of the client area expressed as an 1.997 + * offset from the origin of the client area of the parent 1.998 + * widget (for root widgets and popup widgets it is in 1.999 + * screen coordinates) 1.1000 + * @param aWidth the new width of the client area. 1.1001 + * @param aHeight the new height of the client area. 1.1002 + * @param aRepaint whether the widget should be repainted 1.1003 + * 1.1004 + */ 1.1005 + NS_IMETHOD ResizeClient(double aX, 1.1006 + double aY, 1.1007 + double aWidth, 1.1008 + double aHeight, 1.1009 + bool aRepaint) = 0; 1.1010 + 1.1011 + /** 1.1012 + * Sets the widget's z-index. 1.1013 + */ 1.1014 + virtual void SetZIndex(int32_t aZIndex) = 0; 1.1015 + 1.1016 + /** 1.1017 + * Gets the widget's z-index. 1.1018 + */ 1.1019 + int32_t GetZIndex() 1.1020 + { 1.1021 + return mZIndex; 1.1022 + } 1.1023 + 1.1024 + /** 1.1025 + * Position this widget just behind the given widget. (Used to 1.1026 + * control z-order for top-level widgets. Get/SetZIndex by contrast 1.1027 + * control z-order for child widgets of other widgets.) 1.1028 + * @param aPlacement top, bottom, or below a widget 1.1029 + * (if top or bottom, param aWidget is ignored) 1.1030 + * @param aWidget widget to place this widget behind 1.1031 + * (only if aPlacement is eZPlacementBelow). 1.1032 + * null is equivalent to aPlacement of eZPlacementTop 1.1033 + * @param aActivate true to activate the widget after placing it 1.1034 + */ 1.1035 + NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, 1.1036 + nsIWidget *aWidget, bool aActivate) = 0; 1.1037 + 1.1038 + /** 1.1039 + * Minimize, maximize or normalize the window size. 1.1040 + * Takes a value from nsSizeMode (see nsIWidgetListener.h) 1.1041 + */ 1.1042 + NS_IMETHOD SetSizeMode(int32_t aMode) = 0; 1.1043 + 1.1044 + /** 1.1045 + * Return size mode (minimized, maximized, normalized). 1.1046 + * Returns a value from nsSizeMode (see nsIWidgetListener.h) 1.1047 + */ 1.1048 + virtual int32_t SizeMode() = 0; 1.1049 + 1.1050 + /** 1.1051 + * Enable or disable this Widget 1.1052 + * 1.1053 + * @param aState true to enable the Widget, false to disable it. 1.1054 + * 1.1055 + */ 1.1056 + NS_IMETHOD Enable(bool aState) = 0; 1.1057 + 1.1058 + /** 1.1059 + * Ask whether the widget is enabled 1.1060 + */ 1.1061 + virtual bool IsEnabled() const = 0; 1.1062 + 1.1063 + /** 1.1064 + * Request activation of this window or give focus to this widget. 1.1065 + * 1.1066 + * @param aRaise If true, this function requests activation of this 1.1067 + * widget's toplevel window. 1.1068 + * If false, the appropriate toplevel window (which in 1.1069 + * the case of popups may not be this widget's toplevel 1.1070 + * window) is already active. 1.1071 + */ 1.1072 + NS_IMETHOD SetFocus(bool aRaise = false) = 0; 1.1073 + 1.1074 + /** 1.1075 + * Get this widget's outside dimensions relative to its parent widget. For 1.1076 + * popup widgets the returned rect is in screen coordinates and not 1.1077 + * relative to its parent widget. 1.1078 + * 1.1079 + * @param aRect On return it holds the x, y, width and height of 1.1080 + * this widget. 1.1081 + */ 1.1082 + NS_IMETHOD GetBounds(nsIntRect &aRect) = 0; 1.1083 + 1.1084 + /** 1.1085 + * Get this widget's outside dimensions in global coordinates. This 1.1086 + * includes any title bar on the window. 1.1087 + * 1.1088 + * @param aRect On return it holds the x, y, width and height of 1.1089 + * this widget. 1.1090 + */ 1.1091 + NS_IMETHOD GetScreenBounds(nsIntRect &aRect) = 0; 1.1092 + 1.1093 + /** 1.1094 + * Get this widget's client area bounds, if the window has a 3D border 1.1095 + * appearance this returns the area inside the border. The position is the 1.1096 + * position of the client area relative to the client area of the parent 1.1097 + * widget (for root widgets and popup widgets it is in screen coordinates). 1.1098 + * 1.1099 + * @param aRect On return it holds the x. y, width and height of 1.1100 + * the client area of this widget. 1.1101 + */ 1.1102 + NS_IMETHOD GetClientBounds(nsIntRect &aRect) = 0; 1.1103 + 1.1104 + /** 1.1105 + * Get the non-client area dimensions of the window. 1.1106 + * 1.1107 + */ 1.1108 + NS_IMETHOD GetNonClientMargins(nsIntMargin &margins) = 0; 1.1109 + 1.1110 + /** 1.1111 + * Sets the non-client area dimensions of the window. Pass -1 to restore 1.1112 + * the system default frame size for that border. Pass zero to remove 1.1113 + * a border, or pass a specific value adjust a border. Units are in 1.1114 + * pixels. (DPI dependent) 1.1115 + * 1.1116 + * Platform notes: 1.1117 + * Windows: shrinking top non-client height will remove application 1.1118 + * icon and window title text. Glass desktops will refuse to set 1.1119 + * dimensions between zero and size < system default. 1.1120 + * 1.1121 + */ 1.1122 + NS_IMETHOD SetNonClientMargins(nsIntMargin &margins) = 0; 1.1123 + 1.1124 + /** 1.1125 + * Get the client offset from the window origin. 1.1126 + * 1.1127 + * @return the x and y of the offset. 1.1128 + * 1.1129 + */ 1.1130 + virtual nsIntPoint GetClientOffset() = 0; 1.1131 + 1.1132 + /** 1.1133 + * Set the background color for this widget 1.1134 + * 1.1135 + * @param aColor the new background color 1.1136 + * 1.1137 + */ 1.1138 + 1.1139 + virtual void SetBackgroundColor(const nscolor &aColor) { } 1.1140 + 1.1141 + /** 1.1142 + * Get the cursor for this widget. 1.1143 + * 1.1144 + * @return this widget's cursor. 1.1145 + */ 1.1146 + 1.1147 + virtual nsCursor GetCursor(void) = 0; 1.1148 + 1.1149 + /** 1.1150 + * Set the cursor for this widget 1.1151 + * 1.1152 + * @param aCursor the new cursor for this widget 1.1153 + */ 1.1154 + 1.1155 + NS_IMETHOD SetCursor(nsCursor aCursor) = 0; 1.1156 + 1.1157 + /** 1.1158 + * Sets an image as the cursor for this widget. 1.1159 + * 1.1160 + * @param aCursor the cursor to set 1.1161 + * @param aX the X coordinate of the hotspot (from left). 1.1162 + * @param aY the Y coordinate of the hotspot (from top). 1.1163 + * @retval NS_ERROR_NOT_IMPLEMENTED if setting images as cursors is not 1.1164 + * supported 1.1165 + */ 1.1166 + NS_IMETHOD SetCursor(imgIContainer* aCursor, 1.1167 + uint32_t aHotspotX, uint32_t aHotspotY) = 0; 1.1168 + 1.1169 + /** 1.1170 + * Get the window type of this widget. 1.1171 + */ 1.1172 + nsWindowType WindowType() { return mWindowType; } 1.1173 + 1.1174 + /** 1.1175 + * Set the transparency mode of the top-level window containing this widget. 1.1176 + * So, e.g., if you call this on the widget for an IFRAME, the top level 1.1177 + * browser window containing the IFRAME actually gets set. Be careful. 1.1178 + * 1.1179 + * This can fail if the platform doesn't support 1.1180 + * transparency/glass. By default widgets are not 1.1181 + * transparent. This will also fail if the toplevel window is not 1.1182 + * a Mozilla window, e.g., if the widget is in an embedded 1.1183 + * context. 1.1184 + * 1.1185 + * After transparency/glass has been enabled, the initial alpha channel 1.1186 + * value for all pixels is 1, i.e., opaque. 1.1187 + * If the window is resized then the alpha channel values for 1.1188 + * all pixels are reset to 1. 1.1189 + * Pixel RGB color values are already premultiplied with alpha channel values. 1.1190 + */ 1.1191 + virtual void SetTransparencyMode(nsTransparencyMode aMode) = 0; 1.1192 + 1.1193 + /** 1.1194 + * Get the transparency mode of the top-level window that contains this 1.1195 + * widget. 1.1196 + */ 1.1197 + virtual nsTransparencyMode GetTransparencyMode() = 0; 1.1198 + 1.1199 + /** 1.1200 + * This represents a command to set the bounds and clip region of 1.1201 + * a child widget. 1.1202 + */ 1.1203 + struct Configuration { 1.1204 + nsIWidget* mChild; 1.1205 + nsIntRect mBounds; 1.1206 + nsTArray<nsIntRect> mClipRegion; 1.1207 + }; 1.1208 + 1.1209 + /** 1.1210 + * Sets the clip region of each mChild (which must actually be a child 1.1211 + * of this widget) to the union of the pixel rects given in 1.1212 + * mClipRegion, all relative to the top-left of the child 1.1213 + * widget. Clip regions are not implemented on all platforms and only 1.1214 + * need to actually work for children that are plugins. 1.1215 + * 1.1216 + * Also sets the bounds of each child to mBounds. 1.1217 + * 1.1218 + * This will invalidate areas of the children that have changed, but 1.1219 + * does not need to invalidate any part of this widget. 1.1220 + * 1.1221 + * Children should be moved in the order given; the array is 1.1222 + * sorted so to minimize unnecessary invalidation if children are 1.1223 + * moved in that order. 1.1224 + */ 1.1225 + virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) = 0; 1.1226 + 1.1227 + /** 1.1228 + * Appends to aRects the rectangles constituting this widget's clip 1.1229 + * region. If this widget is not clipped, appends a single rectangle 1.1230 + * (0, 0, bounds.width, bounds.height). 1.1231 + */ 1.1232 + virtual void GetWindowClipRegion(nsTArray<nsIntRect>* aRects) = 0; 1.1233 + 1.1234 + /** 1.1235 + * Set the shadow style of the window. 1.1236 + * 1.1237 + * Ignored on child widgets and on non-Mac platforms. 1.1238 + */ 1.1239 + NS_IMETHOD SetWindowShadowStyle(int32_t aStyle) = 0; 1.1240 + 1.1241 + /* 1.1242 + * On Mac OS X, this method shows or hides the pill button in the titlebar 1.1243 + * that's used to collapse the toolbar. 1.1244 + * 1.1245 + * Ignored on child widgets and on non-Mac platforms. 1.1246 + */ 1.1247 + virtual void SetShowsToolbarButton(bool aShow) = 0; 1.1248 + 1.1249 + /* 1.1250 + * On Mac OS X Lion, this method shows or hides the full screen button in 1.1251 + * the titlebar that handles native full screen mode. 1.1252 + * 1.1253 + * Ignored on child widgets, non-Mac platforms, & pre-Lion Mac. 1.1254 + */ 1.1255 + virtual void SetShowsFullScreenButton(bool aShow) = 0; 1.1256 + 1.1257 + enum WindowAnimationType { 1.1258 + eGenericWindowAnimation, 1.1259 + eDocumentWindowAnimation 1.1260 + }; 1.1261 + 1.1262 + /** 1.1263 + * Sets the kind of top-level window animation this widget should have. On 1.1264 + * Mac OS X, this causes a particular kind of animation to be shown when the 1.1265 + * window is first made visible. 1.1266 + * 1.1267 + * Ignored on child widgets and on non-Mac platforms. 1.1268 + */ 1.1269 + virtual void SetWindowAnimationType(WindowAnimationType aType) = 0; 1.1270 + 1.1271 + /** 1.1272 + * Specifies whether the window title should be drawn even if the window 1.1273 + * contents extend into the titlebar. Ignored on windows that don't draw 1.1274 + * in the titlebar. Only implemented on OS X. 1.1275 + */ 1.1276 + virtual void SetDrawsTitle(bool aDrawTitle) {} 1.1277 + 1.1278 + /** 1.1279 + * Hide window chrome (borders, buttons) for this widget. 1.1280 + * 1.1281 + */ 1.1282 + NS_IMETHOD HideWindowChrome(bool aShouldHide) = 0; 1.1283 + 1.1284 + /** 1.1285 + * Put the toplevel window into or out of fullscreen mode. 1.1286 + * 1.1287 + */ 1.1288 + NS_IMETHOD MakeFullScreen(bool aFullScreen) = 0; 1.1289 + 1.1290 + /** 1.1291 + * Invalidate a specified rect for a widget so that it will be repainted 1.1292 + * later. 1.1293 + */ 1.1294 + NS_IMETHOD Invalidate(const nsIntRect & aRect) = 0; 1.1295 + 1.1296 + enum LayerManagerPersistence 1.1297 + { 1.1298 + LAYER_MANAGER_CURRENT = 0, 1.1299 + LAYER_MANAGER_PERSISTENT 1.1300 + }; 1.1301 + 1.1302 + /** 1.1303 + * Return the widget's LayerManager. The layer tree for that 1.1304 + * LayerManager is what gets rendered to the widget. 1.1305 + * 1.1306 + * @param aAllowRetaining an outparam that states whether the returned 1.1307 + * layer manager should be used for retained layers 1.1308 + */ 1.1309 + inline LayerManager* GetLayerManager(bool* aAllowRetaining = nullptr) 1.1310 + { 1.1311 + return GetLayerManager(nullptr, mozilla::layers::LayersBackend::LAYERS_NONE, 1.1312 + LAYER_MANAGER_CURRENT, aAllowRetaining); 1.1313 + } 1.1314 + 1.1315 + inline LayerManager* GetLayerManager(LayerManagerPersistence aPersistence, 1.1316 + bool* aAllowRetaining = nullptr) 1.1317 + { 1.1318 + return GetLayerManager(nullptr, mozilla::layers::LayersBackend::LAYERS_NONE, 1.1319 + aPersistence, aAllowRetaining); 1.1320 + } 1.1321 + 1.1322 + /** 1.1323 + * Like GetLayerManager(), but prefers creating a layer manager of 1.1324 + * type |aBackendHint| instead of what would normally be created. 1.1325 + * LayersBackend::LAYERS_NONE means "no hint". 1.1326 + */ 1.1327 + virtual LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager, 1.1328 + LayersBackend aBackendHint, 1.1329 + LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT, 1.1330 + bool* aAllowRetaining = nullptr) = 0; 1.1331 + 1.1332 + /** 1.1333 + * Called before each layer manager transaction to allow any preparation 1.1334 + * for DrawWindowUnderlay/Overlay that needs to be on the main thread. 1.1335 + * 1.1336 + * Always called on the main thread. 1.1337 + */ 1.1338 + virtual void PrepareWindowEffects() = 0; 1.1339 + 1.1340 + /** 1.1341 + * Called when shutting down the LayerManager to clean-up any cached resources. 1.1342 + * 1.1343 + * Always called from the compositing thread, which may be the main-thread if 1.1344 + * OMTC is not enabled. 1.1345 + */ 1.1346 + virtual void CleanupWindowEffects() = 0; 1.1347 + 1.1348 + /** 1.1349 + * Called before rendering using OMTC. Returns false when the widget is 1.1350 + * not ready to be rendered (for example while the window is closed). 1.1351 + * 1.1352 + * Always called from the compositing thread, which may be the main-thread if 1.1353 + * OMTC is not enabled. 1.1354 + */ 1.1355 + virtual bool PreRender(LayerManagerComposite* aManager) = 0; 1.1356 + 1.1357 + /** 1.1358 + * Called after rendering using OMTC. Not called when rendering was 1.1359 + * cancelled by a negative return value from PreRender. 1.1360 + * 1.1361 + * Always called from the compositing thread, which may be the main-thread if 1.1362 + * OMTC is not enabled. 1.1363 + */ 1.1364 + virtual void PostRender(LayerManagerComposite* aManager) = 0; 1.1365 + 1.1366 + /** 1.1367 + * Called before the LayerManager draws the layer tree. 1.1368 + * 1.1369 + * Always called from the compositing thread. 1.1370 + */ 1.1371 + virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, nsIntRect aRect) = 0; 1.1372 + 1.1373 + /** 1.1374 + * Called after the LayerManager draws the layer tree 1.1375 + * 1.1376 + * Always called from the compositing thread. 1.1377 + */ 1.1378 + virtual void DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect) = 0; 1.1379 + 1.1380 + /** 1.1381 + * Return a DrawTarget for the window which can be composited into. 1.1382 + * 1.1383 + * Called by BasicCompositor on the compositor thread for OMTC drawing 1.1384 + * before each composition. 1.1385 + */ 1.1386 + virtual mozilla::TemporaryRef<mozilla::gfx::DrawTarget> StartRemoteDrawing() = 0; 1.1387 + 1.1388 + /** 1.1389 + * Ensure that what was painted into the DrawTarget returned from 1.1390 + * StartRemoteDrawing reaches the screen. 1.1391 + * 1.1392 + * Called by BasicCompositor on the compositor thread for OMTC drawing 1.1393 + * after each composition. 1.1394 + */ 1.1395 + virtual void EndRemoteDrawing() = 0; 1.1396 + 1.1397 + /** 1.1398 + * Clean up any resources used by Start/EndRemoteDrawing. 1.1399 + * 1.1400 + * Called by BasicCompositor on the compositor thread for OMTC drawing 1.1401 + * when the compositor is destroyed. 1.1402 + */ 1.1403 + virtual void CleanupRemoteDrawing() = 0; 1.1404 + 1.1405 + /** 1.1406 + * Called when Gecko knows which themed widgets exist in this window. 1.1407 + * The passed array contains an entry for every themed widget of the right 1.1408 + * type (currently only NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR and 1.1409 + * NS_THEME_TOOLBAR) within the window, except for themed widgets which are 1.1410 + * transformed or have effects applied to them (e.g. CSS opacity or 1.1411 + * filters). 1.1412 + * This could sometimes be called during display list construction 1.1413 + * outside of painting. 1.1414 + * If called during painting, it will be called before we actually 1.1415 + * paint anything. 1.1416 + */ 1.1417 + virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) = 0; 1.1418 + 1.1419 + /** 1.1420 + * Informs the widget about the region of the window that is opaque. 1.1421 + * 1.1422 + * @param aOpaqueRegion the region of the window that is opaque. 1.1423 + */ 1.1424 + virtual void UpdateOpaqueRegion(const nsIntRegion &aOpaqueRegion) {} 1.1425 + 1.1426 + /** 1.1427 + * Internal methods 1.1428 + */ 1.1429 + 1.1430 + //@{ 1.1431 + virtual void AddChild(nsIWidget* aChild) = 0; 1.1432 + virtual void RemoveChild(nsIWidget* aChild) = 0; 1.1433 + virtual void* GetNativeData(uint32_t aDataType) = 0; 1.1434 + virtual void FreeNativeData(void * data, uint32_t aDataType) = 0;//~~~ 1.1435 + 1.1436 + // GetDeviceContext returns a weak pointer to this widget's device context 1.1437 + virtual nsDeviceContext* GetDeviceContext() = 0; 1.1438 + 1.1439 + //@} 1.1440 + 1.1441 + /** 1.1442 + * Set the widget's title. 1.1443 + * Must be called after Create. 1.1444 + * 1.1445 + * @param aTitle string displayed as the title of the widget 1.1446 + */ 1.1447 + 1.1448 + NS_IMETHOD SetTitle(const nsAString& aTitle) = 0; 1.1449 + 1.1450 + /** 1.1451 + * Set the widget's icon. 1.1452 + * Must be called after Create. 1.1453 + * 1.1454 + * @param anIconSpec string specifying the icon to use; convention is to pass 1.1455 + * a resource: URL from which a platform-dependent resource 1.1456 + * file name will be constructed 1.1457 + */ 1.1458 + 1.1459 + NS_IMETHOD SetIcon(const nsAString& anIconSpec) = 0; 1.1460 + 1.1461 + /** 1.1462 + * Return this widget's origin in screen coordinates. 1.1463 + * 1.1464 + * @return screen coordinates stored in the x,y members 1.1465 + */ 1.1466 + 1.1467 + virtual nsIntPoint WidgetToScreenOffset() = 0; 1.1468 + 1.1469 + /** 1.1470 + * Given the specified client size, return the corresponding window size, 1.1471 + * which includes the area for the borders and titlebar. This method 1.1472 + * should work even when the window is not yet visible. 1.1473 + */ 1.1474 + virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize) = 0; 1.1475 + 1.1476 + /** 1.1477 + * Dispatches an event to the widget 1.1478 + * 1.1479 + */ 1.1480 + NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* event, 1.1481 + nsEventStatus & aStatus) = 0; 1.1482 + 1.1483 + /** 1.1484 + * Enables the dropping of files to a widget (XXX this is temporary) 1.1485 + * 1.1486 + */ 1.1487 + NS_IMETHOD EnableDragDrop(bool aEnable) = 0; 1.1488 + 1.1489 + /** 1.1490 + * Enables/Disables system mouse capture. 1.1491 + * @param aCapture true enables mouse capture, false disables mouse capture 1.1492 + * 1.1493 + */ 1.1494 + NS_IMETHOD CaptureMouse(bool aCapture) = 0; 1.1495 + 1.1496 + /** 1.1497 + * Classify the window for the window manager. Mostly for X11. 1.1498 + */ 1.1499 + NS_IMETHOD SetWindowClass(const nsAString& xulWinType) = 0; 1.1500 + 1.1501 + /** 1.1502 + * Enables/Disables system capture of any and all events that would cause a 1.1503 + * popup to be rolled up. aListener should be set to a non-null value for 1.1504 + * any popups that are not managed by the popup manager. 1.1505 + * @param aDoCapture true enables capture, false disables capture 1.1506 + * 1.1507 + */ 1.1508 + NS_IMETHOD CaptureRollupEvents(nsIRollupListener* aListener, bool aDoCapture) = 0; 1.1509 + 1.1510 + /** 1.1511 + * Bring this window to the user's attention. This is intended to be a more 1.1512 + * gentle notification than popping the window to the top or putting up an 1.1513 + * alert. See, for example, Win32 FlashWindow or the NotificationManager on 1.1514 + * the Mac. The notification should be suppressed if the window is already 1.1515 + * in the foreground and should be dismissed when the user brings this window 1.1516 + * to the foreground. 1.1517 + * @param aCycleCount Maximum number of times to animate the window per system 1.1518 + * conventions. If set to -1, cycles indefinitely until 1.1519 + * window is brought into the foreground. 1.1520 + */ 1.1521 + NS_IMETHOD GetAttention(int32_t aCycleCount) = 0; 1.1522 + 1.1523 + /** 1.1524 + * Ask whether there user input events pending. All input events are 1.1525 + * included, including those not targeted at this nsIwidget instance. 1.1526 + */ 1.1527 + virtual bool HasPendingInputEvent() = 0; 1.1528 + 1.1529 + /** 1.1530 + * Set the background color of the window titlebar for this widget. On Mac, 1.1531 + * for example, this will remove the grey gradient and bottom border and 1.1532 + * instead show a single, solid color. 1.1533 + * 1.1534 + * Ignored on any platform that does not support it. Ignored by widgets that 1.1535 + * do not represent windows. 1.1536 + * 1.1537 + * @param aColor The color to set the title bar background to. Alpha values 1.1538 + * other than fully transparent (0) are respected if possible 1.1539 + * on the platform. An alpha of 0 will cause the window to 1.1540 + * draw with the default style for the platform. 1.1541 + * 1.1542 + * @param aActive Whether the color should be applied to active or inactive 1.1543 + * windows. 1.1544 + */ 1.1545 + NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, bool aActive) = 0; 1.1546 + 1.1547 + /** 1.1548 + * If set to true, the window will draw its contents into the titlebar 1.1549 + * instead of below it. 1.1550 + * 1.1551 + * Ignored on any platform that does not support it. Ignored by widgets that 1.1552 + * do not represent windows. 1.1553 + * May result in a resize event, so should only be called from places where 1.1554 + * reflow and painting is allowed. 1.1555 + * 1.1556 + * @param aState Whether drawing into the titlebar should be activated. 1.1557 + */ 1.1558 + virtual void SetDrawsInTitlebar(bool aState) = 0; 1.1559 + 1.1560 + /* 1.1561 + * Determine whether the widget shows a resize widget. If it does, 1.1562 + * aResizerRect returns the resizer's rect. 1.1563 + * 1.1564 + * Returns false on any platform that does not support it. 1.1565 + * 1.1566 + * @param aResizerRect The resizer's rect in device pixels. 1.1567 + * @return Whether a resize widget is shown. 1.1568 + */ 1.1569 + virtual bool ShowsResizeIndicator(nsIntRect* aResizerRect) = 0; 1.1570 + 1.1571 + /** 1.1572 + * Get the Thebes surface associated with this widget. 1.1573 + */ 1.1574 + virtual gfxASurface *GetThebesSurface() = 0; 1.1575 + 1.1576 + /** 1.1577 + * Return the popup that was last rolled up, or null if there isn't one. 1.1578 + */ 1.1579 + virtual nsIContent* GetLastRollup() = 0; 1.1580 + 1.1581 + /** 1.1582 + * Begin a window resizing drag, based on the event passed in. 1.1583 + */ 1.1584 + NS_IMETHOD BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent, 1.1585 + int32_t aHorizontal, 1.1586 + int32_t aVertical) = 0; 1.1587 + 1.1588 + /** 1.1589 + * Begin a window moving drag, based on the event passed in. 1.1590 + */ 1.1591 + NS_IMETHOD BeginMoveDrag(mozilla::WidgetMouseEvent* aEvent) = 0; 1.1592 + 1.1593 + enum Modifiers { 1.1594 + CAPS_LOCK = 0x01, // when CapsLock is active 1.1595 + NUM_LOCK = 0x02, // when NumLock is active 1.1596 + SHIFT_L = 0x0100, 1.1597 + SHIFT_R = 0x0200, 1.1598 + CTRL_L = 0x0400, 1.1599 + CTRL_R = 0x0800, 1.1600 + ALT_L = 0x1000, // includes Option 1.1601 + ALT_R = 0x2000, 1.1602 + COMMAND_L = 0x4000, 1.1603 + COMMAND_R = 0x8000, 1.1604 + HELP = 0x10000, 1.1605 + FUNCTION = 0x100000, 1.1606 + NUMERIC_KEY_PAD = 0x01000000 // when the key is coming from the keypad 1.1607 + }; 1.1608 + /** 1.1609 + * Utility method intended for testing. Dispatches native key events 1.1610 + * to this widget to simulate the press and release of a key. 1.1611 + * @param aNativeKeyboardLayout a *platform-specific* constant. 1.1612 + * On Mac, this is the resource ID for a 'uchr' or 'kchr' resource. 1.1613 + * On Windows, it is converted to a hex string and passed to 1.1614 + * LoadKeyboardLayout, see 1.1615 + * http://msdn.microsoft.com/en-us/library/ms646305(VS.85).aspx 1.1616 + * @param aNativeKeyCode a *platform-specific* keycode. 1.1617 + * On Windows, this is the virtual key code. 1.1618 + * @param aModifiers some combination of the above 'Modifiers' flags; 1.1619 + * not all flags will apply to all platforms. Mac ignores the _R 1.1620 + * modifiers. Windows ignores COMMAND, NUMERIC_KEY_PAD, HELP and 1.1621 + * FUNCTION. 1.1622 + * @param aCharacters characters that the OS would decide to generate 1.1623 + * from the event. On Windows, this is the charCode passed by 1.1624 + * WM_CHAR. 1.1625 + * @param aUnmodifiedCharacters characters that the OS would decide 1.1626 + * to generate from the event if modifier keys (other than shift) 1.1627 + * were assumed inactive. Needed on Mac, ignored on Windows. 1.1628 + * @return NS_ERROR_NOT_AVAILABLE to indicate that the keyboard 1.1629 + * layout is not supported and the event was not fired 1.1630 + */ 1.1631 + virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout, 1.1632 + int32_t aNativeKeyCode, 1.1633 + uint32_t aModifierFlags, 1.1634 + const nsAString& aCharacters, 1.1635 + const nsAString& aUnmodifiedCharacters) = 0; 1.1636 + 1.1637 + /** 1.1638 + * Utility method intended for testing. Dispatches native mouse events 1.1639 + * may even move the mouse cursor. On Mac the events are guaranteed to 1.1640 + * be sent to the window containing this widget, but on Windows they'll go 1.1641 + * to whatever's topmost on the screen at that position, so for 1.1642 + * cross-platform testing ensure that your window is at the top of the 1.1643 + * z-order. 1.1644 + * @param aPoint screen location of the mouse, in device 1.1645 + * pixels, with origin at the top left 1.1646 + * @param aNativeMessage *platform-specific* event type (e.g. on Mac, 1.1647 + * NSMouseMoved; on Windows, MOUSEEVENTF_MOVE, MOUSEEVENTF_LEFTDOWN etc) 1.1648 + * @param aModifierFlags *platform-specific* modifier flags (ignored 1.1649 + * on Windows) 1.1650 + */ 1.1651 + virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint, 1.1652 + uint32_t aNativeMessage, 1.1653 + uint32_t aModifierFlags) = 0; 1.1654 + 1.1655 + /** 1.1656 + * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native message. 1.1657 + * aPoint is location in device pixels to which the mouse pointer moves to. 1.1658 + */ 1.1659 + virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint) = 0; 1.1660 + 1.1661 + /** 1.1662 + * Utility method intended for testing. Dispatching native mouse scroll 1.1663 + * events may move the mouse cursor. 1.1664 + * 1.1665 + * @param aPoint Mouse cursor position in screen coordinates. 1.1666 + * In device pixels, the origin at the top left of 1.1667 + * the primary display. 1.1668 + * @param aNativeMessage Platform native message. 1.1669 + * @param aDeltaX The delta value for X direction. If the native 1.1670 + * message doesn't indicate X direction scrolling, 1.1671 + * this may be ignored. 1.1672 + * @param aDeltaY The delta value for Y direction. If the native 1.1673 + * message doesn't indicate Y direction scrolling, 1.1674 + * this may be ignored. 1.1675 + * @param aDeltaZ The delta value for Z direction. If the native 1.1676 + * message doesn't indicate Z direction scrolling, 1.1677 + * this may be ignored. 1.1678 + * @param aModifierFlags Must be values of Modifiers, or zero. 1.1679 + * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their 1.1680 + * document. 1.1681 + */ 1.1682 + virtual nsresult SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint, 1.1683 + uint32_t aNativeMessage, 1.1684 + double aDeltaX, 1.1685 + double aDeltaY, 1.1686 + double aDeltaZ, 1.1687 + uint32_t aModifierFlags, 1.1688 + uint32_t aAdditionalFlags) = 0; 1.1689 + 1.1690 + /* 1.1691 + * TouchPointerState states for SynthesizeNativeTouchPoint. Match 1.1692 + * touch states in nsIDOMWindowUtils.idl. 1.1693 + */ 1.1694 + enum TouchPointerState { 1.1695 + // The pointer is in a hover state above the digitizer 1.1696 + TOUCH_HOVER = 0x01, 1.1697 + // The pointer is in contact with the digitizer 1.1698 + TOUCH_CONTACT = 0x02, 1.1699 + // The pointer has been removed from the digitizer detection area 1.1700 + TOUCH_REMOVE = 0x04, 1.1701 + // The pointer has been canceled. Will cancel any pending os level 1.1702 + // gestures that would triggered as a result of completion of the 1.1703 + // input sequence. This may not cancel moz platform related events 1.1704 + // that might get tirggered by input already delivered. 1.1705 + TOUCH_CANCEL = 0x08 1.1706 + }; 1.1707 + 1.1708 + /* 1.1709 + * Create a new or update an existing touch pointer on the digitizer. 1.1710 + * To trigger os level gestures, individual touch points should 1.1711 + * transition through a complete set of touch states which should be 1.1712 + * sent as individual messages. 1.1713 + * 1.1714 + * @param aPointerId The touch point id to create or update. 1.1715 + * @param aPointerState one or more of the touch states listed above 1.1716 + * @param aScreenX, aScreenY screen coords of this event 1.1717 + * @param aPressure 0.0 -> 1.0 float val indicating pressure 1.1718 + * @param aOrientation 0 -> 359 degree value indicating the 1.1719 + * orientation of the pointer. Use 90 for normal taps. 1.1720 + */ 1.1721 + virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId, 1.1722 + TouchPointerState aPointerState, 1.1723 + nsIntPoint aPointerScreenPoint, 1.1724 + double aPointerPressure, 1.1725 + uint32_t aPointerOrientation) = 0; 1.1726 + 1.1727 + /* 1.1728 + * Cancels all active simulated touch input points and pending long taps. 1.1729 + * Native widgets should track existing points such that they can clear the 1.1730 + * digitizer state when this call is made. 1.1731 + */ 1.1732 + virtual nsresult ClearNativeTouchSequence(); 1.1733 + 1.1734 + /* 1.1735 + * Helper for simulating a simple tap event with one touch point. When 1.1736 + * aLongTap is true, simulates a native long tap with a duration equal to 1.1737 + * ui.click_hold_context_menus.delay. This pref is compatible with the 1.1738 + * apzc long tap duration. Defaults to 1.5 seconds. 1.1739 + */ 1.1740 + nsresult SynthesizeNativeTouchTap(nsIntPoint aPointerScreenPoint, 1.1741 + bool aLongTap); 1.1742 + 1.1743 +private: 1.1744 + class LongTapInfo 1.1745 + { 1.1746 + public: 1.1747 + LongTapInfo(int32_t aPointerId, nsIntPoint& aPoint, 1.1748 + mozilla::TimeDuration aDuration) : 1.1749 + mPointerId(aPointerId), 1.1750 + mPosition(aPoint), 1.1751 + mDuration(aDuration), 1.1752 + mStamp(mozilla::TimeStamp::Now()) 1.1753 + { 1.1754 + } 1.1755 + 1.1756 + int32_t mPointerId; 1.1757 + nsIntPoint mPosition; 1.1758 + mozilla::TimeDuration mDuration; 1.1759 + mozilla::TimeStamp mStamp; 1.1760 + }; 1.1761 + 1.1762 + static void OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure); 1.1763 + 1.1764 + nsAutoPtr<LongTapInfo> mLongTapTouchPoint; 1.1765 + nsCOMPtr<nsITimer> mLongTapTimer; 1.1766 + static int32_t sPointerIdCounter; 1.1767 + 1.1768 +public: 1.1769 + /** 1.1770 + * Activates a native menu item at the position specified by the index 1.1771 + * string. The index string is a string of positive integers separated 1.1772 + * by the "|" (pipe) character. The last integer in the string represents 1.1773 + * the item index in a submenu located using the integers preceding it. 1.1774 + * 1.1775 + * Example: 1|0|4 1.1776 + * In this string, the first integer represents the top-level submenu 1.1777 + * in the native menu bar. Since the integer is 1, it is the second submeu 1.1778 + * in the native menu bar. Within that, the first item (index 0) is a 1.1779 + * submenu, and we want to activate the 5th item within that submenu. 1.1780 + */ 1.1781 + virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) = 0; 1.1782 + 1.1783 + /** 1.1784 + * This is used for native menu system testing. 1.1785 + * 1.1786 + * Updates a native menu at the position specified by the index string. 1.1787 + * The index string is a string of positive integers separated by the "|" 1.1788 + * (pipe) character. 1.1789 + * 1.1790 + * Example: 1|0|4 1.1791 + * In this string, the first integer represents the top-level submenu 1.1792 + * in the native menu bar. Since the integer is 1, it is the second submeu 1.1793 + * in the native menu bar. Within that, the first item (index 0) is a 1.1794 + * submenu, and we want to update submenu at index 4 within that submenu. 1.1795 + * 1.1796 + * If this is called with an empty string it forces a full reload of the 1.1797 + * menu system. 1.1798 + */ 1.1799 + virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) = 0; 1.1800 + 1.1801 + /** 1.1802 + * Notify IME of the specified notification. 1.1803 + */ 1.1804 + NS_IMETHOD NotifyIME(const IMENotification& aIMENotification) = 0; 1.1805 + 1.1806 + /* 1.1807 + * Notifies the input context changes. 1.1808 + */ 1.1809 + NS_IMETHOD_(void) SetInputContext(const InputContext& aContext, 1.1810 + const InputContextAction& aAction) = 0; 1.1811 + 1.1812 + /* 1.1813 + * Get current input context. 1.1814 + */ 1.1815 + NS_IMETHOD_(InputContext) GetInputContext() = 0; 1.1816 + 1.1817 + /* 1.1818 + * Given a WidgetKeyboardEvent, this method synthesizes a corresponding 1.1819 + * native (OS-level) event for it. This method allows tests to simulate 1.1820 + * keystrokes that trigger native key bindings (which require a native 1.1821 + * event). 1.1822 + */ 1.1823 + NS_IMETHOD AttachNativeKeyEvent(mozilla::WidgetKeyboardEvent& aEvent) = 0; 1.1824 + 1.1825 + /* 1.1826 + * Execute native key bindings for aType. 1.1827 + */ 1.1828 + typedef void (*DoCommandCallback)(mozilla::Command, void*); 1.1829 + enum NativeKeyBindingsType 1.1830 + { 1.1831 + NativeKeyBindingsForSingleLineEditor, 1.1832 + NativeKeyBindingsForMultiLineEditor, 1.1833 + NativeKeyBindingsForRichTextEditor 1.1834 + }; 1.1835 + NS_IMETHOD_(bool) ExecuteNativeKeyBinding( 1.1836 + NativeKeyBindingsType aType, 1.1837 + const mozilla::WidgetKeyboardEvent& aEvent, 1.1838 + DoCommandCallback aCallback, 1.1839 + void* aCallbackData) = 0; 1.1840 + 1.1841 + /** 1.1842 + * Set layers acceleration to 'True' or 'False' 1.1843 + */ 1.1844 + NS_IMETHOD SetLayersAcceleration(bool aEnabled) = 0; 1.1845 + 1.1846 + /* 1.1847 + * Get toggled key states. 1.1848 + * aKeyCode should be NS_VK_CAPS_LOCK or NS_VK_NUM_LOCK or 1.1849 + * NS_VK_SCROLL_LOCK. 1.1850 + * aLEDState is the result for current LED state of the key. 1.1851 + * If the LED is 'ON', it returns TRUE, otherwise, FALSE. 1.1852 + * If the platform doesn't support the LED state (or we cannot get the 1.1853 + * state), this method returns NS_ERROR_NOT_IMPLEMENTED. 1.1854 + */ 1.1855 + NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) = 0; 1.1856 + 1.1857 + /* 1.1858 + * Retrieves preference for IME updates 1.1859 + */ 1.1860 + virtual nsIMEUpdatePreference GetIMEUpdatePreference() = 0; 1.1861 + 1.1862 + /* 1.1863 + * Call this method when a dialog is opened which has a default button. 1.1864 + * The button's rectangle should be supplied in aButtonRect. 1.1865 + */ 1.1866 + NS_IMETHOD OnDefaultButtonLoaded(const nsIntRect &aButtonRect) = 0; 1.1867 + 1.1868 + /** 1.1869 + * Compute the overridden system mouse scroll speed on the root content of 1.1870 + * web pages. The widget may set the same value as aOriginalDelta. E.g., 1.1871 + * when the system scrolling settings were customized, widget can respect 1.1872 + * the will of the user. 1.1873 + * 1.1874 + * This is called only when the mouse wheel event scrolls the root content 1.1875 + * of the web pages by line. In other words, this isn't called when the 1.1876 + * mouse wheel event is used for zoom, page scroll and other special 1.1877 + * actions. And also this isn't called when the user doesn't use the 1.1878 + * system wheel speed settings. 1.1879 + * 1.1880 + * @param aOriginalDeltaX The X delta value of the current mouse wheel 1.1881 + * scrolling event. 1.1882 + * @param aOriginalDeltaX The Y delta value of the current mouse wheel 1.1883 + * scrolling event. 1.1884 + * @param aOverriddenDeltaX The overridden mouse scrolling speed along X 1.1885 + * axis. This value may be same as aOriginalDeltaX. 1.1886 + * @param aOverriddenDeltaY The overridden mouse scrolling speed along Y 1.1887 + * axis. This value may be same as aOriginalDeltaY. 1.1888 + */ 1.1889 + NS_IMETHOD OverrideSystemMouseScrollSpeed(double aOriginalDeltaX, 1.1890 + double aOriginalDeltaY, 1.1891 + double& aOverriddenDeltaX, 1.1892 + double& aOverriddenDeltaY) = 0; 1.1893 + 1.1894 + /** 1.1895 + * Return true if this process shouldn't use platform widgets, and 1.1896 + * so should use PuppetWidgets instead. If this returns true, the 1.1897 + * result of creating and using a platform widget is undefined, 1.1898 + * and likely to end in crashes or other buggy behavior. 1.1899 + */ 1.1900 + static bool 1.1901 + UsePuppetWidgets() 1.1902 + { 1.1903 + return XRE_GetProcessType() == GeckoProcessType_Content; 1.1904 + } 1.1905 + 1.1906 + /** 1.1907 + * Allocate and return a "puppet widget" that doesn't directly 1.1908 + * correlate to a platform widget; platform events and data must 1.1909 + * be fed to it. Currently used in content processes. NULL is 1.1910 + * returned if puppet widgets aren't supported in this build 1.1911 + * config, on this platform, or for this process type. 1.1912 + * 1.1913 + * This function is called "Create" to match CreateInstance(). 1.1914 + * The returned widget must still be nsIWidget::Create()d. 1.1915 + */ 1.1916 + static already_AddRefed<nsIWidget> 1.1917 + CreatePuppetWidget(TabChild* aTabChild); 1.1918 + 1.1919 + /** 1.1920 + * Reparent this widget's native widget. 1.1921 + * @param aNewParent the native widget of aNewParent is the new native 1.1922 + * parent widget 1.1923 + */ 1.1924 + NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent) = 0; 1.1925 + 1.1926 + /** 1.1927 + * Return the internal format of the default framebuffer for this 1.1928 + * widget. 1.1929 + */ 1.1930 + virtual uint32_t GetGLFrameBufferFormat() { return 0; /*GL_NONE*/ } 1.1931 + 1.1932 + /** 1.1933 + * Return true if widget has it's own GL context 1.1934 + */ 1.1935 + virtual bool HasGLContext() { return false; } 1.1936 + 1.1937 + /** 1.1938 + * Returns true to indicate that this widget paints an opaque background 1.1939 + * that we want to be visible under the page, so layout should not force 1.1940 + * a default background. 1.1941 + */ 1.1942 + virtual bool WidgetPaintsBackground() { return false; } 1.1943 + 1.1944 + virtual bool NeedsPaint() { 1.1945 + if (!IsVisible()) { 1.1946 + return false; 1.1947 + } 1.1948 + nsIntRect bounds; 1.1949 + nsresult rv = GetBounds(bounds); 1.1950 + NS_ENSURE_SUCCESS(rv, false); 1.1951 + return !bounds.IsEmpty(); 1.1952 + } 1.1953 + 1.1954 + /** 1.1955 + * Get the natural bounds of this widget. This method is only 1.1956 + * meaningful for widgets for which Gecko implements screen 1.1957 + * rotation natively. When this is the case, GetBounds() returns 1.1958 + * the widget bounds taking rotation into account, and 1.1959 + * GetNaturalBounds() returns the bounds *not* taking rotation 1.1960 + * into account. 1.1961 + * 1.1962 + * No code outside of the composition pipeline should know or care 1.1963 + * about this. If you're not an agent of the compositor, you 1.1964 + * probably shouldn't call this method. 1.1965 + */ 1.1966 + virtual nsIntRect GetNaturalBounds() { 1.1967 + nsIntRect bounds; 1.1968 + GetBounds(bounds); 1.1969 + return bounds; 1.1970 + } 1.1971 + 1.1972 + /** 1.1973 + * Set size constraints on the window size such that it is never less than 1.1974 + * the specified minimum size and never larger than the specified maximum 1.1975 + * size. The size constraints are sizes of the outer rectangle including 1.1976 + * the window frame and title bar. Use 0 for an unconstrained minimum size 1.1977 + * and NS_MAXSIZE for an unconstrained maximum size. Note that this method 1.1978 + * does not necessarily change the size of a window to conform to this size, 1.1979 + * thus Resize should be called afterwards. 1.1980 + * 1.1981 + * @param aConstraints: the size constraints in device pixels 1.1982 + */ 1.1983 + virtual void SetSizeConstraints(const SizeConstraints& aConstraints) = 0; 1.1984 + 1.1985 + /** 1.1986 + * Return the size constraints currently observed by the widget. 1.1987 + * 1.1988 + * @return the constraints in device pixels 1.1989 + */ 1.1990 + virtual const SizeConstraints& GetSizeConstraints() const = 0; 1.1991 + 1.1992 + /** 1.1993 + * If this is owned by a TabChild, return that. Otherwise return 1.1994 + * null. 1.1995 + */ 1.1996 + virtual TabChild* GetOwningTabChild() { return nullptr; } 1.1997 + 1.1998 + /** 1.1999 + * If this isn't directly compositing to its window surface, 1.2000 + * return the compositor which is doing that on our behalf. 1.2001 + */ 1.2002 + virtual CompositorChild* GetRemoteRenderer() 1.2003 + { return nullptr; } 1.2004 + 1.2005 + /** 1.2006 + * If this widget has a more efficient composer available for its 1.2007 + * native framebuffer, return it. 1.2008 + * 1.2009 + * This can be called from a non-main thread, but that thread must 1.2010 + * hold a strong reference to this. 1.2011 + */ 1.2012 + virtual Composer2D* GetComposer2D() 1.2013 + { return nullptr; } 1.2014 + 1.2015 + /** 1.2016 + * Some platforms (only cocoa right now) round widget coordinates to the 1.2017 + * nearest even pixels (see bug 892994), this function allows us to 1.2018 + * determine how widget coordinates will be rounded. 1.2019 + */ 1.2020 + virtual int32_t RoundsWidgetCoordinatesTo() { return 1; } 1.2021 + 1.2022 +protected: 1.2023 + /** 1.2024 + * Like GetDefaultScale, but taking into account only the system settings 1.2025 + * and ignoring Gecko preferences. 1.2026 + */ 1.2027 + virtual double GetDefaultScaleInternal() { return 1.0; } 1.2028 + 1.2029 + // keep the list of children. We also keep track of our siblings. 1.2030 + // The ownership model is as follows: parent holds a strong ref to 1.2031 + // the first element of the list, and each element holds a strong 1.2032 + // ref to the next element in the list. The prevsibling and 1.2033 + // lastchild pointers are weak, which is fine as long as they are 1.2034 + // maintained properly. 1.2035 + nsCOMPtr<nsIWidget> mFirstChild; 1.2036 + nsIWidget* mLastChild; 1.2037 + nsCOMPtr<nsIWidget> mNextSibling; 1.2038 + nsIWidget* mPrevSibling; 1.2039 + // When Destroy() is called, the sub class should set this true. 1.2040 + bool mOnDestroyCalled; 1.2041 + nsWindowType mWindowType; 1.2042 + int32_t mZIndex; 1.2043 +}; 1.2044 + 1.2045 +NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget, NS_IWIDGET_IID) 1.2046 + 1.2047 +#endif // nsIWidget_h__