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

List:       kfm-devel
Subject:    JavaScript/HTML adventures.
From:       Michael Bedy <mjbedy () mediaone ! net>
Date:       2001-11-12 3:45:03
[Download RAW message or body]

Hi,

  So, I'm tring to learn javascript and how it works with HTML. I write a
test html document. KHtml crases. It figures.

  I spent 3 hours figuring out what happened. I have no idea if the
attached diff is the correct fix but it stopped the crashes. The Button
was being derefed and deleted by the call to dispatchMouseEvent, so
m_element was garbage for the second call. If someone could look and let
me know if it's the right fix or not I'd appreciate it.

  Anyway, even with that fix, Konqueror does not appear to do the right
thing with the attached html file. (Where "Right Thing" is defined as
"What Mozilla and IE6 do.") I have no clue why, though. Any hints?

  Learning the hard way,
      - Mike


["ref.diff" (TEXT/plain)]

Index: render_form.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_form.cpp,v
retrieving revision 1.138
diff -u -r1.138 render_form.cpp
--- render_form.cpp	2001/09/25 20:08:54	1.138
+++ render_form.cpp	2001/11/12 03:10:00
@@ -264,12 +264,14 @@
 void RenderFormElement::slotClicked()
 {
     if(isRenderButton()) {
+        ref();
         QMouseEvent e2( QEvent::MouseButtonRelease, m_mousePos, m_button, m_state);
 
         m_element->dispatchMouseEvent(&e2, m_isDoubleClick ? \
EventImpl::KHTML_DBLCLICK_EVENT : EventImpl::KHTML_CLICK_EVENT, m_clickCount);  
 	m_element->dispatchUIEvent(EventImpl::DOMACTIVATE_EVENT,m_isDoubleClick ? 2 : 1);
 	m_isDoubleClick = false;
+        deref();
     }
 }
 


["test.html" (TEXT/html)]

<html>
<body>

<script>
<!---
function foo() {
	var b = 8;
	document.write("<table>");
	for (a = 1; a < b; a++) {
	    if (a % 5 == 1) {
        	    document.write("<tr>");
	    }
	    document.write("<td>",a,"</td>");
	    if (a % 5 == 0 || a == b - 1) {
                    document.write("</tr>");
            }
	}
	document.write("</table>");
}

-->
</script>
WHY??????
<form>
<input type="button" onclick="foo()" value="Hi!">
</form>
</body>
</html>



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

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