Title: [115149] trunk/Source/WebCore
Revision
115149
Author
[email protected]
Date
2012-04-24 17:47:16 -0700 (Tue, 24 Apr 2012)

Log Message

Unreviewed, rolling out r115099, r115102, and r115127.
http://trac.webkit.org/changeset/115099
http://trac.webkit.org/changeset/115102
http://trac.webkit.org/changeset/115127
https://bugs.webkit.org/show_bug.cgi?id=84809

Made html5lib/runner.html crash, spot fix didn't help so
rolling out so original author can do over. (Requested by
kling on #webkit).

Patch by Sheriff Bot <[email protected]> on 2012-04-24

* dom/Element.cpp:
(WebCore::Element::parserSetAttributes):
(WebCore::Element::normalizeAttributes):
* dom/Element.h:
(Element):
* dom/ElementAttributeData.cpp:
(WebCore::AttributeVector::removeAttribute):
(WebCore):
* dom/ElementAttributeData.h:
(AttributeVector):
(WebCore::AttributeVector::AttributeVector):
(WebCore):
(WebCore::AttributeVector::getAttributeItem):
(WebCore::AttributeVector::getAttributeItemIndex):
(WebCore::AttributeVector::insertAttribute):
(WebCore::ElementAttributeData::getAttributeItem):
(WebCore::ElementAttributeData::getAttributeItemIndex):
(WebCore::ElementAttributeData::attributeVector):
(WebCore::ElementAttributeData::clonedAttributeVector):
(ElementAttributeData):
* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::createHTMLElementFromSavedElement):
* html/parser/HTMLToken.h:
(WebCore::AtomicHTMLToken::AtomicHTMLToken):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::processFakeStartTag):
(WebCore::HTMLTreeBuilder::attributesForIsindexInput):
* html/parser/HTMLTreeBuilder.h:
* html/parser/TextDocumentParser.cpp:
(WebCore::TextDocumentParser::insertFakePreElement):
* xml/XMLErrors.cpp:
(WebCore::createXHTMLParserErrorHeader):
(WebCore::XMLErrors::insertErrorMessageBlock):
* xml/parser/MarkupTokenBase.h:
(WebCore::AtomicMarkupTokenBase::AtomicMarkupTokenBase):
(WebCore::AtomicMarkupTokenBase::getAttributeItem):
(WebCore::AtomicMarkupTokenBase::attributes):
(AtomicMarkupTokenBase):
(WebCore::::initializeAttributes):
* xml/parser/XMLToken.h:
(WebCore::AtomicXMLToken::AtomicXMLToken):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (115148 => 115149)


