TextCheckingParagraph::isEmpty() is sufficient to check whether paragraph is empty
authorg.czajkowski@samsung.com <g.czajkowski@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Mar 2015 08:56:22 +0000 (08:56 +0000)
committerg.czajkowski@samsung.com <g.czajkowski@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Mar 2015 08:56:22 +0000 (08:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142276

Reviewed by Darin Adler.

TextCheckingParagraph::isEmpty() already calls TextCheckingParagraph::isRangeEmpty().
There is no need to call them both at the caller site.

No new tests. No behavior change.

* editing/Editor.cpp:
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
Update caller site.

* editing/TextCheckingHelper.cpp:
(WebCore::TextCheckingParagraph::isEmpty):
Avoid using helepers here to get rid of them as they are
no longer needed outside TextCheckingParagraph.

* editing/TextCheckingHelper.h:
(WebCore::TextCheckingParagraph::isTextEmpty): Deleted.
(WebCore::TextCheckingParagraph::isRangeEmpty): Deleted.
Do not expose isTextEmpty() and isRangeEmpty().

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

Source/WebCore/ChangeLog
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/TextCheckingHelper.cpp
Source/WebCore/editing/TextCheckingHelper.h

index f4bbf72..52c2e1d 100644 (file)
@@ -1,3 +1,29 @@
+2015-03-05  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
+
+        TextCheckingParagraph::isEmpty() is sufficient to check whether paragraph is empty
+        https://bugs.webkit.org/show_bug.cgi?id=142276
+
+        Reviewed by Darin Adler.
+
+        TextCheckingParagraph::isEmpty() already calls TextCheckingParagraph::isRangeEmpty().
+        There is no need to call them both at the caller site.
+
+        No new tests. No behavior change.
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
+        Update caller site.
+
+        * editing/TextCheckingHelper.cpp:
+        (WebCore::TextCheckingParagraph::isEmpty):
+        Avoid using helepers here to get rid of them as they are
+        no longer needed outside TextCheckingParagraph.
+
+        * editing/TextCheckingHelper.h:
+        (WebCore::TextCheckingParagraph::isTextEmpty): Deleted.
+        (WebCore::TextCheckingParagraph::isRangeEmpty): Deleted.
+        Do not expose isTextEmpty() and isRangeEmpty().
+
 2015-03-04  Simon Fraser  <simon.fraser@apple.com>
 
         Clarify RenderElement::adjustStyleDifference()
index b07a9ea..710aa39 100644 (file)
@@ -2352,7 +2352,7 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textC
 
     Range* rangeToCheck = shouldMarkGrammar ? grammarRange : spellingRange;
     TextCheckingParagraph paragraphToCheck(rangeToCheck);
-    if (paragraphToCheck.isRangeEmpty() || paragraphToCheck.isEmpty())
+    if (paragraphToCheck.isEmpty())
         return;
     RefPtr<Range> paragraphRange = paragraphToCheck.paragraphRange();
 
index e7d5b45..024d2ad 100644 (file)
@@ -184,7 +184,7 @@ bool TextCheckingParagraph::isEmpty() const
 {
     // Both predicates should have same result, but we check both just for sure.
     // We need to investigate to remove this redundancy.
-    return isRangeEmpty() || isTextEmpty();
+    return checkingStart() >= checkingEnd() || text().isEmpty();
 }
 
 PassRefPtr<Range> TextCheckingParagraph::offsetAsRange() const
index 246d256..9ecba12 100644 (file)
@@ -50,10 +50,8 @@ public:
     int textLength() const { return text().length(); }
     String textSubstring(unsigned pos, unsigned len = UINT_MAX) const { return text().substring(pos, len); }
     UChar textCharAt(int index) const { return text()[static_cast<unsigned>(index)]; }
-    bool isTextEmpty() const { return text().isEmpty(); }
 
     bool isEmpty() const;
-    bool isRangeEmpty() const { return checkingStart() >= checkingEnd(); }
 
     int checkingStart() const;
     int checkingEnd() const;