Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Unified Diff: Source/core/dom/ProcessingInstruction.js

Issue 365873002: Implement a part of ProcessingInstruction by using PrivateScript (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use PrivateScript to invoke XSLTransform Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/ProcessingInstruction.js
diff --git a/Source/core/dom/ProcessingInstruction.js b/Source/core/dom/ProcessingInstruction.js
new file mode 100644
index 0000000000000000000000000000000000000000..d5a03acc839c4bff738031710e04bd1dde3a81a3
--- /dev/null
+++ b/Source/core/dom/ProcessingInstruction.js
@@ -0,0 +1,69 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+"use strict";
+
+installClass("ProcessingInstruction", function(global, ProcessingInstructionPrototype) {
+
+ ProcessingInstructionPrototype.registerSheet = function(parsing) {
+ if (!global.document.xslStyleSheetInitialized_) {
+ global.document.parsing = parsing;
+ global.document.xslStyleSheetLoaded = [];
+ global.document.xslStyleSheet = [];
+ global.document.xslStyleSheetInitialized_ = true;
+
+ global.document.addEventListener('DOMContentLoaded', function() {
+ global.document.parsing = false;
+ var found = false;
+ for (var index = 0; index < global.document.xslStyleSheetLoaded.length; index++) {
+ if (global.document.xslStyleSheetLoaded[index] == global.document.xslStyleSheet[0]) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ return;
+ if (global.document.transformSourceDocument)
+ return;
+ global.document.applyXSLTransform(global.document.xslStyleSheet[0]);
+ }, false);
+ }
+
+ if (global.document.xslStyleSheet.length == 0) {
+ global.document.xslStyleSheet.push(this);
+ return;
+ }
+
+ for (var index = 0; index < global.document.xslStyleSheet.length; index++) {
+ var position = global.document.xslStyleSheet[index].compareDocumentPosition(this);
+ if (position & Node.DOCUMENT_POSITION_PRECEDING) {
+ global.document.xslStyleSheet.splice(index, 0, this);
+ return;
+ }
+ }
+ }
+
+ ProcessingInstructionPrototype.unregisterSheet = function() {
+ for (var index = 0; index < global.document.xslStyleSheet.length; index++) {
+ if (global.document.xslStyleSheet[index] == this) {
+ global.document.xslStyleSheet.splice(index, 1);
+ break;
+ }
+ }
+ for (var index = 0; index < global.document.xslStyleSheetLoaded.length; index++) {
+ if (!global.document.xslStyleSheetLoaded[index] == this) {
+ global.document.xslStyleSheetLoaded.splice(index, 1);
+ break;
+ }
+ }
+ }
+
+ ProcessingInstructionPrototype.sheetLoadedCallback = function() {
+ global.document.xslStyleSheetLoaded.push(this);
+ if (global.document.xslStyleSheet[0] != this || global.document.parsing || global.document.transformSourceDocument)
+ return;
+ global.document.applyXSLTransform(global.document.xslStyleSheet[0]);
+ }
+});
+

Powered by Google App Engine
This is Rietveld 408576698