@@ -140,11 +140,6 @@ public partial class ChromiumWebBrowser : Control, IRenderWebBrowser, IWpfWebBro
140
140
/// </summary>
141
141
private static bool DesignMode ;
142
142
143
- /// <summary>
144
- /// The class that coordinates the positioning of the dropdown if wanted.
145
- /// </summary>
146
- private IMouseAdjustor mouseAdjustor ;
147
-
148
143
// https://github.com/chromiumembedded/cef/issues/3427
149
144
private bool resizeHackIgnoreOnPaint ;
150
145
private Structs . Size ? resizeHackSize ;
@@ -155,6 +150,11 @@ public partial class ChromiumWebBrowser : Control, IRenderWebBrowser, IWpfWebBro
155
150
/// </summary>
156
151
private bool initialFocus ;
157
152
153
+ /// <summary>
154
+ /// The class that coordinates the positioning of the dropdown if wanted.
155
+ /// </summary>
156
+ internal IMousePositionTransform MousePositionTransform { get ; set ; }
157
+
158
158
/// <summary>
159
159
/// When enabled the browser will resize by 1px when it becomes visible to workaround
160
160
/// the upstream issue
@@ -489,14 +489,6 @@ public ChromiumWebBrowser()
489
489
{
490
490
NoInliningConstructor ( ) ;
491
491
}
492
-
493
- bool adjust = true ;
494
-
495
- if ( adjust )
496
- this . mouseAdjustor = new MouseAdjustor ( ) ;
497
-
498
- else
499
- this . mouseAdjustor = new NoMouseAdjustor ( ) ;
500
492
}
501
493
502
494
/// <summary>
@@ -626,6 +618,7 @@ private void NoInliningConstructor()
626
618
PresentationSource . AddSourceChangedHandler ( this , PresentationSourceChangedHandler ) ;
627
619
628
620
MenuHandler = new ContextMenuHandler ( ) ;
621
+ MousePositionTransform = new NoOpMousePositionTransform ( ) ;
629
622
630
623
UseLayoutRounding = true ;
631
624
}
@@ -1053,7 +1046,7 @@ protected virtual void OnPopupShow(bool isOpen)
1053
1046
UiThreadRunAsync ( ( ) =>
1054
1047
{
1055
1048
popupImage . Visibility = isOpen ? Visibility . Visible : Visibility . Hidden ;
1056
- mouseAdjustor . OnPopupShow ( isOpen ) ;
1049
+ MousePositionTransform . OnPopupShow ( isOpen ) ;
1057
1050
} ) ;
1058
1051
}
1059
1052
@@ -2125,7 +2118,7 @@ private void SetPopupSizeAndPositionImpl(Rect rect)
2125
2118
popupImage . Width = rect . Width ;
2126
2119
popupImage . Height = rect . Height ;
2127
2120
2128
- Point point = this . mouseAdjustor . UpdatePopupSizeAndPosition ( rect , this . viewRect ) ;
2121
+ var point = MousePositionTransform . UpdatePopupSizeAndPosition ( rect , viewRect ) ;
2129
2122
2130
2123
Canvas . SetLeft ( popupImage , point . X ) ;
2131
2124
Canvas . SetTop ( popupImage , point . Y ) ;
@@ -2295,8 +2288,8 @@ protected override void OnMouseMove(MouseEventArgs e)
2295
2288
var point = e . GetPosition ( this ) ;
2296
2289
var modifiers = e . GetModifiers ( ) ;
2297
2290
2298
- var adjustedPoint = mouseAdjustor . GetAdjustedMouseCoords ( point ) ;
2299
- browser . GetHost ( ) . SendMouseMoveEvent ( adjustedPoint . X , adjustedPoint . Y , false , modifiers ) ;
2291
+ MousePositionTransform . TransformMousePoint ( ref point ) ;
2292
+ browser . GetHost ( ) . SendMouseMoveEvent ( ( int ) point . X , ( int ) point . Y , false , modifiers ) ;
2300
2293
}
2301
2294
2302
2295
base . OnMouseMove ( e ) ;
@@ -2313,11 +2306,11 @@ protected override void OnMouseWheel(MouseWheelEventArgs e)
2313
2306
var point = e . GetPosition ( this ) ;
2314
2307
var modifiers = e . GetModifiers ( ) ;
2315
2308
var isShiftKeyDown = Keyboard . IsKeyDown ( Key . LeftShift ) || Keyboard . IsKeyDown ( Key . RightShift ) ;
2316
- var adjustedPoint = mouseAdjustor . GetAdjustedMouseCoords ( point ) ;
2309
+ MousePositionTransform . TransformMousePoint ( ref point ) ;
2317
2310
2318
2311
browser . SendMouseWheelEvent (
2319
- adjustedPoint . X ,
2320
- adjustedPoint . Y ,
2312
+ ( int ) point . X ,
2313
+ ( int ) point . Y ,
2321
2314
deltaX : isShiftKeyDown ? e . Delta : 0 ,
2322
2315
deltaY : ! isShiftKeyDown ? e . Delta : 0 ,
2323
2316
modifiers : modifiers ) ;
@@ -2467,11 +2460,9 @@ private void OnMouseButton(MouseButtonEventArgs e)
2467
2460
{
2468
2461
clickCount = 1 ;
2469
2462
}
2470
-
2471
2463
2472
- var adjustedPoint = mouseAdjustor . GetAdjustedMouseCoords ( point ) ;
2473
- browser . GetHost ( ) . SendMouseClickEvent ( adjustedPoint . X , adjustedPoint . Y , ( MouseButtonType ) e . ChangedButton , mouseUp , clickCount , modifiers ) ;
2474
- // browser.GetHost().SendMouseClickEvent(mouseTeleport.originalRect.X + mouseTeleport.originalRect.Width, (int)point.Y, (MouseButtonType)e.ChangedButton, mouseUp, clickCount, modifiers);
2464
+ MousePositionTransform . TransformMousePoint ( ref point ) ;
2465
+ browser . GetHost ( ) . SendMouseClickEvent ( ( int ) point . X , ( int ) point . Y , ( MouseButtonType ) e . ChangedButton , mouseUp , clickCount , modifiers ) ;
2475
2466
}
2476
2467
2477
2468
e . Handled = true ;
0 commit comments