--- trunk/Source/WebCore/ChangeLog	2012-04-25 00:43:31 UTC (rev 115148)
+++ trunk/Source/WebCore/ChangeLog	2012-04-25 00:47:16 UTC (rev 115149)
@@ -1,3 +1,57 @@
+2012-04-24  Sheriff Bot  <[email protected]>
+
+        Unreviewed, rolling out r115099, r115102, and r115127.
+        http://trac.webkit.org/changeset/115099
+        http://trac.webkit.org/changeset/115102
+        http://trac.webkit.org/changeset/115127
+        https://bugs.webkit.org/show_bug.cgi?id=84809
+
+        Made html5lib/runner.html crash, spot fix didn't help so
+        rolling out so original author can do over. (Requested by
+        kling on #webkit).
+
+        * dom/Element.cpp:
+        (WebCore::Element::parserSetAttributes):
+        (WebCore::Element::normalizeAttributes):
+        * dom/Element.h:
+        (Element):
+        * dom/ElementAttributeData.cpp:
+        (WebCore::AttributeVector::removeAttribute):
+        (WebCore):
+        * dom/ElementAttributeData.h:
+        (AttributeVector):
+        (WebCore::AttributeVector::AttributeVector):
+        (WebCore):
+        (WebCore::AttributeVector::getAttributeItem):
+        (WebCore::AttributeVector::getAttributeItemIndex):
+        (WebCore::AttributeVector::insertAttribute):
+        (WebCore::ElementAttributeData::getAttributeItem):
+        (WebCore::ElementAttributeData::getAttributeItemIndex):
+        (WebCore::ElementAttributeData::attributeVector):
+        (WebCore::ElementAttributeData::clonedAttributeVector):
+        (ElementAttributeData):
+        * html/parser/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::createHTMLElementFromSavedElement):
+        * html/parser/HTMLToken.h:
+        (WebCore::AtomicHTMLToken::AtomicHTMLToken):
+        * html/parser/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processFakeStartTag):
+        (WebCore::HTMLTreeBuilder::attributesForIsindexInput):
+        * html/parser/HTMLTreeBuilder.h:
+        * html/parser/TextDocumentParser.cpp:
+        (WebCore::TextDocumentParser::insertFakePreElement):
+        * xml/XMLErrors.cpp:
+        (WebCore::createXHTMLParserErrorHeader):
+        (WebCore::XMLErrors::insertErrorMessageBlock):
+        * xml/parser/MarkupTokenBase.h:
+        (WebCore::AtomicMarkupTokenBase::AtomicMarkupTokenBase):
+        (WebCore::AtomicMarkupTokenBase::getAttributeItem):
+        (WebCore::AtomicMarkupTokenBase::attributes):
+        (AtomicMarkupTokenBase):
+        (WebCore::::initializeAttributes):
+        * xml/parser/XMLToken.h:
+        (WebCore::AtomicXMLToken::AtomicXMLToken):
+
 2012-04-24  Jeffrey Pfau  <[email protected]>
 
         Prevent drag and drop from setting file URLs

Modified: trunk/Source/WebCore/dom/Element.cpp (115148 => 115149)


--- trunk/Source/WebCore/dom/Element.cpp	2012-04-25 00:43:31 UTC (rev 115148)
+++ trunk/Source/WebCore/dom/Element.cpp	2012-04-25 00:47:16 UTC (rev 115149)
@@ -760,7 +760,7 @@
     return (name.localName().endsWith(hrefAttr.localName()) || name == srcAttr || name == actionAttr) && protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(value));       
 }
 
-void Element::parserSetAttributes(const Vector<Attribute>& attributeVector, FragmentScriptingPermission scriptingPermission)
+void Element::parserSetAttributes(const AttributeVector& attributeVector, FragmentScriptingPermission scriptingPermission)
 {
     ASSERT(!inDocument());
     ASSERT(!parentNode());
@@ -793,7 +793,7 @@
 
     // Store the set of attributes that changed on the stack in case
     // attributeChanged mutates m_attributeData.
-    Vector<Attribute> clonedAttributes = m_attributeData->clonedAttributeVector();
+    AttributeVector clonedAttributes = m_attributeData->clonedAttributeVector();
     for (unsigned i = 0; i < clonedAttributes.size(); ++i)
         attributeChanged(&clonedAttributes[i]);
 }
@@ -1737,7 +1737,7 @@
     if (!attributeData || attributeData->isEmpty())
         return;
 
-    const Vector<Attribute>& attributes = attributeData->attributeVector();
+    const AttributeVector& attributes = attributeData->attributeVector();
     for (size_t i = 0; i < attributes.size(); ++i) {
         if (RefPtr<Attr> attr = attrIfExists(attributes[i].name()))
             attr->normalize();

Modified: trunk/Source/WebCore/dom/Element.h (115148 => 115149)


--- trunk/Source/WebCore/dom/Element.h	2012-04-25 00:43:31 UTC (rev 115148)
+++ trunk/Source/WebCore/dom/Element.h	2012-04-25 00:47:16 UTC (rev 115149)
@@ -244,7 +244,7 @@
     virtual void attributeChanged(Attribute*);
 
     // Only called by the parser immediately after element construction.
-    void parserSetAttributes(const Vector<Attribute>&, FragmentScriptingPermission);
+    void parserSetAttributes(const AttributeVector&, FragmentScriptingPermission);
 
     ElementAttributeData* attributeData() const { return m_attributeData.get(); }
     ElementAttributeData* ensureAttributeData() const;

Modified: trunk/Source/WebCore/dom/ElementAttributeData.cpp (115148 => 115149)


--- trunk/Source/WebCore/dom/ElementAttributeData.cpp	2012-04-25 00:43:31 UTC (rev 115148)
+++ trunk/Source/WebCore/dom/ElementAttributeData.cpp	2012-04-25 00:47:16 UTC (rev 115149)
@@ -71,6 +71,15 @@
     --m_attrCount;
 }
 
+void AttributeVector::removeAttribute(const QualifiedName& name)
+{
+    size_t index = getAttributeItemIndex(name);
+    if (index == notFound)
+        return;
+
+    remove(index);
+}
+
 ElementAttributeData::~ElementAttributeData()
 {
 }

Modified: trunk/Source/WebCore/dom/ElementAttributeData.h (115148 => 115149)


--- trunk/Source/WebCore/dom/ElementAttributeData.h	2012-04-25 00:43:31 UTC (rev 115148)
+++ trunk/Source/WebCore/dom/ElementAttributeData.h	2012-04-25 00:47:16 UTC (rev 115149)
@@ -36,15 +36,41 @@
 class Attr;
 class Element;
 
-inline Attribute* findAttributeInVector(const Vector<Attribute>& attributes, const QualifiedName& name)
+class AttributeVector : public Vector<Attribute> {
+public:
+    AttributeVector() { }
+
+    Attribute* getAttributeItem(const QualifiedName&) const;
+    size_t getAttributeItemIndex(const QualifiedName&) const;
+
+    // Used during parsing: only inserts if not already there.
+    void insertAttribute(const Attribute&);
+    void removeAttribute(const QualifiedName&);
+};
+
+inline Attribute* AttributeVector::getAttributeItem(const QualifiedName& name) const
 {
-    for (unsigned i = 0; i < attributes.size(); ++i) {
-        if (attributes.at(i).name().matches(name))
-            return &const_cast<Vector<Attribute>& >(attributes).at(i);
-    }
+    size_t index = getAttributeItemIndex(name);
+    if (index != notFound)
+        return &const_cast<AttributeVector*>(this)->at(index);
     return 0;
 }
 
+inline size_t AttributeVector::getAttributeItemIndex(const QualifiedName& name) const
+{
+    for (unsigned i = 0; i < size(); ++i) {
+        if (at(i).name().matches(name))
+            return i;
+    }
+    return notFound;
+}
+
+inline void AttributeVector::insertAttribute(const Attribute& newAttribute)
+{
+    if (!getAttributeItem(newAttribute.name()))
+        append(newAttribute);
+}
+
 enum EInUpdateStyleAttribute { NotInUpdateStyleAttribute, InUpdateStyleAttribute };
 
 class ElementAttributeData {
@@ -81,8 +107,8 @@
 
     // Internal interface.
     Attribute* attributeItem(unsigned index) const { return &const_cast<ElementAttributeData*>(this)->m_attributes[index]; }
-    Attribute* getAttributeItem(const QualifiedName& name) const { return findAttributeInVector(m_attributes, name); }
-    size_t getAttributeItemIndex(const QualifiedName&) const;
+    Attribute* getAttributeItem(const QualifiedName& name) const { return m_attributes.getAttributeItem(name); }
+    size_t getAttributeItemIndex(const QualifiedName& name) const { return m_attributes.getAttributeItemIndex(name); }
     size_t getAttributeItemIndex(const String& name, bool shouldIgnoreAttributeCase) const;
 
     // These functions do no error checking.
@@ -110,8 +136,8 @@
     {
     }
 
-    const Vector<Attribute>& attributeVector() const { return m_attributes; }
-    Vector<Attribute> clonedAttributeVector() const { return m_attributes; }
+    const AttributeVector& attributeVector() const { return m_attributes; }
+    AttributeVector clonedAttributeVector() const { return m_attributes; }
 
     void detachAttributesFromElement(Element*);
     Attribute* getAttributeItem(const String& name, bool shouldIgnoreAttributeCase) const;
@@ -124,7 +150,7 @@
     RefPtr<StylePropertySet> m_attributeStyle;
     SpaceSplitString m_classNames;
     AtomicString m_idForStyleResolution;
-    Vector<Attribute> m_attributes;
+    AttributeVector m_attributes;
 
     unsigned m_attrCount;
 };
