[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

trey trey at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:12:59 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 14525a90ba2e20044b140f250fb2b88253ea10f3
Author: trey <trey at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Dec 9 19:00:31 2002 +0000

    	Fixed 3115903 - exchangehomes.com sometimes has form state poorly restored
    
    	KHTML is much smarter about restoring form state now, taking into account element names and
    	types instead of blindly blasting data by simple element ordering.  We encode the name
    	and type at the front of the "state" strings that previously just held the value of the
    	element.
    
    	QString::endsWith() was just plain wrong.  Looks like it had some copied code, but was
    	never really implemented.
    
            Reviewed by: Darin Adler
    
            * WebCore.pbproj/project.pbxproj:  PB is hellbent on adding "shouldUseHeadermap = 0;"
            * khtml/html/html_formimpl.cpp:
            (encodedElementName):  Utility func to encode an element name, escaping amp and lt
            (HTMLGenericFormElementImpl::state):  Build the prefix of an element's state string,
    	e.g. ELEMENT_NAME&ELEMENT_TYPE&
            (HTMLGenericFormElementImpl::findMatchingState):  Find a matching piece of state out of
    	the list of state strings that were previously saved.
            (HTMLFieldSetElementImpl::type):  Return our element type.
            (HTMLInputElementImpl::state):  Call super as part of building state string.
            (HTMLInputElementImpl::restoreState):  Use findMatchingState.
            (HTMLLegendElementImpl::type):  Return our element type.
            (HTMLSelectElementImpl::state):  Call super as part of building state string.
            (HTMLSelectElementImpl::restoreState):  Use findMatchingState.
            (HTMLKeygenElementImpl::type):  Return our element type.
            (HTMLOptGroupElementImpl::type):  Return our element type.
            (HTMLOptionElementImpl::type):  Return our element type.
            (HTMLTextAreaElementImpl::state):  Call super as part of building state string.
            (HTMLTextAreaElementImpl::restoreState):  Use findMatchingState.
            * khtml/html/html_formimpl.h:  type() is moved up to HTMLGenericFormElementImpl
            * khtml/html/htmlparser.cpp:
            (KHTMLParser::insertNode):  Pass list of states to restoreState.
            (KHTMLParser::popOneBlock):  Pass list of states to restoreState.
            * khtml/xml/dom_docimpl.h:  Add method to return the whole list of form states.
            * khtml/xml/dom_nodeimpl.cpp:
            (NodeImpl::restoreState):    Nodes receive the whole list of form states to restore from,
    	not just a single state that has already been chosen.
            * khtml/xml/dom_nodeimpl.h:
            * kwq/KWQString.mm:
            (QString::endsWith):  Walk the search string correctly.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2977 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index aacb6df..6743021 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,47 @@
+2002-12-08  Trey Matteson  <trey at apple.com>
+
+	Fixed 3115903 - exchangehomes.com sometimes has form state poorly restored
+
+	KHTML is much smarter about restoring form state now, taking into account element names and
+	types instead of blindly blasting data by simple element ordering.  We encode the name
+	and type at the front of the "state" strings that previously just held the value of the
+	element.	
+
+	QString::endsWith() was just plain wrong.  Looks like it had some copied code, but was
+	never really implemented.
+
+        Reviewed by: Darin Adler
+
+        * WebCore.pbproj/project.pbxproj:  PB is hellbent on adding "shouldUseHeadermap = 0;"
+        * khtml/html/html_formimpl.cpp:
+        (encodedElementName):  Utility func to encode an element name, escaping amp and lt
+        (HTMLGenericFormElementImpl::state):  Build the prefix of an element's state string,
+	e.g. ELEMENT_NAME&ELEMENT_TYPE&
+        (HTMLGenericFormElementImpl::findMatchingState):  Find a matching piece of state out of
+	the list of state strings that were previously saved.
+        (HTMLFieldSetElementImpl::type):  Return our element type.
+        (HTMLInputElementImpl::state):  Call super as part of building state string.
+        (HTMLInputElementImpl::restoreState):  Use findMatchingState.
+        (HTMLLegendElementImpl::type):  Return our element type.
+        (HTMLSelectElementImpl::state):  Call super as part of building state string.
+        (HTMLSelectElementImpl::restoreState):  Use findMatchingState.
+        (HTMLKeygenElementImpl::type):  Return our element type.
+        (HTMLOptGroupElementImpl::type):  Return our element type.
+        (HTMLOptionElementImpl::type):  Return our element type.
+        (HTMLTextAreaElementImpl::state):  Call super as part of building state string.
+        (HTMLTextAreaElementImpl::restoreState):  Use findMatchingState.
+        * khtml/html/html_formimpl.h:  type() is moved up to HTMLGenericFormElementImpl
+        * khtml/html/htmlparser.cpp:
+        (KHTMLParser::insertNode):  Pass list of states to restoreState.
+        (KHTMLParser::popOneBlock):  Pass list of states to restoreState.
+        * khtml/xml/dom_docimpl.h:  Add method to return the whole list of form states.
+        * khtml/xml/dom_nodeimpl.cpp:
+        (NodeImpl::restoreState):    Nodes receive the whole list of form states to restore from,
+	not just a single state that has already been chosen.
+        * khtml/xml/dom_nodeimpl.h:
+        * kwq/KWQString.mm:
+        (QString::endsWith):  Walk the search string correctly.
+
 2002-12-09  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by Darin.
@@ -118,7 +162,6 @@
 
         * WebCore.pbproj/project.pbxproj: Electron is doing his thing.
 
->>>>>>> 1.1071
 2002-12-08  David Hyatt  <hyatt at apple.com>
 
 	Fix for image bullets.  They were neglecting to offset
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index aacb6df..6743021 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,47 @@
+2002-12-08  Trey Matteson  <trey at apple.com>
+
+	Fixed 3115903 - exchangehomes.com sometimes has form state poorly restored
+
+	KHTML is much smarter about restoring form state now, taking into account element names and
+	types instead of blindly blasting data by simple element ordering.  We encode the name
+	and type at the front of the "state" strings that previously just held the value of the
+	element.	
+
+	QString::endsWith() was just plain wrong.  Looks like it had some copied code, but was
+	never really implemented.
+
+        Reviewed by: Darin Adler
+
+        * WebCore.pbproj/project.pbxproj:  PB is hellbent on adding "shouldUseHeadermap = 0;"
+        * khtml/html/html_formimpl.cpp:
+        (encodedElementName):  Utility func to encode an element name, escaping amp and lt
+        (HTMLGenericFormElementImpl::state):  Build the prefix of an element's state string,
+	e.g. ELEMENT_NAME&ELEMENT_TYPE&
+        (HTMLGenericFormElementImpl::findMatchingState):  Find a matching piece of state out of
+	the list of state strings that were previously saved.
+        (HTMLFieldSetElementImpl::type):  Return our element type.
+        (HTMLInputElementImpl::state):  Call super as part of building state string.
+        (HTMLInputElementImpl::restoreState):  Use findMatchingState.
+        (HTMLLegendElementImpl::type):  Return our element type.
+        (HTMLSelectElementImpl::state):  Call super as part of building state string.
+        (HTMLSelectElementImpl::restoreState):  Use findMatchingState.
+        (HTMLKeygenElementImpl::type):  Return our element type.
+        (HTMLOptGroupElementImpl::type):  Return our element type.
+        (HTMLOptionElementImpl::type):  Return our element type.
+        (HTMLTextAreaElementImpl::state):  Call super as part of building state string.
+        (HTMLTextAreaElementImpl::restoreState):  Use findMatchingState.
+        * khtml/html/html_formimpl.h:  type() is moved up to HTMLGenericFormElementImpl
+        * khtml/html/htmlparser.cpp:
+        (KHTMLParser::insertNode):  Pass list of states to restoreState.
+        (KHTMLParser::popOneBlock):  Pass list of states to restoreState.
+        * khtml/xml/dom_docimpl.h:  Add method to return the whole list of form states.
+        * khtml/xml/dom_nodeimpl.cpp:
+        (NodeImpl::restoreState):    Nodes receive the whole list of form states to restore from,
+	not just a single state that has already been chosen.
+        * khtml/xml/dom_nodeimpl.h:
+        * kwq/KWQString.mm:
+        (QString::endsWith):  Walk the search string correctly.
+
 2002-12-09  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by Darin.
@@ -118,7 +162,6 @@
 
         * WebCore.pbproj/project.pbxproj: Electron is doing his thing.
 
->>>>>>> 1.1071
 2002-12-08  David Hyatt  <hyatt at apple.com>
 
 	Fix for image bullets.  They were neglecting to offset
diff --git a/WebCore/WebCore.pbproj/project.pbxproj b/WebCore/WebCore.pbproj/project.pbxproj
index da51e6c..69616ea 100644
--- a/WebCore/WebCore.pbproj/project.pbxproj
+++ b/WebCore/WebCore.pbproj/project.pbxproj
@@ -178,6 +178,7 @@
 </dict>
 </plist>
 ";
+			shouldUseHeadermap = 0;
 		};
 		0867D69DFE84028FC02AAC07 = {
 			buildActionMask = 2147483647;
diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp
index f96d055..e80e23e 100644
--- a/WebCore/khtml/html/html_formimpl.cpp
+++ b/WebCore/khtml/html/html_formimpl.cpp
@@ -775,6 +775,66 @@ bool HTMLGenericFormElementImpl::isEditable()
     return false;
 }
 
+// Special chars used to encode form state strings.
+// We pick chars that are unlikely to be used in an HTML attr, so we rarely have to really encode.
+const QChar stateSeparator = '&';
+const QChar stateEscape = '<';
+const QString stateSeparatorMarker = "<A";
+const QString stateEscapeMarker = "<<";
+
+// Encode an element name so we can put it in a state string without colliding
+// with our separator char.
+static QString encodedElementName(QString str)
+{
+    int sepLoc = str.find(stateSeparator);
+    int escLoc = str.find(stateSeparator);
+    if (sepLoc >= 0 || escLoc >= 0) {
+        QString newStr = str;
+        //   replace "<" with "<<"
+        while (escLoc >= 0) {
+            newStr.replace(escLoc, 1, stateEscapeMarker);
+            escLoc = str.find(stateSeparator, escLoc+1);
+        }
+        //   replace "&" with "<A"
+        while (sepLoc >= 0) {
+            newStr.replace(sepLoc, 1, stateSeparatorMarker);
+            sepLoc = str.find(stateSeparator, sepLoc+1);
+        }
+        return newStr;
+    } else {
+        return str;
+    }
+}
+
+QString HTMLGenericFormElementImpl::state( )
+{
+    // Build a string that contains ElementName&ElementType&
+    return encodedElementName(name().string()) + stateSeparator + type().string() + stateSeparator;
+}
+
+QString HTMLGenericFormElementImpl::findMatchingState(QStringList &states)
+{
+    QString encName = encodedElementName(name().string());
+    QString typeStr = type().string();
+    for (QStringList::Iterator it = states.begin(); it != states.end(); ++it) {
+        QString state = *it;
+        int sep1 = state.find(stateSeparator);
+        int sep2 = state.find(stateSeparator, sep1+1);
+        assert(sep1 >= 0);
+        assert(sep2 >= 0);
+
+        QString nameAndType = state.left(sep2);
+        if (encName.length() + typeStr.length() + 1 == (uint)sep2
+            && nameAndType.startsWith(encName)
+            && nameAndType.endsWith(typeStr))
+        {
+            states.remove(it);
+            return state.mid(sep2+1);
+        }
+    }
+    return QString::null;
+}
+
 // -------------------------------------------------------------------------
 
 HTMLButtonElementImpl::HTMLButtonElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f)
