Reviewed by Darin.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Apr 2004 00:08:34 +0000 (00:08 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Apr 2004 00:08:34 +0000 (00:08 +0000)
<rdar://problem/3628309>: Fedex tracking page so slow it seems like a hang (site change?)
<rdar://problem/3608061>: "ATI Developer site so slow it seems like a hang"
<rdar://problem/3612130>: "Reproducible hang in JavaScript at www.tfl.gov.uk"
<rdar://problem/3626022>: "Safari was consuming > 100% CPU on dual-G5 Mac, sample shows JavaScript"
<rdar://problem/3632348>: "www.whatis.com search for "pivot table" leads to JavaScript hang"

        * khtml/ecma/kjs_html.cpp:
        (KJS::HTMLElement::getValueProperty): The "text" property for anchors should be
innerText, not innerHTML.
        * khtml/html/html_elementimpl.cpp:
        (HTMLElementImpl::innerText): Make sure not to include all the text after an
element if it has no children.
        * layout-tests/fast/dom/anchor-text-expected.txt: Added.
        * layout-tests/fast/dom/anchor-text.html: Added.
        * layout-tests/fast/dom/inner-text-expected.txt: Added.
        * layout-tests/fast/dom/inner-text.html: Added.

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

LayoutTests/fast/dom/anchor-text-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/anchor-text.html [new file with mode: 0644]
LayoutTests/fast/dom/inner-text-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/inner-text.html [new file with mode: 0644]
WebCore/ChangeLog-2005-08-23
WebCore/khtml/ecma/kjs_html.cpp
WebCore/khtml/html/html_elementimpl.cpp

diff --git a/LayoutTests/fast/dom/anchor-text-expected.txt b/LayoutTests/fast/dom/anchor-text-expected.txt
new file mode 100644 (file)
index 0000000..4b671da
--- /dev/null
@@ -0,0 +1,14 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x34
+  RenderBlock {HTML} at (0,0) size 800x34
+    RenderBody {BODY} at (8,8) size 784x18
+      RenderInline {A} at (0,0) size 236x18 [color=#0000EE]
+        RenderInline {B} at (0,0) size 236x18
+          RenderText {TEXT} at (0,0) size 236x18
+            text run at (0,0) width 236: "the second copy should not be bold"
+      RenderText {TEXT} at (236,0) size 4x18
+        text run at (236,0) width 4: " "
+      RenderInline {B} at (0,0) size 236x18
+        RenderText {TEXT} at (240,0) size 236x18
+          text run at (240,0) width 236: "the second copy should not be bold"
diff --git a/LayoutTests/fast/dom/anchor-text.html b/LayoutTests/fast/dom/anchor-text.html
new file mode 100644 (file)
index 0000000..a5c6e97
--- /dev/null
@@ -0,0 +1,4 @@
+<a id="x" href="http://www.google.com"><b>the second copy should not be bold</b></a>
+<script>
+document.write(document.getElementById("x").text);
+</script>
\ No newline at end of file
diff --git a/LayoutTests/fast/dom/inner-text-expected.txt b/LayoutTests/fast/dom/inner-text-expected.txt
new file mode 100644 (file)
index 0000000..f47ebf5
--- /dev/null
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x62
+  RenderBlock {HTML} at (0,0) size 800x62
+    RenderBody {BODY} at (8,8) size 784x46
+      RenderImage {IMG} at (0,0) size 24x24
+      RenderText {TEXT} at (24,10) size 225x18
+        text run at (24,10) width 225: " This text should only appear once. "
+      RenderText {TEXT} at (249,10) size 466x36
+        text run at (249,10) width 217: "This text should only appear once."
+        text run at (0,28) width 378: "document.write(document.getElementById(\"x\").innerText);"
diff --git a/LayoutTests/fast/dom/inner-text.html b/LayoutTests/fast/dom/inner-text.html
new file mode 100644 (file)
index 0000000..4f06f8d
--- /dev/null
@@ -0,0 +1,5 @@
+<img id="x" src="broken.gif">
+This text should only appear once.
+<script>
+document.write(document.getElementById("x").innerText);
+</script>
index ed8441a..c67912c 100644 (file)
@@ -1,3 +1,24 @@
+2004-04-25  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Darin.
+
+       <rdar://problem/3628309>: Fedex tracking page so slow it seems like a hang (site change?)
+       <rdar://problem/3608061>: "ATI Developer site so slow it seems like a hang"
+       <rdar://problem/3612130>: "Reproducible hang in JavaScript at www.tfl.gov.uk"
+       <rdar://problem/3626022>: "Safari was consuming > 100% CPU on dual-G5 Mac, sample shows JavaScript"
+       <rdar://problem/3632348>: "www.whatis.com search for "pivot table" leads to JavaScript hang"
+       
+        * khtml/ecma/kjs_html.cpp:
+        (KJS::HTMLElement::getValueProperty): The "text" property for anchors should be
+       innerText, not innerHTML.
+        * khtml/html/html_elementimpl.cpp:
+        (HTMLElementImpl::innerText): Make sure not to include all the text after an
+       element if it has no children.
+        * layout-tests/fast/dom/anchor-text-expected.txt: Added.
+        * layout-tests/fast/dom/anchor-text.html: Added.
+        * layout-tests/fast/dom/inner-text-expected.txt: Added.
+        * layout-tests/fast/dom/inner-text.html: Added.
+
 2004-04-24  Darin Adler  <darin@apple.com>
 
         Reviewed by Dave.
index c4e3a80..a01f81c 100644 (file)
@@ -1544,7 +1544,7 @@ Value KJS::HTMLElement::getValueProperty(ExecState *exec, int token) const
     case AnchorShape:           return String(anchor.shape());
     case AnchorTabIndex:        return Number(anchor.tabIndex());
     case AnchorTarget:          return String(anchor.target());
-    case AnchorText:            return String(anchor.innerHTML());
+    case AnchorText:            return String(anchor.innerText());
     case AnchorType:            return String(anchor.type());
     }
   }
index 4b4df19..687aa0e 100644 (file)
@@ -614,9 +614,12 @@ DOMString HTMLElementImpl::innerText() const
 {
     DOMString text;
 
-    const NodeImpl *n = this;
+    const NodeImpl *n = firstChild();
     // find the next text/image after the anchor, to get a position
     while(n) {
+        if(n->isTextNode() ) {
+            text += static_cast<const TextImpl *>(n)->data();
+        }
         if(n->firstChild())
             n = n->firstChild();
         else if(n->nextSibling())
@@ -630,9 +633,6 @@ DOMString HTMLElementImpl::innerText() const
             }
             n = next;
         }
-        if(n->isTextNode() ) {
-            text += static_cast<const TextImpl *>(n)->data();
-        }
     }
  end:
     return text;