[webkit-changes] cvs commit: WebCore/layout-tests/editing editing.js

Adele adele at opensource.apple.com
Tue Jul 26 14:14:27 PDT 2005


adele       05/07/26 14:14:27

  Modified:    .        Tag: Safari-2-0-branch ChangeLog
               WebCoreSupport.subproj Tag: Safari-2-0-branch WebBridge.m
               .        Tag: Safari-2-0-branch ChangeLog
               khtml    Tag: Safari-2-0-branch khtml_part.cpp khtml_part.h
               khtml/editing Tag: Safari-2-0-branch jsediting.cpp
                        visible_position.cpp visible_units.cpp
               kwq      Tag: Safari-2-0-branch KWQKHTMLPart.h
                        KWQKHTMLPart.mm WebCoreBridge.h WebCoreBridge.mm
               layout-tests/editing Tag: Safari-2-0-branch editing.js
  Log:
  WebCore:
  
          Merged fix from TOT to Safari-2-0-branch
  
      2005-05-26  David Harrison  <harrison at apple.com>
  
          Reviewed by John.
  
          <rdar://problem/4120518> Mail: control-T in an empty message crashes mail
  
          * kwq/WebCoreBridge.mm:
          (-[WebCoreBridge rangeOfCharactersAroundCaret]):
          Nil-check result of VisiblePosition previous() and next().
  
          * khtml/editing/visible_position.cpp:
          (khtml::VisiblePosition::previous):
          (khtml::VisiblePosition::previousVisiblePosition):
          Make sure previous() does not return the original position.  Also, simplified.
          Commented odd, but required, behavior in previousVisiblePosition().
  
          * khtml/editing/visible_units.cpp:
          (khtml::startOfEditableContent):
          (khtml::endOfEditableContent):
          Removed redundant check for isEditableContent().
  
          * khtml/editing/jsediting.cpp:
          * khtml/khtml_part.cpp:
          (KHTMLPart::transpose):
          * khtml/khtml_part.h:
          * kwq/KWQKHTMLPart.h:
          * kwq/KWQKHTMLPart.mm:
          (KWQKHTMLPart::issueTransposeCommand):
          * layout-tests/editing/editing.js:
          * kwq/WebCoreBridge.h:
          Add support for transpose command in JavaScript and therefore layout tests.
  
          * layout-tests/editing/deleting/transpose-empty-expected.txt: Added.
          * layout-tests/editing/deleting/transpose-empty.html: Added.
          New test for this bug.
  
  WebKit:
  
          Merged fix from TOT to Safari-2-0-branch
  
      2005-05-26  David Harrison  <harrison at apple.com>
  
          <rdar://problem/4120518> Mail: control-T in an empty message crashes mail
  
          * WebCoreSupport.subproj/WebBridge.m:
          (-[WebBridge issueTransposeCommand]):
          New, to support transpose in JS.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.3118.4.28 +12 -0     WebKit/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebKit/ChangeLog,v
  retrieving revision 1.3118.4.27
  retrieving revision 1.3118.4.28
  diff -u -r1.3118.4.27 -r1.3118.4.28
  --- ChangeLog	26 Jul 2005 20:32:20 -0000	1.3118.4.27
  +++ ChangeLog	26 Jul 2005 21:14:10 -0000	1.3118.4.28
  @@ -2,6 +2,18 @@
   
           Merged fix from TOT to Safari-2-0-branch
   
  +    2005-05-26  David Harrison  <harrison at apple.com>
  +
  +        <rdar://problem/4120518> Mail: control-T in an empty message crashes mail
  +
  +        * WebCoreSupport.subproj/WebBridge.m:
  +        (-[WebBridge issueTransposeCommand]):
  +        New, to support transpose in JS.
  +
  +2005-07-26  Adele Peterson  <adele at apple.com>
  +
  +        Merged fix from TOT to Safari-2-0-branch
  +
       2005-05-10  John Sullivan  <sullivan at apple.com>
   
           Reviewed by Chris.
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.340.8.5 +8 -0      WebKit/WebCoreSupport.subproj/WebBridge.m
  
  Index: WebBridge.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebBridge.m,v
  retrieving revision 1.340.8.4
  retrieving revision 1.340.8.5
  diff -u -r1.340.8.4 -r1.340.8.5
  --- WebBridge.m	22 Jul 2005 01:18:46 -0000	1.340.8.4
  +++ WebBridge.m	26 Jul 2005 21:14:14 -0000	1.340.8.5
  @@ -1395,6 +1395,14 @@
       [[_frame webView] pasteAsPlainText:nil];
   }
   
  +- (void)issueTransposeCommand
  +{
  +    NSView <WebDocumentView> *view = [[_frame frameView] documentView];
  +    if ([view isKindOfClass:[WebHTMLView class]]) {
  +        [(WebHTMLView *)view transpose:nil];
  +    }
  +}
  +
   - (BOOL)canPaste
   {
       return [[_frame webView] _canPaste];
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.4104.2.74 +40 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.4104.2.73
  retrieving revision 1.4104.2.74
  diff -u -r1.4104.2.73 -r1.4104.2.74
  --- ChangeLog	26 Jul 2005 20:57:17 -0000	1.4104.2.73
  +++ ChangeLog	26 Jul 2005 21:14:15 -0000	1.4104.2.74
  @@ -2,6 +2,46 @@
   
           Merged fix from TOT to Safari-2-0-branch
   
  +    2005-05-26  David Harrison  <harrison at apple.com>
  +
  +        Reviewed by John.
  +
  +        <rdar://problem/4120518> Mail: control-T in an empty message crashes mail
  +        
  +        * kwq/WebCoreBridge.mm:
  +        (-[WebCoreBridge rangeOfCharactersAroundCaret]):
  +        Nil-check result of VisiblePosition previous() and next().
  +
  +        * khtml/editing/visible_position.cpp:
  +        (khtml::VisiblePosition::previous):
  +        (khtml::VisiblePosition::previousVisiblePosition):
  +        Make sure previous() does not return the original position.  Also, simplified.
  +        Commented odd, but required, behavior in previousVisiblePosition().
  +
  +        * khtml/editing/visible_units.cpp:
  +        (khtml::startOfEditableContent):
  +        (khtml::endOfEditableContent):
  +        Removed redundant check for isEditableContent().
  +        
  +        * khtml/editing/jsediting.cpp:
  +        * khtml/khtml_part.cpp:
  +        (KHTMLPart::transpose):
  +        * khtml/khtml_part.h:
  +        * kwq/KWQKHTMLPart.h:
  +        * kwq/KWQKHTMLPart.mm:
  +        (KWQKHTMLPart::issueTransposeCommand):
  +        * layout-tests/editing/editing.js:
  +        * kwq/WebCoreBridge.h:
  +        Add support for transpose command in JavaScript and therefore layout tests.
  +        
  +        * layout-tests/editing/deleting/transpose-empty-expected.txt: Added.
  +        * layout-tests/editing/deleting/transpose-empty.html: Added.
  +        New test for this bug.
  +
  +2005-07-26  Adele Peterson  <adele at apple.com>
  +
  +        Merged fix from TOT to Safari-2-0-branch
  +
       2005-04-26  Darin Adler  <darin at apple.com>
   
           Reviewed by Maciej.
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.311.8.10 +7 -0      WebCore/khtml/khtml_part.cpp
  
  Index: khtml_part.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/khtml_part.cpp,v
  retrieving revision 1.311.8.9
  retrieving revision 1.311.8.10
  diff -u -r1.311.8.9 -r1.311.8.10
  --- khtml_part.cpp	15 Jul 2005 17:56:39 -0000	1.311.8.9
  +++ khtml_part.cpp	26 Jul 2005 21:14:22 -0000	1.311.8.10
  @@ -5462,6 +5462,13 @@
   #endif
   }
   
  +void KHTMLPart::transpose()
  +{
  +#if APPLE_CHANGES
  +    KWQ(this)->issueTransposeCommand();
  +#endif
  +}
  +
   void KHTMLPart::redo()
   {
   #if APPLE_CHANGES
  
  
  
  1.127.8.3 +5 -0      WebCore/khtml/khtml_part.h
  
  Index: khtml_part.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/khtml_part.h,v
  retrieving revision 1.127.8.2
  retrieving revision 1.127.8.3
  diff -u -r1.127.8.2 -r1.127.8.3
  --- khtml_part.h	2 Jul 2005 01:32:55 -0000	1.127.8.2
  +++ khtml_part.h	26 Jul 2005 21:14:22 -0000	1.127.8.3
  @@ -628,6 +628,11 @@
     void setDragCaret(const khtml::Selection &);
     
     /**
  +   * Transposes characters either side of caret selection.
  +   */
  +  void transpose();
  +  
  +  /**
      * Clears the current selection.
      */
     void clearSelection();
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.25.8.1  +7 -0      WebCore/khtml/editing/jsediting.cpp
  
  Index: jsediting.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/editing/jsediting.cpp,v
  retrieving revision 1.25
  retrieving revision 1.25.8.1
  diff -u -r1.25 -r1.25.8.1
  --- jsediting.cpp	2 Mar 2005 03:38:43 -0000	1.25
  +++ jsediting.cpp	26 Jul 2005 21:14:23 -0000	1.25.8.1
  @@ -336,6 +336,12 @@
       return execStyleChange(part, CSS_PROP_VERTICAL_ALIGN, "super");
   }
   
  +bool execTranspose(KHTMLPart *part, bool userInterface, const DOMString &value)
  +{
  +    part->transpose();
  +    return true;
  +}
  +
   bool execUnderline(KHTMLPart *part, bool userInterface, const DOMString &value)
   {
       bool isUnderlined = selectionStartHasStyle(part, CSS_PROP__KHTML_TEXT_DECORATIONS_IN_EFFECT, "underline");
  @@ -517,6 +523,7 @@
           { "SelectAll", { execSelectAll, enabled, stateNone, valueNull } },
           { "Subscript", { execSubscript, enabledAnySelection, stateSubscript, valueNull } },
           { "Superscript", { execSuperscript, enabledAnySelection, stateSuperscript, valueNull } },
  +        { "Transpose", { execTranspose, enabled, stateNone, valueNull } },
           { "Underline", { execUnderline, enabledAnySelection, stateUnderline, valueNull } },
           { "Undo", { execUndo, enabledUndo, stateNone, valueNull } },
           { "Unselect", { execUnselect, enabledAnySelection, stateNone, valueNull } }
  
  
  
  1.39.8.2  +23 -4     WebCore/khtml/editing/visible_position.cpp
  
  Index: visible_position.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/editing/visible_position.cpp,v
  retrieving revision 1.39.8.1
  retrieving revision 1.39.8.2
  diff -u -r1.39.8.1 -r1.39.8.2
  --- visible_position.cpp	22 Jul 2005 01:18:32 -0000	1.39.8.1
  +++ visible_position.cpp	26 Jul 2005 21:14:23 -0000	1.39.8.2
  @@ -168,8 +168,21 @@
   
   VisiblePosition VisiblePosition::previous() const
   {
  -    VisiblePosition result =  VisiblePosition(previousVisiblePosition(m_deepPosition), DOWNSTREAM);
  -
  +    // find first previous DOM position that is visible
  +    Position pos = m_deepPosition;
  +    while (!pos.atStart()) {
  +        pos = pos.previous(UsingComposedCharacters);
  +        if (isCandidate(pos))
  +            break;
  +    }
  +    
  +    // return null visible position if there is no previous visible position
  +    if (pos.atStart())
  +        return VisiblePosition();
  +        
  +    VisiblePosition result = VisiblePosition(pos, DOWNSTREAM);
  +    ASSERT(result != *this);
  +    
   #ifndef NDEBUG
       // we should always be able to make the affinity DOWNSTREAM, because going previous from an
       // UPSTREAM position can never yield another UPSTREAM position (unless line wrap length is 0!).
  @@ -191,6 +204,12 @@
       Position downstreamTest = test.downstream(StayInBlock);
       bool acceptAnyVisiblePosition = !isCandidate(test);
   
  +    // NOTE: The first position examined is the deepEquivalent of pos.  This,
  +    // of course, is often after pos in the DOM.  Some care is taken to not return
  +    // a position later than pos, but it is clearly possible to return pos
  +    // itself (if it is a candidate) when iterating back from a deepEquivalent
  +    // that is not a candidate.  That is wrong!  However, our clients seem to
  +    // like it.  Gotta lose those clients! (initDownstream and initUpstream)
       Position current = test;
       while (!atStart(current)) {
           current = previousPosition(current);
  @@ -198,8 +217,8 @@
               return current;
           }
       }
  -    
  -    return Position();
  +
  +     return Position();
   }
   
   Position VisiblePosition::nextVisiblePosition(const Position &pos)
  
  
  
  1.27.8.1  +0 -6      WebCore/khtml/editing/visible_units.cpp
  
  Index: visible_units.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/editing/visible_units.cpp,v
  retrieving revision 1.27
  retrieving revision 1.27.8.1
  diff -u -r1.27 -r1.27.8.1
  --- visible_units.cpp	20 Mar 2005 21:31:25 -0000	1.27
  +++ visible_units.cpp	26 Jul 2005 21:14:23 -0000	1.27.8.1
  @@ -821,9 +821,6 @@
       if (!node)
           return VisiblePosition();
   
  -    if (!node->isContentEditable())
  -        return VisiblePosition();
  -
       return VisiblePosition(node->rootEditableElement(), 0, DOWNSTREAM);
   }
   
  @@ -834,9 +831,6 @@
       if (!node)
           return VisiblePosition();
   
  -    if (!node->isContentEditable())
  -        return VisiblePosition();
  -
       node = node->rootEditableElement();
       if (!node)
           return VisiblePosition();
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.216.8.2 +1 -0      WebCore/kwq/KWQKHTMLPart.h
  
  Index: KWQKHTMLPart.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPart.h,v
  retrieving revision 1.216.8.1
  retrieving revision 1.216.8.2
  diff -u -r1.216.8.1 -r1.216.8.2
  --- KWQKHTMLPart.h	27 Apr 2005 00:58:15 -0000	1.216.8.1
  +++ KWQKHTMLPart.h	26 Jul 2005 21:14:24 -0000	1.216.8.2
  @@ -340,6 +340,7 @@
       void issueCopyCommand();
       void issuePasteCommand();
       void issuePasteAndMatchStyleCommand();
  +    void issueTransposeCommand();
       void respondToChangedSelection(const khtml::Selection &oldSelection, bool closeTyping);
       void respondToChangedContents();
       virtual bool isContentEditable() const;
  
  
  
  1.628.6.4 +5 -0      WebCore/kwq/KWQKHTMLPart.mm
  
  Index: KWQKHTMLPart.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPart.mm,v
  retrieving revision 1.628.6.3
  retrieving revision 1.628.6.4
  diff -u -r1.628.6.3 -r1.628.6.4
  --- KWQKHTMLPart.mm	22 Jul 2005 03:09:53 -0000	1.628.6.3
  +++ KWQKHTMLPart.mm	26 Jul 2005 21:14:24 -0000	1.628.6.4
  @@ -3993,6 +3993,11 @@
       [_bridge issuePasteAndMatchStyleCommand];
   }
   
  +void KWQKHTMLPart::issueTransposeCommand()
  +{
  +    [_bridge issueTransposeCommand];
  +}
  +
   bool KHTMLPart::canUndo() const
   {
       return [[KWQ(this)->_bridge undoManager] canUndo];
  
  
  
  1.327.8.4 +1 -0      WebCore/kwq/WebCoreBridge.h
  
  Index: WebCoreBridge.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/WebCoreBridge.h,v
  retrieving revision 1.327.8.3
  retrieving revision 1.327.8.4
  diff -u -r1.327.8.3 -r1.327.8.4
  --- WebCoreBridge.h	14 Jul 2005 21:48:37 -0000	1.327.8.3
  +++ WebCoreBridge.h	26 Jul 2005 21:14:25 -0000	1.327.8.4
  @@ -605,6 +605,7 @@
   - (void)issueCopyCommand;
   - (void)issuePasteCommand;
   - (void)issuePasteAndMatchStyleCommand;
  +- (void)issueTransposeCommand;
   - (void)respondToChangedSelection;
   - (void)respondToChangedContents;
   - (void)setIsSelected:(BOOL)isSelected forView:(NSView *)view;
  
  
  
  1.382.2.6 +1 -1      WebCore/kwq/WebCoreBridge.mm
  
  Index: WebCoreBridge.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/WebCoreBridge.mm,v
  retrieving revision 1.382.2.5
  retrieving revision 1.382.2.6
  diff -u -r1.382.2.5 -r1.382.2.6
  --- WebCoreBridge.mm	22 Jul 2005 01:18:36 -0000	1.382.2.5
  +++ WebCoreBridge.mm	26 Jul 2005 21:14:25 -0000	1.382.2.6
  @@ -2276,7 +2276,7 @@
       VisiblePosition caret(selection.start(), selection.startAffinity());
       VisiblePosition next = caret.next();
       VisiblePosition previous = caret.previous();
  -    if (caret == next || caret == previous)
  +    if (previous.isNull() || next.isNull() || caret == next || caret == previous)
           return nil;
   
       return [DOMRange _rangeWithImpl:makeRange(previous, next).handle()];
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.17.8.1  +15 -0     WebCore/layout-tests/editing/editing.js
  
  Index: editing.js
  ===================================================================
  RCS file: /cvs/root/WebCore/layout-tests/editing/editing.js,v
  retrieving revision 1.17
  retrieving revision 1.17.8.1
  diff -u -r1.17 -r1.17.8.1
  --- editing.js	23 Feb 2005 02:34:06 -0000	1.17
  +++ editing.js	26 Jul 2005 21:14:26 -0000	1.17.8.1
  @@ -9,6 +9,21 @@
   
   //-------------------------------------------------------------------------------------------------------
   
  +function execTransposeCharactersCommand() {
  +    document.execCommand("Transpose");
  +}
  +function transposeCharactersCommand() {
  +    if (commandDelay > 0) {
  +        window.setTimeout(execTransposeCharactersCommand, commandCount * commandDelay);
  +        commandCount++;
  +    }
  +    else {
  +        execTransposeCharactersCommand();
  +    }
  +}
  +
  +//-------------------------------------------------------------------------------------------------------
  +
   function execMoveSelectionForwardByCharacterCommand() {
       selection.modify("move", "forward", "character");
   }
  
  
  



More information about the webkit-changes mailing list