Diff
Modified: trunk/Source/WebCore/ChangeLog (112951 => 112952)
--- trunk/Source/WebCore/ChangeLog 2012-04-02 22:19:32 UTC (rev 112951)
+++ trunk/Source/WebCore/ChangeLog 2012-04-02 22:30:04 UTC (rev 112952)
@@ -1,3 +1,56 @@
+2012-04-02 Alexis Menard <[email protected]>
+
+ We should use CSSPropertyID rather than integers when manipulating CSS property ids.
+ https://bugs.webkit.org/show_bug.cgi?id=82941
+
+ Reviewed by Andreas Kling.
+
+ CSSPropertyID enum holds all the CSS property ids but many parts of WebKit treat the ids
+ as integers. While it's not incorrect it is nicer to use the enum as a parameter of
+ functions manipulating property ids, as we ensure that the value passed will be an
+ existing value. It will also feel more correct after this patch that CSSProperty::id()
+ return a value of the enum rather than an integer. As this modification is quite big this
+ is the first part only so it will be easier to review.
+
+ No new tests : There should be no behavior change in this patch.
+
+ * css/CSSParser.cpp:
+ (WebCore::cssPropertyID):
+ * css/CSSParser.h:
+ (WebCore):
+ * css/CSSProperty.cpp:
+ (WebCore::CSSProperty::cssText):
+ * css/CSSProperty.h:
+ (WebCore::CSSProperty::id):
+ (WebCore::CSSProperty::shorthandID):
+ * css/PropertySetCSSStyleDeclaration.cpp:
+ (WebCore::PropertySetCSSStyleDeclaration::item):
+ (WebCore::PropertySetCSSStyleDeclaration::getPropertyCSSValue):
+ (WebCore::PropertySetCSSStyleDeclaration::getPropertyValue):
+ (WebCore::PropertySetCSSStyleDeclaration::getPropertyPriority):
+ (WebCore::PropertySetCSSStyleDeclaration::getPropertyShorthand):
+ (WebCore::PropertySetCSSStyleDeclaration::isPropertyImplicit):
+ * css/StylePropertySet.cpp:
+ (WebCore::StylePropertySet::getPropertyValue):
+ (WebCore::StylePropertySet::appendFontLonghandValueIfExplicit):
+ (WebCore::StylePropertySet::propertyIsImportant):
+ (WebCore::StylePropertySet::getPropertyShorthand):
+ (WebCore::StylePropertySet::isPropertyImplicit):
+ (WebCore::StylePropertySet::asText):
+ * css/StylePropertySet.h:
+ (StylePropertySet):
+ * editing/EditingStyle.cpp:
+ (WebCore::EditingStyle::conflictsWithInlineStyleOfElement):
+ (WebCore::removePropertiesInStyle):
+ (WebCore::setTextDecorationProperty):
+ (WebCore::diffTextDecorations):
+ * editing/Editor.cpp:
+ (WebCore::Editor::selectionStartCSSPropertyValue):
+ * editing/Editor.h:
+ (Editor):
+ * editing/EditorCommand.cpp:
+ (WebCore::valueStyle):
+
2012-04-02 Nate Chapin <[email protected]>
Simplify main resource load start/end in FrameLoader
Modified: trunk/Source/WebCore/css/CSSParser.cpp (112951 => 112952)
--- trunk/Source/WebCore/css/CSSParser.cpp 2012-04-02 22:19:32 UTC (rev 112951)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2012-04-02 22:30:04 UTC (rev 112952)
@@ -9343,19 +9343,19 @@
resetPropertyMarks();
}
-static int cssPropertyID(const UChar* propertyName, unsigned length)
+static CSSPropertyID cssPropertyID(const UChar* propertyName, unsigned length)
{
if (!length)
- return 0;
+ return CSSPropertyInvalid;
if (length > maxCSSPropertyNameLength)
- return 0;
+ return CSSPropertyInvalid;
char buffer[maxCSSPropertyNameLength + 1 + 1]; // 1 to turn "apple"/"khtml" into "webkit", 1 for null character
for (unsigned i = 0; i != length; ++i) {
UChar c = propertyName[i];
if (c == 0 || c >= 0x7F)
- return 0; // illegal character
+ return CSSPropertyInvalid; // illegal character
buffer[i] = toASCIILower(c);
}
buffer[length] = '\0';
@@ -9375,15 +9375,15 @@
}
const Property* hashTableEntry = findProperty(name, length);
- return hashTableEntry ? hashTableEntry->id : 0;
+ return hashTableEntry ? static_cast<CSSPropertyID>(hashTableEntry->id) : CSSPropertyInvalid;
}
-int cssPropertyID(const String& string)
+CSSPropertyID cssPropertyID(const String& string)
{
return cssPropertyID(string.characters(), string.length());
}
-int cssPropertyID(const CSSParserString& string)
+CSSPropertyID cssPropertyID(const CSSParserString& string)
{
return cssPropertyID(string.characters, string.length);
}
Modified: trunk/Source/WebCore/css/CSSParser.h (112951 => 112952)
--- trunk/Source/WebCore/css/CSSParser.h 2012-04-02 22:19:32 UTC (rev 112951)
+++ trunk/Source/WebCore/css/CSSParser.h 2012-04-02 22:30:04 UTC (rev 112952)
@@ -464,8 +464,8 @@
#endif
};
-int cssPropertyID(const CSSParserString&);
-int cssPropertyID(const String&);
+CSSPropertyID cssPropertyID(const CSSParserString&);
+CSSPropertyID cssPropertyID(const String&);
int cssValueKeywordID(const CSSParserString&);
#if PLATFORM(IOS)
void cssPropertyNameIOSAliasing(const char* propertyName, const char*& propertyNameAlias, unsigned& newLength);
Modified: trunk/Source/WebCore/css/CSSProperty.cpp (112951 => 112952)
--- trunk/Source/WebCore/css/CSSProperty.cpp 2012-04-02 22:19:32 UTC (rev 112951)
+++ trunk/Source/WebCore/css/CSSProperty.cpp 2012-04-02 22:30:04 UTC (rev 112952)
@@ -21,7 +21,6 @@
#include "config.h"
#include "CSSProperty.h"
-#include "CSSPropertyNames.h"
#include "CSSValueList.h"
#include "PlatformString.h"
#include "RenderStyleConstants.h"
@@ -38,7 +37,7 @@
String CSSProperty::cssText() const
{
- return String(getPropertyName(static_cast<CSSPropertyID>(id()))) + ": " + m_value->cssText() + (isImportant() ? " !important" : "") + "; ";
+ return String(getPropertyName(id())) + ": " + m_value->cssText() + (isImportant() ? " !important" : "") + "; ";
}
void CSSProperty::wrapValueInCommaSeparatedList()
Modified: trunk/Source/WebCore/css/CSSProperty.h (112951 => 112952)
--- trunk/Source/WebCore/css/CSSProperty.h 2012-04-02 22:19:32 UTC (rev 112951)
+++ trunk/Source/WebCore/css/CSSProperty.h 2012-04-02 22:30:04 UTC (rev 112952)
@@ -21,6 +21,7 @@
#ifndef CSSProperty_h
#define CSSProperty_h
+#include "CSSPropertyNames.h"
#include "CSSValue.h"
#include "RenderStyleConstants.h"
#include "TextDirection.h"
@@ -41,8 +42,8 @@
{
}
- int id() const { return m_id; }
- int shorthandID() const { return m_shorthandID; }
+ CSSPropertyID id() const { return static_cast<CSSPropertyID>(m_id); }
+ CSSPropertyID shorthandID() const { return static_cast<CSSPropertyID>(m_shorthandID); }
bool isImportant() const { return m_important; }
bool isImplicit() const { return m_implicit; }
Modified: trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp (112951 => 112952)
--- trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp 2012-04-02 22:19:32 UTC (rev 112951)
+++ trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp 2012-04-02 22:30:04 UTC (rev 112952)
@@ -138,7 +138,7 @@
{
if (i >= m_propertySet->propertyCount())
return "";
- return getPropertyName(static_cast<CSSPropertyID>(m_propertySet->propertyAt(i).id()));
+ return getPropertyName(m_propertySet->propertyAt(i).id());
}
String PropertySetCSSStyleDeclaration::cssText() const
@@ -163,7 +163,7 @@
PassRefPtr<CSSValue> PropertySetCSSStyleDeclaration::getPropertyCSSValue(const String& propertyName)
{
- int propertyID = cssPropertyID(propertyName);
+ CSSPropertyID propertyID = cssPropertyID(propertyName);
if (!propertyID)
return 0;
return m_propertySet->getPropertyCSSValue(propertyID);
@@ -171,7 +171,7 @@
String PropertySetCSSStyleDeclaration::getPropertyValue(const String &propertyName)
{
- int propertyID = cssPropertyID(propertyName);
+ CSSPropertyID propertyID = cssPropertyID(propertyName);
if (!propertyID)
return String();
return m_propertySet->getPropertyValue(propertyID);
@@ -179,7 +179,7 @@
String PropertySetCSSStyleDeclaration::getPropertyPriority(const String& propertyName)
{
- int propertyID = cssPropertyID(propertyName);
+ CSSPropertyID propertyID = cssPropertyID(propertyName);
if (!propertyID)
return String();
return m_propertySet->propertyIsImportant(propertyID) ? "important" : "";
@@ -187,18 +187,18 @@
String PropertySetCSSStyleDeclaration::getPropertyShorthand(const String& propertyName)
{
- int propertyID = cssPropertyID(propertyName);
+ CSSPropertyID propertyID = cssPropertyID(propertyName);
if (!propertyID)
return String();
- int shorthandID = m_propertySet->getPropertyShorthand(propertyID);
+ CSSPropertyID shorthandID = m_propertySet->getPropertyShorthand(propertyID);
if (!shorthandID)
return String();
- return getPropertyName(static_cast<CSSPropertyID>(shorthandID));
+ return getPropertyName(shorthandID);
}
bool PropertySetCSSStyleDeclaration::isPropertyImplicit(const String& propertyName)
{
- int propertyID = cssPropertyID(propertyName);
+ CSSPropertyID propertyID = cssPropertyID(propertyName);
if (!propertyID)
return false;
return m_propertySet->isPropertyImplicit(propertyID);
Modified: trunk/Source/WebCore/css/StylePropertySet.cpp (112951 => 112952)
--- trunk/Source/WebCore/css/StylePropertySet.cpp 2012-04-02 22:19:32 UTC (rev 112951)
+++ trunk/Source/WebCore/css/StylePropertySet.cpp 2012-04-02 22:30:04 UTC (rev 112952)
@@ -93,7 +93,7 @@
m_properties = other.m_properties;
}
-String StylePropertySet::getPropertyValue(int propertyID) const
+String StylePropertySet::getPropertyValue(CSSPropertyID propertyID) const
{
RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
if (value)
@@ -171,8 +171,9 @@
return value->cssText();
}
#endif
+ default:
+ return String();
}
- return String();
}
String StylePropertySet::borderSpacingValue(const StylePropertyShorthand& shorthand) const
@@ -191,7 +192,7 @@
return horizontalValueCSSText + ' ' + verticalValueCSSText;
}
-bool StylePropertySet::appendFontLonghandValueIfExplicit(int propertyId, StringBuilder& result) const
+bool StylePropertySet::appendFontLonghandValueIfExplicit(CSSPropertyID propertyId, StringBuilder& result) const
{
const CSSProperty* property = findPropertyWithId(propertyId);
if (!property)
@@ -452,7 +453,7 @@
return true;
}
-bool StylePropertySet::propertyIsImportant(int propertyID) const
+bool StylePropertySet::propertyIsImportant(CSSPropertyID propertyID) const
{
const CSSProperty* property = findPropertyWithId(propertyID);
if (property)
@@ -469,13 +470,13 @@
return true;
}
-int StylePropertySet::getPropertyShorthand(int propertyID) const
+CSSPropertyID StylePropertySet::getPropertyShorthand(CSSPropertyID propertyID) const
{
const CSSProperty* property = findPropertyWithId(propertyID);
- return property ? property->shorthandID() : 0;
+ return property ? property->shorthandID() : CSSPropertyInvalid;
}
-bool StylePropertySet::isPropertyImplicit(int propertyID) const
+bool StylePropertySet::isPropertyImplicit(CSSPropertyID propertyID) const
{
const CSSProperty* property = findPropertyWithId(propertyID);
return property ? property->isImplicit() : false;
@@ -571,8 +572,8 @@
unsigned size = m_properties.size();
for (unsigned n = 0; n < size; ++n) {
const CSSProperty& prop = m_properties[n];
- int propertyID = prop.id();
- int shorthandPropertyID = 0;
+ CSSPropertyID propertyID = prop.id();
+ CSSPropertyID shorthandPropertyID = CSSPropertyInvalid;
switch (propertyID) {
case CSSPropertyBackgroundPositionX:
@@ -611,12 +612,12 @@
String commonValue;
bool commonImportance = false;
for (size_t j = 0; j < shorthand.length(); ++j) {
- int id = shorthand.properties()[j];
+ CSSPropertyID id = shorthand.properties()[j];
RefPtr<CSSValue> value = getPropertyCSSValue(id);
String currentValue = value ? value->cssText() : String();
bool isImportant = propertyIsImportant(id);
if (j && (currentValue != commonValue || commonImportance != isImportant)) {
- shorthandPropertyID = 0;
+ shorthandPropertyID = CSSPropertyInvalid;
break;
}
if (!j) {
@@ -705,6 +706,8 @@
case CSSPropertyWebkitWrapPadding:
shorthandPropertyID = CSSPropertyWebkitWrap;
break;
+ default:
+ break;
}
String value;
Modified: trunk/Source/WebCore/css/StylePropertySet.h (112951 => 112952)
--- trunk/Source/WebCore/css/StylePropertySet.h 2012-04-02 22:19:32 UTC (rev 112951)
+++ trunk/Source/WebCore/css/StylePropertySet.h 2012-04-02 22:30:04 UTC (rev 112952)
@@ -62,10 +62,10 @@
void shrinkToFit() { m_properties.shrinkToFit(); }
PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const;
- String getPropertyValue(int propertyID) const;
- bool propertyIsImportant(int propertyID) const;
- int getPropertyShorthand(int propertyID) const;
- bool isPropertyImplicit(int propertyID) const;
+ String getPropertyValue(CSSPropertyID) const;
+ bool propertyIsImportant(CSSPropertyID) const;
+ CSSPropertyID getPropertyShorthand(CSSPropertyID) const;
+ bool isPropertyImplicit(CSSPropertyID) const;
// These expand shorthand properties into multiple properties.
bool setProperty(int propertyID, const String& value, bool important = false, CSSStyleSheet* contextStyleSheet = 0);
@@ -126,7 +126,7 @@
String get4Values(const StylePropertyShorthand&) const;
String borderSpacingValue(const StylePropertyShorthand&) const;
String fontValue() const;
- bool appendFontLonghandValueIfExplicit(int propertyID, StringBuilder& result) const;
+ bool appendFontLonghandValueIfExplicit(CSSPropertyID, StringBuilder&) const;
bool removeShorthandProperty(int propertyID);
bool propertyMatches(const CSSProperty*) const;
Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (112951 => 112952)
--- trunk/Source/WebCore/editing/EditingStyle.cpp 2012-04-02 22:19:32 UTC (rev 112951)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp 2012-04-02 22:30:04 UTC (rev 112952)
@@ -671,7 +671,7 @@
unsigned propertyCount = m_mutableStyle->propertyCount();
for (unsigned i = 0; i < propertyCount; ++i) {
- CSSPropertyID propertyID = static_cast<CSSPropertyID>(m_mutableStyle->propertyAt(i).id());
+ CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id();
// We don't override whitespace property of a tab span because that would collapse the tab into a space.
if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element))
@@ -1086,7 +1086,7 @@
unsigned propertyCount = style->propertyCount();
Vector<CSSPropertyID> propertiesToRemove(propertyCount);
for (unsigned i = 0; i < propertyCount; ++i)
- propertiesToRemove[i] = static_cast<CSSPropertyID>(style->propertyAt(i).id());
+ propertiesToRemove[i] = style->propertyAt(i).id();
styleToRemovePropertiesFrom->removePropertiesInSet(propertiesToRemove.data(), propertiesToRemove.size());
}
@@ -1319,7 +1319,7 @@
m_cssStyle = mutableStyle->asText().stripWhiteSpace();
}
-static void setTextDecorationProperty(StylePropertySet* style, const CSSValueList* newTextDecoration, int propertyID)
+static void setTextDecorationProperty(StylePropertySet* style, const CSSValueList* newTextDecoration, CSSPropertyID propertyID)
{
if (newTextDecoration->length())
style->setProperty(propertyID, newTextDecoration->cssText(), style->propertyIsImportant(propertyID));
@@ -1395,7 +1395,7 @@
}
}
-static void diffTextDecorations(StylePropertySet* style, int propertID, CSSValue* refTextDecoration)
+static void diffTextDecorations(StylePropertySet* style, CSSPropertyID propertID, CSSValue* refTextDecoration)
{
RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(propertID);
if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration || !refTextDecoration->isValueList())
Modified: trunk/Source/WebCore/editing/Editor.cpp (112951 => 112952)
--- trunk/Source/WebCore/editing/Editor.cpp 2012-04-02 22:19:32 UTC (rev 112951)
+++ trunk/Source/WebCore/editing/Editor.cpp 2012-04-02 22:30:04 UTC (rev 112952)
@@ -742,7 +742,7 @@
return EditingStyle::create(propertyID, value)->triStateOfStyle(m_frame->selection()->selection());
}
-String Editor::selectionStartCSSPropertyValue(int propertyID)
+String Editor::selectionStartCSSPropertyValue(CSSPropertyID propertyID)
{
RefPtr<EditingStyle> selectionStyle = EditingStyle::styleAtSelectionStart(m_frame->selection()->selection(),
propertyID == CSSPropertyBackgroundColor);
Modified: trunk/Source/WebCore/editing/Editor.h (112951 => 112952)
--- trunk/Source/WebCore/editing/Editor.h 2012-04-02 22:19:32 UTC (rev 112951)
+++ trunk/Source/WebCore/editing/Editor.h 2012-04-02 22:30:04 UTC (rev 112952)
@@ -138,7 +138,7 @@
bool selectionStartHasStyle(int propertyID, const String& value) const;
TriState selectionHasStyle(int propertyID, const String& value) const;
- String selectionStartCSSPropertyValue(int propertyID);
+ String selectionStartCSSPropertyValue(CSSPropertyID);
TriState selectionUnorderedListState() const;
TriState selectionOrderedListState() const;
Modified: trunk/Source/WebCore/editing/EditorCommand.cpp (112951 => 112952)
--- trunk/Source/WebCore/editing/EditorCommand.cpp 2012-04-02 22:19:32 UTC (rev 112951)
+++ trunk/Source/WebCore/editing/EditorCommand.cpp 2012-04-02 22:30:04 UTC (rev 112952)
@@ -231,7 +231,7 @@
return frame->editor()->selectionHasStyle(propertyID, desiredValue);
}
-static String valueStyle(Frame* frame, int propertyID)
+static String valueStyle(Frame* frame, CSSPropertyID propertyID)
{
// FIXME: Rather than retrieving the style at the start of the current selection,
// we should retrieve the style present throughout the selection for non-Mac platforms.
Modified: trunk/Source/WebKit/qt/Api/qwebelement.cpp (112951 => 112952)
--- trunk/Source/WebKit/qt/Api/qwebelement.cpp 2012-04-02 22:19:32 UTC (rev 112951)
+++ trunk/Source/WebKit/qt/Api/qwebelement.cpp 2012-04-02 22:30:04 UTC (rev 112952)
@@ -839,7 +839,7 @@
if (!m_element || !m_element->isStyledElement())
return QString();
- int propID = cssPropertyID(name);
+ CSSPropertyID propID = cssPropertyID(name);
if (!propID)
return QString();
@@ -881,8 +881,6 @@
if (!m_element || !m_element->isStyledElement())
return QString();
- int propID = cssPropertyID(name);
-
RefPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration::create(m_element, true);
if (!propID || !style)
return QString();
Modified: trunk/Source/WebKit/qt/ChangeLog (112951 => 112952)
--- trunk/Source/WebKit/qt/ChangeLog 2012-04-02 22:19:32 UTC (rev 112951)
+++ trunk/Source/WebKit/qt/ChangeLog 2012-04-02 22:30:04 UTC (rev 112952)
@@ -1,3 +1,21 @@
+2012-04-02 Alexis Menard <[email protected]>
+
+ We should use CSSPropertyID rather than integers when manipulating CSS property ids.
+ https://bugs.webkit.org/show_bug.cgi?id=82941
+
+ Reviewed by Andreas Kling.
+
+ CSSPropertyID enum holds all the CSS property ids but many parts of WebKit treat the ids
+ as integers. While it's not incorrect it is nicer to use the enum as a parameter of
+ functions manipulating property ids, as we ensure that the value passed will be an
+ existing value. It will also feel more correct after this patch that CSSProperty::id()
+ return a value of the enum rather than an integer. As this modification is quite big this
+ is the first part only so it will be easier to review.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::styleProperty): Adapt to the API change and also remove an unecessary name->id
+ conversion.
+
2012-04-02 Casper van Donderen <[email protected]>
Qt: Doc: Fix typo which marks document to be printed in console font.