@@ -147,15 +173,6 @@
     return 0;
 }
 
-inline size_t ElementAttributeData::getAttributeItemIndex(const QualifiedName& name) const
-{
-    for (unsigned i = 0; i < m_attributes.size(); ++i) {
-        if (m_attributes.at(i).name().matches(name))
-            return i;
-    }
-    return notFound;
-}
-
 // We use a boolean parameter instead of calling shouldIgnoreAttributeCase so that the caller
 // can tune the behavior (hasAttribute is case sensitive whereas getAttribute is not).
 inline size_t ElementAttributeData::getAttributeItemIndex(const String& name, bool shouldIgnoreAttributeCase) const

Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp (115148 => 115149)


--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp	2012-04-25 00:43:31 UTC (rev 115148)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp	2012-04-25 00:47:16 UTC (rev 115149)
@@ -432,7 +432,7 @@
 
     ASSERT(element->isHTMLElement()); // otherwise localName() might be wrong.
 
-    Vector<Attribute> clonedAttributes;
+    AttributeVector clonedAttributes;
     if (ElementAttributeData* attributeData = element->updatedAttributeData())
         clonedAttributes = attributeData->clonedAttributeVector();
 

Modified: trunk/Source/WebCore/html/parser/HTMLToken.h (115148 => 115149)


--- trunk/Source/WebCore/html/parser/HTMLToken.h	2012-04-25 00:43:31 UTC (rev 115148)
+++ trunk/Source/WebCore/html/parser/HTMLToken.h	2012-04-25 00:47:16 UTC (rev 115149)
@@ -86,7 +86,7 @@
 public:
     AtomicHTMLToken(HTMLToken& token) : AtomicMarkupTokenBase<HTMLToken>(&token) { }
 
-    AtomicHTMLToken(HTMLTokenTypes::Type type, AtomicString name, const Vector<Attribute>& attributes = Vector<Attribute>())
+    AtomicHTMLToken(HTMLTokenTypes::Type type, AtomicString name, const AttributeVector& attributes = AttributeVector())
         : AtomicMarkupTokenBase<HTMLToken>(type, name, attributes)
     {
     }

Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (115148 => 115149)


--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp	2012-04-25 00:43:31 UTC (rev 115148)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp	2012-04-25 00:47:16 UTC (rev 115149)
@@ -531,7 +531,7 @@
     parseError(token);
 }
 
-void HTMLTreeBuilder::processFakeStartTag(const QualifiedName& tagName, const Vector<Attribute>& attributes)
+void HTMLTreeBuilder::processFakeStartTag(const QualifiedName& tagName, const AttributeVector& attributes)
 {
     // FIXME: We'll need a fancier conversion than just "localName" for SVG/MathML tags.
     AtomicHTMLToken fakeToken(HTMLTokenTypes::StartTag, tagName.localName(), attributes);
@@ -560,17 +560,16 @@
     processEndTag(endP);
 }
 
