WebCore:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Aug 2004 18:09:44 +0000 (18:09 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Aug 2004 18:09:44 +0000 (18:09 +0000)
        Reviewed by Ken.

        - fixed <rdar://problem/3740937> ER: A way to turn a DOMRange into text (equivalent of -innerText)

        * khtml/xml/dom2_rangeimpl.h: Added text function. Like innerText, but on a range.
        * khtml/xml/dom2_rangeimpl.cpp: (DOM::RangeImpl::text): Added.

        * kwq/DOM.mm: (-[DOMRange _text]): Added. Calls DOM::RangeImpl::text.
        * kwq/DOMPrivate.h: Added.

        * WebCore.pbproj/project.pbxproj: Added DOMPrivate.h, an internal header (private in WebKit, internal here).

WebKit:

        Reviewed by Ken.

        - fixed <rdar://problem/3740937> ER: A way to turn a DOMRange into text (equivalent of -innerText)

        * DOM.subproj/DOMPrivate.h: Added.
        * WebKit.pbproj/project.pbxproj: Added DOMPrivate.h.
        * copy-webcore-files-to-webkit: Added DOMPrivate.h.

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

WebCore/ChangeLog-2005-08-23
WebCore/WebCore.pbproj/project.pbxproj
WebCore/khtml/xml/dom2_rangeimpl.cpp
WebCore/khtml/xml/dom2_rangeimpl.h
WebCore/kwq/DOM.mm
WebCore/kwq/DOMPrivate.h [new file with mode: 0644]
WebKit/ChangeLog
WebKit/DOM.subproj/DOMPrivate.h [new file with mode: 0644]
WebKit/WebKit.pbproj/project.pbxproj
WebKit/copy-webcore-files-to-webkit

index 3f0f868..90e2ab3 100644 (file)
@@ -1,3 +1,17 @@
+2004-08-03  Darin Adler  <darin@apple.com>
+
+        Reviewed by Ken.
+
+        - fixed <rdar://problem/3740937> ER: A way to turn a DOMRange into text (equivalent of -innerText)
+
+        * khtml/xml/dom2_rangeimpl.h: Added text function. Like innerText, but on a range.
+        * khtml/xml/dom2_rangeimpl.cpp: (DOM::RangeImpl::text): Added.
+
+        * kwq/DOM.mm: (-[DOMRange _text]): Added. Calls DOM::RangeImpl::text.
+        * kwq/DOMPrivate.h: Added.
+
+        * WebCore.pbproj/project.pbxproj: Added DOMPrivate.h, an internal header (private in WebKit, internal here).
+
 2004-08-02  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Darin.
index 32c5f03..7b9931c 100644 (file)
                                BE02F484066E1C550013A9F6,
                                BE02D4E8066F908A0076809F,
                                93D1FEF7067EBF89009CE68A,
+                               9348900606C00363007E7ACE,
                        );
                        isa = PBXHeadersBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                        settings = {
                        };
                };
