[Pkg-javascript-commits] [pdf.js] 29/115: Move CustomStyle.
David Prévot
taffit at moszumanska.debian.org
Wed Dec 16 20:03:11 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 2f34fd46cbcbb0d91f7201a10f9e73263908dfa4
Author: Yury Delendik <ydelendik at mozilla.com>
Date: Mon Nov 9 19:24:15 2015 -0600
Move CustomStyle.
---
examples/acroforms/index.html | 1 +
examples/helloworld/index.html | 1 +
make.js | 1 +
src/display/dom_utils.js | 73 ++++++++++++++++++++++++++++++++++++++++
test/test_slave.html | 1 +
test/unit/unit_test.html | 1 +
web/annotations_layer_builder.js | 4 ++-
web/pdf_page_view.js | 4 ++-
web/text_layer_builder.js | 4 +--
web/ui_utils.js | 51 ----------------------------
web/viewer.html | 1 +
11 files changed, 87 insertions(+), 55 deletions(-)
diff --git a/examples/acroforms/index.html b/examples/acroforms/index.html
index 3011e01..1936ae1 100644
--- a/examples/acroforms/index.html
+++ b/examples/acroforms/index.html
@@ -11,6 +11,7 @@
<script src="../../src/display/webgl.js"></script>
<script src="../../src/display/pattern_helper.js"></script>
<script src="../../src/display/font_loader.js"></script>
+ <script src="../../src/display/dom_utils.js"></script>
<script src="../../src/display/annotation_helper.js"></script>
<script>
diff --git a/examples/helloworld/index.html b/examples/helloworld/index.html
index 748d606..9f79d54 100644
--- a/examples/helloworld/index.html
+++ b/examples/helloworld/index.html
@@ -11,6 +11,7 @@
<script src="../../src/display/webgl.js"></script>
<script src="../../src/display/pattern_helper.js"></script>
<script src="../../src/display/font_loader.js"></script>
+ <script src="../../src/display/dom_utils.js"></script>
<script src="../../src/display/annotation_helper.js"></script>
<script>
diff --git a/make.js b/make.js
index 2b15f3c..5b4e206 100644
--- a/make.js
+++ b/make.js
@@ -530,6 +530,7 @@ target.bundle = function(args) {
'display/webgl.js',
'display/pattern_helper.js',
'display/font_loader.js',
+ 'display/dom_utils.js',
'display/annotation_helper.js',
'display/svg.js'
]);
diff --git a/src/display/dom_utils.js b/src/display/dom_utils.js
new file mode 100644
index 0000000..5b76bc4
--- /dev/null
+++ b/src/display/dom_utils.js
@@ -0,0 +1,73 @@
+/* Copyright 2015 Mozilla Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/* globals PDFJS */
+
+'use strict';
+
+/**
+ * Optimised CSS custom property getter/setter.
+ * @class
+ */
+var CustomStyle = (function CustomStyleClosure() {
+
+ // As noted on: http://www.zachstronaut.com/posts/2009/02/17/
+ // animate-css-transforms-firefox-webkit.html
+ // in some versions of IE9 it is critical that ms appear in this list
+ // before Moz
+ var prefixes = ['ms', 'Moz', 'Webkit', 'O'];
+ var _cache = {};
+
+ function CustomStyle() {}
+
+ CustomStyle.getProp = function get(propName, element) {
+ // check cache only when no element is given
+ if (arguments.length === 1 && typeof _cache[propName] === 'string') {
+ return _cache[propName];
+ }
+
+ element = element || document.documentElement;
+ var style = element.style, prefixed, uPropName;
+
+ // test standard property first
+ if (typeof style[propName] === 'string') {
+ return (_cache[propName] = propName);
+ }
+
+ // capitalize
+ uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
+
+ // test vendor specific properties
+ for (var i = 0, l = prefixes.length; i < l; i++) {
+ prefixed = prefixes[i] + uPropName;
+ if (typeof style[prefixed] === 'string') {
+ return (_cache[propName] = prefixed);
+ }
+ }
+
+ //if all fails then set to undefined
+ return (_cache[propName] = 'undefined');
+ };
+
+ CustomStyle.setProp = function set(propName, element, str) {
+ var prop = this.getProp(propName);
+ if (prop !== 'undefined') {
+ element.style[prop] = str;
+ }
+ };
+
+ return CustomStyle;
+})();
+
+PDFJS.CustomStyle = CustomStyle;
diff --git a/test/test_slave.html b/test/test_slave.html
index 8a78e97..3677b4e 100644
--- a/test/test_slave.html
+++ b/test/test_slave.html
@@ -25,6 +25,7 @@ limitations under the License.
<script src="../src/display/webgl.js"></script>
<script src="../src/display/pattern_helper.js"></script>
<script src="../src/display/font_loader.js"></script>
+ <script src="../src/display/dom_utils.js"></script>
<script src="../src/display/annotation_helper.js"></script>
<script src="driver.js"></script>
</head>
diff --git a/test/unit/unit_test.html b/test/unit/unit_test.html
index 5fe1f25..687bd52 100644
--- a/test/unit/unit_test.html
+++ b/test/unit/unit_test.html
@@ -36,6 +36,7 @@
<script src="../../src/core/ps_parser.js"></script>
<script src="../../src/display/pattern_helper.js"></script>
<script src="../../src/display/font_loader.js"></script>
+ <script src="../../src/display/dom_utils.js"></script>
<script src="../../src/display/annotation_helper.js"></script>
<script src="../../src/core/stream.js"></script>
<script src="../../src/core/worker.js"></script>
diff --git a/web/annotations_layer_builder.js b/web/annotations_layer_builder.js
index 7e81c7e..752e431 100644
--- a/web/annotations_layer_builder.js
+++ b/web/annotations_layer_builder.js
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*globals PDFJS, CustomStyle, mozL10n, SimpleLinkService */
+/*globals PDFJS, mozL10n, SimpleLinkService */
'use strict';
@@ -27,6 +27,8 @@
* @class
*/
var AnnotationsLayerBuilder = (function AnnotationsLayerBuilderClosure() {
+ var CustomStyle = PDFJS.CustomStyle;
+
/**
* @param {AnnotationsLayerBuilderOptions} options
* @constructs AnnotationsLayerBuilder
diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js
index 52b3f59..021fe7f 100644
--- a/web/pdf_page_view.js
+++ b/web/pdf_page_view.js
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/* globals RenderingStates, PDFJS, CustomStyle, CSS_UNITS, getOutputScale,
+/* globals RenderingStates, PDFJS, CSS_UNITS, getOutputScale,
TextLayerBuilder, AnnotationsLayerBuilder, Promise,
approximateFraction, roundToDivide */
@@ -36,6 +36,8 @@ var TEXT_LAYER_RENDER_DELAY = 200; // ms
* @implements {IRenderableView}
*/
var PDFPageView = (function PDFPageViewClosure() {
+ var CustomStyle = PDFJS.CustomStyle;
+
/**
* @constructs PDFPageView
* @param {PDFPageViewOptions} options
diff --git a/web/text_layer_builder.js b/web/text_layer_builder.js
index 0691c8c..805498d 100644
--- a/web/text_layer_builder.js
+++ b/web/text_layer_builder.js
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/* globals CustomStyle, PDFJS */
+/* globals PDFJS */
'use strict';
@@ -119,7 +119,7 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
transform = 'rotate(' + rotation + 'deg) ' + transform;
}
if (transform) {
- CustomStyle.setProp('transform' , textDiv, transform);
+ PDFJS.CustomStyle.setProp('transform' , textDiv, transform);
}
}
}
diff --git a/web/ui_utils.js b/web/ui_utils.js
index 6f5aa26..5f4b4fd 100644
--- a/web/ui_utils.js
+++ b/web/ui_utils.js
@@ -23,57 +23,6 @@ var MAX_AUTO_SCALE = 1.25;
var SCROLLBAR_PADDING = 40;
var VERTICAL_PADDING = 5;
-// optimised CSS custom property getter/setter
-var CustomStyle = (function CustomStyleClosure() {
-
- // As noted on: http://www.zachstronaut.com/posts/2009/02/17/
- // animate-css-transforms-firefox-webkit.html
- // in some versions of IE9 it is critical that ms appear in this list
- // before Moz
- var prefixes = ['ms', 'Moz', 'Webkit', 'O'];
- var _cache = {};
-
- function CustomStyle() {}
-
- CustomStyle.getProp = function get(propName, element) {
- // check cache only when no element is given
- if (arguments.length === 1 && typeof _cache[propName] === 'string') {
- return _cache[propName];
- }
-
- element = element || document.documentElement;
- var style = element.style, prefixed, uPropName;
-
- // test standard property first
- if (typeof style[propName] === 'string') {
- return (_cache[propName] = propName);
- }
-
- // capitalize
- uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
-
- // test vendor specific properties
- for (var i = 0, l = prefixes.length; i < l; i++) {
- prefixed = prefixes[i] + uPropName;
- if (typeof style[prefixed] === 'string') {
- return (_cache[propName] = prefixed);
- }
- }
-
- //if all fails then set to undefined
- return (_cache[propName] = 'undefined');
- };
-
- CustomStyle.setProp = function set(propName, element, str) {
- var prop = this.getProp(propName);
- if (prop !== 'undefined') {
- element.style[prop] = str;
- }
- };
-
- return CustomStyle;
-})();
-
var NullCharactersRegExp = /\x00/g;
function removeNullCharacters(str) {
diff --git a/web/viewer.html b/web/viewer.html
index 8a65736..217d3f2 100644
--- a/web/viewer.html
+++ b/web/viewer.html
@@ -60,6 +60,7 @@ See https://github.com/adobe-type-tools/cmap-resources
<script src="../src/display/webgl.js"></script>
<script src="../src/display/pattern_helper.js"></script>
<script src="../src/display/font_loader.js"></script>
+ <script src="../src/display/dom_utils.js"></script>
<script src="../src/display/annotation_helper.js"></script>
<script>PDFJS.workerSrc = '../src/worker_loader.js';</script>
<!--#endif-->
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list