Title: [117100] branches/safari-536-branch/Source/WebCore

Diff

Modified: branches/safari-536-branch/Source/WebCore/ChangeLog (117099 => 117100)


--- branches/safari-536-branch/Source/WebCore/ChangeLog	2012-05-15 18:08:56 UTC (rev 117099)
+++ branches/safari-536-branch/Source/WebCore/ChangeLog	2012-05-15 18:10:42 UTC (rev 117100)
@@ -1,5 +1,33 @@
 2012-05-15  Lucas Forschler  <[email protected]>
 
+    Merge 116368
+
+    2012-05-07  Enrica Casucci  <[email protected]>
+
+            REGRESSION (r101575): Chinese input is broken when composing mail in iCloud using Safari.
+            https://bugs.webkit.org/show_bug.cgi?id=85840
+            <rdar://problem/11115520> 
+
+            Reviewed by Alexey Proskuryakov.
+
+            The revision that broke this, introduced a way to sanitize the markup when deleting a range selection.
+            iCloud listens for DOM modification events and clears the selection, altering the input method state.
+            The fix consists in adding a paramenter to DeleteSelectionCommand to control when we sanitize the
+            markup.
+
+            * editing/CompositeEditCommand.cpp:
+            (WebCore::CompositeEditCommand::deleteSelection):
+            * editing/CompositeEditCommand.h:
+            * editing/DeleteSelectionCommand.cpp:
+            (WebCore::DeleteSelectionCommand::DeleteSelectionCommand):
+            (WebCore::DeleteSelectionCommand::doApply):
+            * editing/DeleteSelectionCommand.h:
+            (WebCore::DeleteSelectionCommand::create):
+            * editing/InsertTextCommand.cpp:
+            (WebCore::InsertTextCommand::doApply):
+
+2012-05-15  Lucas Forschler  <[email protected]>
+
     Merge 116367
 
     2012-05-07  Andy Estes  <[email protected]>

Modified: branches/safari-536-branch/Source/WebCore/editing/CompositeEditCommand.cpp (117099 => 117100)


--- branches/safari-536-branch/Source/WebCore/editing/CompositeEditCommand.cpp	2012-05-15 18:08:56 UTC (rev 117099)
+++ branches/safari-536-branch/Source/WebCore/editing/CompositeEditCommand.cpp	2012-05-15 18:10:42 UTC (rev 117100)
@@ -553,16 +553,16 @@
     insertNodeAt(node, positionOutsideTabSpan(pos));
 }
 
-void CompositeEditCommand::deleteSelection(bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements)
+void CompositeEditCommand::deleteSelection(bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements, bool sanitizeMarkup)
 {
     if (endingSelection().isRange())
-        applyCommandToComposite(DeleteSelectionCommand::create(document(), smartDelete, mergeBlocksAfterDelete, replace, expandForSpecialElements));
+        applyCommandToComposite(DeleteSelectionCommand::create(document(), smartDelete, mergeBlocksAfterDelete, replace, expandForSpecialElements, sanitizeMarkup));
 }
 
-void CompositeEditCommand::deleteSelection(const VisibleSelection &selection, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements)
+void CompositeEditCommand::deleteSelection(const VisibleSelection &selection, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements, bool sanitizeMarkup)
 {
     if (selection.isRange())
-        applyCommandToComposite(DeleteSelectionCommand::create(selection, smartDelete, mergeBlocksAfterDelete, replace, expandForSpecialElements));
+        applyCommandToComposite(DeleteSelectionCommand::create(selection, smartDelete, mergeBlocksAfterDelete, replace, expandForSpecialElements, sanitizeMarkup));
 }
 
 void CompositeEditCommand::removeCSSProperty(PassRefPtr<StyledElement> element, CSSPropertyID property)

Modified: branches/safari-536-branch/Source/WebCore/editing/CompositeEditCommand.h (117099 => 117100)


--- branches/safari-536-branch/Source/WebCore/editing/CompositeEditCommand.h	2012-05-15 18:08:56 UTC (rev 117099)
+++ branches/safari-536-branch/Source/WebCore/editing/CompositeEditCommand.h	2012-05-15 18:10:42 UTC (rev 117100)
@@ -101,8 +101,8 @@
     void applyStyle(const EditingStyle*, const Position& start, const Position& end, EditAction = EditActionChangeAttributes);
     void applyStyledElement(PassRefPtr<Element>);
     void removeStyledElement(PassRefPtr<Element>);
-    void deleteSelection(bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = true);
-    void deleteSelection(const VisibleSelection&, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = true);
+    void deleteSelection(bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = true, bool sanitizeMarkup = true);
+    void deleteSelection(const VisibleSelection&, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = true, bool sanitizeMarkup = true);
     virtual void deleteTextFromNode(PassRefPtr<Text>, unsigned offset, unsigned count);
     bool isRemovableBlock(const Node*);
     void insertNodeAfter(PassRefPtr<Node>, PassRefPtr<Node> refChild);

Modified: branches/safari-536-branch/Source/WebCore/editing/DeleteSelectionCommand.cpp (117099 => 117100)


--- branches/safari-536-branch/Source/WebCore/editing/DeleteSelectionCommand.cpp	2012-05-15 18:08:56 UTC (rev 117099)
+++ branches/safari-536-branch/Source/WebCore/editing/DeleteSelectionCommand.cpp	2012-05-15 18:10:42 UTC (rev 117100)
@@ -68,7 +68,7 @@
     return true;
 }
 