+               9348900506C00363007E7ACE = {
+                       fileEncoding = 30;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
+                       path = DOMPrivate.h;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               9348900606C00363007E7ACE = {
+                       fileRef = 9348900506C00363007E7ACE;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
                934E43780414294A008635CE = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
                                832556E6061DF161007B8054,
                                BE94EB6405EFFE6B0032DCB5,
                                BE9CB64D05F942CB00514D9C,
+                               9348900506C00363007E7ACE,
                                9321274F0606724900B62302,
                                932127510606724900B62302,
                                932127530606724900B62302,
index d186dc7..6fe3c32 100644 (file)
@@ -29,6 +29,7 @@
 #include "dom_textimpl.h"
 #include "dom_xmlimpl.h"
 #include "html/html_elementimpl.h"
+#include "misc/khtml_text_operations.h"
 
 #include "render_block.h"
 
@@ -865,6 +866,19 @@ DOMString RangeImpl::toHTML(  )
     return toHTMLWithOptions();
 }
 
+DOMString RangeImpl::text() const
+{
+    if (m_detached)
+        return DOMString();
+
+    // We need to update layout, since plainText uses line boxes in the render tree.
+    // FIXME: As with innerText, we'd like this to work even if there are no render objects.
+    m_startContainer->getDocument()->updateLayout();
+
+    // FIXME: Maybe DOMRange constructor take const DOMRangeImpl*; if it did we would not need this const_cast.
+    return plainText(const_cast<RangeImpl *>(this));
+}
+
 DocumentFragmentImpl *RangeImpl::createContextualFragment ( DOMString &html, int &exceptioncode )
 {
    if (m_detached) {
index 5709e0b..209864f 100644 (file)
@@ -69,6 +69,7 @@ public:
     DOMString toString ( int &exceptioncode );
     DOMString toHTML (  );
     DOMString toHTMLWithOptions(QPtrList<NodeImpl> *nodes=NULL);
+    DOMString text() const;
 
     DocumentFragmentImpl *createContextualFragment ( DOMString &html, int &exceptioncode );
     
index 3f2e21d..ba632a5 100644 (file)
 
 #include <objc/objc-class.h>
 
-#import <dom/dom_doc.h>
-#import <dom/dom_element.h>
-#import <dom/dom_exception.h>
-#import <dom/dom_node.h>
-#import <dom/dom_string.h>
-#import <dom/dom_text.h>
-#import <dom/dom_xml.h>
-#import <dom/dom2_range.h>
-#import <dom/dom2_traversal.h>
-#import <html/html_elementimpl.h>
-#import <misc/htmltags.h>
-#import <xml/dom_docimpl.h>
-#import <xml/dom_elementimpl.h>
-#import <xml/dom_nodeimpl.h>
-#import <xml/dom_stringimpl.h>
-#import <xml/dom_textimpl.h>
-#import <xml/dom_xmlimpl.h>
-#import <xml/dom2_rangeimpl.h>
-#import <xml/dom2_viewsimpl.h>
-
 #import <JavaScriptCore/WebScriptObjectPrivate.h>
 
+#import "dom2_range.h"
+#import "dom2_rangeimpl.h"
+#import "dom2_traversal.h"
+#import "dom2_viewsimpl.h"
+#import "dom_doc.h"
+#import "dom_docimpl.h"
+#import "dom_element.h"
+#import "dom_elementimpl.h"
+#import "dom_exception.h"
+#import "dom_node.h"
+#import "dom_nodeimpl.h"
+#import "dom_string.h"
+#import "dom_stringimpl.h"
+#import "dom_text.h"
+#import "dom_textimpl.h"
+#import "dom_xml.h"
+#import "dom_xmlimpl.h"
+#import "html_elementimpl.h"
+#import "htmltags.h"
+
 #import "DOMEventsInternal.h"
 #import "DOMHTML.h"
 #import "DOMInternal.h"
+#import "DOMPrivate.h"
 #import "KWQAssertions.h"
 #import "KWQFoundationExtras.h"
 
@@ -1919,6 +1920,15 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
 
 @end
 
+@implementation DOMRange (WebPrivate)
+
+- (NSString *)_text
+{
+    return [self _rangeImpl]->text().string().getNSString();
+}
+
+@end
+
 //------------------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------------------
diff --git a/WebCore/kwq/DOMPrivate.h b/WebCore/kwq/DOMPrivate.h
new file mode 100644 (file)
index 0000000..8889fd3
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import <WebCore/DOMRange.h>
+
+@interface DOMRange (WebPrivate)
+- (NSString *)_text; // uses same algorithm as innerText
+@end
index 16b076c..b44e641 100644 (file)
@@ -1,3 +1,13 @@
+2004-08-03  Darin Adler  <darin@apple.com>
+
+        Reviewed by Ken.
+
+        - fixed <rdar://problem/3740937> ER: A way to turn a DOMRange into text (equivalent of -innerText)
+
+        * DOM.subproj/DOMPrivate.h: Added.
+        * WebKit.pbproj/project.pbxproj: Added DOMPrivate.h.
+        * copy-webcore-files-to-webkit: Added DOMPrivate.h.
+
 2004-08-02  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Darin.
diff --git a/WebKit/DOM.subproj/DOMPrivate.h b/WebKit/DOM.subproj/DOMPrivate.h
new file mode 100644 (file)
index 0000000..a27d4f7
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import <WebKit/DOMRange.h>
+
+@interface DOMRange (WebPrivate)
+- (NSString *)_text; // uses same algorithm as innerText
+@end
index 6221e6a..7100ea9 100644 (file)
                                51863EFD065419EB00E9E8DD,
                                93185DB606679F42005D5E7E,
                                93D1FE14067EB10B009CE68A,
+                               9348903806C0040B007E7ACE,
                        );
                        isa = PBXHeadersBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                        settings = {
                        };
                };
+               9348903706C0040B007E7ACE = {
+                       fileEncoding = 4;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
+                       name = DOMPrivate.h;
+                       path = DOM.subproj/DOMPrivate.h;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               9348903806C0040B007E7ACE = {
+                       fileRef = 9348903706C0040B007E7ACE;
+                       isa = PBXBuildFile;
+                       settings = {
+                               ATTRIBUTES = (
+                                       Private,
+                               );
+                       };
+               };
                93AEB17D032C1735008635CE = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
                                9321290006068E3100B62302,
                                8325571F061DF71E007B8054,
                                9321290106068E3100B62302,
+                               9348903706C0040B007E7ACE,
                                9321290206068E3100B62302,
                                9321290306068E3100B62302,
                                9321290406068E3100B62302,
index 73dbc26..ae35be9 100755 (executable)
@@ -8,16 +8,17 @@ my $ProgramName = 'copy-webcore-files-to-webkit';
 
 my %WebCoreFiles = (
     'kwq/DOM.h' => 'DOM.subproj/DOM.h',
+    'kwq/DOM-compat.h' => 'DOM.subproj/DOM-compat.h',
+    'kwq/DOMCSS.h' => 'DOM.subproj/DOMCSS.h',
     'kwq/DOMCore.h' => 'DOM.subproj/DOMCore.h',
-    'kwq/DOMViews.h' => 'DOM.subproj/DOMViews.h',
     'kwq/DOMEvents.h' => 'DOM.subproj/DOMEvents.h',
+    'kwq/DOMExtensions.h' => 'DOM.subproj/DOMExtensions.h',
+    'kwq/DOMHTML.h' => 'DOM.subproj/DOMHTML.h',
+    'kwq/DOMPrivate.h' => 'DOM.subproj/DOMPrivate.h',
+    'kwq/DOMRange.h' => 'DOM.subproj/DOMRange.h',
     'kwq/DOMStylesheets.h' => 'DOM.subproj/DOMStylesheets.h',
-    'kwq/DOMCSS.h' => 'DOM.subproj/DOMCSS.h',
     'kwq/DOMTraversal.h' => 'DOM.subproj/DOMTraversal.h',
-    'kwq/DOMRange.h' => 'DOM.subproj/DOMRange.h',
-    'kwq/DOMHTML.h' => 'DOM.subproj/DOMHTML.h',
-    'kwq/DOM-compat.h' => 'DOM.subproj/DOM-compat.h',
-    'kwq/DOMExtensions.h' => 'DOM.subproj/DOMExtensions.h',
+    'kwq/DOMViews.h' => 'DOM.subproj/DOMViews.h',
 );
 
 my %JavaScriptCoreFiles = (