Title: [173071] trunk/Source
Revision
173071
Author
enr...@apple.com
Date
2014-08-28 12:21:24 -0700 (Thu, 28 Aug 2014)

Log Message

textStylingAtPosition returns incorrect values after executing toggleBold, toggleItalic and toggleUnderline.
https://bugs.webkit.org/show_bug.cgi?id=136323
rdar://problem/18141964

Reviewed by Antti Koivisto.

For underline style we need to check typingStyle first and use that information to populate
the dictionary. If there is no typing style we can use the render style.
Source/WebCore:


* WebCore.exp.in:
* editing/ios/EditorIOS.mm:
(WebCore::Editor::fontAttributesForSelectionStart):

Source/WebKit2:

We also need to update the editor state for the toggle commands to reflect the state in the UIProcess
even for commands that don't change the selection.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::editorState):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::executeEditCommandWithCallback):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (173070 => 173071)


--- trunk/Source/WebCore/ChangeLog	2014-08-28 19:19:33 UTC (rev 173070)
+++ trunk/Source/WebCore/ChangeLog	2014-08-28 19:21:24 UTC (rev 173071)
@@ -1,3 +1,18 @@
+2014-08-27  Enrica Casucci  <enr...@apple.com>
+
+        textStylingAtPosition returns incorrect values after executing toggleBold, toggleItalic and toggleUnderline.
+        https://bugs.webkit.org/show_bug.cgi?id=136323
+        rdar://problem/18141964
+
+        Reviewed by Antti Koivisto.
+
+        For underline style we need to check typingStyle first and use that information to populate
+        the dictionary. If there is no typing style we can use the render style.
+
+        * WebCore.exp.in:
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::fontAttributesForSelectionStart):
+
 2014-08-28  Iago Toral  <ito...@igalia.com> and Zan Dobersek  <zdober...@igalia.com>
 
         [GTK] Add WaylandEventSource

Modified: trunk/Source/WebCore/WebCore.exp.in (173070 => 173071)


--- trunk/Source/WebCore/WebCore.exp.in	2014-08-28 19:19:33 UTC (rev 173070)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-08-28 19:21:24 UTC (rev 173071)
@@ -1752,6 +1752,7 @@
 __ZNK7WebCore15ResourceRequest12cfURLRequestENS_20HTTPBodyUpdatePolicyE
 __ZNK7WebCore15ResourceRequest12nsURLRequestENS_20HTTPBodyUpdatePolicyE
 __ZNK7WebCore15StyleProperties11mutableCopyEv
+__ZNK7WebCore15StyleProperties16getPropertyValueENS_13CSSPropertyIDE
 __ZNK7WebCore15VisiblePosition14characterAfterEv
 __ZNK7WebCore15VisiblePosition14localCaretRectERPNS_12RenderObjectE
 __ZNK7WebCore15VisiblePosition19absoluteCaretBoundsEv

Modified: trunk/Source/WebCore/editing/ios/EditorIOS.mm (173070 => 173071)


--- trunk/Source/WebCore/editing/ios/EditorIOS.mm	2014-08-28 19:19:33 UTC (rev 173070)
+++ trunk/Source/WebCore/editing/ios/EditorIOS.mm	2014-08-28 19:21:24 UTC (rev 173071)
@@ -263,10 +263,16 @@
     CTFontRef font = style->font().primaryFont()->getCTFont();
     if (font)
         [result setObject:(id)font forKey:NSFontAttributeName];
-    
-    if (style->textDecorationsInEffect() & TextDecorationUnderline)
-        [result setObject:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
-    
+
+    RefPtr<EditingStyle> typingStyle = m_frame.selection().typingStyle();
+    if (typingStyle && typingStyle->style()) {
+        String value = typingStyle->style()->getPropertyValue(CSSPropertyWebkitTextDecorationsInEffect);
+        if (value.contains("underline"))
+            [result setObject:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
+    } else {
+        if (style->textDecorationsInEffect() & TextDecorationUnderline)
+            [result setObject:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
+    }
     if (nodeToRemove)
         nodeToRemove->remove(ASSERT_NO_EXCEPTION);
     

Modified: trunk/Source/WebKit2/ChangeLog (173070 => 173071)


--- trunk/Source/WebKit2/ChangeLog	2014-08-28 19:19:33 UTC (rev 173070)
+++ trunk/Source/WebKit2/ChangeLog	2014-08-28 19:21:24 UTC (rev 173071)
@@ -1,3 +1,21 @@
+2014-08-27  Enrica Casucci  <enr...@apple.com>
+
+        textStylingAtPosition returns incorrect values after executing toggleBold, toggleItalic and toggleUnderline.
+        https://bugs.webkit.org/show_bug.cgi?id=136323
+        rdar://problem/18141964
+
+        Reviewed by Antti Koivisto.
+
+        For underline style we need to check typingStyle first and use that information to populate
+        the dictionary. If there is no typing style we can use the render style.
+        We also need to update the editor state for the toggle commands to reflect the state in the UIProcess
+        even for commands that don't change the selection.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::editorState):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::executeEditCommandWithCallback):
+
 2014-08-28  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK] Add webkit_uri_response_get_http_headers to WebKit2 GTK+ API

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (173070 => 173071)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-08-28 19:19:33 UTC (rev 173070)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-08-28 19:21:24 UTC (rev 173071)
@@ -145,6 +145,7 @@
 #include <WebCore/Settings.h>
 #include <WebCore/ShadowRoot.h>
 #include <WebCore/SharedBuffer.h>
+#include <WebCore/StyleProperties.h>
 #include <WebCore/SubframeLoader.h>
 #include <WebCore/SubstituteData.h>
 #include <WebCore/TextIterator.h>
@@ -762,10 +763,17 @@
                 result.typingAttributes |= AttributeBold;
             if (traits & kCTFontTraitItalic)
                 result.typingAttributes |= AttributeItalics;
-            
-            if (style->textDecorationsInEffect() & TextDecorationUnderline)
-                result.typingAttributes |= AttributeUnderline;
-            
+
+            RefPtr<EditingStyle> typingStyle = frame.selection().typingStyle();
+            if (typingStyle && typingStyle->style()) {
+                String value = typingStyle->style()->getPropertyValue(CSSPropertyWebkitTextDecorationsInEffect);
+                if (value.contains("underline"))
+                    result.typingAttributes |= AttributeUnderline;
+            } else {
+                if (style->textDecorationsInEffect() & TextDecorationUnderline)
+                    result.typingAttributes |= AttributeUnderline;
+            }
+
             if (nodeToRemove)
                 nodeToRemove->remove(ASSERT_NO_EXCEPTION);
         }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (173070 => 173071)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-08-28 19:19:33 UTC (rev 173070)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-08-28 19:21:24 UTC (rev 173071)
@@ -1704,6 +1704,8 @@
 void WebPage::executeEditCommandWithCallback(const String& commandName, uint64_t callbackID)
 {
     executeEditCommand(commandName);
+    if (commandName == "toggleBold" || commandName == "toggleItalic" || commandName == "toggleUnderline")
+        send(Messages::WebPageProxy::EditorStateChanged(editorState()));
     send(Messages::WebPageProxy::VoidCallback(callbackID));
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to