This repository was archived by the owner on Mar 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 98
PRJ-57 Draw notifications and floating toolbar on top of client markdown/JCEF component #141
Open
ARTI1208
wants to merge
7
commits into
jcef
Choose a base branch
from
prj-57
base: jcef
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9c06c73
PRJ-57 Draw notifications and floating toolbar over client markdown/J…
ARTI1208 bb835df
Correctly implement `clearRect` function
ARTI1208 cda3aba
Fix fake windows positioning
ARTI1208 8186dfc
Pass client component mouse events to server
ARTI1208 9948e57
Fix drawing semi-transparent windows in double buffering mode
ARTI1208 5049eb7
Fix logging of missing implementation of server composite operation
ARTI1208 336b3e2
Update commonVersionList
ARTI1208 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,7 +95,7 @@ internal class DomContext2d(private val myContext2d: CanvasRenderingContext2D) : | |
| CompositeOperationType.CLEAR, | ||
| CompositeOperationType.DST, | ||
| -> "source-over".also { | ||
| logger.info { "Missing implementation for $this, applying source-over" } | ||
| logger.info { "Missing implementation for $type, applying $it" } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! |
||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,16 +25,24 @@ package org.jetbrains.projector.client.web.component | |
|
|
||
| import kotlinx.browser.document | ||
| import org.w3c.dom.HTMLIFrameElement | ||
| import org.w3c.dom.events.Event | ||
| import org.w3c.dom.events.EventListener | ||
| import org.w3c.dom.events.MouseEvent | ||
| import org.w3c.dom.events.MouseEventInit | ||
|
|
||
| abstract class ClientComponent( | ||
| protected val id: Int, | ||
| private val onMouseMove: (Event) -> Unit, | ||
| ) { | ||
|
|
||
| private val contentDocumentListeners = mutableMapOf<String, EventListener>() | ||
|
|
||
| val iFrame: HTMLIFrameElement = createIFrame(id) | ||
|
|
||
| var windowId: Int? = null | ||
|
|
||
| fun dispose() { | ||
| contentDocumentListeners.forEach { iFrame.contentDocument?.removeEventListener(it.key, it.value) } | ||
| iFrame.remove() | ||
| } | ||
|
|
||
|
|
@@ -60,6 +68,10 @@ abstract class ClientComponent( | |
| } | ||
|
|
||
| contentDocument!!.oncontextmenu = { false } | ||
|
|
||
| addEventListener("load", EventListener { | ||
| onContentChanged() | ||
| }) | ||
| } | ||
|
|
||
| protected fun setLinkProcessor(linkProcessor: (String) -> Unit) { | ||
|
|
@@ -92,6 +104,49 @@ abstract class ClientComponent( | |
| } | ||
| } | ||
|
|
||
| private fun onContentChanged() { | ||
| contentDocumentListeners.forEach { iFrame.contentDocument!!.addEventListener(it.key, it.value) } | ||
| } | ||
|
|
||
| private fun getIFrameId(browserId: Int) = "${this::class.simpleName}$browserId" | ||
|
|
||
| init { | ||
| contentDocumentListeners["mousemove"] = EventListener { | ||
|
|
||
| val mouseEventInit = with(it as MouseEvent) { | ||
| MouseEventInit( | ||
| screenX = screenX, | ||
| screenY = screenY, | ||
| clientX = clientX + iFrame.offsetLeft, | ||
| clientY = clientY + iFrame.offsetTop, | ||
| button = button, | ||
| buttons = buttons, | ||
| relatedTarget = relatedTarget, | ||
| region = region, | ||
| ctrlKey = ctrlKey, | ||
| shiftKey = shiftKey, | ||
| altKey = altKey, | ||
| metaKey = metaKey, | ||
| modifierAltGraph = getModifierState("AltGraph"), | ||
| modifierCapsLock = getModifierState("CapsLock"), | ||
| modifierFn = getModifierState("Fn"), | ||
| modifierFnLock = getModifierState("FnLock"), | ||
| modifierHyper = getModifierState("Hyper"), | ||
| modifierNumLock = getModifierState("NumLock"), | ||
| modifierScrollLock = getModifierState("ScrollLock"), | ||
| modifierSuper = getModifierState("Super"), | ||
| modifierSymbol = getModifierState("Symbol"), | ||
| modifierSymbolLock = getModifierState("SymbolLock"), | ||
| view = view, | ||
| detail = detail, | ||
| bubbles = bubbles, | ||
| cancelable = cancelable, | ||
| composed = composed, | ||
| ) | ||
| } | ||
|
Comment on lines
+117
to
+146
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's because of copying object from a different context to make it usable? Let's leave a comment about it! |
||
| onMouseMove(MouseEvent(it.type, mouseEventInit)) | ||
|
|
||
| } | ||
| onContentChanged() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,14 +26,17 @@ package org.jetbrains.projector.client.web.component | |
| import kotlinx.browser.document | ||
| import org.jetbrains.projector.client.web.UriHandler | ||
| import org.w3c.dom.HTMLScriptElement | ||
| import org.w3c.dom.events.Event | ||
| import org.w3c.dom.events.EventListener | ||
| import org.w3c.dom.events.MouseEvent | ||
|
|
||
| class EmbeddedBrowserManager( | ||
| zIndexByWindowIdGetter: (Int) -> Int?, | ||
| private val onMouseMove: (Event) -> Unit, | ||
| private val openInExternalBrowser: (String) -> Unit, | ||
| ) : ClientComponentManager<EmbeddedBrowserManager.EmbeddedBrowserPanel>(zIndexByWindowIdGetter) { | ||
|
|
||
| class EmbeddedBrowserPanel(id: Int, private val openInExternalBrowser: (String) -> Unit) : ClientComponent(id) { | ||
| inner class EmbeddedBrowserPanel(id: Int, private val openInExternalBrowser: (String) -> Unit) : ClientComponent(id, onMouseMove) { | ||
|
|
||
| var wasLoaded = false | ||
|
|
||
|
|
@@ -44,17 +47,15 @@ class EmbeddedBrowserManager( | |
| private val jsQueue = ArrayDeque<String>() | ||
|
|
||
| init { | ||
| iFrame.apply { | ||
| onload = { | ||
| setOpenLinksInExternalBrowser(openLinksInExternalBrowser, true) | ||
|
|
||
| wasLoaded = true | ||
| while (jsQueue.isNotEmpty()) { | ||
| val code = jsQueue.removeFirst() | ||
| executeJsImpl(code) | ||
| } | ||
| iFrame.addEventListener("load", EventListener { | ||
| setOpenLinksInExternalBrowser(openLinksInExternalBrowser, true) | ||
|
Comment on lines
+50
to
+51
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we change onload to load? |
||
|
|
||
| wasLoaded = true | ||
| while (jsQueue.isNotEmpty()) { | ||
| val code = jsQueue.removeFirst() | ||
| executeJsImpl(code) | ||
| } | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| fun setHtml(html: String) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, probably it could be easier to just set https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation to
copy. However, firstly https://youtrack.jetbrains.com/issue/PRJ-700 should be resolved