File: text_layer.html

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (112 lines) | stat: -rw-r--r-- 2,926 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<style>
  :host {
    height: 100%;
    width: 100%;
  }

  :host([is-selecting-text]) {
    cursor: text;
  }

  #textRenderCanvas {
    visibility: hidden;
  }

  .background-image {
    position: absolute;
    pointer-events: none;
    user-select: none;
    z-index: 0;
  }

  .translated-line,
  .word {
    cursor: text;
    opacity: 0;
    pointer-events: all;
    position: absolute;
    user-select: none;
  }

  .translated-line {
    align-items: center;
    display: flex;
    flex-wrap: nowrap;
    opacity: 100%;
    pointer-events: none;
    white-space: pre;
    z-index: 1;
  }

  .translated-word {
    cursor: text;
    pointer-events: all;
    user-select: none;
  }

  :host([debug-mode]) .translated-line {
    border: 1px solid orange;
  }

  :host([debug-mode]) .translated-word {
    border: 1px solid teal;
  }

  :host([debug-mode]) .word {
    border: 1px solid blue;
    opacity: 50%;
  }

  :host(:not([should-render-translate-words])) .translated-line,
  :host(:not([should-render-translate-words])) .background-image {
    display: none;
  }

  .highlighted-line {
    position: absolute;
    background-color: var(--color-shader-layer-3);
    opacity: 60%;
    z-index: 1;
  }

  /* Set styles for high contrast mode in Windows. */
  @media (forced-colors: active) {
    .highlighted-line {
      /* Set the icon color to hcm (high contrast mode) value. */
      background-color: Highlight;
    }
  }
</style>
<template id="wordsContainer" is="dom-repeat" items="[[renderedWords]]"
  index-as="wordIndex">
  <div
    style$="[[getWordStyle(item, wordIndex, shouldRenderTranslateWords, selectionOverlayRect)]]"
    class="word"
    on-pointerenter="handlePointerEnter" on-pointerleave="handlePointerLeave">
  </div>
</template>
<template id="translateContainer" is="dom-repeat"
  items="[[renderedTranslateLines]]" as="translatedLineData"
  index-as="lineIndex">
  <template is="dom-if" if="[[translatedLineData.line.backgroundImageData]]">
    <img class="background-image"
      style$="[[getBackgroundImageDataStyle(translatedLineData,selectionOverlayRect)]]"
      src="[[getBlobUrlFromImageData(translatedLineData.line.backgroundImageData)]]">
  </template>
  <div
    style$="[[getTranslatedLineStyle(translatedLineData,selectionOverlayRect)]]"
    class="translated-line">
    <template is="dom-repeat" items="[[translatedLineData.words]]"
      as="translatedWordData" index-as="wordIndex">
      <span class="translated-word"
        data-line-index$="[[lineIndex]]"
        data-word-index$="[[translatedWordData.index]]"
        lang$="[[currentTranslateLanguage]]">[[translatedWordData.word.plainText]][[translatedWordData.word.textSeparator]]</span>
    </template>
  </div>
</template>
<template is="dom-repeat" items="[[highlightedLines]]">
  <div style$="[[getHighlightedLineStyle(item)]]" class="highlighted-line">
  </div>
</template>
<canvas id="textRenderCanvas"></canvas>