Title: [233833] trunk/Source/WebCore
- Revision
- 233833
- Author
- simon.fra...@apple.com
- Date
- 2018-07-13 19:15:49 -0700 (Fri, 13 Jul 2018)
Log Message
Avoid fetching visitedDependentColor() so many times in editing code
https://bugs.webkit.org/show_bug.cgi?id=187676
Reviewed by Zalan Bujtas.
editingAttributedStringFromRange called style.visitedDependentColor() twice for each property,
and fontAttributesForSelectionStart() called it two or three times. Use a local Color variable
to avoid so many calls. Also replace a call to alpha() with isVisible() which makes the usage more clear.
No behavior change.
* editing/cocoa/EditorCocoa.mm:
(WebCore::Editor::fontAttributesForSelectionStart const):
* editing/cocoa/HTMLConverter.mm:
(WebCore::editingAttributedStringFromRange):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (233832 => 233833)
--- trunk/Source/WebCore/ChangeLog 2018-07-14 01:53:50 UTC (rev 233832)
+++ trunk/Source/WebCore/ChangeLog 2018-07-14 02:15:49 UTC (rev 233833)
@@ -1,3 +1,21 @@
+2018-07-13 Simon Fraser <simon.fra...@apple.com>
+
+ Avoid fetching visitedDependentColor() so many times in editing code
+ https://bugs.webkit.org/show_bug.cgi?id=187676
+
+ Reviewed by Zalan Bujtas.
+
+ editingAttributedStringFromRange called style.visitedDependentColor() twice for each property,
+ and fontAttributesForSelectionStart() called it two or three times. Use a local Color variable
+ to avoid so many calls. Also replace a call to alpha() with isVisible() which makes the usage more clear.
+
+ No behavior change.
+
+ * editing/cocoa/EditorCocoa.mm:
+ (WebCore::Editor::fontAttributesForSelectionStart const):
+ * editing/cocoa/HTMLConverter.mm:
+ (WebCore::editingAttributedStringFromRange):
+
2018-07-13 Youenn Fablet <you...@apple.com>
Support connecting a MediaStreamAudioDestinationNode to RTCPeerConnection
Modified: trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm (233832 => 233833)
--- trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm 2018-07-14 01:53:50 UTC (rev 233832)
+++ trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm 2018-07-14 02:15:49 UTC (rev 233833)
@@ -93,11 +93,13 @@
// FIXME: Why would we not want to retrieve these attributes on iOS?
#if PLATFORM(MAC)
- if (style->visitedDependentColor(CSSPropertyBackgroundColor).isVisible())
- [attributes setObject:nsColor(style->visitedDependentColor(CSSPropertyBackgroundColor)) forKey:NSBackgroundColorAttributeName];
+ Color backgroundColor = style->visitedDependentColor(CSSPropertyBackgroundColor);
+ if (backgroundColor.isVisible())
+ [attributes setObject:nsColor(backgroundColor) forKey:NSBackgroundColorAttributeName];
- if (style->visitedDependentColor(CSSPropertyColor).isValid() && !Color::isBlackColor(style->visitedDependentColor(CSSPropertyColor)))
- [attributes setObject:nsColor(style->visitedDependentColor(CSSPropertyColor)) forKey:NSForegroundColorAttributeName];
+ Color foregroundColor = style->visitedDependentColor(CSSPropertyColor);
+ if (foregroundColor.isValid() && !Color::isBlackColor(foregroundColor))
+ [attributes setObject:nsColor(foregroundColor) forKey:NSForegroundColorAttributeName];
const ShadowData* shadowData = style->textShadow();
if (shadowData) {
Modified: trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm (233832 => 233833)
--- trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm 2018-07-14 01:53:50 UTC (rev 233832)
+++ trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm 2018-07-14 02:15:49 UTC (rev 233833)
@@ -2513,12 +2513,16 @@
[attrs.get() setObject:toNSFont(font) forKey:NSFontAttributeName];
else
[attrs.get() setObject:[fontManager convertFont:WebDefaultFont() toSize:style.fontCascade().primaryFont().platformData().size()] forKey:NSFontAttributeName];
- if (style.visitedDependentColor(CSSPropertyColor).alpha())
- [attrs.get() setObject:nsColor(style.visitedDependentColor(CSSPropertyColor)) forKey:NSForegroundColorAttributeName];
+
+ Color foregroundColor = style.visitedDependentColor(CSSPropertyColor);
+ if (foregroundColor.isVisible())
+ [attrs.get() setObject:nsColor(foregroundColor) forKey:NSForegroundColorAttributeName];
else
[attrs.get() removeObjectForKey:NSForegroundColorAttributeName];
- if (style.visitedDependentColor(CSSPropertyBackgroundColor).alpha())
- [attrs.get() setObject:nsColor(style.visitedDependentColor(CSSPropertyBackgroundColor)) forKey:NSBackgroundColorAttributeName];
+
+ Color backgroundColor = style.visitedDependentColor(CSSPropertyBackgroundColor);
+ if (backgroundColor.isVisible())
+ [attrs.get() setObject:nsColor(backgroundColor) forKey:NSBackgroundColorAttributeName];
else
[attrs.get() removeObjectForKey:NSBackgroundColorAttributeName];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes