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

List:       konq-bugs
Subject:    [Bug 118658] Incremental-repainting not incremental enough for
From:       Germain Garand <germain () ebooksfrance ! com>
Date:       2006-02-28 4:16:35
Message-ID: 20060228041635.31485.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=118658         




------- Additional Comments From germain ebooksfrance com  2006-02-28 05:16 -------
SVN commit 514357 by ggarand:

Common-case style selection optimisation inspired from WebCore.
Avoids repetitive scanning of the class attribute for a list of classes.

CCBUG: 118658
(not the only issue there)



 M  +10 -0     ChangeLog  
 M  +3 -2      css/css_base.cpp  
 M  +1 -0      css/css_base.h  
 M  +25 -15    css/cssstyleselector.cpp  
 M  +1 -1      css/parser.cpp  
 M  +1 -1      css/parser.y  
 M  +10 -0     html/html_elementimpl.cpp  
 M  +1 -0      xml/dom_elementimpl.cpp  
 M  +8 -2      xml/dom_elementimpl.h  


--- branches/KDE/3.5/kdelibs/khtml/ChangeLog #514356:514357
 @ -1,5 +1,15  @
 2006-02-28  Germain Garand  <germain ebooksfrance org>
+         
+        Common-case style selection optimisation inspired from WebCore.
 
+        * css/css_base.cpp/.h: add 'Class' to possible matching modes
+        * css/cssstyleselector.cpp: treat 'Class' extra, not anymore as an ordinary \
List. +        * css/parser.cpp/y: use 'Class' matching mode 
+        * html/html_elementimpl.cpp: when parsing ATTR_CLASS, set a boolean to \
remember if it is or not a class list. +        * xml/dom_elementimpl.{cpp,h}: add \
m_hasClassList boolean + setter/getter +
+2006-02-28  Germain Garand  <germain ebooksfrance org>
+
         * rendering/render_object.cpp (dirtyFormattingContext): be more efficient \
                with inlineflow objects.
         * rendering/render_block.cpp (layoutBlockChildren): be more efficient with \
regard to positioned objects relayout.   Merge WC margin-collapse regression fix \
                (WC/#3508). 
--- branches/KDE/3.5/kdelibs/khtml/css/css_base.cpp #514356:514357
 @ -144,6 +144,7  @
     case Exact:
     case Set:
     case List:
+    case Class:
     case Hyphen:
     case PseudoClass:
     case PseudoElement:
 @ -317,7 +318,7  @
         str = "#";
         str += cs->value;
     }
-    else if ( tag == anyLocalName && cs->attr == ATTR_CLASS && cs->match == \
CSSSelector::List ) +    else if ( tag == anyLocalName && cs->match == \
CSSSelector::Class )  {
         str = ".";
         str += cs->value;
 @ -343,7 +344,7  @
             str += "#";
             str += cs->value;
         }
