https://bugs.webkit.org/show_bug.cgi?id=49058
Reviewed by Andreas Kling.
Source/WebCore:
CSSMutableStyleDeclaration::getPropertyPriority was not handling shorthands properly. Shorthands are
not part of the property list of the style so we need to query the longhands which are the one added
in the list. Only if the longhands have equal priority the shorthand priority is known. I also renamed
getPropertyPriority (not the CSSOM exposed method) to something more consistent with WebKit naming guidelines.
Test: fast/css/shorthand-priority.html
* css/CSSMutableStyleDeclaration.cpp:
(WebCore::CSSMutableStyleDeclaration::propertyIsImportant):
(WebCore::CSSMutableStyleDeclaration::addParsedProperty):
(WebCore::CSSMutableStyleDeclaration::getPropertyPriority):
* css/CSSMutableStyleDeclaration.h:
(CSSMutableStyleDeclaration):
* editing/EditingStyle.cpp:
(WebCore::EditingStyle::extractAndRemoveTextDirection):
(WebCore::EditingStyle::collapseTextDecorationProperties):
(WebCore::EditingStyle::conflictsWithInlineStyleOfElement):
(WebCore::setTextDecorationProperty):
* editing/RemoveCSSPropertyCommand.cpp:
(WebCore::RemoveCSSPropertyCommand::doApply):
Source/WebKit/qt:
Update the code as getPropertyPriority has been renamed to propertyIsImportant.
* Api/qwebelement.cpp:
(QWebElement::styleProperty):
LayoutTests:
* fast/css/shorthand-priority-expected.txt: Added.
* fast/css/shorthand-priority.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106490
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-02-01 Alexis Menard <alexis.menard@openbossa.org>
+
+ CSSStyleDeclaration.getPropertyPriority() fails for CSS shorthand properties with 'important' priority
+ https://bugs.webkit.org/show_bug.cgi?id=49058
+
+ Reviewed by Andreas Kling.
+
+ * fast/css/shorthand-priority-expected.txt: Added.
+ * fast/css/shorthand-priority.html: Added.
+
2012-02-01 Ryosuke Niwa <rniwa@webkit.org>
Crash in EventHandler::updateDragAndDrop
--- /dev/null
+Tests that querying the priority for a shorthand works.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS e.style.getPropertyValue('border-bottom-style') is 'solid'
+PASS e.style.getPropertyPriority('border-bottom-style') is 'important'
+PASS e.style.getPropertyValue('border') is '20px solid green'
+PASS e.style.getPropertyPriority('border') is ''
+PASS e.style.getPropertyValue('border') is '20px solid green'
+PASS e.style.getPropertyPriority('border') is 'important'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+
+description("Tests that querying the priority for a shorthand works.");
+
+var testContainer = document.createElement("div");
+document.body.appendChild(testContainer);
+
+testContainer.innerHTML = '<div id="test">hello</div>';
+
+e = document.getElementById('test');
+
+// Sanity check.
+e.style.setProperty("border-bottom-style", "solid", "!important");
+shouldBe("e.style.getPropertyValue('border-bottom-style')", "'solid'");
+shouldBe("e.style.getPropertyPriority('border-bottom-style')", "'important'");
+
+e.style.borderBottomStyle = "";
+e.style.border = "20px solid green";
+shouldBe("e.style.getPropertyValue('border')", "'20px solid green'");
+shouldBe("e.style.getPropertyPriority('border')", "''");
+
+e.style.border = "";
+e.style.setProperty("border", "20px solid green", "!important");
+shouldBe("e.style.getPropertyValue('border')", "'20px solid green'");
+shouldBe("e.style.getPropertyPriority('border')", "'important'");
+
+document.body.removeChild(testContainer);
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
+2012-02-01 Alexis Menard <alexis.menard@openbossa.org>
+
+ CSSStyleDeclaration.getPropertyPriority() fails for CSS shorthand properties with 'important' priority
+ https://bugs.webkit.org/show_bug.cgi?id=49058
+
+ Reviewed by Andreas Kling.
+
+ CSSMutableStyleDeclaration::getPropertyPriority was not handling shorthands properly. Shorthands are
+ not part of the property list of the style so we need to query the longhands which are the one added
+ in the list. Only if the longhands have equal priority the shorthand priority is known. I also renamed
+ getPropertyPriority (not the CSSOM exposed method) to something more consistent with WebKit naming guidelines.
+
+ Test: fast/css/shorthand-priority.html
+
+ * css/CSSMutableStyleDeclaration.cpp:
+ (WebCore::CSSMutableStyleDeclaration::propertyIsImportant):
+ (WebCore::CSSMutableStyleDeclaration::addParsedProperty):
+ (WebCore::CSSMutableStyleDeclaration::getPropertyPriority):
+ * css/CSSMutableStyleDeclaration.h:
+ (CSSMutableStyleDeclaration):
+ * editing/EditingStyle.cpp:
+ (WebCore::EditingStyle::extractAndRemoveTextDirection):
+ (WebCore::EditingStyle::collapseTextDecorationProperties):
+ (WebCore::EditingStyle::conflictsWithInlineStyleOfElement):
+ (WebCore::setTextDecorationProperty):
+ * editing/RemoveCSSPropertyCommand.cpp:
+ (WebCore::RemoveCSSPropertyCommand::doApply):
+
2012-02-01 Ryosuke Niwa <rniwa@webkit.org>
Crash in EventHandler::updateDragAndDrop
}
}
-bool CSSMutableStyleDeclaration::getPropertyPriority(int propertyID) const
+bool CSSMutableStyleDeclaration::propertyIsImportant(int propertyID) const
{
const CSSProperty* property = findPropertyWithId(propertyID);
- return property ? property->isImportant() : false;
+ if (property)
+ return property->isImportant();
+
+ CSSPropertyLonghand longhands = longhandForProperty(propertyID);
+ if (!longhands.length())
+ return false;
+
+ for (unsigned i = 0; i < longhands.length(); ++i) {
+ if (!propertyIsImportant(longhands.properties()[i]))
+ return false;
+ }
+ return true;
}
int CSSMutableStyleDeclaration::getPropertyShorthand(int propertyID) const
#endif
// Only add properties that have no !important counterpart present
- if (!getPropertyPriority(property.id()) || property.isImportant()) {
+ if (!propertyIsImportant(property.id()) || property.isImportant()) {
removeProperty(property.id(), false, false);
m_properties.append(property);
}
int propertyID = cssPropertyID(propertyName);
if (!propertyID)
return String();
- return getPropertyPriority(propertyID) ? "important" : "";
+ return propertyIsImportant(propertyID) ? "important" : "";
}
String CSSMutableStyleDeclaration::getPropertyShorthand(const String& propertyName)
PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const;
String getPropertyValue(int propertyID) const;
- bool getPropertyPriority(int propertyID) const;
+ bool propertyIsImportant(int propertyID) const;
int getPropertyShorthand(int propertyID) const;
bool isPropertyImplicit(int propertyID) const;
{
RefPtr<EditingStyle> textDirection = EditingStyle::create();
textDirection->m_mutableStyle = CSSMutableStyleDeclaration::create();
- textDirection->m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueEmbed, m_mutableStyle->getPropertyPriority(CSSPropertyUnicodeBidi));
+ textDirection->m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueEmbed, m_mutableStyle->propertyIsImportant(CSSPropertyUnicodeBidi));
textDirection->m_mutableStyle->setProperty(CSSPropertyDirection, m_mutableStyle->getPropertyValue(CSSPropertyDirection),
- m_mutableStyle->getPropertyPriority(CSSPropertyDirection));
+ m_mutableStyle->propertyIsImportant(CSSPropertyDirection));
m_mutableStyle->removeProperty(CSSPropertyUnicodeBidi);
m_mutableStyle->removeProperty(CSSPropertyDirection);
return;
if (textDecorationsInEffect->isValueList())
- m_mutableStyle->setProperty(CSSPropertyTextDecoration, textDecorationsInEffect->cssText(), m_mutableStyle->getPropertyPriority(CSSPropertyTextDecoration));
+ m_mutableStyle->setProperty(CSSPropertyTextDecoration, textDecorationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(CSSPropertyTextDecoration));
else
m_mutableStyle->removeProperty(CSSPropertyTextDecoration);
m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect);
return true;
conflictingProperties->append(CSSPropertyTextDecoration);
if (extractedStyle)
- extractedStyle->setProperty(CSSPropertyTextDecoration, inlineStyle->getPropertyValue(CSSPropertyTextDecoration), inlineStyle->getPropertyPriority(CSSPropertyTextDecoration));
+ extractedStyle->setProperty(CSSPropertyTextDecoration, inlineStyle->getPropertyValue(CSSPropertyTextDecoration), inlineStyle->propertyIsImportant(CSSPropertyTextDecoration));
continue;
}
return true;
conflictingProperties->append(CSSPropertyDirection);
if (extractedStyle)
- extractedStyle->setProperty(propertyID, inlineStyle->getPropertyValue(propertyID), inlineStyle->getPropertyPriority(propertyID));
+ extractedStyle->setProperty(propertyID, inlineStyle->getPropertyValue(propertyID), inlineStyle->propertyIsImportant(propertyID));
}
if (!conflictingProperties)
conflictingProperties->append(propertyID);
if (extractedStyle)
- extractedStyle->setProperty(propertyID, inlineStyle->getPropertyValue(propertyID), inlineStyle->getPropertyPriority(propertyID));
+ extractedStyle->setProperty(propertyID, inlineStyle->getPropertyValue(propertyID), inlineStyle->propertyIsImportant(propertyID));
}
return conflictingProperties && !conflictingProperties->isEmpty();
static void setTextDecorationProperty(CSSMutableStyleDeclaration* style, const CSSValueList* newTextDecoration, int propertyID)
{
if (newTextDecoration->length())
- style->setProperty(propertyID, newTextDecoration->cssText(), style->getPropertyPriority(propertyID));
+ style->setProperty(propertyID, newTextDecoration->cssText(), style->propertyIsImportant(propertyID));
else {
// text-decoration: none is redundant since it does not remove any text decorations.
- ASSERT(!style->getPropertyPriority(propertyID));
+ ASSERT(!style->propertyIsImportant(propertyID));
style->removeProperty(propertyID);
}
}
{
CSSMutableStyleDeclaration* style = m_element->inlineStyleDecl();
m_oldValue = style->getPropertyValue(m_property);
- m_important = style->getPropertyPriority(m_property);
+ m_important = style->propertyIsImportant(m_property);
style->removeProperty(m_property);
}
return style->getPropertyValue(propID);
if (strategy == CascadedStyle) {
- if (style->getPropertyPriority(propID))
+ if (style->propertyIsImportant(propID))
return style->getPropertyValue(propID);
// We are going to resolve the style property by walking through the
for (int i = rules->length(); i > 0; --i) {
CSSStyleRule* rule = static_cast<CSSStyleRule*>(rules->item(i - 1));
- if (rule->declaration()->getPropertyPriority(propID))
+ if (rule->declaration()->propertyIsImportant(propID))
return rule->declaration()->getPropertyValue(propID);
if (style->getPropertyValue(propID).isEmpty())
+2012-02-01 Alexis Menard <alexis.menard@openbossa.org>
+
+ CSSStyleDeclaration.getPropertyPriority() fails for CSS shorthand properties with 'important' priority
+ https://bugs.webkit.org/show_bug.cgi?id=49058
+
+ Reviewed by Andreas Kling.
+
+ Update the code as getPropertyPriority has been renamed to propertyIsImportant.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::styleProperty):
+
2012-01-31 Antti Koivisto <antti@apple.com>
Try to fix Qt build.