@@ -884,6 +944,11 @@ NodeImpl::Id HTMLFieldSetElementImpl::id() const
     return ID_FIELDSET;
 }
 
+DOMString HTMLFieldSetElementImpl::type() const
+{
+    return "fieldset";
+}
+
 void HTMLFieldSetElementImpl::attach()
 {
     // Fieldsets need to at least get a render object so that the
@@ -950,17 +1015,21 @@ DOMString HTMLInputElementImpl::type() const
 
 QString HTMLInputElementImpl::state( )
 {
+    QString state = HTMLGenericFormElementImpl::state();
     switch (m_type) {
     case CHECKBOX:
     case RADIO:
-        return QString::fromLatin1(m_checked ? "on" : "off");
+        return state + QString::fromLatin1(m_checked ? "on" : "off");
     default:
-        return value().string()+'.'; // Make sure the string is not empty!
+        return state + value().string()+'.'; // Make sure the string is not empty!
     }
 }
 
-void HTMLInputElementImpl::restoreState(const QString &state)
+void HTMLInputElementImpl::restoreState(QStringList &states)
 {
+    QString state = HTMLGenericFormElementImpl::findMatchingState(states);
+    if (state.isNull()) return;
+
     switch (m_type) {
     case CHECKBOX:
     case RADIO:
@@ -1488,6 +1557,11 @@ NodeImpl::Id HTMLLegendElementImpl::id() const
     return ID_LEGEND;
 }
 
+DOMString HTMLLegendElementImpl::type() const
+{
+    return "legend";
+}
+
 // -------------------------------------------------------------------------
 
 HTMLSelectElementImpl::HTMLSelectElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f)
@@ -1649,11 +1723,14 @@ QString HTMLSelectElementImpl::state( )
             state[i] = 'X';
 #endif /* APPLE_CHANGES not defined */
 
-    return state;
+    return HTMLGenericFormElementImpl::state() + state;
 }
 
-void HTMLSelectElementImpl::restoreState(const QString &_state)
+void HTMLSelectElementImpl::restoreState(QStringList &_states)
 {
+    QString _state = HTMLGenericFormElementImpl::findMatchingState(_states);
+    if (_state.isNull()) return;
+
     recalcListItems();
 
     QString state = _state;
@@ -1944,6 +2021,11 @@ NodeImpl::Id HTMLKeygenElementImpl::id() const
     return ID_KEYGEN;
 }
 
+DOMString HTMLKeygenElementImpl::type() const
+{
+    return "keygen";
+}
+
 void HTMLKeygenElementImpl::parseAttribute(AttributeImpl* attr)
 {
     switch(attr->id())
@@ -1992,6 +2074,11 @@ NodeImpl::Id HTMLOptGroupElementImpl::id() const
     return ID_OPTGROUP;
 }
 
+DOMString HTMLOptGroupElementImpl::type() const
+{
+    return "optgroup";
+}
+
 NodeImpl *HTMLOptGroupElementImpl::insertBefore ( NodeImpl *newChild, NodeImpl *refChild, int &exceptioncode )
 {
     NodeImpl *result = HTMLGenericFormElementImpl::insertBefore(newChild,refChild, exceptioncode);
@@ -2059,6 +2146,11 @@ NodeImpl::Id HTMLOptionElementImpl::id() const
     return ID_OPTION;
 }
 
