mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Merge pull request #16593 from calixteman/popup_hcm
Improve highlightments and popups in HCM (bug 1830850)
This commit is contained in:
commit
c4a61a7692
6 changed files with 248 additions and 69 deletions
|
@ -30,6 +30,7 @@
|
|||
--input-disabled-border-color: GrayText;
|
||||
--input-hover-border-color: Highlight;
|
||||
--link-outline: 1.5px solid LinkText;
|
||||
--hcm-highligh-filter: invert(100%);
|
||||
}
|
||||
.annotationLayer .textWidgetAnnotation :is(input, textarea):required,
|
||||
.annotationLayer .choiceWidgetAnnotation select:required,
|
||||
|
@ -40,7 +41,30 @@
|
|||
}
|
||||
|
||||
.annotationLayer .linkAnnotation:hover {
|
||||
backdrop-filter: invert(100%);
|
||||
backdrop-filter: var(--hcm-highligh-filter);
|
||||
}
|
||||
|
||||
.annotationLayer .linkAnnotation > a:hover {
|
||||
opacity: 0 !important;
|
||||
background: none !important;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.annotationLayer .popupAnnotation .popup {
|
||||
outline: calc(1.5px * var(--scale-factor)) solid CanvasText !important;
|
||||
background-color: ButtonFace !important;
|
||||
color: ButtonText !important;
|
||||
}
|
||||
|
||||
.annotationLayer .highlightArea:hover::after {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
backdrop-filter: var(--hcm-highligh-filter);
|
||||
content: "";
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.annotationLayer .popupAnnotation.focused .popup {
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
/** @typedef {import("../src/display/base_factory.js").BaseFilterFactory} BaseFilterFactory */
|
||||
// eslint-disable-next-line max-len
|
||||
/** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
|
||||
// eslint-disable-next-line max-len
|
||||
|
@ -84,6 +86,8 @@ import { XfaLayerBuilder } from "./xfa_layer_builder.js";
|
|||
* @property {IL10n} [l10n] - Localization service.
|
||||
* @property {function} [layerProperties] - The function that is used to lookup
|
||||
* the necessary layer-properties.
|
||||
* @property {BaseFilterFactory} [filterFactory] - Factory to create some SVG
|
||||
* filters.
|
||||
*/
|
||||
|
||||
const MAX_CANVAS_PIXELS = compatibilityParams.maxCanvasPixels || 16777216;
|
||||
|
@ -203,6 +207,21 @@ class PDFPageView {
|
|||
"--scale-factor",
|
||||
this.scale * PixelsPerInch.PDF_TO_CSS_UNITS
|
||||
);
|
||||
if (
|
||||
options.filterFactory &&
|
||||
(this.pageColors?.foreground === "CanvasText" ||
|
||||
this.pageColors?.background === "Canvas")
|
||||
) {
|
||||
container?.style.setProperty(
|
||||
"--hcm-highligh-filter",
|
||||
options.filterFactory.addHighlightHCMFilter(
|
||||
"CanvasText",
|
||||
"Canvas",
|
||||
"HighlightText",
|
||||
"Highlight"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const { optionalContentConfigPromise } = options;
|
||||
if (optionalContentConfigPromise) {
|
||||
|
|
|
@ -883,6 +883,20 @@ class PDFViewer {
|
|||
// Ensure that the various layers always get the correct initial size,
|
||||
// see issue 15795.
|
||||
this.viewer.style.setProperty("--scale-factor", viewport.scale);
|
||||
if (
|
||||
this.pageColors?.foreground === "CanvasText" ||
|
||||
this.pageColors?.background === "Canvas"
|
||||
) {
|
||||
this.viewer.style.setProperty(
|
||||
"--hcm-highligh-filter",
|
||||
pdfDocument.filterFactory.addHighlightHCMFilter(
|
||||
"CanvasText",
|
||||
"Canvas",
|
||||
"HighlightText",
|
||||
"Highlight"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
||||
const pageView = new PDFPageView({
|
||||
|
@ -902,6 +916,7 @@ class PDFViewer {
|
|||
pageColors: this.pageColors,
|
||||
l10n: this.l10n,
|
||||
layerProperties,
|
||||
filterFactory: pdfDocument.filterFactory,
|
||||
});
|
||||
this._pages.push(pageView);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue