| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc. | 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc. |
| 3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "core/dom/NodeTraversal.h" | 46 #include "core/dom/NodeTraversal.h" |
| 47 #include "core/dom/Position.h" | 47 #include "core/dom/Position.h" |
| 48 #include "core/dom/QualifiedName.h" | 48 #include "core/dom/QualifiedName.h" |
| 49 #include "core/editing/ApplyStyleCommand.h" | 49 #include "core/editing/ApplyStyleCommand.h" |
| 50 #include "core/editing/Editor.h" | 50 #include "core/editing/Editor.h" |
| 51 #include "core/editing/FrameSelection.h" | 51 #include "core/editing/FrameSelection.h" |
| 52 #include "core/editing/HTMLInterchange.h" | 52 #include "core/editing/HTMLInterchange.h" |
| 53 #include "core/editing/htmlediting.h" | 53 #include "core/editing/htmlediting.h" |
| 54 #include "core/frame/LocalFrame.h" | 54 #include "core/frame/LocalFrame.h" |
| 55 #include "core/html/HTMLFontElement.h" | 55 #include "core/html/HTMLFontElement.h" |
| 56 #include "core/html/HTMLSpanElement.h" |
| 56 #include "core/rendering/RenderBox.h" | 57 #include "core/rendering/RenderBox.h" |
| 57 #include "core/rendering/RenderObject.h" | 58 #include "core/rendering/RenderObject.h" |
| 58 #include "core/rendering/style/RenderStyle.h" | 59 #include "core/rendering/style/RenderStyle.h" |
| 59 | 60 |
| 60 namespace blink { | 61 namespace blink { |
| 61 | 62 |
| 62 static const CSSPropertyID& textDecorationPropertyForEditing() | 63 static const CSSPropertyID& textDecorationPropertyForEditing() |
| 63 { | 64 { |
| 64 static const CSSPropertyID property = RuntimeEnabledFeatures::css3TextDecora
tionsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration; | 65 static const CSSPropertyID property = RuntimeEnabledFeatures::css3TextDecora
tionsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration; |
| 65 return property; | 66 return property; |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 449 |
| 449 template<typename T> | 450 template<typename T> |
| 450 static int textAlignResolvingStartAndEnd(T* style) | 451 static int textAlignResolvingStartAndEnd(T* style) |
| 451 { | 452 { |
| 452 return textAlignResolvingStartAndEnd(getIdentifierValue(style, CSSPropertyTe
xtAlign), getIdentifierValue(style, CSSPropertyDirection)); | 453 return textAlignResolvingStartAndEnd(getIdentifierValue(style, CSSPropertyTe
xtAlign), getIdentifierValue(style, CSSPropertyDirection)); |
| 453 } | 454 } |
| 454 | 455 |
| 455 void EditingStyle::init(Node* node, PropertiesToInclude propertiesToInclude) | 456 void EditingStyle::init(Node* node, PropertiesToInclude propertiesToInclude) |
| 456 { | 457 { |
| 457 if (isTabSpanTextNode(node)) | 458 if (isTabSpanTextNode(node)) |
| 458 node = tabSpanNode(node)->parentNode(); | 459 node = tabSpanElement(node)->parentNode(); |
| 459 else if (isTabSpanNode(node)) | 460 else if (isTabSpanElement(node)) |
| 460 node = node->parentNode(); | 461 node = node->parentNode(); |
| 461 | 462 |
| 462 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CS
SComputedStyleDeclaration::create(node); | 463 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CS
SComputedStyleDeclaration::create(node); |
| 463 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi
tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle
(computedStyleAtPosition); | 464 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi
tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle
(computedStyleAtPosition); |
| 464 | 465 |
| 465 if (propertiesToInclude == EditingPropertiesInEffect) { | 466 if (propertiesToInclude == EditingPropertiesInEffect) { |
| 466 if (RefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(node)) | 467 if (RefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(node)) |
| 467 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe
xt()); | 468 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe
xt()); |
| 468 if (RefPtrWillBeRawPtr<CSSValue> value = computedStyleAtPosition->getPro
pertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)) | 469 if (RefPtrWillBeRawPtr<CSSValue> value = computedStyleAtPosition->getPro
pertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)) |
| 469 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex
t()); | 470 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex
t()); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 | 739 |
| 739 const StylePropertySet* inlineStyle = element->inlineStyle(); | 740 const StylePropertySet* inlineStyle = element->inlineStyle(); |
| 740 if (!m_mutableStyle || !inlineStyle) | 741 if (!m_mutableStyle || !inlineStyle) |
| 741 return false; | 742 return false; |
| 742 | 743 |
| 743 unsigned propertyCount = m_mutableStyle->propertyCount(); | 744 unsigned propertyCount = m_mutableStyle->propertyCount(); |
| 744 for (unsigned i = 0; i < propertyCount; ++i) { | 745 for (unsigned i = 0; i < propertyCount; ++i) { |
| 745 CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id(); | 746 CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id(); |
| 746 | 747 |
| 747 // We don't override whitespace property of a tab span because that woul
d collapse the tab into a space. | 748 // We don't override whitespace property of a tab span because that woul
d collapse the tab into a space. |
| 748 if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element)) | 749 if (propertyID == CSSPropertyWhiteSpace && isTabSpanElement(element)) |
| 749 continue; | 750 continue; |
| 750 | 751 |
| 751 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyl
e->getPropertyCSSValue(textDecorationPropertyForEditing())) { | 752 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyl
e->getPropertyCSSValue(textDecorationPropertyForEditing())) { |
| 752 if (!conflictingProperties) | 753 if (!conflictingProperties) |
| 753 return true; | 754 return true; |
| 754 conflictingProperties->append(CSSPropertyTextDecoration); | 755 conflictingProperties->append(CSSPropertyTextDecoration); |
| 755 // Because text-decoration expands to text-decoration-line when CSS3 | 756 // Because text-decoration expands to text-decoration-line when CSS3 |
| 756 // Text Decoration is enabled, we also state it as conflicting. | 757 // Text Decoration is enabled, we also state it as conflicting. |
| 757 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) | 758 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) |
| 758 conflictingProperties->append(CSSPropertyTextDecorationLine); | 759 conflictingProperties->append(CSSPropertyTextDecorationLine); |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 | 1427 |
| 1427 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyle = position.com
putedStyle(); | 1428 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyle = position.com
putedStyle(); |
| 1428 // FIXME: take care of background-color in effect | 1429 // FIXME: take care of background-color in effect |
| 1429 RefPtrWillBeRawPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotI
n(style->style(), computedStyle.get()); | 1430 RefPtrWillBeRawPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotI
n(style->style(), computedStyle.get()); |
| 1430 | 1431 |
| 1431 reconcileTextDecorationProperties(mutableStyle.get()); | 1432 reconcileTextDecorationProperties(mutableStyle.get()); |
| 1432 if (!document->frame()->editor().shouldStyleWithCSS()) | 1433 if (!document->frame()->editor().shouldStyleWithCSS()) |
| 1433 extractTextStyles(document, mutableStyle.get(), computedStyle->fixedPitc
hFontType()); | 1434 extractTextStyles(document, mutableStyle.get(), computedStyle->fixedPitc
hFontType()); |
| 1434 | 1435 |
| 1435 // Changing the whitespace style in a tab span would collapse the tab into a
space. | 1436 // Changing the whitespace style in a tab span would collapse the tab into a
space. |
| 1436 if (isTabSpanTextNode(position.deprecatedNode()) || isTabSpanNode((position.
deprecatedNode()))) | 1437 if (isTabSpanTextNode(position.deprecatedNode()) || isTabSpanElement((positi
on.deprecatedNode()))) |
| 1437 mutableStyle->removeProperty(CSSPropertyWhiteSpace); | 1438 mutableStyle->removeProperty(CSSPropertyWhiteSpace); |
| 1438 | 1439 |
| 1439 // If unicode-bidi is present in mutableStyle and direction is not, then add
direction to mutableStyle. | 1440 // If unicode-bidi is present in mutableStyle and direction is not, then add
direction to mutableStyle. |
| 1440 // FIXME: Shouldn't this be done in getPropertiesNotIn? | 1441 // FIXME: Shouldn't this be done in getPropertiesNotIn? |
| 1441 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->sty
le()->getPropertyCSSValue(CSSPropertyDirection)) | 1442 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->sty
le()->getPropertyCSSValue(CSSPropertyDirection)) |
| 1442 mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPrope
rtyValue(CSSPropertyDirection)); | 1443 mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPrope
rtyValue(CSSPropertyDirection)); |
| 1443 | 1444 |
| 1444 // Save the result for later | 1445 // Save the result for later |
| 1445 m_cssStyle = mutableStyle->asText().stripWhiteSpace(); | 1446 m_cssStyle = mutableStyle->asText().stripWhiteSpace(); |
| 1446 } | 1447 } |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 { | 1676 { |
| 1676 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1677 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
| 1677 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); | 1678 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); |
| 1678 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1679 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
| 1679 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1680 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
| 1680 } | 1681 } |
| 1681 return nullptr; | 1682 return nullptr; |
| 1682 } | 1683 } |
| 1683 | 1684 |
| 1684 } | 1685 } |
| OLD | NEW |