Title: [105829] trunk
Revision
105829
Author
[email protected]
Date
2012-01-24 15:58:42 -0800 (Tue, 24 Jan 2012)

Log Message

WebHTMLView should implement typingAttributes methods to work correctly with the Inspector bar in Mail.
https://bugs.webkit.org/show_bug.cgi?id=76951
<rdar://problem/9325158>

Source/WebKit/mac: 

The Inspector bar calls the typingAttributes methods on the clients that support it
to retrieve the set of attributes representing the style at the selection and uses
this information to update the state of the B, I and U buttons.
If this method is not supported, it defaults to the attributes of the previous
character position, reporting an incorrect state.
This occurs only when we have a caret selection.
        
Reviewed by Alexey Proskuryakov.

* WebView/WebHTMLView.mm:
(-[WebHTMLView _styleForAttributeChange:]): Removed dead code.
(-[WebHTMLView _updateFontPanel]): Removed comment that doesn't apply anymore.
(-[WebHTMLView typingAttributes]): Added.

Tools: 

Added test to verify that WebHTMLView supports the typingAttributes method and that it
works as expected.
        
Reviewed by Alexey Proskuryakov.

* TestWebKitAPI/Tests/mac/InspectorBar.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (105828 => 105829)


--- trunk/Source/WebKit/mac/ChangeLog	2012-01-24 23:53:27 UTC (rev 105828)
+++ trunk/Source/WebKit/mac/ChangeLog	2012-01-24 23:58:42 UTC (rev 105829)
@@ -1,3 +1,23 @@
+2012-01-24  Enrica Casucci  <[email protected]>
+
+        WebHTMLView should implement typingAttributes methods to work correctly with the Inspector bar in Mail.
+        https://bugs.webkit.org/show_bug.cgi?id=76951
+        <rdar://problem/9325158>
+
+        The Inspector bar calls the typingAttributes methods on the clients that support it
+        to retrieve the set of attributes representing the style at the selection and uses
+        this information to update the state of the B, I and U buttons.
+        If this method is not supported, it defaults to the attributes of the previous
+        character position, reporting an incorrect state.
+        This occurs only when we have a caret selection.
+        
+        Reviewed by Alexey Proskuryakov.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _styleForAttributeChange:]): Removed dead code.
+        (-[WebHTMLView _updateFontPanel]): Removed comment that doesn't apply anymore.
+        (-[WebHTMLView typingAttributes]): Added.
+
 2012-01-24  Benjamin Poulain  <[email protected]>
 
         pageCacheSupportsPlugins should default to true on WebKit1

Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (105828 => 105829)


--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2012-01-24 23:53:27 UTC (rev 105828)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2012-01-24 23:58:42 UTC (rev 105829)
@@ -4568,29 +4568,6 @@
 
     [shadow release];
 
-#if 0
-
-NSObliquenessAttributeName        /* float; skew to be applied to glyphs, default 0: no skew */
-    // font-style, but that is just an on-off switch
-
-NSExpansionAttributeName          /* float; log of expansion factor to be applied to glyphs, default 0: no expansion */
-    // font-stretch?
-
-NSKernAttributeName               /* float, amount to modify default kerning, if 0, kerning off */
-    // letter-spacing? probably not good enough
-
-NSUnderlineColorAttributeName     /* NSColor, default nil: same as foreground color */
-NSStrikethroughColorAttributeName /* NSColor, default nil: same as foreground color */
-    // text-decoration-color?
-
-NSLigatureAttributeName           /* int, default 1: default ligatures, 0: no ligatures, 2: all ligatures */
-NSBaselineOffsetAttributeName     /* float, in points; offset from baseline, default 0 */
-NSStrokeWidthAttributeName        /* float, in percent of font point size, default 0: no stroke; positive for stroke alone, negative for stroke and fill (a typical value for outlined text would be 3.0) */
-NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground color */
-    // need extensions?
-
-#endif
-    
     NSDictionary *a = [sender convertAttributes:oa];
     NSDictionary *b = [sender convertAttributes:ob];
 
