WebCore:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Sep 2004 15:00:12 +0000 (15:00 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Sep 2004 15:00:12 +0000 (15:00 +0000)
        Reviewed by Ken.

        - fixed <rdar://problem/3790526> mark-related methods not implemented (needed for people with them in their key bindings files)

        * khtml/khtml_part.h: Added mark and setMark.
        * khtml/khtmlpart_p.h: Added m_mark.
        * khtml/khtml_part.cpp:
        (KHTMLPart::mark): Added.
        (KHTMLPart::setMark): Added.

        * kwq/KWQKHTMLPart.h: Change name of markedRange to markedTextRange to decrease
        the change it will be confused with the mark.
        * kwq/KWQKHTMLPart.mm:
        (KWQKHTMLPart::clear): Update for name change.
        (KWQKHTMLPart::markedTextRange): Ditto.
        (KWQKHTMLPart::setMarkedTextRange): Ditto.

        * khtml/rendering/render_text.cpp: (RenderText::paint): Update for name change.

        * kwq/WebCoreBridge.h: Remove setSelectionFrom, selectionStart, selectionStartOffset,
        selectionEnd, selectionEndOffset, and clearMarkedDOMRange. Renamed setMarkedDOMRange
        to setMarkedTextDOMRange and markedDOMRange to markedTextDOMRange. Added setMarkDOMRange
        and markDOMRange for the Emacs "mark".
        * kwq/WebCoreBridge.mm:
        (-[WebCoreBridge setMarkDOMRange:]): Added.
        (-[WebCoreBridge markDOMRange]): Added.
        (-[WebCoreBridge setMarkedTextDOMRange:]): Renamed.
        (-[WebCoreBridge markedTextDOMRange]): Renamed.

        * khtml/xml/dom_selection.cpp: (DOM::Selection::validate): Make paragraph positions
        canonical by using deep rendered positions. Maybe someday this won't be an ad hoc
        decision any more.

        * khtml/xml/dom_nodeimpl.cpp: (NodeBaseImpl::removeChildren): Use ref and deref
        rather than the unconventional check for 0 refCount. This makes us a bit more
        robust against a node going away partway through the removal process.

        * WebCore.pbproj/project.pbxproj: Update MACOSX_DEPLOYMENT_TARGET to 10.3.

WebKit:

        Reviewed by Ken.

        - fixed <rdar://problem/3790526> mark-related methods not implemented (needed for people with them in their key bindings files)

        * WebKit.pbproj/project.pbxproj: Update MACOSX_DEPLOYMENT_TARGET to 10.3 and add -fobjc-exceptions
        so we can use new exceptions.

        * WebView.subproj/WebHTMLView.m:
        (-[WebHTMLView setMark:]): Added.
        (unionDOMRanges): Added.
        (-[WebHTMLView deleteToMark:]): Added.
        (-[WebHTMLView selectToMark:]): Added.
        (-[WebHTMLView swapWithMark:]): Added.
        (-[WebHTMLView markedRange]): Updated for change to bridge method names.
        (-[WebHTMLView hasMarkedText]): Ditto.
        (-[WebHTMLView unmarkText]): Ditto.
        (-[WebHTMLView _selectMarkedText]): Ditto.
        (-[WebHTMLView _selectRangeInMarkedText:]): Ditto.
        (-[WebHTMLView setMarkedText:selectedRange:]): Ditto.
        (-[WebHTMLView _insertText:selectInsertedText:]): Removed check for empty string. An empty string
        should not be filtered out here. We need to allow inserting an empty string.
        (-[WebHTMLView _selectionIsInsideMarkedText]): Updated for change to bridge method names.
        (-[WebHTMLView _updateSelectionForInputManager]): Ditto.

        * WebView.subproj/WebView.m: (-[WebView searchFor:direction:caseSensitive:wrap:]):
        Changed to use selectionDOMRange instead of selectionStart.

        * WebView.subproj/WebHTMLRepresentation.h: Removed unused setSelectionFrom method.
        * WebView.subproj/WebHTMLRepresentation.m: Ditto.

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

20 files changed:
WebCore/ChangeLog-2005-08-23
WebCore/WebCore.pbproj/project.pbxproj
WebCore/khtml/editing/SelectionController.cpp
WebCore/khtml/editing/selection.cpp
WebCore/khtml/khtml_part.cpp
WebCore/khtml/khtml_part.h
WebCore/khtml/khtmlpart_p.h
WebCore/khtml/rendering/render_text.cpp
WebCore/khtml/xml/dom_nodeimpl.cpp
WebCore/khtml/xml/dom_selection.cpp
WebCore/kwq/KWQKHTMLPart.h
WebCore/kwq/KWQKHTMLPart.mm
WebCore/kwq/WebCoreBridge.h
WebCore/kwq/WebCoreBridge.mm
WebKit/ChangeLog
WebKit/WebKit.pbproj/project.pbxproj
WebKit/WebView.subproj/WebHTMLRepresentation.h
WebKit/WebView.subproj/WebHTMLRepresentation.m
WebKit/WebView.subproj/WebHTMLView.m
WebKit/WebView.subproj/WebView.m

index 0f0aa8ffbeac3c019a46a3715b697a1a3598ca1e..8478f1fc0a384d0403d7d536c2041b3e95f87fa4 100644 (file)
@@ -1,3 +1,44 @@
+2004-09-06  Darin Adler  <darin@apple.com>
+
+        Reviewed by Ken.
+
+        - fixed <rdar://problem/3790526> mark-related methods not implemented (needed for people with them in their key bindings files)
+
+        * khtml/khtml_part.h: Added mark and setMark.
+        * khtml/khtmlpart_p.h: Added m_mark.
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::mark): Added.
+        (KHTMLPart::setMark): Added.
+
+        * kwq/KWQKHTMLPart.h: Change name of markedRange to markedTextRange to decrease
+        the change it will be confused with the mark.
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::clear): Update for name change.
+        (KWQKHTMLPart::markedTextRange): Ditto.
+        (KWQKHTMLPart::setMarkedTextRange): Ditto.
+
+        * khtml/rendering/render_text.cpp: (RenderText::paint): Update for name change.
+
+        * kwq/WebCoreBridge.h: Remove setSelectionFrom, selectionStart, selectionStartOffset,
+        selectionEnd, selectionEndOffset, and clearMarkedDOMRange. Renamed setMarkedDOMRange
+        to setMarkedTextDOMRange and markedDOMRange to markedTextDOMRange. Added setMarkDOMRange
+        and markDOMRange for the Emacs "mark".
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge setMarkDOMRange:]): Added.
+        (-[WebCoreBridge markDOMRange]): Added.
+        (-[WebCoreBridge setMarkedTextDOMRange:]): Renamed.
+        (-[WebCoreBridge markedTextDOMRange]): Renamed.
+
+        * khtml/xml/dom_selection.cpp: (DOM::Selection::validate): Make paragraph positions
+        canonical by using deep rendered positions. Maybe someday this won't be an ad hoc
+        decision any more.
+
+        * khtml/xml/dom_nodeimpl.cpp: (NodeBaseImpl::removeChildren): Use ref and deref
+        rather than the unconventional check for 0 refCount. This makes us a bit more
+        robust against a node going away partway through the removal process.
+
+        * WebCore.pbproj/project.pbxproj: Update MACOSX_DEPLOYMENT_TARGET to 10.3.
+
 2004-09-08  Maciej Stachowiak  <mjs@apple.com>
 
         - fixed deployment build problems noticed by Grant
index 5a9e459c64e8840a8daf252cebca5cb37b2892dd..90bee05beee78703ed04bd178a5ba01d619593a1 100644 (file)
                                INSTALL_PATH = /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks;
                                LIBRARY_SEARCH_PATHS = "";
                                LOCAL_SEG1_ADDR = 0x9000000;
-                               MACOSX_DEPLOYMENT_TARGET = 10.2;
+                               MACOSX_DEPLOYMENT_TARGET = 10.3;
                                OPTIMIZATION_CFLAGS = "-Os -falign-loops=16";
                                OTHER_CFLAGS = "$(DEBUG_CFLAGS) -DAPPLE_CHANGES";
                                OTHER_LDFLAGS = "-no-c++filt -umbrella WebKit $(COMMON_LDFLAGS)";
index b25200e7900154e4c11b4fa76322a40b33d43abe..2552884316cce8585a4c5e24a7529ad94b1d1cb8 100644 (file)
@@ -698,11 +698,11 @@ void Selection::validate(ETextGranularity granularity)
         }
         case PARAGRAPH:
             if (m_baseIsStart) {
-                assignStart(base().startParagraphBoundary());
-                assignEnd(extent().endParagraphBoundary(IncludeLineBreak));
+                assignStart(base().startParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(DOWNSTREAM));
+                assignEnd(extent().endParagraphBoundary(IncludeLineBreak).equivalentDeepPosition().closestRenderedPosition(UPSTREAM));
             } else {
-                assignStart(extent().startParagraphBoundary());
-                assignEnd(base().endParagraphBoundary(IncludeLineBreak));
+                assignStart(extent().startParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(DOWNSTREAM));
+                assignEnd(base().endParagraphBoundary(IncludeLineBreak).equivalentDeepPosition().closestRenderedPosition(UPSTREAM));
             }
             break;
         case DOCUMENT: {
@@ -713,11 +713,11 @@ void Selection::validate(ETextGranularity granularity)
         }
         case PARAGRAPH_BOUNDARY:
             if (m_baseIsStart) {
-                assignStart(base().startParagraphBoundary());
-                assignEnd(extent().endParagraphBoundary());
+                assignStart(base().startParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(DOWNSTREAM));
+                assignEnd(extent().endParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(UPSTREAM));
             } else {
-                assignStart(extent().startParagraphBoundary());
-                assignEnd(base().endParagraphBoundary());
+                assignStart(extent().startParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(DOWNSTREAM));
+                assignEnd(base().endParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(UPSTREAM));
             }
             break;
     }
index b25200e7900154e4c11b4fa76322a40b33d43abe..2552884316cce8585a4c5e24a7529ad94b1d1cb8 100644 (file)
@@ -698,11 +698,11 @@ void Selection::validate(ETextGranularity granularity)
         }
         case PARAGRAPH:
             if (m_baseIsStart) {
-                assignStart(base().startParagraphBoundary());
-                assignEnd(extent().endParagraphBoundary(IncludeLineBreak));
+                assignStart(base().startParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(DOWNSTREAM));
+                assignEnd(extent().endParagraphBoundary(IncludeLineBreak).equivalentDeepPosition().closestRenderedPosition(UPSTREAM));
             } else {
-                assignStart(extent().startParagraphBoundary());
-                assignEnd(base().endParagraphBoundary(IncludeLineBreak));
+                assignStart(extent().startParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(DOWNSTREAM));
+                assignEnd(base().endParagraphBoundary(IncludeLineBreak).equivalentDeepPosition().closestRenderedPosition(UPSTREAM));
             }
             break;
         case DOCUMENT: {
@@ -713,11 +713,11 @@ void Selection::validate(ETextGranularity granularity)
         }
         case PARAGRAPH_BOUNDARY:
             if (m_baseIsStart) {
-                assignStart(base().startParagraphBoundary());
-                assignEnd(extent().endParagraphBoundary());
+                assignStart(base().startParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(DOWNSTREAM));
+                assignEnd(extent().endParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(UPSTREAM));
             } else {
-                assignStart(extent().startParagraphBoundary());
-                assignEnd(base().endParagraphBoundary());
+                assignStart(extent().startParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(DOWNSTREAM));
+                assignEnd(base().endParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(UPSTREAM));
             }
             break;
     }
index 4732debdfc5b503f0bb5491c37ace44be6906acd..39d0646d78ed821470fd172d6241ae368eef6f6f 100644 (file)
@@ -2330,6 +2330,16 @@ const Selection &KHTMLPart::dragCaret() const
     return d->m_dragCaret;
 }
 
