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

List:       kde-commits
Subject:    branches/KDE/3.5/kdewebdev/quanta
From:       Andras Mantia <amantia () kde ! org>
Date:       2005-10-06 7:29:01
Message-ID: 1128583741.364677.15623.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 467740 by amantia:

Show again the CSS selector group.
Allow editing CSS areas with comments inside with the dialog.
Fixes last part of bug #99385.

BUG: 99385

 M  +50 -19    components/csseditor/stylesheetparser.cpp  
 M  +1 -1      parsers/saparser.cpp  
 M  +1 -1      src/quanta.cpp  


--- branches/KDE/3.5/kdewebdev/quanta/components/csseditor/stylesheetparser.cpp \
#467739:467740 @@ -43,17 +43,17 @@
 void stylesheetParser::parse(){
   if(!m_stopProcessing){
     if(!m_styleSheet.isEmpty()){
-        if(m_styleSheet.startsWith("/*")) 
+       if(m_styleSheet.startsWith("/*"))
           parseComment();
-        else if(m_styleSheet.startsWith("@page")) 
-                  parseAtRules1();
-                else if(m_styleSheet.startsWith("@media")) 
-                          parseAtRules1();
-                        else if(m_styleSheet.startsWith("@import")) 
-                                  parseAtRules2();
-                                else if(m_styleSheet.startsWith("@charset")) 
-                                          parseAtRules2();
-                                        else parseSelector();
+          else if(m_styleSheet.startsWith("@page"))
+              parseAtRules1();
+              else if(m_styleSheet.startsWith("@media"))
+                        parseAtRules1();
+                      else if(m_styleSheet.startsWith("@import"))
+                                parseAtRules2();
+                              else if(m_styleSheet.startsWith("@charset"))
+                                        parseAtRules2();
+                                      else parseSelector();
     }    
     else return;
   }  
@@ -88,15 +88,46 @@
 }
 
 unsigned int stylesheetParser::numberOfParenthesisInAParenthesisBlock(parenthesisKind \
                p, const QString& b){
-  switch(p){
-    case opened: return b.contains("{");
-    case closed: return b.contains("}");
-    default:return 0;
+  QChar searchFor = '{';
+  if (p == closed)
+    searchFor = '}';
+  int num = 0;
+  int len = b.length();
+  bool ignore = false;
+  for (int i = 0; i < len; i++)
+  {
+    if (b[i] == '/' && (i + 1 < len) && b[i + 1] == '*')
+      ignore = true;
+    if (b[i] == '*' && (i + 1 < len) && b[i + 1] == '/')
+      ignore = false;
+    if (!ignore && b[i] == searchFor)
+      num++;
   }
+  return num;
 }
 
+int findParanthesis(const QString& string, const QChar &ch, int startPos = 0)
+{
+  int pos = -1;
+  int len = string.length();
+  bool ignore = false;
+  for (int i = startPos; i < len; i++)
+  {
+    if (string[i] == '/' && (i + 1 < len) && string[i + 1] == '*')
+      ignore = true;
+    if (string[i] == '*' && (i + 1 < len) && string[i + 1] == '/')
+      ignore = false;
+    if (!ignore && string[i] == ch)
+    {
+      pos = i;
+      break;
+    }
+  }
+  return pos;
+}
+
 void stylesheetParser::parseSelector(){
-  int closingParenthesisPos = m_styleSheet.find("}");
+  int closingParenthesisPos = findParanthesis(m_styleSheet, '}');
    if(closingParenthesisPos==-1) {
     m_stopProcessing = true;
     emit errorOccurred(i18n("The selector") + " :\n" +m_styleSheet.mid(0,20) + \
"...\n "+ msg1);       @@ -120,11 +151,11 @@
    int closingParentheses = 1,
         openingParentheses = 0;
   while(true){ 
-    openingParentheses = m_styleSheet.left(closingParenthesisPos+1).contains("{");
+    openingParentheses = \
numberOfParenthesisInAParenthesisBlock(closed,m_styleSheet.left(closingParenthesisPos+1)); \
//m_styleSheet.left(closingParenthesisPos+1).contains("{");  
     if(openingParentheses==closingParentheses){
-      QString selectorName=m_styleSheet.left(m_styleSheet.find("{")).stripWhiteSpace(),
                
-                   selectorValue=m_styleSheet.mid(m_styleSheet.find("{")+1, \
closingParenthesisPos - m_styleSheet.find("{") -1);     +      QString \
selectorName=m_styleSheet.left(findParanthesis(m_styleSheet, \
'{')/*m_styleSheet.find("{")*/).stripWhiteSpace(), +                   \
selectorValue=m_styleSheet.mid(findParanthesis(m_styleSheet, \
'{')/*m_styleSheet.find("{")*/+1, closingParenthesisPos - m_styleSheet.find("{") -1); \
  
       selectorName.remove("\n").remove("\t");
       selectorValue.remove("\n").remove("\t");
@@ -133,7 +164,7 @@
       break;
     } 
     else {
-      closingParenthesisPos = m_styleSheet.find("}",closingParenthesisPos+1);
+      closingParenthesisPos = findParanthesis(m_styleSheet, \
'{',closingParenthesisPos+1)/*m_styleSheet.find("}",closingParenthesisPos+1)*/;  \
closingParentheses++;  } 
   }
--- branches/KDE/3.5/kdewebdev/quanta/parsers/saparser.cpp #467739:467740
@@ -782,7 +782,7 @@
     Node *n;
     if (s_parentNode)
     {
-      n = s_parentNode->child;
+      n = s_parentNode;//->child;
     } else
     {
       n = s_currentNode;
--- branches/KDE/3.5/kdewebdev/quanta/src/quanta.cpp #467739:467740
@@ -4458,7 +4458,7 @@
   } else
   if (!node || w->currentDTD(true)->name == "text/css") 
   {
-        kdDebug(24000) << "[CSS editor] This is a pure CSS document";
+        kdDebug(24000) << "[CSS editor] This is a pure CSS document" << endl;
 
     CSSSelector *dlg = new CSSSelector;
 


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

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