[webkit-changes] cvs commit: WebCore/khtml/rendering render_box.cpp render_box.h render_list.cpp render_object.cpp render_object.h render_replaced.cpp

David harrison at opensource.apple.com
Wed Dec 21 14:51:13 PST 2005


harrison    05/12/21 14:51:13

  Modified:    .        ChangeLog
               khtml/editing apply_style_command.cpp apply_style_command.h
                        composite_edit_command.cpp composite_edit_command.h
                        insert_line_break_command.cpp
                        replace_selection_command.cpp
               khtml/rendering render_box.cpp render_box.h render_list.cpp
                        render_object.cpp render_object.h
                        render_replaced.cpp
  Log:
          Reviewed by Justin).
  
          <rdar://problem/4039777> Pasting particular snippet of HTML containing list items and a link creates too many list items
          - Fixed paste crash by making calling RenderBox::deleteLineBoxWrapper() from RenderObject::remove(),
          so that the connection is broken before the InlineBox's parent gets deleted.
          - Fixed overzealous style changes when setting the style on a specific range of elements.  These specific
          ranges are derived programmatically, e.g. as a part of pasting, so they must be respected exactly rather
          than modified by converting the endpoints to VisiblePositions.
  
          Test cases coming soon.
  
          * khtml/editing/apply_style_command.cpp:
          (khtml::ApplyStyleCommand::ApplyStyleCommand):
          (khtml::ApplyStyleCommand::updateStartEnd):
          (khtml::ApplyStyleCommand::startPosition):
          (khtml::ApplyStyleCommand::endPosition):
          (khtml::ApplyStyleCommand::applyBlockStyle):
          (khtml::ApplyStyleCommand::applyRelativeFontStyleChange):
          (khtml::ApplyStyleCommand::applyInlineStyle):
          (khtml::ApplyStyleCommand::removeInlineStyle):
          (khtml::ApplyStyleCommand::splitTextAtStartIfNeeded):
          (khtml::ApplyStyleCommand::splitTextAtEndIfNeeded):
          (khtml::ApplyStyleCommand::splitTextElementAtStartIfNeeded):
          (khtml::ApplyStyleCommand::splitTextElementAtEndIfNeeded):
          (khtml::ApplyStyleCommand::mergeStartWithPreviousIfIdentical):
          (khtml::ApplyStyleCommand::mergeEndWithNextIfIdentical):
          (khtml::ApplyStyleCommand::joinChildTextNodes):
          * khtml/editing/apply_style_command.h:
          * khtml/editing/composite_edit_command.cpp:
          (khtml::CompositeEditCommand::applyStyle):
          * khtml/editing/composite_edit_command.h:
          * khtml/editing/insert_line_break_command.cpp:
          (khtml::InsertLineBreakCommand::doApply):
          * khtml/editing/replace_selection_command.cpp:
          (khtml::ReplaceSelectionCommand::fixupNodeStyles):
          (khtml::ReplaceSelectionCommand::completeHTMLReplacement):
          * khtml/rendering/render_box.cpp:
          (RenderBox::destroy):
          (RenderBox::deleteLineBoxWrapper):
          * khtml/rendering/render_box.h:
          * khtml/rendering/render_list.cpp:
          (RenderListMarker::~RenderListMarker):
          (RenderListMarker::setStyle):
          * khtml/rendering/render_object.cpp:
          (RenderObject::remove):
          * khtml/rendering/render_object.h:
          * khtml/rendering/render_replaced.cpp:
          (RenderWidget::destroy):
  
  Revision  Changes    Path
  1.19      +51 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ChangeLog	21 Dec 2005 16:51:00 -0000	1.18
  +++ ChangeLog	21 Dec 2005 22:51:10 -0000	1.19
  @@ -1,3 +1,54 @@
  +2005-12-21  David Harrison  <harrison at apple.com>
  +
  +        Reviewed by Justin).
  +
  +        <rdar://problem/4039777> Pasting particular snippet of HTML containing list items and a link creates too many list items
  +        - Fixed paste crash by making calling RenderBox::deleteLineBoxWrapper() from RenderObject::remove(),
  +        so that the connection is broken before the InlineBox's parent gets deleted.
  +        - Fixed overzealous style changes when setting the style on a specific range of elements.  These specific
  +        ranges are derived programmatically, e.g. as a part of pasting, so they must be respected exactly rather
  +        than modified by converting the endpoints to VisiblePositions.
  +        
  +        Test cases coming soon.
  +
  +        * khtml/editing/apply_style_command.cpp:
  +        (khtml::ApplyStyleCommand::ApplyStyleCommand):
  +        (khtml::ApplyStyleCommand::updateStartEnd):
  +        (khtml::ApplyStyleCommand::startPosition):
  +        (khtml::ApplyStyleCommand::endPosition):
  +        (khtml::ApplyStyleCommand::applyBlockStyle):
  +        (khtml::ApplyStyleCommand::applyRelativeFontStyleChange):
  +        (khtml::ApplyStyleCommand::applyInlineStyle):
  +        (khtml::ApplyStyleCommand::removeInlineStyle):
  +        (khtml::ApplyStyleCommand::splitTextAtStartIfNeeded):
  +        (khtml::ApplyStyleCommand::splitTextAtEndIfNeeded):
  +        (khtml::ApplyStyleCommand::splitTextElementAtStartIfNeeded):
  +        (khtml::ApplyStyleCommand::splitTextElementAtEndIfNeeded):
  +        (khtml::ApplyStyleCommand::mergeStartWithPreviousIfIdentical):
  +        (khtml::ApplyStyleCommand::mergeEndWithNextIfIdentical):
  +        (khtml::ApplyStyleCommand::joinChildTextNodes):
  +        * khtml/editing/apply_style_command.h:
  +        * khtml/editing/composite_edit_command.cpp:
  +        (khtml::CompositeEditCommand::applyStyle):
  +        * khtml/editing/composite_edit_command.h:
  +        * khtml/editing/insert_line_break_command.cpp:
  +        (khtml::InsertLineBreakCommand::doApply):
  +        * khtml/editing/replace_selection_command.cpp:
  +        (khtml::ReplaceSelectionCommand::fixupNodeStyles):
  +        (khtml::ReplaceSelectionCommand::completeHTMLReplacement):
  +        * khtml/rendering/render_box.cpp:
  +        (RenderBox::destroy):
  +        (RenderBox::deleteLineBoxWrapper):
  +        * khtml/rendering/render_box.h:
  +        * khtml/rendering/render_list.cpp:
  +        (RenderListMarker::~RenderListMarker):
  +        (RenderListMarker::setStyle):
  +        * khtml/rendering/render_object.cpp:
  +        (RenderObject::remove):
  +        * khtml/rendering/render_object.h:
  +        * khtml/rendering/render_replaced.cpp:
  +        (RenderWidget::destroy):
  +
   2005-12-20  Adele Peterson  <adele at apple.com>
   
           Reviewed by Darin.
  
  
  
  1.21      +82 -49    WebCore/khtml/editing/apply_style_command.cpp
  
  Index: apply_style_command.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/editing/apply_style_command.cpp,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- apply_style_command.cpp	20 Dec 2005 22:31:44 -0000	1.20
  +++ apply_style_command.cpp	21 Dec 2005 22:51:10 -0000	1.21
  @@ -284,12 +284,52 @@
       : CompositeEditCommand(document), m_style(style->makeMutable()), m_editingAction(editingAction), m_propertyLevel(propertyLevel)
   {   
       ASSERT(style);
  +    m_start = endingSelection().start().downstream();
  +    m_end = endingSelection().end().upstream();
  +    m_useEndingSelection = true;
  +}
  +
  +ApplyStyleCommand::ApplyStyleCommand(DocumentImpl *document, CSSStyleDeclarationImpl *style, Position start, Position end, EditAction editingAction, EPropertyLevel propertyLevel)
  +    : CompositeEditCommand(document), m_style(style->makeMutable()), m_editingAction(editingAction), m_propertyLevel(propertyLevel)
  +{
  +    ASSERT(style);
  +    m_start = start;
  +    m_end = end;
  +    m_useEndingSelection = false;
   }
   
   ApplyStyleCommand::~ApplyStyleCommand()
   {
   }
   
  +void ApplyStyleCommand::updateStartEnd(Position newStart, Position newEnd)
  +{
  +    ASSERT (RangeImpl::compareBoundaryPoints(newEnd, newStart) >= 0);
  +
  +    if (!m_useEndingSelection && (newStart != m_start || newEnd != m_end))
  +        m_useEndingSelection = true;
  +
  +    setEndingSelection(SelectionController(newStart, VP_DEFAULT_AFFINITY, newEnd, VP_DEFAULT_AFFINITY));
  +    m_start = newStart;
  +    m_end = newEnd;
  +}
  +
  +Position ApplyStyleCommand::startPosition()
  +{
  +    if (m_useEndingSelection)
  +        return endingSelection().start();
  +    
  +    return m_start;
  +}
  +
  +Position ApplyStyleCommand::endPosition()
  +{
  +    if (m_useEndingSelection)
  +        return endingSelection().end();
  +    
  +    return m_end;
  +}
  +
   void ApplyStyleCommand::doApply()
   {
       switch (m_propertyLevel) {
  @@ -329,9 +369,14 @@
       document()->updateLayout();
   
       // get positions we want to use for applying style
  -    Position start(endingSelection().start());
  -    Position end(endingSelection().end());
  -    
  +    Position start = startPosition();
  +    Position end = endPosition();
  +    if (RangeImpl::compareBoundaryPoints(end, start) < 0) {
  +        Position swap = start;
  +        start = end;
  +        end = swap;
  +    }
  +
       // remove current values, if any, of the specified styles from the blocks
       // NOTE: tracks the previous block to avoid repeated processing
       // Also, gather up all the nodes we want to process in a QPtrList before
  @@ -394,40 +439,36 @@
       if (adjustment == NoFontDelta)
           return;
       
  -    // Adjust to the positions we want to use for applying style.
  -    SelectionController selection = endingSelection();
  -    Position start(selection.start().downstream());
  -    Position end(selection.end().upstream());
  +    Position start = startPosition();
  +    Position end = endPosition();
       if (RangeImpl::compareBoundaryPoints(end, start) < 0) {
           Position swap = start;
           start = end;
           end = swap;
       }
  -
  +    
       // Join up any adjacent text nodes.
       if (start.node()->isTextNode()) {
           joinChildTextNodes(start.node()->parentNode(), start, end);
  -        selection = endingSelection();
  -        start = selection.start();
  -        end = selection.end();
  +        start = startPosition();
  +        end = endPosition();
       }
       if (end.node()->isTextNode() && start.node()->parentNode() != end.node()->parentNode()) {
           joinChildTextNodes(end.node()->parentNode(), start, end);
  -        selection = endingSelection();
  -        start = selection.start();
  -        end = selection.end();
  +        start = startPosition();
  +        end = endPosition();
       }
   
       // Split the start text nodes if needed to apply style.
       bool splitStart = splitTextAtStartIfNeeded(start, end); 
       if (splitStart) {
  -        start = endingSelection().start();
  -        end = endingSelection().end();
  +        start = startPosition();
  +        end = endPosition();
       }
       bool splitEnd = splitTextAtEndIfNeeded(start, end);
       if (splitEnd) {
  -        start = endingSelection().start();
  -        end = endingSelection().end();
  +        start = startPosition();
  +        end = endPosition();
       }
   
       NodeImpl *beyondEnd = end.node()->traverseNextNode(); // Calculate loop end point.
  @@ -453,15 +494,13 @@
               if (!nodeFullySelected(node, start, end))
                   continue;
               elem = static_cast<HTMLElementImpl *>(node);
  -        }
  -        else if (node->isTextNode() && node->parentNode() != lastStyledNode) {
  +        } else if (node->isTextNode() && node->parentNode() != lastStyledNode) {
               // Last styled node was not parent node of this text node, but we wish to style this
               // text node. To make this possible, add a style span to surround this text node.
               elem = static_cast<HTMLElementImpl *>(createStyleSpanElement(document()));
               insertNodeBefore(elem, node);
               surroundNodeRangeWithElement(node, node, elem);
  -        }
  -        else {
  +        }  else {
               // Only handle HTML elements and text nodes.
               continue;
           }
  @@ -503,9 +542,8 @@
       document()->updateLayout();
       
       // adjust to the positions we want to use for applying style
  -    Position start(endingSelection().start().downstream());
  -    Position end(endingSelection().end().upstream());
  -
  +    Position start = startPosition();
  +    Position end = endPosition();
       if (RangeImpl::compareBoundaryPoints(end, start) < 0) {
           Position swap = start;
           start = end;
  @@ -515,15 +553,15 @@
       // split the start node and containing element if the selection starts inside of it
       bool splitStart = splitTextElementAtStartIfNeeded(start, end); 
       if (splitStart) {
  -        start = endingSelection().start();
  -        end = endingSelection().end();
  +        start = startPosition();
  +        end = endPosition();
       }
   
       // split the end node and containing element if the selection ends inside of it
       bool splitEnd = splitTextElementAtEndIfNeeded(start, end);
       if (splitEnd) {
  -        start = endingSelection().start();
  -        end = endingSelection().end();
  +        start = startPosition();
  +        end = endPosition();
       }
   
       // Remove style from the selection.
  @@ -532,21 +570,21 @@
       // and prevent us from adding redundant ones, as described in:
       // <rdar://problem/3724344> Bolding and unbolding creates extraneous tags
       removeInlineStyle(style, start.upstream(), end);
  -    start = endingSelection().start();
  -    end = endingSelection().end();
  +    start = startPosition();
  +    end = endPosition();
   
       if (splitStart) {
           bool mergedStart = mergeStartWithPreviousIfIdentical(start, end);
           if (mergedStart) {
  -            start = endingSelection().start();
  -            end = endingSelection().end();
  +            start = startPosition();
  +            end = endPosition();
           }
       }
   
       if (splitEnd) {
           mergeEndWithNextIfIdentical(start, end);
  -        start = endingSelection().start();
  -        end = endingSelection().end();
  +        start = startPosition();
  +        end = endPosition();
       }
   
       // update document layout once before running the rest of the function
  @@ -844,7 +882,7 @@
       ASSERT(end.isNotNull());
       ASSERT(start.node()->inDocument());
       ASSERT(end.node()->inDocument());
  -    ASSERT(RangeImpl::compareBoundaryPoints(start, end) < 0);
  +    ASSERT(RangeImpl::compareBoundaryPoints(start, end) <= 0);
       
       RefPtr<CSSValueImpl> textDecorationSpecialProperty = style->getPropertyCSSValue(CSS_PROP__KHTML_TEXT_DECORATIONS_IN_EFFECT);
   
  @@ -902,7 +940,7 @@
       
       ASSERT(s.node()->inDocument());
       ASSERT(e.node()->inDocument());
  -    setEndingSelection(SelectionController(s, VP_DEFAULT_AFFINITY, e, VP_DEFAULT_AFFINITY));
  +    updateStartEnd(s,e);
   }
   
   bool ApplyStyleCommand::nodeFullySelected(NodeImpl *node, const Position &start, const Position &end) const
  @@ -934,7 +972,7 @@
           int endOffsetAdjustment = start.node() == end.node() ? start.offset() : 0;
           TextImpl *text = static_cast<TextImpl *>(start.node());
           splitTextNode(text, start.offset());
  -        setEndingSelection(SelectionController(Position(start.node(), 0), SEL_DEFAULT_AFFINITY, Position(end.node(), end.offset() - endOffsetAdjustment), SEL_DEFAULT_AFFINITY));
  +        updateStartEnd(Position(start.node(), 0), Position(end.node(), end.offset() - endOffsetAdjustment));
           return true;
       }
       return false;
  @@ -950,7 +988,7 @@
           ASSERT(prevNode);
           NodeImpl *startNode = start.node() == end.node() ? prevNode : start.node();
           ASSERT(startNode);
  -        setEndingSelection(SelectionController(Position(startNode, start.offset()), SEL_DEFAULT_AFFINITY, Position(prevNode, prevNode->caretMaxOffset()), SEL_DEFAULT_AFFINITY));
  +        updateStartEnd(Position(startNode, start.offset()), Position(prevNode, prevNode->caretMaxOffset()));
           return true;
       }
       return false;
  @@ -963,7 +1001,7 @@
           TextImpl *text = static_cast<TextImpl *>(start.node());
           splitTextNodeContainingElement(text, start.offset());
   
  -        setEndingSelection(SelectionController(Position(start.node()->parentNode(), start.node()->nodeIndex()), SEL_DEFAULT_AFFINITY, Position(end.node(), end.offset() - endOffsetAdjustment), SEL_DEFAULT_AFFINITY));
  +        updateStartEnd(Position(start.node()->parentNode(), start.node()->nodeIndex()), Position(end.node(), end.offset() - endOffsetAdjustment));
           return true;
       }
       return false;
  @@ -979,7 +1017,7 @@
           ASSERT(prevNode);
           NodeImpl *startNode = start.node() == end.node() ? prevNode : start.node();
           ASSERT(startNode);
  -        setEndingSelection(SelectionController(Position(startNode, start.offset()), SEL_DEFAULT_AFFINITY, Position(prevNode->parent(), prevNode->nodeIndex() + 1), SEL_DEFAULT_AFFINITY));
  +        updateStartEnd(Position(startNode, start.offset()), Position(prevNode->parent(), prevNode->nodeIndex() + 1));
           return true;
       }
       return false;
  @@ -1053,10 +1091,7 @@
   
           int startOffsetAdjustment = startChild->nodeIndex();
           int endOffsetAdjustment = startNode == end.node() ? startOffsetAdjustment : 0;
  -
  -        setEndingSelection(SelectionController(Position(startNode, startOffsetAdjustment), SEL_DEFAULT_AFFINITY,
  -                                     Position(end.node(), end.offset() + endOffsetAdjustment), SEL_DEFAULT_AFFINITY)); 
  -
  +        updateStartEnd(Position(startNode, startOffsetAdjustment), Position(end.node(), end.offset() + endOffsetAdjustment)); 
           return true;
       }
   
  @@ -1096,9 +1131,7 @@
           ASSERT(startNode);
   
           int endOffset = nextChild ? nextChild->nodeIndex() : nextElement->childNodes()->length();
  -
  -        setEndingSelection(SelectionController(Position(startNode, start.offset()), SEL_DEFAULT_AFFINITY, 
  -                                     Position(nextElement, endOffset), SEL_DEFAULT_AFFINITY));
  +        updateStartEnd(Position(startNode, start.offset()), Position(nextElement, endOffset));
           return true;
       }
   
  @@ -1282,7 +1315,7 @@
           }
       }
   
  -    setEndingSelection(SelectionController(newStart, SEL_DEFAULT_AFFINITY, newEnd, SEL_DEFAULT_AFFINITY));
  +    updateStartEnd(newStart, newEnd);
   }
   
   } // namespace khtml
  
  
  
  1.4       +8 -0      WebCore/khtml/editing/apply_style_command.h
  
  Index: apply_style_command.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/editing/apply_style_command.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- apply_style_command.h	1 Dec 2005 10:32:14 -0000	1.3
  +++ apply_style_command.h	21 Dec 2005 22:51:10 -0000	1.4
  @@ -40,6 +40,7 @@
       enum EPropertyLevel { PropertyDefault, ForceBlockProperties };
   
       ApplyStyleCommand(DOM::DocumentImpl *, DOM::CSSStyleDeclarationImpl *style, EditAction editingAction=EditActionChangeAttributes, EPropertyLevel=PropertyDefault);
  +    ApplyStyleCommand(DOM::DocumentImpl *, DOM::CSSStyleDeclarationImpl *style, const DOM::Position start, const DOM::Position end, EditAction editingAction=EditActionChangeAttributes, EPropertyLevel=PropertyDefault);
       virtual ~ApplyStyleCommand();
   	
       virtual void doApply();
  @@ -80,10 +81,17 @@
       void surroundNodeRangeWithElement(DOM::NodeImpl *start, DOM::NodeImpl *end, DOM::ElementImpl *element);
       float computedFontSize(const DOM::NodeImpl *);
       void joinChildTextNodes(DOM::NodeImpl *, const DOM::Position &start, const DOM::Position &end);
  +
  +    void ApplyStyleCommand::updateStartEnd(DOM::Position newStart, DOM::Position newEnd);
  +    DOM::Position ApplyStyleCommand::startPosition();
  +    DOM::Position ApplyStyleCommand::endPosition();
       
  +    DOM::Position m_start;
  +    DOM::Position m_end;
       RefPtr<DOM::CSSMutableStyleDeclarationImpl> m_style;
       EditAction m_editingAction;
       EPropertyLevel m_propertyLevel;
  +    bool m_useEndingSelection;
   };
   
   bool isStyleSpan(const DOM::NodeImpl *node);
  
  
  
  1.21      +6 -0      WebCore/khtml/editing/composite_edit_command.cpp
  
  Index: composite_edit_command.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/editing/composite_edit_command.cpp,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- composite_edit_command.cpp	10 Dec 2005 02:59:31 -0000	1.20
  +++ composite_edit_command.cpp	21 Dec 2005 22:51:10 -0000	1.21
  @@ -118,6 +118,12 @@
       applyCommandToComposite(cmd);
   }
   
  +void CompositeEditCommand::applyStyle(CSSStyleDeclarationImpl *style, Position start, Position end, EditAction editingAction)
  +{
  +    EditCommandPtr cmd(new ApplyStyleCommand(document(), style, start, end, editingAction));
  +    applyCommandToComposite(cmd);
  +}
  +
   void CompositeEditCommand::insertParagraphSeparator()
   {
       EditCommandPtr cmd(new InsertParagraphSeparatorCommand(document()));
  
  
  
  1.7       +1 -0      WebCore/khtml/editing/composite_edit_command.h
  
  Index: composite_edit_command.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/editing/composite_edit_command.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- composite_edit_command.h	9 Nov 2005 19:56:47 -0000	1.6
  +++ composite_edit_command.h	21 Dec 2005 22:51:10 -0000	1.7
  @@ -53,6 +53,7 @@
       void appendNode(DOM::NodeImpl *appendChild, DOM::NodeImpl *parentNode);
       void applyCommandToComposite(EditCommandPtr &);
       void applyStyle(DOM::CSSStyleDeclarationImpl *style, EditAction editingAction=EditActionChangeAttributes);
  +    void applyStyle(DOM::CSSStyleDeclarationImpl *style, DOM::Position start, DOM::Position end, EditAction editingAction=EditActionChangeAttributes);
       void deleteKeyPressed();
       void deleteSelection(bool smartDelete=false, bool mergeBlocksAfterDelete=true);
       void deleteSelection(const SelectionController &selection, bool smartDelete=false, bool mergeBlocksAfterDelete=true);
  
  
  
  1.11      +1 -10     WebCore/khtml/editing/insert_line_break_command.cpp
  
  Index: insert_line_break_command.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/editing/insert_line_break_command.cpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- insert_line_break_command.cpp	21 Nov 2005 01:20:03 -0000	1.10
  +++ insert_line_break_command.cpp	21 Dec 2005 22:51:10 -0000	1.11
  @@ -171,16 +171,7 @@
       
       if (typingStyle && typingStyle->length() > 0) {
           SelectionController selectionBeforeStyle = endingSelection();
  -
  -        DOM::RangeImpl *rangeAroundNode = document()->createRange();
  -        int exception = 0;
  -        rangeAroundNode->selectNode(nodeToInsert, exception);
  -
  -        // affinity is not really important since this is a temp selection
  -        // just for calling applyStyle
  -        setEndingSelection(SelectionController(rangeAroundNode, khtml::SEL_DEFAULT_AFFINITY, khtml::SEL_DEFAULT_AFFINITY));
  -        applyStyle(typingStyle);
  -
  +        applyStyle(typingStyle, Position(nodeToInsert, 0), Position(nodeToInsert, nodeToInsert->maxDeepOffset()));
           setEndingSelection(selectionBeforeStyle);
       }
   
  
  
  
  1.21      +5 -19     WebCore/khtml/editing/replace_selection_command.cpp
  
  Index: replace_selection_command.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/editing/replace_selection_command.cpp,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- replace_selection_command.cpp	13 Dec 2005 01:28:58 -0000	1.20
  +++ replace_selection_command.cpp	21 Dec 2005 22:51:10 -0000	1.21
  @@ -347,18 +347,8 @@
           
           // If the desiredStyle is non-zero length, that means the current style differs
           // from the desired by the styles remaining in the desiredStyle declaration.
  -        if (desiredStyle->length() > 0) {
  -            DOM::RangeImpl *rangeAroundNode = document()->createRange();
  -            rangeAroundNode->ref();
  -            int exceptionCode = 0;
  -            rangeAroundNode->selectNode(node, exceptionCode);
  -            ASSERT(exceptionCode == 0);
  -            // affinity is not really important since this is a temp selection
  -            // just for calling applyStyle
  -            setEndingSelection(SelectionController(rangeAroundNode, SEL_DEFAULT_AFFINITY, SEL_DEFAULT_AFFINITY));
  -            applyStyle(desiredStyle);
  -            rangeAroundNode->deref();
  -        }
  +        if (desiredStyle->length() > 0)
  +	    applyStyle(desiredStyle, Position(node, 0), Position(node, node->maxDeepOffset()));
   
           currentStyle->deref();
       }
  @@ -986,19 +976,15 @@
   
           if (m_matchStyle) {
               assert(m_insertionStyle);
  -            setEndingSelection(SelectionController(start, SEL_DEFAULT_AFFINITY, end, SEL_DEFAULT_AFFINITY));
  -            applyStyle(m_insertionStyle);
  +            applyStyle(m_insertionStyle, start, end);
           }    
           
           if (lastPositionToSelect.isNotNull())
               end = lastPositionToSelect;
  -    }
  -    else if (lastPositionToSelect.isNotNull()) {
  +    } else if (lastPositionToSelect.isNotNull()) {
           start = end = lastPositionToSelect;
  -    }
  -    else {
  +    } else
           return;
  -    }
       
       if (m_selectReplacement)
           setEndingSelection(SelectionController(start, SEL_DEFAULT_AFFINITY, end, SEL_DEFAULT_AFFINITY));
  
  
  
  1.179     +5 -9      WebCore/khtml/rendering/render_box.cpp
  
  Index: render_box.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_box.cpp,v
  retrieving revision 1.178
  retrieving revision 1.179
  diff -u -r1.178 -r1.179
  --- render_box.cpp	30 Nov 2005 01:58:45 -0000	1.178
  +++ render_box.cpp	21 Dec 2005 22:51:11 -0000	1.179
  @@ -148,13 +148,6 @@
       // This must be done before we destroy the RenderObject.
       if (layer)
           layer->clearClipRect();
  -        
  -    if (m_inlineBoxWrapper) {
  -        if (!documentBeingDestroyed())
  -            m_inlineBoxWrapper->remove();
  -        m_inlineBoxWrapper->destroy(arena);
  -        m_inlineBoxWrapper = 0;
  -    }
   
       RenderObject::destroy();
       
  @@ -755,9 +748,12 @@
   
   void RenderBox::deleteLineBoxWrapper()
   {
  -    if (m_inlineBoxWrapper)
  +    if (m_inlineBoxWrapper) {
  +        if (!documentBeingDestroyed())
  +            m_inlineBoxWrapper->remove();
           m_inlineBoxWrapper->destroy(renderArena());
  -    m_inlineBoxWrapper = 0;
  +        m_inlineBoxWrapper = 0;
  +    }
   }
   
   void RenderBox::setInlineBoxWrapper(InlineBox* b)
  
  
  
  1.61      +1 -1      WebCore/khtml/rendering/render_box.h
  
  Index: render_box.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_box.h,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- render_box.h	25 Oct 2005 20:54:28 -0000	1.60
  +++ render_box.h	21 Dec 2005 22:51:11 -0000	1.61
  @@ -103,7 +103,7 @@
       // iterate over structures on the line.
       virtual InlineBox* inlineBoxWrapper() const;
       virtual void setInlineBoxWrapper(InlineBox* b);
  -    void deleteLineBoxWrapper();
  +    virtual void deleteLineBoxWrapper();
       
       virtual int lowestPosition(bool includeOverflowInterior=true, bool includeSelf=true) const;
       virtual int rightmostPosition(bool includeOverflowInterior=true, bool includeSelf=true) const;
  
  
  
  1.74      +6 -4      WebCore/khtml/rendering/render_list.cpp
  
  Index: render_list.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_list.cpp,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- render_list.cpp	21 Nov 2005 01:20:26 -0000	1.73
  +++ render_list.cpp	21 Dec 2005 22:51:11 -0000	1.74
  @@ -330,21 +330,23 @@
   
   RenderListMarker::~RenderListMarker()
   {
  -    if(m_listImage)
  +    if (m_listImage)
           m_listImage->deref(this);
   }
   
   void RenderListMarker::setStyle(RenderStyle *s)
   {
  -    if ( s && style() && s->listStylePosition() != style()->listStylePosition() )
  +    if (s && style() && s->listStylePosition() != style()->listStylePosition())
           setNeedsLayoutAndMinMaxRecalc();
       
       RenderBox::setStyle(s);
   
       if ( m_listImage != style()->listStyleImage() ) {
  -	if(m_listImage)  m_listImage->deref(this);
  +	if (m_listImage)
  +	    m_listImage->deref(this);
   	m_listImage = style()->listStyleImage();
  -	if(m_listImage) m_listImage->ref(this);
  +	if (m_listImage)
  +	    m_listImage->ref(this);
       }
   }
   
  
  
  
  1.231     +2 -0      WebCore/khtml/rendering/render_object.cpp
  
  Index: render_object.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_object.cpp,v
  retrieving revision 1.230
  retrieving revision 1.231
  diff -u -r1.230 -r1.231
  --- render_object.cpp	7 Dec 2005 21:24:59 -0000	1.230
  +++ render_object.cpp	21 Dec 2005 22:51:11 -0000	1.231
  @@ -2061,6 +2061,8 @@
       if (parent())
           //have parent, take care of the tree integrity
           parent()->removeChild(this);
  +    
  +    deleteLineBoxWrapper();
   }
   
   void RenderObject::destroy()
  
  
  
  1.171     +1 -1      WebCore/khtml/rendering/render_object.h
  
  Index: render_object.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_object.h,v
  retrieving revision 1.170
  retrieving revision 1.171
  diff -u -r1.170 -r1.171
  --- render_object.h	11 Dec 2005 09:26:14 -0000	1.170
  +++ render_object.h	21 Dec 2005 22:51:11 -0000	1.171
  @@ -385,7 +385,7 @@
       // iterate over structures on the line.
       virtual InlineBox* inlineBoxWrapper() const;
       virtual void setInlineBoxWrapper(InlineBox* b);
  -    void deleteLineBoxWrapper();
  +    virtual void deleteLineBoxWrapper();
   
       virtual InlineBox *inlineBox(int offset=0, EAffinity affinity = UPSTREAM);
       
  
  
  
  1.98      +0 -7      WebCore/khtml/rendering/render_replaced.cpp
  
  Index: render_replaced.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_replaced.cpp,v
  retrieving revision 1.97
  retrieving revision 1.98
  diff -u -r1.97 -r1.98
  --- render_replaced.cpp	15 Dec 2005 22:31:47 -0000	1.97
  +++ render_replaced.cpp	21 Dec 2005 22:51:12 -0000	1.98
  @@ -262,13 +262,6 @@
       if (layer)
           layer->clearClipRect();
       
  -    if (m_inlineBoxWrapper) {
  -        if (!documentBeingDestroyed())
  -            m_inlineBoxWrapper->remove();
  -        m_inlineBoxWrapper->destroy(arena);
  -        m_inlineBoxWrapper = 0;
  -    }
  -    
       setNode(0);
       deref(arena);
       
  
  
  



More information about the webkit-changes mailing list