Reviewed by Kevin.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Feb 2005 01:30:10 +0000 (01:30 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Feb 2005 01:30:10 +0000 (01:30 +0000)
        - fixed <rdar://problem/3998627> WebKit crashes when deleting text in a modified div

        * khtml/khtml_part.cpp: (KHTMLPart::selectionComputedStyle): Add a ref and deref to keep
        the element alive until it's added to the DOM tree.
        * kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::styleForSelectionStart): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8627 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/khtml/khtml_part.cpp
WebCore/kwq/KWQKHTMLPart.mm

index d87b36924fab39864a701c3ddaace82f8e5da20c..fe042719ea83c52ca3a39d0da68a198deca15ef6 100644 (file)
@@ -1,3 +1,13 @@
+2005-02-17  Darin Adler  <darin@apple.com>
+
+        Reviewed by Kevin.
+
+        - fixed <rdar://problem/3998627> WebKit crashes when deleting text in a modified div
+
+        * khtml/khtml_part.cpp: (KHTMLPart::selectionComputedStyle): Add a ref and deref to keep
+        the element alive until it's added to the DOM tree.
+        * kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::styleForSelectionStart): Ditto.
+
 2005-02-17  Richard Williamson   <rjw@apple.com>
 
         Fixed <rdar://problem/3999467> when Osaka-Mono is specified as fixed width font, Osaka used instead
index 0414f5273689f173915d02bdc19031b36e8790cf..0cd62b17614e92c224c9b7ac2dbf0e4f2603cfe6 100644 (file)
@@ -5614,8 +5614,10 @@ CSSComputedStyleDeclarationImpl *KHTMLPart::selectionComputedStyle(NodeImpl *&no
     int exceptionCode = 0;
 
     if (d->m_typingStyle) {
-        styleElement = xmlDocImpl()->createHTMLElement("SPAN", exceptionCode);
+        styleElement = xmlDocImpl()->createHTMLElement("span", exceptionCode);
         assert(exceptionCode == 0);
+
+        styleElement->ref();
         
         styleElement->setAttribute(ATTR_STYLE, d->m_typingStyle->cssText().implementation(), exceptionCode);
         assert(exceptionCode == 0);
@@ -5625,20 +5627,21 @@ CSSComputedStyleDeclarationImpl *KHTMLPart::selectionComputedStyle(NodeImpl *&no
         assert(exceptionCode == 0);
 
         if (elem->renderer() && elem->renderer()->canHaveChildren()) {
-          elem->appendChild(styleElement, exceptionCode);
+            elem->appendChild(styleElement, exceptionCode);
         } else {
-          NodeImpl *parent = elem->parent();
-          NodeImpl *next = elem->nextSibling();
+            NodeImpl *parent = elem->parent();
+            NodeImpl *next = elem->nextSibling();
 
-          if (next) {
-            parent->insertBefore(styleElement, next, exceptionCode);
-          } else {
-            parent->appendChild(styleElement, exceptionCode);
-          }
+            if (next) {
+                parent->insertBefore(styleElement, next, exceptionCode);
+            } else {
+                parent->appendChild(styleElement, exceptionCode);
+            }
         }
-
         assert(exceptionCode == 0);
 
+        styleElement->deref();
+
         nodeToRemove = styleElement;
     }
 
index ea287f84c67e8ec3ced832bc648145fe2e674201..75a5a3091fed416ed6e666b29d7362b71c1dabd6 100644 (file)
@@ -3457,7 +3457,9 @@ RenderStyle *KWQKHTMLPart::styleForSelectionStart(NodeImpl *&nodeToRemove) const
     int exceptionCode = 0;
     ElementImpl *styleElement = xmlDocImpl()->createHTMLElement("span", exceptionCode);
     ASSERT(exceptionCode == 0);
-    
+
+    styleElement->ref();
+
     styleElement->setAttribute(ATTR_STYLE, d->m_typingStyle->cssText().implementation(), exceptionCode);
     ASSERT(exceptionCode == 0);
     
@@ -3468,6 +3470,8 @@ RenderStyle *KWQKHTMLPart::styleForSelectionStart(NodeImpl *&nodeToRemove) const
     node->parentNode()->appendChild(styleElement, exceptionCode);
     ASSERT(exceptionCode == 0);
 
+    styleElement->deref();
+
     nodeToRemove = styleElement;    
     return styleElement->renderer()->style();
 }