Modified: trunk/Source/WebCore/html/HTMLElement.cpp (180630 => 180631)
--- trunk/Source/WebCore/html/HTMLElement.cpp 2015-02-25 17:43:40 UTC (rev 180630)
+++ trunk/Source/WebCore/html/HTMLElement.cpp 2015-02-25 18:42:04 UTC (rev 180631)
@@ -167,6 +167,32 @@
return equalIgnoringCase(dirAttributeValue, "rtl") || equalIgnoringCase(dirAttributeValue, "ltr");
}
+enum class ContentEditableType {
+ Inherit,
+ True,
+ False,
+ PlaintextOnly
+};
+
+static inline ContentEditableType contentEditableType(const AtomicString& value)
+{
+ if (value.isNull())
+ return ContentEditableType::Inherit;
+ if (value.isEmpty() || equalIgnoringCase(value, "true"))
+ return ContentEditableType::True;
+ if (equalIgnoringCase(value, "false"))
+ return ContentEditableType::False;
+ if (equalIgnoringCase(value, "plaintext-only"))
+ return ContentEditableType::PlaintextOnly;
+
+ return ContentEditableType::Inherit;
+}
+
+static ContentEditableType contentEditableType(const HTMLElement& element)
+{
+ return contentEditableType(element.fastGetAttribute(contenteditableAttr));
+}
+
void HTMLElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStyleProperties& style)
{
if (name == alignAttr) {
@@ -175,24 +201,26 @@
else
addPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, value);
} else if (name == contenteditableAttr) {
- if (value.isEmpty() || equalIgnoringCase(value, "true")) {
- addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserModify, CSSValueReadWrite);
+ CSSValueID userModifyValue = CSSValueReadWrite;
+ switch (contentEditableType(value)) {
+ case ContentEditableType::Inherit:
+ return;
+ case ContentEditableType::False:
+ userModifyValue = CSSValueReadOnly;
+ break;
+ case ContentEditableType::PlaintextOnly:
+ userModifyValue = CSSValueReadWritePlaintextOnly;
+ FALLTHROUGH;
+ case ContentEditableType::True:
addPropertyToPresentationAttributeStyle(style, CSSPropertyWordWrap, CSSValueBreakWord);
addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitNbspMode, CSSValueSpace);
addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLineBreak, CSSValueAfterWhiteSpace);
#if PLATFORM(IOS)
addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitTextSizeAdjust, CSSValueNone);
#endif
- } else if (equalIgnoringCase(value, "plaintext-only")) {
- addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserModify, CSSValueReadWritePlaintextOnly);
- addPropertyToPresentationAttributeStyle(style, CSSPropertyWordWrap, CSSValueBreakWord);
- addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitNbspMode, CSSValueSpace);
- addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLineBreak, CSSValueAfterWhiteSpace);
-#if PLATFORM(IOS)
- addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitTextSizeAdjust, CSSValueNone);
-#endif
- } else if (equalIgnoringCase(value, "false"))
- addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserModify, CSSValueReadOnly);
+ break;
+ }
+ addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserModify, userModifyValue);
} else if (name == hiddenAttr) {
addPropertyToPresentationAttributeStyle(style, CSSPropertyDisplay, CSSValueNone);
} else if (name == draggableAttr) {
@@ -339,29 +367,6 @@
map.add(customTable[i].attributeName.localName().impl(), customTable[i].eventName);
}
-enum class ContentEditableType {
- Inherit,
- True,
- False,
- PlaintextOnly
-};
-
-static ContentEditableType contentEditableType(const HTMLElement& element)
-{
- const AtomicString& value = element.fastGetAttribute(contenteditableAttr);
-
- if (value.isNull())
- return ContentEditableType::Inherit;
- if (value.isEmpty() || equalIgnoringCase(value, "true"))
- return ContentEditableType::True;
- if (equalIgnoringCase(value, "false"))
- return ContentEditableType::False;
- if (equalIgnoringCase(value, "plaintext-only"))
- return ContentEditableType::PlaintextOnly;
-
- return ContentEditableType::Inherit;
-}
-
bool HTMLElement::matchesReadWritePseudoClass() const
{
const Element* currentElement = this;