OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 element = span.release(); | 407 element = span.release(); |
408 } else { | 408 } else { |
409 // Only handle HTML elements and text nodes. | 409 // Only handle HTML elements and text nodes. |
410 continue; | 410 continue; |
411 } | 411 } |
412 lastStyledNode = node; | 412 lastStyledNode = node; |
413 | 413 |
414 RefPtrWillBeRawPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCre
ateEmpty(element->inlineStyle()); | 414 RefPtrWillBeRawPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCre
ateEmpty(element->inlineStyle()); |
415 float currentFontSize = computedFontSize(node); | 415 float currentFontSize = computedFontSize(node); |
416 float desiredFontSize = max(MinimumFontSize, startingFontSizes.get(node)
+ style->fontSizeDelta()); | 416 float desiredFontSize = max(MinimumFontSize, startingFontSizes.get(node)
+ style->fontSizeDelta()); |
417 RefPtrWillBeRawPtr<CSSValue> value = inlineStyle->getPropertyCSSValue(CS
SPropertyFontSize); | 417 NullableCSSValue value = inlineStyle->getPropertyCSSValue(CSSPropertyFon
tSize); |
418 if (value) { | 418 if (value) { |
419 element->removeInlineStyleProperty(CSSPropertyFontSize); | 419 element->removeInlineStyleProperty(CSSPropertyFontSize); |
420 currentFontSize = computedFontSize(node); | 420 currentFontSize = computedFontSize(node); |
421 } | 421 } |
422 if (currentFontSize != desiredFontSize) { | 422 if (currentFontSize != desiredFontSize) { |
423 inlineStyle->setProperty(CSSPropertyFontSize, cssValuePool().createV
alue(desiredFontSize, CSSPrimitiveValue::CSS_PX), false); | 423 inlineStyle->setProperty(CSSPropertyFontSize, cssValuePool().createV
alue(desiredFontSize, CSSPrimitiveValue::CSS_PX), false); |
424 setNodeAttribute(element.get(), styleAttr, AtomicString(inlineStyle-
>asText())); | 424 setNodeAttribute(element.get(), styleAttr, AtomicString(inlineStyle-
>asText())); |
425 } | 425 } |
426 if (inlineStyle->isEmpty()) { | 426 if (inlineStyle->isEmpty()) { |
427 removeElementAttribute(element.get(), styleAttr); | 427 removeElementAttribute(element.get(), styleAttr); |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 | 1537 |
1538 float ApplyStyleCommand::computedFontSize(Node* node) | 1538 float ApplyStyleCommand::computedFontSize(Node* node) |
1539 { | 1539 { |
1540 if (!node) | 1540 if (!node) |
1541 return 0; | 1541 return 0; |
1542 | 1542 |
1543 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDecl
aration::create(node); | 1543 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDecl
aration::create(node); |
1544 if (!style) | 1544 if (!style) |
1545 return 0; | 1545 return 0; |
1546 | 1546 |
1547 RefPtrWillBeRawPtr<CSSPrimitiveValue> value = static_pointer_cast<CSSPrimiti
veValue>(style->getPropertyCSSValue(CSSPropertyFontSize)); | 1547 NullableCSSValue value = style->getPropertyCSSValue(CSSPropertyFontSize); |
1548 if (!value) | 1548 if (!value) |
1549 return 0; | 1549 return 0; |
1550 | 1550 |
1551 ASSERT(value->primitiveType() == CSSPrimitiveValue::CSS_PX); | 1551 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(*value); |
1552 return value->getFloatValue(); | 1552 ASSERT(primitiveValue.primitiveType() == CSSPrimitiveValue::CSS_PX); |
| 1553 return primitiveValue.getFloatValue(); |
1553 } | 1554 } |
1554 | 1555 |
1555 void ApplyStyleCommand::joinChildTextNodes(ContainerNode* node, const Position&
start, const Position& end) | 1556 void ApplyStyleCommand::joinChildTextNodes(ContainerNode* node, const Position&
start, const Position& end) |
1556 { | 1557 { |
1557 if (!node) | 1558 if (!node) |
1558 return; | 1559 return; |
1559 | 1560 |
1560 Position newStart = start; | 1561 Position newStart = start; |
1561 Position newEnd = end; | 1562 Position newEnd = end; |
1562 | 1563 |
(...skipping 28 matching lines...) Expand all Loading... |
1591 DEFINE_TRACE(ApplyStyleCommand) | 1592 DEFINE_TRACE(ApplyStyleCommand) |
1592 { | 1593 { |
1593 visitor->trace(m_style); | 1594 visitor->trace(m_style); |
1594 visitor->trace(m_start); | 1595 visitor->trace(m_start); |
1595 visitor->trace(m_end); | 1596 visitor->trace(m_end); |
1596 visitor->trace(m_styledInlineElement); | 1597 visitor->trace(m_styledInlineElement); |
1597 CompositeEditCommand::trace(visitor); | 1598 CompositeEditCommand::trace(visitor); |
1598 } | 1599 } |
1599 | 1600 |
1600 } | 1601 } |
OLD | NEW |