LayoutTests:
[WebKit-https.git] / WebCore / editing / Editor.cpp
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