Title: [105291] trunk
Revision
105291
Author
enr...@apple.com
Date
2012-01-18 10:12:19 -0800 (Wed, 18 Jan 2012)

Log Message

Source/WebKit/mac: Missing NSForegroundColorAttributeName should be treated as black instead of transparent.
https://bugs.webkit.org/show_bug.cgi?id=76490
<rdar://problem/9460733>
        
Starting with Lion, there is no more NSForegroundColor attribute in the dictionary
if the color matches the default (solid black).
The fix consists in treating the lack of color as solid black instead of transparent as
we did before.

Added a TestWebKitAPI test.
        
Reviewed by Darin Adler and Dan Bernstein.

* WebView/WebHTMLView.mm:
(-[WebHTMLView _styleForAttributeChange:]):

Tools: Missing NSForegroundColorAttributeName should be treated as black instead of transparent.
https://bugs.webkit.org/show_bug.cgi?id=76490
<rdar://problem/9460733>

Added TestWebKitAPI test.
        
Reviewed by Dan Bernstein.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added new test file.
* TestWebKitAPI/Tests/mac/InspectorBar.mm: Added test that calls
changeAttributes to the WebView.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (105290 => 105291)


--- trunk/Source/WebKit/mac/ChangeLog	2012-01-18 18:10:30 UTC (rev 105290)
+++ trunk/Source/WebKit/mac/ChangeLog	2012-01-18 18:12:19 UTC (rev 105291)
@@ -1,3 +1,21 @@
+2012-01-17  Enrica Casucci  <enr...@apple.com>
+
+        Missing NSForegroundColorAttributeName should be treated as black instead of transparent.
+        https://bugs.webkit.org/show_bug.cgi?id=76490
+        <rdar://problem/9460733>
+        
+        Starting with Lion, there is no more NSForegroundColor attribute in the dictionary
+        if the color matches the default (solid black).
+        The fix consists in treating the lack of color as solid black instead of transparent as
+        we did before.
+
+        Added a TestWebKitAPI test.
+        
+        Reviewed by Darin Adler and Dan Bernstein.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _styleForAttributeChange:]):
+
 2012-01-17  Matthew Delaney  <mdela...@apple.com>
 
         On post-Lion releases, preserve the Lion behavior where WebKit explicitly calls -setGeometryFlipped on the hosting layer for applications that were linked on Lion or earlier.

Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (105290 => 105291)


--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2012-01-18 18:10:30 UTC (rev 105290)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2012-01-18 18:12:19 UTC (rev 105291)
@@ -4602,6 +4602,8 @@
     ca = [a objectForKey:NSForegroundColorAttributeName];
     cb = [b objectForKey:NSForegroundColorAttributeName];
     if (ca == cb) {
+        if (!ca)
+            ca = [NSColor blackColor];
         [style setColor:[self _colorAsString:ca]];
     }
 

Modified: trunk/Tools/ChangeLog (105290 => 105291)


--- trunk/Tools/ChangeLog	2012-01-18 18:10:30 UTC (rev 105290)
+++ trunk/Tools/ChangeLog	2012-01-18 18:12:19 UTC (rev 105291)
@@ -1,3 +1,17 @@
+2012-01-17  Enrica Casucci  <enr...@apple.com>
+
+        Missing NSForegroundColorAttributeName should be treated as black instead of transparent.
+        https://bugs.webkit.org/show_bug.cgi?id=76490
+        <rdar://problem/9460733>
+
+        Added TestWebKitAPI test.
+        
+        Reviewed by Dan Bernstein.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added new test file.
+        * TestWebKitAPI/Tests/mac/InspectorBar.mm: Added test that calls
+        changeAttributes to the WebView.
+        
 2012-01-18  Balazs Kelemen  <kbal...@webkit.org>
 
         [Qt] Consolidate layout test crash logging

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (105290 => 105291)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2012-01-18 18:10:30 UTC (rev 105290)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2012-01-18 18:12:19 UTC (rev 105291)
@@ -105,6 +105,7 @@
 		C0BD669F131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */; };
 		C0C5D3BE14598B6F00A802A6 /* GetBackingScaleFactor.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */; };
 		C0C5D3C61459912900A802A6 /* GetBackingScaleFactor_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */; };
