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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 "use strict";
6
7 installClass("ProcessingInstruction", function(global, ProcessingInstructionProt otype) {
8
9 ProcessingInstructionPrototype.registerSheet = function(parsing) {
10 if (!global.document.xslStyleSheetInitialized_) {
11 global.document.parsing = parsing;
12 global.document.xslStyleSheetLoaded = [];
13 global.document.xslStyleSheet = [];
14 global.document.xslStyleSheetInitialized_ = true;
15
16 global.document.addEventListener('DOMContentLoaded', function() {
17 global.document.parsing = false;
18 var found = false;
19 for (var index = 0; index < global.document.xslStyleSheetLoaded. length; index++) {
20 if (global.document.xslStyleSheetLoaded[index] == global.doc ument.xslStyleSheet[0]) {
21 found = true;
22 break;
23 }
24 }
25 if (!found)
26 return;
27 if (global.document.transformSourceDocument)
28 return;
29 global.document.applyXSLTransform(global.document.xslStyleSheet[ 0]);
30 }, false);
31 }
32
33 if (global.document.xslStyleSheet.length == 0) {
34 global.document.xslStyleSheet.push(this);
35 return;
36 }
37
38 for (var index = 0; index < global.document.xslStyleSheet.length; index+ +) {
39 var position = global.document.xslStyleSheet[index].compareDocumentP osition(this);
40 if (position & Node.DOCUMENT_POSITION_PRECEDING) {
41 global.document.xslStyleSheet.splice(index, 0, this);
42 return;
43 }
44 }
45 }
46
47 ProcessingInstructionPrototype.unregisterSheet = function() {
48 for (var index = 0; index < global.document.xslStyleSheet.length; index+ +) {
49 if (global.document.xslStyleSheet[index] == this) {
50 global.document.xslStyleSheet.splice(index, 1);
51 break;
52 }
53 }
54 for (var index = 0; index < global.document.xslStyleSheetLoaded.length; index++) {
55 if (!global.document.xslStyleSheetLoaded[index] == this) {
56 global.document.xslStyleSheetLoaded.splice(index, 1);
57 break;
58 }
59 }
60 }
61
62 ProcessingInstructionPrototype.sheetLoadedCallback = function() {
63 global.document.xslStyleSheetLoaded.push(this);
64 if (global.document.xslStyleSheet[0] != this || global.document.parsing || global.document.transformSourceDocument)
65 return;
66 global.document.applyXSLTransform(global.document.xslStyleSheet[0]);
67 }
68 });
69
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698