LayoutTests:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Mar 2006 23:52:24 +0000 (23:52 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Mar 2006 23:52:24 +0000 (23:52 +0000)
        - test for <rdar://problem/4251515> REGRESSION: listing tag broken in TOT

        * fast/html: Added.
        * fast/html/listing-expected.checksum: Added.
        * fast/html/listing-expected.png: Added.
        * fast/html/listing-expected.txt: Added.
        * fast/html/listing.html: Added.

WebCore:

        Reviewed by Tim O.

        - fixed <rdar://problem/4251515> REGRESSION: listing tag broken in TOT

        Test: fast/html/listing.html

        * html/HTMLNames.h: Add listing tag.

        * bindings/objc/DOM.mm: (+[DOMNode _nodeWith:]):
        * bridge/mac/FrameMac.mm: (WebCore::FrameMac::attributedString):
        * css/html4.css:
        * editing/ReplaceSelectionCommand.cpp: (WebCore::isProbablyBlock):
        * editing/TextIterator.cpp:
        (WebCore::TextIterator::handleNonTextNode):
        (WebCore::TextIterator::exitNode):
        (WebCore::SimplifiedBackwardsTextIterator::handleNonTextNode):
        * editing/markup.cpp:
        (WebCore::startMarkup):
        (WebCore::createMarkup):
        * html/HTMLElement.cpp: (WebCore::blockTagList):
        * html/HTMLElementFactory.cpp:
        (WebCore::addTag):
        (WebCore::createFunctionMap):
        (WebCore::HTMLElementFactory::createHTMLElement):
        * html/HTMLParser.cpp: (WebCore::HTMLParser::isAffectedByResidualStyle):
        * html/HTMLTokenizer.cpp: (WebCore::HTMLTokenizer::parseTag):
        * khtml/ecma/kjs_html.cpp:
        (KJS::JSHTMLElement::classInfo):
        (KJS::JSHTMLElement::accessors):
        Add listing tags everywhere pre tags are listed.

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

18 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/html/listing-expected.checksum [new file with mode: 0644]
LayoutTests/fast/html/listing-expected.png [new file with mode: 0644]
LayoutTests/fast/html/listing-expected.txt [new file with mode: 0644]
LayoutTests/fast/html/listing.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/bindings/objc/DOM.mm
WebCore/bridge/mac/FrameMac.mm
WebCore/css/html4.css
WebCore/editing/ReplaceSelectionCommand.cpp
WebCore/editing/TextIterator.cpp
WebCore/editing/markup.cpp
WebCore/html/HTMLElement.cpp
WebCore/html/HTMLElementFactory.cpp
WebCore/html/HTMLNames.h
WebCore/html/HTMLParser.cpp
WebCore/html/HTMLTokenizer.cpp
WebCore/khtml/ecma/kjs_html.cpp

index 9004831c56c30b1afd0007e6496df2129aaf431b..6090369feaea94e27a19676bc8727babf60f7fd7 100644 (file)
@@ -1,3 +1,13 @@
+2006-03-21  Darin Adler  <darin@apple.com>
+
+        - test for <rdar://problem/4251515> REGRESSION: listing tag broken in TOT
+
+        * fast/html: Added.
+        * fast/html/listing-expected.checksum: Added.
+        * fast/html/listing-expected.png: Added.
+        * fast/html/listing-expected.txt: Added.
+        * fast/html/listing.html: Added.
+
 2006-03-21  Beth Dakin  <bdakin@apple.com>
 
         Reducing the amount of time this test waits for the frame to fully
diff --git a/LayoutTests/fast/html/listing-expected.checksum b/LayoutTests/fast/html/listing-expected.checksum
new file mode 100644 (file)
index 0000000..512cf26
--- /dev/null
@@ -0,0 +1 @@
+a56f7c3fb3a108a62558c1677b8de78b
\ No newline at end of file
diff --git a/LayoutTests/fast/html/listing-expected.png b/LayoutTests/fast/html/listing-expected.png
new file mode 100644 (file)
index 0000000..a9cf021
Binary files /dev/null and b/LayoutTests/fast/html/listing-expected.png differ
diff --git a/LayoutTests/fast/html/listing-expected.txt b/LayoutTests/fast/html/listing-expected.txt
new file mode 100644 (file)
index 0000000..b0f6fe0
--- /dev/null
@@ -0,0 +1,22 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x576
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {TEXT} at (0,0) size 406x18
+          text run at (0,0) width 406: "This tests the listing tag. It's an obsolete synonym for the pre tag."
+      RenderBlock {DIV} at (0,34) size 784x18
+        RenderText {TEXT} at (0,0) size 168x18
+          text run at (0,0) width 168: "Text just before the listing."
+      RenderBlock {LISTING} at (0,65) size 784x45
+        RenderText {TEXT} at (0,0) size 792x45
+          text run at (0,0) width 272: "This text is inside a listing tag."
+          text run at (0,15) width 768: "It acts exactly like the pre tag, so the text should be monospaced and not have any line breaks."
+          text run at (0,30) width 792: "Also, it eats the very first newline inside the listing, so there should not be a blank line above."
+      RenderBlock {P} at (0,126) size 784x18
+        RenderText {TEXT} at (0,0) size 588x18
+          text run at (0,0) width 588: "The listing tag has a width in it. To test the JavaScript binding, this page gets the width, here: "
+        RenderInline {A} at (0,0) size 24x18
+          RenderText {TEXT} at (588,0) size 24x18
+            text run at (588,0) width 24: "100"
diff --git a/LayoutTests/fast/html/listing.html b/LayoutTests/fast/html/listing.html
new file mode 100644 (file)
index 0000000..77280c3
--- /dev/null
@@ -0,0 +1,16 @@
+<p>This tests the listing tag. It's an obsolete synonym for the pre tag.</p>
+
+<div>Text just before the listing.</div>
+<listing id="mr. listing" width=100>
+This text is inside a listing tag.
+It acts exactly like the pre tag, so the text should be monospaced and not have any line breaks.
+Also, it eats the very first newline inside the listing, so there should not be a blank line above.
+</listing>
+
+<p>The listing tag has a width in it. To test the JavaScript binding, this page gets the width, here: <a id="width place"></a></p>
+
+<script>
+    var listing = document.getElementById("mr. listing");
+    var widthPlace = document.getElementById("width place");
+    widthPlace.appendChild(document.createTextNode(listing.width));
+</script>
index 2aa97e551fffe809899df0641249871c87c03d7b..e7ea839c7e3c852ba3bea51a34a5490156eaa1d3 100644 (file)
@@ -1,3 +1,36 @@
+2006-03-21  Darin Adler  <darin@apple.com>
+
+        Reviewed by Tim O.
+
+        - fixed <rdar://problem/4251515> REGRESSION: listing tag broken in TOT
+
+        Test: fast/html/listing.html
+
+        * html/HTMLNames.h: Add listing tag.
+
+        * bindings/objc/DOM.mm: (+[DOMNode _nodeWith:]):
+        * bridge/mac/FrameMac.mm: (WebCore::FrameMac::attributedString):
+        * css/html4.css:
+        * editing/ReplaceSelectionCommand.cpp: (WebCore::isProbablyBlock):
+        * editing/TextIterator.cpp:
+        (WebCore::TextIterator::handleNonTextNode):
+        (WebCore::TextIterator::exitNode):
+        (WebCore::SimplifiedBackwardsTextIterator::handleNonTextNode):
+        * editing/markup.cpp:
+        (WebCore::startMarkup):
+        (WebCore::createMarkup):
+        * html/HTMLElement.cpp: (WebCore::blockTagList):
+        * html/HTMLElementFactory.cpp:
+        (WebCore::addTag):
+        (WebCore::createFunctionMap):
+        (WebCore::HTMLElementFactory::createHTMLElement):
+        * html/HTMLParser.cpp: (WebCore::HTMLParser::isAffectedByResidualStyle):
+        * html/HTMLTokenizer.cpp: (WebCore::HTMLTokenizer::parseTag):
+        * khtml/ecma/kjs_html.cpp:
+        (KJS::JSHTMLElement::classInfo):
+        (KJS::JSHTMLElement::accessors):
+        Add listing tags everywhere pre tags are listed.
+
 2006-03-21  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Darin.
index 1649b0e999b34668c7d5cb5b2ab69b985630671d..18ef81c2af9e1ff68aafc3f731358b77899efc60 100644 (file)
@@ -558,7 +558,7 @@ static ListenerMap *listenerMap;
                     wrapperClass = [DOMHTMLHeadingElement class];
                 else if (htmlElt->hasLocalName(qTag))
                     wrapperClass = [DOMHTMLQuoteElement class];
-                else if (htmlElt->hasLocalName(preTag))
+                else if (htmlElt->hasLocalName(preTag) || htmlElt->hasLocalName(listingTag))
                     wrapperClass = [DOMHTMLPreElement class];
                 else if (htmlElt->hasLocalName(brTag))
                     wrapperClass = [DOMHTMLBRElement class];
index 9e54d3e910de953ac402fde51a5fd8d3f8f37a08..fefe01c9dea2f582949e77b77b251503befd3a50 100644 (file)
@@ -2407,26 +2407,27 @@ NSAttributedString *FrameMac::attributedString(Node *_start, int startOffset, No
                     if (!hasNewLine)
                         text += "\n";
                     hasNewLine = true;
-                } else if (n->hasTagName(tdTag) ||
-                           n->hasTagName(thTag) ||
-                           n->hasTagName(hrTag) ||
-                           n->hasTagName(ddTag) ||
-                           n->hasTagName(dlTag) ||
-                           n->hasTagName(dtTag) ||
-                           n->hasTagName(preTag) ||
-                           n->hasTagName(blockquoteTag) ||
-                           n->hasTagName(divTag)) {
+                } else if (n->hasTagName(blockquoteTag)
+                        || n->hasTagName(ddTag)
+                        || n->hasTagName(divTag)
+                        || n->hasTagName(dlTag)
+                        || n->hasTagName(dtTag)
+                        || n->hasTagName(hrTag)
+                        || n->hasTagName(listingTag)
+                        || n->hasTagName(preTag)
+                        || n->hasTagName(tdTag)
+                        || n->hasTagName(thTag)) {
                     if (!hasNewLine)
                         text += '\n';
                     hasNewLine = true;
-                } else if (n->hasTagName(pTag) ||
-                           n->hasTagName(trTag) ||
-                           n->hasTagName(h1Tag) ||
-                           n->hasTagName(h2Tag) ||
-                           n->hasTagName(h3Tag) ||
-                           n->hasTagName(h4Tag) ||
-                           n->hasTagName(h5Tag) ||
-                           n->hasTagName(h6Tag)) {
+                } else if (n->hasTagName(h1Tag)
+                        || n->hasTagName(h2Tag)
+                        || n->hasTagName(h3Tag)
+                        || n->hasTagName(h4Tag)
+                        || n->hasTagName(h5Tag)
+                        || n->hasTagName(h6Tag)
+                        || n->hasTagName(pTag)
+                        || n->hasTagName(trTag)) {
                     if (!hasNewLine)
                         text += '\n';
                     
@@ -2509,15 +2510,16 @@ NSAttributedString *FrameMac::attributedString(Node *_start, int startOffset, No
                 if (!hasNewLine)
                     text += '\n';
                 hasNewLine = true;
-            } else if (n->hasTagName(tdTag) ||
-                       n->hasTagName(thTag) ||
-                       n->hasTagName(hrTag) ||
+            } else if (n->hasTagName(blockquoteTag) ||
                        n->hasTagName(ddTag) ||
+                       n->hasTagName(divTag) ||
                        n->hasTagName(dlTag) ||
                        n->hasTagName(dtTag) ||
+                       n->hasTagName(hrTag) ||
+                       n->hasTagName(listingTag) ||
                        n->hasTagName(preTag) ||
-                       n->hasTagName(blockquoteTag) ||
-                       n->hasTagName(divTag)) {
+                       n->hasTagName(tdTag) ||
+                       n->hasTagName(thTag)) {
                 if (!hasNewLine)
                     text += '\n';
                 hasNewLine = true;
index 976616aafbacc3d7684308fa5d1e886f3a3975ec..0eddd9e4f3ca6d2452fe6ca211a737aa651c6639 100644 (file)
@@ -381,7 +381,7 @@ tt, code, kbd, samp {
     font-family: monospace
 }
       
-pre, xmp, plaintext {
+pre, xmp, plaintext, listing {
     display: block;
     font-family: monospace;
     white-space: pre;
index d473c166ce0728d20ee4983aca16f018a4796316..383ca09d55f1ab2608910b4a118bf00b4d55e027 100644 (file)
@@ -167,19 +167,32 @@ Node *ReplacementFragment::lastChild() const
     return  m_fragment->lastChild(); 
 }
 
-static bool isProbablyBlock(const Node *node)
+static bool isProbablyBlock(const Nodenode)
 {
     if (!node)
         return false;
     
     // FIXME: This function seems really broken to me.  It isn't even including all the block-level elements.
-    return (node->hasTagName(blockquoteTag) || node->hasTagName(ddTag) || node->hasTagName(divTag) ||
-            node->hasTagName(dlTag) || node->hasTagName(dtTag) || node->hasTagName(h1Tag) ||
-            node->hasTagName(h2Tag) || node->hasTagName(h3Tag) || node->hasTagName(h4Tag) ||
-            node->hasTagName(h5Tag) || node->hasTagName(h6Tag) || node->hasTagName(hrTag) ||
-            node->hasTagName(liTag) || node->hasTagName(olTag) || node->hasTagName(pTag) ||
-            node->hasTagName(preTag) || node->hasTagName(tdTag) || node->hasTagName(thTag) ||
-            node->hasTagName(ulTag));
+    return node->hasTagName(blockquoteTag)
+        || node->hasTagName(ddTag)
+        || node->hasTagName(divTag)
+        || node->hasTagName(dlTag)
+        || node->hasTagName(dtTag)
+        || node->hasTagName(h1Tag)
+        || node->hasTagName(h2Tag)
+        || node->hasTagName(h3Tag)
+        || node->hasTagName(h4Tag)
+        || node->hasTagName(h5Tag)
+        || node->hasTagName(h6Tag)
+        || node->hasTagName(hrTag)
+        || node->hasTagName(liTag)
+        || node->hasTagName(listingTag)
+        || node->hasTagName(olTag)
+        || node->hasTagName(pTag)
+        || node->hasTagName(preTag)
+        || node->hasTagName(tdTag)
+        || node->hasTagName(thTag)
+        || node->hasTagName(ulTag);
 }
 
 static bool isMailPasteAsQuotationNode(const Node *node)
index b494727ea601ed9f4cbf6fcdc172d8057bfb268c..719fdfb26522783a505fde482c79b97eb77c1d4d 100644 (file)
@@ -359,16 +359,25 @@ bool TextIterator::handleNonTextNode()
     } else if (m_node->hasTagName(tdTag) || m_node->hasTagName(thTag)) {
         if (m_lastCharacter != '\n' && m_lastTextNode)
             emitCharacter('\t', m_lastTextNode->parentNode(), m_lastTextNode, 0, 1);
-    } else if (m_node->hasTagName(blockquoteTag) || m_node->hasTagName(ddTag) ||
-               m_node->hasTagName(divTag) ||
-               m_node->hasTagName(dlTag) || m_node->hasTagName(dtTag) || 
-               m_node->hasTagName(h1Tag) || m_node->hasTagName(h2Tag) ||
-               m_node->hasTagName(h3Tag) || m_node->hasTagName(h4Tag) ||
-               m_node->hasTagName(h5Tag) || m_node->hasTagName(h6Tag) ||
-               m_node->hasTagName(hrTag) || m_node->hasTagName(liTag) ||
-               m_node->hasTagName(olTag) || m_node->hasTagName(pTag) ||
-               m_node->hasTagName(preTag) || m_node->hasTagName(trTag) ||
-               m_node->hasTagName(ulTag)) {
+    } else if (m_node->hasTagName(blockquoteTag)
+                || m_node->hasTagName(ddTag)
+                || m_node->hasTagName(divTag)
+                || m_node->hasTagName(dlTag)
+                || m_node->hasTagName(dtTag)
+                || m_node->hasTagName(h1Tag)
+                || m_node->hasTagName(h2Tag)
+                || m_node->hasTagName(h3Tag)
+                || m_node->hasTagName(h4Tag)
+                || m_node->hasTagName(h5Tag)
+                || m_node->hasTagName(h6Tag)
+                || m_node->hasTagName(hrTag)
+                || m_node->hasTagName(liTag)
+                || m_node->hasTagName(listingTag)
+                || m_node->hasTagName(olTag)
+                || m_node->hasTagName(pTag)
+                || m_node->hasTagName(preTag) 
+                || m_node->hasTagName(trTag)
+                || m_node->hasTagName(ulTag)) {
         if (m_lastCharacter != '\n' && m_lastTextNode)
             emitCharacter('\n', m_lastTextNode->parentNode(), m_lastTextNode, 0, 1);
     }
@@ -381,18 +390,26 @@ void TextIterator::exitNode()
     bool endLine = false;
     bool addNewline = false;
 
-    if (m_node->hasTagName(blockquoteTag) || m_node->hasTagName(ddTag) ||
-               m_node->hasTagName(divTag) ||
-               m_node->hasTagName(dlTag) || m_node->hasTagName(dtTag) || 
-               m_node->hasTagName(hrTag) || m_node->hasTagName(liTag) ||
-               m_node->hasTagName(olTag) ||
-               m_node->hasTagName(preTag) || m_node->hasTagName(trTag) ||
-               m_node->hasTagName(ulTag))
+    if (m_node->hasTagName(blockquoteTag)
+            || m_node->hasTagName(ddTag)
+            || m_node->hasTagName(divTag)
+            || m_node->hasTagName(dlTag)
+            || m_node->hasTagName(dtTag)
+            || m_node->hasTagName(hrTag)
+            || m_node->hasTagName(liTag)
+            || m_node->hasTagName(listingTag)
+            || m_node->hasTagName(olTag)
+            || m_node->hasTagName(preTag)
+            || m_node->hasTagName(trTag)
+            || m_node->hasTagName(ulTag))
         endLine = true;
-    else if (m_node->hasTagName(h1Tag) || m_node->hasTagName(h2Tag) ||
-             m_node->hasTagName(h3Tag) || m_node->hasTagName(h4Tag) ||
-             m_node->hasTagName(h5Tag) || m_node->hasTagName(h6Tag) ||
-             m_node->hasTagName(pTag)) {
+    else if (m_node->hasTagName(h1Tag)
+            || m_node->hasTagName(h2Tag)
+            || m_node->hasTagName(h3Tag)
+            || m_node->hasTagName(h4Tag)
+            || m_node->hasTagName(h5Tag)
+            || m_node->hasTagName(h6Tag)
+            || m_node->hasTagName(pTag)) {
         endLine = true;
 
         // In certain cases, emit a new newline character for this node
@@ -641,17 +658,27 @@ bool SimplifiedBackwardsTextIterator::handleNonTextNode()
 {
     if (m_node->hasTagName(brTag))
         emitNewlineForBROrText();
-    else if (m_node->hasTagName(tdTag) || m_node->hasTagName(thTag) ||
-             m_node->hasTagName(blockquoteTag) || m_node->hasTagName(ddTag) ||
-             m_node->hasTagName(divTag) ||
-             m_node->hasTagName(dlTag) || m_node->hasTagName(dtTag) || 
-             m_node->hasTagName(h1Tag) || m_node->hasTagName(h2Tag) ||
-             m_node->hasTagName(h3Tag) || m_node->hasTagName(h4Tag) ||
-             m_node->hasTagName(h5Tag) || m_node->hasTagName(h6Tag) ||
-             m_node->hasTagName(hrTag) || m_node->hasTagName(liTag) ||
-             m_node->hasTagName(olTag) || m_node->hasTagName(pTag) ||
-             m_node->hasTagName(preTag) || m_node->hasTagName(trTag) ||
-             m_node->hasTagName(ulTag)) {
+    else if (m_node->hasTagName(blockquoteTag)
+            || m_node->hasTagName(ddTag)
+            || m_node->hasTagName(divTag)
+            || m_node->hasTagName(dlTag)
+            || m_node->hasTagName(dtTag)
+            || m_node->hasTagName(h1Tag)
+            || m_node->hasTagName(h2Tag)
+            || m_node->hasTagName(h3Tag)
+            || m_node->hasTagName(h4Tag)
+            || m_node->hasTagName(h5Tag)
+            || m_node->hasTagName(h6Tag)
+            || m_node->hasTagName(hrTag)
+            || m_node->hasTagName(liTag)
+            || m_node->hasTagName(listingTag)
+            || m_node->hasTagName(olTag)
+            || m_node->hasTagName(pTag)
+            || m_node->hasTagName(preTag)
+            || m_node->hasTagName(tdTag)
+            || m_node->hasTagName(thTag)
+            || m_node->hasTagName(trTag)
+            || m_node->hasTagName(ulTag)) {
         // Emit a space to "break up" content. Any word break
         // character will do.
         emitCharacter(' ', m_node, 0, 0);
index 4d37223097baab5ea62a55a825074e9a638605e6..9b95e86ea26f981a3155121e5a0aa7528891eabe 100644 (file)
@@ -150,14 +150,14 @@ static DeprecatedString renderedText(const Node *node, const Range *range)
 static DeprecatedString startMarkup(const Node *node, const Range *range, EAnnotateForInterchange annotate, CSSMutableStyleDeclaration *defaultStyle)
 {
     bool documentIsHTML = node->getDocument()->isHTMLDocument();
-    Node::NodeType type = node->nodeType();
-    switch (type) {
+    switch (node->nodeType()) {
         case Node::TEXT_NODE: {
-            if (node->parentNode()) {
-                if (node->parentNode()->hasTagName(preTag) ||
-                    node->parentNode()->hasTagName(scriptTag) ||
-                    node->parentNode()->hasTagName(styleTag) ||
-                    node->parentNode()->hasTagName(textareaTag))
+            if (Node* parent = node->parentNode()) {
+                if (parent->hasTagName(listingTag)
+                        || parent->hasTagName(preTag)
+                        || parent->hasTagName(scriptTag)
+                        || parent->hasTagName(styleTag)
+                        || parent->hasTagName(textareaTag))
                     return stringValueForRange(node, range).deprecatedString();
             }
             DeprecatedString markup = annotate ? escapeTextForMarkup(renderedText(node, range)) : escapeTextForMarkup(stringValueForRange(node, range).deprecatedString());            
@@ -193,44 +193,42 @@ static DeprecatedString startMarkup(const Node *node, const Range *range, EAnnot
             return static_cast<const ProcessingInstruction *>(node)->toString().deprecatedString();
         case Node::ELEMENT_NODE: {
             DeprecatedString markup = QChar('<') + node->nodeName().deprecatedString();
-            if (type == Node::ELEMENT_NODE) {
-                const Element *el = static_cast<const Element *>(node);
-                String additionalStyle;
-                if (defaultStyle && el->isHTMLElement()) {
-                    RefPtr<CSSComputedStyleDeclaration> computedStyle = Position(const_cast<Element *>(el), 0).computedStyle();
-                    RefPtr<CSSMutableStyleDeclaration> style = computedStyle->copyInheritableProperties();
-                    defaultStyle->diff(style.get());
-                    if (style->length() > 0) {
-                        CSSMutableStyleDeclaration *inlineStyleDecl = static_cast<const HTMLElement *>(el)->inlineStyleDecl();
-                        if (inlineStyleDecl)
-                            inlineStyleDecl->diff(style.get());
-                        additionalStyle = style->cssText();
-                    }
-                }
-                NamedAttrMap *attrs = el->attributes();
-                unsigned length = attrs->length();
-                if (length == 0 && additionalStyle.length() > 0) {
-                    // FIXME: Handle case where additionalStyle has illegal characters in it, like "
-                    markup += " " +  styleAttr.localName().deprecatedString() + "=\"" + additionalStyle.deprecatedString() + "\"";
+            const Element* el = static_cast<const Element*>(node);
+            String additionalStyle;
+            if (defaultStyle && el->isHTMLElement()) {
+                RefPtr<CSSComputedStyleDeclaration> computedStyle = Position(const_cast<Element *>(el), 0).computedStyle();
+                RefPtr<CSSMutableStyleDeclaration> style = computedStyle->copyInheritableProperties();
+                defaultStyle->diff(style.get());
+                if (style->length() > 0) {
+                    CSSMutableStyleDeclaration *inlineStyleDecl = static_cast<const HTMLElement *>(el)->inlineStyleDecl();
+                    if (inlineStyleDecl)
+                        inlineStyleDecl->diff(style.get());
+                    additionalStyle = style->cssText();
                 }
-                else {
-                    for (unsigned int i=0; i<length; i++) {
-                        Attribute *attr = attrs->attributeItem(i);
-                        String value = attr->value();
-                        if (attr->name() == styleAttr && additionalStyle.length() > 0)
-                            value += "; " + additionalStyle;
-                        // FIXME: Handle case where value has illegal characters in it, like "
-                        if (documentIsHTML)
-                            markup += " " + attr->name().localName().deprecatedString();
-                        else
-                            markup += " " + attr->name().toString().deprecatedString();
-                        markup += "=\"" + escapeTextForMarkup(value.deprecatedString()) + "\"";
-                    }
+            }
+            NamedAttrMap *attrs = el->attributes();
+            unsigned length = attrs->length();
+            if (length == 0 && additionalStyle.length() > 0) {
+                // FIXME: Handle case where additionalStyle has illegal characters in it, like "
+                markup += " " +  styleAttr.localName().deprecatedString() + "=\"" + additionalStyle.deprecatedString() + "\"";
+            }
+            else {
+                for (unsigned int i=0; i<length; i++) {
+                    Attribute *attr = attrs->attributeItem(i);
+                    String value = attr->value();
+                    if (attr->name() == styleAttr && additionalStyle.length() > 0)
+                        value += "; " + additionalStyle;
+                    // FIXME: Handle case where value has illegal characters in it, like "
+                    if (documentIsHTML)
+                        markup += " " + attr->name().localName().deprecatedString();
+                    else
+                        markup += " " + attr->name().toString().deprecatedString();
+                    markup += "=\"" + escapeTextForMarkup(value.deprecatedString()) + "\"";
                 }
             }
             
-            if (shouldSelfClose(node)) {
-                if (node->isHTMLElement())
+            if (shouldSelfClose(el)) {
+                if (el->isHTMLElement())
                     markup += " "; // XHTML 1.0 <-> HTML compatibility.
                 markup += "/>";
             } else
@@ -437,8 +435,11 @@ DeprecatedString createMarkup(const Range *range, DeprecatedPtrList<Node> *nodes
             bool breakAtEnd = false;
             if (commonAncestorBlock == ancestor) {
                 // Include ancestors that are required to retain the appearance of the copied markup.
-                if (ancestor->hasTagName(preTag) || ancestor->hasTagName(tableTag) ||
-                    ancestor->hasTagName(olTag) || ancestor->hasTagName(ulTag)) {
+                if (ancestor->hasTagName(listingTag)
+                        || ancestor->hasTagName(olTag)
+                        || ancestor->hasTagName(preTag)
+                        || ancestor->hasTagName(tableTag)
+                        || ancestor->hasTagName(ulTag)) {
                     breakAtEnd = true;
                 } else {
                     break;
index d3017dc0efe16072886d8c30f268de8df23e22ef..2f7f959b49c8a626d40cb44544d4d8995f2a2f57 100644 (file)
@@ -698,39 +698,40 @@ HashSet<AtomicStringImpl*>* blockTagList()
 {
     static HashSet<AtomicStringImpl*> tagList;
     if (tagList.isEmpty()) {
-        tagList.add(pTag.localName().impl());
+        tagList.add(addressTag.localName().impl());
+        tagList.add(blockquoteTag.localName().impl());
+        tagList.add(centerTag.localName().impl());
+        tagList.add(ddTag.localName().impl());
+        tagList.add(dirTag.localName().impl());
+        tagList.add(divTag.localName().impl());
+        tagList.add(dlTag.localName().impl());
+        tagList.add(dtTag.localName().impl());
+        tagList.add(fieldsetTag.localName().impl());
+        tagList.add(formTag.localName().impl());
         tagList.add(h1Tag.localName().impl());
         tagList.add(h2Tag.localName().impl());
         tagList.add(h3Tag.localName().impl());
         tagList.add(h4Tag.localName().impl());
         tagList.add(h5Tag.localName().impl());
         tagList.add(h6Tag.localName().impl());
-        tagList.add(ulTag.localName().impl());
-        tagList.add(olTag.localName().impl());
-        tagList.add(dirTag.localName().impl());
-        tagList.add(menuTag.localName().impl());
-        tagList.add(preTag.localName().impl());
-        tagList.add(plaintextTag.localName().impl());
-        tagList.add(xmpTag.localName().impl());
-        tagList.add(dlTag.localName().impl());
-        tagList.add(divTag.localName().impl());
+        tagList.add(hrTag.localName().impl());
+        tagList.add(isindexTag.localName().impl());
         tagList.add(layerTag.localName().impl());
-        tagList.add(centerTag.localName().impl());
-        tagList.add(noscriptTag.localName().impl());
-        tagList.add(noframesTag.localName().impl());
+        tagList.add(liTag.localName().impl());
+        tagList.add(listingTag.localName().impl());
+        tagList.add(marqueeTag.localName().impl());
+        tagList.add(menuTag.localName().impl());
         tagList.add(noembedTag.localName().impl());
+        tagList.add(noframesTag.localName().impl());
         tagList.add(nolayerTag.localName().impl());
-        tagList.add(blockquoteTag.localName().impl());
-        tagList.add(formTag.localName().impl());
-        tagList.add(isindexTag.localName().impl());
-        tagList.add(hrTag.localName().impl());
+        tagList.add(noscriptTag.localName().impl());
+        tagList.add(olTag.localName().impl());
+        tagList.add(pTag.localName().impl());
+        tagList.add(plaintextTag.localName().impl());
+        tagList.add(preTag.localName().impl());
         tagList.add(tableTag.localName().impl());
-        tagList.add(fieldsetTag.localName().impl());
-        tagList.add(addressTag.localName().impl());
-        tagList.add(liTag.localName().impl());
-        tagList.add(ddTag.localName().impl());
-        tagList.add(dtTag.localName().impl());
-        tagList.add(marqueeTag.localName().impl());
+        tagList.add(ulTag.localName().impl());
+        tagList.add(xmpTag.localName().impl());
     }
     return &tagList;
 }
index d5b4fe7784d07dd78172b0a6257dd7eb6fbabe8e..899ebd867790f76fbe1f75673370459dd17e2c48 100644 (file)
 #include "config.h"
 #include "HTMLElementFactory.h"
 
-#include "html_baseimpl.h"
-#include "html_blockimpl.h"
+#include "HTMLBaseFontElement.h"
+#include "HTMLButtonElement.h"
 #include "HTMLCanvasElement.h"
-#include "HTMLDocument.h"
-#include "html_headimpl.h"
-#include "html_imageimpl.h"
-#include "html_listimpl.h"
-#include "html_tableimpl.h"
-#include "html_objectimpl.h"
-
 #include "HTMLCollection.h"
+#include "HTMLDocument.h"
+#include "HTMLFieldSetElement.h"
 #include "HTMLFormElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLIsIndexElement.h"
-#include "HTMLFieldSetElement.h"
 #include "HTMLLabelElement.h"
 #include "HTMLLegendElement.h"
-#include "HTMLButtonElement.h"
-#include "HTMLOptionElement.h"
 #include "HTMLOptGroupElement.h"
+#include "HTMLOptionElement.h"
 #include "HTMLSelectElement.h"
 #include "HTMLTextAreaElement.h"
-#include "HTMLBaseFontElement.h"
-
+#include "html_baseimpl.h"
+#include "html_blockimpl.h"
+#include "html_headimpl.h"
+#include "html_imageimpl.h"
+#include "html_listimpl.h"
+#include "html_objectimpl.h"
+#include "html_tableimpl.h"
 #include <kxmlcore/HashMap.h>
 
-namespace WebCore
-{
+namespace WebCore {
 
 using namespace HTMLNames;
 
@@ -342,85 +339,95 @@ PassRefPtr<HTMLElement> marqueeConstructor(const AtomicString& tagName, Document
     return new HTMLMarqueeElement(docPtr);
 }
 
+static void addTag(const QualifiedName& tag, ConstructorFunc func)
+{
+    gFunctionMap->set(tag.localName().impl(), func);
+}
+
+static void createFunctionMap()
+{
+    // Create the table.
+    gFunctionMap = new FunctionMap;
+    
+    // Populate it with constructor functions.
+    addTag(aTag, anchorConstructor);
+    addTag(appletTag, appletConstructor);
+    addTag(areaTag, areaConstructor);
+    addTag(baseTag, baseConstructor);
+    addTag(basefontTag, basefontConstructor);
+    addTag(blockquoteTag, blockquoteConstructor);
+    addTag(bodyTag, bodyConstructor);
+    addTag(brTag, brConstructor);
+    addTag(buttonTag, buttonConstructor);
+    addTag(canvasTag, canvasConstructor);
+    addTag(captionTag, tableCaptionConstructor);
+    addTag(colTag, tableColConstructor);
+    addTag(colgroupTag, tableColConstructor);
+    addTag(delTag, modConstructor);
+    addTag(dirTag, dirConstructor);
+    addTag(divTag, divConstructor);
+    addTag(dlTag, dlConstructor);
+    addTag(embedTag, embedConstructor);
+    addTag(fieldsetTag, fieldsetConstructor);
+    addTag(fontTag, fontConstructor);
+    addTag(formTag, formConstructor);
+    addTag(frameTag, frameConstructor);
+    addTag(framesetTag, framesetConstructor);
+    addTag(h1Tag, headingConstructor);
+    addTag(h2Tag, headingConstructor);
+    addTag(h3Tag, headingConstructor);
+    addTag(h4Tag, headingConstructor);
+    addTag(h5Tag, headingConstructor);
+    addTag(h6Tag, headingConstructor);
+    addTag(headTag, headConstructor);
+    addTag(hrTag, hrConstructor);
+    addTag(htmlTag, htmlConstructor);
+    addTag(iframeTag, iframeConstructor);
+    addTag(imageTag, imageConstructor);
+    addTag(imgTag, imageConstructor);
+    addTag(inputTag, inputConstructor);
+    addTag(insTag, modConstructor);
+    addTag(isindexTag, isindexConstructor);
+    addTag(labelTag, labelConstructor);
+    addTag(legendTag, legendConstructor);
+    addTag(liTag, liConstructor);
+    addTag(linkTag, linkConstructor);
+    addTag(listingTag, preConstructor);
+    addTag(mapTag, mapConstructor);
+    addTag(marqueeTag, marqueeConstructor);
+    addTag(menuTag, menuConstructor);
+    addTag(metaTag, metaConstructor);
+    addTag(objectTag, objectConstructor);
+    addTag(olTag, olConstructor);
+    addTag(optgroupTag, optgroupConstructor);
+    addTag(optionTag, optionConstructor);
+    addTag(pTag, paragraphConstructor);
+    addTag(paramTag, paramConstructor);
+    addTag(preTag, preConstructor);
+    addTag(qTag, quoteConstructor);
+    addTag(scriptTag, scriptConstructor);
+    addTag(selectTag, selectConstructor);
+    addTag(styleTag, styleConstructor);
+    addTag(tableTag, tableConstructor);
+    addTag(tbodyTag, tableSectionConstructor);
+    addTag(tdTag, tableCellConstructor);
+    addTag(textareaTag, textareaConstructor);
+    addTag(tfootTag, tableSectionConstructor);
+    addTag(thTag, tableCellConstructor);
+    addTag(theadTag, tableSectionConstructor);
+    addTag(titleTag, titleConstructor);
+    addTag(trTag, tableRowConstructor);
+    addTag(ulTag, ulConstructor);
+    addTag(xmpTag, preConstructor);
+}
+
 PassRefPtr<HTMLElement> HTMLElementFactory::createHTMLElement(const AtomicString& tagName, Document* doc, HTMLFormElement* form, bool createdByParser)
 {
     if (!doc)
         return 0; // Don't allow elements to ever be made without having a doc.
 
-    if (!gFunctionMap) {
-        // Create the table.
-        gFunctionMap = new FunctionMap;
-        
-        // Populate it with constructor functions.
-        gFunctionMap->set(htmlTag.localName().impl(), htmlConstructor);
-        gFunctionMap->set(headTag.localName().impl(), headConstructor);
-        gFunctionMap->set(bodyTag.localName().impl(), bodyConstructor);
-        gFunctionMap->set(baseTag.localName().impl(), baseConstructor);
-        gFunctionMap->set(linkTag.localName().impl(), linkConstructor);
-        gFunctionMap->set(metaTag.localName().impl(), metaConstructor);
-        gFunctionMap->set(styleTag.localName().impl(), styleConstructor);
-        gFunctionMap->set(titleTag.localName().impl(), titleConstructor);
-        gFunctionMap->set(frameTag.localName().impl(), frameConstructor);
-        gFunctionMap->set(framesetTag.localName().impl(), framesetConstructor);
-        gFunctionMap->set(iframeTag.localName().impl(), iframeConstructor);
-        gFunctionMap->set(formTag.localName().impl(), formConstructor);
-        gFunctionMap->set(buttonTag.localName().impl(), buttonConstructor);
-        gFunctionMap->set(inputTag.localName().impl(), inputConstructor);
-        gFunctionMap->set(isindexTag.localName().impl(), isindexConstructor);
-        gFunctionMap->set(fieldsetTag.localName().impl(), fieldsetConstructor);
-        gFunctionMap->set(labelTag.localName().impl(), labelConstructor);
-        gFunctionMap->set(legendTag.localName().impl(), legendConstructor);
-        gFunctionMap->set(optgroupTag.localName().impl(), optgroupConstructor);
-        gFunctionMap->set(optionTag.localName().impl(), optionConstructor);
-        gFunctionMap->set(selectTag.localName().impl(), selectConstructor);
-        gFunctionMap->set(textareaTag.localName().impl(), textareaConstructor);
-        gFunctionMap->set(dlTag.localName().impl(), dlConstructor);
-        gFunctionMap->set(olTag.localName().impl(), olConstructor);
-        gFunctionMap->set(ulTag.localName().impl(), ulConstructor);
-        gFunctionMap->set(dirTag.localName().impl(), dirConstructor);
-        gFunctionMap->set(menuTag.localName().impl(), menuConstructor);
-        gFunctionMap->set(liTag.localName().impl(), liConstructor);
-        gFunctionMap->set(blockquoteTag.localName().impl(), blockquoteConstructor);
-        gFunctionMap->set(divTag.localName().impl(), divConstructor);
-        gFunctionMap->set(h1Tag.localName().impl(), headingConstructor);
-        gFunctionMap->set(h2Tag.localName().impl(), headingConstructor);
-        gFunctionMap->set(h3Tag.localName().impl(), headingConstructor);
-        gFunctionMap->set(h4Tag.localName().impl(), headingConstructor);
-        gFunctionMap->set(h5Tag.localName().impl(), headingConstructor);
-        gFunctionMap->set(h6Tag.localName().impl(), headingConstructor);
-        gFunctionMap->set(hrTag.localName().impl(), hrConstructor);
-        gFunctionMap->set(pTag.localName().impl(), paragraphConstructor);
-        gFunctionMap->set(preTag.localName().impl(), preConstructor);
-        gFunctionMap->set(xmpTag.localName().impl(), preConstructor);
-        gFunctionMap->set(basefontTag.localName().impl(), basefontConstructor);
-        gFunctionMap->set(fontTag.localName().impl(), fontConstructor);
-        gFunctionMap->set(delTag.localName().impl(), modConstructor);
-        gFunctionMap->set(insTag.localName().impl(), modConstructor);
-        gFunctionMap->set(aTag.localName().impl(), anchorConstructor);
-        gFunctionMap->set(imageTag.localName().impl(), imageConstructor);
-        gFunctionMap->set(imgTag.localName().impl(), imageConstructor);
-        gFunctionMap->set(mapTag.localName().impl(), mapConstructor);
-        gFunctionMap->set(areaTag.localName().impl(), areaConstructor);
-        gFunctionMap->set(canvasTag.localName().impl(), canvasConstructor);
-        gFunctionMap->set(appletTag.localName().impl(), appletConstructor);
-        gFunctionMap->set(embedTag.localName().impl(), embedConstructor);
-        gFunctionMap->set(objectTag.localName().impl(), objectConstructor);
-        gFunctionMap->set(paramTag.localName().impl(), paramConstructor);
-        gFunctionMap->set(scriptTag.localName().impl(), scriptConstructor);
-        gFunctionMap->set(tableTag.localName().impl(), tableConstructor);
-        gFunctionMap->set(captionTag.localName().impl(), tableCaptionConstructor);
-        gFunctionMap->set(colgroupTag.localName().impl(), tableColConstructor);
-        gFunctionMap->set(colTag.localName().impl(), tableColConstructor);
-        gFunctionMap->set(trTag.localName().impl(), tableRowConstructor);
-        gFunctionMap->set(tdTag.localName().impl(), tableCellConstructor);
-        gFunctionMap->set(thTag.localName().impl(), tableCellConstructor);
-        gFunctionMap->set(theadTag.localName().impl(), tableSectionConstructor);
-        gFunctionMap->set(tbodyTag.localName().impl(), tableSectionConstructor);
-        gFunctionMap->set(tfootTag.localName().impl(), tableSectionConstructor);
-        gFunctionMap->set(brTag.localName().impl(), brConstructor);
-        gFunctionMap->set(qTag.localName().impl(), quoteConstructor);
-        gFunctionMap->set(marqueeTag.localName().impl(), marqueeConstructor);
-    }
+    if (!gFunctionMap)
+        createFunctionMap();
     
     ConstructorFunc func = gFunctionMap->get(tagName.impl());
     if (func)
index b6aef785230d5dd6fd2cedf34947e6bc4d8a4f75..b6f0388707021f30be82b302db32364807db71be 100644 (file)
@@ -86,6 +86,7 @@ namespace WebCore { namespace HTMLNames {
     macro(legend) \
     macro(li) \
     macro(link) \
+    macro(listing) \
     macro(map) \
     macro(marquee) \
     macro(menu) \
index 4500ee93b1d98d9aa43d69c4187a2296cdb1ecec..446687c9302ee29a652913853a85426076e67424 100644 (file)
@@ -919,25 +919,26 @@ bool HTMLParser::isAffectedByResidualStyle(const AtomicString& tagName)
 
     static HashSet<AtomicStringImpl*> affectedBlockTags;
     if (affectedBlockTags.isEmpty()) {
+        affectedBlockTags.add(addressTag.localName().impl());
+        affectedBlockTags.add(blockquoteTag.localName().impl());
+        affectedBlockTags.add(centerTag.localName().impl());
+        affectedBlockTags.add(ddTag.localName().impl());
+        affectedBlockTags.add(divTag.localName().impl());
+        affectedBlockTags.add(dlTag.localName().impl());
+        affectedBlockTags.add(dtTag.localName().impl());
+        affectedBlockTags.add(formTag.localName().impl());
         affectedBlockTags.add(h1Tag.localName().impl());
         affectedBlockTags.add(h2Tag.localName().impl());
         affectedBlockTags.add(h3Tag.localName().impl());
         affectedBlockTags.add(h4Tag.localName().impl());
         affectedBlockTags.add(h5Tag.localName().impl());
         affectedBlockTags.add(h6Tag.localName().impl());
-        affectedBlockTags.add(pTag.localName().impl());
-        affectedBlockTags.add(divTag.localName().impl());
-        affectedBlockTags.add(blockquoteTag.localName().impl());
-        affectedBlockTags.add(addressTag.localName().impl());
-        affectedBlockTags.add(centerTag.localName().impl());
-        affectedBlockTags.add(ulTag.localName().impl());
-        affectedBlockTags.add(olTag.localName().impl());
         affectedBlockTags.add(liTag.localName().impl());
-        affectedBlockTags.add(dlTag.localName().impl());
-        affectedBlockTags.add(dtTag.localName().impl());
-        affectedBlockTags.add(ddTag.localName().impl());
+        affectedBlockTags.add(listingTag.localName().impl());
+        affectedBlockTags.add(olTag.localName().impl());
+        affectedBlockTags.add(pTag.localName().impl());
         affectedBlockTags.add(preTag.localName().impl());
-        affectedBlockTags.add(formTag.localName().impl());
+        affectedBlockTags.add(ulTag.localName().impl());
     }
     
     return affectedBlockTags.contains(tagName.impl());
index 3662a3b13563c9e5b450237fcfa527d2109f99f3..53d7cf469c6af04a9867dc6066685bca4a26f2ff 100644 (file)
@@ -1232,7 +1232,7 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString &src, State state)
 
             RefPtr<Node> n = processToken();
 
-            if (tagName == preTag) {
+            if (tagName == preTag || tagName == listingTag) {
                 if (beginTag)
                     state.setDiscardLF(true); // Discard the first LF after we open a pre.
             } else if (tagName == scriptTag) {
index dd561913adc00073974230be1738c3d226eeb800..7c27a1611dec1eacbd1c012447a62a67e07aedfc 100644 (file)
@@ -526,6 +526,7 @@ const ClassInfo* JSHTMLElement::classInfo() const
         classInfoMap.set(legendTag.localName().impl(), &legend_info);
         classInfoMap.set(liTag.localName().impl(), &li_info);
         classInfoMap.set(linkTag.localName().impl(), &link_info);
+        classInfoMap.set(listingTag.localName().impl(), &pre_info);
         classInfoMap.set(mapTag.localName().impl(), &map_info);
         classInfoMap.set(marqueeTag.localName().impl(), &marquee_info);
         classInfoMap.set(menuTag.localName().impl(), &menu_info);
@@ -661,6 +662,7 @@ const JSHTMLElement::Accessors* JSHTMLElement::accessors() const
         accessorMap.add(legendTag.localName().impl(), &legend_accessors);
         accessorMap.add(liTag.localName().impl(), &li_accessors);
         accessorMap.add(linkTag.localName().impl(), &link_accessors);
+        accessorMap.set(listingTag.localName().impl(), &pre_accessors);
         accessorMap.add(mapTag.localName().impl(), &map_accessors);
         accessorMap.add(marqueeTag.localName().impl(), &marquee_accessors);
         accessorMap.add(menuTag.localName().impl(), &menu_accessors);