LayoutTests:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Apr 2006 08:31:17 +0000 (08:31 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Apr 2006 08:31:17 +0000 (08:31 +0000)
        Reviewed by Anders.

        Added test case for incidental fix from this change:

        - Convert Element JS bindings to be almost completely autogenerated
        http://bugzilla.opendarwin.org/show_bug.cgi?id=8227

        * fast/dom/Element/dimension-properties-unrendered-expected.txt: Added.
        * fast/dom/Element/dimension-properties-unrendered.html: Added.
        * fast/dom/Element/resources/dimension-properties-unrendered.js: Added.

WebCore:

        Reviewed by Anders.

        - Convert Element JS bindings to be almost completely autogenerated
        http://bugzilla.opendarwin.org/show_bug.cgi?id=8227

        * dom/Element.idl: Declare full interface in IDL.
        * dom/Element.h:
        (WebCore::Element::tagQName): Renamed from tagName, so the real DOM
        method can be called tagName.
        (WebCore::Element::tagName): inline alias for nodeName.
        * dom/Element.cpp:
        (WebCore::Element::scrollByUnits): Moved logic from JS bindings to
        core DOM.
        (WebCore::Element::scrollByLines): ditto
        (WebCore::Element::scrollByPages): ditto
        (WebCore::Element::offsetLeft): ditto, plus make unrendered elements return 0 not undefined
        (WebCore::Element::offsetTop): ditto, plus make unrendered elements return 0 not undefined
        (WebCore::Element::offsetWidth): ditto, plus make unrendered elements return 0 not undefined
        (WebCore::Element::offsetHeight): ditto, plus make unrendered elements return 0 not undefined
        (WebCore::Element::offsetParent): ditto
        (WebCore::Element::clientWidth): ditto, plus make unrendered elements return 0 not undefined
        (WebCore::Element::clientHeight): ditto, plus make unrendered elements return 0 not undefined
        (WebCore::Element::scrollLeft): ditto
        (WebCore::Element::scrollTop): ditto
        (WebCore::Element::setScrollLeft): ditto
        (WebCore::Element::setScrollTop): ditto
        (WebCore::Element::scrollWidth): ditto, plus make unrendered elements return 0 not undefined
        (WebCore::Element::scrollHeight): ditto, plus make unrendered elements return 0 not undefined

        * bindings/scripts/CodeGeneratorJS.pm: Added support for
        ConvertUndefinedToTrue, for benefit of scroll methods where
        omitted arguments should be treated as true.  However, maybe
        explicit overloading in the IDL would be a better long-term
        approach for optional arguments.

        * khtml/ecma/kjs_binding.cpp:
        (KJS::valueToStringWithNullCheck): fixed formatting
        (KJS::valueToBooleanTreatUndefinedAsTrue): added for binding of scrollIntoView
        (isn't this lame?)
        * khtml/ecma/kjs_binding.h:
        (KJS::toJS): fixed formatting, added new stuff
        * khtml/ecma/kjs_dom.cpp:
        (KJS::DOMElement::getValueProperty): removed most of contents
        (KJS::DOMElement::putValueProperty): ditto
        (KJS::DOMElementProtoFunc::callAsFunction): ditto

        * css/cssstyleselector.cpp:
        (WebCore::CSSStyleSelector::canShareStyleWithElement): updated for rename
        of tagName to tagQName
        (WebCore::CSSStyleSelector::checkOneSelector): ditto
        * dom/Document.cpp:
        (WebCore::Document::importNode): ditto
        * editing/ApplyStyleCommand.cpp:
        (WebCore::ApplyStyleCommand::removeInlineStyle): ditto
        (WebCore::areIdenticalElements): ditto
        * html/HTMLElement.cpp:
        (WebCore::HTMLElement::inEitherTagList): ditto
        (WebCore::HTMLElement::inInlineTagList): ditto
        (WebCore::HTMLElement::inBlockTagList): ditto

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/Element/dimension-properties-unrendered-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Element/dimension-properties-unrendered.html [new file with mode: 0644]
LayoutTests/fast/dom/Element/resources/dimension-properties-unrendered.js [new file with mode: 0644]
WebCore/ChangeLog
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/css/cssstyleselector.cpp
WebCore/dom/Document.cpp
WebCore/dom/Element.cpp
WebCore/dom/Element.h
WebCore/dom/Element.idl
WebCore/editing/ApplyStyleCommand.cpp
WebCore/html/HTMLElement.cpp
WebCore/khtml/ecma/kjs_binding.cpp
WebCore/khtml/ecma/kjs_binding.h
WebCore/khtml/ecma/kjs_dom.cpp

index 93dd891b6b5044f0cb359707662023e35a9a0c6a..920340d80b2482561df126e492127c144369c95f 100644 (file)
@@ -1,3 +1,16 @@
+2006-04-07  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Anders.
+
+        Added test case for incidental fix from this change:
+        
+        - Convert Element JS bindings to be almost completely autogenerated
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=8227
+
+        * fast/dom/Element/dimension-properties-unrendered-expected.txt: Added.
+        * fast/dom/Element/dimension-properties-unrendered.html: Added.
+        * fast/dom/Element/resources/dimension-properties-unrendered.js: Added.
+
 2006-04-06  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Darin.
diff --git a/LayoutTests/fast/dom/Element/dimension-properties-unrendered-expected.txt b/LayoutTests/fast/dom/Element/dimension-properties-unrendered-expected.txt
new file mode 100644 (file)
index 0000000..be74b98
--- /dev/null
@@ -0,0 +1,19 @@
+This test checks the scroll, client and offset dimension properties return "0" instead of undefined for an unrendered element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testDiv.offsetLeft is 0
+PASS testDiv.offsetTop is 0
+PASS testDiv.offsetWidth is 0
+PASS testDiv.offsetHeight is 0
+PASS testDiv.clientWidth is 0
+PASS testDiv.clientHeight is 0
+PASS testDiv.scrollLeft is 0
+PASS testDiv.scrollTop is 0
+PASS testDiv.scrollWidth is 0
+PASS testDiv.scrollHeight is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Element/dimension-properties-unrendered.html b/LayoutTests/fast/dom/Element/dimension-properties-unrendered.html
new file mode 100644 (file)
index 0000000..bcfb0ba
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/dimension-properties-unrendered.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/Element/resources/dimension-properties-unrendered.js b/LayoutTests/fast/dom/Element/resources/dimension-properties-unrendered.js
new file mode 100644 (file)
index 0000000..9fe1cc1
--- /dev/null
@@ -0,0 +1,17 @@
+description(
+'This test checks the scroll, client and offset dimension properties return "0" instead of undefined for an unrendered element. <div id="testDiv" style="display: none">x</div>'
+);
+
+var testDiv = document.getElementById("testDiv");
+shouldBe("testDiv.offsetLeft", "0");
+shouldBe("testDiv.offsetTop", "0");
+shouldBe("testDiv.offsetWidth", "0");
+shouldBe("testDiv.offsetHeight", "0");
+shouldBe("testDiv.clientWidth", "0");
+shouldBe("testDiv.clientHeight", "0");
+shouldBe("testDiv.scrollLeft", "0");
+shouldBe("testDiv.scrollTop", "0");
+shouldBe("testDiv.scrollWidth", "0");
+shouldBe("testDiv.scrollHeight", "0");
+
+var successfullyParsed = true;
index 272f365800445cd5f0c7686b49d27d64187ddb42..a7dbef8cba5f071d2f796ec794d743e21bf538bf 100644 (file)
@@ -1,3 +1,65 @@
+2006-04-06  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Anders.
+
+        - Convert Element JS bindings to be almost completely autogenerated
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=8227
+
+        * dom/Element.idl: Declare full interface in IDL.
+        * dom/Element.h:
+        (WebCore::Element::tagQName): Renamed from tagName, so the real DOM
+        method can be called tagName.
+        (WebCore::Element::tagName): inline alias for nodeName.
+        * dom/Element.cpp:
+        (WebCore::Element::scrollByUnits): Moved logic from JS bindings to
+        core DOM.
+        (WebCore::Element::scrollByLines): ditto
+        (WebCore::Element::scrollByPages): ditto
+        (WebCore::Element::offsetLeft): ditto, plus make unrendered elements return 0 not undefined
+        (WebCore::Element::offsetTop): ditto, plus make unrendered elements return 0 not undefined
+        (WebCore::Element::offsetWidth): ditto, plus make unrendered elements return 0 not undefined
+        (WebCore::Element::offsetHeight): ditto, plus make unrendered elements return 0 not undefined
+        (WebCore::Element::offsetParent): ditto
+        (WebCore::Element::clientWidth): ditto, plus make unrendered elements return 0 not undefined
+        (WebCore::Element::clientHeight): ditto, plus make unrendered elements return 0 not undefined
+        (WebCore::Element::scrollLeft): ditto
+        (WebCore::Element::scrollTop): ditto
+        (WebCore::Element::setScrollLeft): ditto
+        (WebCore::Element::setScrollTop): ditto
+        (WebCore::Element::scrollWidth): ditto, plus make unrendered elements return 0 not undefined
+        (WebCore::Element::scrollHeight): ditto, plus make unrendered elements return 0 not undefined
+
+        * bindings/scripts/CodeGeneratorJS.pm: Added support for
+        ConvertUndefinedToTrue, for benefit of scroll methods where
+        omitted arguments should be treated as true.  However, maybe
+        explicit overloading in the IDL would be a better long-term
+        approach for optional arguments.
+
+        * khtml/ecma/kjs_binding.cpp:
+        (KJS::valueToStringWithNullCheck): fixed formatting
+        (KJS::valueToBooleanTreatUndefinedAsTrue): added for binding of scrollIntoView
+        (isn't this lame?)
+        * khtml/ecma/kjs_binding.h:
+        (KJS::toJS): fixed formatting, added new stuff
+        * khtml/ecma/kjs_dom.cpp:
+        (KJS::DOMElement::getValueProperty): removed most of contents
+        (KJS::DOMElement::putValueProperty): ditto
+        (KJS::DOMElementProtoFunc::callAsFunction): ditto
+
+        * css/cssstyleselector.cpp:
+        (WebCore::CSSStyleSelector::canShareStyleWithElement): updated for rename
+        of tagName to tagQName
+        (WebCore::CSSStyleSelector::checkOneSelector): ditto
+        * dom/Document.cpp:
+        (WebCore::Document::importNode): ditto
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::removeInlineStyle): ditto
+        (WebCore::areIdenticalElements): ditto
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::inEitherTagList): ditto
+        (WebCore::HTMLElement::inInlineTagList): ditto
+        (WebCore::HTMLElement::inBlockTagList): ditto
+
 2006-04-06  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Darin.
index 585ac77c5da10df702becf15ef4773a9de30e464..3f91f0550411503f40889018de6cc678bfdae209 100644 (file)
@@ -799,7 +799,12 @@ sub JSValueToNative
   my $type = $signature->type;
 
   if ($type eq "boolean") {
-    return "$value->toBoolean(exec)";
+    my $conv = $signature->extendedAttributes->{"ConvertUndefinedToTrue"};
+    if (defined $conv) {
+       return "valueToBooleanTreatUndefinedAsTrue(exec, $value)";
+    } else {
+       return "$value->toBoolean(exec)";
+    }
   } elsif ($type eq "unsigned long" or $type eq "long") {
     return "$value->toInt32(exec)";
   } elsif ($type eq "unsigned short") {
index 6bbe76f6125dd93e4fff0192ed4c8f8e9f8eae58..d5f3d09c4f41943e6183baf3b912f2bacbc5c2d7 100644 (file)
@@ -619,7 +619,7 @@ bool CSSStyleSelector::canShareStyleWithElement(Node* n)
 {
     if (n->isStyledElement()) {
         StyledElement* s = static_cast<StyledElement*>(n);
-        if (s->renderer() && (s->tagName() == element->tagName()) && !s->hasID() &&
+        if (s->renderer() && (s->tagQName() == element->tagQName()) && !s->hasID() &&
             (s->hasClass() == element->hasClass()) && !s->inlineStyleDecl() &&
             (s->hasMappedAttributes() == styledElement->hasMappedAttributes()) &&
             (s->isLink() == element->isLink()) && 
@@ -1300,7 +1300,7 @@ bool CSSStyleSelector::checkOneSelector(CSSSelector* sel, Element* e, bool isSub
             case CSSSelector::PseudoFirstOfType: {
                 // first-of-type matches the first element of its type!
                 if (e->parentNode() && e->parentNode()->isElementNode()) {
-                    const QualifiedName& type = e->tagName();
+                    const QualifiedName& type = e->tagQName();
                     Node *n = e->previousSibling();
                     while (n) {
                         if (n->isElementNode() && static_cast<Element*>(n)->hasTagName(type))
@@ -1326,7 +1326,7 @@ bool CSSStyleSelector::checkOneSelector(CSSSelector* sel, Element* e, bool isSub
             case CSSSelector::PseudoLastOfType: {
                 // last-of-type matches the last element of its type!
                 if (e->parentNode() && e->parentNode()->isElementNode()) {
-                    const QualifiedName& type = e->tagName();
+                    const QualifiedName& type = e->tagQName();
                     Node *n = e->nextSibling();
                     while (n) {
                         if (n->isElementNode() && static_cast<Element*>(n)->hasTagName(type))
@@ -1357,7 +1357,7 @@ bool CSSStyleSelector::checkOneSelector(CSSSelector* sel, Element* e, bool isSub
             case CSSSelector::PseudoOnlyOfType: {
                 // If both first-of-type and last-of-type apply, then only-of-type applies.
                 if (e->parentNode() && e->parentNode()->isElementNode()) {
-                    const QualifiedName& type = e->tagName();
+                    const QualifiedName& type = e->tagQName();
                     Node *n = e->previousSibling();
                     while (n && !static_cast<Element*>(n)->hasTagName(type))
                         n = n->previousSibling();
index 497f986ebc91578da79b09fc2d592ac24d24c043..faf705c027a94d53704502e3ae4e82e075d3fb8e 100644 (file)
@@ -475,7 +475,7 @@ PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionCo
             return createComment(importedNode->nodeValue());
         case ELEMENT_NODE: {
             Element *oldElement = static_cast<Element *>(importedNode);
-            RefPtr<Element> newElement = createElementNS(oldElement->namespaceURI(), oldElement->tagName().toString(), ec);
+            RefPtr<Element> newElement = createElementNS(oldElement->namespaceURI(), oldElement->tagQName().toString(), ec);
                         
             if (ec != 0)
                 return 0;
index 715da4d6f6289ae1d2e4ce9f3f0e5b32699d1f72..3918749d9dccd60fc979ebdb0ee8552b7b1f263b 100644 (file)
@@ -151,6 +151,135 @@ void Element::scrollIntoViewIfNeeded(bool centerIfNeeded)
     }
 }
 
+void Element::scrollByUnits(int units, KWQScrollGranularity granularity)
+{
+    document()->updateLayoutIgnorePendingStylesheets();
+    if (RenderObject *rend = renderer()) {
+        if (rend->hasOverflowClip()) {
+            KWQScrollDirection direction = KWQScrollDown;
+            if (units < 0) {
+                direction = KWQScrollUp;
+                units = -units;
+            }
+            rend->layer()->scroll(direction, granularity, units);
+        }
+    }
+}
+
+void Element::scrollByLines(int lines)
+{
+    scrollByUnits(lines, KWQScrollLine);
+}
+
+void Element::scrollByPages(int pages)
+{
+    scrollByUnits(pages, KWQScrollPage);
+}
+
+int Element::offsetLeft()
+{
+    document()->updateLayoutIgnorePendingStylesheets();
+    if (RenderObject* rend = renderer())
+        return rend->offsetLeft();
+    return 0;
+}
+
+int Element::offsetTop()
+{
+    document()->updateLayoutIgnorePendingStylesheets();
+    if (RenderObject* rend = renderer())
+        return rend->offsetTop();
+    return 0;
+}
+
+int Element::offsetWidth()
+{
+    document()->updateLayoutIgnorePendingStylesheets();
+    if (RenderObject* rend = renderer())
+        return rend->offsetWidth();
+    return 0;
+}
+
+int Element::offsetHeight()
+{
+    document()->updateLayoutIgnorePendingStylesheets();
+    if (RenderObject* rend = renderer())
+        return rend->offsetHeight();
+    return 0;
+}
+
+Element* Element::offsetParent()
+{
+    document()->updateLayoutIgnorePendingStylesheets();
+    if (RenderObject* rend = renderer())
+        return static_cast<Element*>(rend->offsetParent()->element());
+    return 0;
+}
+
+int Element::clientWidth()
+{
+    document()->updateLayoutIgnorePendingStylesheets();
+    if (RenderObject* rend = renderer())
+        return rend->clientWidth();
+    return 0;
+}
+
+int Element::clientHeight()
+{
+    document()->updateLayoutIgnorePendingStylesheets();
+    if (RenderObject* rend = renderer())
+        return rend->clientHeight();
+    return 0;
+}
+
+int Element::scrollLeft()
+{
+    document()->updateLayoutIgnorePendingStylesheets();
+    RenderObject* rend = renderer();
+    if (rend && rend->layer())
+        return rend->layer()->scrollXOffset();
+    return 0;
+}
+
+int Element::scrollTop()
+{
+    document()->updateLayoutIgnorePendingStylesheets();
+    RenderObject* rend = renderer();
+    if (rend && rend->layer())
+        return rend->layer()->scrollYOffset();
+    return 0;
+}
+
+void Element::setScrollLeft(int newLeft)
+{
+    RenderObject *rend = renderer();
+    if (rend && rend->hasOverflowClip())
+        rend->layer()->scrollToXOffset(newLeft);
+}
+
+void Element::setScrollTop(int newTop)
+{
+    RenderObject *rend = renderer();
+    if (rend && rend->hasOverflowClip())
+        rend->layer()->scrollToYOffset(newTop);
+}
+
+int Element::scrollWidth()
+{
+    document()->updateLayoutIgnorePendingStylesheets();
+    if (RenderObject* rend = renderer())
+        return rend->scrollWidth();
+    return 0;
+}
+
+int Element::scrollHeight()
+{
+    document()->updateLayoutIgnorePendingStylesheets();
+    if (RenderObject* rend = renderer())
+        return rend->scrollHeight();
+    return 0;
+}
+
 static inline bool inHTMLDocument(const Element* e)
 {
     return e && e->document()->isHTMLDocument();
index c53cc93c3d9cf2afe6d40eddd466e981f15a90cf..a1f4962b679004162a168776845018aeb5b05521 100644 (file)
@@ -30,6 +30,7 @@
 #include "ContainerNode.h"
 #include "Attr.h"
 #include "QualifiedName.h"
+#include "KWQScrollBar.h"
 
 namespace WebCore {
 
@@ -68,6 +69,24 @@ public:
     void scrollIntoView (bool alignToTop);
     void scrollIntoViewIfNeeded(bool centerIfNeeded);
 
+    void scrollByUnits(int units, KWQScrollGranularity granularity);
+    void scrollByLines(int lines);
+    void scrollByPages(int pages);
+
+    int offsetLeft();
+    int offsetTop();
+    int offsetWidth();
+    int offsetHeight();
+    Element* offsetParent();
+    int clientWidth();
+    int clientHeight();
+    int scrollLeft();
+    int scrollTop();
+    void setScrollLeft(int);
+    void setScrollTop(int);
+    int scrollWidth();
+    int scrollHeight();
+
     void removeAttribute(const String &name, ExceptionCode& ec);
     void removeAttributeNS(const String &namespaceURI, const String& localName, ExceptionCode&);
 
@@ -79,7 +98,8 @@ public:
     
     virtual CSSStyleDeclaration *style();
 
-    virtual const QualifiedName& tagName() const { return m_tagName; }
+    const QualifiedName& tagQName() const { return m_tagName; }
+    String tagName() const { return nodeName(); }
     virtual bool hasTagName(const QualifiedName& tagName) const { return m_tagName.matches(tagName); }
     
     // A fast function for checking the local name against another atomic string.
index 9a67b2c91419ebd343217880148500d233d16421..87d1a4b8f2548d09db79c53224dcca77c49e23ef 100644 (file)
@@ -21,12 +21,10 @@ module core {
 
     interface [LegacyParent=KJS::DOMElement] Element : EventTargetNode {
 
-        // DOM Level 1
+        // DOM Level 1 Core
 
-        NodeList getElementsByTagName(in DOMString name);
+        readonly attribute [ConvertNullStringTo=Null] DOMString tagName;
 
-        // ConvertNullStringTo=Null is used here since if the attribute isn't present at all
-        // the function should return null and not "".
         [ConvertNullStringTo=Null] DOMString getAttribute(in DOMString name);
 
         void setAttribute(in DOMString name,
@@ -44,15 +42,9 @@ module core {
         Attr removeAttributeNode(in Attr oldAttr)
             raises(DOMException);
 
-        // DOM Level 2
-
-        NodeList getElementsByTagNameNS(in [ConvertNullToNullString] DOMString namespaceURI,
-                                        in DOMString localName);
-
-        boolean hasAttribute(in DOMString name);
+        NodeList getElementsByTagName(in DOMString name);
 
-        boolean hasAttributeNS(in [ConvertNullToNullString] DOMString namespaceURI,
-                               in DOMString localName);
+        // DOM Level 2 Core
 
         DOMString getAttributeNS(in [ConvertNullToNullString] DOMString namespaceURI,
                                  in DOMString localName);
@@ -66,20 +58,53 @@ module core {
                                in DOMString localName)
             raises(DOMException);
 
+        NodeList getElementsByTagNameNS(in [ConvertNullToNullString] DOMString namespaceURI,
+                                        in DOMString localName);
+
         Attr getAttributeNodeNS(in [ConvertNullToNullString] DOMString namespaceURI,
                                 in DOMString localName);
 
         Attr setAttributeNodeNS(in Attr newAttr)
             raises(DOMException);
 
-        // extensions
+        boolean hasAttribute(in DOMString name);
+
+        boolean hasAttributeNS(in [ConvertNullToNullString] DOMString namespaceURI,
+                               in DOMString localName);
+
+        readonly attribute CSSStyleDeclaration style;
+
+        // Common extensions
+
+        readonly attribute long offsetLeft;
+
+        readonly attribute long offsetTop;
+
+        readonly attribute long offsetWidth;
+
+        readonly attribute long offsetHeight;
+
+        readonly attribute Element offsetParent;
+        
+        readonly attribute long clientWidth;
+
+        readonly attribute long clientHeight;
+
+        attribute long scrollLeft;
+
+        attribute long scrollTop;
+
+        readonly attribute long scrollWidth;
+
+        readonly attribute long scrollHeight;
 
         void focus();
+
         void blur();
 
-        readonly attribute CSSStyleDeclaration style;
+        void scrollIntoView(in [ConvertUndefinedToTrue] boolean alignWithTop);
 
-        // IE-only extensions
+        // IE extensions
 
         Node insertAdjacentElement(in DOMString position, 
                                    in Node newElement)
@@ -87,6 +112,14 @@ module core {
         
         boolean contains(in Element element);
 
+        // WebKit extensions
+
+        void scrollIntoViewIfNeeded(in [ConvertUndefinedToTrue] boolean alignWithTop);
+
+        void scrollByLines(in long lines);
+
+        void scrollByPages(in long pages);
+
     };
 
 }
index f47773ef7f6e46d0ea27a534bf091b81a74bb705..19b1de42c777744ee79cafd221e2f6ec4d788e0b 100644 (file)
@@ -899,7 +899,7 @@ void ApplyStyleCommand::removeInlineStyle(PassRefPtr<CSSMutableStyleDeclaration>
             HTMLElement *elem = static_cast<HTMLElement *>(node);
             Node *prev = elem->traversePreviousNodePostOrder();
             Node *next = elem->traverseNextNode();
-            if (m_styledInlineElement && elem->hasTagName(m_styledInlineElement->tagName()))
+            if (m_styledInlineElement && elem->hasTagName(m_styledInlineElement->tagQName()))
                 removeNodePreservingChildren(elem);
             if (isHTMLStyleNode(style.get(), elem))
                 removeHTMLStyleNode(elem);
@@ -1026,7 +1026,7 @@ static bool areIdenticalElements(Node *first, Node *second)
     Element *firstElement = static_cast<Element *>(first);
     Element *secondElement = static_cast<Element *>(second);
     
-    if (!firstElement->tagName().matches(secondElement->tagName()))
+    if (!firstElement->tagQName().matches(secondElement->tagQName()))
         return false;
 
     NamedAttrMap *firstMap = firstElement->attributes();
index 0a29f34ced176a55821b9cb6bdb967613858cf94..5ff6bb9d79727b2a592654b0e72ffbfbbdba15ca 100644 (file)
@@ -750,11 +750,11 @@ bool HTMLElement::inEitherTagList(const Node* newChild)
         
     if (newChild->isHTMLElement()) {
         const HTMLElement* child = static_cast<const HTMLElement*>(newChild);
-        if (inlineTagList()->contains(child->tagName().localName().impl()))
+        if (inlineTagList()->contains(child->tagQName().localName().impl()))
             return true;
-        if (blockTagList()->contains(child->tagName().localName().impl()))
+        if (blockTagList()->contains(child->tagQName().localName().impl()))
             return true;
-        return !isRecognizedTagName(child->tagName()); // Accept custom html tags
+        return !isRecognizedTagName(child->tagQName()); // Accept custom html tags
     }
 
     return false;
@@ -767,9 +767,9 @@ bool HTMLElement::inInlineTagList(const Node* newChild)
 
     if (newChild->isHTMLElement()) {
         const HTMLElement* child = static_cast<const HTMLElement*>(newChild);
-        if (inlineTagList()->contains(child->tagName().localName().impl()))
+        if (inlineTagList()->contains(child->tagQName().localName().impl()))
             return true;
-        return !isRecognizedTagName(child->tagName()); // Accept custom html tags
+        return !isRecognizedTagName(child->tagQName()); // Accept custom html tags
     }
 
     return false;
@@ -782,7 +782,7 @@ bool HTMLElement::inBlockTagList(const Node* newChild)
             
     if (newChild->isHTMLElement()) {
         const HTMLElement* child = static_cast<const HTMLElement*>(newChild);
-        return (blockTagList()->contains(child->tagName().localName().impl()));
+        return (blockTagList()->contains(child->tagQName().localName().impl()));
     }
 
     return false;
index 686acbed6ca1344891bcec86ce9cbe4a89d7a9eb..3e9f425a3ebf80d941404ed14b415cffbc769c0e 100644 (file)
@@ -255,13 +255,20 @@ JSValue *jsStringOrFalse(const String &s)
     return jsString(s);
 }
 
-String valueToStringWithNullCheck(ExecState *exec, JSValue *val)
+String valueToStringWithNullCheck(ExecState* exec, JSValue* val)
 {
     if (val->isNull())
         return String();
     return val->toString(exec);
 }
 
+bool valueToBooleanTreatUndefinedAsTrue(ExecState* exec, JSValue* val)
+{
+    if (val->isUndefined())
+        return true;
+    return val->toBoolean(exec);
+}
+
 static const char * const exceptionNames[] = {
     0,
     "INDEX_SIZE_ERR",
index 508bb4b4f48d1cfdba273ac97d9803610b03bfbe..7385e13e7efc66cb4cbe95290d0d0d553f6671dd 100644 (file)
@@ -156,9 +156,11 @@ namespace KJS {
   /**
    *  Get a String object or a null String if the value is null
    */
-  WebCore::String valueToStringWithNullCheck(ExecState* exec, JSValue *val);
+  WebCore::String valueToStringWithNullCheck(ExecState* exec, JSValueval);
 
-    template <typename T> inline JSValue* toJS(ExecState* exec, PassRefPtr<T> ptr) { return toJS(exec, ptr.get()); }
+  bool valueToBooleanTreatUndefinedAsTrue(ExecState* exec, JSValue* val);
+
+  template <typename T> inline JSValue* toJS(ExecState* exec, PassRefPtr<T> ptr) { return toJS(exec, ptr.get()); }
   
 } // namespace
 
index ae9f6bd217227cb6f96eef4351a2bb0a77d9914f..facd758f0422f7ea310479558f196ffd312b6632 100644 (file)
@@ -804,13 +804,7 @@ Attr* toAttr(JSValue* val, bool& ok)
 // -------------------------------------------------------------------------
 
 /* Source for DOMElementProtoTable. Use "make hashtables" to regenerate.
-@begin DOMElementProtoTable 8
-  scrollIntoView                DOMElement::ScrollIntoView      DontDelete|Function 1
-  scrollIntoViewIfNeeded        DOMElement::ScrollIntoViewIfNeeded      DontDelete|Function 1
-
-# extension for Safari RSS
-  scrollByLines         DOMElement::ScrollByLines       DontDelete|Function 1
-  scrollByPages         DOMElement::ScrollByPages       DontDelete|Function 1
+@begin DOMElementProtoTable 1
 @end
 */
 KJS_IMPLEMENT_PROTOFUNC(DOMElementProtoFunc)
@@ -818,21 +812,7 @@ KJS_IMPLEMENT_PROTOTYPE("DOMElement", DOMElementProto, DOMElementProtoFunc)
 
 const ClassInfo DOMElement::info = { "Element", &DOMEventTargetNode::info, &DOMElementTable, 0 };
 /* Source for DOMElementTable. Use "make hashtables" to regenerate.
-@begin DOMElementTable 17
-    tagName       DOMElement::TagName                         DontDelete|ReadOnly
-
-# IE extensions
-    offsetLeft    DOMElement::OffsetLeft             DontDelete|ReadOnly
-    offsetTop     DOMElement::OffsetTop              DontDelete|ReadOnly
-    offsetWidth   DOMElement::OffsetWidth            DontDelete|ReadOnly
-    offsetHeight  DOMElement::OffsetHeight           DontDelete|ReadOnly
-    offsetParent  DOMElement::OffsetParent           DontDelete|ReadOnly
-    clientWidth   DOMElement::ClientWidth            DontDelete|ReadOnly
-    clientHeight  DOMElement::ClientHeight           DontDelete|ReadOnly
-    scrollLeft    DOMElement::ScrollLeft             DontDelete
-    scrollTop     DOMElement::ScrollTop              DontDelete
-    scrollWidth   DOMElement::ScrollWidth            DontDelete|ReadOnly
-    scrollHeight  DOMElement::ScrollHeight           DontDelete|ReadOnly
+@begin DOMElementTable 1
 @end
 */
 DOMElement::DOMElement(ExecState *exec, Element *e)
@@ -848,47 +828,6 @@ DOMElement::DOMElement(Element *e)
 
 JSValue *DOMElement::getValueProperty(ExecState *exec, int token) const
 {
-    Element *element = static_cast<Element *>(impl());
-    switch (token) {
-    case TagName:
-        return jsStringOrNull(element->nodeName());
-
-    default:
-        // no DOM standard -- IE extension
-        
-        // Make sure our layout is up to date before we allow a query on these attributes.
-        element->document()->updateLayoutIgnorePendingStylesheets();
-        
-        RenderObject *rend = element->renderer();
-        
-        switch (token) {
-            case OffsetLeft:
-                return rend ? jsNumber(rend->offsetLeft()) : static_cast<JSValue *>(jsUndefined());
-            case OffsetTop:
-                return rend ? jsNumber(rend->offsetTop()) : static_cast<JSValue *>(jsUndefined());
-            case OffsetWidth:
-                return rend ? jsNumber(rend->offsetWidth()) : static_cast<JSValue *>(jsUndefined());
-            case OffsetHeight:
-                return rend ? jsNumber(rend->offsetHeight()) : static_cast<JSValue *>(jsUndefined());
-            case OffsetParent: {
-                RenderObject* par = rend ? rend->offsetParent() : 0;
-                return toJS(exec, par ? par->element() : 0);
-            }
-            case ClientWidth:
-                return rend ? jsNumber(rend->clientWidth()) : static_cast<JSValue *>(jsUndefined());
-            case ClientHeight:
-                return rend ? jsNumber(rend->clientHeight()) : static_cast<JSValue *>(jsUndefined());
-            case ScrollWidth:
-                return rend ? jsNumber(rend->scrollWidth()) : static_cast<JSValue *>(jsUndefined());
-            case ScrollHeight:
-                return rend ? jsNumber(rend->scrollHeight()) : static_cast<JSValue *>(jsUndefined());
-            case ScrollLeft:
-                return jsNumber(rend && rend->layer() ? rend->layer()->scrollXOffset() : 0);
-            case ScrollTop:
-                return jsNumber(rend && rend->layer() ? rend->layer()->scrollYOffset() : 0);
-        }
-    }
-
     return jsUndefined();
 }
 
@@ -899,21 +838,6 @@ void DOMElement::put(ExecState *exec, const Identifier& propertyName, JSValue *v
 
 void DOMElement::putValueProperty(ExecState *exec, int token, JSValue *value, int /*attr*/)
 {
-    WebCore::Node& node = *m_impl;
-    switch (token) {
-        case ScrollTop: {
-            RenderObject *rend = node.renderer();
-            if (rend && rend->hasOverflowClip())
-                rend->layer()->scrollToYOffset(value->toInt32(exec));
-            break;
-        }
-        case ScrollLeft: {
-            RenderObject *rend = node.renderer();
-            if (rend && rend->hasOverflowClip())
-                rend->layer()->scrollToXOffset(value->toInt32(exec));
-            break;
-        }
-    }
 }
 
 JSValue* DOMElement::attributeGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
@@ -955,33 +879,6 @@ JSValue *DOMElementProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj,
 {
   if (!thisObj->inherits(&KJS::DOMElement::info))
     return throwError(exec, TypeError);
-  DOMExceptionTranslator exception(exec);
-  WebCore::Node& node = *static_cast<DOMNode*>(thisObj)->impl();
-  Element &element = static_cast<Element &>(node);
-
-  switch(id) {
-      case DOMElement::ScrollIntoView: 
-        element.scrollIntoView(args[0]->isUndefinedOrNull() || args[0]->toBoolean(exec));
-        return jsUndefined();
-      case DOMElement::ScrollIntoViewIfNeeded: 
-        element.scrollIntoViewIfNeeded(args[0]->isUndefinedOrNull() || args[0]->toBoolean(exec));
-        return jsUndefined();
-      case DOMElement::ScrollByLines:
-      case DOMElement::ScrollByPages:
-        element.document()->updateLayoutIgnorePendingStylesheets();
-        if (RenderObject *rend = element.renderer())
-          if (rend->hasOverflowClip()) {
-            KWQScrollDirection direction = KWQScrollDown;
-            int multiplier = args[0]->toInt32(exec);
-            if (multiplier < 0) {
-                direction = KWQScrollUp;
-                multiplier = -multiplier;
-            }
-            KWQScrollGranularity granularity = id == DOMElement::ScrollByLines ? KWQScrollLine : KWQScrollPage;
-            rend->layer()->scroll(direction, granularity, multiplier);
-          }
-        return jsUndefined();
-    }
 
     return jsUndefined();
 }