diff options
author | Ben Murdoch <benm@google.com> | 2010-06-15 19:36:43 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-06-16 14:52:28 +0100 |
commit | 545e470e52f0ac6a3a072bf559c796b42c6066b6 (patch) | |
tree | c0c14763654d84d37577dde512c3d3b4699a9e86 /WebCore/css | |
parent | 719298a66237d38ea5c05f1547123ad8aacbc237 (diff) | |
download | external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.zip external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.tar.gz external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.tar.bz2 |
Merge webkit.org at r61121: Initial merge by git.
Change-Id: Icd6db395c62285be384d137164d95d7466c98760
Diffstat (limited to 'WebCore/css')
25 files changed, 445 insertions, 107 deletions
diff --git a/WebCore/css/CSSComputedStyleDeclaration.cpp b/WebCore/css/CSSComputedStyleDeclaration.cpp index 35fbb7d..23366cf 100644 --- a/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -268,7 +268,8 @@ static const int computedProperties[] = { CSSPropertyWritingMode, CSSPropertyGlyphOrientationHorizontal, CSSPropertyGlyphOrientationVertical, - CSSPropertyWebkitSvgShadow + CSSPropertyWebkitSvgShadow, + CSSPropertyVectorEffect #endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR , diff --git a/WebCore/css/CSSCursorImageValue.cpp b/WebCore/css/CSSCursorImageValue.cpp index 239048d..f2e5d95 100644 --- a/WebCore/css/CSSCursorImageValue.cpp +++ b/WebCore/css/CSSCursorImageValue.cpp @@ -52,9 +52,9 @@ static inline SVGCursorElement* resourceReferencedByCursorElement(const String& } #endif -CSSCursorImageValue::CSSCursorImageValue(const String& url, const IntPoint& hotspot) +CSSCursorImageValue::CSSCursorImageValue(const String& url, const IntPoint& hotSpot) : CSSImageValue(url) - , m_hotspot(hotspot) + , m_hotSpot(hotSpot) { } @@ -90,11 +90,12 @@ bool CSSCursorImageValue::updateIfSVGCursorIsUsed(Element* element) return false; if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, element->document())) { + // FIXME: This will override hot spot specified in CSS, which is probably incorrect. float x = roundf(cursorElement->x().value(0)); - m_hotspot.setX(static_cast<int>(x)); + m_hotSpot.setX(static_cast<int>(x)); float y = roundf(cursorElement->y().value(0)); - m_hotspot.setY(static_cast<int>(y)); + m_hotSpot.setY(static_cast<int>(y)); if (cachedImageURL() != element->document()->completeURL(cursorElement->href())) clearCachedImage(); diff --git a/WebCore/css/CSSCursorImageValue.h b/WebCore/css/CSSCursorImageValue.h index efcdda6..742138c 100644 --- a/WebCore/css/CSSCursorImageValue.h +++ b/WebCore/css/CSSCursorImageValue.h @@ -32,14 +32,14 @@ class SVGElement; class CSSCursorImageValue : public CSSImageValue { public: - static PassRefPtr<CSSCursorImageValue> create(const String& url, const IntPoint& hotspot) + static PassRefPtr<CSSCursorImageValue> create(const String& url, const IntPoint& hotSpot) { - return adoptRef(new CSSCursorImageValue(url, hotspot)); + return adoptRef(new CSSCursorImageValue(url, hotSpot)); } virtual ~CSSCursorImageValue(); - IntPoint hotspot() const { return m_hotspot; } + IntPoint hotSpot() const { return m_hotSpot; } bool updateIfSVGCursorIsUsed(Element*); virtual StyleCachedImage* cachedImage(DocLoader*); @@ -49,9 +49,9 @@ public: #endif private: - CSSCursorImageValue(const String& url, const IntPoint& hotspot); + CSSCursorImageValue(const String& url, const IntPoint& hotSpot); - IntPoint m_hotspot; + IntPoint m_hotSpot; #if ENABLE(SVG) HashSet<SVGElement*> m_referencedElements; diff --git a/WebCore/css/CSSOMUtils.cpp b/WebCore/css/CSSOMUtils.cpp new file mode 100644 index 0000000..d1e9638 --- /dev/null +++ b/WebCore/css/CSSOMUtils.cpp @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "CSSOMUtils.h" + +#include "PlatformString.h" + +namespace WebCore { + +static void appendCharacter(UChar32 c, Vector<UChar>& appendTo) +{ + if (U16_LENGTH(c) == 1) + appendTo.append(static_cast<UChar>(c)); + else { + appendTo.append(U16_LEAD(c)); + appendTo.append(U16_TRAIL(c)); + } +} + +void serializeCharacter(UChar32 c, Vector<UChar>& appendTo) +{ + appendTo.append('\\'); + appendCharacter(c, appendTo); +} + +void serializeCharacterAsCodePoint(UChar32 c, Vector<UChar>& appendTo) +{ + append(appendTo, String::format("\\%x ", c)); +} + +void serializeIdentifier(const String& identifier, String& appendTo) +{ + Vector<UChar> addend; + serializeIdentifier(identifier, addend); + appendTo.append(String::adopt(addend)); +} + +void serializeIdentifier(const String& identifier, Vector<UChar>& appendTo) +{ + bool isFirst = true; + bool isSecond = false; + bool isFirstCharHyphen = false; + unsigned index = 0; + while (index < identifier.length()) { + UChar32 c = identifier.characterStartingAt(index); + index += U16_LENGTH(c); + + if (c <= 0x1f || (0x30 <= c && c <= 0x39 && (isFirst || (isSecond && isFirstCharHyphen)))) + serializeCharacterAsCodePoint(c, appendTo); + else if (c == 0x2d && isSecond && isFirstCharHyphen) + serializeCharacter(c, appendTo); + else if (0x80 <= c || c == 0x2d || c == 0x5f || (0x30 <= c && c <= 0x39) || (0x41 <= c && c <= 0x5a) || (0x61 <= c && c <= 0x7a)) + appendCharacter(c, appendTo); + else + serializeCharacter(c, appendTo); + + if (isFirst) { + isFirst = false; + isSecond = true; + isFirstCharHyphen = (c == 0x2d); + } else if (isSecond) { + isSecond = false; + } + } +} + +void serializeString(const String& string, String& appendTo) +{ + Vector<UChar> addend; + serializeString(string, addend); + appendTo.append(String::adopt(addend)); +} + +void serializeString(const String& string, Vector<UChar>& appendTo) +{ + appendTo.append('\"'); + + unsigned index = 0; + while (index < string.length()) { + UChar32 c = string.characterStartingAt(index); + index += U16_LENGTH(c); + if (c <= 0x1f) + serializeCharacterAsCodePoint(c, appendTo); + else if (c == 0x22 || c == 0x5c) + serializeCharacter(c, appendTo); + else + appendCharacter(c, appendTo); + } + + appendTo.append('\"'); +} + +} // namespace WebCore diff --git a/WebCore/css/CSSOMUtils.h b/WebCore/css/CSSOMUtils.h new file mode 100644 index 0000000..6602b35 --- /dev/null +++ b/WebCore/css/CSSOMUtils.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef CSSOMUtils_h +#define CSSOMUtils_h + +#include <wtf/Vector.h> +#include <wtf/unicode/Unicode.h> + +// Utilities for CSSOM http://dev.w3.org/csswg/cssom/ + +namespace WebCore { + +class String; + +// Common serializing methods. See: http://dev.w3.org/csswg/cssom/#common-serializing-idioms +void serializeCharacter(UChar32, Vector<UChar>& appendTo); +void serializeCharacterAsCodePoint(UChar32, Vector<UChar>& appendTo); +void serializeIdentifier(const String& identifier, String& appendTo); +void serializeIdentifier(const String& identifier, Vector<UChar>& appendTo); +void serializeString(const String& string, String& appendTo); +void serializeString(const String& string, Vector<UChar>& appendTo); + +} // namespace WebCore + +#endif // CSSOMUtils_h diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp index 76f9fb1..8934656 100644 --- a/WebCore/css/CSSParser.cpp +++ b/WebCore/css/CSSParser.cpp @@ -89,7 +89,7 @@ using namespace std; using namespace WTF; #include "CSSPropertyNames.cpp" -#include "CSSValueKeywords.c" +#include "CSSValueKeywords.cpp" #ifdef ANDROID_INSTRUMENT #include "TimeCounter.h" @@ -894,17 +894,17 @@ bool CSSParser::parseValue(int propId, bool important) coords.append(int(value->fValue)); value = m_valueList->next(); } - IntPoint hotspot; + IntPoint hotSpot(-1, -1); int nrcoords = coords.size(); if (nrcoords > 0 && nrcoords != 2) return false; if (nrcoords == 2) - hotspot = IntPoint(coords[0], coords[1]); + hotSpot = IntPoint(coords[0], coords[1]); if (!uri.isNull() && m_styleSheet) { // FIXME: The completeURL call should be done when using the CSSCursorImageValue, // not when creating it. - list->append(CSSCursorImageValue::create(m_styleSheet->completeURL(uri), hotspot)); + list->append(CSSCursorImageValue::create(m_styleSheet->completeURL(uri), hotSpot)); } if ((m_strict && !value) || (value && !(value->unit == CSSParserValue::Operator && value->iValue == ','))) @@ -3855,7 +3855,7 @@ PassRefPtr<CSSPrimitiveValue> CSSParser::parseColor(CSSParserValue* value) return CSSPrimitiveValue::createColor(c); } -bool CSSParser::parseColorFromValue(CSSParserValue* value, RGBA32& c, bool svg) +bool CSSParser::parseColorFromValue(CSSParserValue* value, RGBA32& c) { if (!m_strict && value->unit == CSSPrimitiveValue::CSS_NUMBER && value->fValue >= 0. && value->fValue < 1000000.) { @@ -3875,7 +3875,7 @@ bool CSSParser::parseColorFromValue(CSSParserValue* value, RGBA32& c, bool svg) if (!parseColorParameters(value, colorValues, false)) return false; c = makeRGB(colorValues[0], colorValues[1], colorValues[2]); - } else if (!svg) { + } else { if (value->unit == CSSParserValue::Function && value->function->args != 0 && value->function->args->size() == 7 /* rgba + three commas */ && @@ -3902,8 +3902,7 @@ bool CSSParser::parseColorFromValue(CSSParserValue* value, RGBA32& c, bool svg) c = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2], colorValues[3]); } else return false; - } else - return false; + } return true; } @@ -5628,7 +5627,7 @@ static int cssPropertyID(const UChar* propertyName, unsigned length) } } - const props* hashTableEntry = findProp(name, length); + const Property* hashTableEntry = findProperty(name, length); return hashTableEntry ? hashTableEntry->id : 0; } @@ -5670,7 +5669,7 @@ int cssValueKeywordID(const CSSParserString& string) } } - const css_value* hashTableEntry = findValue(buffer, length); + const Value* hashTableEntry = findValue(buffer, length); return hashTableEntry ? hashTableEntry->id : 0; } diff --git a/WebCore/css/CSSParser.h b/WebCore/css/CSSParser.h index 271e98e..81b1ae2 100644 --- a/WebCore/css/CSSParser.h +++ b/WebCore/css/CSSParser.h @@ -126,7 +126,7 @@ namespace WebCore { bool parseColorParameters(CSSParserValue*, int* colorValues, bool parseAlpha); bool parseHSLParameters(CSSParserValue*, double* colorValues, bool parseAlpha); PassRefPtr<CSSPrimitiveValue> parseColor(CSSParserValue* = 0); - bool parseColorFromValue(CSSParserValue*, RGBA32&, bool = false); + bool parseColorFromValue(CSSParserValue*, RGBA32&); void parseSelector(const String&, Document* doc, CSSSelectorList&); static bool parseColor(const String&, RGBA32& rgb, bool strict); diff --git a/WebCore/css/CSSPrimitiveValueMappings.h b/WebCore/css/CSSPrimitiveValueMappings.h index 0f302a0..f646b29 100644 --- a/WebCore/css/CSSPrimitiveValueMappings.h +++ b/WebCore/css/CSSPrimitiveValueMappings.h @@ -2,6 +2,8 @@ * Copyright (C) 2007 Alexey Proskuryakov <ap@nypop.com>. * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) + * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com> + * Copyright (C) Research In Motion Limited 2010. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -278,6 +280,18 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e) case MeterPart: m_value.ident = CSSValueMeter; break; + case RelevancyLevelIndicatorPart: + m_value.ident = CSSValueRelevancyLevelIndicator; + break; + case ContinuousCapacityLevelIndicatorPart: + m_value.ident = CSSValueContinuousCapacityLevelIndicator; + break; + case DiscreteCapacityLevelIndicatorPart: + m_value.ident = CSSValueDiscreteCapacityLevelIndicator; + break; + case RatingLevelIndicatorPart: + m_value.ident = CSSValueRatingLevelIndicator; + break; case OuterSpinButtonPart: m_value.ident = CSSValueOuterSpinButton; break; @@ -2587,6 +2601,33 @@ template<> inline CSSPrimitiveValue::operator EWritingMode() const return static_cast<EWritingMode>(m_value.ident - CSSValueLrTb); } +template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EVectorEffect e) + : m_type(CSS_IDENT) + , m_hasCachedCSSText(false) +{ + switch (e) { + case VE_NONE: + m_value.ident = CSSValueNone; + break; + case VE_NON_SCALING_STROKE: + m_value.ident = CSSValueNonScalingStroke; + break; + } +} + +template<> inline CSSPrimitiveValue::operator EVectorEffect() const +{ + switch (m_value.ident) { + case CSSValueNone: + return VE_NONE; + case CSSValueNonScalingStroke: + return VE_NON_SCALING_STROKE; + default: + ASSERT_NOT_REACHED(); + return VE_NONE; + } +} + #endif } diff --git a/WebCore/css/CSSSelector.cpp b/WebCore/css/CSSSelector.cpp index 5add90b..e45bf4c 100644 --- a/WebCore/css/CSSSelector.cpp +++ b/WebCore/css/CSSSelector.cpp @@ -25,9 +25,9 @@ #include "config.h" #include "CSSSelector.h" -#include "wtf/Assertions.h" +#include "CSSOMUtils.h" #include "HTMLNames.h" - +#include <wtf/Assertions.h> #include <wtf/HashMap.h> #include <wtf/StdLibExtras.h> @@ -585,10 +585,10 @@ String CSSSelector::selectorText() const while (true) { if (cs->m_match == CSSSelector::Id) { str += "#"; - str += cs->m_value; + serializeIdentifier(cs->m_value, str); } else if (cs->m_match == CSSSelector::Class) { str += "."; - str += cs->m_value; + serializeIdentifier(cs->m_value, str); } else if (cs->m_match == CSSSelector::PseudoClass || cs->m_match == CSSSelector::PagePseudoClass) { str += ":"; str += cs->m_value; @@ -640,9 +640,8 @@ String CSSSelector::selectorText() const break; } if (cs->m_match != CSSSelector::Set) { - str += "\""; - str += cs->m_value; - str += "\"]"; + serializeString(cs->m_value, str); + str += "]"; } } if (cs->relation() != CSSSelector::SubSelector || !cs->tagHistory()) diff --git a/WebCore/css/CSSStyleSelector.cpp b/WebCore/css/CSSStyleSelector.cpp index 92ba843..13bdeb9 100644 --- a/WebCore/css/CSSStyleSelector.cpp +++ b/WebCore/css/CSSStyleSelector.cpp @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) - * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) @@ -357,7 +357,8 @@ public: typedef HashMap<AtomicStringImpl*, CSSRuleDataList*> AtomRuleMap; void addRulesFromSheet(CSSStyleSheet*, const MediaQueryEvaluator&, CSSStyleSelector* = 0); - + + void addStyleRule(StyleBase* item); void addRule(CSSStyleRule* rule, CSSSelector* sel); void addPageRule(CSSStyleRule* rule, CSSSelector* sel); void addToRuleSet(AtomicStringImpl* key, AtomRuleMap& map, @@ -666,7 +667,7 @@ void CSSStyleSelector::matchRules(CSSRuleSet* rules, int& firstRuleIndex, int& l // We need to collect the rules for id, class, tag, and everything else into a buffer and // then sort the buffer. if (m_element->hasID()) - matchRulesForList(rules->getIDRules(m_element->getIDAttribute().impl()), firstRuleIndex, lastRuleIndex); + matchRulesForList(rules->getIDRules(m_element->idForStyleResolution().impl()), firstRuleIndex, lastRuleIndex); if (m_element->hasClass()) { ASSERT(m_styledElement); const SpaceSplitString& classNames = m_styledElement->classNames(); @@ -2037,7 +2038,7 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme return e->hasClass() && static_cast<StyledElement*>(e)->classNames().contains(sel->m_value); if (sel->m_match == CSSSelector::Id) - return e->hasID() && e->getIDAttribute() == sel->m_value; + return e->hasID() && e->idForStyleResolution() == sel->m_value; const QualifiedName& attr = sel->attribute(); @@ -2768,14 +2769,7 @@ void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet, const MediaQueryEvaluat for (int i = 0; i < len; i++) { StyleBase* item = sheet->item(i); if (item->isStyleRule()) { - if (item->isPageRule()) { - CSSPageRule* pageRule = static_cast<CSSPageRule*>(item); - addPageRule(pageRule, pageRule->selectorList().first()); - } else { - CSSStyleRule* rule = static_cast<CSSStyleRule*>(item); - for (CSSSelector* s = rule->selectorList().first(); s; s = CSSSelectorList::next(s)) - addRule(rule, s); - } + addStyleRule(item); } else if (item->isImportRule()) { CSSImportRule* import = static_cast<CSSImportRule*>(item); @@ -2792,9 +2786,7 @@ void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet, const MediaQueryEvaluat CSSRule *childItem = rules->item(j); if (childItem->isStyleRule()) { // It is a StyleRule, so append it to our list - CSSStyleRule* rule = static_cast<CSSStyleRule*>(childItem); - for (CSSSelector* s = rule->selectorList().first(); s; s = CSSSelectorList::next(s)) - addRule(rule, s); + addStyleRule(childItem); } else if (childItem->isFontFaceRule() && styleSelector) { // Add this font face to our set. const CSSFontFaceRule* fontFaceRule = static_cast<CSSFontFaceRule*>(childItem); @@ -2819,6 +2811,18 @@ void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet, const MediaQueryEvaluat } } +void CSSRuleSet::addStyleRule(StyleBase* item) +{ + if (item->isPageRule()) { + CSSPageRule* pageRule = static_cast<CSSPageRule*>(item); + addPageRule(pageRule, pageRule->selectorList().first()); + } else { + CSSStyleRule* rule = static_cast<CSSStyleRule*>(item); + for (CSSSelector* s = rule->selectorList().first(); s; s = CSSSelectorList::next(s)) + addRule(rule, s); + } +} + // ------------------------------------------------------------------------------------- // this is mostly boring stuff on how to apply a certain rule to the renderstyle... @@ -3393,7 +3397,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) // StyleImage. RefPtr<StyleCachedImage> styleCachedImage(image->cachedImage(m_element->document()->docLoader())); if (styleCachedImage) - m_style->addCursor(styleCachedImage->cachedImage(), image->hotspot()); + m_style->addCursor(styleCachedImage->cachedImage(), image->hotSpot()); } else if (type == CSSPrimitiveValue::CSS_IDENT) m_style->setCursor(*primitiveValue); } diff --git a/WebCore/css/CSSStyleSheet.cpp b/WebCore/css/CSSStyleSheet.cpp index fb25374..ad63265 100644 --- a/WebCore/css/CSSStyleSheet.cpp +++ b/WebCore/css/CSSStyleSheet.cpp @@ -207,7 +207,7 @@ void CSSStyleSheet::checkLoaded() if (parent()) parent()->checkLoaded(); - // Avoid |this| being deleted by scripts that run via HTMLTokenizer::executeScriptsWaitingForStylesheets(). + // Avoid |this| being deleted by scripts that run via HTMLDocumentParser::executeScriptsWaitingForStylesheets(). // See <rdar://problem/6622300>. RefPtr<CSSStyleSheet> protector(this); m_loadCompleted = ownerNode() ? ownerNode()->sheetLoaded() : true; @@ -245,8 +245,7 @@ void CSSStyleSheet::addSubresourceStyleURLs(ListHashSet<KURL>& urls) styleSheetQueue.append(this); while (!styleSheetQueue.isEmpty()) { - CSSStyleSheet* styleSheet = styleSheetQueue.first(); - styleSheetQueue.removeFirst(); + CSSStyleSheet* styleSheet = styleSheetQueue.takeFirst(); for (unsigned i = 0; i < styleSheet->length(); ++i) { StyleBase* styleBase = styleSheet->item(i); diff --git a/WebCore/css/CSSValueKeywords.in b/WebCore/css/CSSValueKeywords.in index a20e64f..154183b 100644 --- a/WebCore/css/CSSValueKeywords.in +++ b/WebCore/css/CSSValueKeywords.in @@ -604,8 +604,12 @@ searchfield-results-decoration searchfield-results-button searchfield-cancel-button textfield -textarea caps-lock-indicator +relevancy-level-indicator +continuous-capacity-level-indicator +discrete-capacity-level-indicator +rating-level-indicator +textarea # # CSS_PROP_BORDER_IMAGE diff --git a/WebCore/css/MediaQuery.cpp b/WebCore/css/MediaQuery.cpp index ff57372..187a33d 100644 --- a/WebCore/css/MediaQuery.cpp +++ b/WebCore/css/MediaQuery.cpp @@ -2,6 +2,7 @@ * CSS Media Query * * Copyright (C) 2005, 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,69 +30,100 @@ #include "MediaQuery.h" #include "MediaQueryExp.h" +#include "StringBuilder.h" + +#include <algorithm> namespace WebCore { -MediaQuery::MediaQuery(Restrictor r, const String& mediaType, Vector<MediaQueryExp*>* exprs) +// http://dev.w3.org/csswg/cssom/#serialize-a-media-query +String MediaQuery::serialize() const +{ + StringBuilder result; + + switch (m_restrictor) { + case MediaQuery::Only: + result.append("only "); + break; + case MediaQuery::Not: + result.append("not "); + break; + case MediaQuery::None: + break; + } + + if (m_expressions->isEmpty()) { + result.append(m_mediaType); + return result.toString(); + } + + if (m_mediaType != "all" || m_restrictor != None) { + result.append(m_mediaType); + result.append(" and "); + } + + result.append(m_expressions->at(0)->serialize()); + for (size_t i = 1; i < m_expressions->size(); ++i) { + result.append(" and "); + result.append(m_expressions->at(i)->serialize()); + } + return result.toString(); +} + +static bool expressionCompare(const MediaQueryExp* a, const MediaQueryExp* b) +{ + return codePointCompare(a->serialize(), b->serialize()) < 0; +} + +MediaQuery::MediaQuery(Restrictor r, const String& mediaType, PassOwnPtr<Vector<MediaQueryExp*> > exprs) : m_restrictor(r) - , m_mediaType(mediaType) - , m_expressions(exprs) + , m_mediaType(mediaType.lower()) + , m_expressions(exprs.release()) + , m_ignored(false) { - if (!m_expressions) + if (!m_expressions) { m_expressions = new Vector<MediaQueryExp*>; + return; + } + + std::sort(m_expressions->begin(), m_expressions->end(), expressionCompare); + + // remove all duplicated expressions + String key; + for (int i = m_expressions->size() - 1; i >= 0; --i) { + + // if not all of the expressions is valid the media query must be ignored. + if (!m_ignored) + m_ignored = !m_expressions->at(i)->isValid(); + + if (m_expressions->at(i)->serialize() == key) { + MediaQueryExp* item = m_expressions->at(i); + m_expressions->remove(i); + delete item; + } else + key = m_expressions->at(i)->serialize(); + } } MediaQuery::~MediaQuery() { - if (m_expressions) { - deleteAllValues(*m_expressions); - delete m_expressions; - } + deleteAllValues(*m_expressions); + delete m_expressions; } +// http://dev.w3.org/csswg/cssom/#compare-media-queries bool MediaQuery::operator==(const MediaQuery& other) const { - if (m_restrictor != other.m_restrictor - || m_mediaType != other.m_mediaType - || m_expressions->size() != other.m_expressions->size()) - return false; - - for (size_t i = 0; i < m_expressions->size(); ++i) { - MediaQueryExp* exp = m_expressions->at(i); - MediaQueryExp* oexp = other.m_expressions->at(i); - if (!(*exp == *oexp)) - return false; - } - - return true; + return cssText() == other.cssText(); } +// http://dev.w3.org/csswg/cssom/#serialize-a-list-of-media-queries String MediaQuery::cssText() const { - String text; - switch (m_restrictor) { - case MediaQuery::Only: - text += "only "; - break; - case MediaQuery::Not: - text += "not "; - break; - case MediaQuery::None: - default: - break; - } - text += m_mediaType; - for (size_t i = 0; i < m_expressions->size(); ++i) { - MediaQueryExp* exp = m_expressions->at(i); - text += " and ("; - text += exp->mediaFeature(); - if (exp->value()) { - text += ": "; - text += exp->value()->cssText(); - } - text += ")"; - } - return text; + if (m_serializationCache.isNull()) + const_cast<MediaQuery*>(this)->m_serializationCache = serialize(); + + return m_serializationCache; } } //namespace diff --git a/WebCore/css/MediaQuery.h b/WebCore/css/MediaQuery.h index 7cbd3bf..ccc59ac 100644 --- a/WebCore/css/MediaQuery.h +++ b/WebCore/css/MediaQuery.h @@ -2,6 +2,7 @@ * CSS Media Query * * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,7 +30,9 @@ #define MediaQuery_h #include "PlatformString.h" +#include <wtf/PassOwnPtr.h> #include <wtf/Vector.h> +#include <wtf/text/StringHash.h> namespace WebCore { class MediaQueryExp; @@ -40,20 +43,24 @@ public: Only, Not, None }; - MediaQuery(Restrictor r, const String& mediaType, Vector<MediaQueryExp*>* exprs); + MediaQuery(Restrictor r, const String& mediaType, PassOwnPtr<Vector<MediaQueryExp*> > exprs); ~MediaQuery(); Restrictor restrictor() const { return m_restrictor; } const Vector<MediaQueryExp*>* expressions() const { return m_expressions; } String mediaType() const { return m_mediaType; } bool operator==(const MediaQuery& other) const; - void append(MediaQueryExp* newExp) { m_expressions->append(newExp); } String cssText() const; + bool ignored() const { return m_ignored; } private: Restrictor m_restrictor; String m_mediaType; Vector<MediaQueryExp*>* m_expressions; + bool m_ignored; + String m_serializationCache; + + String serialize() const; }; } // namespace diff --git a/WebCore/css/MediaQueryEvaluator.cpp b/WebCore/css/MediaQueryEvaluator.cpp index 20c7bb9..9d5822f 100644 --- a/WebCore/css/MediaQueryEvaluator.cpp +++ b/WebCore/css/MediaQueryEvaluator.cpp @@ -144,6 +144,9 @@ bool MediaQueryEvaluator::eval(const MediaList* mediaList, CSSStyleSelector* sty for (size_t i = 0; i < queries.size() && !result; ++i) { MediaQuery* query = queries.at(i); + if (query->ignored()) + continue; + if (mediaTypeMatch(query->mediaType())) { const Vector<MediaQueryExp*>* exps = query->expressions(); // iterate through expressions, stop if any of them eval to false diff --git a/WebCore/css/MediaQueryExp.cpp b/WebCore/css/MediaQueryExp.cpp index 53c0b73..a93ddcc 100644 --- a/WebCore/css/MediaQueryExp.cpp +++ b/WebCore/css/MediaQueryExp.cpp @@ -2,6 +2,7 @@ * CSS Media Query * * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -31,6 +32,7 @@ #include "CSSParser.h" #include "CSSPrimitiveValue.h" #include "CSSValueList.h" +#include "StringBuilder.h" namespace WebCore { @@ -82,4 +84,22 @@ MediaQueryExp::~MediaQueryExp() { } +String MediaQueryExp::serialize() const +{ + if (!m_serializationCache.isNull()) + return m_serializationCache; + + StringBuilder result; + result.append("("); + result.append(m_mediaFeature.lower()); + if (m_value) { + result.append(": "); + result.append(m_value->cssText()); + } + result.append(")"); + + const_cast<MediaQueryExp*>(this)->m_serializationCache = result.toString(); + return m_serializationCache; +} + } // namespace diff --git a/WebCore/css/MediaQueryExp.h b/WebCore/css/MediaQueryExp.h index 9272402..24f2207 100644 --- a/WebCore/css/MediaQueryExp.h +++ b/WebCore/css/MediaQueryExp.h @@ -2,6 +2,7 @@ * CSS Media Query * * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -64,10 +65,14 @@ public: m_mediaFeature == MediaFeatureNames::aspect_ratioMediaFeature || m_mediaFeature == MediaFeatureNames::min_aspect_ratioMediaFeature || m_mediaFeature == MediaFeatureNames::max_aspect_ratioMediaFeature; } + + String serialize() const; + private: AtomicString m_mediaFeature; RefPtr<CSSValue> m_value; bool m_isValid; + String m_serializationCache; }; } // namespace diff --git a/WebCore/css/SVGCSSComputedStyleDeclaration.cpp b/WebCore/css/SVGCSSComputedStyleDeclaration.cpp index 25da148..00cb308 100644 --- a/WebCore/css/SVGCSSComputedStyleDeclaration.cpp +++ b/WebCore/css/SVGCSSComputedStyleDeclaration.cpp @@ -168,6 +168,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getSVGPropertyCSSValue(int pro } case CSSPropertyWebkitSvgShadow: return valueForShadow(svgStyle->shadow(), propertyID); + case CSSPropertyVectorEffect: + return CSSPrimitiveValue::create(svgStyle->vectorEffect()); case CSSPropertyMarker: case CSSPropertyEnableBackground: case CSSPropertyColorProfile: diff --git a/WebCore/css/SVGCSSParser.cpp b/WebCore/css/SVGCSSParser.cpp index 0986f1c..0d5cde6 100644 --- a/WebCore/css/SVGCSSParser.cpp +++ b/WebCore/css/SVGCSSParser.cpp @@ -183,7 +183,7 @@ bool CSSParser::parseSVGValue(int propId, bool important) parsedValue = SVGPaint::create(SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR); else if (value->unit == CSSPrimitiveValue::CSS_URI) { RGBA32 c = Color::transparent; - if (m_valueList->next() && parseColorFromValue(m_valueList->current(), c, true)) { + if (m_valueList->next() && parseColorFromValue(m_valueList->current(), c)) { parsedValue = SVGPaint::create(value->string, c); } else parsedValue = SVGPaint::create(SVGPaint::SVG_PAINTTYPE_URI, value->string); @@ -221,6 +221,11 @@ bool CSSParser::parseSVGValue(int propId, bool important) m_valueList->next(); break; + + case CSSPropertyVectorEffect: // none | non-scaling-stroke | inherit + if (id == CSSValueNone || id == CSSValueNonScalingStroke) + valid_primitive = true; + break; case CSSPropertyWritingMode: // lr-tb | rl_tb | tb-rl | lr | rl | tb | inherit @@ -330,7 +335,7 @@ PassRefPtr<CSSValue> CSSParser::parseSVGStrokeDasharray() PassRefPtr<CSSValue> CSSParser::parseSVGPaint() { RGBA32 c = Color::transparent; - if (!parseColorFromValue(m_valueList->current(), c, true)) + if (!parseColorFromValue(m_valueList->current(), c)) return SVGPaint::create(); return SVGPaint::create(Color(c)); } @@ -338,7 +343,7 @@ PassRefPtr<CSSValue> CSSParser::parseSVGPaint() PassRefPtr<CSSValue> CSSParser::parseSVGColor() { RGBA32 c = Color::transparent; - if (!parseColorFromValue(m_valueList->current(), c, true)) + if (!parseColorFromValue(m_valueList->current(), c)) return 0; return SVGColor::create(Color(c)); } diff --git a/WebCore/css/SVGCSSPropertyNames.in b/WebCore/css/SVGCSSPropertyNames.in index 9f97146..7c157a8 100644 --- a/WebCore/css/SVGCSSPropertyNames.in +++ b/WebCore/css/SVGCSSPropertyNames.in @@ -45,6 +45,7 @@ glyph-orientation-horizontal glyph-orientation-vertical kerning text-anchor +vector-effect writing-mode -webkit-svg-shadow diff --git a/WebCore/css/SVGCSSStyleSelector.cpp b/WebCore/css/SVGCSSStyleSelector.cpp index 1deb259..3b38890 100644 --- a/WebCore/css/SVGCSSStyleSelector.cpp +++ b/WebCore/css/SVGCSSStyleSelector.cpp @@ -552,6 +552,14 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value) svgstyle->setShadow(shadowData); return; } + case CSSPropertyVectorEffect: { + HANDLE_INHERIT_AND_INITIAL(vectorEffect, VectorEffect) + if (!primitiveValue) + break; + + svgstyle->setVectorEffect(*primitiveValue); + break; + } default: // If you crash here, it's because you added a css property and are not handling it // in either this switch statement or the one in CSSStyleSelector::applyProperty diff --git a/WebCore/css/SVGCSSValueKeywords.in b/WebCore/css/SVGCSSValueKeywords.in index 91fb57e..420fbd8 100644 --- a/WebCore/css/SVGCSSValueKeywords.in +++ b/WebCore/css/SVGCSSValueKeywords.in @@ -273,6 +273,11 @@ reset-size # middle # end +# CSS_PROP_VECTOR_EFFECT +# none +non-scaling-stroke + + # CSS_PROP_WRITING_MODE lr-tb rl-tb diff --git a/WebCore/css/StyleSheet.idl b/WebCore/css/StyleSheet.idl index 4f53689..5b52a33 100644 --- a/WebCore/css/StyleSheet.idl +++ b/WebCore/css/StyleSheet.idl @@ -33,6 +33,12 @@ module stylesheets { readonly attribute [ConvertNullStringTo=Null] DOMString href; readonly attribute [ConvertNullStringTo=Null] DOMString title; readonly attribute MediaList media; + +#if defined(LANGUAGE_CPP) && LANGUAGE_CPP + // Extra WebCore methods exposed to allowe compile-time casting in C++ + boolean isCSSStyleSheet(); +#endif + }; } diff --git a/WebCore/css/makeprop.pl b/WebCore/css/makeprop.pl index 115969f..0fd1f08 100644 --- a/WebCore/css/makeprop.pl +++ b/WebCore/css/makeprop.pl @@ -5,6 +5,7 @@ # Copyright (C) 1999 Waldo Bastian (bastian@kde.org) # Copyright (C) 2007, 2008 Apple Inc. All rights reserved. # Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) +# Copyright (C) 2010 Andras Becsi (abecsi@inf.u-szeged.hu), University of Szeged # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -39,10 +40,20 @@ print GPERF << "EOF"; /* This file is automatically generated from CSSPropertyNames.in by makeprop, do not edit */ #include \"CSSPropertyNames.h\" %} -struct props { +%struct-type +struct Property { const char* name; int id; }; +%language=ANSI-C +%readonly-tables +%global-table +%compare-strncmp +%define lookup-function-name findProperty +%define hash-function-name propery_hash_function +%define word-array-name property_wordlist +%includes +%enum %% EOF @@ -88,12 +99,13 @@ print HEADER << "EOF"; const char* getPropertyName(CSSPropertyID); -#endif +#endif // CSSPropertyNames_h + EOF close HEADER; -system("gperf -a -L ANSI-C -E -C -c -o -t --key-positions=\"*\" -NfindProp -Hhash_prop -Wwordlist_prop -D -s 2 CSSPropertyNames.gperf > CSSPropertyNames.cpp") == 0 || die "calling gperf failed: $?"; +system("gperf --key-positions=\"*\" -D -n -s 2 CSSPropertyNames.gperf > CSSPropertyNames.cpp") == 0 || die "calling gperf failed: $?"; open C, ">>CSSPropertyNames.cpp" || die "Could not open CSSPropertyNames.cpp for writing"; print C "static const char * const propertyNameStrings[$num] = {\n"; diff --git a/WebCore/css/makevalues.pl b/WebCore/css/makevalues.pl index e49981d..421e470 100644 --- a/WebCore/css/makevalues.pl +++ b/WebCore/css/makevalues.pl @@ -5,6 +5,7 @@ # Copyright (C) 1999 Waldo Bastian (bastian@kde.org) # Copyright (C) 2007 Apple Inc. All rights reserved. # Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) +# Copyright (C) 2010 Andras Becsi (abecsi@inf.u-szeged.hu), University of Szeged # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -40,10 +41,19 @@ print GPERF << "EOF"; #include \"CSSValueKeywords.h\" %} -struct css_value { +%struct-type +struct Value { const char* name; int id; }; +%language=ANSI-C +%readonly-tables +%compare-strncmp +%define lookup-function-name findValue +%define hash-function-name value_hash_function +%define word-array-name value_word_list +%includes +%enum %% EOF @@ -59,8 +69,8 @@ open HEADER, ">CSSValueKeywords.h" || die "Could not open CSSValueKeywords.h for print HEADER << "EOF"; /* This file is automatically generated from CSSValueKeywords.in by makevalues, do not edit */ -#ifndef CSSValues_h -#define CSSValues_h +#ifndef CSSValueKeywords_h +#define CSSValueKeywords_h const int CSSValueInvalid = 0; EOF @@ -82,13 +92,13 @@ print HEADER << "EOF"; const char* getValueName(unsigned short id); -#endif +#endif // CSSValueKeywords_h EOF close HEADER; -system("gperf -L ANSI-C -E -C -n -o -t --key-positions=\"*\" -NfindValue -Hhash_val -Wwordlist_value -D CSSValueKeywords.gperf > CSSValueKeywords.c") == 0 || die "calling gperf failed: $?"; +system("gperf --key-positions=\"*\" -D -n -s 2 CSSValueKeywords.gperf > CSSValueKeywords.cpp") == 0 || die "calling gperf failed: $?"; -open C, ">>CSSValueKeywords.c" || die "Could not open CSSValueKeywords.c for writing"; +open C, ">>CSSValueKeywords.cpp" || die "Could not open CSSValueKeywords.cpp for writing"; print C "static const char * const valueList[] = {\n"; print C "\"\",\n"; foreach my $name (@names) { |