-        else if ( cs->attr == ATTR_CLASS && cs->match == CSSSelector::List )
+        else if ( cs->match == CSSSelector::Class )
         {
             str += ".";
             str += cs->value;
--- branches/KDE/3.5/kdelibs/khtml/css/css_base.h #514356:514357
 @ -107,6 +107,7  @
 	    Id,
 	    Exact,
 	    Set,
+	    Class,
 	    List,
 	    Hyphen,
 	    PseudoClass,
--- branches/KDE/3.5/kdelibs/khtml/css/cssstyleselector.cpp #514356:514357
 @ -1068,25 +1068,35  @
             break;
         case CSSSelector::Set:
             break;
+        case CSSSelector::Class:
+            if (!e->hasClassList()) {
+                if( (strictParsing && strcmp(sel->value, value) ) ||
+                    (!strictParsing && strcasecmp(sel->value, value)))
+                    return false;
+               return true;
+            }
+            // no break    
         case CSSSelector::List:
         {
-            const QChar* s = value.unicode();
-            int l = value.length();
-            while( l && !s->isSpace() )
-              l--,s++;
-	    if (!l) {
-		// There is no list, just a single item.  We can avoid
-		// allocing QStrings and just treat this as an exact
-		// match check.
-		if( (strictParsing && strcmp(sel->value, value) ) ||
-		    (!strictParsing && strcasecmp(sel->value, value)))
-		    return false;
-		break;
-	    }
+            if (sel->match != CSSSelector::Class) {
+                const QChar* s = value.unicode();
+                int l = value.length();
+                while( l && !s->isSpace() )
+                    l--,s++;
+                if (!l) {
+		    // There is no list, just a single item.  We can avoid
+		    // allocing QStrings and just treat this as an exact
+		    // match check.
+		    if( (strictParsing && strcmp(sel->value, value) ) ||
+		        (!strictParsing && strcasecmp(sel->value, value)))
+		        return false;
+		    break;
+	        }
+            }
 
             // The selector's value can't contain a space, or it's totally bogus.
-            l = sel->value.find(' ');
-            if (l != -1)
+            // ### check if this can still happen
+            if (sel->value.find(' ') != -1)
                 return false;
 
             QString str = value.string();
--- branches/KDE/3.5/kdelibs/khtml/css/parser.cpp #514356:514357
 @ -2072,7 +2072,7  @
 
     {
 	yyval.selector = new CSSSelector();
-	yyval.selector->match = CSSSelector::List;
+	yyval.selector->match = CSSSelector::Class;
 	yyval.selector->attr = ATTR_CLASS;
 	yyval.selector->value = domString(yyvsp[0].string);
     ;}
--- branches/KDE/3.5/kdelibs/khtml/css/parser.y #514356:514357
 @ -691,7 +691,7  @
 class:
     '.' IDENT {
 	$$ = new CSSSelector();
-	$$->match = CSSSelector::List;
+	$$->match = CSSSelector::Class;
 	$$->attr = ATTR_CLASS;
 	$$->value = domString($2);
     }
--- branches/KDE/3.5/kdelibs/khtml/html/html_elementimpl.cpp #514356:514357
 @ -175,6 +175,16  @
         getDocument()->incDOMTreeVersion();
         break;
     case ATTR_CLASS:
+        if (attr->val()) {
+          DOMString v = attr->value();
+          const QChar* s = v.unicode();
+          int l = v.length();
+          while( l && !s->isSpace() )
+            l--,s++;
+          setHasClassList(l);
+        } else
+          setHasClassList(false);                 
+    // no break                                         
     case ATTR_NAME:
         setChanged(); // in case of a CSS selector on class/name
         getDocument()->incDOMTreeVersion();
--- branches/KDE/3.5/kdelibs/khtml/xml/dom_elementimpl.cpp #514356:514357
 @ -308,6 +308,7  @
     m_restyleLate = false;
     m_restyleSelfLate = false;
     m_restyleChildrenLate = false;
+    m_hasClassList = false;
 }
 
 ElementImpl::~ElementImpl()
--- branches/KDE/3.5/kdelibs/khtml/xml/dom_elementimpl.h #514356:514357
 @ -141,7 +141,7  @
 public:
     ElementImpl(DocumentPtr *doc);
     ~ElementImpl();
-
+    
     DOMString getAttribute( NodeImpl::Id id, bool nsAware = 0, const DOMString& \
                qName = DOMString() ) const;
     void setAttribute( NodeImpl::Id id, const DOMString &value, const DOMString \
&qName,  int &exceptioncode );
 @ -224,16 +224,21  @
      */
     DOMString openTagStartToString(bool expandurls = false) const;
     
-    bool restyleLate() { return m_restyleLate; };
+    bool restyleLate() const { return m_restyleLate; };
     void setRestyleLate(bool b=true) { m_restyleLate = b; };
     void setRestyleSelfLate() { m_restyleSelfLate = true; };
     void setRestyleChildrenLate() { m_restyleChildrenLate = true; };
 
+    // for style selection performance: whether the element matches several CSS \
Classes +    bool hasClassList() const { return m_hasClassList; }
+    void setHasClassList(bool b) { m_hasClassList = b; }
+
     void updateId(DOMStringImpl* oldId, DOMStringImpl* newId);
     //Called when mapping from id to this node in document should be removed
     virtual void removeId(const QString& id);
     //Called when mapping from id to this node in document should be added
     virtual void addId   (const QString& id);
+
 protected:
     void createAttributeMap() const;
     void createDecl();
 @ -253,6 +258,7  @
     bool m_restyleLate;
     bool m_restyleSelfLate;
     bool m_restyleChildrenLate;
+    bool m_hasClassList;
 };
_______________________________________________
Konq-bugs mailing list
Konq-bugs@mail.kde.org
https://mail.kde.org/mailman/listinfo/konq-bugs


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

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