Title: [155320] trunk/Source/WebCore
Revision
155320
Author
[email protected]
Date
2013-09-08 22:12:43 -0700 (Sun, 08 Sep 2013)

Log Message

Make Editor::deleteButtonController a reference
https://bugs.webkit.org/show_bug.cgi?id=121019

Reviewed by Andreas Kling.

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::cloneChildNodes): Updated to use . instead of ->.
* editing/DeleteButton.cpp:
(WebCore::DeleteButton::defaultEventHandler): Ditto.

* editing/DeleteButtonController.cpp:
(WebCore::DeleteButtonController::DeleteButtonController): Updated to take a Frame&
instead of a Frame*.
(WebCore::DeleteButtonController::respondToChangedSelection): Ditto.
(WebCore::DeleteButtonController::createDeletionUI): Ditto.
(WebCore::DeleteButtonController::show): Ditto.
(WebCore::DeleteButtonController::enable): Ditto.
(WebCore::DeleteButtonController::deleteTarget): Ditto.
* editing/DeleteButtonController.h: Ditto.

* editing/Editor.cpp:
(WebCore::Editor::avoidIntersectionWithDeleteButtonController): Removed bogus
null check from both versions of this function.
(WebCore::Editor::Editor): Use construction rather than assignment and pass
a reference instead of a pointer to make m_deleteButtonController.
(WebCore::Editor::clear): Ditto.

* editing/Editor.h: Made deleteButtonController return a reference.
Also reorganized the header to put all the conditional functions together,
and not mixed in with non-conditional ones.

* editing/markup.cpp:
(WebCore::createMarkup): Updated to use . instead of -> and also to use
emptyString() instead of constructing a new empty string.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (155319 => 155320)


--- trunk/Source/WebCore/ChangeLog	2013-09-09 03:54:14 UTC (rev 155319)
+++ trunk/Source/WebCore/ChangeLog	2013-09-09 05:12:43 UTC (rev 155320)
@@ -1,3 +1,40 @@
+2013-09-08  Darin Adler  <[email protected]>
+
+        Make Editor::deleteButtonController a reference
+        https://bugs.webkit.org/show_bug.cgi?id=121019
+
+        Reviewed by Andreas Kling.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::cloneChildNodes): Updated to use . instead of ->.
+        * editing/DeleteButton.cpp:
+        (WebCore::DeleteButton::defaultEventHandler): Ditto.
+
+        * editing/DeleteButtonController.cpp:
+        (WebCore::DeleteButtonController::DeleteButtonController): Updated to take a Frame&
+        instead of a Frame*.
+        (WebCore::DeleteButtonController::respondToChangedSelection): Ditto.
+        (WebCore::DeleteButtonController::createDeletionUI): Ditto.
+        (WebCore::DeleteButtonController::show): Ditto.
+        (WebCore::DeleteButtonController::enable): Ditto.
+        (WebCore::DeleteButtonController::deleteTarget): Ditto.
+        * editing/DeleteButtonController.h: Ditto.
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::avoidIntersectionWithDeleteButtonController): Removed bogus
+        null check from both versions of this function.
+        (WebCore::Editor::Editor): Use construction rather than assignment and pass
+        a reference instead of a pointer to make m_deleteButtonController.
+        (WebCore::Editor::clear): Ditto.
+
+        * editing/Editor.h: Made deleteButtonController return a reference.
+        Also reorganized the header to put all the conditional functions together,
+        and not mixed in with non-conditional ones.
+
+        * editing/markup.cpp:
+        (WebCore::createMarkup): Updated to use . instead of -> and also to use
+        emptyString() instead of constructing a new empty string.
+
 2013-09-08  Andreas Kling  <[email protected]>
 
         InlineBox::root() should return a reference.

Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (155319 => 155320)


--- trunk/Source/WebCore/dom/ContainerNode.cpp	2013-09-09 03:54:14 UTC (rev 155319)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp	2013-09-09 05:12:43 UTC (rev 155320)
@@ -865,7 +865,7 @@
 #if ENABLE(DELETION_UI)
     HTMLElement* deleteButtonContainerElement = 0;
     if (Frame* frame = document().frame())