+DOMString HTMLOptionElementImpl::type() const
+{
+    return "option";
+}
+
 DOMString HTMLOptionElementImpl::text() const
 {
     DOMString label = getAttribute(ATTR_LABEL);
@@ -2181,11 +2273,13 @@ DOMString HTMLTextAreaElementImpl::type() const
 QString HTMLTextAreaElementImpl::state( )
 {
     // Make sure the string is not empty!
-    return value().string()+'.';
+    return HTMLGenericFormElementImpl::state() + value().string()+'.';
 }
 
-void HTMLTextAreaElementImpl::restoreState(const QString &state)
+void HTMLTextAreaElementImpl::restoreState(QStringList &states)
 {
+    QString state = HTMLGenericFormElementImpl::findMatchingState(states);
+    if (state.isNull()) return;
     setDefaultValue(state.left(state.length()-1));
     // the close() in the rendertree will take care of transferring defaultvalue to 'value'
 }
diff --git a/WebCore/khtml/html/html_formimpl.h b/WebCore/khtml/html/html_formimpl.h
index 237ab0d..9ff871c 100644
--- a/WebCore/khtml/html/html_formimpl.h
+++ b/WebCore/khtml/html/html_formimpl.h
@@ -133,6 +133,8 @@ public:
 
     HTMLFormElementImpl *form() { return m_form; }
 
+    virtual DOMString type() const = 0;
+
     virtual void parseAttribute(AttributeImpl *attr);
     virtual void attach();
     virtual void reset() {}
@@ -168,6 +170,9 @@ public:
     virtual void defaultEventHandler(EventImpl *evt);
     virtual bool isEditable();
 
+    virtual QString state();
+    QString findMatchingState(QStringList &states);
+
 protected:
     HTMLFormElementImpl *getForm() const;
 
@@ -192,8 +197,8 @@ public:
     };
 
     virtual Id id() const;
-
     DOMString type() const;
+
     virtual void attach();
     virtual void parseAttribute(AttributeImpl *attr);
     virtual void defaultEventHandler(EventImpl *evt);
@@ -218,6 +223,7 @@ public:
     virtual ~HTMLFieldSetElementImpl();
 
     virtual Id id() const;
+    DOMString type() const;
 
     virtual void attach();
 };
@@ -270,7 +276,7 @@ public:
 
     virtual bool maintainsState() { return true; }
     virtual QString state();
-    virtual void restoreState(const QString &);
+    virtual void restoreState(QStringList &);
 
     void select();
     void click();
@@ -338,6 +344,7 @@ public:
     virtual ~HTMLLegendElementImpl();
 
     virtual Id id() const;
+    DOMString type() const;
 };
 
 
@@ -352,7 +359,6 @@ public:
     ~HTMLSelectElementImpl();
 
     virtual Id id() const;
-
     DOMString type() const;
 
     virtual void recalcStyle( StyleChange );
@@ -380,7 +386,7 @@ public:
 
     virtual bool maintainsState() { return true; }
     virtual QString state();
-    virtual void restoreState(const QString &);
+    virtual void restoreState(QStringList &);
 
     virtual NodeImpl *insertBefore ( NodeImpl *newChild, NodeImpl *refChild, int &exceptioncode );
     virtual NodeImpl *replaceChild ( NodeImpl *newChild, NodeImpl *oldChild, int &exceptioncode );
@@ -453,6 +459,7 @@ public:
     virtual ~HTMLOptGroupElementImpl();
 
     virtual Id id() const;
+    DOMString type() const;
 
     virtual NodeImpl *insertBefore ( NodeImpl *newChild, NodeImpl *refChild, int &exceptioncode );
     virtual NodeImpl *replaceChild ( NodeImpl *newChild, NodeImpl *oldChild, int &exceptioncode );
@@ -476,6 +483,7 @@ public:
     HTMLOptionElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f = 0);
 
     virtual Id id() const;
+    DOMString type() const;
 
     DOMString text() const;
 
@@ -526,7 +534,7 @@ public:
 
     virtual bool maintainsState() { return true; }
     virtual QString state();
-    virtual void restoreState(const QString &);
+    virtual void restoreState(QStringList &);
 
     void select (  );
 
