#include "config.h"
#include "core/editing/EditingStyle.h"
-#include "bindings/v8/ExceptionStatePlaceholder.h"
+#include "bindings/core/v8/ExceptionStatePlaceholder.h"
#include "core/HTMLNames.h"
#include "core/css/CSSComputedStyleDeclaration.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/CSSRuleList.h"
#include "core/css/CSSStyleRule.h"
#include "core/css/CSSValueList.h"
+#include "core/css/CSSValuePool.h"
#include "core/css/FontSize.h"
#include "core/css/RuntimeCSSEnabled.h"
#include "core/css/StylePropertySet.h"
#include "core/css/StyleRule.h"
#include "core/css/resolver/StyleResolver.h"
+#include "core/dom/Document.h"
#include "core/dom/Element.h"
#include "core/dom/Node.h"
#include "core/dom/NodeTraversal.h"
#include "core/editing/htmlediting.h"
#include "core/frame/LocalFrame.h"
#include "core/html/HTMLFontElement.h"
+#include "core/html/HTMLSpanElement.h"
+#include "core/rendering/RenderBox.h"
+#include "core/rendering/RenderObject.h"
#include "core/rendering/style/RenderStyle.h"
-namespace WebCore {
+namespace blink {
static const CSSPropertyID& textDecorationPropertyForEditing()
{
if (properties.isEmpty()) {
RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingProperties, WTF_ARRAY_LENGTH(staticEditingProperties), properties);
for (size_t index = 0; index < properties.size();) {
- if (!CSSProperty::isInheritedProperty(properties[index])) {
+ if (!CSSPropertyMetadata::isInheritedProperty(properties[index])) {
properties.remove(index);
continue;
}
static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle);
enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelValuesMatch };
-static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool shouldUseFixedFontDefaultSize, LegacyFontSizeMode);
+static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, FixedPitchFontType, LegacyFontSizeMode);
static bool isTransparentColorValue(CSSValue*);
static bool hasTransparentBackgroundColor(CSSStyleDeclaration*);
static bool hasTransparentBackgroundColor(StylePropertySet*);
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent);
public:
- static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSPropertyID propertyID, CSSValueID primitiveValue, const QualifiedName& tagName)
+ static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSPropertyID propertyID, CSSValueID primitiveValue, const HTMLQualifiedName& tagName)
{
return adoptPtrWillBeNoop(new HTMLElementEquivalent(propertyID, primitiveValue, tagName));
}
virtual bool matches(const Element* element) const { return !m_tagName || element->hasTagName(*m_tagName); }
virtual bool hasAttribute() const { return false; }
virtual bool propertyExistsInStyle(const StylePropertySet* style) const { return style->getPropertyCSSValue(m_propertyID); }
- virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const;
+ virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const;
virtual void addToStyle(Element*, EditingStyle*) const;
virtual void trace(Visitor* visitor) { visitor->trace(m_primitiveValue); }
protected:
HTMLElementEquivalent(CSSPropertyID);
- HTMLElementEquivalent(CSSPropertyID, const QualifiedName& tagName);
- HTMLElementEquivalent(CSSPropertyID, CSSValueID primitiveValue, const QualifiedName& tagName);
+ HTMLElementEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName);
+ HTMLElementEquivalent(CSSPropertyID, CSSValueID primitiveValue, const HTMLQualifiedName& tagName);
const CSSPropertyID m_propertyID;
const RefPtrWillBeMember<CSSPrimitiveValue> m_primitiveValue;
- const QualifiedName* m_tagName; // We can store a pointer because HTML tag names are const global.
+ const HTMLQualifiedName* m_tagName; // We can store a pointer because HTML tag names are const global.
};
DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent);
{
}
-HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, const QualifiedName& tagName)
+HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, const HTMLQualifiedName& tagName)
: m_propertyID(id)
, m_tagName(&tagName)
{
}
-HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primitiveValue, const QualifiedName& tagName)
+HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primitiveValue, const HTMLQualifiedName& tagName)
: m_propertyID(id)
, m_primitiveValue(CSSPrimitiveValue::createIdentifier(primitiveValue))
, m_tagName(&tagName)
ASSERT(primitiveValue != CSSValueInvalid);
}
-bool HTMLElementEquivalent::valueIsPresentInStyle(Element* element, StylePropertySet* style) const
+bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const
{
RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValue(m_propertyID);
return matches(element) && value && value->isPrimitiveValue() && toCSSPrimitiveValue(value.get())->getValueID() == m_primitiveValue->getValueID();
class HTMLTextDecorationEquivalent FINAL : public HTMLElementEquivalent {
public:
- static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSValueID primitiveValue, const QualifiedName& tagName)
+ static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSValueID primitiveValue, const HTMLQualifiedName& tagName)
{
return adoptPtrWillBeNoop(new HTMLTextDecorationEquivalent(primitiveValue, tagName));
}
virtual bool propertyExistsInStyle(const StylePropertySet*) const OVERRIDE;
- virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const OVERRIDE;
+ virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const OVERRIDE;
virtual void trace(Visitor* visitor) OVERRIDE { HTMLElementEquivalent::trace(visitor); }
private:
- HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName& tagName);
+ HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const HTMLQualifiedName& tagName);
};
-HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName& tagName)
+HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const HTMLQualifiedName& tagName)
: HTMLElementEquivalent(textDecorationPropertyForEditing(), primitiveValue, tagName)
// m_propertyID is used in HTMLElementEquivalent::addToStyle
{
|| style->getPropertyCSSValue(textDecorationPropertyForEditing());
}
-bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(Element* element, StylePropertySet* style) const
+bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const
{
RefPtrWillBeRawPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
if (!styleValue)
class HTMLAttributeEquivalent : public HTMLElementEquivalent {
public:
- static PassOwnPtrWillBeRawPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& tagName, const QualifiedName& attrName)
+ static PassOwnPtrWillBeRawPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const HTMLQualifiedName& tagName, const QualifiedName& attrName)
{
return adoptPtrWillBeNoop(new HTMLAttributeEquivalent(propertyID, tagName, attrName));
}
return adoptPtrWillBeNoop(new HTMLAttributeEquivalent(propertyID, attrName));
}
- virtual bool matches(const Element* elem) const OVERRIDE { return HTMLElementEquivalent::matches(elem) && elem->hasAttribute(m_attrName); }
+ virtual bool matches(const Element* element) const OVERRIDE { return HTMLElementEquivalent::matches(element) && element->hasAttribute(m_attrName); }
virtual bool hasAttribute() const OVERRIDE { return true; }
- virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const OVERRIDE;
+ virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const OVERRIDE;
virtual void addToStyle(Element*, EditingStyle*) const OVERRIDE;
virtual PassRefPtrWillBeRawPtr<CSSValue> attributeValueAsCSSValue(Element*) const;
inline const QualifiedName& attributeName() const { return m_attrName; }
virtual void trace(Visitor* visitor) OVERRIDE { HTMLElementEquivalent::trace(visitor); }
protected:
- HTMLAttributeEquivalent(CSSPropertyID, const QualifiedName& tagName, const QualifiedName& attrName);
+ HTMLAttributeEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName, const QualifiedName& attrName);
HTMLAttributeEquivalent(CSSPropertyID, const QualifiedName& attrName);
const QualifiedName& m_attrName; // We can store a reference because HTML attribute names are const global.
};
-HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const QualifiedName& tagName, const QualifiedName& attrName)
+HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const HTMLQualifiedName& tagName, const QualifiedName& attrName)
: HTMLElementEquivalent(id, tagName)
, m_attrName(attrName)
{
{
}
-bool HTMLAttributeEquivalent::valueIsPresentInStyle(Element* element, StylePropertySet* style) const
+bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePropertySet* style) const
{
RefPtrWillBeRawPtr<CSSValue> value = attributeValueAsCSSValue(element);
RefPtrWillBeRawPtr<CSSValue> styleValue = style->getPropertyCSSValue(m_propertyID);
float EditingStyle::NoFontDelta = 0.0f;
EditingStyle::EditingStyle()
- : m_shouldUseFixedDefaultFontSize(false)
+ : m_fixedPitchFontType(NonFixedPitchFont)
, m_fontSizeDelta(NoFontDelta)
{
}
-EditingStyle::EditingStyle(Node* node, PropertiesToInclude propertiesToInclude)
- : m_shouldUseFixedDefaultFontSize(false)
+EditingStyle::EditingStyle(ContainerNode* node, PropertiesToInclude propertiesToInclude)
+ : m_fixedPitchFontType(NonFixedPitchFont)
, m_fontSizeDelta(NoFontDelta)
{
init(node, propertiesToInclude);
}
EditingStyle::EditingStyle(const Position& position, PropertiesToInclude propertiesToInclude)
- : m_shouldUseFixedDefaultFontSize(false)
+ : m_fixedPitchFontType(NonFixedPitchFont)
, m_fontSizeDelta(NoFontDelta)
{
init(position.deprecatedNode(), propertiesToInclude);
EditingStyle::EditingStyle(const StylePropertySet* style)
: m_mutableStyle(style ? style->mutableCopy() : nullptr)
- , m_shouldUseFixedDefaultFontSize(false)
+ , m_fixedPitchFontType(NonFixedPitchFont)
, m_fontSizeDelta(NoFontDelta)
{
extractFontSizeDelta();
EditingStyle::EditingStyle(CSSPropertyID propertyID, const String& value)
: m_mutableStyle(nullptr)
- , m_shouldUseFixedDefaultFontSize(false)
+ , m_fixedPitchFontType(NonFixedPitchFont)
, m_fontSizeDelta(NoFontDelta)
{
setProperty(propertyID, value);
void EditingStyle::init(Node* node, PropertiesToInclude propertiesToInclude)
{
- if (isTabSpanTextNode(node))
- node = tabSpanNode(node)->parentNode();
- else if (isTabSpanNode(node))
+ if (isTabHTMLSpanElementTextNode(node))
+ node = tabSpanElement(node)->parentNode();
+ else if (isTabHTMLSpanElement(node))
node = node->parentNode();
RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CSSComputedStyleDeclaration::create(node);
replaceFontSizeByKeywordIfPossible(renderStyle, computedStyleAtPosition.get());
}
- m_shouldUseFixedDefaultFontSize = computedStyleAtPosition->useFixedFontDefaultSize();
+ m_fixedPitchFontType = computedStyleAtPosition->fixedPitchFontType();
extractFontSizeDelta();
}
void EditingStyle::clear()
{
m_mutableStyle.clear();
- m_shouldUseFixedDefaultFontSize = false;
+ m_fixedPitchFontType = NonFixedPitchFont;
m_fontSizeDelta = NoFontDelta;
}
RefPtrWillBeRawPtr<EditingStyle> copy = EditingStyle::create();
if (m_mutableStyle)
copy->m_mutableStyle = m_mutableStyle->mutableCopy();
- copy->m_shouldUseFixedDefaultFontSize = m_shouldUseFixedDefaultFontSize;
+ copy->m_fixedPitchFontType = m_fixedPitchFontType;
copy->m_fontSizeDelta = m_fontSizeDelta;
return copy;
}
m_mutableStyle->removeBlockProperties();
}
-void EditingStyle::removeStyleAddedByNode(Node* node)
+void EditingStyle::removeStyleAddedByElement(Element* element)
{
- if (!node || !node->parentNode())
+ if (!element || !element->parentNode())
return;
- RefPtrWillBeRawPtr<MutableStylePropertySet> parentStyle = editingStyleFromComputedStyle(CSSComputedStyleDeclaration::create(node->parentNode()), AllEditingProperties);
- RefPtrWillBeRawPtr<MutableStylePropertySet> nodeStyle = editingStyleFromComputedStyle(CSSComputedStyleDeclaration::create(node), AllEditingProperties);
+ RefPtrWillBeRawPtr<MutableStylePropertySet> parentStyle = editingStyleFromComputedStyle(CSSComputedStyleDeclaration::create(element->parentNode()), AllEditingProperties);
+ RefPtrWillBeRawPtr<MutableStylePropertySet> nodeStyle = editingStyleFromComputedStyle(CSSComputedStyleDeclaration::create(element), AllEditingProperties);
nodeStyle->removeEquivalentProperties(parentStyle.get());
m_mutableStyle->removeEquivalentProperties(nodeStyle.get());
}
-void EditingStyle::removeStyleConflictingWithStyleOfNode(Node* node)
+void EditingStyle::removeStyleConflictingWithStyleOfElement(Element* element)
{
- if (!node || !node->parentNode() || !m_mutableStyle)
+ if (!element || !element->parentNode() || !m_mutableStyle)
return;
- RefPtrWillBeRawPtr<MutableStylePropertySet> parentStyle = editingStyleFromComputedStyle(CSSComputedStyleDeclaration::create(node->parentNode()), AllEditingProperties);
- RefPtrWillBeRawPtr<MutableStylePropertySet> nodeStyle = editingStyleFromComputedStyle(CSSComputedStyleDeclaration::create(node), AllEditingProperties);
+ RefPtrWillBeRawPtr<MutableStylePropertySet> parentStyle = editingStyleFromComputedStyle(CSSComputedStyleDeclaration::create(element->parentNode()), AllEditingProperties);
+ RefPtrWillBeRawPtr<MutableStylePropertySet> nodeStyle = editingStyleFromComputedStyle(CSSComputedStyleDeclaration::create(element), AllEditingProperties);
nodeStyle->removeEquivalentProperties(parentStyle.get());
unsigned propertyCount = nodeStyle->propertyCount();
TriState state = FalseTriState;
bool nodeIsStart = true;
for (Node* node = selection.start().deprecatedNode(); node; node = NodeTraversal::next(*node)) {
- if (node->renderer() && node->rendererIsEditable()) {
+ if (node->renderer() && node->hasEditableStyle()) {
RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> nodeStyle = CSSComputedStyleDeclaration::create(node);
if (nodeStyle) {
TriState nodeState = triStateOfStyle(nodeStyle.get(), node->isTextNode() ? EditingStyle::DoNotIgnoreTextOnlyProperties : EditingStyle::IgnoreTextOnlyProperties);
return state;
}
-bool EditingStyle::conflictsWithInlineStyleOfElement(Element* element, EditingStyle* extractedStyle, Vector<CSSPropertyID>* conflictingProperties) const
+bool EditingStyle::conflictsWithInlineStyleOfElement(HTMLElement* element, EditingStyle* extractedStyle, Vector<CSSPropertyID>* conflictingProperties) const
{
ASSERT(element);
ASSERT(!conflictingProperties || conflictingProperties->isEmpty());
CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id();
// We don't override whitespace property of a tab span because that would collapse the tab into a space.
- if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element))
+ if (propertyID == CSSPropertyWhiteSpace && isTabHTMLSpanElement(element))
continue;
if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyle->getPropertyCSSValue(textDecorationPropertyForEditing())) {
}
}
- if (!element->hasAttributes())
+ AttributeCollection attributes = element->attributes();
+ if (attributes.isEmpty())
return elementIsSpanOrElementEquivalent; // span, b, etc... without any attributes
unsigned matchedAttributes = 0;
}
// font with color attribute, span with style attribute, etc...
- ASSERT(matchedAttributes <= element->attributeCount());
- return matchedAttributes >= element->attributeCount();
+ ASSERT(matchedAttributes <= attributes.size());
+ return matchedAttributes >= attributes.size();
}
void EditingStyle::prepareToApplyAt(const Position& position, ShouldPreserveWritingDirection shouldPreserveWritingDirection)
mergeStyle(typingStyle->style(), OverrideValues);
}
-void EditingStyle::mergeInlineStyleOfElement(Element* element, CSSPropertyOverrideMode mode, PropertiesToInclude propertiesToInclude)
+void EditingStyle::mergeInlineStyleOfElement(HTMLElement* element, CSSPropertyOverrideMode mode, PropertiesToInclude propertiesToInclude)
{
ASSERT(element);
if (!element->inlineStyle())
{
RefPtrWillBeRawPtr<EditingStyle> styleFromRules = EditingStyle::create();
styleFromRules->mergeStyleFromRulesForSerialization(element);
+
+ if (element->inlineStyle())
+ styleFromRules->m_mutableStyle->mergeAndOverrideOnConflict(element->inlineStyle());
+
styleFromRules->m_mutableStyle = extractEditingProperties(styleFromRules->m_mutableStyle.get(), propertiesToInclude);
mergeStyle(styleFromRules->m_mutableStyle.get(), mode);
- mergeInlineStyleOfElement(element, mode, propertiesToInclude);
-
const WillBeHeapVector<OwnPtrWillBeMember<HTMLElementEquivalent> >& elementEquivalents = htmlElementEquivalents();
for (size_t i = 0; i < elementEquivalents.size(); ++i) {
if (elementMatchesAndPropertyIsNotInInlineStyleDecl(elementEquivalents[i].get(), element, mode, m_mutableStyle.get()))
}
}
-PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::wrappingStyleForSerialization(Node* context, bool shouldAnnotate)
+PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::wrappingStyleForSerialization(ContainerNode* context, bool shouldAnnotate)
{
RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = nullptr;
if (shouldAnnotate) {
// Styles that Mail blockquotes contribute should only be placed on the Mail blockquote,
// to help us differentiate those styles from ones that the user has applied.
// This helps us get the color of content pasted into blockquotes right.
- wrappingStyle->removeStyleAddedByNode(enclosingNodeOfType(firstPositionInOrBeforeNode(context), isMailBlockquote, CanCrossEditingBoundary));
+ wrappingStyle->removeStyleAddedByElement(toHTMLElement(enclosingNodeOfType(firstPositionInOrBeforeNode(context), isMailHTMLBlockquoteElement, CanCrossEditingBoundary)));
// Call collapseTextDecorationProperties first or otherwise it'll copy the value over from in-effect to text-decorations.
wrappingStyle->collapseTextDecorationProperties();
wrappingStyle = EditingStyle::create();
// When not annotating for interchange, we only preserve inline style declarations.
- for (Node* node = context; node && !node->isDocumentNode(); node = node->parentNode()) {
- if (node->isStyledElement() && !isMailBlockquote(node)) {
+ for (ContainerNode* node = context; node && !node->isDocumentNode(); node = node->parentNode()) {
+ if (node->isStyledElement() && !isMailHTMLBlockquoteElement(node)) {
wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node), EditingStyle::DoNotOverrideValues,
EditingStyle::EditingPropertiesInEffect);
}
static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueList* valueToMerge)
{
-#if ENABLE_OILPAN
- DEFINE_STATIC_LOCAL(Persistent<CSSPrimitiveValue>, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
- DEFINE_STATIC_LOCAL(Persistent<CSSPrimitiveValue>, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
- if (valueToMerge->hasValue(underline) && !mergedValue->hasValue(underline))
- mergedValue->append(underline.get());
-
- if (valueToMerge->hasValue(lineThrough) && !mergedValue->hasValue(lineThrough))
- mergedValue->append(lineThrough.get());
-#else
- DEFINE_STATIC_REF(CSSPrimitiveValue, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
- DEFINE_STATIC_REF(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
+ DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
+ DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
if (valueToMerge->hasValue(underline) && !mergedValue->hasValue(underline))
mergedValue->append(underline);
if (valueToMerge->hasValue(lineThrough) && !mergedValue->hasValue(lineThrough))
mergedValue->append(lineThrough);
-#endif
}
void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverrideMode mode)
styleToRemovePropertiesFrom->removePropertiesInSet(propertiesToRemove.data(), propertiesToRemove.size());
}
-void EditingStyle::removeStyleFromRulesAndContext(Element* element, Node* context)
+void EditingStyle::removeStyleFromRulesAndContext(Element* element, ContainerNode* context)
{
ASSERT(element);
if (!m_mutableStyle)
if (!m_mutableStyle || m_mutableStyle->isEmpty())
return;
- RefPtr<StylePropertySet> defaultStyle = styleFromMatchedRulesForElement(element, StyleResolver::UAAndUserCSSRules);
+ RefPtrWillBeRawPtr<StylePropertySet> defaultStyle = styleFromMatchedRulesForElement(element, StyleResolver::UAAndUserCSSRules);
removePropertiesInStyle(m_mutableStyle.get(), defaultStyle.get());
}
+void EditingStyle::addAbsolutePositioningFromElement(const Element& element)
+{
+ LayoutRect rect = element.boundingBox();
+ RenderObject* renderer = element.renderer();
+
+ LayoutUnit x = rect.x();
+ LayoutUnit y = rect.y();
+ LayoutUnit width = rect.width();
+ LayoutUnit height = rect.height();
+ if (renderer && renderer->isBox()) {
+ RenderBox* renderBox = toRenderBox(renderer);
+
+ x -= renderBox->marginLeft();
+ y -= renderBox->marginTop();
+
+ m_mutableStyle->setProperty(CSSPropertyBoxSizing, CSSValueBorderBox);
+ }
+
+ m_mutableStyle->setProperty(CSSPropertyPosition, CSSValueAbsolute);
+ m_mutableStyle->setProperty(CSSPropertyLeft, cssValuePool().createValue(x, CSSPrimitiveValue::CSS_PX));
+ m_mutableStyle->setProperty(CSSPropertyTop, cssValuePool().createValue(y, CSSPrimitiveValue::CSS_PX));
+ m_mutableStyle->setProperty(CSSPropertyWidth, cssValuePool().createValue(width, CSSPrimitiveValue::CSS_PX));
+ m_mutableStyle->setProperty(CSSPropertyHeight, cssValuePool().createValue(height, CSSPrimitiveValue::CSS_PX));
+}
+
void EditingStyle::forceInline()
{
if (!m_mutableStyle)
if (!cssValue || !cssValue->isPrimitiveValue())
return 0;
return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue.get()),
- m_shouldUseFixedDefaultFontSize, AlwaysUseLegacyFontSize);
+ m_fixedPitchFontType, AlwaysUseLegacyFontSize);
}
PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const VisibleSelection& selection, bool shouldUseBackgroundColorInEffect)
if (!node->isStyledElement())
continue;
- RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration::create(node);
+ Element* element = toElement(node);
+ RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration::create(element);
RefPtrWillBeRawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);
if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
continue;
return NaturalWritingDirection;
// In the range case, make sure that the embedding element persists until the end of the range.
- if (selection.isRange() && !end.deprecatedNode()->isDescendantOf(node))
+ if (selection.isRange() && !end.deprecatedNode()->isDescendantOf(element))
return NaturalWritingDirection;
foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection;
reconcileTextDecorationProperties(mutableStyle.get());
if (!document->frame()->editor().shouldStyleWithCSS())
- extractTextStyles(document, mutableStyle.get(), computedStyle->useFixedFontDefaultSize());
+ extractTextStyles(document, mutableStyle.get(), computedStyle->fixedPitchFontType());
// Changing the whitespace style in a tab span would collapse the tab into a space.
- if (isTabSpanTextNode(position.deprecatedNode()) || isTabSpanNode((position.deprecatedNode())))
+ if (isTabHTMLSpanElementTextNode(position.deprecatedNode()) || isTabHTMLSpanElement((position.deprecatedNode())))
mutableStyle->removeProperty(CSSPropertyWhiteSpace);
// If unicode-bidi is present in mutableStyle and direction is not, then add direction to mutableStyle.
}
}
-void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet* style, bool shouldUseFixedFontDefaultSize)
+void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet* style, FixedPitchFontType fixedPitchFontType)
{
ASSERT(style);
// Furthermore, text-decoration: none has been trimmed so that text-decoration property is always a CSSValueList.
RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(textDecorationPropertyForEditing());
if (textDecoration && textDecoration->isValueList()) {
-#if ENABLE(OILPAN)
- DEFINE_STATIC_LOCAL(Persistent<CSSPrimitiveValue>, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
- DEFINE_STATIC_LOCAL(Persistent<CSSPrimitiveValue>, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
-#else
- DEFINE_STATIC_REF(CSSPrimitiveValue, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
- DEFINE_STATIC_REF(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
-#endif
+ DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
+ DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration.get())->copy();
if (newTextDecoration->removeAll(underline))
m_applyUnderline = true;
style->removeProperty(CSSPropertyFontFamily);
if (RefPtrWillBeRawPtr<CSSValue> fontSize = style->getPropertyCSSValue(CSSPropertyFontSize)) {
- if (!fontSize->isPrimitiveValue())
+ if (!fontSize->isPrimitiveValue()) {
style->removeProperty(CSSPropertyFontSize); // Can't make sense of the number. Put no font size.
- else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(fontSize.get()),
- shouldUseFixedFontDefaultSize, UseLegacyFontSizeOnlyIfPixelValuesMatch)) {
+ } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(fontSize.get()), fixedPitchFontType, UseLegacyFontSizeOnlyIfPixelValuesMatch)) {
m_applyFontSize = String::number(legacyFontSize);
style->removeProperty(CSSPropertyFontSize);
}
return value->isFontIndependentLength();
}
-int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, bool shouldUseFixedFontDefaultSize, LegacyFontSizeMode mode)
+int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, FixedPitchFontType fixedPitchFontType, LegacyFontSizeMode mode)
{
if (isCSSValueLength(value)) {
int pixelFontSize = value->getIntValue(CSSPrimitiveValue::CSS_PX);
- int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, shouldUseFixedFontDefaultSize);
+ int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, fixedPitchFontType);
// Use legacy font size only if pixel value matches exactly to that of legacy font size.
- int cssPrimitiveEquivalent = legacyFontSize - 1 + CSSValueXSmall;
- if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(document, cssPrimitiveEquivalent, shouldUseFixedFontDefaultSize) == pixelFontSize)
+ CSSValueID cssPrimitiveEquivalent = static_cast<CSSValueID>(legacyFontSize - 1 + CSSValueXSmall);
+ if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(document, cssPrimitiveEquivalent, fixedPitchFontType) == pixelFontSize)
return legacyFontSize;
return 0;