Revert "WebKit doesn't preserve style when copying text from another element"
authorGrzegorz Czajkowski <g.czajkowski@samsung.com>
Fri, 17 May 2013 09:13:47 +0000 (11:13 +0200)
committerGrzegorz Czajkowski <g.czajkowski@samsung.com>
Mon, 3 Jun 2013 12:55:08 +0000 (14:55 +0200)
This reverts commit fccadac34c199ba488e2835fde9401fe7faca785.
There is a better solution at https://tizendev.org/gerrit/#/c/69322/ (no regression)

Change-Id: I75bf5fd5fa7cd9e51b470ba8f0438ee32844b80f

Source/WTF/wtf/Platform.h
Source/WebCore/editing/EditingStyle.cpp
Source/WebCore/editing/EditingStyle.h
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/editing/markup.cpp

index 71dc544..3316d65 100755 (executable)
 #define ENABLE_TIZEN_LOAD_HTML_STRING_AS_UTF8 1 /* KwangYong Choi (ky0.choi@samsung.com) : Use UTF-8 instead of UTF-16 when the page is loaded by WebPage::loadHTMLString() */
 #define ENABLE_TIZEN_DRAW_SCALED_PATTERN 1 /* Kyungjin Kim(gen.kim@samsung.com) : Scale image prior to draw it's pattern to enhance performance */
 #define ENABLE_TIZEN_PAINT_SELECTION_ANTIALIAS_NONE 1 /* Hyeonji Kim(hyeonji.kim@samsung.com) : Remove the line between the preceding text block and the next text block which are selected */
-#define ENABLE_TIZEN_PRESERVE_STYLE_WHILE_COPYING 1 /* Grzegorz Czajkowski (g.czajkowski@samsung.com): while copying elements, their style are not being copied. It happens for span tag if it occurs alone. This is cherry-pick from https://bugs.webkit.org/show_bug.cgi?id=112329 which is under review. */
 #define ENABLE_TIZEN_USE_SETTINGS_FONT 1 /* Hyeonji Kim(hyeonji.kim@samsung.com) : When font-family is "Tizen", use system's setting font as default font-family */
 #define ENABLE_TIZEN_PARAGRAPH_SEPARATOR_FIX 1 /* Michal Pakula (m.pakula@samsung.com) : This is a quick fix for a bug where new paragraph was not created on contenteditable area with image and text nodes inside span tag */
 #define ENABLE_TIZEN_CONTENT_EDITABLE_BACKSPACE 1 /* Wojciech Bielawski(w.bielawski.com) : This is a quick fix for a bug where after pressing backspace image was moved not correctly */
index 870cc13..a486e17 100644 (file)
@@ -1131,36 +1131,16 @@ static void removePropertiesInStyle(StylePropertySet* styleToRemovePropertiesFro
     styleToRemovePropertiesFrom->removePropertiesInSet(propertiesToRemove.data(), propertiesToRemove.size());
 }
 
-#if ENABLE(TIZEN_PRESERVE_STYLE_WHILE_COPYING)
-bool EditingStyle::removeStyleFromRulesAndContext(StyledElement* element, Node* context)
-#else
 void EditingStyle::removeStyleFromRulesAndContext(StyledElement* element, Node* context)
-#endif
 {
     ASSERT(element);
     if (!m_mutableStyle)
-#if ENABLE(TIZEN_PRESERVE_STYLE_WHILE_COPYING)
-        return false;
-#else
         return;
-#endif
 
     // 1. Remove style from matched rules because style remain without repeating it in inline style declaration
-#if ENABLE(TIZEN_PRESERVE_STYLE_WHILE_COPYING)
-    bool removedStyleFromRules = false;
-#endif
     RefPtr<StylePropertySet> styleFromMatchedRules = styleFromMatchedRulesForElement(element, StyleResolver::AllButEmptyCSSRules);
-#if ENABLE(TIZEN_PRESERVE_STYLE_WHILE_COPYING)
-    if (styleFromMatchedRules && !styleFromMatchedRules->isEmpty()) {
-        RefPtr<StylePropertySet> newStyle = getPropertiesNotIn(m_mutableStyle.get(), styleFromMatchedRules->ensureCSSStyleDeclaration());
-        removedStyleFromRules = newStyle->propertyCount() != m_mutableStyle->propertyCount();
-        if (removedStyleFromRules)
-            m_mutableStyle = newStyle;
-    }
-#else
     if (styleFromMatchedRules && !styleFromMatchedRules->isEmpty())
         m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), styleFromMatchedRules->ensureCSSStyleDeclaration());
-#endif
 
     // 2. Remove style present in context and not overriden by matched rules.
     RefPtr<EditingStyle> computedStyle = EditingStyle::create(context, EditingPropertiesInEffect);
@@ -1180,10 +1160,6 @@ void EditingStyle::removeStyleFromRulesAndContext(StyledElement* element, Node*
         if (!styleFromMatchedRules->getPropertyCSSValue(CSSPropertyFloat) && getIdentifierValue(m_mutableStyle.get(), CSSPropertyFloat) == CSSValueNone)
             m_mutableStyle->removeProperty(CSSPropertyFloat);
     }
-
-#if ENABLE(TIZEN_PRESERVE_STYLE_WHILE_COPYING)
-    return removedStyleFromRules;
-#endif
 }
 
 void EditingStyle::removePropertiesInElementDefaultStyle(Element* element)
index 2e2ff4d..00e9d57 100644 (file)
@@ -135,11 +135,7 @@ public:
     static PassRefPtr<EditingStyle> wrappingStyleForSerialization(Node* context, bool shouldAnnotate);
     void mergeStyleFromRules(StyledElement*);
     void mergeStyleFromRulesForSerialization(StyledElement*);
-#if ENABLE(TIZEN_PRESERVE_STYLE_WHILE_COPYING)
-    bool removeStyleFromRulesAndContext(StyledElement*, Node* context);
-#else
     void removeStyleFromRulesAndContext(StyledElement*, Node* context);
-#endif
     void removePropertiesInElementDefaultStyle(Element*);
     void forceInline();
     int legacyFontSize(Document*) const;
index cac674f..d672392 100644 (file)
@@ -488,9 +488,6 @@ void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
 
         const StylePropertySet* inlineStyle = element->inlineStyle();
         RefPtr<EditingStyle> newInlineStyle = EditingStyle::create(inlineStyle);
-#if ENABLE(TIZEN_PRESERVE_STYLE_WHILE_COPYING)
-        bool removedStyleFromRules = false;
-#endif
         if (inlineStyle) {
             ContainerNode* context = element->parentNode();
 
@@ -498,23 +495,13 @@ void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
             // styles from blockquoteNode are allowed to override those from the source document, see <rdar://problem/4930986> and <rdar://problem/5089327>.
             Node* blockquoteNode = isMailPasteAsQuotationNode(context) ? context : enclosingNodeOfType(firstPositionInNode(context), isMailBlockquote, CanCrossEditingBoundary);
             if (blockquoteNode)
-#if ENABLE(TIZEN_PRESERVE_STYLE_WHILE_COPYING)
-                removedStyleFromRules = newInlineStyle->removeStyleFromRulesAndContext(element, document()->documentElement());
-
-            removedStyleFromRules |= newInlineStyle->removeStyleFromRulesAndContext(element, context);
-#else
                 newInlineStyle->removeStyleFromRulesAndContext(element, document()->documentElement());
 
             newInlineStyle->removeStyleFromRulesAndContext(element, context);
-#endif
         }
 
         if (!inlineStyle || newInlineStyle->isEmpty()) {
-#if ENABLE(TIZEN_PRESERVE_STYLE_WHILE_COPYING)
-            if (!removedStyleFromRules && (isStyleSpanOrSpanWithOnlyStyleAttribute(element))) {
-#else
             if (isStyleSpanOrSpanWithOnlyStyleAttribute(element)) {
-#endif
                 insertedNodes.willRemoveNodePreservingChildren(element);
                 removeNodePreservingChildren(element);
                 continue;
index ac67c80..5d9ba2d 100644 (file)
@@ -587,11 +587,7 @@ String createMarkup(const Range* range, Vector<Node*>* nodes, EAnnotateForInterc
     if (body && areRangesEqual(VisibleSelection::selectionFromContentsOfNode(body).toNormalizedRange().get(), range))
         fullySelectedRoot = body;
     Node* specialCommonAncestor = highestAncestorToWrapMarkup(updatedRange.get(), shouldAnnotate);
-#if ENABLE(TIZEN_PRESERVE_STYLE_WHILE_COPYING)
-    StyledMarkupAccumulator accumulator(nodes, shouldResolveURLs, AnnotateForInterchange, updatedRange.get(), specialCommonAncestor);
-#else
     StyledMarkupAccumulator accumulator(nodes, shouldResolveURLs, shouldAnnotate, updatedRange.get(), specialCommonAncestor);
-#endif
     Node* pastEnd = updatedRange->pastLastNode();
 
     Node* startNode = updatedRange->firstNode();