diff --git a/WebCore/khtml/html/htmlparser.cpp b/WebCore/khtml/html/htmlparser.cpp
index e7ea4cb..a2280ec 100644
--- a/WebCore/khtml/html/htmlparser.cpp
+++ b/WebCore/khtml/html/htmlparser.cpp
@@ -346,8 +346,9 @@ bool KHTMLParser::insertNode(NodeImpl *n, bool flat)
             }
             if (n->maintainsState()) {
                 document->document()->registerMaintainsState(n);
-                QString state(document->document()->nextState());
-                if (!state.isNull()) n->restoreState(state);
+                QStringList &states = document->document()->restoreState();
+                if (!states.isEmpty())
+                    n->restoreState(states);
             }
             n->closeRenderer();
 #endif
@@ -1217,8 +1218,9 @@ void KHTMLParser::popOneBlock()
     if((Elem->node != current)) {
         if (current->maintainsState() && document->document()){
             document->document()->registerMaintainsState(current);
-            QString state(document->document()->nextState());
-            if (!state.isNull()) current->restoreState(state);
+            QStringList &states = document->document()->restoreState();
+            if (!states.isEmpty())
+                current->restoreState(states);
         }
         current->closeRenderer();
     }
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 6858a34..631c8ec 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -207,6 +207,7 @@ public:
 
     // Set the state the document should restore to
     void setRestoreState( const QStringList &s) { m_state = s; }
+    QStringList &restoreState( ) { return m_state; }
 
     KHTMLView *view() const { return m_view; }
 
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index 8034e9b..4f26dd1 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -965,7 +965,7 @@ QString NodeImpl::state()
     return QString::null;
 }
 
-void NodeImpl::restoreState(const QString &/*state*/)
+void NodeImpl::restoreState(QStringList &/*states*/)
 {
 }
 
diff --git a/WebCore/khtml/xml/dom_nodeimpl.h b/WebCore/khtml/xml/dom_nodeimpl.h
index ed43b32..2aacb29 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.h
+++ b/WebCore/khtml/xml/dom_nodeimpl.h
@@ -40,6 +40,7 @@ class QRect;
 class QMouseEvent;
 class QKeyEvent;
 class QTextStream;
+class QStringList;
 
 namespace khtml {
     class RenderStyle;
@@ -327,12 +328,13 @@ public:
     virtual QString state();
 
     /**
-     * Sets the state of the element based on a string previosuly returned by state(). This is used to initialize form
-     * controls with their old values when the user returns to the page in their history.
+     * Sets the state of the element based on strings previously returned by state(). This is used to initialize form
+     * controls with their old values when the user returns to the page in their history.  The receiver
+     * should remove the string from the list that it uses for its restore.
      *
-     * @param state A string representation of the node's previously-stored state
+     * @param states The strings previously returned by nodes' state methods.
      */
-    virtual void restoreState(const QString &state);
+    virtual void restoreState(QStringList &stateList);
 
     // -----------------------------------------------------------------------------
     // Notification of document stucture changes
diff --git a/WebCore/kwq/KWQString.mm b/WebCore/kwq/KWQString.mm
index 591c46a..803f3fa 100644
--- a/WebCore/kwq/KWQString.mm
+++ b/WebCore/kwq/KWQString.mm
@@ -1080,8 +1080,8 @@ bool QString::endsWith( const QString& s ) const
     if (dataHandle[0]->_length < s.data()->_length)
         return FALSE;
         
-    for ( int i = dataHandle[0]->_length - s.data()->_length; i < (int) s.data()->_length; i++ ) {
-	if ( uni[i] != s[i] )
+    for ( int i = dataHandle[0]->_length - s.data()->_length, j = 0; i < (int) s.data()->_length; i++, j++ ) {
+	if ( uni[i] != s[j] )
 	    return FALSE;
     }
     return TRUE;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list