diff options
author | Ben Murdoch <benm@google.com> | 2010-07-22 15:37:06 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-07-27 10:20:25 +0100 |
commit | 967717af5423377c967781471ee106e2bb4e11c8 (patch) | |
tree | 1e701dc0a12f7f07cce1df4a7681717de77a211b /WebCore/css | |
parent | dcc30a9fca45f634b1d3a12b276d3a0ccce99fc3 (diff) | |
download | external_webkit-967717af5423377c967781471ee106e2bb4e11c8.zip external_webkit-967717af5423377c967781471ee106e2bb4e11c8.tar.gz external_webkit-967717af5423377c967781471ee106e2bb4e11c8.tar.bz2 |
Merge WebKit at r63859 : Initial merge by git.
Change-Id: Ie8096c63ec7c991c9a9cba8bdd9c3b74a3b8ed62
Diffstat (limited to 'WebCore/css')
-rw-r--r-- | WebCore/css/CSSComputedStyleDeclaration.cpp | 8 | ||||
-rw-r--r-- | WebCore/css/CSSParser.cpp | 72 | ||||
-rw-r--r-- | WebCore/css/CSSProperty.cpp | 20 | ||||
-rw-r--r-- | WebCore/css/CSSPropertyNames.in | 9 | ||||
-rw-r--r-- | WebCore/css/CSSSegmentedFontFace.cpp | 19 | ||||
-rw-r--r-- | WebCore/css/CSSSegmentedFontFace.h | 3 | ||||
-rw-r--r-- | WebCore/css/CSSSelector.cpp | 75 | ||||
-rw-r--r-- | WebCore/css/CSSSelector.h | 10 | ||||
-rw-r--r-- | WebCore/css/CSSStyleSelector.cpp | 27 | ||||
-rw-r--r-- | WebCore/css/CSSStyleSelector.h | 8 | ||||
-rw-r--r-- | WebCore/css/WebKitCSSTransformValue.idl | 3 |
11 files changed, 189 insertions, 65 deletions
diff --git a/WebCore/css/CSSComputedStyleDeclaration.cpp b/WebCore/css/CSSComputedStyleDeclaration.cpp index 2ebab06..44ff1fc 100644 --- a/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -1482,6 +1482,14 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper break; /* Directional properties are resolved by resolveDirectionAwareProperty() before the switch. */ + case CSSPropertyWebkitBorderEnd: + case CSSPropertyWebkitBorderEndColor: + case CSSPropertyWebkitBorderEndStyle: + case CSSPropertyWebkitBorderEndWidth: + case CSSPropertyWebkitBorderStart: + case CSSPropertyWebkitBorderStartColor: + case CSSPropertyWebkitBorderStartStyle: + case CSSPropertyWebkitBorderStartWidth: case CSSPropertyWebkitMarginEnd: case CSSPropertyWebkitMarginStart: case CSSPropertyWebkitPaddingEnd: diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp index be410b4..6bf7751 100644 --- a/WebCore/css/CSSParser.cpp +++ b/WebCore/css/CSSParser.cpp @@ -812,6 +812,8 @@ bool CSSParser::parseValue(int propId, bool important) case CSSPropertyBorderRightStyle: // Defined as: none | hidden | dotted | dashed | case CSSPropertyBorderBottomStyle: // solid | double | groove | ridge | inset | outset case CSSPropertyBorderLeftStyle: + case CSSPropertyWebkitBorderStartStyle: + case CSSPropertyWebkitBorderEndStyle: case CSSPropertyWebkitColumnRuleStyle: if (id >= CSSValueNone && id <= CSSValueDouble) validPrimitive = true; @@ -851,12 +853,14 @@ bool CSSParser::parseValue(int propId, bool important) break; } /* nobreak */ - case CSSPropertyBackgroundColor: // <color> | inherit - case CSSPropertyBorderTopColor: // <color> | inherit - case CSSPropertyBorderRightColor: // <color> | inherit - case CSSPropertyBorderBottomColor: // <color> | inherit - case CSSPropertyBorderLeftColor: // <color> | inherit - case CSSPropertyColor: // <color> | inherit + case CSSPropertyBackgroundColor: // <color> | inherit + case CSSPropertyBorderTopColor: // <color> | inherit + case CSSPropertyBorderRightColor: + case CSSPropertyBorderBottomColor: + case CSSPropertyBorderLeftColor: + case CSSPropertyWebkitBorderStartColor: + case CSSPropertyWebkitBorderEndColor: + case CSSPropertyColor: // <color> | inherit case CSSPropertyTextLineThroughColor: // CSS3 text decoration colors case CSSPropertyTextUnderlineColor: case CSSPropertyTextOverlineColor: @@ -1005,6 +1009,8 @@ bool CSSParser::parseValue(int propId, bool important) case CSSPropertyBorderRightWidth: // Which is defined as case CSSPropertyBorderBottomWidth: // thin | medium | thick | <length> case CSSPropertyBorderLeftWidth: + case CSSPropertyWebkitBorderStartWidth: + case CSSPropertyWebkitBorderEndWidth: case CSSPropertyWebkitColumnRuleWidth: if (id == CSSValueThin || id == CSSValueMedium || id == CSSValueThick) validPrimitive = true; @@ -1698,6 +1704,20 @@ bool CSSParser::parseValue(int propId, bool important) CSSPropertyBorderLeftColor }; return parseShorthand(propId, properties, 3, important); } + case CSSPropertyWebkitBorderStart: + // [ '-webkit-border-start-width' || 'border-style' || <color> ] | inherit + { + const int properties[3] = { CSSPropertyWebkitBorderStartWidth, CSSPropertyWebkitBorderStartStyle, + CSSPropertyWebkitBorderStartColor }; + return parseShorthand(propId, properties, 3, important); + } + case CSSPropertyWebkitBorderEnd: + // [ '-webkit-border-end-width' || 'border-style' || <color> ] | inherit + { + const int properties[3] = { CSSPropertyWebkitBorderEndWidth, CSSPropertyWebkitBorderEndStyle, + CSSPropertyWebkitBorderEndColor }; + return parseShorthand(propId, properties, 3, important); + } case CSSPropertyOutline: // [ 'outline-color' || 'outline-style' || 'outline-width' ] | inherit { @@ -5657,31 +5677,27 @@ static int cssPropertyID(const UChar* propertyName, unsigned length) const char* name = buffer; if (buffer[0] == '-') { - // If the prefix is -apple- or -khtml-, change it to -webkit-. - // This makes the string one character longer. - if (hasPrefix(buffer, length, "-apple-") || hasPrefix(buffer, length, "-khtml-")) { + if (!strcmp(buffer, "-apple-dashboard-region") || !strcmp(buffer, "-apple-line-clamp")) { + // Support two Apple-specific CSS properties previously used for + // the Dashboard and Safari RSS line clamping. memmove(buffer + 7, buffer + 6, length + 1 - 6); memcpy(buffer, "-webkit", 7); ++length; - } - - if (hasPrefix(buffer, length, "-webkit")) { - if (strcmp(buffer, "-webkit-opacity") == 0) { - // Honor -webkit-opacity as a synonym for opacity. - // This was the only syntax that worked in Safari 1.1, and may be in use on some websites and widgets. - const char* const opacity = "opacity"; - name = opacity; - length = strlen(opacity); - } else if (hasPrefix(buffer + 7, length - 7, "-border-")) { - // -webkit-border-*-*-radius worked in Safari 4 and earlier. -webkit-border-radius syntax - // differs from border-radius, so it is remains as a distinct property. - if (!strcmp(buffer + 15, "top-left-radius") - || !strcmp(buffer + 15, "top-right-radius") - || !strcmp(buffer + 15, "bottom-right-radius") - || !strcmp(buffer + 15, "bottom-left-radius")) { - name = buffer + 8; - length -= 8; - } + } else if (!strcmp(buffer, "-webkit-opacity")) { + // Honor -webkit-opacity as a synonym for opacity. This was the only + // syntax that worked in Safari 1.1, and may be in use on some websites and widgets. + const char* const opacity = "opacity"; + name = opacity; + length = 7; + } else if (hasPrefix(buffer, length, "-webkit-border-")) { + // -webkit-border-*-*-radius worked in Safari 4 and earlier. -webkit-border-radius syntax + // differs from border-radius, so it remains as a distinct property. + if (!strcmp(buffer + 15, "top-left-radius") + || !strcmp(buffer + 15, "top-right-radius") + || !strcmp(buffer + 15, "bottom-right-radius") + || !strcmp(buffer + 15, "bottom-left-radius")) { + name = buffer + 8; + length -= 8; } } } diff --git a/WebCore/css/CSSProperty.cpp b/WebCore/css/CSSProperty.cpp index 777c0c0..453b381 100644 --- a/WebCore/css/CSSProperty.cpp +++ b/WebCore/css/CSSProperty.cpp @@ -45,10 +45,30 @@ int CSSProperty::resolveDirectionAwareProperty(int propertyID, TextDirection dir return direction == LTR ? CSSPropertyMarginRight : CSSPropertyMarginLeft; case CSSPropertyWebkitMarginStart: return direction == LTR ? CSSPropertyMarginLeft : CSSPropertyMarginRight; + case CSSPropertyWebkitPaddingEnd: return direction == LTR ? CSSPropertyPaddingRight : CSSPropertyPaddingLeft; case CSSPropertyWebkitPaddingStart: return direction == LTR ? CSSPropertyPaddingLeft : CSSPropertyPaddingRight; + + case CSSPropertyWebkitBorderEnd: + return direction == LTR ? CSSPropertyBorderRight : CSSPropertyBorderLeft; + case CSSPropertyWebkitBorderEndColor: + return direction == LTR ? CSSPropertyBorderRightColor : CSSPropertyBorderLeftColor; + case CSSPropertyWebkitBorderEndStyle: + return direction == LTR ? CSSPropertyBorderRightStyle : CSSPropertyBorderLeftStyle; + case CSSPropertyWebkitBorderEndWidth: + return direction == LTR ? CSSPropertyBorderRightWidth : CSSPropertyBorderLeftWidth; + + case CSSPropertyWebkitBorderStart: + return direction == LTR ? CSSPropertyBorderLeft : CSSPropertyBorderRight; + case CSSPropertyWebkitBorderStartColor: + return direction == LTR ? CSSPropertyBorderLeftColor : CSSPropertyBorderRightColor; + case CSSPropertyWebkitBorderStartStyle: + return direction == LTR ? CSSPropertyBorderLeftStyle : CSSPropertyBorderRightStyle; + case CSSPropertyWebkitBorderStartWidth: + return direction == LTR ? CSSPropertyBorderLeftWidth : CSSPropertyBorderRightWidth; + default: return propertyID; } diff --git a/WebCore/css/CSSPropertyNames.in b/WebCore/css/CSSPropertyNames.in index a330abe..44216e0 100644 --- a/WebCore/css/CSSPropertyNames.in +++ b/WebCore/css/CSSPropertyNames.in @@ -173,14 +173,21 @@ z-index # whereas background-size: l; is equivalent to background-size: l auto; -webkit-background-size -webkit-binding +-webkit-border-end +-webkit-border-end-color +-webkit-border-end-style +-webkit-border-end-width -webkit-border-fit -webkit-border-horizontal-spacing -webkit-border-image - # -webkit-border-radius differs from border-radius only in the interpretation of # a value consisting of two lengths: "-webkit-border-radius: l1 l2;" is equivalent # to "border-radius: l1 / l2;" -webkit-border-radius +-webkit-border-start +-webkit-border-start-color +-webkit-border-start-style +-webkit-border-start-width -webkit-border-vertical-spacing -webkit-box-align -webkit-box-direction diff --git a/WebCore/css/CSSSegmentedFontFace.cpp b/WebCore/css/CSSSegmentedFontFace.cpp index b13dd9c..bda29f0 100644 --- a/WebCore/css/CSSSegmentedFontFace.cpp +++ b/WebCore/css/CSSSegmentedFontFace.cpp @@ -59,24 +59,15 @@ void CSSSegmentedFontFace::pruneTable() m_fontDataTable.clear(); } -bool CSSSegmentedFontFace::isLoaded() const -{ - unsigned size = m_fontFaces.size(); - for (unsigned i = 0; i < size; i++) { - if (!m_fontFaces[i]->isLoaded()) - return false; - } - return true; -} - bool CSSSegmentedFontFace::isValid() const { + // Valid if at least one font face is valid. unsigned size = m_fontFaces.size(); for (unsigned i = 0; i < size; i++) { - if (!m_fontFaces[i]->isValid()) - return false; + if (m_fontFaces[i]->isValid()) + return true; } - return true; + return false; } void CSSSegmentedFontFace::fontLoaded(CSSFontFace*) @@ -107,6 +98,8 @@ FontData* CSSSegmentedFontFace::getFontData(const FontDescription& fontDescripti unsigned size = m_fontFaces.size(); for (unsigned i = 0; i < size; i++) { + if (!m_fontFaces[i]->isValid()) + continue; FontTraitsMask traitsMask = m_fontFaces[i]->traitsMask(); bool syntheticBold = !(traitsMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask)) && (desiredTraitsMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask)); bool syntheticItalic = !(traitsMask & FontStyleItalicMask) && (desiredTraitsMask & FontStyleItalicMask); diff --git a/WebCore/css/CSSSegmentedFontFace.h b/WebCore/css/CSSSegmentedFontFace.h index 57a3c58..03ebe4a 100644 --- a/WebCore/css/CSSSegmentedFontFace.h +++ b/WebCore/css/CSSSegmentedFontFace.h @@ -45,8 +45,6 @@ public: static PassRefPtr<CSSSegmentedFontFace> create(CSSFontSelector* selector) { return adoptRef(new CSSSegmentedFontFace(selector)); } ~CSSSegmentedFontFace(); - bool isLoaded() const; - bool isValid() const; CSSFontSelector* fontSelector() const { return m_fontSelector; } void fontLoaded(CSSFontFace*); @@ -59,6 +57,7 @@ private: CSSSegmentedFontFace(CSSFontSelector*); void pruneTable(); + bool isValid() const; CSSFontSelector* m_fontSelector; HashMap<unsigned, SegmentedFontData*> m_fontDataTable; diff --git a/WebCore/css/CSSSelector.cpp b/WebCore/css/CSSSelector.cpp index 47ead5f..b1de4ec 100644 --- a/WebCore/css/CSSSelector.cpp +++ b/WebCore/css/CSSSelector.cpp @@ -31,11 +31,83 @@ #include <wtf/Assertions.h> #include <wtf/HashMap.h> #include <wtf/StdLibExtras.h> +#include <wtf/Vector.h> namespace WebCore { using namespace HTMLNames; +// A helper class to hold CSSSelectors. +class CSSSelectorBag : public Noncopyable { +public: + ~CSSSelectorBag() + { + deleteAllValues(m_stack); + } + + bool isEmpty() const + { + return m_stack.isEmpty(); + } + + void append(PassOwnPtr<CSSSelector> selector) + { + if (selector) + m_stack.append(selector.leakPtr()); + } + + PassOwnPtr<CSSSelector> takeAny() + { + ASSERT(!isEmpty()); + OwnPtr<CSSSelector> selector = adoptPtr(m_stack.last()); + m_stack.removeLast(); + return selector.release(); + } + +private: + Vector<CSSSelector*, 16> m_stack; +}; + +CSSSelector::~CSSSelector() +{ + // We should avoid a recursive destructor call, which causes stack overflow + // if CSS Selectors are deeply nested. + + // Early exit if we have already processed the children of this selector. + if (m_hasRareData) { + if (!m_data.m_rareData) + return; + } else if (!m_data.m_tagHistory) + return; + + CSSSelectorBag selectorsToBeDeleted; + if (m_hasRareData) { + selectorsToBeDeleted.append(m_data.m_rareData->m_tagHistory.release()); + selectorsToBeDeleted.append(m_data.m_rareData->m_simpleSelector.release()); + delete m_data.m_rareData; + } else + selectorsToBeDeleted.append(adoptPtr(m_data.m_tagHistory)); + + // Traverse the tree of CSSSelector and delete each CSSSelector iteratively. + while (!selectorsToBeDeleted.isEmpty()) { + OwnPtr<CSSSelector> selector(selectorsToBeDeleted.takeAny()); + ASSERT(selector); + if (selector->m_hasRareData) { + ASSERT(selector->m_data.m_rareData); + selectorsToBeDeleted.append(selector->m_data.m_rareData->m_tagHistory.release()); + selectorsToBeDeleted.append(selector->m_data.m_rareData->m_simpleSelector.release()); + delete selector->m_data.m_rareData; + // Clear the pointer so that a destructor of the selector, which is + // about to be called, can know the children are already processed. + selector->m_data.m_rareData = 0; + } else { + selectorsToBeDeleted.append(adoptPtr(selector->m_data.m_tagHistory)); + // Clear the pointer for the same reason. + selector->m_data.m_tagHistory = 0; + } + } +} + unsigned int CSSSelector::specificity() { if (m_isForPage) @@ -63,6 +135,7 @@ unsigned int CSSSelector::specificity() break; } + // FIXME: Avoid recursive calls to prevent possible stack overflow. if (CSSSelector* tagHistory = this->tagHistory()) s += tagHistory->specificity(); @@ -906,5 +979,5 @@ bool CSSSelector::RareData::matchNth(int count) return (m_b - count) % (-m_a) == 0; } } - + } // namespace WebCore diff --git a/WebCore/css/CSSSelector.h b/WebCore/css/CSSSelector.h index fc0dd7b..518ff2c 100644 --- a/WebCore/css/CSSSelector.h +++ b/WebCore/css/CSSSelector.h @@ -22,8 +22,8 @@ #ifndef CSSSelector_h #define CSSSelector_h -#include "RenderStyleConstants.h" #include "QualifiedName.h" +#include "RenderStyleConstants.h" #include <wtf/Noncopyable.h> #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> @@ -57,13 +57,7 @@ namespace WebCore { { } - ~CSSSelector() - { - if (m_hasRareData) - delete m_data.m_rareData; - else - delete m_data.m_tagHistory; - } + ~CSSSelector(); /** * Re-create selector text from selector's data diff --git a/WebCore/css/CSSStyleSelector.cpp b/WebCore/css/CSSStyleSelector.cpp index 44d9e66..516e0e2 100644 --- a/WebCore/css/CSSStyleSelector.cpp +++ b/WebCore/css/CSSStyleSelector.cpp @@ -2600,11 +2600,11 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme AtomicString value; // The language property is inherited, so we iterate over the parents // to find the first language. - while (n && value.isEmpty()) { + while (n && value.isNull()) { if (n->isElementNode()) { // Spec: xml:lang takes precedence -- http://www.w3.org/TR/xhtml1/#C_7 value = static_cast<Element*>(n)->fastGetAttribute(XMLNames::langAttr); - if (value.isEmpty()) + if (value.isNull()) value = static_cast<Element*>(n)->fastGetAttribute(langAttr); } else if (n->isDocumentNode()) // checking the MIME content-language @@ -2613,7 +2613,7 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme n = n->parent(); } const AtomicString& argument = sel->argument(); - if (value.isEmpty() || !value.startsWith(argument, false)) + if (value.isNull() || !value.startsWith(argument, false)) break; if (value.length() != argument.length() && value[argument.length()] != '-') break; @@ -5479,6 +5479,23 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) return; case CSSPropertyInvalid: return; + + // Directional properties are resolved by resolveDirectionAwareProperty() before the switch. + case CSSPropertyWebkitBorderEnd: + case CSSPropertyWebkitBorderEndColor: + case CSSPropertyWebkitBorderEndStyle: + case CSSPropertyWebkitBorderEndWidth: + case CSSPropertyWebkitBorderStart: + case CSSPropertyWebkitBorderStartColor: + case CSSPropertyWebkitBorderStartStyle: + case CSSPropertyWebkitBorderStartWidth: + case CSSPropertyWebkitMarginEnd: + case CSSPropertyWebkitMarginStart: + case CSSPropertyWebkitPaddingEnd: + case CSSPropertyWebkitPaddingStart: + ASSERT_NOT_REACHED(); + break; + case CSSPropertyFontStretch: case CSSPropertyPage: case CSSPropertyQuotes: @@ -5498,10 +5515,6 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) case CSSPropertyTextUnderlineStyle: case CSSPropertyTextUnderlineWidth: case CSSPropertyWebkitFontSizeDelta: - case CSSPropertyWebkitMarginEnd: - case CSSPropertyWebkitMarginStart: - case CSSPropertyWebkitPaddingEnd: - case CSSPropertyWebkitPaddingStart: case CSSPropertyWebkitTextDecorationsInEffect: case CSSPropertyWebkitTextStroke: case CSSPropertyWebkitVariableDeclarationBlock: diff --git a/WebCore/css/CSSStyleSelector.h b/WebCore/css/CSSStyleSelector.h index dca6c1c..6e4a26b 100644 --- a/WebCore/css/CSSStyleSelector.h +++ b/WebCore/css/CSSStyleSelector.h @@ -87,7 +87,6 @@ public: bool strictParsing, bool matchAuthorAndUserStyles); ~CSSStyleSelector(); - void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO); PassRefPtr<RenderStyle> styleForElement(Element* e, RenderStyle* parentStyle = 0, bool allowSharing = true, bool resolveForRootDefault = false, bool matchVisitedPseudoClass = false); void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList& list); @@ -105,6 +104,7 @@ public: #endif private: + void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO); void initElement(Element*); RenderStyle* locateSharedStyle(); Node* locateCousinList(Element* parent, unsigned depth = 1); @@ -119,11 +119,11 @@ public: PassRefPtr<CSSRuleList> styleRulesForElement(Element*, bool authorOnly); PassRefPtr<CSSRuleList> pseudoStyleRulesForElement(Element*, PseudoId, bool authorOnly); + private: // Given a CSS keyword in the range (xx-small to -webkit-xxx-large), this function will return // the correct font size scaled relative to the user's default (medium). static float fontSizeForKeyword(Document*, int keyword, bool monospace); - - private: + // When the CSS keyword "larger" is used, this function will attempt to match within the keyword // table, and failing that, will simply multiply by 1.2. float largerFontSize(float size, bool quirksMode) const; @@ -133,11 +133,11 @@ public: public: void setStyle(PassRefPtr<RenderStyle> s) { m_style = s; } // Used by the document when setting up its root style. - void setFontSize(FontDescription&, float size); void applyPropertyToStyle(int id, CSSValue*, RenderStyle*); private: + void setFontSize(FontDescription&, float size); static float getComputedSizeFromSpecifiedSize(Document*, RenderStyle*, bool isAbsoluteSize, float specifiedSize, bool useSVGZoomRules); public: diff --git a/WebCore/css/WebKitCSSTransformValue.idl b/WebCore/css/WebKitCSSTransformValue.idl index 087aa82..007097e 100644 --- a/WebCore/css/WebKitCSSTransformValue.idl +++ b/WebCore/css/WebKitCSSTransformValue.idl @@ -29,7 +29,8 @@ module css { interface [ - HasIndexGetter + HasIndexGetter, + DontCheckEnums ] WebKitCSSTransformValue : CSSValueList { // OperationTypes |