-Vector<Attribute> HTMLTreeBuilder::attributesForIsindexInput(AtomicHTMLToken& token)
+AttributeVector HTMLTreeBuilder::attributesForIsindexInput(AtomicHTMLToken& token)
 {
-    Vector<Attribute> attributes = token.attributes();
-
-    for (unsigned i = 0; i < attributes.size(); ++i) {
-        const QualifiedName& name = attributes.at(i).name();
-        if (name.matches(nameAttr) || name.matches(actionAttr) || name.matches(promptAttr))
-            attributes.remove(i);
+    AttributeVector attributes = token.attributes();
+    if (!attributes.isEmpty()) {
+        attributes.removeAttribute(nameAttr);
+        attributes.removeAttribute(actionAttr);
+        attributes.removeAttribute(promptAttr);
     }
 
-    attributes.append(Attribute(nameAttr, isindexTag.localName()));
+    attributes.insertAttribute(Attribute(nameAttr, isindexTag.localName()));
     return attributes;
 }
 

Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h (115148 => 115149)


--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h	2012-04-25 00:43:31 UTC (rev 115148)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h	2012-04-25 00:47:16 UTC (rev 115149)
@@ -151,7 +151,7 @@
     void processCharacterBuffer(ExternalCharacterTokenBuffer&);
     inline void processCharacterBufferForInBody(ExternalCharacterTokenBuffer&);
 
-    void processFakeStartTag(const QualifiedName&, const Vector<Attribute>& attributes = Vector<Attribute>());
+    void processFakeStartTag(const QualifiedName&, const AttributeVector& attributes = AttributeVector());
     void processFakeEndTag(const QualifiedName&);
     void processFakeCharacters(const String&);
     void processFakePEndTagIfPInButtonScope();
@@ -172,7 +172,7 @@
     inline bool shouldProcessTokenInForeignContent(AtomicHTMLToken&);
     void processTokenInForeignContent(AtomicHTMLToken&);
 
-    Vector<Attribute> attributesForIsindexInput(AtomicHTMLToken&);
+    AttributeVector attributesForIsindexInput(AtomicHTMLToken&);
 
     HTMLElementStack::ElementRecord* furthestBlockForFormattingElement(Element*);
     void callTheAdoptionAgency(AtomicHTMLToken&);

Modified: trunk/Source/WebCore/html/parser/TextDocumentParser.cpp (115148 => 115149)


--- trunk/Source/WebCore/html/parser/TextDocumentParser.cpp	2012-04-25 00:43:31 UTC (rev 115148)
+++ trunk/Source/WebCore/html/parser/TextDocumentParser.cpp	2012-04-25 00:47:16 UTC (rev 115149)
@@ -60,8 +60,8 @@
     // sending fake bytes through the front-end of the parser to avoid
     // distrubing the line/column number calculations.
 
-    Vector<Attribute> attributes;
-    attributes.append(Attribute(styleAttr, "word-wrap: break-word; white-space: pre-wrap;"));
+    AttributeVector attributes;
+    attributes.insertAttribute(Attribute("style", "word-wrap: break-word; white-space: pre-wrap;"));
     AtomicHTMLToken fakePre(HTMLTokenTypes::StartTag, preTag.localName(), attributes);
 
     treeBuilder()->constructTreeFromAtomicToken(fakePre);

Modified: trunk/Source/WebCore/xml/XMLErrors.cpp (115148 => 115149)


--- trunk/Source/WebCore/xml/XMLErrors.cpp	2012-04-25 00:43:31 UTC (rev 115148)
+++ trunk/Source/WebCore/xml/XMLErrors.cpp	2012-04-25 00:47:16 UTC (rev 115149)
@@ -91,7 +91,7 @@
 {
     RefPtr<Element> reportElement = doc->createElement(QualifiedName(nullAtom, "parsererror", xhtmlNamespaceURI), true);
 
-    Vector<Attribute> reportAttributes;
+    AttributeVector reportAttributes;
     reportAttributes.append(Attribute(styleAttr, "display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black"));
     reportElement->parserSetAttributes(reportAttributes, FragmentScriptingNotAllowed);
 
@@ -100,7 +100,7 @@
     h3->parserAddChild(doc->createTextNode("This page contains the following errors:"));
 
     RefPtr<Element> fixed = doc->createElement(divTag, true);
-    Vector<Attribute> fixedAttributes;
+    AttributeVector fixedAttributes;
     fixedAttributes.append(Attribute(styleAttr, "font-family:monospace;font-size:12px"));
     fixed->parserSetAttributes(fixedAttributes, FragmentScriptingNotAllowed);
     reportElement->parserAddChild(fixed.get());
@@ -158,7 +158,7 @@
 
 #if ENABLE(XSLT)
     if (m_document->transformSourceDocument()) {
-        Vector<Attribute> attributes;
+        AttributeVector attributes;
         attributes.append(Attribute(styleAttr, "white-space: normal"));
         RefPtr<Element> paragraph = m_document->createElement(pTag, true);
         paragraph->parserSetAttributes(attributes, FragmentScriptingNotAllowed);

Modified: trunk/Source/WebCore/xml/parser/MarkupTokenBase.h (115148 => 115149)


--- trunk/Source/WebCore/xml/parser/MarkupTokenBase.h	2012-04-25 00:43:31 UTC (rev 115148)
+++ trunk/Source/WebCore/xml/parser/MarkupTokenBase.h	2012-04-25 00:47:16 UTC (rev 115149)
@@ -409,7 +409,7 @@
         }
     }
 
-    AtomicMarkupTokenBase(typename Token::Type::Type type, AtomicString name, const Vector<Attribute>& attributes = Vector<Attribute>())
+    AtomicMarkupTokenBase(typename Token::Type::Type type, AtomicString name, const AttributeVector& attributes = AttributeVector())
         : m_type(type)
         , m_name(name)
         , m_externalCharacters(0)
@@ -441,16 +441,16 @@
     Attribute* getAttributeItem(const QualifiedName& attributeName)
     {
         ASSERT(usesAttributes());
-        return findAttributeInVector(m_attributes, attributeName);
+        return m_attributes.getAttributeItem(attributeName);
     }
 
-    Vector<Attribute>& attributes()
+    AttributeVector& attributes()
     {
         ASSERT(usesAttributes());
         return m_attributes;
     }
 
-    const Vector<Attribute>& attributes() const
+    const AttributeVector& attributes() const
     {
         ASSERT(usesAttributes());
         return m_attributes;
@@ -514,7 +514,7 @@
     // For StartTag and EndTag
     bool m_selfClosing;
 
-    Vector<Attribute> m_attributes;
+    AttributeVector m_attributes;
 };
 
 template<typename Token>
@@ -539,9 +539,7 @@
         ASSERT(attribute.m_valueRange.m_end);
 
         AtomicString value(attribute.m_value.data(), attribute.m_value.size());
-        const QualifiedName name = nameForAttribute(attribute);
-        if (!findAttributeInVector(m_attributes, name))
-            m_attributes.append(Attribute(name, value));
+        m_attributes.insertAttribute(Attribute(nameForAttribute(attribute), value));
     }
 }
 

Modified: trunk/Source/WebCore/xml/parser/XMLToken.h (115148 => 115149)


--- trunk/Source/WebCore/xml/parser/XMLToken.h	2012-04-25 00:43:31 UTC (rev 115148)
+++ trunk/Source/WebCore/xml/parser/XMLToken.h	2012-04-25 00:47:16 UTC (rev 115149)
@@ -431,7 +431,7 @@
         }
     }
 
-    AtomicXMLToken(XMLTokenTypes::Type type, AtomicString name, const Vector<Attribute>& attributes = Vector<Attribute>())
+    AtomicXMLToken(XMLTokenTypes::Type type, AtomicString name, const AttributeVector& attributes = AttributeVector())
         : AtomicMarkupTokenBase<XMLToken>(type, name, attributes)
     {
     }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to