OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009, 2010, 2011 Google Inc. All rights reserved. |
4 * Copyright (C) 2011 Igalia S.L. | 4 * Copyright (C) 2011 Igalia S.L. |
5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 5 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 virtual void appendElement(StringBuilder&, Element&, Namespaces*) override; | 54 virtual void appendElement(StringBuilder&, Element&, Namespaces*) override; |
55 void appendElement(StringBuilder&, Element&, bool, RangeFullySelectsNode); | 55 void appendElement(StringBuilder&, Element&, bool, RangeFullySelectsNode); |
56 void appendStyleNodeOpenTag(StringBuilder&, StylePropertySet*, bool isBlock
= false); | 56 void appendStyleNodeOpenTag(StringBuilder&, StylePropertySet*, bool isBlock
= false); |
57 | 57 |
58 // TODO(hajimehoshi): These functions are called from the serializer, but | 58 // TODO(hajimehoshi): These functions are called from the serializer, but |
59 // should not. | 59 // should not. |
60 Node* highestNodeToBeSerialized() { return m_highestNodeToBeSerialized.get()
; } | 60 Node* highestNodeToBeSerialized() { return m_highestNodeToBeSerialized.get()
; } |
61 void setHighestNodeToBeSerialized(Node* node) { m_highestNodeToBeSerialized
= node; } | 61 void setHighestNodeToBeSerialized(Node* node) { m_highestNodeToBeSerialized
= node; } |
62 bool shouldAnnotate() const { return m_shouldAnnotate == AnnotateForIntercha
nge || m_shouldAnnotate == AnnotateForNavigationTransition; } | 62 bool shouldAnnotate() const { return m_shouldAnnotate == AnnotateForIntercha
nge || m_shouldAnnotate == AnnotateForNavigationTransition; } |
63 bool shouldAnnotateForNavigationTransition() const { return m_shouldAnnotate
== AnnotateForNavigationTransition; } | 63 bool shouldAnnotateForNavigationTransition() const { return m_shouldAnnotate
== AnnotateForNavigationTransition; } |
| 64 bool shouldAnnotateForInterchange() const { return m_shouldAnnotate == Annot
ateForInterchange; } |
64 | 65 |
65 private: | 66 private: |
66 String renderedText(Text&); | 67 String renderedText(Text&); |
67 String stringValueForRange(const Node&); | 68 String stringValueForRange(const Node&); |
68 | 69 |
69 bool shouldApplyWrappingStyle(const Node&) const; | 70 bool shouldApplyWrappingStyle(const Node&) const; |
70 | 71 |
71 // StyledMarkupAccumulator is owned by StyledMarkupSerializer and | 72 // StyledMarkupAccumulator is owned by StyledMarkupSerializer and |
72 // |m_serializer| must be living while this is living. | 73 // |m_serializer| must be living while this is living. |
73 // | 74 // |
74 // TODO(hajimehoshi): m_serializer is used only to access |m_wrappingStyle|. | 75 // TODO(hajimehoshi): m_serializer is used only to access |m_wrappingStyle|. |
75 // Remove this. | 76 // Remove this. |
76 StyledMarkupSerializer* m_serializer; | 77 StyledMarkupSerializer* m_serializer; |
77 | 78 |
78 const Position m_start; | 79 const Position m_start; |
79 const Position m_end; | 80 const Position m_end; |
80 const EAnnotateForInterchange m_shouldAnnotate; | 81 const EAnnotateForInterchange m_shouldAnnotate; |
81 RawPtrWillBeMember<Node> m_highestNodeToBeSerialized; | 82 RawPtrWillBeMember<Node> m_highestNodeToBeSerialized; |
82 }; | 83 }; |
83 | 84 |
84 class StyledMarkupSerializer final { | 85 class StyledMarkupSerializer final { |
85 STACK_ALLOCATED(); | 86 STACK_ALLOCATED(); |
86 public: | 87 public: |
87 StyledMarkupSerializer(EAbsoluteURLs, EAnnotateForInterchange, const Positio
n& start, const Position& end, Node* highestNodeToBeSerialized = nullptr); | 88 StyledMarkupSerializer(EAbsoluteURLs, EAnnotateForInterchange, const Positio
n& start, const Position& end, Node* highestNodeToBeSerialized = nullptr); |
88 | 89 |
| 90 String createMarkup(bool convertBlocksToInlines, Node* specialCommonAncestor
); |
| 91 |
89 template<typename Strategy> | 92 template<typename Strategy> |
90 Node* serializeNodes(Node* startNode, Node* pastEnd); | 93 Node* serializeNodes(Node* startNode, Node* pastEnd); |
91 | 94 |
92 // TODO(hajimehoshi): These functions should be at the accumulator, but are | |
93 // used at markup.cpp. Move those usages to here. | |
94 void appendString(const String& s) { return m_markupAccumulator.appendString
(s); } | |
95 void wrapWithNode(ContainerNode&, bool convertBlocksToInlines = false, Style
dMarkupAccumulator::RangeFullySelectsNode = StyledMarkupAccumulator::DoesFullySe
lectNode); | |
96 void wrapWithStyleNode(StylePropertySet*, bool isBlock = false); | |
97 | |
98 String takeResults(); | 95 String takeResults(); |
99 | 96 |
100 // TODO(hajimehoshi): This is called by StyledMarkupAccumulator but should | 97 // TODO(hajimehoshi): This is called by StyledMarkupAccumulator but should |
101 // not. Move |m_wrappingStyle| to the accumulator. | 98 // not. Move |m_wrappingStyle| to the accumulator. |
102 EditingStyle* wrappingStyle() { return m_wrappingStyle.get(); } | 99 EditingStyle* wrappingStyle() { return m_wrappingStyle.get(); } |
103 | 100 |
104 private: | 101 private: |
105 enum NodeTraversalMode { EmitString, DoNotEmitString }; | 102 enum NodeTraversalMode { EmitString, DoNotEmitString }; |
106 | 103 |
107 template<typename Strategy> | 104 template<typename Strategy> |
108 Node* traverseNodesForSerialization(Node* startNode, Node* pastEnd, NodeTrav
ersalMode); | 105 Node* traverseNodesForSerialization(Node* startNode, Node* pastEnd, NodeTrav
ersalMode); |
109 | 106 |
| 107 // TODO(hajimehoshi): These functions should be at the accumulator. |
| 108 void wrapWithNode(ContainerNode&, bool convertBlocksToInlines = false, Style
dMarkupAccumulator::RangeFullySelectsNode = StyledMarkupAccumulator::DoesFullySe
lectNode); |
| 109 void wrapWithStyleNode(StylePropertySet*, bool isBlock = false); |
| 110 |
110 StyledMarkupAccumulator m_markupAccumulator; | 111 StyledMarkupAccumulator m_markupAccumulator; |
| 112 const Position m_start; |
| 113 const Position m_end; |
111 Vector<String> m_reversedPrecedingMarkup; | 114 Vector<String> m_reversedPrecedingMarkup; |
112 RefPtrWillBeMember<EditingStyle> m_wrappingStyle; | 115 RefPtrWillBeMember<EditingStyle> m_wrappingStyle; |
113 }; | 116 }; |
114 | 117 |
115 extern template Node* StyledMarkupSerializer::serializeNodes<EditingStrategy>(No
de* startNode, Node* endNode); | 118 extern template Node* StyledMarkupSerializer::serializeNodes<EditingStrategy>(No
de* startNode, Node* endNode); |
116 | 119 |
117 } // namespace blink | 120 } // namespace blink |
118 | 121 |
119 #endif // StyledMarkupSerializer_h | 122 #endif // StyledMarkupSerializer_h |
OLD | NEW |