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 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_XML_DOCUMENT_XSLT_H_
6 #define THIRD_PARTY_BLINK_RENDERER_CORE_XML_DOCUMENT_XSLT_H_
7 
8 #include "base/macros.h"
9 #include "base/memory/scoped_refptr.h"
10 #include "third_party/blink/renderer/core/dom/document.h"
11 #include "third_party/blink/renderer/platform/heap/handle.h"
12 
13 namespace blink {
14 
15 class Document;
16 class ProcessingInstruction;
17 
18 class DocumentXSLT final : public GarbageCollected<DocumentXSLT>,
19                            public Supplement<Document> {
20   USING_GARBAGE_COLLECTED_MIXIN(DocumentXSLT);
21 
22  public:
23   static const char kSupplementName[];
24 
TransformSourceDocument()25   Document* TransformSourceDocument() {
26     return transform_source_document_.Get();
27   }
28 
SetTransformSourceDocument(Document * document)29   void SetTransformSourceDocument(Document* document) {
30     DCHECK(document);
31     transform_source_document_ = document;
32   }
33 
34   static DocumentXSLT& From(Document&);
35 
36   // The following static methods don't use any instance of DocumentXSLT.
37   // They are just using DocumentXSLT namespace.
38   static void ApplyXSLTransform(Document&, ProcessingInstruction*);
39   static ProcessingInstruction* FindXSLStyleSheet(Document&);
40   static bool ProcessingInstructionInsertedIntoDocument(Document&,
41                                                         ProcessingInstruction*);
42   static bool ProcessingInstructionRemovedFromDocument(Document&,
43                                                        ProcessingInstruction*);
44   static bool SheetLoaded(Document&, ProcessingInstruction*);
45   static bool HasTransformSourceDocument(Document&);
46 
47   explicit DocumentXSLT(Document&);
48   void Trace(Visitor*) override;
49 
50  private:
51   Member<Document> transform_source_document_;
52   DISALLOW_COPY_AND_ASSIGN(DocumentXSLT);
53 };
54 
55 }  // namespace blink
56 
57 #endif
58