2 * Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef __htmlediting_h__
27 #define __htmlediting_h__
29 #include "edit_command.h"
31 #include "xml/dom_nodeimpl.h"
34 class CSSStyleDeclarationImpl
;
35 class DocumentFragmentImpl
;
47 class AppendNodeCommandImpl
;
48 class ApplyStyleCommandImpl
;
49 class CompositeEditCommandImpl
;
50 class DeleteCollapsibleWhitespaceCommandImpl
;
51 class DeleteSelectionCommandImpl
;
52 class DeleteTextCommandImpl
;
54 class EditCommandImpl
;
55 class InputNewlineCommandImpl
;
56 class InputTextCommandImpl
;
57 class InsertNodeBeforeCommandImpl
;
58 class InsertTextCommandImpl
;
59 class JoinTextNodesCommandImpl
;
60 class MoveSelectionCommandImpl
;
61 class ReplaceSelectionCommandImpl
;
62 class RemoveCSSPropertyCommandImpl
;
63 class RemoveNodeAttributeCommandImpl
;
64 class RemoveNodeCommandImpl
;
65 class RemoveNodeAndPruneCommandImpl
;
66 class RemoveNodePreservingChildrenCommandImpl
;
67 class SetNodeAttributeCommandImpl
;
68 class SplitTextNodeCommandImpl
;
69 class TypingCommandImpl
;
71 //------------------------------------------------------------------------------------------
72 // CompositeEditCommand
74 class CompositeEditCommand
: public EditCommand
77 CompositeEditCommand();
78 CompositeEditCommand(CompositeEditCommandImpl
*);
79 CompositeEditCommand(const CompositeEditCommand
&);
80 ~CompositeEditCommand();
83 inline CompositeEditCommandImpl
*impl() const;
86 //==========================================================================================
88 //------------------------------------------------------------------------------------------
91 class AppendNodeCommand
: public EditCommand
94 AppendNodeCommand(DOM::DocumentImpl
*, DOM::NodeImpl
*parentNode
, DOM::NodeImpl
*appendChild
);
97 DOM::NodeImpl
*parentNode() const;
98 DOM::NodeImpl
*appendChild() const;
101 inline AppendNodeCommandImpl
*impl() const;
104 //------------------------------------------------------------------------------------------
107 class ApplyStyleCommand
: public CompositeEditCommand
110 ApplyStyleCommand(DOM::DocumentImpl
*, DOM::CSSStyleDeclarationImpl
*);
111 ~ApplyStyleCommand();
113 DOM::CSSStyleDeclarationImpl
*style() const;
116 inline ApplyStyleCommandImpl
*impl() const;
119 //------------------------------------------------------------------------------------------
120 // DeleteCollapsibleWhitespaceCommand
122 class DeleteCollapsibleWhitespaceCommand
: public CompositeEditCommand
125 DeleteCollapsibleWhitespaceCommand(DOM::DocumentImpl
*document
);
126 DeleteCollapsibleWhitespaceCommand(DOM::DocumentImpl
*document
, const DOM::Selection
&selection
);
128 ~DeleteCollapsibleWhitespaceCommand();
131 inline DeleteCollapsibleWhitespaceCommandImpl
*impl() const;
134 //------------------------------------------------------------------------------------------
135 // DeleteSelectionCommand
137 class DeleteSelectionCommand
: public CompositeEditCommand
140 DeleteSelectionCommand(DOM::DocumentImpl
*document
);
141 DeleteSelectionCommand(DOM::DocumentImpl
*document
, const DOM::Selection
&selection
);
142 ~DeleteSelectionCommand();
145 inline DeleteSelectionCommandImpl
*impl() const;
148 //------------------------------------------------------------------------------------------
151 class DeleteTextCommand
: public EditCommand
154 DeleteTextCommand(DOM::DocumentImpl
*document
, DOM::TextImpl
*, long offset
, long count
);
155 DeleteTextCommand(const DeleteTextCommand
&);
156 ~DeleteTextCommand();
158 DOM::TextImpl
*node() const;
163 inline DeleteTextCommandImpl
*impl() const;
166 //------------------------------------------------------------------------------------------
167 // InputNewlineCommand
169 class InputNewlineCommand
: public CompositeEditCommand
172 InputNewlineCommand(DOM::DocumentImpl
*document
);
173 ~InputNewlineCommand();
176 inline InputNewlineCommandImpl
*impl() const;
179 //------------------------------------------------------------------------------------------
182 class InputTextCommand
: public CompositeEditCommand
185 InputTextCommand(DOM::DocumentImpl
*document
);
188 void deleteCharacter();
189 void input(const DOM::DOMString
&text
);
191 unsigned long charactersAdded() const;
194 inline InputTextCommandImpl
*impl() const;
197 //------------------------------------------------------------------------------------------
198 // InsertNodeBeforeCommand
200 class InsertNodeBeforeCommand
: public EditCommand
203 InsertNodeBeforeCommand();
204 InsertNodeBeforeCommand(DOM::DocumentImpl
*, DOM::NodeImpl
*insertChild
, DOM::NodeImpl
*refChild
);
205 InsertNodeBeforeCommand(const InsertNodeBeforeCommand
&);
206 ~InsertNodeBeforeCommand();
208 DOM::NodeImpl
*insertChild() const;
209 DOM::NodeImpl
*refChild() const;
212 inline InsertNodeBeforeCommandImpl
*impl() const;
215 //------------------------------------------------------------------------------------------
218 class InsertTextCommand
: public EditCommand
221 InsertTextCommand(DOM::DocumentImpl
*document
, DOM::TextImpl
*, long, const DOM::DOMString
&);
222 ~InsertTextCommand();
224 DOM::TextImpl
*node() const;
226 DOM::DOMString
text() const;
229 inline InsertTextCommandImpl
*impl() const;
232 //------------------------------------------------------------------------------------------
233 // JoinTextNodesCommand
235 class JoinTextNodesCommand
: public EditCommand
238 JoinTextNodesCommand(DOM::DocumentImpl
*, DOM::TextImpl
*, DOM::TextImpl
*);
239 ~JoinTextNodesCommand();
241 DOM::TextImpl
*firstNode() const;
242 DOM::TextImpl
*secondNode() const;
245 inline JoinTextNodesCommandImpl
*impl() const;
248 //------------------------------------------------------------------------------------------
249 // ReplaceSelectionCommand
251 class ReplaceSelectionCommand
: public CompositeEditCommand
254 ReplaceSelectionCommand(DOM::DocumentImpl
*document
, DOM::DocumentFragmentImpl
*fragment
, bool selectReplacement
=true);
255 ~ReplaceSelectionCommand();
258 inline ReplaceSelectionCommandImpl
*impl() const;
261 //------------------------------------------------------------------------------------------
262 // MoveSelectionCommand
264 class MoveSelectionCommand
: public CompositeEditCommand
267 MoveSelectionCommand(DOM::DocumentImpl
*document
, DOM::DocumentFragmentImpl
*fragment
, DOM::Position
&position
);
268 ~MoveSelectionCommand();
271 inline MoveSelectionCommandImpl
*impl() const;
274 //------------------------------------------------------------------------------------------
275 // RemoveCSSPropertyCommand
277 class RemoveCSSPropertyCommand
: public EditCommand
280 RemoveCSSPropertyCommand(DOM::DocumentImpl
*, DOM::CSSStyleDeclarationImpl
*, int property
);
281 ~RemoveCSSPropertyCommand();
283 DOM::CSSStyleDeclarationImpl
*styleDeclaration() const;
284 int property() const;
287 inline RemoveCSSPropertyCommandImpl
*impl() const;
290 //------------------------------------------------------------------------------------------
291 // RemoveNodeAttributeCommand
293 class RemoveNodeAttributeCommand
: public EditCommand
296 RemoveNodeAttributeCommand(DOM::DocumentImpl
*, DOM::ElementImpl
*, DOM::NodeImpl::Id attribute
);
297 ~RemoveNodeAttributeCommand();
299 DOM::ElementImpl
*element() const;
300 DOM::NodeImpl::Id
attribute() const;
303 inline RemoveNodeAttributeCommandImpl
*impl() const;
306 //------------------------------------------------------------------------------------------
309 class RemoveNodeCommand
: public EditCommand
312 RemoveNodeCommand(DOM::DocumentImpl
*, DOM::NodeImpl
*node
);
313 ~RemoveNodeCommand();
315 DOM::NodeImpl
*node() const;
318 inline RemoveNodeCommandImpl
*impl() const;
321 //------------------------------------------------------------------------------------------
322 // RemoveNodeAndPruneCommand
324 class RemoveNodeAndPruneCommand
: public CompositeEditCommand
327 RemoveNodeAndPruneCommand(DOM::DocumentImpl
*, DOM::NodeImpl
*pruneNode
, DOM::NodeImpl
*stopNode
=0);
328 ~RemoveNodeAndPruneCommand();
330 DOM::NodeImpl
*pruneNode() const;
331 DOM::NodeImpl
*stopNode() const;
334 inline RemoveNodeAndPruneCommandImpl
*impl() const;
337 //------------------------------------------------------------------------------------------
338 // RemoveNodePreservingChildrenCommand
340 class RemoveNodePreservingChildrenCommand
: public CompositeEditCommand
343 RemoveNodePreservingChildrenCommand(DOM::DocumentImpl
*document
, DOM::NodeImpl
*node
);
344 ~RemoveNodePreservingChildrenCommand();
346 DOM::NodeImpl
*node() const;
349 inline RemoveNodePreservingChildrenCommandImpl
*impl() const;
352 //------------------------------------------------------------------------------------------
353 // SetNodeAttributeCommand
355 class SetNodeAttributeCommand
: public EditCommand
358 SetNodeAttributeCommand(DOM::DocumentImpl
*, DOM::ElementImpl
*, DOM::NodeImpl::Id attribute
, const DOM::DOMString
&value
);
359 ~SetNodeAttributeCommand();
361 DOM::ElementImpl
*element() const;
362 DOM::NodeImpl::Id
attribute() const;
363 DOM::DOMString
value() const;
366 inline SetNodeAttributeCommandImpl
*impl() const;
369 //------------------------------------------------------------------------------------------
370 // SplitTextNodeCommand
372 class SplitTextNodeCommand
: public EditCommand
375 SplitTextNodeCommand(DOM::DocumentImpl
*, DOM::TextImpl
*, long);
376 ~SplitTextNodeCommand();
378 DOM::TextImpl
*node() const;
382 inline SplitTextNodeCommandImpl
*impl() const;
385 //------------------------------------------------------------------------------------------
388 class TypingCommand
: public CompositeEditCommand
391 static void deleteKeyPressed(DOM::DocumentImpl
*document
);
392 static void insertText(DOM::DocumentImpl
*document
, const DOM::DOMString
&text
);
393 static void insertNewline(DOM::DocumentImpl
*document
);
394 static bool isOpenForMoreTypingCommand(const EditCommand
&);
395 static void closeTyping(EditCommand
);
397 bool openForMoreTyping() const;
401 TypingCommand(DOM::DocumentImpl
*document
);
402 TypingCommand(TypingCommand
*);
403 TypingCommand(const TypingCommand
&);
406 void deleteKeyPressed();
407 void insertText(const DOM::DOMString
&text
);
408 void insertNewline();
410 inline TypingCommandImpl
*impl() const;
413 //------------------------------------------------------------------------------------------
415 } // end namespace khtml