+const Selection &KHTMLPart::mark() const
+{
+    return d->m_mark;
+}
+
+void KHTMLPart::setMark(const Selection &s)
+{
+    d->m_mark = s;
+}
+
 void KHTMLPart::setSelection(const Selection &s, bool closeTyping)
 {
     if (d->m_selection != s) {
index 0789424b7ed959f01356125b9d0c0dd42531986c..7e7f43f995583259d97bad43cd90a660e2ed0402 100644 (file)
@@ -569,7 +569,7 @@ public:
    */
   int zoomFactor() const;
 
-/**
+  /**
    * Returns the text the user has marked.
    */
   virtual QString selectedText() const;
@@ -590,7 +590,17 @@ public:
   void setSelection(const DOM::Selection &, bool closeTyping=true);
 
   /**
-      * Sets the current drag cart.
+   * Returns a mark, to be used as emacs uses it.
+   */
+  const DOM::Selection &mark() const;
+
+  /**
+   * Returns the mark.
+   */
+  void setMark(const DOM::Selection &);
+
+  /**
+   * Sets the current drag cart.
    */
   void setDragCaret(const DOM::Selection &);
   
index 261f7ed4c234b6a266c118438f181727fb6ed421..efd70c75de5466da3df56ec113c31e8fb9cc46c7 100644 (file)
@@ -359,6 +359,7 @@ public:
 
   DOM::Selection m_selection;
   DOM::Selection m_dragCaret;
+  DOM::Selection m_mark;
   int m_caretBlinkTimer;
 
   bool m_caretVisible:1;
index c6adea535676701e66349f5cfa3d53e45f2034d6..a978f691ac7e8563e6d02a7c42ed5d269a033d1f 100644 (file)
@@ -801,7 +801,7 @@ void RenderText::paint(PaintInfo& i, int tx, int ty)
         return;
     }
 
-    Range markedTextRange = KWQ(document()->part())->markedRange();
+    Range markedTextRange = KWQ(document()->part())->markedTextRange();
     bool haveMarkedText = markedTextRange.handle() != 0 && markedTextRange.startContainer() == node();
 
     if ((haveSelection || haveMarkedText) && i.phase != PaintActionSelection && !isPrinting) {
index d5df5f7bc9dabd1ac1154e1b6b9b270acfdccb20..fac1b41c9a17eaa4489335bc2e058f82603854ad 100644 (file)
@@ -1700,9 +1700,11 @@ void NodeBaseImpl::removeChildren()
     while (NodeImpl *n = _first) {
         NodeImpl *next = n->nextSibling();
         
+        n->ref();
+
         // Fire removed from document mutation events.
         dispatchChildRemovalEvents(n, exceptionCode);
-    
+
         if (n->attached())
            n->detach();
         n->setPreviousSibling(0);
@@ -1711,8 +1713,9 @@ void NodeBaseImpl::removeChildren()
         
         if (n->inDocument())
             n->removedFromDocument();
-        if (!n->refCount())
-            delete n;
+
+        n->deref();
+
         _first = next;
     }
     _last = 0;
index b25200e7900154e4c11b4fa76322a40b33d43abe..2552884316cce8585a4c5e24a7529ad94b1d1cb8 100644 (file)
@@ -698,11 +698,11 @@ void Selection::validate(ETextGranularity granularity)
         }
         case PARAGRAPH:
             if (m_baseIsStart) {
-                assignStart(base().startParagraphBoundary());
-                assignEnd(extent().endParagraphBoundary(IncludeLineBreak));
+                assignStart(base().startParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(DOWNSTREAM));
+                assignEnd(extent().endParagraphBoundary(IncludeLineBreak).equivalentDeepPosition().closestRenderedPosition(UPSTREAM));
             } else {
-                assignStart(extent().startParagraphBoundary());
-                assignEnd(base().endParagraphBoundary(IncludeLineBreak));
+                assignStart(extent().startParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(DOWNSTREAM));
+                assignEnd(base().endParagraphBoundary(IncludeLineBreak).equivalentDeepPosition().closestRenderedPosition(UPSTREAM));
             }
             break;
         case DOCUMENT: {
@@ -713,11 +713,11 @@ void Selection::validate(ETextGranularity granularity)
         }
         case PARAGRAPH_BOUNDARY:
             if (m_baseIsStart) {
-                assignStart(base().startParagraphBoundary());
-                assignEnd(extent().endParagraphBoundary());
+                assignStart(base().startParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(DOWNSTREAM));
+                assignEnd(extent().endParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(UPSTREAM));
             } else {
-                assignStart(extent().startParagraphBoundary());
-                assignEnd(base().endParagraphBoundary());
+                assignStart(extent().startParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(DOWNSTREAM));
+                assignEnd(base().endParagraphBoundary().equivalentDeepPosition().closestRenderedPosition(UPSTREAM));
             }
             break;
     }
index 5664236c43e9faf79f9f00ad99ccd7dc5e9ba54a..4887f71f4c584366e51897b0cbb55a1fcfddc7dd 100644 (file)
@@ -334,8 +334,8 @@ public:
     // Implementation of CSS property -khtml-user-drag == auto
     bool shouldDragAutoNode(DOM::NodeImpl*, int x, int y) const;
 
-    DOM::Range markedRange() const;
-    void setMarkedRange(const DOM::Range &);
+    DOM::Range markedTextRange() const;
+    void setMarkedTextRange(const DOM::Range &);
 
     bool canGoBackOrForward(int distance) const;
 
@@ -422,7 +422,7 @@ private:
     
     mutable DOM::Node _elementToDraw;
 
-    DOM::Range m_markedRange;
+    DOM::Range m_markedTextRange;
 };
 
 inline KWQKHTMLPart *KWQ(KHTMLPart *part) { return static_cast<KWQKHTMLPart *>(part); }
index 804a836f93bedc1939227685d64c21a4d754fa77..e1e6a5517d376da774108bcd519627e9ccca0461 100644 (file)
@@ -3554,7 +3554,7 @@ bool KWQKHTMLPart::haveToldBridgeAboutLoad(const QString &urlString)
 void KWQKHTMLPart::clear()
 {
     urlsBridgeKnowsAbout.clear();
-    setMarkedRange(0);
+    setMarkedTextRange(0);
     KHTMLPart::clear();
 }
 
@@ -3895,26 +3895,26 @@ bool KWQKHTMLPart::shouldEndEditing(const Range &range) const
     return [_bridge shouldEndEditing:[DOMRange _rangeWithImpl:range.handle()]];
 }
 
-DOM::Range KWQKHTMLPart::markedRange() const
+DOM::Range KWQKHTMLPart::markedTextRange() const
 {
-    return m_markedRange;
+    return m_markedTextRange;
 }
 
-void KWQKHTMLPart::setMarkedRange(const DOM::Range &range)
+void KWQKHTMLPart::setMarkedTextRange(const DOM::Range &range)
 {
     ASSERT(!range.handle() || range.startContainer() == range.endContainer());
     ASSERT(!range.handle() || range.startOffset() == range.endOffset() || range.startContainer().nodeType() == Node::TEXT_NODE);
 
-    if (m_markedRange.handle() && xmlDocImpl() 
-       && m_markedRange.startContainer().handle()->renderer()) {
-       m_markedRange.startContainer().handle()->renderer()->repaint();
+    if (m_markedTextRange.handle() && xmlDocImpl() 
+       && m_markedTextRange.startContainer().handle()->renderer()) {
+       m_markedTextRange.startContainer().handle()->renderer()->repaint();
     }
 
-    m_markedRange = range;
+    m_markedTextRange = range;
 
-    if (m_markedRange.handle() && xmlDocImpl() 
-       && m_markedRange.startContainer().handle()->renderer()) {
-       m_markedRange.startContainer().handle()->renderer()->repaint();
+    if (m_markedTextRange.handle() && xmlDocImpl() 
+       && m_markedTextRange.startContainer().handle()->renderer()) {
+       m_markedTextRange.startContainer().handle()->renderer()->repaint();
     }
 }
 
index 26cc46318900653f587937b04c0b0c8e27e22135..2109b3ab935d00503ea396ee3ed6d376c79993c8 100644 (file)
@@ -236,8 +236,6 @@ typedef enum {
 - (DOMDocument *)DOMDocument;
 - (DOMHTMLElement *)frameElement;
 
-- (void)setSelectionFrom:(DOMNode *)start startOffset:(int)startOffset to:(DOMNode *)end endOffset:(int) endOffset;
-
 - (BOOL)isSelectionEditable;
 - (WebSelectionState)selectionState;
 
@@ -260,17 +258,17 @@ typedef enum {
 - (NSImage *)selectionImage;
 - (NSRect)caretRectAtNode:(DOMNode *)node offset:(int)offset;
 
-- (DOMNode *)selectionStart;
-- (int)selectionStartOffset;
-- (DOMNode *)selectionEnd;
-- (int)selectionEndOffset;
 - (void)setSelectedDOMRange:(DOMRange *)range affinity:(NSSelectionAffinity)selectionAffinity;
 - (DOMRange *)selectedDOMRange;
 - (NSSelectionAffinity)selectionAffinity;
 
-- (void)setMarkedDOMRange:(DOMRange *)range;
-- (DOMRange *)markedDOMRange;
-- (void)clearMarkedDOMRange;
+// Emacs-style-editing "mark"
+- (void)setMarkDOMRange:(DOMRange *)range;
+- (DOMRange *)markDOMRange;
+
+// spelling-checking "marked text"
+- (void)setMarkedTextDOMRange:(DOMRange *)range;
+- (DOMRange *)markedTextDOMRange;
 
 - (NSAttributedString *)attributedStringFrom:(DOMNode *)startNode startOffset:(int)startOffset to:(DOMNode *)endNode endOffset:(int)endOffset;
 
index 14a9b845153f46cb8e0535a7d423598abae30c8a..1c972e7495035b6966cfb6165cdeb26d525edaa1 100644 (file)
@@ -1151,13 +1151,6 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
     return (DOMHTMLElement *)[[self DOMDocument] _ownerElement];
 }
 
-- (void)setSelectionFrom:(DOMNode *)start startOffset:(int)startOffset to:(DOMNode *)end endOffset:(int) endOffset
-{
-    Position s([start _nodeImpl], startOffset);
-    Position e([end _nodeImpl], endOffset);
-    _part->setSelection(Selection(s, e));
-}
-
 - (NSAttributedString *)selectedAttributedString
 {
     return _part->attributedString(_part->selectionStart(), _part->selectionStartOffset(), _part->selectionEnd(), _part->selectionEndOffset());
@@ -1170,26 +1163,6 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
     return _part->attributedString([startNode _nodeImpl], startOffset, [endNode _nodeImpl], endOffset);
 }
 
-- (DOMNode *)selectionStart
-{
-    return [DOMNode _nodeWithImpl:_part->selectionStart()];
-}
-
-- (int)selectionStartOffset
-{
-    return _part->selectionStartOffset();
-}
-
-- (DOMNode *)selectionEnd
-{
-    return [DOMNode _nodeWithImpl:_part->selectionEnd()];
-}
-
-- (int)selectionEndOffset
-{
-    return _part->selectionEndOffset();
-}
-
 - (NSRect)selectionRect
 {
     return _part->selectionRect(); 
@@ -1437,20 +1410,24 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
     return static_cast<NSSelectionAffinity>(_part->selection().affinity());
 }
 
-- (void)setMarkedDOMRange:(DOMRange *)range
+- (void)setMarkDOMRange:(DOMRange *)range
+{
+    _part->setMark(Selection([range _rangeImpl]));
+}
+
+- (DOMRange *)markDOMRange
 {
-    _part->setMarkedRange([range _rangeImpl]);
+    return [DOMRange _rangeWithImpl:_part->mark().toRange().handle()];
 }
 
-- (DOMRange *)markedDOMRange
+- (void)setMarkedTextDOMRange:(DOMRange *)range
 {
-    DOM::RangeImpl *range = _part->markedRange().handle();
-    return range ? [DOMRange _rangeWithImpl:range] : nil;
+    _part->setMarkedTextRange([range _rangeImpl]);
 }
 
-- (void)clearMarkedDOMRange
+- (DOMRange *)markedTextDOMRange
 {
-    _part->setMarkedRange(Range(0));
+    return [DOMRange _rangeWithImpl:_part->markedTextRange().handle()];
 }
 
 - (DOMDocumentFragment *)documentFragmentWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString 
index 6b176521d9a4bb3ff606a5c7599434789a47f0e4..25935d3f31b16dbd69e7272370fda6df46c371d7 100644 (file)
@@ -1,3 +1,35 @@
+2004-09-09  Darin Adler  <darin@apple.com>
+
+        Reviewed by Ken.
+
+        - fixed <rdar://problem/3790526> mark-related methods not implemented (needed for people with them in their key bindings files)
+
+        * WebKit.pbproj/project.pbxproj: Update MACOSX_DEPLOYMENT_TARGET to 10.3 and add -fobjc-exceptions
+        so we can use new exceptions.
+
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView setMark:]): Added.
+        (unionDOMRanges): Added.
+        (-[WebHTMLView deleteToMark:]): Added.
+        (-[WebHTMLView selectToMark:]): Added.
+        (-[WebHTMLView swapWithMark:]): Added.
+        (-[WebHTMLView markedRange]): Updated for change to bridge method names.
+        (-[WebHTMLView hasMarkedText]): Ditto.
+        (-[WebHTMLView unmarkText]): Ditto.
+        (-[WebHTMLView _selectMarkedText]): Ditto.
+        (-[WebHTMLView _selectRangeInMarkedText:]): Ditto.
+        (-[WebHTMLView setMarkedText:selectedRange:]): Ditto.
+        (-[WebHTMLView _insertText:selectInsertedText:]): Removed check for empty string. An empty string
+        should not be filtered out here. We need to allow inserting an empty string.
+        (-[WebHTMLView _selectionIsInsideMarkedText]): Updated for change to bridge method names.
+        (-[WebHTMLView _updateSelectionForInputManager]): Ditto.
+
+        * WebView.subproj/WebView.m: (-[WebView searchFor:direction:caseSensitive:wrap:]):
+        Changed to use selectionDOMRange instead of selectionStart.
+
+        * WebView.subproj/WebHTMLRepresentation.h: Removed unused setSelectionFrom method.
+        * WebView.subproj/WebHTMLRepresentation.m: Ditto.
+
 2004-09-08  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Darin.
index 1abd7d80060c301711ce98f93ab61de5d720ae0f..b190efb6654c4e7fe62fc88edd77d86d71c51639 100644 (file)
                                INSTALL_PATH = /System/Library/Frameworks;
                                LIBRARY_SEARCH_PATHS = "";
                                LOCAL_SEG1_ADDR = 0x7000000;
-                               MACOSX_DEPLOYMENT_TARGET = 10.2;
+                               MACOSX_DEPLOYMENT_TARGET = 10.3;
                                OPTIMIZATION_CFLAGS = "-Os";
-                               OTHER_CFLAGS = "$(DEBUG_CFLAGS) -DFRAMEWORK_NAME=WebKit";
+                               OTHER_CFLAGS = "$(DEBUG_CFLAGS) -DFRAMEWORK_NAME=WebKit -fobjc-exceptions";
                                OTHER_LDFLAGS = "$(COMMON_LDFLAGS) -sub_umbrella WebCore -sub_umbrella JavaScriptCore";
                                PRECOMPILE_PREFIX_HEADER = YES;
                                PREFIX_HEADER = WebKitPrefix.h;
index 081cd9f42b2736ac40c929509fb8f9268b34184a..1464c59a084e21e4285fb73cab85196ee153f1fc 100644 (file)
     WebHTMLRepresentationPrivate *_private;
 }
 
-/*!
-    @method setSelectionFrom:startOffset:to:endOffset
-    @abstract Set the text selection in the document.
-    @param start The node that include the starting selection point.
-    @param startOffset The character offset into the text of the starting node.
-    @param end The node that includes the ending selection point.
-    @param endOffset The character offset into the text of the ending node.
-*/
-- (void)setSelectionFrom:(DOMNode *)start startOffset:(int)startOffset to:(DOMNode *)end endOffset:(int)endOffset;
-
 - (NSAttributedString *)attributedStringFrom:(DOMNode *)startNode startOffset:(int)startOffset to:(DOMNode *)endNode endOffset:(int)endOffset;
 
 - (DOMElement *)elementWithName:(NSString *)name inForm:(DOMElement *)form;
index baa4461b8b9392557974b7cdb2e11540d1e9210d..c29f7c14b00bce03ee4eac10c1844f3af67f93ec 100644 (file)
     return [_private->bridge DOMDocument];
 }
 
-- (void)setSelectionFrom:(DOMNode *)start startOffset:(int)startOffset to:(DOMNode *)end endOffset:(int) endOffset
-{
-}
-
 - (NSAttributedString *)attributedText
 {
     // FIXME:  Implement
index 7516f3f44e92629f0d74cc724f7bb447a3dc6f5b..7196e09e7f51fe0a855254fa591d353c85f39e79 100644 (file)
@@ -3552,6 +3552,75 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
     _NSSetKillRingToYankedState();
 }
 
+- (void)setMark:(id)sender
+{
+    [[self _bridge] setMarkDOMRange:[self _selectedRange]];
+}
+
+static DOMRange *unionDOMRanges(DOMRange *a, DOMRange *b)
+{
+    ASSERT(a);
+    ASSERT(b);
+    DOMRange *s = [a compareBoundaryPoints:DOM_START_TO_START :b] <= 0 ? a : b;
+    DOMRange *e = [a compareBoundaryPoints:DOM_END_TO_END :b] <= 0 ? b : a;
+    DOMRange *r = [[[a startContainer] ownerDocument] createRange];
+    [r setStart:[s startContainer] :[s startOffset]];
+    [r setEnd:[e endContainer] :[e endOffset]];
+    return r;
+}
+
+- (void)deleteToMark:(id)sender
+{
+    DOMRange *mark = [[self _bridge] markDOMRange];
+    if (mark == nil) {
+        [self delete:sender];
+    } else {
+        DOMRange *selection = [self _selectedRange];
+        DOMRange *r;
+        @try {
+            r = unionDOMRanges(mark, selection);
+        } @catch (NSException *exception) {
+            r = selection;
+        }
+        [self _deleteRange:r preflight:YES killRing:YES prepend:YES];
+    }
+    [self setMark:sender];
+}
+
+- (void)selectToMark:(id)sender
+{
+    WebBridge *bridge = [self _bridge];
+    DOMRange *mark = [bridge markDOMRange];
+    if (mark == nil) {
+        NSBeep();
+        return;
+    }
+    DOMRange *selection = [self _selectedRange];
+    @try {
+        [bridge setSelectedDOMRange:unionDOMRanges(mark, selection) affinity:NSSelectionAffinityUpstream];
+    } @catch (NSException *exception) {
+        NSBeep();
+    }
+}
+
+- (void)swapWithMark:(id)sender
+{
+    WebBridge *bridge = [self _bridge];
+    DOMRange *mark = [bridge markDOMRange];
+    if (mark == nil) {
+        NSBeep();
+        return;
+    }
+    DOMRange *selection = [self _selectedRange];
+    @try {
+        [bridge setSelectedDOMRange:mark affinity:NSSelectionAffinityUpstream];
+    } @catch (NSException *exception) {
+        NSBeep();
+        return;
+    }
+    [bridge setMarkDOMRange:selection];
+}
+
 #if 0
 
 // CSS does not have a way to specify an outline font, which may make this difficult to implement.
@@ -3578,14 +3647,6 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
 
 // === key binding methods that NSTextView has that don't have standard key bindings
 
-// Implementing these four requires implementing a mark.
-// We can't just keep a DOM range on the WebKit side because the mark needs
-// to stay in the document as the document is edited.
-- (void)setMark:(id)sender;
-- (void)deleteToMark:(id)sender;
-- (void)selectToMark:(id)sender;
-- (void)swapWithMark:(id)sender;
-
 // These could be important.
 - (void)toggleBaseWritingDirection:(id)sender;
 - (void)toggleTraditionalCharacterShape:(id)sender;
@@ -3789,10 +3850,10 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
        return NSMakeRange(NSNotFound,0);
     }
 
-    DOMRange *markedDOMRange = [[self _bridge] markedDOMRange];
+    DOMRange *markedTextDOMRange = [[self _bridge] markedTextDOMRange];
 
-    unsigned rangeLocation = [markedDOMRange startOffset];
-    unsigned rangeLength = [markedDOMRange endOffset] - rangeLocation;
+    unsigned rangeLocation = [markedTextDOMRange startOffset];
+    unsigned rangeLength = [markedTextDOMRange endOffset] - rangeLocation;
 
     return NSMakeRange(rangeLocation, rangeLength);
 }
@@ -3810,19 +3871,19 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
 
 - (BOOL)hasMarkedText
 {
-    return [[self _bridge] markedDOMRange] != nil;
+    return [[self _bridge] markedTextDOMRange] != nil;
 }
 
 - (void)unmarkText
 {
-    [[self _bridge] clearMarkedDOMRange];
+    [[self _bridge] setMarkedTextDOMRange:nil];
 }
 
 - (void)_selectMarkedText
 {
     if ([self hasMarkedText]) {
        WebBridge *bridge = [self _bridge];
-       DOMRange *markedTextRange = [bridge markedDOMRange];
+       DOMRange *markedTextRange = [bridge markedTextDOMRange];
        [bridge setSelectedDOMRange:markedTextRange affinity:NSSelectionAffinityUpstream];
     }
 }
@@ -3833,15 +3894,15 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
 
     WebBridge *bridge = [self _bridge];
     DOMRange *selectedRange = [[bridge DOMDocument] createRange];
-    DOMRange *markedRange = [bridge markedDOMRange];
+    DOMRange *markedTextRange = [bridge markedTextDOMRange];
     
-    ASSERT([markedRange startContainer] == [markedRange endContainer]);
+    ASSERT([markedTextRange startContainer] == [markedTextRange endContainer]);
 
-    unsigned selectionStart = [markedRange startOffset] + range.location;
+    unsigned selectionStart = [markedTextRange startOffset] + range.location;
     unsigned selectionEnd = selectionStart + range.length;
 
-    [selectedRange setStart:[markedRange startContainer] :selectionStart];
-    [selectedRange setEnd:[markedRange startContainer] :selectionEnd];
+    [selectedRange setStart:[markedTextRange startContainer] :selectionStart];
+    [selectedRange setEnd:[markedTextRange startContainer] :selectionEnd];
 
     [bridge setSelectedDOMRange:selectedRange affinity:NSSelectionAffinityUpstream];
 }
@@ -3868,7 +3929,7 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
     }
 
     [bridge replaceSelectionWithText:text selectReplacement:YES];
-    [bridge setMarkedDOMRange:[self _selectedRange]];
+    [bridge setMarkedTextDOMRange:[self _selectedRange]];
     [self _selectRangeInMarkedText:newSelRange];
 
     _private->ignoreMarkedTextSelectionChange = NO;
@@ -3896,7 +3957,7 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
 
 - (void)_insertText:(NSString *)text selectInsertedText:(BOOL)selectText
 {
-    if (text == nil || [text length] == 0) {
+    if (text == nil) {
         return;
     }
 
@@ -3940,20 +4001,20 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
 {
     WebBridge *bridge = [self _bridge];
     DOMRange *selection = [self _selectedRange];
-    DOMRange *markedRange = [bridge markedDOMRange];
+    DOMRange *markedTextRange = [bridge markedTextDOMRange];
 
-    ASSERT([markedRange startContainer] == [markedRange endContainer]);
+    ASSERT([markedTextRange startContainer] == [markedTextRange endContainer]);
 
-    if ([selection startContainer] != [markedRange startContainer]) 
+    if ([selection startContainer] != [markedTextRange startContainer]) 
        return NO;
 
-    if ([selection endContainer] != [markedRange startContainer])
+    if ([selection endContainer] != [markedTextRange startContainer])
        return NO;
 
-    if ([selection startOffset] < [markedRange startOffset])
+    if ([selection startOffset] < [markedTextRange startOffset])
        return NO;
 
-    if ([selection endOffset] > [markedRange endOffset])
+    if ([selection endOffset] > [markedTextRange endOffset])
        return NO;
 
     return YES;
@@ -3966,9 +4027,9 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
 
     if ([self _selectionIsInsideMarkedText]) {
        DOMRange *selection = [self _selectedRange];
-       DOMRange *markedDOMRange = [[self _bridge] markedDOMRange];
+       DOMRange *markedTextDOMRange = [[self _bridge] markedTextDOMRange];
 
-       unsigned markedSelectionStart = [selection startOffset] - [markedDOMRange startOffset];
+       unsigned markedSelectionStart = [selection startOffset] - [markedTextDOMRange startOffset];
        unsigned markedSelectionLength = [selection endOffset] - [selection startOffset];
        NSRange newSelectionRange = NSMakeRange(markedSelectionStart, markedSelectionLength);
        
index aa2ae08a7ec4746a4a45a0e3e5d482b72070b445..4958339779e682bc008f18a4f9c851a238b0b861 100644 (file)
@@ -1905,7 +1905,7 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
                 // Remember if start even has a selection, to know if we need to search more later
                 if ([searchView isKindOfClass:[WebHTMLView class]]) {
                     // optimization for the common case, to avoid making giant string for selection
-                    startHasSelection = [[startFrame _bridge] selectionStart] != nil;
+                    startHasSelection = [[startFrame _bridge] selectedDOMRange] != nil;
                 } else if ([searchView conformsToProtocol:@protocol(WebDocumentText)]) {
                     startHasSelection = [(id <WebDocumentText>)searchView selectedString] != nil;
                 }