-DeleteSelectionCommand::DeleteSelectionCommand(Document *document, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements)
+DeleteSelectionCommand::DeleteSelectionCommand(Document *document, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements, bool sanitizeMarkup)
     : CompositeEditCommand(document)
     , m_hasSelectionToDelete(false)
     , m_smartDelete(smartDelete)
@@ -78,6 +78,7 @@
     , m_expandForSpecialElements(expandForSpecialElements)
     , m_pruneStartBlockIfNecessary(false)
     , m_startsAtEmptyLine(false)
+    , m_sanitizeMarkup(sanitizeMarkup)
     , m_startBlock(0)
     , m_endBlock(0)
     , m_typingStyle(0)
@@ -85,7 +86,7 @@
 {
 }
 
-DeleteSelectionCommand::DeleteSelectionCommand(const VisibleSelection& selection, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements)
+DeleteSelectionCommand::DeleteSelectionCommand(const VisibleSelection& selection, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements, bool sanitizeMarkup)
     : CompositeEditCommand(selection.start().anchorNode()->document())
     , m_hasSelectionToDelete(true)
     , m_smartDelete(smartDelete)
@@ -95,6 +96,7 @@
     , m_expandForSpecialElements(expandForSpecialElements)
     , m_pruneStartBlockIfNecessary(false)
     , m_startsAtEmptyLine(false)
+    , m_sanitizeMarkup(sanitizeMarkup)
     , m_selectionToDelete(selection)
     , m_startBlock(0)
     , m_endBlock(0)
@@ -814,7 +816,8 @@
     RefPtr<Node> placeholder = m_needPlaceholder ? createBreakElement(document()).get() : 0;
     
     if (placeholder) {
-        removeRedundantBlocks();
+        if (m_sanitizeMarkup)
+            removeRedundantBlocks();
         insertNodeAt(placeholder.get(), m_endingPosition);
     }
 

Modified: branches/safari-536-branch/Source/WebCore/editing/DeleteSelectionCommand.h (117099 => 117100)


--- branches/safari-536-branch/Source/WebCore/editing/DeleteSelectionCommand.h	2012-05-15 18:08:56 UTC (rev 117099)
+++ branches/safari-536-branch/Source/WebCore/editing/DeleteSelectionCommand.h	2012-05-15 18:10:42 UTC (rev 117100)
@@ -34,18 +34,18 @@
 
 class DeleteSelectionCommand : public CompositeEditCommand { 
 public:
-    static PassRefPtr<DeleteSelectionCommand> create(Document* document, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = false)
+    static PassRefPtr<DeleteSelectionCommand> create(Document* document, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = false, bool sanitizeMarkup = true)
     {
-        return adoptRef(new DeleteSelectionCommand(document, smartDelete, mergeBlocksAfterDelete, replace, expandForSpecialElements));
+        return adoptRef(new DeleteSelectionCommand(document, smartDelete, mergeBlocksAfterDelete, replace, expandForSpecialElements, sanitizeMarkup));
     }
-    static PassRefPtr<DeleteSelectionCommand> create(const VisibleSelection& selection, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = false)
+    static PassRefPtr<DeleteSelectionCommand> create(const VisibleSelection& selection, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = false, bool sanitizeMarkup = true)
     {
-        return adoptRef(new DeleteSelectionCommand(selection, smartDelete, mergeBlocksAfterDelete, replace, expandForSpecialElements));
+        return adoptRef(new DeleteSelectionCommand(selection, smartDelete, mergeBlocksAfterDelete, replace, expandForSpecialElements, sanitizeMarkup));
     }
 
 private:
-    DeleteSelectionCommand(Document*, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements);
-    DeleteSelectionCommand(const VisibleSelection&, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements);
+    DeleteSelectionCommand(Document*, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements, bool santizeMarkup);
+    DeleteSelectionCommand(const VisibleSelection&, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements, bool sanitizeMarkup);
 
     virtual void doApply();
     virtual EditAction editingAction() const;
@@ -80,6 +80,7 @@
     bool m_expandForSpecialElements;
     bool m_pruneStartBlockIfNecessary;
     bool m_startsAtEmptyLine;
+    bool m_sanitizeMarkup;
 
     // This data is transient and should be cleared at the end of the doApply function.
     VisibleSelection m_selectionToDelete;

Modified: branches/safari-536-branch/Source/WebCore/editing/InsertTextCommand.cpp (117099 => 117100)


--- branches/safari-536-branch/Source/WebCore/editing/InsertTextCommand.cpp	2012-05-15 18:08:56 UTC (rev 117099)
+++ branches/safari-536-branch/Source/WebCore/editing/InsertTextCommand.cpp	2012-05-15 18:10:42 UTC (rev 117100)
@@ -116,7 +116,7 @@
     if (endingSelection().isRange()) {
         if (performTrivialReplace(m_text, m_selectInsertedText))
             return;
-        deleteSelection(false, true, true, false);
+        deleteSelection(false, true, true, false, false);
         // deleteSelection eventually makes a new endingSelection out of a Position. If that Position doesn't have
         // a renderer (e.g. it is on a <frameset> in the DOM), the VisibleSelection cannot be canonicalized to 
         // anything other than NoSelection. The rest of this function requires a real endingSelection, so bail out.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to