| 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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 #include "core/editing/commands/CompositeEditCommand.h" | 29 #include "core/editing/commands/CompositeEditCommand.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 class EditingStyle; | 33 class EditingStyle; |
| 34 class HTMLTableRowElement; | 34 class HTMLTableRowElement; |
| 35 | 35 |
| 36 class DeleteSelectionCommand final : public CompositeEditCommand { | 36 class DeleteSelectionCommand final : public CompositeEditCommand { |
| 37 public: | 37 public: |
| 38 static PassRefPtrWillBeRawPtr<DeleteSelectionCommand> create(Document& docum
ent, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool expandFo
rSpecialElements = false, bool sanitizeMarkup = true) | 38 static RawPtr<DeleteSelectionCommand> create(Document& document, bool smartD
elete = false, bool mergeBlocksAfterDelete = true, bool expandForSpecialElements
= false, bool sanitizeMarkup = true) |
| 39 { | 39 { |
| 40 return adoptRefWillBeNoop(new DeleteSelectionCommand(document, smartDele
te, mergeBlocksAfterDelete, expandForSpecialElements, sanitizeMarkup)); | 40 return new DeleteSelectionCommand(document, smartDelete, mergeBlocksAfte
rDelete, expandForSpecialElements, sanitizeMarkup); |
| 41 } | 41 } |
| 42 static PassRefPtrWillBeRawPtr<DeleteSelectionCommand> create(const VisibleSe
lection& selection, bool smartDelete = false, bool mergeBlocksAfterDelete = true
, bool expandForSpecialElements = false, bool sanitizeMarkup = true) | 42 static RawPtr<DeleteSelectionCommand> create(const VisibleSelection& selecti
on, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool expandFor
SpecialElements = false, bool sanitizeMarkup = true) |
| 43 { | 43 { |
| 44 return adoptRefWillBeNoop(new DeleteSelectionCommand(selection, smartDel
ete, mergeBlocksAfterDelete, expandForSpecialElements, sanitizeMarkup)); | 44 return new DeleteSelectionCommand(selection, smartDelete, mergeBlocksAft
erDelete, expandForSpecialElements, sanitizeMarkup); |
| 45 } | 45 } |
| 46 | 46 |
| 47 DECLARE_VIRTUAL_TRACE(); | 47 DECLARE_VIRTUAL_TRACE(); |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 DeleteSelectionCommand(Document&, bool smartDelete, bool mergeBlocksAfterDel
ete, bool expandForSpecialElements, bool santizeMarkup); | 50 DeleteSelectionCommand(Document&, bool smartDelete, bool mergeBlocksAfterDel
ete, bool expandForSpecialElements, bool santizeMarkup); |
| 51 DeleteSelectionCommand(const VisibleSelection&, bool smartDelete, bool merge
BlocksAfterDelete, bool expandForSpecialElements, bool sanitizeMarkup); | 51 DeleteSelectionCommand(const VisibleSelection&, bool smartDelete, bool merge
BlocksAfterDelete, bool expandForSpecialElements, bool sanitizeMarkup); |
| 52 | 52 |
| 53 void doApply(EditingState*) override; | 53 void doApply(EditingState*) override; |
| 54 EditAction editingAction() const override; | 54 EditAction editingAction() const override; |
| 55 | 55 |
| 56 bool preservesTypingStyle() const override; | 56 bool preservesTypingStyle() const override; |
| 57 | 57 |
| 58 void initializeStartEnd(Position&, Position&); | 58 void initializeStartEnd(Position&, Position&); |
| 59 void setStartingSelectionOnSmartDelete(const Position&, const Position&); | 59 void setStartingSelectionOnSmartDelete(const Position&, const Position&); |
| 60 void initializePositionData(EditingState*); | 60 void initializePositionData(EditingState*); |
| 61 void saveTypingStyleState(); | 61 void saveTypingStyleState(); |
| 62 bool handleSpecialCaseBRDelete(EditingState*); | 62 bool handleSpecialCaseBRDelete(EditingState*); |
| 63 void handleGeneralDelete(EditingState*); | 63 void handleGeneralDelete(EditingState*); |
| 64 void fixupWhitespace(); | 64 void fixupWhitespace(); |
| 65 void mergeParagraphs(EditingState*); | 65 void mergeParagraphs(EditingState*); |
| 66 void removePreviouslySelectedEmptyTableRows(EditingState*); | 66 void removePreviouslySelectedEmptyTableRows(EditingState*); |
| 67 void calculateTypingStyleAfterDelete(); | 67 void calculateTypingStyleAfterDelete(); |
| 68 void clearTransientState(); | 68 void clearTransientState(); |
| 69 void makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss(Editi
ngState*); | 69 void makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss(Editi
ngState*); |
| 70 void removeNode(PassRefPtrWillBeRawPtr<Node>, EditingState*, ShouldAssumeCon
tentIsAlwaysEditable = DoNotAssumeContentIsAlwaysEditable) override; | 70 void removeNode(RawPtr<Node>, EditingState*, ShouldAssumeContentIsAlwaysEdit
able = DoNotAssumeContentIsAlwaysEditable) override; |
| 71 void deleteTextFromNode(PassRefPtrWillBeRawPtr<Text>, unsigned, unsigned) ov
erride; | 71 void deleteTextFromNode(RawPtr<Text>, unsigned, unsigned) override; |
| 72 void removeRedundantBlocks(EditingState*); | 72 void removeRedundantBlocks(EditingState*); |
| 73 | 73 |
| 74 bool m_hasSelectionToDelete; | 74 bool m_hasSelectionToDelete; |
| 75 bool m_smartDelete; | 75 bool m_smartDelete; |
| 76 bool m_mergeBlocksAfterDelete; | 76 bool m_mergeBlocksAfterDelete; |
| 77 bool m_needPlaceholder; | 77 bool m_needPlaceholder; |
| 78 bool m_expandForSpecialElements; | 78 bool m_expandForSpecialElements; |
| 79 bool m_pruneStartBlockIfNecessary; | 79 bool m_pruneStartBlockIfNecessary; |
| 80 bool m_startsAtEmptyLine; | 80 bool m_startsAtEmptyLine; |
| 81 bool m_sanitizeMarkup; | 81 bool m_sanitizeMarkup; |
| 82 | 82 |
| 83 // This data is transient and should be cleared at the end of the doApply fu
nction. | 83 // This data is transient and should be cleared at the end of the doApply fu
nction. |
| 84 VisibleSelection m_selectionToDelete; | 84 VisibleSelection m_selectionToDelete; |
| 85 Position m_upstreamStart; | 85 Position m_upstreamStart; |
| 86 Position m_downstreamStart; | 86 Position m_downstreamStart; |
| 87 Position m_upstreamEnd; | 87 Position m_upstreamEnd; |
| 88 Position m_downstreamEnd; | 88 Position m_downstreamEnd; |
| 89 Position m_endingPosition; | 89 Position m_endingPosition; |
| 90 Position m_leadingWhitespace; | 90 Position m_leadingWhitespace; |
| 91 Position m_trailingWhitespace; | 91 Position m_trailingWhitespace; |
| 92 RefPtrWillBeMember<Node> m_startBlock; | 92 Member<Node> m_startBlock; |
| 93 RefPtrWillBeMember<Node> m_endBlock; | 93 Member<Node> m_endBlock; |
| 94 RefPtrWillBeMember<EditingStyle> m_typingStyle; | 94 Member<EditingStyle> m_typingStyle; |
| 95 RefPtrWillBeMember<EditingStyle> m_deleteIntoBlockquoteStyle; | 95 Member<EditingStyle> m_deleteIntoBlockquoteStyle; |
| 96 RefPtrWillBeMember<Element> m_startRoot; | 96 Member<Element> m_startRoot; |
| 97 RefPtrWillBeMember<Element> m_endRoot; | 97 Member<Element> m_endRoot; |
| 98 RefPtrWillBeMember<HTMLTableRowElement> m_startTableRow; | 98 Member<HTMLTableRowElement> m_startTableRow; |
| 99 RefPtrWillBeMember<HTMLTableRowElement> m_endTableRow; | 99 Member<HTMLTableRowElement> m_endTableRow; |
| 100 RefPtrWillBeMember<Node> m_temporaryPlaceholder; | 100 Member<Node> m_temporaryPlaceholder; |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 } // namespace blink | 103 } // namespace blink |
| 104 | 104 |
| 105 #endif // DeleteSelectionCommand_h | 105 #endif // DeleteSelectionCommand_h |
| OLD | NEW |