OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 30 matching lines...) Expand all Loading... |
41 TextInsertionMarkerSupplier() { } | 41 TextInsertionMarkerSupplier() { } |
42 }; | 42 }; |
43 | 43 |
44 class InsertTextCommand : public CompositeEditCommand { | 44 class InsertTextCommand : public CompositeEditCommand { |
45 public: | 45 public: |
46 enum RebalanceType { | 46 enum RebalanceType { |
47 RebalanceLeadingAndTrailingWhitespaces, | 47 RebalanceLeadingAndTrailingWhitespaces, |
48 RebalanceAllWhitespaces | 48 RebalanceAllWhitespaces |
49 }; | 49 }; |
50 | 50 |
51 static PassRefPtr<InsertTextCommand> create(Document* document, const String
& text, bool selectInsertedText = false, | 51 static PassRefPtr<InsertTextCommand> create(Document& document, const String
& text, bool selectInsertedText = false, |
52 RebalanceType rebalanceType = RebalanceLeadingAndTrailingWhitespaces) | 52 RebalanceType rebalanceType = RebalanceLeadingAndTrailingWhitespaces) |
53 { | 53 { |
54 return adoptRef(new InsertTextCommand(document, text, selectInsertedText
, rebalanceType)); | 54 return adoptRef(new InsertTextCommand(document, text, selectInsertedText
, rebalanceType)); |
55 } | 55 } |
56 | 56 |
57 static PassRefPtr<InsertTextCommand> createWithMarkerSupplier(Document* docu
ment, const String& text, PassRefPtr<TextInsertionMarkerSupplier> markerSupplier
) | 57 static PassRefPtr<InsertTextCommand> createWithMarkerSupplier(Document& docu
ment, const String& text, PassRefPtr<TextInsertionMarkerSupplier> markerSupplier
) |
58 { | 58 { |
59 return adoptRef(new InsertTextCommand(document, text, markerSupplier)); | 59 return adoptRef(new InsertTextCommand(document, text, markerSupplier)); |
60 } | 60 } |
61 | 61 |
62 private: | 62 private: |
63 | 63 |
64 InsertTextCommand(Document*, const String& text, bool selectInsertedText, Re
balanceType); | 64 InsertTextCommand(Document&, const String& text, bool selectInsertedText, Re
balanceType); |
65 InsertTextCommand(Document*, const String& text, PassRefPtr<TextInsertionMar
kerSupplier>); | 65 InsertTextCommand(Document&, const String& text, PassRefPtr<TextInsertionMar
kerSupplier>); |
66 | 66 |
67 void deleteCharacter(); | 67 void deleteCharacter(); |
68 | 68 |
69 virtual void doApply(); | 69 virtual void doApply(); |
70 | 70 |
71 Position positionInsideTextNode(const Position&); | 71 Position positionInsideTextNode(const Position&); |
72 Position insertTab(const Position&); | 72 Position insertTab(const Position&); |
73 | 73 |
74 bool performTrivialReplace(const String&, bool selectInsertedText); | 74 bool performTrivialReplace(const String&, bool selectInsertedText); |
75 bool performOverwrite(const String&, bool selectInsertedText); | 75 bool performOverwrite(const String&, bool selectInsertedText); |
76 void setEndingSelectionWithoutValidation(const Position& startPosition, cons
t Position& endPosition); | 76 void setEndingSelectionWithoutValidation(const Position& startPosition, cons
t Position& endPosition); |
77 | 77 |
78 friend class TypingCommand; | 78 friend class TypingCommand; |
79 | 79 |
80 String m_text; | 80 String m_text; |
81 bool m_selectInsertedText; | 81 bool m_selectInsertedText; |
82 RebalanceType m_rebalanceType; | 82 RebalanceType m_rebalanceType; |
83 RefPtr<TextInsertionMarkerSupplier> m_markerSupplier; | 83 RefPtr<TextInsertionMarkerSupplier> m_markerSupplier; |
84 }; | 84 }; |
85 | 85 |
86 } // namespace WebCore | 86 } // namespace WebCore |
87 | 87 |
88 #endif // InsertTextCommand_h | 88 #endif // InsertTextCommand_h |
OLD | NEW |