From b608f4a1b276c4d2a130b5f9bb83c90cd6804b39 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 3 Dec 2018 11:15:06 +0100 Subject: [PATCH] Use provided attributes for surrounding text (IDEA-CR-40763) --- .../intellij/codeInsight/daemon/impl/HintRenderer.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HintRenderer.kt b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HintRenderer.kt index 1528b4bbb27f..a344f7b05cd4 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HintRenderer.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HintRenderer.kt @@ -12,7 +12,6 @@ import com.intellij.openapi.editor.colors.EditorFontType import com.intellij.openapi.editor.impl.EditorImpl import com.intellij.openapi.editor.impl.FocusModeModel import com.intellij.openapi.editor.impl.FontInfo -import com.intellij.openapi.editor.impl.view.IterationState import com.intellij.openapi.editor.markup.EffectType import com.intellij.openapi.editor.markup.TextAttributes import com.intellij.openapi.util.Key @@ -60,7 +59,7 @@ open class HintRenderer(var text: String?) : EditorCustomElementRenderer { val gap = if (r.height < fontMetrics.lineHeight + 2) 1 else 2 val backgroundColor = attributes.backgroundColor if (backgroundColor != null) { - val alpha = if (isInsufficientContrast(editor, inlay, attributes)) 1.0f else BACKGROUND_ALPHA + val alpha = if (isInsufficientContrast(attributes, textAttributes)) 1.0f else BACKGROUND_ALPHA val config = GraphicsUtil.setupAAPainting(g) GraphicsUtil.paintWithAlpha(g, alpha) g.setColor(backgroundColor) @@ -115,12 +114,10 @@ open class HintRenderer(var text: String?) : EditorCustomElementRenderer { } private fun isInsufficientContrast( - editor: EditorImpl, - inlay: Inlay<*>, - attributes: TextAttributes + attributes: TextAttributes, + surroundingAttributes: TextAttributes ): Boolean { - val iterationState = IterationState(editor, inlay.offset, inlay.offset + 1, null, false, false, false, false) - val backgroundUnderHint = iterationState.mergedAttributes.backgroundColor + val backgroundUnderHint = surroundingAttributes.backgroundColor if (backgroundUnderHint != null && attributes.foregroundColor != null) { val backgroundBlended = srcOverBlend(attributes.backgroundColor, backgroundUnderHint, BACKGROUND_ALPHA)