1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "base/basictypes.h"
10 #include "ClientLayerManager.h"
11 #include "gfxPlatform.h"
12 #include "nsRefreshDriver.h"
13 #include "mozilla/dom/BrowserChild.h"
14 #include "mozilla/gfx/gfxVars.h"
15 #include "mozilla/Hal.h"
16 #include "mozilla/IMEStateManager.h"
17 #include "mozilla/layers/APZChild.h"
18 #include "mozilla/layers/PLayerTransactionChild.h"
19 #include "mozilla/layers/WebRenderLayerManager.h"
20 #include "mozilla/Preferences.h"
21 #include "mozilla/PresShell.h"
22 #include "mozilla/SchedulerGroup.h"
23 #include "mozilla/StaticPrefs_browser.h"
24 #include "mozilla/TextComposition.h"
25 #include "mozilla/TextEventDispatcher.h"
26 #include "mozilla/TextEvents.h"
27 #include "mozilla/Unused.h"
28 #include "BasicLayers.h"
29 #include "PuppetWidget.h"
30 #include "nsContentUtils.h"
31 #include "nsIWidgetListener.h"
32 #include "imgIContainer.h"
34 #include "nsXPLookAndFeel.h"
35 #include "nsPrintfCString.h"
37 using namespace mozilla
;
38 using namespace mozilla::dom
;
39 using namespace mozilla::hal
;
40 using namespace mozilla::gfx
;
41 using namespace mozilla::layers
;
42 using namespace mozilla::widget
;
44 static void InvalidateRegion(nsIWidget
* aWidget
,
45 const LayoutDeviceIntRegion
& aRegion
) {
46 for (auto iter
= aRegion
.RectIter(); !iter
.Done(); iter
.Next()) {
47 aWidget
->Invalidate(iter
.Get());
52 already_AddRefed
<nsIWidget
> nsIWidget::CreatePuppetWidget(
53 BrowserChild
* aBrowserChild
) {
54 MOZ_ASSERT(!aBrowserChild
|| nsIWidget::UsePuppetWidgets(),
55 "PuppetWidgets not allowed in this configuration");
57 nsCOMPtr
<nsIWidget
> widget
= new PuppetWidget(aBrowserChild
);
58 return widget
.forget();
64 static bool IsPopup(const nsWidgetInitData
* aInitData
) {
65 return aInitData
&& aInitData
->mWindowType
== eWindowType_popup
;
68 static bool MightNeedIMEFocus(const nsWidgetInitData
* aInitData
) {
69 // In the puppet-widget world, popup widgets are just dummies and
70 // shouldn't try to mess with IME state.
71 #ifdef MOZ_CROSS_PROCESS_IME
72 return !IsPopup(aInitData
);
78 // Arbitrary, fungible.
79 const size_t PuppetWidget::kMaxDimension
= 4000;
81 NS_IMPL_ISUPPORTS_INHERITED(PuppetWidget
, nsBaseWidget
,
82 TextEventDispatcherListener
)
84 PuppetWidget::PuppetWidget(BrowserChild
* aBrowserChild
)
85 : mBrowserChild(aBrowserChild
),
86 mMemoryPressureObserver(nullptr),
94 mNeedIMEStateInit(false),
95 mIgnoreCompositionEvents(false) {
96 // Setting 'Unknown' means "not yet cached".
97 mInputContext
.mIMEState
.mEnabled
= IMEEnabled::Unknown
;
100 PuppetWidget::~PuppetWidget() { Destroy(); }
102 void PuppetWidget::InfallibleCreate(nsIWidget
* aParent
,
103 nsNativeWidget aNativeParent
,
104 const LayoutDeviceIntRect
& aRect
,
105 nsWidgetInitData
* aInitData
) {
106 MOZ_ASSERT(!aNativeParent
, "got a non-Puppet native parent");
108 BaseCreate(nullptr, aInitData
);
114 mDrawTarget
= gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
115 IntSize(1, 1), SurfaceFormat::B8G8R8A8
);
117 mNeedIMEStateInit
= MightNeedIMEFocus(aInitData
);
119 PuppetWidget
* parent
= static_cast<PuppetWidget
*>(aParent
);
121 parent
->SetChild(this);
122 mLayerManager
= parent
->GetLayerManager();
124 Resize(mBounds
.X(), mBounds
.Y(), mBounds
.Width(), mBounds
.Height(), false);
126 mMemoryPressureObserver
= MemoryPressureObserver::Create(this);
129 nsresult
PuppetWidget::Create(nsIWidget
* aParent
, nsNativeWidget aNativeParent
,
130 const LayoutDeviceIntRect
& aRect
,
131 nsWidgetInitData
* aInitData
) {
132 InfallibleCreate(aParent
, aNativeParent
, aRect
, aInitData
);
136 void PuppetWidget::InitIMEState() {
137 MOZ_ASSERT(mBrowserChild
);
138 if (mNeedIMEStateInit
) {
139 mContentCache
.Clear();
140 mBrowserChild
->SendUpdateContentCache(mContentCache
);
141 mIMENotificationRequestsOfParent
= IMENotificationRequests();
142 mNeedIMEStateInit
= false;
146 already_AddRefed
<nsIWidget
> PuppetWidget::CreateChild(
147 const LayoutDeviceIntRect
& aRect
, nsWidgetInitData
* aInitData
,
148 bool aForceUseIWidgetParent
) {
149 bool isPopup
= IsPopup(aInitData
);
150 nsCOMPtr
<nsIWidget
> widget
= nsIWidget::CreatePuppetWidget(mBrowserChild
);
151 return ((widget
&& NS_SUCCEEDED(widget
->Create(isPopup
? nullptr : this,
152 nullptr, aRect
, aInitData
)))
157 void PuppetWidget::Destroy() {
158 if (mOnDestroyCalled
) {
161 mOnDestroyCalled
= true;
165 if (mMemoryPressureObserver
) {
166 mMemoryPressureObserver
->Unregister();
167 mMemoryPressureObserver
= nullptr;
171 mLayerManager
->Destroy();
173 mLayerManager
= nullptr;
174 mBrowserChild
= nullptr;
177 void PuppetWidget::Show(bool aState
) {
178 NS_ASSERTION(mEnabled
,
179 "does it make sense to Show()/Hide() a disabled widget?");
181 bool wasVisible
= mVisible
;
185 mChild
->mVisible
= aState
;
188 if (!wasVisible
&& mVisible
) {
189 // The previously attached widget listener is handy if
190 // we're transitioning from page to page without dropping
191 // layers (since we'll continue to show the old layers
192 // associated with that old widget listener). If the
193 // PuppetWidget was hidden, those layers are dropped,
194 // so the previously attached widget listener is really
195 // of no use anymore (and is actually actively harmful - see
197 mPreviouslyAttachedWidgetListener
= nullptr;
198 Resize(mBounds
.Width(), mBounds
.Height(), false);
203 void PuppetWidget::Resize(double aWidth
, double aHeight
, bool aRepaint
) {
204 LayoutDeviceIntRect oldBounds
= mBounds
;
206 LayoutDeviceIntSize(NSToIntRound(aWidth
), NSToIntRound(aHeight
)));
209 mChild
->Resize(aWidth
, aHeight
, aRepaint
);
213 // XXX: roc says that |aRepaint| dictates whether or not to
214 // invalidate the expanded area
215 if (oldBounds
.Size() < mBounds
.Size() && aRepaint
) {
216 LayoutDeviceIntRegion
dirty(mBounds
);
217 dirty
.Sub(dirty
, oldBounds
);
218 InvalidateRegion(this, dirty
);
221 // call WindowResized() on both the current listener, and possibly
222 // also the previous one if we're in a state where we're drawing that one
223 // because the current one is paint suppressed
224 if (!oldBounds
.IsEqualEdges(mBounds
) && mAttachedWidgetListener
) {
225 if (GetCurrentWidgetListener() &&
226 GetCurrentWidgetListener() != mAttachedWidgetListener
) {
227 GetCurrentWidgetListener()->WindowResized(this, mBounds
.Width(),
230 mAttachedWidgetListener
->WindowResized(this, mBounds
.Width(),
235 nsresult
PuppetWidget::ConfigureChildren(
236 const nsTArray
<Configuration
>& aConfigurations
) {
237 for (uint32_t i
= 0; i
< aConfigurations
.Length(); ++i
) {
238 const Configuration
& configuration
= aConfigurations
[i
];
239 PuppetWidget
* w
= static_cast<PuppetWidget
*>(configuration
.mChild
.get());
240 NS_ASSERTION(w
->GetParent() == this, "Configured widget is not a child");
241 w
->SetWindowClipRegion(configuration
.mClipRegion
, true);
242 LayoutDeviceIntRect bounds
= w
->GetBounds();
243 if (bounds
.Size() != configuration
.mBounds
.Size()) {
244 w
->Resize(configuration
.mBounds
.X(), configuration
.mBounds
.Y(),
245 configuration
.mBounds
.Width(), configuration
.mBounds
.Height(),
247 } else if (bounds
.TopLeft() != configuration
.mBounds
.TopLeft()) {
248 w
->Move(configuration
.mBounds
.X(), configuration
.mBounds
.Y());
250 w
->SetWindowClipRegion(configuration
.mClipRegion
, false);
255 void PuppetWidget::SetFocus(Raise aRaise
, CallerType aCallerType
) {
256 if (aRaise
== Raise::Yes
&& mBrowserChild
) {
257 mBrowserChild
->SendRequestFocus(true, aCallerType
);
261 void PuppetWidget::Invalidate(const LayoutDeviceIntRect
& aRect
) {
263 debug_DumpInvalidate(stderr
, this, &aRect
, "PuppetWidget", 0);
267 mChild
->Invalidate(aRect
);
271 if (mBrowserChild
&& !aRect
.IsEmpty() && !mWidgetPaintTask
.IsPending()) {
272 mWidgetPaintTask
= new WidgetPaintTask(this);
273 nsCOMPtr
<nsIRunnable
> event(mWidgetPaintTask
.get());
274 SchedulerGroup::Dispatch(TaskCategory::Other
, event
.forget());
278 mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
279 PuppetWidget::WidgetToTopLevelWidgetTransform() {
280 if (!GetOwningBrowserChild()) {
281 NS_WARNING("PuppetWidget without Tab does not have transform information.");
282 return mozilla::LayoutDeviceToLayoutDeviceMatrix4x4();
284 return GetOwningBrowserChild()->GetChildToParentConversionMatrix();
287 void PuppetWidget::InitEvent(WidgetGUIEvent
& aEvent
,
288 LayoutDeviceIntPoint
* aPoint
) {
289 if (nullptr == aPoint
) {
290 aEvent
.mRefPoint
= LayoutDeviceIntPoint(0, 0);
292 // use the point override if provided
293 aEvent
.mRefPoint
= *aPoint
;
295 aEvent
.mTime
= PR_Now() / 1000;
298 nsresult
PuppetWidget::DispatchEvent(WidgetGUIEvent
* aEvent
,
299 nsEventStatus
& aStatus
) {
301 debug_DumpEvent(stdout
, aEvent
->mWidget
, aEvent
, "PuppetWidget", 0);
304 MOZ_ASSERT(!mChild
|| mChild
->mWindowType
== eWindowType_popup
,
305 "Unexpected event dispatch!");
307 MOZ_ASSERT(!aEvent
->AsKeyboardEvent() ||
308 aEvent
->mFlags
.mIsSynthesizedForTests
||
309 aEvent
->AsKeyboardEvent()->AreAllEditCommandsInitialized(),
310 "Non-sysnthesized keyboard events should have edit commands for "
312 "before dispatched");
314 if (aEvent
->mClass
== eCompositionEventClass
) {
315 // If we've already requested to commit/cancel the latest composition,
316 // TextComposition for the old composition has been destroyed. Then,
317 // the DOM tree needs to listen to next eCompositionStart and its
318 // following events. So, until we meet new eCompositionStart, let's
319 // discard all unnecessary composition events here.
320 if (mIgnoreCompositionEvents
) {
321 if (aEvent
->mMessage
!= eCompositionStart
) {
322 aStatus
= nsEventStatus_eIgnore
;
325 // Now, we receive new eCompositionStart. Let's restart to handle
326 // composition in this process.
327 mIgnoreCompositionEvents
= false;
329 // Store the latest native IME context of parent process's widget or
330 // TextEventDispatcher if it's in this process.
331 WidgetCompositionEvent
* compositionEvent
= aEvent
->AsCompositionEvent();
333 if (mNativeIMEContext
.IsValid() &&
334 mNativeIMEContext
!= compositionEvent
->mNativeIMEContext
) {
335 RefPtr
<TextComposition
> composition
=
336 IMEStateManager::GetTextCompositionFor(this);
339 "When there is composition caused by old native IME context, "
340 "composition events caused by different native IME context are not "
343 #endif // #ifdef DEBUG
344 mNativeIMEContext
= compositionEvent
->mNativeIMEContext
;
345 mContentCache
.OnCompositionEvent(*compositionEvent
);
348 // If the event is a composition event or a keyboard event, it should be
349 // dispatched with TextEventDispatcher if we could do that with current
350 // design. However, we cannot do that without big changes and the behavior
351 // is not so complicated for now. Therefore, we should just notify it
352 // of dispatching events and TextEventDispatcher should emulate the state
354 if (aEvent
->mClass
== eCompositionEventClass
||
355 aEvent
->mClass
== eKeyboardEventClass
) {
356 TextEventDispatcher
* dispatcher
= GetTextEventDispatcher();
357 // However, if the event is being dispatched by the text event dispatcher
358 // or, there is native text event dispatcher listener, that means that
359 // native text input event handler is in this process like on Android,
360 // and the event is not synthesized for tests, the event is coming from
361 // the TextEventDispatcher. In these cases, we shouldn't notify
362 // TextEventDispatcher of dispatching the event.
363 if (!dispatcher
->IsDispatchingEvent() &&
364 !(mNativeTextEventDispatcherListener
&&
365 !aEvent
->mFlags
.mIsSynthesizedForTests
)) {
366 DebugOnly
<nsresult
> rv
=
367 dispatcher
->BeginInputTransactionFor(aEvent
, this);
368 NS_WARNING_ASSERTION(
370 "The text event dispatcher should always succeed to start input "
371 "transaction for the event");
375 aStatus
= nsEventStatus_eIgnore
;
377 if (GetCurrentWidgetListener()) {
379 GetCurrentWidgetListener()->HandleEvent(aEvent
, mUseAttachedEvents
);
385 nsEventStatus
PuppetWidget::DispatchInputEvent(WidgetInputEvent
* aEvent
) {
386 if (!AsyncPanZoomEnabled()) {
387 nsEventStatus status
= nsEventStatus_eIgnore
;
388 DispatchEvent(aEvent
, status
);
392 if (!mBrowserChild
) {
393 return nsEventStatus_eIgnore
;
396 switch (aEvent
->mClass
) {
397 case eWheelEventClass
:
398 Unused
<< mBrowserChild
->SendDispatchWheelEvent(*aEvent
->AsWheelEvent());
400 case eMouseEventClass
:
401 Unused
<< mBrowserChild
->SendDispatchMouseEvent(*aEvent
->AsMouseEvent());
403 case eKeyboardEventClass
:
404 Unused
<< mBrowserChild
->SendDispatchKeyboardEvent(
405 *aEvent
->AsKeyboardEvent());
408 MOZ_ASSERT_UNREACHABLE("unsupported event type");
411 return nsEventStatus_eIgnore
;
414 nsresult
PuppetWidget::SynthesizeNativeKeyEvent(
415 int32_t aNativeKeyboardLayout
, int32_t aNativeKeyCode
,
416 uint32_t aModifierFlags
, const nsAString
& aCharacters
,
417 const nsAString
& aUnmodifiedCharacters
, nsIObserver
* aObserver
) {
418 AutoObserverNotifier
notifier(aObserver
, "keyevent");
419 if (!mBrowserChild
) {
420 return NS_ERROR_FAILURE
;
422 mBrowserChild
->SendSynthesizeNativeKeyEvent(
423 aNativeKeyboardLayout
, aNativeKeyCode
, aModifierFlags
,
424 nsString(aCharacters
), nsString(aUnmodifiedCharacters
),
425 notifier
.SaveObserver());
429 nsresult
PuppetWidget::SynthesizeNativeMouseEvent(
430 mozilla::LayoutDeviceIntPoint aPoint
, NativeMouseMessage aNativeMessage
,
431 MouseButton aButton
, nsIWidget::Modifiers aModifierFlags
,
432 nsIObserver
* aObserver
) {
433 AutoObserverNotifier
notifier(aObserver
, "mouseevent");
434 if (!mBrowserChild
) {
435 return NS_ERROR_FAILURE
;
437 mBrowserChild
->SendSynthesizeNativeMouseEvent(
438 aPoint
, static_cast<uint32_t>(aNativeMessage
),
439 static_cast<int16_t>(aButton
), static_cast<uint32_t>(aModifierFlags
),
440 notifier
.SaveObserver());
444 nsresult
PuppetWidget::SynthesizeNativeMouseMove(
445 mozilla::LayoutDeviceIntPoint aPoint
, nsIObserver
* aObserver
) {
446 AutoObserverNotifier
notifier(aObserver
, "mousemove");
447 if (!mBrowserChild
) {
448 return NS_ERROR_FAILURE
;
450 mBrowserChild
->SendSynthesizeNativeMouseMove(aPoint
, notifier
.SaveObserver());
454 nsresult
PuppetWidget::SynthesizeNativeMouseScrollEvent(
455 mozilla::LayoutDeviceIntPoint aPoint
, uint32_t aNativeMessage
,
456 double aDeltaX
, double aDeltaY
, double aDeltaZ
, uint32_t aModifierFlags
,
457 uint32_t aAdditionalFlags
, nsIObserver
* aObserver
) {
458 AutoObserverNotifier
notifier(aObserver
, "mousescrollevent");
459 if (!mBrowserChild
) {
460 return NS_ERROR_FAILURE
;
462 mBrowserChild
->SendSynthesizeNativeMouseScrollEvent(
463 aPoint
, aNativeMessage
, aDeltaX
, aDeltaY
, aDeltaZ
, aModifierFlags
,
464 aAdditionalFlags
, notifier
.SaveObserver());
468 nsresult
PuppetWidget::SynthesizeNativeTouchPoint(
469 uint32_t aPointerId
, TouchPointerState aPointerState
,
470 LayoutDeviceIntPoint aPoint
, double aPointerPressure
,
471 uint32_t aPointerOrientation
, nsIObserver
* aObserver
) {
472 AutoObserverNotifier
notifier(aObserver
, "touchpoint");
473 if (!mBrowserChild
) {
474 return NS_ERROR_FAILURE
;
476 mBrowserChild
->SendSynthesizeNativeTouchPoint(
477 aPointerId
, aPointerState
, aPoint
, aPointerPressure
, aPointerOrientation
,
478 notifier
.SaveObserver());
482 nsresult
PuppetWidget::SynthesizeNativeTouchPadPinch(
483 TouchpadPinchPhase aEventPhase
, float aScale
, LayoutDeviceIntPoint aPoint
,
484 int32_t aModifierFlags
) {
485 if (!mBrowserChild
) {
486 return NS_ERROR_FAILURE
;
488 mBrowserChild
->SendSynthesizeNativeTouchPadPinch(aEventPhase
, aScale
, aPoint
,
493 nsresult
PuppetWidget::SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint
,
495 nsIObserver
* aObserver
) {
496 AutoObserverNotifier
notifier(aObserver
, "touchtap");
497 if (!mBrowserChild
) {
498 return NS_ERROR_FAILURE
;
500 mBrowserChild
->SendSynthesizeNativeTouchTap(aPoint
, aLongTap
,
501 notifier
.SaveObserver());
505 nsresult
PuppetWidget::ClearNativeTouchSequence(nsIObserver
* aObserver
) {
506 AutoObserverNotifier
notifier(aObserver
, "cleartouch");
507 if (!mBrowserChild
) {
508 return NS_ERROR_FAILURE
;
510 mBrowserChild
->SendClearNativeTouchSequence(notifier
.SaveObserver());
514 nsresult
PuppetWidget::SynthesizeNativePenInput(
515 uint32_t aPointerId
, TouchPointerState aPointerState
,
516 LayoutDeviceIntPoint aPoint
, double aPressure
, uint32_t aRotation
,
517 int32_t aTiltX
, int32_t aTiltY
, nsIObserver
* aObserver
) {
518 AutoObserverNotifier
notifier(aObserver
, "peninput");
519 if (!mBrowserChild
) {
520 return NS_ERROR_FAILURE
;
522 mBrowserChild
->SendSynthesizeNativePenInput(aPointerId
, aPointerState
, aPoint
,
523 aPressure
, aRotation
, aTiltX
,
524 aTiltY
, notifier
.SaveObserver());
528 nsresult
PuppetWidget::SynthesizeNativeTouchpadDoubleTap(
529 LayoutDeviceIntPoint aPoint
, uint32_t aModifierFlags
) {
530 if (!mBrowserChild
) {
531 return NS_ERROR_FAILURE
;
533 mBrowserChild
->SendSynthesizeNativeTouchpadDoubleTap(aPoint
, aModifierFlags
);
537 void PuppetWidget::SetConfirmedTargetAPZC(
538 uint64_t aInputBlockId
,
539 const nsTArray
<ScrollableLayerGuid
>& aTargets
) const {
541 mBrowserChild
->SetTargetAPZC(aInputBlockId
, aTargets
);
545 void PuppetWidget::UpdateZoomConstraints(
546 const uint32_t& aPresShellId
, const ScrollableLayerGuid::ViewID
& aViewId
,
547 const Maybe
<ZoomConstraints
>& aConstraints
) {
549 mBrowserChild
->DoUpdateZoomConstraints(aPresShellId
, aViewId
, aConstraints
);
553 bool PuppetWidget::AsyncPanZoomEnabled() const {
554 return mBrowserChild
&& mBrowserChild
->AsyncPanZoomEnabled();
557 bool PuppetWidget::GetEditCommands(NativeKeyBindingsType aType
,
558 const WidgetKeyboardEvent
& aEvent
,
559 nsTArray
<CommandInt
>& aCommands
) {
560 MOZ_ASSERT(!aEvent
.mFlags
.mIsSynthesizedForTests
);
561 // Validate the arguments.
562 if (NS_WARN_IF(!nsIWidget::GetEditCommands(aType
, aEvent
, aCommands
))) {
565 if (NS_WARN_IF(!mBrowserChild
)) {
568 mBrowserChild
->RequestEditCommands(aType
, aEvent
, aCommands
);
572 LayerManager
* PuppetWidget::GetLayerManager(
573 PLayerTransactionChild
* aShadowManager
, LayersBackend aBackendHint
,
574 LayerManagerPersistence aPersistence
) {
575 if (!mLayerManager
) {
576 if (XRE_IsParentProcess()) {
577 // On the parent process there is no CompositorBridgeChild which confuses
578 // some layers code, so we use basic layers instead. Note that we create
579 // a non-retaining layer manager since we don't care about performance.
580 mLayerManager
= new BasicLayerManager(BasicLayerManager::BLM_OFFSCREEN
);
581 return mLayerManager
;
584 // If we know for sure that the parent side of this BrowserChild is not
585 // connected to the compositor, we don't want to use a "remote" layer
586 // manager like WebRender or Client. Instead we use a Basic one which
587 // can do drawing in this process.
588 MOZ_ASSERT(!mBrowserChild
||
589 mBrowserChild
->IsLayersConnected() != Some(true));
590 mLayerManager
= new BasicLayerManager(this);
593 return mLayerManager
;
596 bool PuppetWidget::CreateRemoteLayerManager(
597 const std::function
<bool(LayerManager
*)>& aInitializeFunc
) {
598 RefPtr
<LayerManager
> lm
;
599 MOZ_ASSERT(mBrowserChild
);
600 if (mBrowserChild
->GetCompositorOptions().UseWebRender()) {
601 lm
= new WebRenderLayerManager(this);
603 lm
= new ClientLayerManager(this);
606 if (!aInitializeFunc(lm
)) {
610 // Force the old LM to self destruct, otherwise if the reference dangles we
611 // could fail to revoke the most recent transaction. We only want to replace
612 // it if we successfully create its successor because a partially initialized
613 // layer manager is worse than a fully initialized but shutdown layer manager.
614 DestroyLayerManager();
615 mLayerManager
= std::move(lm
);
619 nsresult
PuppetWidget::RequestIMEToCommitComposition(bool aCancel
) {
620 if (!mBrowserChild
) {
621 return NS_ERROR_FAILURE
;
624 MOZ_ASSERT(!Destroyed());
626 // There must not be composition which is caused by the PuppetWidget instance.
627 if (NS_WARN_IF(!mNativeIMEContext
.IsValid())) {
631 // We've already requested to commit/cancel composition.
632 if (NS_WARN_IF(mIgnoreCompositionEvents
)) {
634 RefPtr
<TextComposition
> composition
=
635 IMEStateManager::GetTextCompositionFor(this);
636 MOZ_ASSERT(!composition
);
637 #endif // #ifdef DEBUG
641 RefPtr
<TextComposition
> composition
=
642 IMEStateManager::GetTextCompositionFor(this);
643 // This method shouldn't be called when there is no text composition instance.
644 if (NS_WARN_IF(!composition
)) {
648 MOZ_DIAGNOSTIC_ASSERT(
649 composition
->IsRequestingCommitOrCancelComposition(),
650 "Requesting commit or cancel composition should be requested via "
651 "TextComposition instance");
653 bool isCommitted
= false;
654 nsAutoString committedString
;
655 if (NS_WARN_IF(!mBrowserChild
->SendRequestIMEToCommitComposition(
656 aCancel
, &isCommitted
, &committedString
))) {
657 return NS_ERROR_FAILURE
;
660 // If the composition wasn't committed synchronously, we need to wait async
661 // composition events for destroying the TextComposition instance.
666 // Dispatch eCompositionCommit event.
667 WidgetCompositionEvent
compositionCommitEvent(true, eCompositionCommit
, this);
668 InitEvent(compositionCommitEvent
, nullptr);
669 compositionCommitEvent
.mData
= committedString
;
670 nsEventStatus status
= nsEventStatus_eIgnore
;
671 DispatchEvent(&compositionCommitEvent
, status
);
674 RefPtr
<TextComposition
> currentComposition
=
675 IMEStateManager::GetTextCompositionFor(this);
676 MOZ_ASSERT(!currentComposition
);
677 #endif // #ifdef DEBUG
679 // Ignore the following composition events until we receive new
680 // eCompositionStart event.
681 mIgnoreCompositionEvents
= true;
683 Unused
<< mBrowserChild
->SendOnEventNeedingAckHandled(
684 eCompositionCommitRequestHandled
);
686 // NOTE: PuppetWidget might be destroyed already.
690 // When this widget caches input context and currently managed by
691 // IMEStateManager, the cache is valid.
692 bool PuppetWidget::HaveValidInputContextCache() const {
693 return (mInputContext
.mIMEState
.mEnabled
!= IMEEnabled::Unknown
&&
694 IMEStateManager::GetWidgetForActiveInputContext() == this);
697 nsRefreshDriver
* PuppetWidget::GetTopLevelRefreshDriver() const {
698 if (!mBrowserChild
) {
702 if (PresShell
* presShell
= mBrowserChild
->GetTopLevelPresShell()) {
703 return presShell
->GetRefreshDriver();
709 void PuppetWidget::SetInputContext(const InputContext
& aContext
,
710 const InputContextAction
& aAction
) {
711 mInputContext
= aContext
;
712 // Any widget instances cannot cache IME open state because IME open state
713 // can be changed by user but native IME may not notify us of changing the
714 // open state on some platforms.
715 mInputContext
.mIMEState
.mOpen
= IMEState::OPEN_STATE_NOT_SUPPORTED
;
716 if (!mBrowserChild
) {
719 mBrowserChild
->SendSetInputContext(aContext
, aAction
);
722 InputContext
PuppetWidget::GetInputContext() {
723 // XXX Currently, we don't support retrieving IME open state from child
726 // If the cache of input context is valid, we can avoid to use synchronous
728 if (HaveValidInputContextCache()) {
729 return mInputContext
;
732 NS_WARNING("PuppetWidget::GetInputContext() needs to retrieve it with IPC");
734 // Don't cache InputContext here because this process isn't managing IME
735 // state of the chrome widget. So, we cannot modify mInputContext when
736 // chrome widget is set to new context.
737 InputContext context
;
739 mBrowserChild
->SendGetInputContext(&context
.mIMEState
);
744 NativeIMEContext
PuppetWidget::GetNativeIMEContext() {
745 return mNativeIMEContext
;
748 nsresult
PuppetWidget::NotifyIMEOfFocusChange(
749 const IMENotification
& aIMENotification
) {
750 MOZ_ASSERT(IMEStateManager::CanSendNotificationToWidget());
752 if (!mBrowserChild
) {
753 return NS_ERROR_FAILURE
;
756 bool gotFocus
= aIMENotification
.mMessage
== NOTIFY_IME_OF_FOCUS
;
758 // When IME gets focus, we should initialize all information of the
760 if (NS_WARN_IF(!mContentCache
.CacheAll(this, &aIMENotification
))) {
761 return NS_ERROR_FAILURE
;
764 // When IME loses focus, we don't need to store anything.
765 mContentCache
.Clear();
768 mIMENotificationRequestsOfParent
=
769 IMENotificationRequests(IMENotificationRequests::NOTIFY_ALL
);
770 RefPtr
<PuppetWidget
> self
= this;
771 mBrowserChild
->SendNotifyIMEFocus(mContentCache
, aIMENotification
)
773 GetMainThreadSerialEventTarget(), __func__
,
774 [self
](IMENotificationRequests
&& aRequests
) {
775 self
->mIMENotificationRequestsOfParent
= aRequests
;
776 if (TextEventDispatcher
* dispatcher
=
777 self
->GetTextEventDispatcher()) {
778 dispatcher
->OnWidgetChangeIMENotificationRequests(self
);
781 [self
](mozilla::ipc::ResponseRejectReason
&& aReason
) {
782 NS_WARNING("SendNotifyIMEFocus got rejected.");
788 nsresult
PuppetWidget::NotifyIMEOfCompositionUpdate(
789 const IMENotification
& aIMENotification
) {
790 MOZ_ASSERT(IMEStateManager::CanSendNotificationToWidget());
792 if (NS_WARN_IF(!mBrowserChild
)) {
793 return NS_ERROR_FAILURE
;
796 if (NS_WARN_IF(!mContentCache
.CacheSelection(this, &aIMENotification
))) {
797 return NS_ERROR_FAILURE
;
799 mBrowserChild
->SendNotifyIMECompositionUpdate(mContentCache
,
804 nsresult
PuppetWidget::NotifyIMEOfTextChange(
805 const IMENotification
& aIMENotification
) {
806 MOZ_ASSERT(IMEStateManager::CanSendNotificationToWidget());
807 MOZ_ASSERT(aIMENotification
.mMessage
== NOTIFY_IME_OF_TEXT_CHANGE
,
808 "Passed wrong notification");
810 if (!mBrowserChild
) {
811 return NS_ERROR_FAILURE
;
814 // FYI: text change notification is the first notification after
815 // a user operation changes the content. So, we need to modify
816 // the cache as far as possible here.
818 if (NS_WARN_IF(!mContentCache
.CacheText(this, &aIMENotification
))) {
819 return NS_ERROR_FAILURE
;
822 // BrowserParent doesn't this this to cache. we don't send the notification
823 // if parent process doesn't request NOTIFY_TEXT_CHANGE.
824 if (mIMENotificationRequestsOfParent
.WantTextChange()) {
825 mBrowserChild
->SendNotifyIMETextChange(mContentCache
, aIMENotification
);
827 mBrowserChild
->SendUpdateContentCache(mContentCache
);
832 nsresult
PuppetWidget::NotifyIMEOfSelectionChange(
833 const IMENotification
& aIMENotification
) {
834 MOZ_ASSERT(IMEStateManager::CanSendNotificationToWidget());
835 MOZ_ASSERT(aIMENotification
.mMessage
== NOTIFY_IME_OF_SELECTION_CHANGE
,
836 "Passed wrong notification");
837 if (!mBrowserChild
) {
838 return NS_ERROR_FAILURE
;
841 // Note that selection change must be notified after text change if it occurs.
842 // Therefore, we don't need to query text content again here.
843 mContentCache
.SetSelection(
844 this, aIMENotification
.mSelectionChangeData
.mOffset
,
845 aIMENotification
.mSelectionChangeData
.Length(),
846 aIMENotification
.mSelectionChangeData
.mReversed
,
847 aIMENotification
.mSelectionChangeData
.GetWritingMode());
849 mBrowserChild
->SendNotifyIMESelection(mContentCache
, aIMENotification
);
854 nsresult
PuppetWidget::NotifyIMEOfMouseButtonEvent(
855 const IMENotification
& aIMENotification
) {
856 MOZ_ASSERT(IMEStateManager::CanSendNotificationToWidget());
857 if (!mBrowserChild
) {
858 return NS_ERROR_FAILURE
;
861 bool consumedByIME
= false;
862 if (!mBrowserChild
->SendNotifyIMEMouseButtonEvent(aIMENotification
,
864 return NS_ERROR_FAILURE
;
867 return consumedByIME
? NS_SUCCESS_EVENT_CONSUMED
: NS_OK
;
870 nsresult
PuppetWidget::NotifyIMEOfPositionChange(
871 const IMENotification
& aIMENotification
) {
872 MOZ_ASSERT(IMEStateManager::CanSendNotificationToWidget());
873 if (NS_WARN_IF(!mBrowserChild
)) {
874 return NS_ERROR_FAILURE
;
877 if (NS_WARN_IF(!mContentCache
.CacheEditorRect(this, &aIMENotification
))) {
878 return NS_ERROR_FAILURE
;
880 if (NS_WARN_IF(!mContentCache
.CacheSelection(this, &aIMENotification
))) {
881 return NS_ERROR_FAILURE
;
883 if (mIMENotificationRequestsOfParent
.WantPositionChanged()) {
884 mBrowserChild
->SendNotifyIMEPositionChange(mContentCache
, aIMENotification
);
886 mBrowserChild
->SendUpdateContentCache(mContentCache
);
891 struct CursorSurface
{
892 UniquePtr
<char[]> mData
;
896 void PuppetWidget::SetCursor(nsCursor aCursor
, imgIContainer
* aCursorImage
,
897 uint32_t aHotspotX
, uint32_t aHotspotY
) {
898 if (!mBrowserChild
) {
902 // Don't cache on windows, Windowless flash breaks this via async cursor
905 if (!mUpdateCursor
&& mCursor
== aCursor
&& mCustomCursor
== aCursorImage
&&
907 (mCursorHotspotX
== aHotspotX
&& mCursorHotspotY
== aHotspotY
))) {
912 bool hasCustomCursor
= false;
913 UniquePtr
<char[]> customCursorData
;
915 IntSize customCursorSize
;
917 auto format
= SurfaceFormat::B8G8R8A8
;
918 bool force
= mUpdateCursor
;
921 RefPtr
<SourceSurface
> surface
= aCursorImage
->GetFrame(
922 imgIContainer::FRAME_CURRENT
,
923 imgIContainer::FLAG_SYNC_DECODE
| imgIContainer::FLAG_ASYNC_NOTIFY
);
925 if (RefPtr
<DataSourceSurface
> dataSurface
= surface
->GetDataSurface()) {
926 hasCustomCursor
= true;
927 customCursorData
= nsContentUtils::GetSurfaceData(
928 WrapNotNull(dataSurface
), &length
, &stride
);
929 customCursorSize
= dataSurface
->GetSize();
930 format
= dataSurface
->GetFormat();
935 mCustomCursor
= nullptr;
937 nsDependentCString
cursorData(customCursorData
? customCursorData
.get() : "",
939 if (!mBrowserChild
->SendSetCursor(aCursor
, hasCustomCursor
, cursorData
,
940 customCursorSize
.width
,
941 customCursorSize
.height
, stride
, format
,
942 aHotspotX
, aHotspotY
, force
)) {
947 mCustomCursor
= aCursorImage
;
948 mCursorHotspotX
= aHotspotX
;
949 mCursorHotspotY
= aHotspotY
;
950 mUpdateCursor
= false;
953 void PuppetWidget::ClearCachedCursor() {
954 nsBaseWidget::ClearCachedCursor();
955 mCustomCursor
= nullptr;
958 void PuppetWidget::SetChild(PuppetWidget
* aChild
) {
959 MOZ_ASSERT(this != aChild
, "can't parent a widget to itself");
960 MOZ_ASSERT(!aChild
->mChild
,
961 "fake widget 'hierarchy' only expected to have one level");
967 PuppetWidget::WidgetPaintTask::Run() {
974 void PuppetWidget::Paint() {
975 if (!GetCurrentWidgetListener()) return;
977 mWidgetPaintTask
.Revoke();
979 RefPtr
<PuppetWidget
> strongThis(this);
981 GetCurrentWidgetListener()->WillPaintWindow(this);
983 if (GetCurrentWidgetListener()) {
984 GetCurrentWidgetListener()->DidPaintWindow();
988 void PuppetWidget::PaintNowIfNeeded() {
989 if (IsVisible() && mWidgetPaintTask
.IsPending()) {
994 void PuppetWidget::OnMemoryPressure(layers::MemoryPressureReason aWhy
) {
995 if (aWhy
!= MemoryPressureReason::LOW_MEMORY_ONGOING
&& !mVisible
&&
996 mLayerManager
&& XRE_IsContentProcess()) {
997 mLayerManager
->ClearCachedResources();
1001 bool PuppetWidget::NeedsPaint() {
1002 // e10s popups are handled by the parent process, so never should be painted
1004 if (XRE_IsContentProcess() &&
1005 StaticPrefs::browser_tabs_remote_desktopbehavior() &&
1006 mWindowType
== eWindowType_popup
) {
1007 NS_WARNING("Trying to paint an e10s popup in the child process!");
1014 float PuppetWidget::GetDPI() { return mDPI
; }
1016 double PuppetWidget::GetDefaultScaleInternal() { return mDefaultScale
; }
1018 int32_t PuppetWidget::RoundsWidgetCoordinatesTo() { return mRounding
; }
1020 void* PuppetWidget::GetNativeData(uint32_t aDataType
) {
1021 switch (aDataType
) {
1022 case NS_NATIVE_SHAREABLE_WINDOW
: {
1023 // NOTE: We can not have a tab child in some situations, such as when
1024 // we're rendering to a fake widget for thumbnails.
1025 if (!mBrowserChild
) {
1026 NS_WARNING("Need BrowserChild to get the nativeWindow from!");
1028 mozilla::WindowsHandle nativeData
= 0;
1029 if (mBrowserChild
) {
1030 nativeData
= mBrowserChild
->WidgetNativeData();
1032 return (void*)nativeData
;
1034 case NS_NATIVE_WINDOW
:
1035 case NS_NATIVE_WIDGET
:
1036 case NS_NATIVE_DISPLAY
:
1037 // These types are ignored (see bug 1183828, bug 1240891).
1039 case NS_RAW_NATIVE_IME_CONTEXT
:
1040 MOZ_CRASH("You need to call GetNativeIMEContext() instead");
1041 case NS_NATIVE_PLUGIN_PORT
:
1042 case NS_NATIVE_GRAPHIC
:
1043 case NS_NATIVE_SHELLWIDGET
:
1045 NS_WARNING("nsWindow::GetNativeData called with bad value");
1052 void PuppetWidget::SetNativeData(uint32_t aDataType
, uintptr_t aVal
) {
1053 switch (aDataType
) {
1054 case NS_NATIVE_CHILD_OF_SHAREABLE_WINDOW
:
1055 MOZ_ASSERT(mBrowserChild
, "Need BrowserChild to send the message.");
1056 if (mBrowserChild
) {
1057 mBrowserChild
->SendSetNativeChildOfShareableWindow(aVal
);
1061 NS_WARNING("SetNativeData called with unsupported data type.");
1066 LayoutDeviceIntPoint
PuppetWidget::GetChromeOffset() {
1067 if (!GetOwningBrowserChild()) {
1068 NS_WARNING("PuppetWidget without Tab does not have chrome information.");
1069 return LayoutDeviceIntPoint();
1071 return GetOwningBrowserChild()->GetChromeOffset();
1074 LayoutDeviceIntPoint
PuppetWidget::WidgetToScreenOffset() {
1075 auto positionRalativeToWindow
=
1076 WidgetToTopLevelWidgetTransform().TransformPoint(LayoutDevicePoint());
1078 return GetWindowPosition() +
1079 LayoutDeviceIntPoint::Round(positionRalativeToWindow
);
1082 LayoutDeviceIntPoint
PuppetWidget::GetWindowPosition() {
1083 if (!GetOwningBrowserChild()) {
1084 return LayoutDeviceIntPoint();
1087 int32_t winX
, winY
, winW
, winH
;
1089 GetOwningBrowserChild()->GetDimensions(0, &winX
, &winY
, &winW
, &winH
),
1090 LayoutDeviceIntPoint());
1091 return LayoutDeviceIntPoint(winX
, winY
) +
1092 GetOwningBrowserChild()->GetClientOffset();
1095 LayoutDeviceIntRect
PuppetWidget::GetScreenBounds() {
1096 return LayoutDeviceIntRect(WidgetToScreenOffset(), mBounds
.Size());
1099 uint32_t PuppetWidget::GetMaxTouchPoints() const {
1100 return mBrowserChild
? mBrowserChild
->MaxTouchPoints() : 0;
1103 void PuppetWidget::StartAsyncScrollbarDrag(
1104 const AsyncDragMetrics
& aDragMetrics
) {
1105 mBrowserChild
->StartScrollbarDrag(aDragMetrics
);
1108 PuppetScreen::PuppetScreen(void* nativeScreen
) {}
1110 PuppetScreen::~PuppetScreen() = default;
1112 static ScreenConfiguration
ScreenConfig() {
1113 ScreenConfiguration config
;
1114 hal::GetCurrentScreenConfiguration(&config
);
1118 nsIntSize
PuppetWidget::GetScreenDimensions() {
1119 nsIntRect r
= ScreenConfig().rect();
1120 return nsIntSize(r
.Width(), r
.Height());
1124 PuppetScreen::GetRect(int32_t* outLeft
, int32_t* outTop
, int32_t* outWidth
,
1125 int32_t* outHeight
) {
1126 nsIntRect r
= ScreenConfig().rect();
1127 r
.GetRect(outLeft
, outTop
, outWidth
, outHeight
);
1132 PuppetScreen::GetAvailRect(int32_t* outLeft
, int32_t* outTop
, int32_t* outWidth
,
1133 int32_t* outHeight
) {
1134 return GetRect(outLeft
, outTop
, outWidth
, outHeight
);
1138 PuppetScreen::GetPixelDepth(int32_t* aPixelDepth
) {
1139 *aPixelDepth
= ScreenConfig().pixelDepth();
1144 PuppetScreen::GetColorDepth(int32_t* aColorDepth
) {
1145 *aColorDepth
= ScreenConfig().colorDepth();
1149 NS_IMPL_ISUPPORTS(PuppetScreenManager
, nsIScreenManager
)
1151 PuppetScreenManager::PuppetScreenManager() {
1152 mOneScreen
= new PuppetScreen(nullptr);
1155 PuppetScreenManager::~PuppetScreenManager() = default;
1158 PuppetScreenManager::GetPrimaryScreen(nsIScreen
** outScreen
) {
1159 NS_IF_ADDREF(*outScreen
= mOneScreen
.get());
1164 PuppetScreenManager::GetTotalScreenPixels(int64_t* aTotalScreenPixels
) {
1165 MOZ_ASSERT(aTotalScreenPixels
);
1167 int32_t x
, y
, width
, height
;
1168 x
= y
= width
= height
= 0;
1169 mOneScreen
->GetRect(&x
, &y
, &width
, &height
);
1170 *aTotalScreenPixels
= width
* height
;
1172 *aTotalScreenPixels
= 0;
1178 PuppetScreenManager::ScreenForRect(int32_t inLeft
, int32_t inTop
,
1179 int32_t inWidth
, int32_t inHeight
,
1180 nsIScreen
** outScreen
) {
1181 return GetPrimaryScreen(outScreen
);
1184 ScreenIntMargin
PuppetWidget::GetSafeAreaInsets() const {
1185 return mSafeAreaInsets
;
1188 void PuppetWidget::UpdateSafeAreaInsets(
1189 const ScreenIntMargin
& aSafeAreaInsets
) {
1190 mSafeAreaInsets
= aSafeAreaInsets
;
1193 nsIWidgetListener
* PuppetWidget::GetCurrentWidgetListener() {
1194 if (!mPreviouslyAttachedWidgetListener
|| !mAttachedWidgetListener
) {
1195 return mAttachedWidgetListener
;
1198 if (mAttachedWidgetListener
->GetView()->IsPrimaryFramePaintSuppressed()) {
1199 return mPreviouslyAttachedWidgetListener
;
1202 return mAttachedWidgetListener
;
1205 void PuppetWidget::ZoomToRect(const uint32_t& aPresShellId
,
1206 const ScrollableLayerGuid::ViewID
& aViewId
,
1207 const CSSRect
& aRect
, const uint32_t& aFlags
) {
1208 if (!mBrowserChild
) {
1212 mBrowserChild
->ZoomToRect(aPresShellId
, aViewId
, aRect
, aFlags
);
1215 void PuppetWidget::LookUpDictionary(
1216 const nsAString
& aText
, const nsTArray
<mozilla::FontRange
>& aFontRangeArray
,
1217 const bool aIsVertical
, const LayoutDeviceIntPoint
& aPoint
) {
1218 if (!mBrowserChild
) {
1222 mBrowserChild
->SendLookUpDictionary(nsString(aText
), aFontRangeArray
,
1223 aIsVertical
, aPoint
);
1226 bool PuppetWidget::HasPendingInputEvent() {
1227 if (!mBrowserChild
) {
1233 mBrowserChild
->GetIPCChannel()->PeekMessages(
1234 [&ret
](const IPC::Message
& aMsg
) -> bool {
1235 if (nsContentUtils::IsMessageInputEvent(aMsg
)) {
1237 return false; // Stop peeking.
1245 // TextEventDispatcherListener
1248 PuppetWidget::NotifyIME(TextEventDispatcher
* aTextEventDispatcher
,
1249 const IMENotification
& aIMENotification
) {
1250 MOZ_ASSERT(aTextEventDispatcher
== mTextEventDispatcher
);
1252 // If there is different text event dispatcher listener for handling
1253 // text event dispatcher, that means that native keyboard events and
1254 // IME events are handled in this process. Therefore, we don't need
1255 // to send any requests and notifications to the parent process.
1256 if (mNativeTextEventDispatcherListener
) {
1257 return NS_ERROR_NOT_IMPLEMENTED
;
1260 switch (aIMENotification
.mMessage
) {
1261 case REQUEST_TO_COMMIT_COMPOSITION
:
1262 return RequestIMEToCommitComposition(false);
1263 case REQUEST_TO_CANCEL_COMPOSITION
:
1264 return RequestIMEToCommitComposition(true);
1265 case NOTIFY_IME_OF_FOCUS
:
1266 case NOTIFY_IME_OF_BLUR
:
1267 return NotifyIMEOfFocusChange(aIMENotification
);
1268 case NOTIFY_IME_OF_SELECTION_CHANGE
:
1269 return NotifyIMEOfSelectionChange(aIMENotification
);
1270 case NOTIFY_IME_OF_TEXT_CHANGE
:
1271 return NotifyIMEOfTextChange(aIMENotification
);
1272 case NOTIFY_IME_OF_COMPOSITION_EVENT_HANDLED
:
1273 return NotifyIMEOfCompositionUpdate(aIMENotification
);
1274 case NOTIFY_IME_OF_MOUSE_BUTTON_EVENT
:
1275 return NotifyIMEOfMouseButtonEvent(aIMENotification
);
1276 case NOTIFY_IME_OF_POSITION_CHANGE
:
1277 return NotifyIMEOfPositionChange(aIMENotification
);
1279 return NS_ERROR_NOT_IMPLEMENTED
;
1282 return NS_ERROR_NOT_IMPLEMENTED
;
1285 NS_IMETHODIMP_(IMENotificationRequests
)
1286 PuppetWidget::GetIMENotificationRequests() {
1287 return IMENotificationRequests(
1288 mIMENotificationRequestsOfParent
.mWantUpdates
|
1289 IMENotificationRequests::NOTIFY_TEXT_CHANGE
|
1290 IMENotificationRequests::NOTIFY_POSITION_CHANGE
);
1293 NS_IMETHODIMP_(void)
1294 PuppetWidget::OnRemovedFrom(TextEventDispatcher
* aTextEventDispatcher
) {
1295 MOZ_ASSERT(aTextEventDispatcher
== mTextEventDispatcher
);
1298 NS_IMETHODIMP_(void)
1299 PuppetWidget::WillDispatchKeyboardEvent(
1300 TextEventDispatcher
* aTextEventDispatcher
,
1301 WidgetKeyboardEvent
& aKeyboardEvent
, uint32_t aIndexOfKeypress
,
1303 MOZ_ASSERT(aTextEventDispatcher
== mTextEventDispatcher
);
1306 nsresult
PuppetWidget::SetSystemFont(const nsCString
& aFontName
) {
1307 if (!mBrowserChild
) {
1308 return NS_ERROR_FAILURE
;
1311 mBrowserChild
->SendSetSystemFont(aFontName
);
1315 nsresult
PuppetWidget::GetSystemFont(nsCString
& aFontName
) {
1316 if (!mBrowserChild
) {
1317 return NS_ERROR_FAILURE
;
1319 mBrowserChild
->SendGetSystemFont(&aFontName
);
1323 } // namespace widget
1324 } // namespace mozilla