@@ -5069,10 +5046,6 @@
     ASSERT(font != nil);
 
     [[NSFontManager sharedFontManager] setSelectedFont:font isMultiple:multipleFonts];
-
-    // FIXME: we don't keep track of selected attributes, or set them on the font panel. This
-    // appears to have no effect on the UI. E.g., underlined text in Mail or TextEdit is
-    // not reflected in the font panel. Maybe someday this will change.
 }
 
 - (BOOL)_canSmartCopyOrDelete
@@ -5713,6 +5686,15 @@
     return result;
 }
 
+- (NSDictionary *)typingAttributes
+{
+    Frame* coreFrame = core([self _frame]);
+    if (coreFrame)
+        return coreFrame->editor()->fontAttributesForSelectionStart();
+
+    return nil;
+}
+
 - (NSAttributedString *)attributedSubstringFromRange:(NSRange)nsRange
 {
     [self _executeSavedKeypressCommands];

Modified: trunk/Tools/ChangeLog (105828 => 105829)


--- trunk/Tools/ChangeLog	2012-01-24 23:53:27 UTC (rev 105828)
+++ trunk/Tools/ChangeLog	2012-01-24 23:58:42 UTC (rev 105829)
@@ -1,3 +1,17 @@
+2012-01-24  Enrica Casucci  <[email protected]>
+
+        WebHTMLView should implement typingAttributes methods to work correctly with the Inspector bar in Mail.
+        https://bugs.webkit.org/show_bug.cgi?id=76951
+        <rdar://problem/9325158>
+
+        Added test to verify that WebHTMLView supports the typingAttributes method and that it
+        works as expected.
+        
+        Reviewed by Alexey Proskuryakov.
+
+        * TestWebKitAPI/Tests/mac/InspectorBar.mm:
+        (TestWebKitAPI::TEST):
+
 2012-01-24  James Robinson  <[email protected]>
 
         Put a space between the trac link and ellipsis in sheriffbot rollout message so it linkifies better in some IRC clients

Modified: trunk/Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm (105828 => 105829)


--- trunk/Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm	2012-01-24 23:53:27 UTC (rev 105828)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm	2012-01-24 23:58:42 UTC (rev 105829)
@@ -62,10 +62,15 @@
 
     DOMDocument *document = webView.get().mainFrameDocument;
     [[document body] focus];
+    
+    EXPECT_TRUE([[[[webView.get() mainFrame] frameView] documentView] respondsToSelector:@selector(typingAttributes)]);
+    NSDictionary *attributes = [(id)[[[webView.get() mainFrame] frameView] documentView] typingAttributes];
+    [(id)[[[webView.get() mainFrame] frameView] documentView] doCommandBySelector:@selector(bold:)];
+    EXPECT_FALSE([attributes isEqual:[(id)[[[webView.get() mainFrame] frameView] documentView] typingAttributes]]);
+    
     [webView.get() selectAll:nil];
-    
     NSAttributedString *attrString = [(NSView <NSTextInput> *)[[[webView.get() mainFrame] frameView] documentView] attributedSubstringFromRange:NSMakeRange(0, 5)];
-    NSDictionary *attributes = [attrString attributesAtIndex:0 effectiveRange:0];
+    attributes = [attrString attributesAtIndex:0 effectiveRange:0];
     
     EXPECT_TRUE([[attributes objectForKey:NSUnderlineStyleAttributeName] intValue] != 0);
 
@@ -77,7 +82,6 @@
 
     DOMCSSStyleDeclaration *style = [document getComputedStyle:(DOMElement *)currentNode pseudoElement:nil];
     EXPECT_WK_STREQ(@"rgb(0, 0, 0)", [style color]);
-    
 }
 
 } // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to