-        deleteButtonContainerElement = frame->editor().deleteButtonController()->containerElement();
+        deleteButtonContainerElement = frame->editor().deleteButtonController().containerElement();
     cloneChildNodesAvoidingDeleteButton(this, clone, deleteButtonContainerElement);
 #else
     cloneChildNodesAvoidingDeleteButton(this, clone, 0);

Modified: trunk/Source/WebCore/editing/DeleteButton.cpp (155319 => 155320)


--- trunk/Source/WebCore/editing/DeleteButton.cpp	2013-09-09 03:54:14 UTC (rev 155319)
+++ trunk/Source/WebCore/editing/DeleteButton.cpp	2013-09-09 05:12:43 UTC (rev 155320)
@@ -53,7 +53,7 @@
 void DeleteButton::defaultEventHandler(Event* event)
 {
     if (event->type() == eventNames().clickEvent) {
-        document().frame()->editor().deleteButtonController()->deleteTarget();
+        document().frame()->editor().deleteButtonController().deleteTarget();
         event->setDefaultHandled();
         return;
     }

Modified: trunk/Source/WebCore/editing/DeleteButtonController.cpp (155319 => 155320)


--- trunk/Source/WebCore/editing/DeleteButtonController.cpp	2013-09-09 03:54:14 UTC (rev 155319)
+++ trunk/Source/WebCore/editing/DeleteButtonController.cpp	2013-09-09 05:12:43 UTC (rev 155320)
@@ -58,7 +58,7 @@
 const char* const DeleteButtonController::buttonElementIdentifier = "WebKit-Editing-Delete-Button";
 const char* const DeleteButtonController::outlineElementIdentifier = "WebKit-Editing-Delete-Outline";
 
-DeleteButtonController::DeleteButtonController(Frame* frame)
+DeleteButtonController::DeleteButtonController(Frame& frame)
     : m_frame(frame)
     , m_wasStaticPositioned(false)
     , m_wasAutoZIndex(false)
@@ -176,7 +176,7 @@
         return;
 
     HTMLElement* oldElement = enclosingDeletableElement(oldSelection);
-    HTMLElement* newElement = enclosingDeletableElement(m_frame->selection().selection());
+    HTMLElement* newElement = enclosingDeletableElement(m_frame.selection().selection());
     if (oldElement == newElement)
         return;
 
@@ -256,7 +256,7 @@
     button->setInlineStyleProperty(CSSPropertyHeight, buttonHeight, CSSPrimitiveValue::CSS_PX);
     button->setInlineStyleProperty(CSSPropertyVisibility, CSSValueVisible);
 
-    float deviceScaleFactor = WebCore::deviceScaleFactor(m_frame);
+    float deviceScaleFactor = WebCore::deviceScaleFactor(&m_frame);
     RefPtr<Image> buttonImage;
     if (deviceScaleFactor >= 2)
         buttonImage = Image::loadPlatformResource("deleteButton@2x");
@@ -285,12 +285,12 @@
     if (!enabled() || !element || !element->inDocument() || !isDeletableElement(element))
         return;
 
-    EditorClient* client = m_frame->editor().client();
+    EditorClient* client = m_frame.editor().client();
     if (!client || !client->shouldShowDeleteInterface(element))
         return;
 
     // we rely on the renderer having current information, so we should update the layout if needed
-    m_frame->document()->updateLayoutIgnorePendingStylesheets();
+    m_frame.document()->updateLayoutIgnorePendingStylesheets();
 
     m_target = element;
 
@@ -349,8 +349,8 @@
         // Determining if the element is deletable currently depends on style
         // because whether something is editable depends on style, so we need
         // to recalculate style before calling enclosingDeletableElement.
-        m_frame->document()->updateStyleIfNeeded();
-        show(enclosingDeletableElement(m_frame->selection().selection()));
+        m_frame.document()->updateStyleIfNeeded();
+        show(enclosingDeletableElement(m_frame.selection().selection()));
     }
 }
 
