[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

rniwa at webkit.org rniwa at webkit.org
Wed Dec 22 11:27:31 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit f6dac76bc3d9214b0827295158df28c7f2ffe31a
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jul 26 04:10:14 2010 +0000

    splitTextAt*IfNeed and splitTextElementAt*IfNeed need to be cleaned up
    https://bugs.webkit.org/show_bug.cgi?id=42937
    
    Reviewed by Kent Tamura.
    
    Isolated the code to decide whether or not text node should be split into isValidCaretPositionInTextNode.
    Moved the condition check out of *IfNeeded methods to applyRelativeFontStyleChange and applyInlineStyle.
    
    No new tests added since this is a clean up.
    
    * editing/ApplyStyleCommand.cpp:
    (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange): Uses isValidCaretPositionInTextNode.
    (WebCore::ApplyStyleCommand::applyInlineStyle): Uses isValidCaretPositionInTextNode.
    (WebCore::ApplyStyleCommand::splitTextAtStart): Renamed from splitTextAtStartIfNeeded.
    (WebCore::ApplyStyleCommand::splitTextAtEnd): Renamed from splitTextAtEndIfNeeded.
    (WebCore::ApplyStyleCommand::splitTextElementAtStart): Renamed from splitTextElementAtStartIfNeeded.
    (WebCore::ApplyStyleCommand::splitTextElementAtEnd): Renamed from splitTextElementAtEndIfNeeded.
    (WebCore::ApplyStyleCommand::isValidCaretPositionInTextNode): Returns true if the position lies within a text node.
    * editing/ApplyStyleCommand.h:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64028 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e2b5fab..dacd9ef 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-07-25  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Kent Tamura.
+
+        splitTextAt*IfNeed and splitTextElementAt*IfNeed need to be cleaned up
+        https://bugs.webkit.org/show_bug.cgi?id=42937
+
+        Isolated the code to decide whether or not text node should be split into isValidCaretPositionInTextNode.
+        Moved the condition check out of *IfNeeded methods to applyRelativeFontStyleChange and applyInlineStyle.
+
+        No new tests added since this is a clean up.
+
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange): Uses isValidCaretPositionInTextNode.
+        (WebCore::ApplyStyleCommand::applyInlineStyle): Uses isValidCaretPositionInTextNode.
+        (WebCore::ApplyStyleCommand::splitTextAtStart): Renamed from splitTextAtStartIfNeeded.
+        (WebCore::ApplyStyleCommand::splitTextAtEnd): Renamed from splitTextAtEndIfNeeded.
+        (WebCore::ApplyStyleCommand::splitTextElementAtStart): Renamed from splitTextElementAtStartIfNeeded.
+        (WebCore::ApplyStyleCommand::splitTextElementAtEnd): Renamed from splitTextElementAtEndIfNeeded.
+        (WebCore::ApplyStyleCommand::isValidCaretPositionInTextNode): Returns true if the position lies within a text node.
+        * editing/ApplyStyleCommand.h:
+
 2010-07-25  Patrick Gansterer  <paroga at paroga.com>
 
         Reviewed by Kent Tamura.
diff --git a/WebCore/editing/ApplyStyleCommand.cpp b/WebCore/editing/ApplyStyleCommand.cpp
index c50c988..8e6ce63 100644
--- a/WebCore/editing/ApplyStyleCommand.cpp
+++ b/WebCore/editing/ApplyStyleCommand.cpp
@@ -684,13 +684,14 @@ void ApplyStyleCommand::applyRelativeFontStyleChange(CSSMutableStyleDeclaration
     }
 
     // Split the start text nodes if needed to apply style.
-    bool splitStart = splitTextAtStartIfNeeded(start, end); 
-    if (splitStart) {
+    if (isValidCaretPositionInTextNode(start)) {
+        splitTextAtStart(start, end);
         start = startPosition();
         end = endPosition();
     }
-    bool splitEnd = splitTextAtEndIfNeeded(start, end);
-    if (splitEnd) {
+
+    if (isValidCaretPositionInTextNode(end)) {
+        splitTextAtEnd(start, end);
         start = startPosition();
         end = endPosition();
     }
@@ -907,16 +908,18 @@ void ApplyStyleCommand::applyInlineStyle(CSSMutableStyleDeclaration *style)
     }
 
     // split the start node and containing element if the selection starts inside of it
-    bool splitStart = splitTextElementAtStartIfNeeded(start, end); 
+    bool splitStart = isValidCaretPositionInTextNode(start);
     if (splitStart) {
+        splitTextElementAtStart(start, end);
         start = startPosition();
         end = endPosition();
         startDummySpanAncestor = dummySpanAncestorForNode(start.node());
     }
 
     // split the end node and containing element if the selection ends inside of it
-    bool splitEnd = splitTextElementAtEndIfNeeded(start, end);
+    bool splitEnd = isValidCaretPositionInTextNode(end);
     if (splitEnd) {
+        splitTextElementAtEnd(start, end);
         start = startPosition();
         end = endPosition();
         endDummySpanAncestor = dummySpanAncestorForNode(end.node());
@@ -1529,62 +1532,53 @@ bool ApplyStyleCommand::nodeFullyUnselected(Node *node, const Position &start, c
     return isFullyBeforeStart || isFullyAfterEnd;
 }
 
+void ApplyStyleCommand::splitTextAtStart(const Position& start, const Position& end)
+{
+    int endOffsetAdjustment = start.node() == end.node() ? start.deprecatedEditingOffset() : 0;
+    Text* text = static_cast<Text*>(start.node());
+    splitTextNode(text, start.deprecatedEditingOffset());
+    updateStartEnd(Position(start.node(), 0), Position(end.node(), end.deprecatedEditingOffset() - endOffsetAdjustment));
+}
 
-bool ApplyStyleCommand::splitTextAtStartIfNeeded(const Position &start, const Position &end)
+void ApplyStyleCommand::splitTextAtEnd(const Position& start, const Position& end)
 {
-    if (start.node()->isTextNode() && start.deprecatedEditingOffset() > caretMinOffset(start.node()) && start.deprecatedEditingOffset() < caretMaxOffset(start.node())) {
-        int endOffsetAdjustment = start.node() == end.node() ? start.deprecatedEditingOffset() : 0;
-        Text *text = static_cast<Text *>(start.node());
-        splitTextNode(text, start.deprecatedEditingOffset());
-        updateStartEnd(Position(start.node(), 0), Position(end.node(), end.deprecatedEditingOffset() - endOffsetAdjustment));
-        return true;
-    }
-    return false;
+    Text* text = static_cast<Text *>(end.node());
+    splitTextNode(text, end.deprecatedEditingOffset());
+
+    Node* prevNode = text->previousSibling();
+    ASSERT(prevNode);
+    Node* startNode = start.node() == end.node() ? prevNode : start.node();
+    ASSERT(startNode);
+    updateStartEnd(Position(startNode, start.deprecatedEditingOffset()), Position(prevNode, caretMaxOffset(prevNode)));
 }
 
-bool ApplyStyleCommand::splitTextAtEndIfNeeded(const Position &start, const Position &end)
+void ApplyStyleCommand::splitTextElementAtStart(const Position& start, const Position& end)
 {
-    if (end.node()->isTextNode() && end.deprecatedEditingOffset() > caretMinOffset(end.node()) && end.deprecatedEditingOffset() < caretMaxOffset(end.node())) {
-        Text *text = static_cast<Text *>(end.node());
-        splitTextNode(text, end.deprecatedEditingOffset());
-        
-        Node *prevNode = text->previousSibling();
-        ASSERT(prevNode);
-        Node *startNode = start.node() == end.node() ? prevNode : start.node();
-        ASSERT(startNode);
-        updateStartEnd(Position(startNode, start.deprecatedEditingOffset()), Position(prevNode, caretMaxOffset(prevNode)));
-        return true;
-    }
-    return false;
+    int endOffsetAdjustment = start.node() == end.node() ? start.deprecatedEditingOffset() : 0;
+    Text* text = static_cast<Text*>(start.node());
+    splitTextNodeContainingElement(text, start.deprecatedEditingOffset());
+    updateStartEnd(Position(start.node()->parentNode(), start.node()->nodeIndex()), Position(end.node(), end.deprecatedEditingOffset() - endOffsetAdjustment));
 }
 
-bool ApplyStyleCommand::splitTextElementAtStartIfNeeded(const Position &start, const Position &end)
+void ApplyStyleCommand::splitTextElementAtEnd(const Position& start, const Position& end)
 {
-    if (start.node()->isTextNode() && start.deprecatedEditingOffset() > caretMinOffset(start.node()) && start.deprecatedEditingOffset() < caretMaxOffset(start.node())) {
-        int endOffsetAdjustment = start.node() == end.node() ? start.deprecatedEditingOffset() : 0;
-        Text *text = static_cast<Text *>(start.node());
-        splitTextNodeContainingElement(text, start.deprecatedEditingOffset());
+    Text* text = static_cast<Text*>(end.node());
+    splitTextNodeContainingElement(text, end.deprecatedEditingOffset());
 
-        updateStartEnd(Position(start.node()->parentNode(), start.node()->nodeIndex()), Position(end.node(), end.deprecatedEditingOffset() - endOffsetAdjustment));
-        return true;
-    }
-    return false;
+    Node* prevNode = text->parent()->previousSibling()->lastChild();
+    ASSERT(prevNode);
+    Node* startNode = start.node() == end.node() ? prevNode : start.node();
+    ASSERT(startNode);
+    updateStartEnd(Position(startNode, start.deprecatedEditingOffset()), Position(prevNode->parent(), prevNode->nodeIndex() + 1));
 }
 
-bool ApplyStyleCommand::splitTextElementAtEndIfNeeded(const Position &start, const Position &end)
+bool ApplyStyleCommand::isValidCaretPositionInTextNode(const Position& position)
 {
-    if (end.node()->isTextNode() && end.deprecatedEditingOffset() > caretMinOffset(end.node()) && end.deprecatedEditingOffset() < caretMaxOffset(end.node())) {
-        Text *text = static_cast<Text *>(end.node());
-        splitTextNodeContainingElement(text, end.deprecatedEditingOffset());
-
-        Node *prevNode = text->parent()->previousSibling()->lastChild();
-        ASSERT(prevNode);
-        Node *startNode = start.node() == end.node() ? prevNode : start.node();
-        ASSERT(startNode);
-        updateStartEnd(Position(startNode, start.deprecatedEditingOffset()), Position(prevNode->parent(), prevNode->nodeIndex() + 1));
-        return true;
-    }
-    return false;
+    Node* node = position.node();
+    if (!node->isTextNode())
+        return false;
+    int offsetInText = position.deprecatedEditingOffset();
+    return (offsetInText > caretMinOffset(node) && offsetInText < caretMaxOffset(node));
 }
 
 static bool areIdenticalElements(Node *first, Node *second)
diff --git a/WebCore/editing/ApplyStyleCommand.h b/WebCore/editing/ApplyStyleCommand.h
index 8326329..199b9db 100644
--- a/WebCore/editing/ApplyStyleCommand.h
+++ b/WebCore/editing/ApplyStyleCommand.h
@@ -91,10 +91,11 @@ private:
     void applyInlineStyleToRange(CSSMutableStyleDeclaration*, const Position& start, const Position& end);
     void addBlockStyle(const StyleChange&, HTMLElement*);
     void addInlineStyleIfNeeded(CSSMutableStyleDeclaration*, Node* start, Node* end);
-    bool splitTextAtStartIfNeeded(const Position& start, const Position& end);
-    bool splitTextAtEndIfNeeded(const Position& start, const Position& end);
-    bool splitTextElementAtStartIfNeeded(const Position& start, const Position& end);
-    bool splitTextElementAtEndIfNeeded(const Position& start, const Position& end);
+    void splitTextAtStart(const Position& start, const Position& end);
+    void splitTextAtEnd(const Position& start, const Position& end);
+    void splitTextElementAtStart(const Position& start, const Position& end);
+    void splitTextElementAtEnd(const Position& start, const Position& end);
+    bool isValidCaretPositionInTextNode(const Position& position);
     bool mergeStartWithPreviousIfIdentical(const Position& start, const Position& end);
     bool mergeEndWithNextIfIdentical(const Position& start, const Position& end);
     void cleanupUnstyledAppleStyleSpans(Node* dummySpanAncestor);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list