Paste number 81456: WML patch, r?

Paste number 81456: WML patch, r?
Pasted by: WildFox
When:8 months, 4 days ago
Share:Tweet this! | http://paste.lisp.org/+1QUO
Channel:#webkit
Paste contents:
Raw Source | XML | Display As
nikolaszimmermann ~/Coding/WebKit > svn diff LayoutTests/ChangeLog LayoutTests/wml/resources/ WebCore/ChangeLog WebCore/dom/Document.* WebCore/wml/WMLCardElement.cpp WebCore/wml/WMLDocument.* WebCore/wml/WMLInputElement.*
Index: LayoutTests/ChangeLog
===================================================================
--- LayoutTests/ChangeLog	(revision 44479)
+++ LayoutTests/ChangeLog	(working copy)
@@ -1,3 +1,13 @@
+2009-06-05  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
+
+        Reviewed by NOBODY (OOPS!).
+
+        Force initialization of the WML variable state, right after the dynamically created WML elements have been added to the tree.
+        Note that "regular WML" doesn't support JavaScript at all, in a normal WML document WMLDocument::finishedParsing() takes care of that.
+
+        * wml/resources/WMLTestCase.js:
+        (startTest):
+
 2009-06-01  Ben Murdoch  <benm@google.com>
 
         <https://bugs.webkit.org/show_bug.cgi?id=25710> HTML5 Database stops executing transactions if the URL hash changes while a transaction is open and an XHR is in progress.
Index: LayoutTests/wml/resources/WMLTestCase.js
===================================================================
--- LayoutTests/wml/resources/WMLTestCase.js	(revision 44479)
+++ LayoutTests/wml/resources/WMLTestCase.js	(working copy)
@@ -81,6 +81,11 @@
 }
 
 function startTest(x, y) {
+    // Initialize variable state
+    // In a regular WML document, this would happen after the parsing finished.
+    // Though as we dynamically create testcases, we have to take care of initializing WML variable state manually.
+    testDocument.initializeWMLPageState();
+
     // Assure first layout finished
     window.setTimeout("triggerUpdate(" + x + ", " + y + ")", 0);
 }
Index: WebCore/ChangeLog
===================================================================
--- WebCore/ChangeLog	(revision 44479)
+++ WebCore/ChangeLog	(working copy)
@@ -1,3 +1,29 @@
+2009-06-05  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
+
+        Reviewed by NOBODY (OOPS!).
+
+        Fix WMLInputElement initialization code. Don't call initialize() on attach(), let
+        WMLCardElement handle initialization once, after the document has been parsed.
+
+        To keep layout tests working introduce a new function in Document.idl: initializeWMLPageState().
+        WMLTestCase.js (the wml/ layout test framework) will use it to simulate a regular WML document,
+        whose variable state gets initialized on WMLDocument::finishedParsing(). Force initialization
+        of the WML variable state, right after the dynamically created elements have been inserted into the tree.
+
+        * dom/Document.cpp:
+        (WebCore::Document::initializeWMLPageState):
+        * dom/Document.h:
+        * dom/Document.idl:
+        * wml/WMLCardElement.cpp:
+        (WebCore::WMLCardElement::handleIntrinsicEventIfNeeded):
+        * wml/WMLDocument.cpp:
+        (WebCore::WMLDocument::finishedParsing):
+        (WebCore::WMLDocument::initialize):
+        * wml/WMLDocument.h:
+        * wml/WMLInputElement.cpp:
+        (WebCore::WMLInputElement::initialize):
+        * wml/WMLInputElement.h:
+
 2009-06-05  WANG Lu  <coolwanglu@gmail.com>
 
         Reviewed by Jan Alonzo.
Index: WebCore/dom/Document.cpp
===================================================================
--- WebCore/dom/Document.cpp	(revision 44479)
+++ WebCore/dom/Document.cpp	(working copy)
@@ -4269,6 +4269,15 @@
     if (WMLPageState* pageState = wmlPageStateForDocument(this))
         pageState->reset();
 }
+
+void Document::initializeWMLPageState()
+{
+    ASSERT(isWMLDocument());
+    if (!isWMLDocument())
+        return;
+
+    static_cast<WMLDocument*>(this)->initialize();
+}
 #endif
 
 void Document::attachRange(Range* range)
Index: WebCore/dom/Document.h
===================================================================
--- WebCore/dom/Document.h	(revision 44479)
+++ WebCore/dom/Document.h	(working copy)
@@ -1029,6 +1029,7 @@
 
 #if ENABLE(WML)
     void resetWMLPageState();
+    void initializeWMLPageState();
 #endif
 
 protected:
Index: WebCore/dom/Document.idl
===================================================================
--- WebCore/dom/Document.idl	(revision 44479)
+++ WebCore/dom/Document.idl	(working copy)
@@ -242,6 +242,7 @@
 #if defined(ENABLE_WML) && ENABLE_WML
         // Only used from within WML layout tests, WML doesn't have JS support at all.
         void resetWMLPageState();
+        void initializeWMLPageState();
 #endif
     };
 
Index: WebCore/wml/WMLCardElement.cpp
===================================================================
--- WebCore/wml/WMLCardElement.cpp	(revision 44479)
+++ WebCore/wml/WMLCardElement.cpp	(working copy)
@@ -31,6 +31,7 @@
 #include "RenderStyle.h"
 #include "WMLDocument.h"
 #include "WMLDoElement.h"
+#include "WMLInputElement.h"
 #include "WMLIntrinsicEventHandler.h"
 #include "WMLNames.h"
 #include "WMLTemplateElement.h"
@@ -164,16 +165,18 @@
     if (m_eventTimer)
         m_eventTimer->start();
 
-    // FIXME: Initialize input/select  elements in this card
-    /*
-    Node* node = this;
-    while (node = node->traverseNextNode()) {
+    // FIXME: Initialize select elements in this card
+    for (Node* node = traverseNextNode(); node != 0; node = node->traverseNextNode()) {
+        if (!node->isElementNode())
+            continue;
+
         if (node->hasTagName(inputTag))
-            static_cast<WMLInputElement*>(node)->init();
+            static_cast<WMLInputElement*>(node)->initialize();
+        /*
         else if (node->hasTagName(selectTag))
             static_cast<WMLSelectElement*>(node)->selectInitialOptions();
+        */
     }
-    */
 }
 
 void WMLCardElement::handleDeckLevelTaskOverridesIfNeeded()
Index: WebCore/wml/WMLDocument.cpp
===================================================================
--- WebCore/wml/WMLDocument.cpp	(revision 44479)
+++ WebCore/wml/WMLDocument.cpp	(working copy)
@@ -61,6 +61,12 @@
     // Remember that we'e successfully entered the deck
     wmlPageState->setNeedCheckDeckAccess(false);
 
+    initialize();
+    Document::finishedParsing();
+}
+
+void WMLDocument::initialize()
+{
     // Notify the existance of templates to all cards of the current deck
     WMLTemplateElement::registerTemplatesInDocument(this);
 
@@ -77,8 +83,6 @@
 
     // Handle card-level intrinsic event
     card->handleIntrinsicEventIfNeeded();
-
-    Document::finishedParsing();
 }
 
 WMLPageState* wmlPageStateForDocument(Document* doc)
Index: WebCore/wml/WMLDocument.h
===================================================================
--- WebCore/wml/WMLDocument.h	(revision 44479)
+++ WebCore/wml/WMLDocument.h	(working copy)
@@ -40,6 +40,8 @@
     virtual bool isWMLDocument() const { return true; }
     virtual void finishedParsing();
 
+    void initialize();
+
 private:
     WMLDocument(Frame*);
 };
Index: WebCore/wml/WMLInputElement.cpp
===================================================================
--- WebCore/wml/WMLInputElement.cpp	(revision 44479)
+++ WebCore/wml/WMLInputElement.cpp	(working copy)
@@ -224,18 +224,6 @@
     return new (arena) RenderTextControlSingleLine(this);
 }
 
-void WMLInputElement::attach()
-{
-    WMLFormControlElement::attach();
-
-    // FIXME: maybe this is not a good place to do this since it is possible 
-    // to cause unexpected several times initialise of <input> if we force the
-    // node to be reattached. But placing it here can ensure the run-webkit-tests
-    // get expected result,i.e. multiple-times initialise is expected when making
-    // layout test for WMLInputElement 
-    init();
-}  
-
 void WMLInputElement::detach()
 {
     WMLElement::detach();
@@ -352,7 +340,7 @@
     WMLElement::didMoveToNewOwnerDocument();
 }
 
-void WMLInputElement::init()
+void WMLInputElement::initialize()
 {
     String nameVariable = formControlName();
     String variableValue;
Index: WebCore/wml/WMLInputElement.h
===================================================================
--- WebCore/wml/WMLInputElement.h	(revision 44479)
+++ WebCore/wml/WMLInputElement.h	(working copy)
@@ -72,7 +72,6 @@
     virtual void copyNonAttributeProperties(const Element* source);
 
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
-    virtual void attach();
     virtual void detach();
     virtual bool appendFormData(FormDataList&, bool);
     virtual void reset();
@@ -92,7 +91,9 @@
     bool isConformedToInputMask(UChar, unsigned, bool isUserInput = true);
 
 private:
-    void init();
+    friend class WMLCardElement;
+    void initialize();
+
     String validateInputMask(const String&);
     unsigned cursorPositionToMaskIndex(unsigned);
 
nikolaszimmermann ~/Coding/WebKit > 

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.