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

Side by Side Diff: sky/engine/core/editing/MarkupAccumulator.h

Issue 771933002: Remove dead markup serialization code. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #ifndef SKY_ENGINE_CORE_EDITING_MARKUPACCUMULATOR_H_
27 #define SKY_ENGINE_CORE_EDITING_MARKUPACCUMULATOR_H_
28
29 #include "sky/engine/core/editing/markup.h"
30 #include "sky/engine/wtf/HashMap.h"
31 #include "sky/engine/wtf/Vector.h"
32 #include "sky/engine/wtf/text/StringBuilder.h"
33
34 namespace blink {
35
36 class Attribute;
37 class DocumentType;
38 class Element;
39 class Node;
40 class Range;
41
42 typedef HashMap<AtomicString, AtomicString> Namespaces;
43
44 enum EntityMask {
45 EntityAmp = 0x0001,
46 EntityLt = 0x0002,
47 EntityGt = 0x0004,
48 EntityQuot = 0x0008,
49 EntityNbsp = 0x0010,
50
51 // Non-breaking space needs to be escaped in innerHTML for compatibility rea son. See http://trac.webkit.org/changeset/32879
52 // However, we cannot do this in a XML document because it does not have the entity reference defined (See the bug 19215).
53 EntityMaskInCDATA = 0,
54 EntityMaskInPCDATA = EntityAmp | EntityLt | EntityGt,
55 EntityMaskInHTMLPCDATA = EntityMaskInPCDATA | EntityNbsp,
56 EntityMaskInAttributeValue = EntityAmp | EntityQuot | EntityLt | EntityGt,
57 EntityMaskInHTMLAttributeValue = EntityAmp | EntityQuot | EntityNbsp,
58 };
59
60 class MarkupAccumulator {
61 WTF_MAKE_NONCOPYABLE(MarkupAccumulator);
62 STACK_ALLOCATED();
63 public:
64 MarkupAccumulator(Vector<RawPtr<Node> >*, EAbsoluteURLs, const Range* = 0);
65 virtual ~MarkupAccumulator();
66
67 String serializeNodes(Node& targetNode, EChildrenOnly, Vector<QualifiedName> * tagNamesToSkip = 0);
68
69 static void appendComment(StringBuilder&, const String&);
70
71 static void appendCharactersReplacingEntities(StringBuilder&, const String&, unsigned, unsigned, EntityMask);
72
73 protected:
74 void appendString(const String&);
75 void appendStartTag(Node&, Namespaces* = 0);
76 virtual void appendEndTag(const Element&);
77 static size_t totalLength(const Vector<String>&);
78 size_t length() const { return m_markup.length(); }
79 void concatenateMarkup(StringBuilder&);
80 void appendAttributeValue(StringBuilder&, const String&, bool);
81 virtual void appendCustomAttributes(StringBuilder&, const Element&, Namespac es*);
82
83 EntityMask entityMaskForText(const Text&) const;
84 virtual void appendText(StringBuilder&, Text&);
85 virtual void appendElement(StringBuilder&, Element&, Namespaces*);
86 void appendOpenTag(StringBuilder&, const Element&, Namespaces*);
87 void appendCloseTag(StringBuilder&, const Element&);
88 void appendAttribute(StringBuilder&, const Element&, const Attribute&, Names paces*);
89 void appendStartMarkup(StringBuilder&, Node&, Namespaces*);
90 void appendEndMarkup(StringBuilder&, const Element&);
91
92 RawPtr<Vector<RawPtr<Node> > > const m_nodes;
93 RawPtr<const Range> const m_range;
94
95 private:
96 String resolveURLIfNeeded(const Element&, const String&) const;
97 void appendQuotedURLAttributeValue(StringBuilder&, const Element&, const Att ribute&);
98 void serializeNodesWithNamespaces(Node& targetNode, EChildrenOnly, const Nam espaces*, Vector<QualifiedName>* tagNamesToSkip);
99
100 StringBuilder m_markup;
101 const EAbsoluteURLs m_resolveURLsMethod;
102 };
103
104 }
105
106 #endif // SKY_ENGINE_CORE_EDITING_MARKUPACCUMULATOR_H_
OLDNEW
« no previous file with comments | « sky/engine/core/editing/EditorCommand.cpp ('k') | sky/engine/core/editing/MarkupAccumulator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698