[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.18-1-697-g2f78b87
tkent at chromium.org
tkent at chromium.org
Wed Jan 20 22:15:01 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 3cf35bb10aab6b16cdfd9803b238da22d66bf134
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Jan 7 04:45:10 2010 +0000
2010-01-06 Kent Tamura <tkent at chromium.org>
Reviewed by Darin Adler.
Use a static HashMap for HTMLElement::tagPriority().
https://bugs.webkit.org/show_bug.cgi?id=33269
The prior code compares AtomicStringImpl pointers 18 times at
worst. This change avoids it.
No new tests because this is just a refactoring.
* html/HTMLElement.cpp:
(WebCore::Empty1IntHashTraits): A HashTraits to return 1 as the empty value.
(WebCore::initializeTagPriorityMap): Initialization of a static HashMap.
(WebCore::HTMLElement::tagPriority): Use the static HashMap created by initializeTagPriorityMap().
* html/HTMLElement.h:
(WebCore::HTMLElement::HTMLElement): Add an assertion about non-null localName().
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52899 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4900c95..36864c2 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-01-06 Kent Tamura <tkent at chromium.org>
+
+ Reviewed by Darin Adler.
+
+ Use a static HashMap for HTMLElement::tagPriority().
+ https://bugs.webkit.org/show_bug.cgi?id=33269
+
+ The prior code compares AtomicStringImpl pointers 18 times at
+ worst. This change avoids it.
+
+ No new tests because this is just a refactoring.
+
+ * html/HTMLElement.cpp:
+ (WebCore::Empty1IntHashTraits): A HashTraits to return 1 as the empty value.
+ (WebCore::initializeTagPriorityMap): Initialization of a static HashMap.
+ (WebCore::HTMLElement::tagPriority): Use the static HashMap created by initializeTagPriorityMap().
+ * html/HTMLElement.h:
+ (WebCore::HTMLElement::HTMLElement): Add an assertion about non-null localName().
+
2010-01-06 Mike Belshe <mike at belshe.com>
Add a flag to the ResourceResponse for tracking if a request was
diff --git a/WebCore/html/HTMLElement.cpp b/WebCore/html/HTMLElement.cpp
index ffa0eea..ae79678 100644
--- a/WebCore/html/HTMLElement.cpp
+++ b/WebCore/html/HTMLElement.cpp
@@ -82,19 +82,48 @@ HTMLTagStatus HTMLElement::endTagRequirement() const
return TagStatusRequired;
}
-int HTMLElement::tagPriority() const
+struct Empty1IntHashTraits : HashTraits<int> {
+ static const bool emptyValueIsZero = false;
+ static int emptyValue() { return 1; }
+};
+typedef HashMap<AtomicStringImpl*, int, DefaultHash<AtomicStringImpl*>::Hash, HashTraits<AtomicStringImpl*>, Empty1IntHashTraits> TagPriorityMap;
+
+static const TagPriorityMap* createTagPriorityMap()
{
- if (hasLocalName(wbrTag))
- return 0;
- if (hasLocalName(addressTag) || hasLocalName(ddTag) || hasLocalName(dtTag) || hasLocalName(noscriptTag) || hasLocalName(rpTag) || hasLocalName(rtTag))
- return 3;
- if (hasLocalName(articleTag) || hasLocalName(asideTag) || hasLocalName(centerTag) || hasLocalName(footerTag) || hasLocalName(headerTag) || hasLocalName(nobrTag) || hasLocalName(rubyTag) || hasLocalName(navTag) || hasLocalName(sectionTag))
- return 5; // Same as <div>.
- if (hasLocalName(noembedTag) || hasLocalName(noframesTag))
- return 10;
+ TagPriorityMap* map = new TagPriorityMap;
+
+ map->add(wbrTag.localName().impl(), 0);
+
+ map->add(addressTag.localName().impl(), 3);
+ map->add(ddTag.localName().impl(), 3);
+ map->add(dtTag.localName().impl(), 3);
+ map->add(noscriptTag.localName().impl(), 3);
+ map->add(rpTag.localName().impl(), 3);
+ map->add(rtTag.localName().impl(), 3);
+
+ // 5 is same as <div>'s priority.
+ map->add(articleTag.localName().impl(), 5);
+ map->add(asideTag.localName().impl(), 5);
+ map->add(centerTag.localName().impl(), 5);
+ map->add(footerTag.localName().impl(), 5);
+ map->add(headerTag.localName().impl(), 5);
+ map->add(nobrTag.localName().impl(), 5);
+ map->add(rubyTag.localName().impl(), 5);
+ map->add(navTag.localName().impl(), 5);
+ map->add(sectionTag.localName().impl(), 5);
+
+ map->add(noembedTag.localName().impl(), 10);
+ map->add(noframesTag.localName().impl(), 10);
+
+ // TagPriorityMap returns 1 for unregistered tags. It's same as <span>.
+ // This way custom tag name elements will behave like inline spans.
+ return map;
+}
- // Same values as <span>. This way custom tag name elements will behave like inline spans.
- return 1;
+int HTMLElement::tagPriority() const
+{
+ static const TagPriorityMap* tagPriorityMap = createTagPriorityMap();
+ return tagPriorityMap->get(localName().impl());
}
bool HTMLElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
diff --git a/WebCore/html/HTMLElement.h b/WebCore/html/HTMLElement.h
index c6a384b..8c82686 100644
--- a/WebCore/html/HTMLElement.h
+++ b/WebCore/html/HTMLElement.h
@@ -116,6 +116,7 @@ private:
inline HTMLElement::HTMLElement(const QualifiedName& tagName, Document* document, ConstructionType type)
: StyledElement(tagName, document, type)
{
+ ASSERT(tagName.localName().impl());
}
} // namespace WebCore
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list