Changeset 143030 in webkit
- Timestamp:
- Feb 15, 2013 11:59:41 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r143028 r143030 1 2013-02-13 Ryosuke Niwa <rniwa@webkit.org> 2 3 DeleteButtonController::enable and disable should be called via a RAII object 4 https://bugs.webkit.org/show_bug.cgi?id=109550 5 6 Reviewed by Enrica Casucci. 7 8 Added DeleteButtonControllerDisableScope, a friend class of DeleteButtonController, 9 and made DeleteButtonController::enable/disable private. 10 11 * dom/ContainerNode.cpp: 12 * editing/CompositeEditCommand.cpp: 13 (WebCore::EditCommandComposition::unapply): 14 (WebCore::EditCommandComposition::reapply): 15 (WebCore::CompositeEditCommand::apply): 16 * editing/DeleteButtonController.h: 17 (WebCore): 18 (DeleteButtonController): 19 (DeleteButtonControllerDisableScope): 20 (WebCore::DeleteButtonControllerDisableScope::DeleteButtonControllerDisableScope): 21 (WebCore::DeleteButtonControllerDisableScope::~DeleteButtonControllerDisableScope): 22 * editing/markup.cpp: 23 (WebCore::createMarkup): 24 (WebCore::createFragmentFromNodes): 25 1 26 2013-02-15 Max Vujovic <mvujovic@adobe.com> 2 27 -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r142642 r143030 104 104 m_document->updateLayoutIgnorePendingStylesheets(); 105 105 106 { 106 107 #if ENABLE(DELETION_UI) 107 DeleteButtonController* deleteButtonController = frame->editor()->deleteButtonController(); 108 deleteButtonController->disable(); 108 DeleteButtonControllerDisableScope deleteButtonControllerDisableScope(frame.get()); 109 109 #endif 110 size_t size = m_commands.size(); 111 for (size_t i = size; i != 0; --i)112 m_commands[i - 1]->doUnapply();113 #if ENABLE(DELETION_UI) 114 deleteButtonController->enable();115 #endif 110 111 size_t size = m_commands.size(); 112 for (size_t i = size; i; --i) 113 m_commands[i - 1]->doUnapply(); 114 } 115 116 116 frame->editor()->unappliedEditing(this); 117 117 } … … 127 127 // if one is necessary (like for the creation of VisiblePositions). 128 128 m_document->updateLayoutIgnorePendingStylesheets(); 129 129 130 { 130 131 #if ENABLE(DELETION_UI) 131 DeleteButtonController* deleteButtonController = frame->editor()->deleteButtonController(); 132 deleteButtonController->disable(); 132 DeleteButtonControllerDisableScope deleteButtonControllerDisableScope(frame.get()); 133 133 #endif 134 size_t size = m_commands.size(); 135 for (size_t i = 0; i != size; ++i) 136 m_commands[i]->doReapply(); 137 #if ENABLE(DELETION_UI) 138 deleteButtonController->enable(); 139 #endif 134 size_t size = m_commands.size(); 135 for (size_t i = 0; i != size; ++i) 136 m_commands[i]->doReapply(); 137 } 140 138 141 139 frame->editor()->reappliedEditing(this); … … 212 210 EventQueueScope scope; 213 211 #if ENABLE(DELETION_UI) 214 DeleteButtonController* deleteButtonController = frame->editor()->deleteButtonController(); 215 deleteButtonController->disable(); 212 DeleteButtonControllerDisableScope deleteButtonControllerDisableScope(frame); 216 213 #endif 217 214 doApply(); 218 #if ENABLE(DELETION_UI)219 deleteButtonController->enable();220 #endif221 215 } 222 216 -
trunk/Source/WebCore/editing/DeleteButtonController.h
r142533 r143030 28 28 29 29 #include "DeleteButton.h" 30 #include "Frame.h" 30 31 31 32 namespace WebCore { 32 33 34 #if ENABLE(DELETION_UI) 35 33 36 class DeleteButton; 34 class Frame;35 37 class HTMLElement; 36 38 class RenderObject; … … 51 53 void hide(); 52 54 53 void enable();54 void disable();55 56 55 void deleteTarget(); 57 56 … … 60 59 static const char* const outlineElementIdentifier; 61 60 static const char* const containerElementIdentifier; 61 62 void enable(); 63 void disable(); 64 friend class DeleteButtonControllerDisableScope; 62 65 63 66 void createDeletionUI(); … … 74 77 }; 75 78 79 class DeleteButtonControllerDisableScope { 80 public: 81 DeleteButtonControllerDisableScope(Frame* frame) 82 : m_frame(frame) 83 { 84 if (frame) 85 frame->editor()->deleteButtonController()->disable(); 86 } 87 88 ~DeleteButtonControllerDisableScope() 89 { 90 if (m_frame) 91 m_frame->editor()->deleteButtonController()->enable(); 92 } 93 94 private: 95 RefPtr<Frame> m_frame; 96 }; 97 98 #endif 99 76 100 } // namespace WebCore 77 101 -
trunk/Source/WebCore/editing/markup.cpp
r142705 r143030 640 640 return emptyString(); 641 641 642 const Range* updatedRange = range; 643 644 #if ENABLE(DELETION_UI) 642 645 // Disable the delete button so it's elements are not serialized into the markup, 643 646 // but make sure neither endpoint is inside the delete user interface. 644 #if ENABLE(DELETION_UI)645 647 Frame* frame = document->frame(); 646 if (DeleteButtonController* deleteButton = frame ? frame->editor()->deleteButtonController() : 0) { 647 RefPtr<Range> updatedRange = frame->editor()->avoidIntersectionWithDeleteButtonController(range); 648 DeleteButtonControllerDisableScope deleteButtonControllerDisableScope(frame); 649 650 if (frame) { 651 RefPtr<Range> updatedRangeRef = frame->editor()->avoidIntersectionWithDeleteButtonController(range); 652 updatedRange = updatedRangeRef.get(); 648 653 if (!updatedRange) 649 654 return emptyString(); 650 651 deleteButton->disable();652 653 String result = createMarkupInternal(document, range, updatedRange.get(), nodes, shouldAnnotate, convertBlocksToInlines, shouldResolveURLs);654 655 deleteButton->enable();656 657 return result;658 655 } 659 656 #endif 660 return createMarkupInternal(document, range, range, nodes, shouldAnnotate, convertBlocksToInlines, shouldResolveURLs); 657 658 return createMarkupInternal(document, range, updatedRange, nodes, shouldAnnotate, convertBlocksToInlines, shouldResolveURLs); 661 659 } 662 660 … … 910 908 #if ENABLE(DELETION_UI) 911 909 // disable the delete button so it's elements are not serialized into the markup 912 if (document->frame()) 913 document->frame()->editor()->deleteButtonController()->disable(); 910 DeleteButtonControllerDisableScope(document->frame()); 914 911 #endif 912 915 913 RefPtr<DocumentFragment> fragment = document->createDocumentFragment(); 916 914 … … 922 920 } 923 921 924 #if ENABLE(DELETION_UI)925 if (document->frame())926 document->frame()->editor()->deleteButtonController()->enable();927 #endif928 922 return fragment.release(); 929 923 }
Note: See TracChangeset
for help on using the changeset viewer.