Title: [128363] trunk/Source
- Revision
- 128363
- Author
- [email protected]
- Date
- 2012-09-12 14:40:26 -0700 (Wed, 12 Sep 2012)
Log Message
Element::classAttributeChanged should use characters8/16 to find first non-whitespace
https://bugs.webkit.org/show_bug.cgi?id=96446
Reviewed by Benjamin Poulain.
Source/WebCore:
Made two new static templated methods to handle 8 or 16 bit class names.
No functional change, so no new tests.
* dom/Element.cpp:
(WebCore::classStringHasClassName):
(WebCore::Element::classAttributeChanged):
Source/WTF:
Added bit size related string accessors to AtomicString to support change.
* wtf/text/AtomicString.h:
(AtomicString):
(WTF::AtomicString::is8Bit):
(WTF::AtomicString::characters8):
(WTF::AtomicString::characters16):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (128362 => 128363)
--- trunk/Source/WTF/ChangeLog 2012-09-12 21:37:35 UTC (rev 128362)
+++ trunk/Source/WTF/ChangeLog 2012-09-12 21:40:26 UTC (rev 128363)
@@ -1,3 +1,18 @@
+2012-09-11 Michael Saboff <[email protected]>
+
+ Element::classAttributeChanged should use characters8/16 to find first non-whitespace
+ https://bugs.webkit.org/show_bug.cgi?id=96446
+
+ Reviewed by Benjamin Poulain.
+
+ Added bit size related string accessors to AtomicString to support change.
+
+ * wtf/text/AtomicString.h:
+ (AtomicString):
+ (WTF::AtomicString::is8Bit):
+ (WTF::AtomicString::characters8):
+ (WTF::AtomicString::characters16):
+
2012-09-12 Michael Saboff <[email protected]>
Build fixed for http://trac.webkit.org/changeset/128243
Modified: trunk/Source/WTF/wtf/text/AtomicString.h (128362 => 128363)
--- trunk/Source/WTF/wtf/text/AtomicString.h 2012-09-12 21:37:35 UTC (rev 128362)
+++ trunk/Source/WTF/wtf/text/AtomicString.h 2012-09-12 21:40:26 UTC (rev 128363)
@@ -86,8 +86,11 @@
const String& string() const { return m_string; };
AtomicStringImpl* impl() const { return static_cast<AtomicStringImpl *>(m_string.impl()); }
-
+
+ bool is8Bit() const { return m_string.is8Bit(); }
const UChar* characters() const { return m_string.characters(); }
+ const LChar* characters8() const { return m_string.characters8(); }
+ const UChar* characters16() const { return m_string.characters16(); }
unsigned length() const { return m_string.length(); }
UChar operator[](unsigned int i) const { return m_string[i]; }
Modified: trunk/Source/WebCore/ChangeLog (128362 => 128363)
--- trunk/Source/WebCore/ChangeLog 2012-09-12 21:37:35 UTC (rev 128362)
+++ trunk/Source/WebCore/ChangeLog 2012-09-12 21:40:26 UTC (rev 128363)
@@ -1,3 +1,18 @@
+2012-09-12 Michael Saboff <[email protected]>
+
+ Element::classAttributeChanged should use characters8/16 to find first non-whitespace
+ https://bugs.webkit.org/show_bug.cgi?id=96446
+
+ Reviewed by Benjamin Poulain.
+
+ Made two new static templated methods to handle 8 or 16 bit class names.
+
+ No functional change, so no new tests.
+
+ * dom/Element.cpp:
+ (WebCore::classStringHasClassName):
+ (WebCore::Element::classAttributeChanged):
+
2012-09-12 Adam Barth <[email protected]>
[V8] V8DOMWrapper::constructorForType is unnecessary now that we can get V8PerContextData from the v8::Context
Modified: trunk/Source/WebCore/dom/Element.cpp (128362 => 128363)
--- trunk/Source/WebCore/dom/Element.cpp 2012-09-12 21:37:35 UTC (rev 128362)
+++ trunk/Source/WebCore/dom/Element.cpp 2012-09-12 21:40:26 UTC (rev 128363)
@@ -755,17 +755,36 @@
classAttributeChanged(attribute.value());
}
-void Element::classAttributeChanged(const AtomicString& newClassString)
+template <typename CharacterType>
+static inline bool classStringHasClassName(const CharacterType* characters, unsigned length)
{
- const UChar* characters = newClassString.characters();
- unsigned length = newClassString.length();
- unsigned i;
- for (i = 0; i < length; ++i) {
+ ASSERT(length > 0);
+
+ unsigned i = 0;
+ do {
if (isNotHTMLSpace(characters[i]))
break;
- }
- bool hasClass = i < length;
- if (hasClass) {
+ ++i;
+ } while (i < length);
+
+ return i < length;
+}
+
+static inline bool classStringHasClassName(const AtomicString& newClassString)
+{
+ unsigned length = newClassString.length();
+
+ if (!length)
+ return false;
+
+ if (newClassString.is8Bit())
+ return classStringHasClassName(newClassString.characters8(), length);
+ return classStringHasClassName(newClassString.characters16(), length);
+}
+
+void Element::classAttributeChanged(const AtomicString& newClassString)
+{
+ if (classStringHasClassName(newClassString)) {
const bool shouldFoldCase = document()->inQuirksMode();
ensureAttributeData()->setClass(newClassString, shouldFoldCase);
} else if (attributeData())
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes