Fix for hitlist bug, crash when deleting.
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Sep 2004 17:22:27 +0000 (17:22 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Sep 2004 17:22:27 +0000 (17:22 +0000)
Also fix repaint bug when inlines are inside overflow:auto/scroll regions.

        Reviewed by kocienda

        * khtml/editing/htmlediting_impl.cpp:
        (khtml::DeleteSelectionCommandImpl::DeleteSelectionCommandImpl):
        (khtml::DeleteSelectionCommandImpl::doApply):
        * khtml/rendering/render_block.cpp:
        (khtml::RenderBlock::removeChild):
        * khtml/rendering/render_flow.cpp:
        (RenderFlow::getAbsoluteRepaintRect):

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

WebCore/ChangeLog-2005-08-23
WebCore/khtml/editing/htmlediting_impl.cpp
WebCore/khtml/rendering/render_block.cpp
WebCore/khtml/rendering/render_flow.cpp

index 420e5da225e2cf620911a7e50f102c6c001f08cd..dec707a33c8b6caf3c80c6b3a913d9f41ce6dd6f 100644 (file)
@@ -1,3 +1,19 @@
+2004-09-23  David Hyatt  <hyatt@apple.com>
+
+       Fix for hitlist bug, crash when deleting.  
+
+       Also fix repaint bug when inlines are inside overflow:auto/scroll regions.
+       
+        Reviewed by kocienda
+
+        * khtml/editing/htmlediting_impl.cpp:
+        (khtml::DeleteSelectionCommandImpl::DeleteSelectionCommandImpl):
+        (khtml::DeleteSelectionCommandImpl::doApply):
+        * khtml/rendering/render_block.cpp:
+        (khtml::RenderBlock::removeChild):
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::getAbsoluteRepaintRect):
+
 2004-09-23  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Ken.
index 38fed4a4cf97c09b1aa3f9783b8f0b526a5c2037..78fcd64c57c26c8c2a8e26839fa445ec9db298fb 100644 (file)
@@ -1274,12 +1274,20 @@ void DeleteSelectionCommandImpl::doApply()
     // has completed.
     // FIXME: Improve typing style.
     // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
-    CSSComputedStyleDeclarationImpl endingStyle(endingPosition.node());
-    endingStyle.diff(style);
-    document()->part()->setTypingStyle(style);
-    setTypingStyle(style);
-    style->deref();
-
+    if (startNode == endingPosition.node())
+        document()->part()->setTypingStyle(0);
+    else {
+        CSSComputedStyleDeclarationImpl endingStyle(endingPosition.node());
+        endingStyle.diff(style);
+        if (!style->length()) {
+            style->deref();
+            style = 0;
+        }
+        document()->part()->setTypingStyle(style);
+        setTypingStyle(style);
+    }
+    if (style)
+        style->deref();
     setEndingSelection(endingPosition);
 }
 
index 0de323cf8dc212337773f76534496bdaff35f732..f741e01bb7aa54b29a21f22a57e294d904e386ad 100644 (file)
@@ -263,11 +263,11 @@ void RenderBlock::removeChild(RenderObject *oldChild)
     // fold the inline content back together.
     RenderObject* prev = oldChild->previousSibling();
     RenderObject* next = oldChild->nextSibling();
-    bool mergedBlocks = false;
-    if (!documentBeingDestroyed() && !isInline() && !oldChild->isInline() && !oldChild->continuation() &&
-        prev && prev->isAnonymousBlock() && prev->childrenInline() &&
-        next && next->isAnonymousBlock() && next->childrenInline()) {
-        
+    bool canDeleteAnonymousBlocks = !documentBeingDestroyed() && !isInline() && !oldChild->isInline() && 
+        !oldChild->continuation() && 
+        (!prev || (prev->isAnonymousBlock() && prev->childrenInline())) &&
+        (!next || (next->isAnonymousBlock() && next->childrenInline()));
+    if (canDeleteAnonymousBlocks && prev && next) {
         // Take all the children out of the |next| block and put them in
         // the |prev| block.
         RenderObject* o = next->firstChild();
@@ -287,8 +287,9 @@ void RenderBlock::removeChild(RenderObject *oldChild)
 
     RenderFlow::removeChild(oldChild);
 
-    if (mergedBlocks && prev && !prev->previousSibling() && !prev->nextSibling()) {
-        // The remerge has knocked us down to containing only a single anonymous
+    RenderObject* child = prev ? prev : next;
+    if (canDeleteAnonymousBlocks && child && !child->previousSibling() && !child->nextSibling()) {
+        // The removal has knocked us down to containing only a single anonymous
         // box.  We can go ahead and pull the content right back up into our
         // box.
         RenderObject* anonBlock = removeChildNode(prev);
index dd026d2cf91086a466176ebe7597b04857f1915b..1ed830045b0445d0b79a5232b42f476768b66415 100644 (file)
@@ -413,7 +413,21 @@ QRect RenderFlow::getAbsoluteRepaintRect()
             m_layer->relativePositionOffset(left, top);
 
         QRect r(-ow+left, -ow+top, width()+ow*2, height()+ow*2);
-        containingBlock()->computeAbsoluteRepaintRect(r);
+        RenderBlock* cb = containingBlock();
+        if (cb->hasOverflowClip()) {
+            // cb->height() is inaccurate if we're in the middle of a layout of |cb|, so use the
+            // layer's size instead.  Even if the layer's size is wrong, the layer itself will repaint
+            // anyway if its size does change.
+            int x = r.left();
+            int y = r.top();
+            QRect boxRect(0, 0, cb->layer()->width(), cb->layer()->height());
+            cb->layer()->subtractScrollOffset(x,y); // For overflow:auto/scroll/hidden.
+            QRect repaintRect(x, y, r.width(), r.height());
+            r = repaintRect.intersect(boxRect);
+        }
+
+        cb->computeAbsoluteRepaintRect(r);
+        
         if (ow) {
             for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) {
                 if (!curr->isText()) {
@@ -427,7 +441,7 @@ QRect RenderFlow::getAbsoluteRepaintRect()
                 r = r.unite(contRect);
             }
         }
-
+        
         return r;
     }
     else {