@@ -394,9 +394,9 @@
     // within the target, we unconditionally update the selection to be
     // a caret where the target had been.
     Position pos = positionInParentBeforeNode(m_target.get());
-    ASSERT(m_frame->document());
-    applyCommand(RemoveTargetCommand::create(*m_frame->document(), m_target));
-    m_frame->selection().setSelection(VisiblePosition(pos));
+    ASSERT(m_frame.document());
+    applyCommand(RemoveTargetCommand::create(*m_frame.document(), m_target));
+    m_frame.selection().setSelection(VisiblePosition(pos));
 }
 #endif
 

Modified: trunk/Source/WebCore/editing/DeleteButtonController.h (155319 => 155320)


--- trunk/Source/WebCore/editing/DeleteButtonController.h	2013-09-09 03:54:14 UTC (rev 155319)
+++ trunk/Source/WebCore/editing/DeleteButtonController.h	2013-09-09 05:12:43 UTC (rev 155320)
@@ -42,7 +42,7 @@
 class DeleteButtonController {
     WTF_MAKE_NONCOPYABLE(DeleteButtonController); WTF_MAKE_FAST_ALLOCATED;
 public:
-    explicit DeleteButtonController(Frame*);
+    explicit DeleteButtonController(Frame&);
 
     HTMLElement* containerElement() const { return m_containerElement.get(); }
 
@@ -67,7 +67,7 @@
     void createDeletionUI();
     bool enabled() const { return (!m_disableStack); }
 
-    Frame* m_frame;
+    Frame& m_frame;
     RefPtr<HTMLElement> m_target;
     RefPtr<HTMLElement> m_containerElement;
     RefPtr<HTMLElement> m_outlineElement;
@@ -83,13 +83,13 @@
         : m_frame(frame)
     {
         if (frame)
-            frame->editor().deleteButtonController()->disable();
+            frame->editor().deleteButtonController().disable();
     }
 
     ~DeleteButtonControllerDisableScope()
     {
         if (m_frame)
-            m_frame->editor().deleteButtonController()->enable();
+            m_frame->editor().deleteButtonController().enable();
     }
 
 private:

Modified: trunk/Source/WebCore/editing/Editor.cpp (155319 => 155320)


--- trunk/Source/WebCore/editing/Editor.cpp	2013-09-09 03:54:14 UTC (rev 155319)
+++ trunk/Source/WebCore/editing/Editor.cpp	2013-09-09 05:12:43 UTC (rev 155320)
@@ -104,10 +104,10 @@
 using namespace Unicode;
 
 #if ENABLE(DELETION_UI)
+
 PassRefPtr<Range> Editor::avoidIntersectionWithDeleteButtonController(const Range* range) const
 {
-    DeleteButtonController* controller = deleteButtonController();
-    if (!range || !controller)
+    if (!range)
         return 0;
 
     Node* startContainer = range->startContainer();
@@ -120,7 +120,7 @@
 
     ASSERT(endContainer);
 
-    Element* element = controller->containerElement();
+    Element* element = m_deleteButtonController->containerElement();
     if (startContainer == element || startContainer->isDescendantOf(element)) {
         ASSERT(element->parentNode());
         startContainer = element->parentNode();
@@ -137,11 +137,10 @@
 
 VisibleSelection Editor::avoidIntersectionWithDeleteButtonController(const VisibleSelection& selection) const
 {
-    DeleteButtonController* controller = deleteButtonController();
-    if (selection.isNone() || !controller)
+    if (selection.isNone())
         return selection;
 
-    Element* element = controller->containerElement();
+    Element* element = m_deleteButtonController->containerElement();
     if (!element)
         return selection;
     VisibleSelection updatedSelection = selection;
@@ -158,6 +157,7 @@
 
     return updatedSelection;
 }
+
 #endif
 
 // When an event handler has moved the selection outside of a text control
@@ -893,6 +893,9 @@
 
 Editor::Editor(Frame& frame)
     : m_frame(frame)
+#if ENABLE(DELETION_UI)
+    , m_deleteButtonController(adoptPtr(new DeleteButtonController(frame)))
+#endif
     , m_ignoreCompositionSelectionChange(false)
     , m_shouldStartNewKillRingSequence(false)
     // This is off by default, since most editors want this behavior (this matches IE but not FF).
@@ -904,9 +907,6 @@
     , m_defaultParagraphSeparator(EditorParagraphSeparatorIsDiv)
     , m_overwriteModeEnabled(false)
 {
-#if ENABLE(DELETION_UI)
-    m_deleteButtonController = adoptPtr(new DeleteButtonController(&frame));
-#endif
 }
 
 Editor::~Editor()
@@ -921,7 +921,7 @@
     m_defaultParagraphSeparator = EditorParagraphSeparatorIsDiv;
 
 #if ENABLE(DELETION_UI)
-    m_deleteButtonController = adoptPtr(new DeleteButtonController(&m_frame));
+    m_deleteButtonController = adoptPtr(new DeleteButtonController(m_frame));
 #endif
 }
 

Modified: trunk/Source/WebCore/editing/Editor.h (155319 => 155320)


--- trunk/Source/WebCore/editing/Editor.h	2013-09-09 03:54:14 UTC (rev 155319)
+++ trunk/Source/WebCore/editing/Editor.h	2013-09-09 05:12:43 UTC (rev 155320)
@@ -92,15 +92,6 @@
     EditorClient* client() const;
     TextCheckerClient* textChecker() const;
 
-#if ENABLE(DELETION_UI)
-    DeleteButtonController* deleteButtonController() const { return m_deleteButtonController.get(); }
-    PassRefPtr<Range> avoidIntersectionWithDeleteButtonController(const Range*) const;
-    VisibleSelection avoidIntersectionWithDeleteButtonController(const VisibleSelection&) const;
-#else
-    PassRefPtr<Range> avoidIntersectionWithDeleteButtonController(Range* range) const { return range; }
-    VisibleSelection avoidIntersectionWithDeleteButtonController(const VisibleSelection& selection) const { return selection; }
-#endif
-
     CompositeEditCommand* lastEditCommand() { return m_lastEditCommand.get(); }
 
     void handleKeyboardEvent(KeyboardEvent*);
@@ -213,10 +204,6 @@
     bool insertLineBreak();
     bool insertParagraphSeparator();
 
-#if PLATFORM(MAC)
-    bool insertParagraphSeparatorInQuotedContent();
-#endif
-    
     bool isContinuousSpellCheckingEnabled() const;
     void toggleContinuousSpellChecking();
     bool isGrammarCheckingEnabled();
@@ -240,28 +227,6 @@
     bool isOverwriteModeEnabled() const { return m_overwriteModeEnabled; }
     void toggleOverwriteModeEnabled();
 
-#if USE(APPKIT)
-    void uppercaseWord();
-    void lowercaseWord();
-    void capitalizeWord();
-#endif
-
-#if USE(AUTOMATIC_TEXT_REPLACEMENT)
-    void showSubstitutionsPanel();
-    bool substitutionsPanelIsShowing();
-    void toggleSmartInsertDelete();
-    bool isAutomaticQuoteSubstitutionEnabled();
-    void toggleAutomaticQuoteSubstitution();
-    bool isAutomaticLinkDetectionEnabled();
-    void toggleAutomaticLinkDetection();
-    bool isAutomaticDashSubstitutionEnabled();
-    void toggleAutomaticDashSubstitution();
-    bool isAutomaticTextReplacementEnabled();
-    void toggleAutomaticTextReplacement();
-    bool isAutomaticSpellingCorrectionEnabled();
-    void toggleAutomaticSpellingCorrection();
-#endif
-
     void markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask, Range* spellingRange, Range* grammarRange);
     void changeBackToReplacedString(const String& replacedString);
 
@@ -382,20 +347,6 @@
     void textDidChangeInTextArea(Element*);
     WritingDirection baseWritingDirectionForSelectionStart() const;
 
-#if PLATFORM(MAC)
-    const SimpleFontData* fontForSelection(bool&) const;
-    NSDictionary* fontAttributesForSelectionStart() const;
-    bool canCopyExcludingStandaloneImages();
-    void takeFindStringFromSelection();
-    void writeSelectionToPasteboard(Pasteboard&);
-    void readSelectionFromPasteboard(const String& pasteboardName);
-    String stringSelectionForPasteboard();
-    String stringSelectionForPasteboardWithImageAltText();
-    PassRefPtr<SharedBuffer> dataSelectionForPasteboard(const String& pasteboardName);
-    void writeURLToPasteboard(Pasteboard&, const KURL&, const String& title);
-    void writeImageToPasteboard(Pasteboard&, Element& imageElement, const KURL&, const String& title);
-#endif
-
     void replaceSelectionWithFragment(PassRefPtr<DocumentFragment>, bool selectReplacement, bool smartReplace, bool matchStyle);
     void replaceSelectionWithText(const String&, bool selectReplacement, bool smartReplace);
     bool selectionStartHasMarkerFor(DocumentMarker::MarkerType, int from, int length) const;
@@ -411,11 +362,78 @@
     Vector<String> dictationAlternativesForMarker(const DocumentMarker*);
     void applyDictationAlternativelternative(const String& alternativeString);
 
+    PassRefPtr<Range> avoidIntersectionWithDeleteButtonController(const Range*) const;
+    VisibleSelection avoidIntersectionWithDeleteButtonController(const VisibleSelection&) const;
+
+#if USE(APPKIT)
+    void uppercaseWord();
+    void lowercaseWord();
+    void capitalizeWord();
+#endif
+
+#if USE(AUTOMATIC_TEXT_REPLACEMENT)
+    void showSubstitutionsPanel();
+    bool substitutionsPanelIsShowing();
+    void toggleSmartInsertDelete();
+    bool isAutomaticQuoteSubstitutionEnabled();
+    void toggleAutomaticQuoteSubstitution();
+    bool isAutomaticLinkDetectionEnabled();
+    void toggleAutomaticLinkDetection();
+    bool isAutomaticDashSubstitutionEnabled();
+    void toggleAutomaticDashSubstitution();
+    bool isAutomaticTextReplacementEnabled();
+    void toggleAutomaticTextReplacement();
+    bool isAutomaticSpellingCorrectionEnabled();
+    void toggleAutomaticSpellingCorrection();
+#endif
+
+#if ENABLE(DELETION_UI)
+    DeleteButtonController& deleteButtonController() const { return *m_deleteButtonController; }
+#endif
+
+#if PLATFORM(MAC)
+    bool insertParagraphSeparatorInQuotedContent();
+    const SimpleFontData* fontForSelection(bool&) const;
+    NSDictionary* fontAttributesForSelectionStart() const;
+    bool canCopyExcludingStandaloneImages();
+    void takeFindStringFromSelection();
+    void writeSelectionToPasteboard(Pasteboard&);
+    void readSelectionFromPasteboard(const String& pasteboardName);
+    String stringSelectionForPasteboard();
+    String stringSelectionForPasteboardWithImageAltText();
+    PassRefPtr<SharedBuffer> dataSelectionForPasteboard(const String& pasteboardName);
+    void writeURLToPasteboard(Pasteboard&, const KURL&, const String& title);
+    void writeImageToPasteboard(Pasteboard&, Element& imageElement, const KURL&, const String& title);
+    String readPlainTextFromPasteboard(Pasteboard&);
+#endif
+
 private:
     explicit Editor(Frame&);
 
     Document& document() const;
 
+    bool canDeleteRange(Range*) const;
+    bool canSmartReplaceWithPasteboard(Pasteboard*);
+    void pasteAsPlainTextWithPasteboard(Pasteboard*);
+    void pasteWithPasteboard(Pasteboard*, bool allowPlainText);
+
+    void revealSelectionAfterEditingOperation(const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent);
+    void markMisspellingsOrBadGrammar(const VisibleSelection&, bool checkSpelling, RefPtr<Range>& firstMisspellingRange);
+    TextCheckingTypeMask resolveTextCheckingTypeMask(TextCheckingTypeMask);
+
+    String selectedText(TextIteratorBehavior) const;
+
+    void selectComposition();
+    enum SetCompositionMode { ConfirmComposition, CancelComposition };
+    void setComposition(const String&, SetCompositionMode);
+
+    void changeSelectionAfterCommand(const VisibleSelection& newSelection, FrameSelection::SetSelectionOptions);
+    void notifyComponentsOnChangedSelection(const VisibleSelection& oldSelection, FrameSelection::SetSelectionOptions);
+
+    Node* findEventTargetFromSelection() const;
+
+    bool unifiedTextCheckerEnabled() const;
+
 #if PLATFORM(MAC)
     PassRefPtr<SharedBuffer> selectionInWebArchiveFormat();
     PassRefPtr<Range> adjustedSelectionRange();
@@ -440,28 +458,6 @@
     bool m_areMarkedTextMatchesHighlighted;
     EditorParagraphSeparator m_defaultParagraphSeparator;
     bool m_overwriteModeEnabled;
-
-    bool canDeleteRange(Range*) const;
-    bool canSmartReplaceWithPasteboard(Pasteboard*);
-    void pasteAsPlainTextWithPasteboard(Pasteboard*);
-    void pasteWithPasteboard(Pasteboard*, bool allowPlainText);
-
-    void revealSelectionAfterEditingOperation(const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent);
-    void markMisspellingsOrBadGrammar(const VisibleSelection&, bool checkSpelling, RefPtr<Range>& firstMisspellingRange);
-    TextCheckingTypeMask resolveTextCheckingTypeMask(TextCheckingTypeMask);
-
-    String selectedText(TextIteratorBehavior) const;
-
-    void selectComposition();
-    enum SetCompositionMode { ConfirmComposition, CancelComposition };
-    void setComposition(const String&, SetCompositionMode);
-
-    void changeSelectionAfterCommand(const VisibleSelection& newSelection, FrameSelection::SetSelectionOptions);
-    void notifyComponentsOnChangedSelection(const VisibleSelection& oldSelection, FrameSelection::SetSelectionOptions);
-
-    Node* findEventTargetFromSelection() const;
-
-    bool unifiedTextCheckerEnabled() const;
 };
 
 inline void Editor::setStartNewKillRingSequence(bool flag)