+		C507E8A714C6545B005D6B3B /* InspectorBar.mm in Sources */ = {isa = PBXBuildFile; fileRef = C507E8A614C6545B005D6B3B /* InspectorBar.mm */; };
 		F3FC3EE313678B7300126A65 /* libgtest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F3FC3EE213678B7300126A65 /* libgtest.a */; };
 		F6F3F29113342FEB00A6BF19 /* CookieManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */; };
 		F6FDDDD314241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */; };
@@ -271,6 +272,7 @@
 		C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResponsivenessTimerDoesntFireEarly_Bundle.cpp; sourceTree = "<group>"; };
 		C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor.mm; sourceTree = "<group>"; };
 		C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor_Bundle.mm; sourceTree = "<group>"; };
+		C507E8A614C6545B005D6B3B /* InspectorBar.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InspectorBar.mm; sourceTree = "<group>"; };
 		F3FC3EE213678B7300126A65 /* libgtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; };
 		F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CookieManager.cpp; sourceTree = "<group>"; };
 		F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateBrowsingPushStateNoHistoryCallback.cpp; sourceTree = "<group>"; };
@@ -529,6 +531,7 @@
 				37DC678B140D7C5000ABCCDB /* DOMRangeOfString.mm */,
 				C07E6CAE13FD67650038B22B /* DynamicDeviceScaleFactor.mm */,
 				939BA91614103412001A01BD /* DeviceScaleFactorOnBack.mm */,
+				C507E8A614C6545B005D6B3B /* InspectorBar.mm */,
 				3722C8681461E03E00C45D00 /* RenderedImageFromDOMRange.mm */,
 				3799AD3914120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm */,
 				37A6895D148A9B50005100FA /* SubresourceErrorCrash.mm */,
@@ -725,6 +728,7 @@
 				BCAA485814A044D40088FAC4 /* EditorCommands.mm in Sources */,
 				BC55F5F914AD78EE00484BE1 /* Vector.cpp in Sources */,
 				440A1D3914A0103A008A66F2 /* KURL.cpp in Sources */,
+				C507E8A714C6545B005D6B3B /* InspectorBar.mm in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: trunk/Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm (0 => 105291)


--- trunk/Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm	2012-01-18 18:12:19 UTC (rev 105291)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "PlatformUtilities.h"
+#import <wtf/RetainPtr.h>
+
+@interface InspectorBarController : NSObject {
+}
+@end
+
+static bool didFinishLoad;
+
+@implementation InspectorBarController
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+    didFinishLoad = true;
+}
+
+- (NSDictionary *)convertAttributes:(NSDictionary *)dictionary
+{
+    NSMutableDictionary *newDictionary = [dictionary mutableCopy];
+    [newDictionary removeObjectForKey:NSForegroundColorAttributeName];
+    return [newDictionary autorelease];
+}
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, InspectorBarTest)
+{
+    RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+    RetainPtr<InspectorBarController> inspectorBarController(AdoptNS, [InspectorBarController new]);
+
+    webView.get().frameLoadDelegate = inspectorBarController.get();
+    [webView.get().mainFrame loadHTMLString:@"<body contenteditable style=\"color: green\">Lorem ipsum sit amet</body>" baseURL:[NSURL URLWithString:@"about:blank"]];
+
+    Util::run(&didFinishLoad);
+
+    DOMDocument *document = webView.get().mainFrameDocument;
+    [[document body] focus];
+    [webView.get() selectAll:nil];
+    [webView.get() changeAttributes:inspectorBarController.get()];
+    
+    DOMNode *currentNode = [document body];
+    while ([[currentNode firstChild] nodeType] != DOM_TEXT_NODE)
+        currentNode = [currentNode firstChild];
+
+    DOMCSSStyleDeclaration *style = [document getComputedStyle:(DOMElement *)currentNode pseudoElement:nil];
+    EXPECT_WK_STREQ(@"rgb(0, 0, 0)", [style color]);
+}
+
+} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to