3030*/
3131import org .cef .CefClient ;
3232import org .cef .callback .CefDragData ;
33+ import org .cef .handler .CefRenderHandlerAdapter ;
3334import org .cef .handler .CefRenderHandler ;
3435
3536import java .awt .Component ;
6162 * The visibility of this class is "package". To create a new
6263 * CefBrowser instance, please use CefBrowserFactory.
6364 */
64- public class CN1CefBrowser extends CefBrowser_N implements CefRenderHandler {
65+ public class CN1CefBrowser extends CefBrowser_N {
6566 //private CefRenderer renderer_;
6667 //private GLCanvas canvas_;
6768 private long window_handle_ = 0 ;
@@ -72,6 +73,47 @@ public class CN1CefBrowser extends CefBrowser_N implements CefRenderHandler {
7273 //private BufferedImage bufferedImage_;
7374 private WeakReference <PixelBuffer > bufferRef ;
7475 private byte [] buf_ ;
76+ private final CefRenderHandler renderHandler_ = new CefRenderHandlerAdapter () {
77+ @ Override
78+ public Rectangle getViewRect (CefBrowser browser ) {
79+ return CN1CefBrowser .this .getViewRectImpl (browser );
80+ }
81+
82+ @ Override
83+ public boolean getScreenInfo (CefBrowser browser , CefScreenInfo screenInfo ) {
84+ return CN1CefBrowser .this .getScreenInfoImpl (browser , screenInfo );
85+ }
86+
87+ @ Override
88+ public Point getScreenPoint (CefBrowser browser , Point viewPoint ) {
89+ return CN1CefBrowser .this .getScreenPointImpl (browser , viewPoint );
90+ }
91+
92+ @ Override
93+ public void onPopupShow (CefBrowser browser , boolean show ) {
94+ CN1CefBrowser .this .onPopupShowImpl (browser , show );
95+ }
96+
97+ @ Override
98+ public void onPopupSize (CefBrowser browser , Rectangle size ) {
99+ CN1CefBrowser .this .onPopupSizeImpl (browser , size );
100+ }
101+
102+ @ Override
103+ public void onPaint (CefBrowser browser , boolean popup , Rectangle [] dirtyRects , ByteBuffer buffer , int width , int height ) {
104+ CN1CefBrowser .this .onPaintImpl (browser , popup , dirtyRects , buffer , width , height );
105+ }
106+
107+ @ Override
108+ public boolean startDragging (CefBrowser browser , CefDragData dragData , int mask , int x , int y ) {
109+ return CN1CefBrowser .this .startDraggingImpl (browser , dragData , mask , x , y );
110+ }
111+
112+ @ Override
113+ public void updateDragCursor (CefBrowser browser , int operation ) {
114+ CN1CefBrowser .this .updateDragCursorImpl (browser , operation );
115+ }
116+ };
75117
76118
77119 public CN1CefBrowser (CefClient client , String url , boolean transparent , CefRequestContext context ) {
@@ -110,7 +152,7 @@ public Component getUIComponent() {
110152
111153 @ Override
112154 public CefRenderHandler getRenderHandler () {
113- return this ;
155+ return renderHandler_ ;
114156 }
115157
116158 @ Override
@@ -120,7 +162,6 @@ protected CefBrowser_N createDevToolsBrowser(CefClient client, String url,
120162 client , url , isTransparent_ , context , (CN1CefBrowser ) this , inspectAt );
121163 }
122164
123- @ Override
124165 public CompletableFuture <BufferedImage > createScreenshot (boolean nativeResolution ) {
125166 return CompletableFuture .completedFuture (null );
126167 }
@@ -365,13 +406,11 @@ public void setFocus(boolean enable) {
365406
366407
367408
368- @ Override
369- public Rectangle getViewRect (CefBrowser browser ) {
409+ public Rectangle getViewRectImpl (CefBrowser browser ) {
370410 return browser_rect_ ;
371411 }
372412
373- @ Override
374- public Point getScreenPoint (CefBrowser browser , Point viewPoint ) {
413+ public Point getScreenPointImpl (CefBrowser browser , Point viewPoint ) {
375414 try {
376415 Point screenPoint = new Point (screenPoint_ );
377416 screenPoint .translate (viewPoint .x , viewPoint .y );
@@ -383,8 +422,7 @@ public Point getScreenPoint(CefBrowser browser, Point viewPoint) {
383422 }
384423 }
385424
386- @ Override
387- public void onPopupShow (CefBrowser browser , boolean show ) {
425+ public void onPopupShowImpl (CefBrowser browser , boolean show ) {
388426 try {
389427 if (!show ) {
390428 //renderer_.clearPopupRects();
@@ -396,8 +434,7 @@ public void onPopupShow(CefBrowser browser, boolean show) {
396434 }
397435 }
398436
399- @ Override
400- public void onPopupSize (CefBrowser browser , Rectangle size ) {
437+ public void onPopupSizeImpl (CefBrowser browser , Rectangle size ) {
401438 try {
402439 //renderer_.onPopupSize(size);
403440 } catch (Throwable t ) {
@@ -408,16 +445,15 @@ public void onPopupSize(CefBrowser browser, Rectangle size) {
408445
409446 private boolean firstPaint =true ;
410447
411- @ Override
412- public void onPaint (final CefBrowser browser , final boolean popup , final Rectangle [] dirtyRects ,
448+ public void onPaintImpl (final CefBrowser browser , final boolean popup , final Rectangle [] dirtyRects ,
413449 final ByteBuffer buffer , final int width , final int height ) {
414450 try {
415- _onPaint (browser , popup , dirtyRects , buffer , width , height );
451+ _onPaintImpl (browser , popup , dirtyRects , buffer , width , height );
416452 } catch (Throwable t ) {
417453 t .printStackTrace ();
418454 }
419455 }
420- public void _onPaint (final CefBrowser browser , final boolean popup , final Rectangle [] dirtyRects ,
456+ public void _onPaintImpl (final CefBrowser browser , final boolean popup , final Rectangle [] dirtyRects ,
421457 final ByteBuffer buffer , final int width , final int height ) {
422458 final PixelBuffer buffer_ = bufferRef .get ();
423459 if (buffer_ == null ) {
@@ -494,24 +530,12 @@ public void run() {
494530 }
495531 }
496532
497- @ Override
498- public boolean onCursorChange (CefBrowser browser , final int cursorType ) {
499- SwingUtilities .invokeLater (new Runnable () {
500- public void run () {
501- component_ .setCursor (new Cursor (cursorType ));
502- }
503- });
504- return true ;
505- }
506-
507- @ Override
508- public boolean startDragging (CefBrowser browser , CefDragData dragData , int mask , int x , int y ) {
533+ public boolean startDraggingImpl (CefBrowser browser , CefDragData dragData , int mask , int x , int y ) {
509534 // TODO(JCEF) Prepared for DnD support using OSR mode.
510535 return false ;
511536 }
512537
513- @ Override
514- public void updateDragCursor (CefBrowser browser , int operation ) {
538+ public void updateDragCursorImpl (CefBrowser browser , int operation ) {
515539 // TODO(JCEF) Prepared for DnD support using OSR mode.
516540 }
517541
@@ -550,8 +574,7 @@ public static void setComponentFactory(ComponentFactory factory) {
550574 componentFactory = factory ;
551575 }
552576
553- @ Override
554- public boolean getScreenInfo (CefBrowser browser , CefScreenInfo screenInfo ) {
577+ public boolean getScreenInfoImpl (CefBrowser browser , CefScreenInfo screenInfo ) {
555578 try {
556579 GraphicsDevice graphicsDevice = GraphicsEnvironment .getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
557580 GraphicsConfiguration graphicsConfig = graphicsDevice .getDefaultConfiguration ();
0 commit comments