Commit 3a675dfc authored by dpapad's avatar dpapad Committed by Commit Bot

PDF Viewer: Use a plain <input> instead of <cr-input> for page input.

There is no benefit by using cr-input, as the UI of this element is
heavily customized anyway, and none other features of cr-input are
needed.

Bug: 1100432
Change-Id: I9831a981dc790b83570a9d6645ffab1af2e290cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2271105Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Commit-Queue: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783787}
parent 0f251ab1
...@@ -64,7 +64,6 @@ js_library("viewer-page-indicator") { ...@@ -64,7 +64,6 @@ js_library("viewer-page-indicator") {
} }
js_library("viewer-page-selector") { js_library("viewer-page-selector") {
deps = [ "//ui/webui/resources/cr_elements/cr_input:cr_input.m" ]
} }
js_library("viewer-password-screen") { js_library("viewer-password-screen") {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
background: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.3);
} }
#pageselector::part(input), input,
#pagelength { #pagelength {
/* --page-length-digits is set through JavaScript. 1px is added because /* --page-length-digits is set through JavaScript. 1px is added because
* the unit 'ch' does not provide exact whole number pixels, and * the unit 'ch' does not provide exact whole number pixels, and
...@@ -20,28 +20,23 @@ ...@@ -20,28 +20,23 @@
width: calc(max(2, var(--page-length-digits)) * 1ch + 1px); width: calc(max(2, var(--page-length-digits)) * 1ch + 1px);
} }
#pageselector { input {
--cr-input-background-color: transparent;
--cr-input-border-radius: 0;
--cr-input-color: white;
--cr-input-error-display: none;
--cr-input-focus-color: transparent;
}
#pageselector::part(input) {
background: rgba(0, 0, 0, 0.5); background: rgba(0, 0, 0, 0.5);
box-sizing: content-box; border: none;
caret-color: var(--cr-input-color); color: white;
font-family: inherit;
line-height: inherit;
outline: none;
padding: 0 var(--page-selector-spacing); padding: 0 var(--page-selector-spacing);
text-align: center;
} }
#divider { #divider {
margin: 0 var(--page-selector-spacing); margin: 0 var(--page-selector-spacing);
} }
</style> </style>
<cr-input id="pageselector" value="[[pageNo]]" on-mouseup="select" <input type="text" id="pageselector" value="[[pageNo]]" on-mouseup="select"
on-value-changed="onInputValueChange_" on-change="pageNoCommitted" on-input="onInput_" on-change="pageNoCommitted"
aria-label$="$i18n{labelPageNumber}"> aria-label$="$i18n{labelPageNumber}">
</cr-input>
<span id="divider">/</span> <span id="divider">/</span>
<span id="pagelength">[[docLength]]</span> <span id="pagelength">[[docLength]]</span>
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'chrome://resources/cr_elements/cr_input/cr_input.m.js';
import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
Polymer({ Polymer({
...@@ -65,7 +63,7 @@ Polymer({ ...@@ -65,7 +63,7 @@ Polymer({
* Immediately remove any non-digit characters. * Immediately remove any non-digit characters.
* @private * @private
*/ */
onInputValueChange_() { onInput_() {
this.pageSelector.value = this.pageSelector.value.replace(/[^\d]/, ''); this.pageSelector.value = this.pageSelector.value.replace(/[^\d]/, '');
}, },
}); });
...@@ -49,7 +49,7 @@ const tests = [ ...@@ -49,7 +49,7 @@ const tests = [
// Test that the traversal through the shadow DOM works correctly. // Test that the traversal through the shadow DOM works correctly.
const viewer = document.body.querySelector('pdf-viewer'); const viewer = document.body.querySelector('pdf-viewer');
const toolbar = viewer.shadowRoot.querySelector('#toolbar'); const toolbar = viewer.shadowRoot.querySelector('#toolbar');
toolbar.$.pageselector.pageSelector.inputElement.focus(); toolbar.$.pageselector.pageSelector.focus();
chrome.test.assertTrue(shouldIgnoreKeyEvents(toolbar)); chrome.test.assertTrue(shouldIgnoreKeyEvents(toolbar));
// Test case where the active element has a shadow root of its own. // Test case where the active element has a shadow root of its own.
......
...@@ -50,6 +50,7 @@ const tests = [ ...@@ -50,6 +50,7 @@ const tests = [
// Simulate entering text into `input` and pressing enter. // Simulate entering text into `input` and pressing enter.
function changeInput(newValue) { function changeInput(newValue) {
input.value = newValue; input.value = newValue;
input.dispatchEvent(new CustomEvent('input'));
input.dispatchEvent(new CustomEvent('change')); input.dispatchEvent(new CustomEvent('change'));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment