From ce6a0047a5c80a663a8f08e4606230cc2727d82f Mon Sep 17 00:00:00 2001 From: "enrica@apple.com" Date: Wed, 18 Jan 2012 18:12:19 +0000 Subject: [PATCH] Source/WebKit/mac: Missing NSForegroundColorAttributeName should be treated as black instead of transparent. https://bugs.webkit.org/show_bug.cgi?id=76490 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 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. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105291 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebKit/mac/ChangeLog | 18 +++++ Source/WebKit/mac/WebView/WebHTMLView.mm | 2 + Tools/ChangeLog | 14 ++++ .../TestWebKitAPI.xcodeproj/project.pbxproj | 4 ++ Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm | 76 ++++++++++++++++++++++ 5 files changed, 114 insertions(+) create mode 100644 Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm diff --git a/Source/WebKit/mac/ChangeLog b/Source/WebKit/mac/ChangeLog index 37b9208..22a997e 100644 --- a/Source/WebKit/mac/ChangeLog +++ b/Source/WebKit/mac/ChangeLog @@ -1,3 +1,21 @@ +2012-01-17 Enrica Casucci + + Missing NSForegroundColorAttributeName should be treated as black instead of transparent. + https://bugs.webkit.org/show_bug.cgi?id=76490 + + + 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 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. diff --git a/Source/WebKit/mac/WebView/WebHTMLView.mm b/Source/WebKit/mac/WebView/WebHTMLView.mm index 8d400f6..ba362dbb 100644 --- a/Source/WebKit/mac/WebView/WebHTMLView.mm +++ b/Source/WebKit/mac/WebView/WebHTMLView.mm @@ -4602,6 +4602,8 @@ NSStrokeColorAttributeName /* NSColor, default nil: same as foreground co ca = [a objectForKey:NSForegroundColorAttributeName]; cb = [b objectForKey:NSForegroundColorAttributeName]; if (ca == cb) { + if (!ca) + ca = [NSColor blackColor]; [style setColor:[self _colorAsString:ca]]; } diff --git a/Tools/ChangeLog b/Tools/ChangeLog index 3258909..17ac3b3 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,17 @@ +2012-01-17 Enrica Casucci + + Missing NSForegroundColorAttributeName should be treated as black instead of transparent. + https://bugs.webkit.org/show_bug.cgi?id=76490 + + + 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 [Qt] Consolidate layout test crash logging diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj index 3483bec..b1a22d9 100644 --- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj +++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj @@ -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 = ""; }; C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor.mm; sourceTree = ""; }; C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor_Bundle.mm; sourceTree = ""; }; + C507E8A614C6545B005D6B3B /* InspectorBar.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InspectorBar.mm; sourceTree = ""; }; 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 = ""; }; F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateBrowsingPushStateNoHistoryCallback.cpp; sourceTree = ""; }; @@ -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; }; diff --git a/Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm b/Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm new file mode 100644 index 0000000..7e46565 --- /dev/null +++ b/Tools/TestWebKitAPI/Tests/mac/InspectorBar.mm @@ -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 + +@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(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]); + RetainPtr inspectorBarController(AdoptNS, [InspectorBarController new]); + + webView.get().frameLoadDelegate = inspectorBarController.get(); + [webView.get().mainFrame loadHTMLString:@"Lorem ipsum sit amet" 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 -- 2.7.4