| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> | 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
| 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
| 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. | 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 return list.release(); | 883 return list.release(); |
| 884 } | 884 } |
| 885 | 885 |
| 886 static PassRefPtr<CSSValue> createLineBoxContainValue(unsigned lineBoxContain) | 886 static PassRefPtr<CSSValue> createLineBoxContainValue(unsigned lineBoxContain) |
| 887 { | 887 { |
| 888 if (!lineBoxContain) | 888 if (!lineBoxContain) |
| 889 return cssValuePool().createIdentifierValue(CSSValueNone); | 889 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 890 return CSSLineBoxContainValue::create(lineBoxContain); | 890 return CSSLineBoxContainValue::create(lineBoxContain); |
| 891 } | 891 } |
| 892 | 892 |
| 893 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n, boo
l allowVisitedStyle, const String& pseudoElementName) | 893 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n, boo
l allowVisitedStyle) |
| 894 : m_node(n) | 894 : m_node(n) |
| 895 , m_allowVisitedStyle(allowVisitedStyle) | 895 , m_allowVisitedStyle(allowVisitedStyle) |
| 896 #if !ENABLE(OILPAN) | 896 #if !ENABLE(OILPAN) |
| 897 , m_refCount(1) | 897 , m_refCount(1) |
| 898 #endif | 898 #endif |
| 899 { | 899 { |
| 900 unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoEleme
ntName[1] == ':' ? 2 : 1) : 0; | |
| 901 m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoTyp
e( | |
| 902 AtomicString(pseudoElementName.substring(nameWithoutColonsStart)))); | |
| 903 } | 900 } |
| 904 | 901 |
| 905 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration() | 902 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration() |
| 906 { | 903 { |
| 907 } | 904 } |
| 908 | 905 |
| 909 #if !ENABLE(OILPAN) | 906 #if !ENABLE(OILPAN) |
| 910 void CSSComputedStyleDeclaration::ref() | 907 void CSSComputedStyleDeclaration::ref() |
| 911 { | 908 { |
| 912 ++m_refCount; | 909 ++m_refCount; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1); | 946 return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1); |
| 950 } | 947 } |
| 951 | 948 |
| 952 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringK
eyword() const | 949 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringK
eyword() const |
| 953 { | 950 { |
| 954 if (!m_node) | 951 if (!m_node) |
| 955 return nullptr; | 952 return nullptr; |
| 956 | 953 |
| 957 m_node->document().updateLayout(); | 954 m_node->document().updateLayout(); |
| 958 | 955 |
| 959 RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier); | 956 RefPtr<RenderStyle> style = m_node->computedStyle(); |
| 960 if (!style) | 957 if (!style) |
| 961 return nullptr; | 958 return nullptr; |
| 962 | 959 |
| 963 if (int keywordSize = style->fontDescription().keywordSize()) | 960 if (int keywordSize = style->fontDescription().keywordSize()) |
| 964 return cssValuePool().createIdentifierValue(cssIdentifierForFontSizeKeyw
ord(keywordSize)); | 961 return cssValuePool().createIdentifierValue(cssIdentifierForFontSizeKeyw
ord(keywordSize)); |
| 965 | 962 |
| 966 | 963 |
| 967 return pixelValue(style->fontDescription().computedPixelSize(), *style); | 964 return pixelValue(style->fontDescription().computedPixelSize(), *style); |
| 968 } | 965 } |
| 969 | 966 |
| 970 FixedPitchFontType CSSComputedStyleDeclaration::fixedPitchFontType() const | 967 FixedPitchFontType CSSComputedStyleDeclaration::fixedPitchFontType() const |
| 971 { | 968 { |
| 972 if (!m_node) | 969 if (!m_node) |
| 973 return NonFixedPitchFont; | 970 return NonFixedPitchFont; |
| 974 | 971 |
| 975 RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier); | 972 RefPtr<RenderStyle> style = m_node->computedStyle(); |
| 976 if (!style) | 973 if (!style) |
| 977 return NonFixedPitchFont; | 974 return NonFixedPitchFont; |
| 978 | 975 |
| 979 return style->fontDescription().fixedPitchFontType(); | 976 return style->fontDescription().fixedPitchFontType(); |
| 980 } | 977 } |
| 981 | 978 |
| 982 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadowData(const Shado
wData& shadow, const RenderStyle& style, bool useSpread) const | 979 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadowData(const Shado
wData& shadow, const RenderStyle& style, bool useSpread) const |
| 983 { | 980 { |
| 984 RefPtr<CSSPrimitiveValue> x = pixelValue(shadow.x(), style); | 981 RefPtr<CSSPrimitiveValue> x = pixelValue(shadow.x(), style); |
| 985 RefPtr<CSSPrimitiveValue> y = pixelValue(shadow.y(), style); | 982 RefPtr<CSSPrimitiveValue> y = pixelValue(shadow.y(), style); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 return renderer && renderer->isBox() && (!style || !style->paddingRight(
).isFixed()); | 1221 return renderer && renderer->isBox() && (!style || !style->paddingRight(
).isFixed()); |
| 1225 case CSSPropertyPaddingTop: | 1222 case CSSPropertyPaddingTop: |
| 1226 return renderer && renderer->isBox() && (!style || !style->paddingTop().
isFixed()); | 1223 return renderer && renderer->isBox() && (!style || !style->paddingTop().
isFixed()); |
| 1227 default: | 1224 default: |
| 1228 return false; | 1225 return false; |
| 1229 } | 1226 } |
| 1230 } | 1227 } |
| 1231 | 1228 |
| 1232 PassRefPtr<RenderStyle> CSSComputedStyleDeclaration::computeRenderStyle(CSSPrope
rtyID propertyID) const | 1229 PassRefPtr<RenderStyle> CSSComputedStyleDeclaration::computeRenderStyle(CSSPrope
rtyID propertyID) const |
| 1233 { | 1230 { |
| 1234 return m_node->computedStyle(m_pseudoElementSpecifier); | 1231 return m_node->computedStyle(); |
| 1235 } | 1232 } |
| 1236 | 1233 |
| 1237 static ItemPosition resolveAlignmentAuto(ItemPosition position, Node* element) | 1234 static ItemPosition resolveAlignmentAuto(ItemPosition position, Node* element) |
| 1238 { | 1235 { |
| 1239 if (position != ItemPositionAuto) | 1236 if (position != ItemPositionAuto) |
| 1240 return position; | 1237 return position; |
| 1241 | 1238 |
| 1242 bool isFlex = element && element->computedStyle() | 1239 bool isFlex = element && element->computedStyle() |
| 1243 && element->computedStyle()->isDisplayFlexibleBox(); | 1240 && element->computedStyle()->isDisplayFlexibleBox(); |
| 1244 | 1241 |
| (...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2234 return ""; | 2231 return ""; |
| 2235 } | 2232 } |
| 2236 | 2233 |
| 2237 | 2234 |
| 2238 unsigned CSSComputedStyleDeclaration::length() const | 2235 unsigned CSSComputedStyleDeclaration::length() const |
| 2239 { | 2236 { |
| 2240 Node* node = m_node.get(); | 2237 Node* node = m_node.get(); |
| 2241 if (!node) | 2238 if (!node) |
| 2242 return 0; | 2239 return 0; |
| 2243 | 2240 |
| 2244 RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier); | 2241 RenderStyle* style = node->computedStyle(); |
| 2245 if (!style) | 2242 if (!style) |
| 2246 return 0; | 2243 return 0; |
| 2247 | 2244 |
| 2248 return computableProperties().size(); | 2245 return computableProperties().size(); |
| 2249 } | 2246 } |
| 2250 | 2247 |
| 2251 String CSSComputedStyleDeclaration::item(unsigned i) const | 2248 String CSSComputedStyleDeclaration::item(unsigned i) const |
| 2252 { | 2249 { |
| 2253 if (i >= length()) | 2250 if (i >= length()) |
| 2254 return ""; | 2251 return ""; |
| 2255 | 2252 |
| 2256 return getPropertyNameString(computableProperties()[i]); | 2253 return getPropertyNameString(computableProperties()[i]); |
| 2257 } | 2254 } |
| 2258 | 2255 |
| 2259 bool CSSComputedStyleDeclaration::cssPropertyMatches(CSSPropertyID propertyID, c
onst CSSValue* propertyValue) const | 2256 bool CSSComputedStyleDeclaration::cssPropertyMatches(CSSPropertyID propertyID, c
onst CSSValue* propertyValue) const |
| 2260 { | 2257 { |
| 2261 if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() &
& m_node) { | 2258 if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() &
& m_node) { |
| 2262 m_node->document().updateLayout(); | 2259 m_node->document().updateLayout(); |
| 2263 RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier); | 2260 RenderStyle* style = m_node->computedStyle(); |
| 2264 if (style && style->fontDescription().keywordSize()) { | 2261 if (style && style->fontDescription().keywordSize()) { |
| 2265 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->fontDe
scription().keywordSize()); | 2262 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->fontDe
scription().keywordSize()); |
| 2266 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(proper
tyValue); | 2263 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(proper
tyValue); |
| 2267 if (primitiveValue->isValueID() && primitiveValue->getValueID() == s
izeValue) | 2264 if (primitiveValue->isValueID() && primitiveValue->getValueID() == s
izeValue) |
| 2268 return true; | 2265 return true; |
| 2269 } | 2266 } |
| 2270 } | 2267 } |
| 2271 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID); | 2268 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID); |
| 2272 return value && propertyValue && value->equals(*propertyValue); | 2269 return value && propertyValue && value->equals(*propertyValue); |
| 2273 } | 2270 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2389 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB
ackgroundSize, CSSPropertyBackgroundOrigin, | 2386 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB
ackgroundSize, CSSPropertyBackgroundOrigin, |
| 2390 CSSPropertyB
ackgroundClip }; | 2387 CSSPropertyB
ackgroundClip }; |
| 2391 | 2388 |
| 2392 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated(); | 2389 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated(); |
| 2393 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa
ckground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlash
Seperator)))); | 2390 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa
ckground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlash
Seperator)))); |
| 2394 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa
ckground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSe
perator)))); | 2391 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa
ckground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSe
perator)))); |
| 2395 return list.release(); | 2392 return list.release(); |
| 2396 } | 2393 } |
| 2397 | 2394 |
| 2398 } // namespace blink | 2395 } // namespace blink |
| OLD | NEW |