[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    [PATCH] Real ordered list patch.
From:       Michael Bedy <mjbedy () mediaone ! net>
Date:       2001-03-18 0:50:38
[Download RAW message or body]

Ok, this one works pretty much as it should. And I think I grasp the
order things happen in khtml now. I feel that this correctly solves the
problem.

  Should I commit?

    - Mike


["orderedlists.diff" (TEXT/PLAIN)]

Index: html/html_listimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/html/html_listimpl.cpp,v
retrieving revision 1.20
diff -u -r1.20 html_listimpl.cpp
--- html/html_listimpl.cpp	2001/01/21 16:06:18	1.20
+++ html/html_listimpl.cpp	2001/03/18 00:44:04
@@ -159,12 +159,15 @@
     switch(attr->attrId)
     {
     case ATTR_VALUE:
+        isValued = true;
+        requestedValue = attr->val() ? attr->val()->toInt() : 0;
+        
         if(m_render && m_render->isListItem())
         {
             RenderListItem *list = static_cast<RenderListItem *>(m_render);
             // ### work out what to do when attribute removed - use default of some sort?
-            long v = attr->val() ? attr->val()->toInt() : 0;
-            list->setValue(v);
+            
+            list->setValue(requestedValue);
         }
         break;
     case ATTR_TYPE:
@@ -185,6 +188,26 @@
         HTMLElementImpl::parseAttribute(attr);
     }
 }
+
+void HTMLLIElementImpl::attach(KHTMLView *w)
+{
+    HTMLElementImpl::attach(w);
+
+    // If we are first, and the OL has a start attr.
+    if (parentNode() && parentNode()->id() == ID_OL)
+    {
+        HTMLOListElementImpl *ol = static_cast<HTMLOListElementImpl *>(parentNode());
+        
+        if(ol->firstChild() && ol->firstChild() == this &&  m_render)
+           static_cast<RenderListItem*>(m_render)->setValue(ol->start());
+    }
+    
+    // If we had a value attr.
+    if (isValued && m_render)
+        static_cast<RenderListItem*>(m_render)->setValue(requestedValue);
+    
+}
+
 
 // -------------------------------------------------------------------------
 
Index: html/html_listimpl.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/html/html_listimpl.h,v
retrieving revision 1.15
diff -u -r1.15 html_listimpl.h
--- html/html_listimpl.h	2001/02/05 11:38:13	1.15
+++ html/html_listimpl.h	2001/03/18 00:44:04
@@ -92,7 +92,7 @@
 class HTMLOListElementImpl : public HTMLUListElementImpl
 {
 public:
-    HTMLOListElementImpl(DocumentImpl *doc) : HTMLUListElementImpl(doc) {}
+    HTMLOListElementImpl(DocumentImpl *doc) : _start(1), HTMLUListElementImpl(doc) {}
     virtual ~HTMLOListElementImpl() {}
 
     virtual const DOMString nodeName() const;
@@ -115,7 +115,7 @@
 class HTMLLIElementImpl : public HTMLElementImpl
 {
 public:
-    HTMLLIElementImpl(DocumentImpl *doc) : HTMLElementImpl(doc) {}
+    HTMLLIElementImpl(DocumentImpl *doc) : isValued(false), HTMLElementImpl(doc) {}
     virtual ~HTMLLIElementImpl() {}
 
     virtual const DOMString nodeName() const;
@@ -125,6 +125,12 @@
     virtual tagStatus endTag() const { return LIEndTag; }
 
     virtual void parseAttribute(AttrImpl *attr);
+    
+    virtual void attach(KHTMLView *);
+
+private:
+    bool isValued;
+    long requestedValue;
 };
 
 // -------------------------------------------------------------------------


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic