| 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 |
| 11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
| 12 * | 12 * |
| 13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Lesser General Public License for more details. | 16 * Lesser General Public License for more details. |
| 17 * | 17 * |
| 18 * You should have received a copy of the GNU Lesser General Public | 18 * You should have received a copy of the GNU Lesser General Public |
| 19 * License along with this library; if not, write to the Free Software | 19 * License along with this library; if not, write to the Free Software |
| 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 21 * 02110-1301 USA | 21 * 02110-1301 USA |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #include "core/css/CSSComputedStyleDeclaration.h" | 24 #include "core/css/CSSComputedStyleDeclaration.h" |
| 25 | 25 |
| 26 #include "bindings/core/v8/ExceptionState.h" | 26 #include "bindings/core/v8/ExceptionState.h" |
| 27 #include "core/CSSPropertyNames.h" | 27 #include "core/CSSPropertyNames.h" |
| 28 #include "core/css/CSSIdentifierValue.h" |
| 28 #include "core/css/CSSPrimitiveValue.h" | 29 #include "core/css/CSSPrimitiveValue.h" |
| 29 #include "core/css/CSSPrimitiveValueMappings.h" | 30 #include "core/css/CSSPrimitiveValueMappings.h" |
| 30 #include "core/css/CSSPropertyIDTemplates.h" | 31 #include "core/css/CSSPropertyIDTemplates.h" |
| 31 #include "core/css/CSSPropertyMetadata.h" | 32 #include "core/css/CSSPropertyMetadata.h" |
| 32 #include "core/css/CSSSelector.h" | 33 #include "core/css/CSSSelector.h" |
| 33 #include "core/css/CSSVariableData.h" | 34 #include "core/css/CSSVariableData.h" |
| 34 #include "core/css/ComputedStyleCSSValueMapping.h" | 35 #include "core/css/ComputedStyleCSSValueMapping.h" |
| 35 #include "core/css/parser/CSSParser.h" | 36 #include "core/css/parser/CSSParser.h" |
| 36 #include "core/css/resolver/StyleResolver.h" | 37 #include "core/css/resolver/StyleResolver.h" |
| 37 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 return nullptr; | 234 return nullptr; |
| 234 | 235 |
| 235 m_node->document().updateStyleAndLayoutIgnorePendingStylesheets(); | 236 m_node->document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 236 | 237 |
| 237 const ComputedStyle* style = | 238 const ComputedStyle* style = |
| 238 m_node->ensureComputedStyle(m_pseudoElementSpecifier); | 239 m_node->ensureComputedStyle(m_pseudoElementSpecifier); |
| 239 if (!style) | 240 if (!style) |
| 240 return nullptr; | 241 return nullptr; |
| 241 | 242 |
| 242 if (int keywordSize = style->getFontDescription().keywordSize()) | 243 if (int keywordSize = style->getFontDescription().keywordSize()) |
| 243 return CSSPrimitiveValue::createIdentifier( | 244 return CSSIdentifierValue::create( |
| 244 cssIdentifierForFontSizeKeyword(keywordSize)); | 245 cssIdentifierForFontSizeKeyword(keywordSize)); |
| 245 | 246 |
| 246 return zoomAdjustedPixelValue(style->getFontDescription().computedPixelSize(), | 247 return zoomAdjustedPixelValue(style->getFontDescription().computedPixelSize(), |
| 247 *style); | 248 *style); |
| 248 } | 249 } |
| 249 | 250 |
| 250 bool CSSComputedStyleDeclaration::isMonospaceFont() const { | 251 bool CSSComputedStyleDeclaration::isMonospaceFont() const { |
| 251 if (!m_node) | 252 if (!m_node) |
| 252 return false; | 253 return false; |
| 253 | 254 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 String CSSComputedStyleDeclaration::item(unsigned i) const { | 435 String CSSComputedStyleDeclaration::item(unsigned i) const { |
| 435 if (i >= length()) | 436 if (i >= length()) |
| 436 return ""; | 437 return ""; |
| 437 | 438 |
| 438 return getPropertyNameString(computableProperties()[i]); | 439 return getPropertyNameString(computableProperties()[i]); |
| 439 } | 440 } |
| 440 | 441 |
| 441 bool CSSComputedStyleDeclaration::cssPropertyMatches( | 442 bool CSSComputedStyleDeclaration::cssPropertyMatches( |
| 442 CSSPropertyID propertyID, | 443 CSSPropertyID propertyID, |
| 443 const CSSValue* propertyValue) const { | 444 const CSSValue* propertyValue) const { |
| 444 if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() && | 445 if (propertyID == CSSPropertyFontSize && |
| 446 (propertyValue->isPrimitiveValue() || |
| 447 propertyValue->isIdentifierValue()) && |
| 445 m_node) { | 448 m_node) { |
| 446 m_node->document().updateStyleAndLayoutIgnorePendingStylesheets(); | 449 m_node->document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 447 const ComputedStyle* style = | 450 const ComputedStyle* style = |
| 448 m_node->ensureComputedStyle(m_pseudoElementSpecifier); | 451 m_node->ensureComputedStyle(m_pseudoElementSpecifier); |
| 449 if (style && style->getFontDescription().keywordSize()) { | 452 if (style && style->getFontDescription().keywordSize()) { |
| 450 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword( | 453 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword( |
| 451 style->getFontDescription().keywordSize()); | 454 style->getFontDescription().keywordSize()); |
| 452 const CSSPrimitiveValue* primitiveValue = | 455 if (propertyValue->isIdentifierValue() && |
| 453 toCSSPrimitiveValue(propertyValue); | 456 toCSSIdentifierValue(propertyValue)->getValueID() == sizeValue) |
| 454 if (primitiveValue->isValueID() && | |
| 455 primitiveValue->getValueID() == sizeValue) | |
| 456 return true; | 457 return true; |
| 457 } | 458 } |
| 458 } | 459 } |
| 459 const CSSValue* value = getPropertyCSSValue(propertyID); | 460 const CSSValue* value = getPropertyCSSValue(propertyID); |
| 460 return value && propertyValue && value->equals(*propertyValue); | 461 return value && propertyValue && value->equals(*propertyValue); |
| 461 } | 462 } |
| 462 | 463 |
| 463 MutableStylePropertySet* CSSComputedStyleDeclaration::copyProperties() const { | 464 MutableStylePropertySet* CSSComputedStyleDeclaration::copyProperties() const { |
| 464 return copyPropertiesInSet(computableProperties()); | 465 return copyPropertiesInSet(computableProperties()); |
| 465 } | 466 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 "These styles are computed, and therefore the '" + | 556 "These styles are computed, and therefore the '" + |
| 556 getPropertyNameString(id) + "' property is read-only."); | 557 getPropertyNameString(id) + "' property is read-only."); |
| 557 } | 558 } |
| 558 | 559 |
| 559 DEFINE_TRACE(CSSComputedStyleDeclaration) { | 560 DEFINE_TRACE(CSSComputedStyleDeclaration) { |
| 560 visitor->trace(m_node); | 561 visitor->trace(m_node); |
| 561 CSSStyleDeclaration::trace(visitor); | 562 CSSStyleDeclaration::trace(visitor); |
| 562 } | 563 } |
| 563 | 564 |
| 564 } // namespace blink | 565 } // namespace blink |
| OLD | NEW |