Minor cleanups to IndentOutdentCommand and related code
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Jan 2017 02:59:12 +0000 (02:59 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Jan 2017 02:59:12 +0000 (02:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166791

Reviewed by Simon Fraser.

Source/WebCore:

* editing/IndentOutdentCommand.cpp:
(WebCore::IndentOutdentCommand::IndentOutdentCommand):
(WebCore::IndentOutdentCommand::outdentRegion):
* editing/IndentOutdentCommand.h:
(WebCore::IndentOutdentCommand::create):
Remove the unused m_marginInPixels and fix the copyright header.

Tools:

* WebEditingTester/EditingOperations.m:
(editingOperations):
Add the outdent operation to WebEditingTester.

LayoutTests:

* editing/execCommand/19653-1-expected.txt:
* editing/execCommand/19653-1.html:
Adjust this indenting test. It had a mislabeled test case (it outdents, not indents),
and also was copy-pasted wrong (it wasn't indented in the first place).

However, since this technically reduces test coverage, keep the existing
(but now correctly labeled) test case, since it caught a bug in code I was changing.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210466 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/execCommand/19653-1-expected.txt
LayoutTests/editing/execCommand/19653-1.html
Source/WebCore/ChangeLog
Source/WebCore/editing/IndentOutdentCommand.cpp
Source/WebCore/editing/IndentOutdentCommand.h
Tools/ChangeLog
Tools/WebEditingTester/EditingOperations.m

index 238c561..8450405 100644 (file)
@@ -1,3 +1,18 @@
+2017-01-06  Tim Horton  <timothy_horton@apple.com>
+
+        Minor cleanups to IndentOutdentCommand and related code
+        https://bugs.webkit.org/show_bug.cgi?id=166791
+
+        Reviewed by Simon Fraser.
+
+        * editing/execCommand/19653-1-expected.txt:
+        * editing/execCommand/19653-1.html:
+        Adjust this indenting test. It had a mislabeled test case (it outdents, not indents),
+        and also was copy-pasted wrong (it wasn't indented in the first place).
+
+        However, since this technically reduces test coverage, keep the existing
+        (but now correctly labeled) test case, since it caught a bug in code I was changing.
+
 2017-01-06  Ryan Haddad  <ryanhaddad@apple.com>
 
         Marking fast/text/variations/advances.html as failing on Sierra.
index eb19b02..b744958 100644 (file)
@@ -13,5 +13,8 @@ This tests indenting an empty paragraph when the typing style was Bold. The word
 This tests outdenting an empty paragraph with bold already applied to it. The word below should be bold.
 <b>Bold</b>
 
-This tests indenting an empty paragraph when the typing style was Bold. The word below should be bold.
+This tests outdenting an empty paragraph when the typing style was Bold. The word below should be bold.
+<b>Bold</b>
+
+This tests outdenting an non-indented empty paragraph when the typing style was Bold. The word below should be bold.
 <b>Bold</b>
index 2bd2bb2..c401df5 100644 (file)
 <div id="description5">This tests outdenting an empty paragraph with bold already applied to it. The word below should be bold.</div>
 <div id="edit5" contentEditable="true"><blockquote class="webkit-indent-blockquote"><b><br></b></blockquote></div>
 
-<div id="description6">This tests indenting an empty paragraph when the typing style was Bold. The word below should be bold.</div>
-<div id="edit6" contentEditable="true"></div>
+<div id="description6">This tests outdenting an empty paragraph when the typing style was Bold. The word below should be bold.</div>
+<div id="edit6" contentEditable="true"><blockquote class="webkit-indent-blockquote"><br></blockquote></div>
+
+<div id="description7">This tests outdenting an non-indented empty paragraph when the typing style was Bold. The word below should be bold.</div>
+<div id="edit7" contentEditable="true"></div>
 
 <script>
 if (window.testRunner)
@@ -52,12 +55,19 @@ document.execCommand("Bold");
 document.execCommand("Outdent");
 document.execCommand("InsertText", false, "Bold");
 
+edit7 = document.getElementById("edit7");
+edit7.focus();
+document.execCommand("Bold");
+document.execCommand("Outdent");
+document.execCommand("InsertText", false, "Bold");
+
 if (window.testRunner)
     document.body.innerText = document.getElementById("description1").innerText + "\n" + edit1.innerHTML + "\n\n" +
                               document.getElementById("description2").innerText + "\n" + edit2.innerHTML + "\n\n" +
                               document.getElementById("description3").innerText + "\n" + edit3.innerHTML + "\n\n" +
                               document.getElementById("description4").innerText + "\n" + edit4.innerHTML + "\n\n" +
                               document.getElementById("description5").innerText + "\n" + edit5.innerHTML + "\n\n" +
-                              document.getElementById("description6").innerText + "\n" + edit6.innerHTML;
+                              document.getElementById("description6").innerText + "\n" + edit6.innerHTML + "\n\n" +
+                              document.getElementById("description7").innerText + "\n" + edit7.innerHTML;
 
 </script>
index 952dcd8..215223b 100644 (file)
@@ -1,3 +1,17 @@
+2017-01-06  Tim Horton  <timothy_horton@apple.com>
+
+        Minor cleanups to IndentOutdentCommand and related code
+        https://bugs.webkit.org/show_bug.cgi?id=166791
+
+        Reviewed by Simon Fraser.
+
+        * editing/IndentOutdentCommand.cpp:
+        (WebCore::IndentOutdentCommand::IndentOutdentCommand):
+        (WebCore::IndentOutdentCommand::outdentRegion):
+        * editing/IndentOutdentCommand.h:
+        (WebCore::IndentOutdentCommand::create):
+        Remove the unused m_marginInPixels and fix the copyright header.
+
 2017-01-06  Alex Christensen  <achristensen@webkit.org>
 
         Fix WinCairo build after r210319.
index e28e97d..75a91c5 100644 (file)
@@ -15,7 +15,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (IndentOutdentCommandINCLUDING, BUT NOT LIMITED TO,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES INCLUDING, BUT NOT LIMITED TO,
  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
@@ -49,10 +49,9 @@ static bool isListOrIndentBlockquote(const Node* node)
     return node && (node->hasTagName(ulTag) || node->hasTagName(olTag) || node->hasTagName(blockquoteTag));
 }
 
-IndentOutdentCommand::IndentOutdentCommand(Document& document, EIndentType typeOfAction, int marginInPixels)
+IndentOutdentCommand::IndentOutdentCommand(Document& document, EIndentType typeOfAction)
     : ApplyBlockElementCommand(document, blockquoteTag, "margin: 0 0 0 40px; border: none; padding: 0px;")
     , m_typeOfAction(typeOfAction)
-    , m_marginInPixels(marginInPixels)
 {
 }
 
@@ -198,7 +197,7 @@ void IndentOutdentCommand::outdentRegion(const VisiblePosition& startOfSelection
         outdentParagraph();
         return;
     }
-    
+
     Position originalSelectionEnd = endingSelection().end();
     VisiblePosition endOfCurrentParagraph = endOfParagraph(startOfSelection);
     VisiblePosition endAfterSelection = endOfParagraph(endOfParagraph(endOfSelection).next());
@@ -209,15 +208,15 @@ void IndentOutdentCommand::outdentRegion(const VisiblePosition& startOfSelection
             setEndingSelection(VisibleSelection(originalSelectionEnd, DOWNSTREAM));
         else
             setEndingSelection(endOfCurrentParagraph);
-        
+
         outdentParagraph();
-        
+
         // outdentParagraph could move more than one paragraph if the paragraph
         // is in a list item. As a result, endAfterSelection and endOfNextParagraph
         // could refer to positions no longer in the document.
         if (endAfterSelection.isNotNull() && !endAfterSelection.deepEquivalent().anchorNode()->inDocument())
             break;
-            
+
         if (endOfNextParagraph.isNotNull() && !endOfNextParagraph.deepEquivalent().anchorNode()->inDocument()) {
             endOfCurrentParagraph = endingSelection().end();
             endOfNextParagraph = endOfParagraph(endOfCurrentParagraph.next());
index b6356b8..c30f743 100644 (file)
@@ -33,15 +33,15 @@ namespace WebCore {
 class IndentOutdentCommand : public ApplyBlockElementCommand {
 public:
     enum EIndentType { Indent, Outdent };
-    static Ref<IndentOutdentCommand> create(Document& document, EIndentType type, int marginInPixels = 0)
+    static Ref<IndentOutdentCommand> create(Document& document, EIndentType type)
     {
-        return adoptRef(*new IndentOutdentCommand(document, type, marginInPixels));
+        return adoptRef(*new IndentOutdentCommand(document, type));
     }
 
     bool preservesTypingStyle() const override { return true; }
 
 private:
-    IndentOutdentCommand(Document&, EIndentType, int marginInPixels);
+    IndentOutdentCommand(Document&, EIndentType);
 
     EditAction editingAction() const override { return m_typeOfAction == Indent ? EditActionIndent : EditActionOutdent; }
 
@@ -55,7 +55,6 @@ private:
     void formatRange(const Position& start, const Position& end, const Position& endOfSelection, RefPtr<Element>& blockquoteForNextIndent) override;
 
     EIndentType m_typeOfAction;
-    int m_marginInPixels;
 };
 
 } // namespace WebCore
index 4dbe35b..2f13530 100644 (file)
@@ -1,3 +1,14 @@
+2017-01-06  Tim Horton  <timothy_horton@apple.com>
+
+        Minor cleanups to IndentOutdentCommand and related code
+        https://bugs.webkit.org/show_bug.cgi?id=166791
+
+        Reviewed by Simon Fraser.
+
+        * WebEditingTester/EditingOperations.m:
+        (editingOperations):
+        Add the outdent operation to WebEditingTester.
+
 2017-01-06  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         Create a plan and a patch files for MotionMark and delete the Animometer's ones
index f654c35..201f364 100644 (file)
@@ -102,6 +102,7 @@ NSArray *editingOperations()
         @"moveWordLeftAndModifySelection:",
         @"moveWordRight:",
         @"moveWordRightAndModifySelection:",
+        @"outdent:",
         @"outline:",
         @"pageDown:",
         @"pageDownAndModifySelection:",