Home | History | Annotate | Download | only in editing

Lines Matching full:style

91 StyleChange::StyleChange(CSSStyleDeclaration* style, const Position& position)
99 init(style, position);
102 void StyleChange::init(PassRefPtr<CSSStyleDeclaration> style, const Position& position)
109 RefPtr<CSSMutableStyleDeclaration> mutableStyle = getPropertiesNotInComputedStyle(style.get(), computedStyle.get());
115 // Changing the whitespace style in a tab span would collapse the tab into a space.
121 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->getPropertyCSSValue(CSSPropertyDirection))
122 mutableStyle->setProperty(CSSPropertyDirection, style->getPropertyValue(CSSPropertyDirection));
128 void StyleChange::reconcileTextDecorationProperties(CSSMutableStyleDeclaration* style)
130 RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
131 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyTextDecoration);
135 style->setProperty(CSSPropertyTextDecoration, textDecorationsInEffect->cssText());
136 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect);
142 style->removeProperty(CSSPropertyTextDecoration);
145 static int getIdentifierValue(CSSMutableStyleDeclaration* style, int propertyID)
147 if (!style)
150 RefPtr<CSSValue> value = style->getPropertyCSSValue(propertyID);
157 static void setTextDecorationProperty(CSSMutableStyleDeclaration* style, const CSSValueList* newTextDecoration, int propertyID)
160 style->setProperty(propertyID, newTextDecoration->cssText(), style->getPropertyPriority(propertyID));
163 ASSERT(!style->getPropertyPriority(propertyID));
164 style->removeProperty(propertyID);
168 void StyleChange::extractTextStyles(CSSMutableStyleDeclaration* style)
170 ASSERT(style);
172 if (getIdentifierValue(style, CSSPropertyFontWeight) == CSSValueBold) {
173 style->removeProperty(CSSPropertyFontWeight);
177 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle);
179 style->removeProperty(CSSPropertyFontStyle);
185 if (RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(CSSPropertyTextDecoration)) {
197 setTextDecorationProperty(style, newTextDecoration.get(), CSSPropertyTextDecoration);
200 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign);
203 style->removeProperty(CSSPropertyVerticalAlign);
207 style->removeProperty(CSSPropertyVerticalAlign);
212 if (RefPtr<CSSValue> colorValue = style->getPropertyCSSValue(CSSPropertyColor)) {
223 style->removeProperty(CSSPropertyColor);
226 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily);
227 style->removeProperty(CSSPropertyFontFamily);
229 if (RefPtr<CSSValue> fontSize = style->getPropertyCSSValue(CSSPropertyFontSize)) {
231 style->removeProperty(CSSPropertyFontSize); // Can't make sense of the number. Put no font size.
324 static void diffTextDecorations(CSSMutableStyleDeclaration* style, int propertID, CSSValue* refTextDecoration)
326 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(propertID);
336 setTextDecorationProperty(style, newTextDecoration.get(), propertID);
339 static bool fontWeightIsBold(CSSStyleDeclaration* style)
341 ASSERT(style);
342 RefPtr<CSSValue> fontWeight = style->getPropertyCSSValue(CSSPropertyFontWeight);
371 RefPtr<CSSMutableStyleDeclaration> getPropertiesNotInComputedStyle(CSSStyleDeclaration* style, CSSComputedStyleDeclaration* computedStyle)
373 ASSERT(style);
375 RefPtr<CSSMutableStyleDeclaration> result = style->copy();
388 // Editing style properties must be preserved during editing operation.
422 RefPtr<CSSMutableStyleDeclaration> style;
424 style = CSSMutableStyleDeclaration::create();
426 style = computedStyleAtPosition->copyPropertiesInSet(editingStyleProperties, numEditingStyleProperties);
428 if (style && pos.node() && pos.node()->computedStyle()) {
435 style->removeProperty(CSSPropertyWebkitTextFillColor, ec);
437 style->removeProperty(CSSPropertyWebkitTextStrokeColor, ec);
440 style->setProperty(CSSPropertyFontSize, computedStyleAtPosition->getFontSizeCSSValuePreferringKeyword()->cssText());
446 style->merge(typingStyle);
449 return style.release();
454 // ReplaceSelectionCommand::handleStyleSpans() requires that this function only removes the editing style.
457 RefPtr<CSSMutableStyleDeclaration> style = editingStyleAtPosition(pos);
458 style->diff(editingStyle);
476 RefPtr<CSSMutableStyleDeclaration> style = editingStyleAtPosition(Position(node, 0));
477 parentStyle->diff(style.get());
478 style->diff(editingStyle);
481 ApplyStyleCommand::ApplyStyleCommand(Document* document, CSSStyleDeclaration* style, EditAction editingAction, EPropertyLevel propertyLevel)
483 , m_style(style->makeMutable())
494 ApplyStyleCommand::ApplyStyleCommand(Document* document, CSSStyleDeclaration* style, const Position& start, const Position& end, EditAction editingAction, EPropertyLevel propertyLevel)
496 , m_style(style->makeMutable())
552 // apply the block-centric properties of the style
578 void ApplyStyleCommand::applyBlockStyle(CSSMutableStyleDeclaration *style)
582 // to check a computed style
585 // get positions we want to use for applying style
610 StyleChange styleChange(style, paragraphStart.deepEquivalent());
618 removeCSSStyle(style, static_cast<HTMLElement*>(block.get()));
636 void ApplyStyleCommand::applyRelativeFontStyleChange(CSSMutableStyleDeclaration *style)
638 RefPtr<CSSValue> value = style->getPropertyCSSValue(CSSPropertyFontSize);
641 style->removeProperty(CSSPropertyWebkitFontSizeDelta);
645 // Get the adjustment amount out of the style.
646 value = style->getPropertyCSSValue(CSSPropertyWebkitFontSizeDelta);
658 style->removeProperty(CSSPropertyWebkitFontSizeDelta);
682 // Split the start text nodes if needed to apply style.
726 // Last styled node was not parent node of this text node, but we wish to style this
727 // text node. To make this possible, add a style span to surround this text node.
778 // Dummy spans are created when text node is split, so that style information
863 // FIXME: This code should really consider the mapped attribute 'dir', the inline style declaration,
864 // and all matching style rules in order to determine how to best set the unicode-bidi property to 'normal'.
866 // otherwise it sets the property in the inline style declaration.
886 void ApplyStyleCommand::applyInlineStyle(CSSMutableStyleDeclaration *style)
893 // to check a computed style
896 // adjust to the positions we want to use for applying style
921 RefPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);
930 direction = style->getPropertyCSSValue(CSSPropertyDirection);
940 // Remove style from the selection.
941 // Use the upstream position of the start for removing style.
963 RefPtr<CSSMutableStyleDeclaration> styleWithoutEmbedding = style->copy();
968 removeInlineStyle(style, removeStart, end);
989 // to check a computed style
1033 RefPtr<CSSMutableStyleDeclaration> styleWithoutEmbedding = style->copy();
1038 applyInlineStyleToRange(style, start, end);
1040 // Remove dummy style spans created by splitting text elements.
1046 void ApplyStyleCommand::applyInlineStyleToRange(CSSMutableStyleDeclaration* style, const Position& start, const Position& rangeEnd)
1066 // if they want style applied to the empty line.
1069 // Add the style to selected inline runs.
1083 // Add to this element's inline style and skip over its contents.
1086 inlineStyle->merge(style);
1112 // Apply the style to the run.
1113 addInlineStyleIfNeeded(style, runStart, node);
1129 // Remove node if it implicitly adds style not present in styleToApply
1137 bool ApplyStyleCommand::implicitlyStyledElementShouldBeRemovedWhenApplyingStyle(HTMLElement* elem, CSSMutableStyleDeclaration* style)
1139 CSSMutableStyleDeclaration::const_iterator end = style->end();
1140 style->begin(); it != end; ++it) {
1164 return shouldRemoveTextDecorationTag(style, CSSValueUnderline) || !elem->hasChildNodes();
1166 return shouldRemoveTextDecorationTag(style,CSSValueLineThrough) || !elem->hasChildNodes();
1176 // Similar to isSpanWithoutAttributesOrUnstyleStyleSpan, but does not look for Apple-style-span.
1181 // Remove the element even if it has just style='' (this might be redundantly checked later too)
1196 void ApplyStyleCommand::removeHTMLFontStyle(CSSMutableStyleDeclaration *style, HTMLElement *elem)
1198 ASSERT(style);
1204 CSSMutableStyleDeclaration::const_iterator end = style->end();
1205 for (CSSMutableStyleDeclaration::const_iterator it = style->begin(); it != end; ++it) {
1223 void ApplyStyleCommand::removeHTMLBidiEmbeddingStyle(CSSMutableStyleDeclaration *style, HTMLElement *elem)
1225 ASSERT(style);
1231 if (!style->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->getPropertyCSSValue(CSSPropertyDirection))
1241 void ApplyStyleCommand::removeCSSStyle(CSSMutableStyleDeclaration* style, HTMLElement* elem)
1243 ASSERT(style);
1250 CSSMutableStyleDeclaration::const_iterator end = style->end();
1251 for (CSSMutableStyleDeclaration::const_iterator it = style->begin(); it != end; ++it) {
1261 // No need to serialize <foo style=""> if we just removed the last css property
1306 RefPtr<CSSMutableStyleDeclaration> style = element->inlineStyleDecl();
1307 if (!style)
1311 RefPtr<CSSMutableStyleDeclaration> textDecorationStyle = style->copyPropertiesInSet(properties, 1);
1313 RefPtr<CSSValue> property = style->getPropertyCSSValue(CSSPropertyTextDecoration);
1315 removeCSSProperty(style.get(), CSSPropertyTextDecoration);
1345 void ApplyStyleCommand::applyTextDecorationStyle(Node *node, CSSMutableStyleDeclaration *style)
1349 if (!style || style->cssText().isEmpty())
1352 StyleChange styleChange(style, Position(node, 0));
1439 void ApplyStyleCommand::removeInlineStyle(PassRefPtr<CSSMutableStyleDeclaration> style, const Position &start, const Position &end)
1447 RefPtr<CSSValue> textDecorationSpecialProperty = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
1451 style = style->copy();
1452 style->setProperty(CSSPropertyTextDecoration, textDecorationSpecialProperty->cssText(), style->getPropertyPriority(CSSPropertyWebkitTextDecorationsInEffect));
1455 // The s and e variables store the positions used to set the ending selection after style removal
1471 if (implicitlyStyledElementShouldBeRemovedWhenApplyingStyle(elem, style.get()))
1475 // styles which must be removed (e.g. <b style='font-weight: bold'>)
1477 removeHTMLFontStyle(style.get(), elem);
1478 removeHTMLBidiEmbeddingStyle(style.get(), elem);
1479 removeCSSStyle(style.get(), elem);
1783 void ApplyStyleCommand::addInlineStyleIfNeeded(CSSMutableStyleDeclaration *style, Node *startNode, Node *endNode)
1788 StyleChange styleChange(style, Position(startNode, 0));
1797 // We only want to insert a font element if it will end up changing the style of the
1799 // most notably when we apply a blockquote style for a message reply.