LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Oct 2006 02:35:42 +0000 (02:35 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Oct 2006 02:35:42 +0000 (02:35 +0000)
        Reviewed by mjs

        <http://bugs.webkit.org/show_bug.cgi?id=11334>
        Writely Editor: Placing caret in a list "highlights" both Numbered List and Bulleted List toolbar icons

        * editing/execCommand/queryCommandState-01-expected.txt: Added.
        * editing/execCommand/queryCommandState-01.html: Added.

WebCore:

        Reviewed by mjs

        <http://bugs.webkit.org/show_bug.cgi?id=11334>
        Writely Editor: Placing caret in a list "highlights" both Numbered List and Bulleted List toolbar icons

        * WebCore.xcodeproj/project.pbxproj:
        * editing/Editor.cpp:
        (WebCore::Editor::selectionUnorderedListState): Added.
        (WebCore::Editor::selectionOrderedListState): Added.
        * editing/Editor.h:
        * editing/JSEditor.cpp:
        * page/Frame.cpp:
        * page/Frame.h:

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

LayoutTests/ChangeLog
WebCore/ChangeLog
WebCore/editing/Editor.cpp
WebCore/editing/Editor.h
WebCore/editing/JSEditor.cpp
WebCore/page/Frame.cpp
WebCore/page/Frame.h

index aad420eba41a22778717c2227921c7f657627895..32042e775df5764253abefb5fb5f3eb731548483 100644 (file)
@@ -1,3 +1,13 @@
+2006-10-23  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by mjs
+        
+        <http://bugs.webkit.org/show_bug.cgi?id=11334>
+        Writely Editor: Placing caret in a list "highlights" both Numbered List and Bulleted List toolbar icons
+
+        * editing/execCommand/queryCommandState-01-expected.txt: Added.
+        * editing/execCommand/queryCommandState-01.html: Added.
+
 2006-10-20  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by john
index e05bdb2032b7f18ed1282d2ee597c7a205ddcfe6..9aea807ff632a9cfe743e053c4777ddad618515a 100644 (file)
@@ -1,3 +1,19 @@
+2006-10-23  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by mjs
+
+        <http://bugs.webkit.org/show_bug.cgi?id=11334>
+        Writely Editor: Placing caret in a list "highlights" both Numbered List and Bulleted List toolbar icons
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * editing/Editor.cpp:
+        (WebCore::Editor::selectionUnorderedListState): Added.
+        (WebCore::Editor::selectionOrderedListState): Added.
+        * editing/Editor.h:
+        * editing/JSEditor.cpp:
+        * page/Frame.cpp:
+        * page/Frame.h:
+
 2006-10-23  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Tim H
index ea57b9e1356e273334d8b84c99817d5cc72f35f0..d13a58963cfdb8f139ea10760b41acc3fc7b0a77 100644 (file)
 
 #include "DeleteButtonController.h"
 #include "EditorClient.h"
-#include "Frame.h"
+#include "htmlediting.h"
 #include "HTMLElement.h"
+#include "HTMLNames.h"
 #include "Range.h"
+#include "SelectionController.h"
 #include "Sound.h"
 
 namespace WebCore {
 
+using namespace HTMLNames;
+
 // implement as platform-specific
 static Pasteboard generalPasteboard()
 {
@@ -162,6 +166,38 @@ void Editor::respondToChangedContents()
     m_deleteButtonController->respondToChangedContents();
 }
 
+Frame::TriState Editor::selectionUnorderedListState() const
+{
+    if (m_frame->selectionController()->isCaret()) {
+        Node* selectionNode = m_frame->selectionController()->selection().start().node();
+        if (enclosingNodeWithTag(selectionNode, ulTag))
+            return Frame::trueTriState;
+    } else if (m_frame->selectionController()->isRange()) {
+        Node* startNode = enclosingNodeWithTag(m_frame->selectionController()->selection().start().node(), ulTag);
+        Node* endNode = enclosingNodeWithTag(m_frame->selectionController()->selection().end().node(), ulTag);
+        if (startNode && endNode && startNode == endNode)
+            return Frame::trueTriState;
+    }
+
+    return Frame::falseTriState;
+}
+
+Frame::TriState Editor::selectionOrderedListState() const
+{
+    if (m_frame->selectionController()->isCaret()) {
+        Node* selectionNode = m_frame->selectionController()->selection().start().node();
+        if (enclosingNodeWithTag(selectionNode, olTag))
+            return Frame::trueTriState;
+    } else if (m_frame->selectionController()->isRange()) {
+        Node* startNode = enclosingNodeWithTag(m_frame->selectionController()->selection().start().node(), olTag);
+        Node* endNode = enclosingNodeWithTag(m_frame->selectionController()->selection().end().node(), olTag);
+        if (startNode && endNode && startNode == endNode)
+            return Frame::trueTriState;
+    }
+
+    return Frame::falseTriState;
+}
+
 // =============================================================================
 //
 // public editing commands
index c64745d8318e2e5aec6c18989346d734cbcf3d08..838091639e17339d40fb9694e8f2a868d210dc17 100644 (file)
@@ -30,6 +30,8 @@
 #include <wtf/OwnPtr.h>
 #include <wtf/RefPtr.h>
 
+#include "Frame.h"
+
 namespace WebCore {
 
 class DeleteButtonController;
@@ -56,6 +58,9 @@ public:
 
     void respondToChangedSelection(const Selection& oldSelection);
     void respondToChangedContents();
+    
+    Frame::TriState selectionUnorderedListState() const;
+    Frame::TriState selectionOrderedListState() const;
 
     Frame* frame() const { return m_frame; }
     DeleteButtonController* deleteButtonController() const { return m_deleteButtonController.get(); }
index f8c941c393fcb68c267c740bbe9735ff052551b7..a4e91d1659656fb7357df08ba983d07420771b12 100644 (file)
@@ -30,6 +30,7 @@
 #include "CreateLinkCommand.h"
 #include "Document.h"
 #include "DocumentFragment.h"
+#include "Editor.h"
 #include "FormatBlockCommand.h"
 #include "Frame.h"
 #include "HTMLNames.h"
@@ -572,9 +573,14 @@ Frame::TriState stateItalic(Frame* frame)
     return stateStyle(frame, CSS_PROP_FONT_STYLE, "italic");
 }
 
-Frame::TriState stateList(Frame* frame)
+Frame::TriState stateUnorderedList(Frame* frame)
 {
-    return frame->selectionListState();
+    return frame->editor()->selectionUnorderedListState();
+}
+
+Frame::TriState stateOrderedList(Frame* frame)
+{
+    return frame->editor()->selectionOrderedListState();
 }
 
 Frame::TriState stateStrikethrough(Frame* frame)
@@ -659,11 +665,11 @@ CommandMap* createCommandDictionary()
         { "InsertHTML", { execInsertHTML, enabledAnyEditableSelection, stateNone, valueNull } },
         { "InsertImage", { execInsertImage, enabledAnyRichlyEditableSelection, stateNone, valueNull } },
         { "InsertLineBreak", { execInsertLineBreak, enabledAnyEditableSelection, stateNone, valueNull } },
-        { "InsertOrderedList", { execInsertOrderedList, enabledAnyRichlyEditableSelection, stateList, valueNull } },
+        { "InsertOrderedList", { execInsertOrderedList, enabledAnyRichlyEditableSelection, stateOrderedList, valueNull } },
         { "InsertParagraph", { execInsertParagraph, enabledAnyEditableSelection, stateNone, valueNull } },
         { "InsertNewlineInQuotedContent", { execInsertNewlineInQuotedContent, enabledAnyRichlyEditableSelection, stateNone, valueNull } },
         { "InsertText", { execInsertText, enabledAnyEditableSelection, stateNone, valueNull } },
-        { "InsertUnorderedList", { execInsertUnorderedList, enabledAnyRichlyEditableSelection, stateList, valueNull } },
+        { "InsertUnorderedList", { execInsertUnorderedList, enabledAnyRichlyEditableSelection, stateUnorderedList, valueNull } },
         { "Italic", { execItalic, enabledAnyRichlyEditableSelection, stateItalic, valueNull } },
         { "JustifyCenter", { execJustifyCenter, enabledAnyRichlyEditableSelection, stateNone, valueNull } },
         { "JustifyFull", { execJustifyFull, enabledAnyRichlyEditableSelection, stateNone, valueNull } },
index 7335fdcad7890db7b51f460ab68dbb7425140a29..a5d31de98c85cc2fe584dd9fcfec67a6618d79cf 100644 (file)
@@ -2378,21 +2378,6 @@ static void updateState(CSSMutableStyleDeclaration *desiredStyle, CSSComputedSty
     }
 }
 
-Frame::TriState Frame::selectionListState() const
-{
-    TriState state = falseTriState;
-
-    if (!selectionController()->isRange()) {
-        Node* selectionNode = selectionController()->selection().start().node();
-        if (enclosingList(selectionNode))
-            return trueTriState;
-    } else {
-        //FIXME: Support ranges
-    }
-
-    return state;
-}
-
 Frame::TriState Frame::selectionHasStyle(CSSStyleDeclaration *style) const
 {
     bool atStart = true;
index c5f22faf104f10afae469dd0a7cdc617e59285c9..090494ed57d4997795c6b743b5dbb799f9b30ac0 100644 (file)
@@ -508,7 +508,6 @@ public:
   void outdent();
   TriState selectionHasStyle(CSSStyleDeclaration*) const;
   bool selectionStartHasStyle(CSSStyleDeclaration*) const;
-  TriState selectionListState() const;
   String selectionStartStylePropertyValue(int stylePropertyID) const;
   void applyEditingStyleToBodyElement() const;
   void removeEditingStyleFromBodyElement() const;