@@ -484,7 +480,20 @@
     return m_areMarkedTextMatchesHighlighted;
 }
 
+#if !ENABLE(DELETION_UI)
 
+inline PassRefPtr<Range> Editor::avoidIntersectionWithDeleteButtonController(const Range* range) const
+{
+    return const_cast<Range*>(range);
+}
+
+inline VisibleSelection Editor::avoidIntersectionWithDeleteButtonController(const VisibleSelection& selection) const
+{
+    return selection;
+}
+
+#endif
+
 } // namespace WebCore
 
 #endif // Editor_h

Modified: trunk/Source/WebCore/editing/markup.cpp (155319 => 155320)


--- trunk/Source/WebCore/editing/markup.cpp	2013-09-09 03:54:14 UTC (rev 155319)
+++ trunk/Source/WebCore/editing/markup.cpp	2013-09-09 05:12:43 UTC (rev 155320)
@@ -757,14 +757,14 @@
 String createMarkup(const Node* node, EChildrenOnly childrenOnly, Vector<Node*>* nodes, EAbsoluteURLs shouldResolveURLs, Vector<QualifiedName>* tagNamesToSkip, EFragmentSerialization fragmentSerialization)
 {
     if (!node)
-        return "";
+        return emptyString();
 
     HTMLElement* deleteButtonContainerElement = 0;
 #if ENABLE(DELETION_UI)
     if (Frame* frame = node->document().frame()) {
-        deleteButtonContainerElement = frame->editor().deleteButtonController()->containerElement();
+        deleteButtonContainerElement = frame->editor().deleteButtonController().containerElement();
         if (node->isDescendantOf(deleteButtonContainerElement))
-            return "";
+            return emptyString();
     }
 #endif
     MarkupAccumulator accumulator(nodes, shouldResolveURLs, 0, fragmentSerialization);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to