REGRESSION (r160908): Unable to unset bold while entering text
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jun 2014 17:02:27 +0000 (17:02 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jun 2014 17:02:27 +0000 (17:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134196
<rdar://problem/17051653>

Reviewed by Andreas Kling.

No test, this code path is used by some WK1 API clients only.

* editing/Editor.cpp:
(WebCore::Editor::styleForSelectionStart):

    This needs to update the style before requesting the renderer.

* editing/Editor.h:
* editing/ios/EditorIOS.mm:
(WebCore::styleForSelectionStart): Deleted.
* editing/mac/EditorMac.mm:
(WebCore::styleForSelectionStart): Deleted.

    Removed the duplicated functions, moved to Editor.cpp.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170296 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/Editor.h
Source/WebCore/editing/ios/EditorIOS.mm
Source/WebCore/editing/mac/EditorMac.mm

index 58e574d..6e63043 100644 (file)
@@ -1,3 +1,26 @@
+2014-06-23  Antti Koivisto  <antti@apple.com>
+
+        REGRESSION (r160908): Unable to unset bold while entering text
+        https://bugs.webkit.org/show_bug.cgi?id=134196
+        <rdar://problem/17051653>
+
+        Reviewed by Andreas Kling.
+        
+        No test, this code path is used by some WK1 API clients only.
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::styleForSelectionStart):
+        
+            This needs to update the style before requesting the renderer.
+
+        * editing/Editor.h:
+        * editing/ios/EditorIOS.mm:
+        (WebCore::styleForSelectionStart): Deleted.
+        * editing/mac/EditorMac.mm:
+        (WebCore::styleForSelectionStart): Deleted.
+        
+            Removed the duplicated functions, moved to Editor.cpp.
+
 2014-06-23  Alex Christensen  <achristensen@webkit.org>
 
         [iOS] Fix video in WebGL.
index 856b81c..4f338b3 100644 (file)
@@ -3644,4 +3644,37 @@ Document& Editor::document() const
     return *m_frame.document();
 }
 
+#if PLATFORM(COCOA)
+// FIXME: This figures out the current style by inserting a <span>!
+RenderStyle* Editor::styleForSelectionStart(Frame* frame, Node *&nodeToRemove)
+{
+    nodeToRemove = nullptr;
+
+    if (frame->selection().isNone())
+        return nullptr;
+
+    Position position = frame->selection().selection().visibleStart().deepEquivalent();
+    if (!position.isCandidate() || position.isNull())
+        return nullptr;
+
+    RefPtr<EditingStyle> typingStyle = frame->selection().typingStyle();
+    if (!typingStyle || !typingStyle->style())
+        return &position.deprecatedNode()->renderer()->style();
+
+    RefPtr<Element> styleElement = frame->document()->createElement(spanTag, false);
+
+    String styleText = typingStyle->style()->asText() + " display: inline";
+    styleElement->setAttribute(styleAttr, styleText);
+
+    styleElement->appendChild(frame->document()->createEditingTextNode(""), ASSERT_NO_EXCEPTION);
+
+    position.deprecatedNode()->parentNode()->appendChild(styleElement, ASSERT_NO_EXCEPTION);
+
+    nodeToRemove = styleElement.get();
+
+    frame->document()->updateStyleIfNeeded();
+    return styleElement->renderer() ? &styleElement->renderer()->style() : nullptr;
+}
+#endif
+
 } // namespace WebCore
index 5c2068c..f49d971 100644 (file)
@@ -489,6 +489,8 @@ private:
     PassRefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(PassRefPtr<ArchiveResource>);
     PassRefPtr<DocumentFragment> createFragmentAndAddResources(NSAttributedString *);
     void fillInUserVisibleForm(PasteboardURL&);
+
+    static RenderStyle* styleForSelectionStart(Frame* , Node *&nodeToRemove);
 #endif
 
     Frame& m_frame;
index 669be88..4265e75 100644 (file)
@@ -185,39 +185,6 @@ bool Editor::insertParagraphSeparatorInQuotedContent()
     return true;
 }
 
-// FIXME: Copied from EditorMac. This should be shared between the two so that
-// the implementation does not differ.
-static RenderStyle* styleForSelectionStart(Frame* frame, Node *&nodeToRemove)
-{
-    nodeToRemove = 0;
-
-    if (frame->selection().isNone())
-        return 0;
-
-    Position position = frame->selection().selection().visibleStart().deepEquivalent();
-    if (!position.isCandidate() || position.isNull())
-        return 0;
-
-    RefPtr<EditingStyle> typingStyle = frame->selection().typingStyle();
-    if (!typingStyle || !typingStyle->style())
-        return &position.deprecatedNode()->renderer()->style();
-
-    RefPtr<Element> styleElement = frame->document()->createElement(spanTag, false);
-
-    String styleText = typingStyle->style()->asText() + " display: inline";
-    styleElement->setAttribute(styleAttr, styleText.impl());
-
-    ExceptionCode ec = 0;
-    styleElement->appendChild(frame->document()->createEditingTextNode(""), ec);
-    ASSERT(!ec);
-
-    position.deprecatedNode()->parentNode()->appendChild(styleElement, ec);
-    ASSERT(!ec);
-
-    nodeToRemove = styleElement.get();
-    return styleElement->renderer() ? &styleElement->renderer()->style() : 0;
-}
-
 const SimpleFontData* Editor::fontForSelection(bool& hasMultipleFonts) const
 {
     hasMultipleFonts = false;
index e6dc544..fae154e 100644 (file)
@@ -106,34 +106,6 @@ bool Editor::insertParagraphSeparatorInQuotedContent()
     return true;
 }
 
-static RenderStyle* styleForSelectionStart(Frame* frame, Node *&nodeToRemove)
-{
-    nodeToRemove = 0;
-
-    if (frame->selection().isNone())
-        return 0;
-
-    Position position = frame->selection().selection().visibleStart().deepEquivalent();
-    if (!position.isCandidate() || position.isNull())
-        return 0;
-
-    RefPtr<EditingStyle> typingStyle = frame->selection().typingStyle();
-    if (!typingStyle || !typingStyle->style())
-        return &position.deprecatedNode()->renderer()->style();
-
-    RefPtr<Element> styleElement = frame->document()->createElement(spanTag, false);
-
-    String styleText = typingStyle->style()->asText() + " display: inline";
-    styleElement->setAttribute(styleAttr, styleText);
-
-    styleElement->appendChild(frame->document()->createEditingTextNode(""), ASSERT_NO_EXCEPTION);
-
-    position.deprecatedNode()->parentNode()->appendChild(styleElement, ASSERT_NO_EXCEPTION);
-
-    nodeToRemove = styleElement.get();
-    return styleElement->renderer() ? &styleElement->renderer()->style() : 0;
-}
-
 const SimpleFontData* Editor::fontForSelection(bool& hasMultipleFonts) const
 {
     hasMultipleFonts = false;