Diff
Modified: trunk/Source/WebCore/ChangeLog (236444 => 236445)
--- trunk/Source/WebCore/ChangeLog 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/ChangeLog 2018-09-25 00:17:29 UTC (rev 236445)
@@ -1,3 +1,82 @@
+2018-09-24 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Refactor Editor::fontAttributesForSelectionStart to be platform-agnostic
+ https://bugs.webkit.org/show_bug.cgi?id=189918
+ Work towards <rdar://problem/44648705>
+
+ Reviewed by Tim Horton.
+
+ Refactors the functionality in Editor::fontAttributesForSelectionStart to not be Cocoa-only. Rename this to
+ fontAttributesAtSelectionStart (to be consistent with `EditingStyle::styleAtSelectionStart`) and move it from
+ EditorCocoa.mm to Editor.cpp; instead of creating and populating an NSDictionary with font attribute
+ information, create and populate a new `FontAttributes` struct that contains the same information. Cocoa clients
+ in WebKitLegacy may then create an `NSDictionary` as needed from the `FontAttributes`.
+
+ * SourcesCocoa.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * editing/Editor.cpp:
+ (WebCore::Editor::platformFontAttributesAtSelectionStart const):
+
+ Add a hook to allow platforms to supply additional information in FontAttributes. On Cocoa, this adds a UIFont
+ or NSFont to FontAttributes; otherwise, this is a no-op.
+
+ (WebCore::Editor::fontAttributesAtSelectionStart const):
+ * editing/Editor.h:
+ * editing/FontAttributeChanges.cpp:
+ (WebCore::cssValueListForShadow):
+ * editing/FontAttributeChanges.h:
+ (): Deleted.
+ (WebCore::FontShadow::encode const): Deleted.
+ (WebCore::FontShadow::decode): Deleted.
+ * editing/FontAttributes.h: Added.
+
+ Introduce a new struct that contains font attribute information. May be converted into an NSDictionary for use
+ by Cocoa clients in WebKitLegacy and WebKit. In a future patch, this will become serializable over IPC for use
+ in WebKit2.
+
+ * editing/FontShadow.h: Added.
+
+ Move FontShadow out into a separate header file, included in `FontAttributeChanges.h` and `FontAttributes.h`.
+
+ (WebCore::FontShadow::encode const):
+ (WebCore::FontShadow::decode):
+ * editing/cocoa/EditorCocoa.mm:
+
+ Add a helper function to convert a WebCore::Color to either `UIColor` on iOS or `NSColor` when AppKit is being
+ used.
+
+ (WebCore::Editor::platformFontAttributesAtSelectionStart const):
+ (WebCore::Editor::getTextDecorationAttributesRespectingTypingStyle const): Deleted.
+
+ Remove a helper function that was only used to compute text decoration attributes in
+ fontAttributesForSelectionStart.
+
+ (WebCore::Editor::fontAttributesForSelectionStart const): Deleted.
+ * editing/cocoa/FontAttributesCocoa.mm: Added.
+ (WebCore::FontAttributes::createDictionary const):
+ * editing/cocoa/FontShadowCocoa.mm: Added.
+ (WebCore::FontShadow::createShadow const):
+ * editing/cocoa/HTMLConverter.mm:
+ (_webKitBundle):
+ (HTMLConverter::_colorForElement):
+ (_platformColor): Deleted.
+
+ Adopt platformColor().
+
+ * platform/graphics/cocoa/ColorCocoa.h: Added.
+ * platform/graphics/cocoa/ColorCocoa.mm: Added.
+ (WebCore::platformColor):
+ * platform/graphics/metal/GPURenderPassDescriptorMetal.mm:
+
+ Build fix due to changes in unified sources.
+
+ * platform/mac/WebCoreNSFontManagerExtras.mm:
+ (WebCore::computedFontAttributeChanges):
+ * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
+ * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
+
+ More build fixes due to changes in unified sources.
+
2018-09-24 Jer Noble <jer.no...@apple.com>
SharedBuffer should have an equality test
Modified: trunk/Source/WebCore/PAL/ChangeLog (236444 => 236445)
--- trunk/Source/WebCore/PAL/ChangeLog 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/PAL/ChangeLog 2018-09-25 00:17:29 UTC (rev 236445)
@@ -1,3 +1,16 @@
+2018-09-24 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Refactor Editor::fontAttributesForSelectionStart to be platform-agnostic
+ https://bugs.webkit.org/show_bug.cgi?id=189918
+ Work towards <rdar://problem/44648705>
+
+ Reviewed by Tim Horton.
+
+ Add `+_disambiguated_due_to_CIImage_colorWithCGColor:` as a UIColor SPI definition. Also, import
+ `UIColor_Private.h` directly when the Apple internal SDK is used.
+
+ * pal/spi/ios/UIKitSPI.h:
+
2018-09-21 Jer Noble <jer.no...@apple.com>
Unreviewed Sierra Build Fix; ensure AVVideoPerformanceMetrics are defined on Sierra.
Modified: trunk/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h (236444 => 236445)
--- trunk/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h 2018-09-25 00:17:29 UTC (rev 236445)
@@ -27,6 +27,7 @@
#import <UIKit/UIApplicationSceneConstants.h>
#import <UIKit/UIApplication_Private.h>
+#import <UIKit/UIColor_Private.h>
#import <UIKit/UIInterface_Private.h>
#import <UIKit/UIScreen_Private.h>
#import <UIKit/UIViewController_Private.h>
@@ -74,6 +75,8 @@
+ (UIColor *)systemRedColor;
+ (UIColor *)systemYellowColor;
++ (UIColor *)_disambiguated_due_to_CIImage_colorWithCGColor:(CGColorRef)cgColor;
+
@end
@interface UIScreen ()
Modified: trunk/Source/WebCore/SourcesCocoa.txt (236444 => 236445)
--- trunk/Source/WebCore/SourcesCocoa.txt 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2018-09-25 00:17:29 UTC (rev 236445)
@@ -79,6 +79,8 @@
editing/cocoa/DataDetection.mm
editing/cocoa/EditorCocoa.mm
editing/cocoa/FontAttributeChangesCocoa.mm
+editing/cocoa/FontAttributesCocoa.mm
+editing/cocoa/FontShadowCocoa.mm
editing/cocoa/HTMLConverter.mm @no-unify
editing/cocoa/WebArchiveResourceFromNSAttributedString.mm
editing/cocoa/WebArchiveResourceWebResourceHandler.mm
@@ -293,6 +295,7 @@
platform/graphics/cg/TransformationMatrixCG.cpp
platform/graphics/cg/UTIRegistry.cpp
+platform/graphics/cocoa/ColorCocoa.mm
platform/graphics/cocoa/GraphicsContext3DCocoa.mm
platform/graphics/cocoa/GraphicsContextCocoa.mm
platform/graphics/cocoa/FontCacheCoreText.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (236444 => 236445)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-09-25 00:17:29 UTC (rev 236445)
@@ -4843,6 +4843,9 @@
F48223101E3869B80066FC79 /* WebItemProviderPasteboard.mm in Sources */ = {isa = PBXBuildFile; fileRef = F482230E1E3869B80066FC79 /* WebItemProviderPasteboard.mm */; };
F48223111E3869B80066FC79 /* WebItemProviderPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = F482230F1E3869B80066FC79 /* WebItemProviderPasteboard.h */; settings = {ATTRIBUTES = (Private, ); }; };
F48223131E386E240066FC79 /* AbstractPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = F48223121E386E240066FC79 /* AbstractPasteboard.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ F48D2A6C215623B400C6752B /* FontShadow.h in Headers */ = {isa = PBXBuildFile; fileRef = F48D2A6A215623B400C6752B /* FontShadow.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ F48D2A7E2157182600C6752B /* FontAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = F48D2A712156DC0A00C6752B /* FontAttributes.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ F48D2AA52159740D00C6752B /* ColorCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = F48D2AA32159740D00C6752B /* ColorCocoa.h */; };
F49786881FF45FA500E060AB /* PasteboardItemInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = F49786871FF45FA500E060AB /* PasteboardItemInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
F4BFB9851E1DDF9B00862C24 /* DumpEditingHistory.js in Copy Scripts */ = {isa = PBXBuildFile; fileRef = F48389831E1DDF2B0076B7EA /* DumpEditingHistory.js */; };
F4BFB9861E1DDF9B00862C24 /* EditingHistoryUtil.js in Copy Scripts */ = {isa = PBXBuildFile; fileRef = F48389841E1DDF2B0076B7EA /* EditingHistoryUtil.js */; };
@@ -14583,6 +14586,12 @@
F48223121E386E240066FC79 /* AbstractPasteboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractPasteboard.h; sourceTree = "<group>"; };
F48389831E1DDF2B0076B7EA /* DumpEditingHistory.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; name = DumpEditingHistory.js; path = Scripts/DumpEditingHistory.js; sourceTree = "<group>"; };
F48389841E1DDF2B0076B7EA /* EditingHistoryUtil.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; name = EditingHistoryUtil.js; path = Scripts/EditingHistoryUtil.js; sourceTree = "<group>"; };
+ F48D2A6A215623B400C6752B /* FontShadow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontShadow.h; sourceTree = "<group>"; };
+ F48D2A712156DC0A00C6752B /* FontAttributes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontAttributes.h; sourceTree = "<group>"; };
+ F48D2A752156FE5700C6752B /* FontAttributesCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FontAttributesCocoa.mm; sourceTree = "<group>"; };
+ F48D2A7A2157051E00C6752B /* FontShadowCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FontShadowCocoa.mm; sourceTree = "<group>"; };
+ F48D2AA32159740D00C6752B /* ColorCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColorCocoa.h; sourceTree = "<group>"; };
+ F48D2AA42159740D00C6752B /* ColorCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ColorCocoa.mm; sourceTree = "<group>"; };
F49786871FF45FA500E060AB /* PasteboardItemInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PasteboardItemInfo.h; sourceTree = "<group>"; };
F4E57EDA213F3F5F004EA98E /* FontAttributeChanges.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontAttributeChanges.h; sourceTree = "<group>"; };
F4E57EDF213F434A004EA98E /* WebCoreNSFontManagerExtras.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCoreNSFontManagerExtras.h; sourceTree = "<group>"; };
@@ -19941,6 +19950,8 @@
C5227DF01C3C6DD700F5ED54 /* DataDetection.mm */,
9B55EEE81B3E8898005342BC /* EditorCocoa.mm */,
F42CEB54214031EE002DCA72 /* FontAttributeChangesCocoa.mm */,
+ F48D2A752156FE5700C6752B /* FontAttributesCocoa.mm */,
+ F48D2A7A2157051E00C6752B /* FontShadowCocoa.mm */,
7C3E510818DF8F3500C112F7 /* HTMLConverter.h */,
7C3E510918DF8F3500C112F7 /* HTMLConverter.mm */,
E18536811F4E472700FE091B /* WebArchiveResourceFromNSAttributedString.h */,
@@ -20245,6 +20256,8 @@
372C00D8129619F8005C9575 /* FindOptions.h */,
F442850B2140412500CCDA22 /* FontAttributeChanges.cpp */,
F4E57EDA213F3F5F004EA98E /* FontAttributeChanges.h */,
+ F48D2A712156DC0A00C6752B /* FontAttributes.h */,
+ F48D2A6A215623B400C6752B /* FontShadow.h */,
D05CED270A40BB2C00C5AF38 /* FormatBlockCommand.cpp */,
D05CED280A40BB2C00C5AF38 /* FormatBlockCommand.h */,
93309DBE099E64910056E581 /* FrameSelection.cpp */,
@@ -23945,6 +23958,8 @@
B5320D68122A24E9002D1440 /* cocoa */ = {
isa = PBXGroup;
children = (
+ F48D2AA32159740D00C6752B /* ColorCocoa.h */,
+ F48D2AA42159740D00C6752B /* ColorCocoa.mm */,
1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */,
C2458E611FE8979E00594759 /* FontCacheCoreText.h */,
B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */,
@@ -27466,6 +27481,7 @@
B27535670B053814002CE64F /* Color.h in Headers */,
C330A22313EC196B0000B45B /* ColorChooser.h in Headers */,
C37CDEBD149EF2030042090D /* ColorChooserClient.h in Headers */,
+ F48D2AA52159740D00C6752B /* ColorCocoa.h in Headers */,
3103B7DF1DB01567008BB890 /* ColorHash.h in Headers */,
F55B3DB41251F12D003EF269 /* ColorInputType.h in Headers */,
EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */,
@@ -28064,6 +28080,7 @@
B2C3DA650D006CD600EF6F26 /* Font.h in Headers */,
1AC2D89D1B1E291F00D52E87 /* FontAntialiasingStateSaver.h in Headers */,
F4E57EDC213F3F5F004EA98E /* FontAttributeChanges.h in Headers */,
+ F48D2A7E2157182600C6752B /* FontAttributes.h in Headers */,
BCB92D4F1293550B00C8387F /* FontBaseline.h in Headers */,
B2C3DA630D006CD600EF6F26 /* FontCache.h in Headers */,
C2458E631FE897B000594759 /* FontCacheCoreText.h in Headers */,
@@ -28080,6 +28097,7 @@
C2AB0AF71E6B3C6C001348C5 /* FontSelectionAlgorithm.h in Headers */,
B2C3DA6B0D006CD600EF6F26 /* FontSelector.h in Headers */,
E419041F1CC6486B00C35F5D /* FontSelectorClient.h in Headers */,
+ F48D2A6C215623B400C6752B /* FontShadow.h in Headers */,
4A6E9FC813C17D570046A7F8 /* FontTaggedSettings.h in Headers */,
C2015C0A1BE6FEB200822389 /* FontVariantBuilder.h in Headers */,
4A0DA2FF129B241900AB61E1 /* FormAssociatedElement.h in Headers */,
Modified: trunk/Source/WebCore/editing/Editor.cpp (236444 => 236445)
--- trunk/Source/WebCore/editing/Editor.cpp 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/editing/Editor.cpp 2018-09-25 00:17:29 UTC (rev 236445)
@@ -48,6 +48,7 @@
#include "EventNames.h"
#include "File.h"
#include "FocusController.h"
+#include "FontAttributes.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameTree.h"
@@ -3851,6 +3852,83 @@
m_editorUIUpdateTimer.startOneShot(0_s);
}
+#if !PLATFORM(COCOA)
+
+void Editor::platformFontAttributesAtSelectionStart(FontAttributes&, const RenderStyle&) const
+{
+}
+
+#endif
+
+FontAttributes Editor::fontAttributesAtSelectionStart() const
+{
+ FontAttributes attributes;
+ Node* nodeToRemove = nullptr;
+ auto* style = styleForSelectionStart(&m_frame, nodeToRemove);
+ if (!style) {
+ if (nodeToRemove)
+ nodeToRemove->remove();
+ return attributes;
+ }
+
+ platformFontAttributesAtSelectionStart(attributes, *style);
+
+ // FIXME: for now, always report the colors after applying -apple-color-filter. In future not all clients
+ // may want this, so we may have to add a setting to control it. See also editingAttributedStringFromRange().
+ auto backgroundColor = style->visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor);
+ if (backgroundColor.isVisible())
+ attributes.backgroundColor = backgroundColor;
+
+ auto foregroundColor = style->visitedDependentColorWithColorFilter(CSSPropertyColor);
+ // FIXME: isBlackColor not suitable for dark mode.
+ if (foregroundColor.isValid() && !Color::isBlackColor(foregroundColor))
+ attributes.foregroundColor = foregroundColor;
+
+ if (auto* shadowData = style->textShadow())
+ attributes.fontShadow = { shadowData->color(), { static_cast<float>(shadowData->x()), static_cast<float>(shadowData->y()) }, static_cast<double>(shadowData->radius()) };
+
+ switch (style->verticalAlign()) {
+ case VerticalAlign::Baseline:
+ case VerticalAlign::Bottom:
+ case VerticalAlign::BaselineMiddle:
+ case VerticalAlign::Length:
+ case VerticalAlign::Middle:
+ case VerticalAlign::TextBottom:
+ case VerticalAlign::TextTop:
+ case VerticalAlign::Top:
+ break;
+ case VerticalAlign::Sub:
+ attributes.subscriptOrSuperscript = SubscriptOrSuperscript::Subscript;
+ break;
+ case VerticalAlign::Super:
+ attributes.subscriptOrSuperscript = SubscriptOrSuperscript::Superscript;
+ break;
+ }
+
+ auto typingStyle = makeRefPtr(m_frame.selection().typingStyle());
+ if (typingStyle && typingStyle->style()) {
+ auto value = typingStyle->style()->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
+ if (value && value->isValueList()) {
+ CSSValueList& valueList = downcast<CSSValueList>(*value);
+ if (valueList.hasValue(CSSValuePool::singleton().createIdentifierValue(CSSValueLineThrough).ptr()))
+ attributes.hasStrikeThrough = true;
+ if (valueList.hasValue(CSSValuePool::singleton().createIdentifierValue(CSSValueUnderline).ptr()))
+ attributes.hasUnderline = true;
+ }
+ } else {
+ auto decoration = style->textDecorationsInEffect();
+ if (decoration & TextDecoration::LineThrough)
+ attributes.hasStrikeThrough = true;
+ if (decoration & TextDecoration::Underline)
+ attributes.hasUnderline = true;
+ }
+
+ if (nodeToRemove)
+ nodeToRemove->remove();
+
+ return attributes;
+}
+
#if ENABLE(ATTACHMENT_ELEMENT)
void Editor::registerAttachmentIdentifier(const String& identifier, const String& contentType, const String& preferredFileName, Ref<SharedBuffer>&& data)
Modified: trunk/Source/WebCore/editing/Editor.h (236444 => 236445)
--- trunk/Source/WebCore/editing/Editor.h 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/editing/Editor.h 2018-09-25 00:17:29 UTC (rev 236445)
@@ -81,6 +81,7 @@
class TextCheckerClient;
class TextEvent;
+struct FontAttributes;
struct PasteboardPlainText;
struct PasteboardURL;
struct TextCheckingResult;
@@ -469,10 +470,9 @@
WEBCORE_EXPORT const Font* fontForSelection(bool& hasMultipleFonts) const;
WEBCORE_EXPORT static const RenderStyle* styleForSelectionStart(Frame* , Node *&nodeToRemove);
+ WEBCORE_EXPORT FontAttributes fontAttributesAtSelectionStart() const;
#if PLATFORM(COCOA)
- void getTextDecorationAttributesRespectingTypingStyle(const RenderStyle&, NSMutableDictionary*) const;
- WEBCORE_EXPORT RetainPtr<NSDictionary> fontAttributesForSelectionStart() const;
WEBCORE_EXPORT String stringSelectionForPasteboard();
String stringSelectionForPasteboardWithImageAltText();
#if !PLATFORM(IOS)
@@ -562,6 +562,7 @@
static RefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *);
static RefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *);
#endif
+ void platformFontAttributesAtSelectionStart(FontAttributes&, const RenderStyle&) const;
void scheduleEditorUIUpdate();
Modified: trunk/Source/WebCore/editing/FontAttributeChanges.cpp (236444 => 236445)
--- trunk/Source/WebCore/editing/FontAttributeChanges.cpp 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/editing/FontAttributeChanges.cpp 2018-09-25 00:17:29 UTC (rev 236445)
@@ -81,13 +81,13 @@
static RefPtr<CSSValueList> cssValueListForShadow(const FontShadow& shadow)
{
- if (!shadow.width && !shadow.height && !shadow.blurRadius)
+ if (shadow.offset.isEmpty() && !shadow.blurRadius)
return nullptr;
auto list = CSSValueList::createCommaSeparated();
auto& cssValuePool = CSSValuePool::singleton();
- auto width = cssValuePool.createValue(shadow.width, CSSPrimitiveValue::CSS_PX);
- auto height = cssValuePool.createValue(shadow.height, CSSPrimitiveValue::CSS_PX);
+ auto width = cssValuePool.createValue(shadow.offset.width(), CSSPrimitiveValue::CSS_PX);
+ auto height = cssValuePool.createValue(shadow.offset.height(), CSSPrimitiveValue::CSS_PX);
auto blurRadius = cssValuePool.createValue(shadow.blurRadius, CSSPrimitiveValue::CSS_PX);
auto color = cssValuePool.createValue(shadow.color);
list->prepend(CSSShadowValue::create(WTFMove(width), WTFMove(height), WTFMove(blurRadius), { }, { }, WTFMove(color)));
Modified: trunk/Source/WebCore/editing/FontAttributeChanges.h (236444 => 236445)
--- trunk/Source/WebCore/editing/FontAttributeChanges.h 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/editing/FontAttributeChanges.h 2018-09-25 00:17:29 UTC (rev 236445)
@@ -26,6 +26,7 @@
#pragma once
#include "Color.h"
+#include "FontShadow.h"
#include <wtf/EnumTraits.h>
#include <wtf/Forward.h>
#include <wtf/Optional.h>
@@ -69,16 +70,6 @@
std::optional<bool> m_italic;
};
-struct FontShadow {
- template<class Encoder> void encode(Encoder&) const;
- template<class Decoder> static bool decode(Decoder&, FontShadow&);
-
- Color color;
- double width { 0 };
- double height { 0 };
- double blurRadius { 0 };
-};
-
class FontAttributeChanges {
public:
template<class Encoder> void encode(Encoder&) const;
@@ -138,30 +129,6 @@
}
template<class Encoder>
-void FontShadow::encode(Encoder& encoder) const
-{
- encoder << color << width << height << blurRadius;
-}
-
-template<class Decoder>
-bool FontShadow::decode(Decoder& decoder, FontShadow& shadow)
-{
- if (!decoder.decode(shadow.color))
- return false;
-
- if (!decoder.decode(shadow.width))
- return false;
-
- if (!decoder.decode(shadow.height))
- return false;
-
- if (!decoder.decode(shadow.blurRadius))
- return false;
-
- return true;
-}
-
-template<class Encoder>
void FontAttributeChanges::encode(Encoder& encoder) const
{
encoder << m_verticalAlign << m_backgroundColor << m_foregroundColor << m_shadow << m_strikeThrough << m_underline << m_fontChanges;
Added: trunk/Source/WebCore/editing/FontAttributes.h (0 => 236445)
--- trunk/Source/WebCore/editing/FontAttributes.h (rev 0)
+++ trunk/Source/WebCore/editing/FontAttributes.h 2018-09-25 00:17:29 UTC (rev 236445)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#pragma once
+
+#include "FontShadow.h"
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS NSDictionary;
+OBJC_CLASS NSFont;
+OBJC_CLASS UIFont;
+
+namespace WebCore {
+
+enum class SubscriptOrSuperscript : uint8_t { None, Subscript, Superscript };
+
+struct FontAttributes {
+#if PLATFORM(COCOA)
+ WEBCORE_EXPORT RetainPtr<NSDictionary> createDictionary() const;
+#endif
+
+#if PLATFORM(MAC)
+ RetainPtr<NSFont> font;
+#elif PLATFORM(IOS)
+ RetainPtr<UIFont> font;
+#endif
+ Color backgroundColor;
+ Color foregroundColor;
+ FontShadow fontShadow;
+ SubscriptOrSuperscript subscriptOrSuperscript { SubscriptOrSuperscript::None };
+ bool hasUnderline { false };
+ bool hasStrikeThrough { false };
+};
+
+} // namespace WebCore
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::SubscriptOrSuperscript> {
+ using values = EnumValues<
+ WebCore::SubscriptOrSuperscript,
+ WebCore::SubscriptOrSuperscript::None,
+ WebCore::SubscriptOrSuperscript::Subscript,
+ WebCore::SubscriptOrSuperscript::Superscript
+ >;
+};
+
+} // namespace WTF
Added: trunk/Source/WebCore/editing/FontShadow.h (0 => 236445)
--- trunk/Source/WebCore/editing/FontShadow.h (rev 0)
+++ trunk/Source/WebCore/editing/FontShadow.h 2018-09-25 00:17:29 UTC (rev 236445)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#pragma once
+
+#include "Color.h"
+#include "FloatSize.h"
+#include <wtf/RetainPtr.h>
+
+#if PLATFORM(COCOA)
+OBJC_CLASS NSShadow;
+#endif
+
+namespace WebCore {
+
+struct FontShadow {
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static bool decode(Decoder&, FontShadow&);
+
+#if PLATFORM(COCOA)
+ RetainPtr<NSShadow> createShadow() const;
+#endif
+
+ Color color;
+ FloatSize offset;
+ double blurRadius { 0 };
+};
+
+template<class Encoder>
+void FontShadow::encode(Encoder& encoder) const
+{
+ encoder << color << offset << blurRadius;
+}
+
+template<class Decoder>
+bool FontShadow::decode(Decoder& decoder, FontShadow& shadow)
+{
+ if (!decoder.decode(shadow.color))
+ return false;
+
+ if (!decoder.decode(shadow.offset))
+ return false;
+
+ if (!decoder.decode(shadow.blurRadius))
+ return false;
+
+ return true;
+}
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm (236444 => 236445)
--- trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm 2018-09-25 00:17:29 UTC (rev 236445)
@@ -36,6 +36,7 @@
#import "Editing.h"
#import "EditingStyle.h"
#import "EditorClient.h"
+#import "FontAttributes.h"
#import "FontCascade.h"
#import "Frame.h"
#import "FrameLoader.h"
@@ -58,91 +59,12 @@
namespace WebCore {
-void Editor::getTextDecorationAttributesRespectingTypingStyle(const RenderStyle& style, NSMutableDictionary* result) const
+void Editor::platformFontAttributesAtSelectionStart(FontAttributes& attributes, const RenderStyle& style) const
{
- RefPtr<EditingStyle> typingStyle = m_frame.selection().typingStyle();
- if (typingStyle && typingStyle->style()) {
- RefPtr<CSSValue> value = typingStyle->style()->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
- if (value && value->isValueList()) {
- CSSValueList& valueList = downcast<CSSValueList>(*value);
- if (valueList.hasValue(CSSValuePool::singleton().createIdentifierValue(CSSValueLineThrough).ptr()))
- [result setObject:@(NSUnderlineStyleSingle) forKey:NSStrikethroughStyleAttributeName];
- if (valueList.hasValue(CSSValuePool::singleton().createIdentifierValue(CSSValueUnderline).ptr()))
- [result setObject:@(NSUnderlineStyleSingle) forKey:NSUnderlineStyleAttributeName];
- }
- } else {
- auto decoration = style.textDecorationsInEffect();
- if (decoration & TextDecoration::LineThrough)
- [result setObject:@(NSUnderlineStyleSingle) forKey:NSStrikethroughStyleAttributeName];
- if (decoration & TextDecoration::Underline)
- [result setObject:@(NSUnderlineStyleSingle) forKey:NSUnderlineStyleAttributeName];
- }
+ if (auto ctFont = style.fontCascade().primaryFont().getCTFont())
+ attributes.font = (__bridge id)ctFont;
}
-RetainPtr<NSDictionary> Editor::fontAttributesForSelectionStart() const
-{
- Node* nodeToRemove;
- auto* style = styleForSelectionStart(&m_frame, nodeToRemove);
- if (!style)
- return nil;
-
- RetainPtr<NSMutableDictionary> attributes = adoptNS([[NSMutableDictionary alloc] init]);
-
- if (auto ctFont = style->fontCascade().primaryFont().getCTFont())
- [attributes setObject:(__bridge id)ctFont forKey:NSFontAttributeName];
-
- // FIXME: Why would we not want to retrieve these attributes on iOS?
-#if PLATFORM(MAC)
- // FIXME: for now, always report the colors after applying -apple-color-filter. In future not all clients
- // may want this, so we may have to add a setting to control it. See also editingAttributedStringFromRange().
- Color backgroundColor = style->visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor);
- if (backgroundColor.isVisible())
- [attributes setObject:nsColor(backgroundColor) forKey:NSBackgroundColorAttributeName];
-
- Color foregroundColor = style->visitedDependentColorWithColorFilter(CSSPropertyColor);
- // FIXME: isBlackColor not suitable for dark mode.
- if (foregroundColor.isValid() && !Color::isBlackColor(foregroundColor))
- [attributes setObject:nsColor(foregroundColor) forKey:NSForegroundColorAttributeName];
-
- const ShadowData* shadowData = style->textShadow();
- if (shadowData) {
- RetainPtr<NSShadow> platformShadow = adoptNS([[NSShadow alloc] init]);
- [platformShadow setShadowOffset:NSMakeSize(shadowData->x(), shadowData->y())];
- [platformShadow setShadowBlurRadius:shadowData->radius()];
- [platformShadow setShadowColor:nsColor(shadowData->color())];
- [attributes setObject:platformShadow.get() forKey:NSShadowAttributeName];
- }
-
- int superscriptInt = 0;
- switch (style->verticalAlign()) {
- case VerticalAlign::Baseline:
- case VerticalAlign::Bottom:
- case VerticalAlign::BaselineMiddle:
- case VerticalAlign::Length:
- case VerticalAlign::Middle:
- case VerticalAlign::TextBottom:
- case VerticalAlign::TextTop:
- case VerticalAlign::Top:
- break;
- case VerticalAlign::Sub:
- superscriptInt = -1;
- break;
- case VerticalAlign::Super:
- superscriptInt = 1;
- break;
- }
- if (superscriptInt)
- [attributes setObject:@(superscriptInt) forKey:NSSuperscriptAttributeName];
-#endif
-
- getTextDecorationAttributesRespectingTypingStyle(*style, attributes.get());
-
- if (nodeToRemove)
- nodeToRemove->remove();
-
- return attributes;
-}
-
static RefPtr<SharedBuffer> archivedDataForAttributedString(NSAttributedString *attributedString)
{
if (!attributedString.length)
Added: trunk/Source/WebCore/editing/cocoa/FontAttributesCocoa.mm (0 => 236445)
--- trunk/Source/WebCore/editing/cocoa/FontAttributesCocoa.mm (rev 0)
+++ trunk/Source/WebCore/editing/cocoa/FontAttributesCocoa.mm 2018-09-25 00:17:29 UTC (rev 236445)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2018 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 "FontAttributes.h"
+
+#import "ColorCocoa.h"
+#import <wtf/SoftLinking.h>
+
+namespace WebCore {
+
+RetainPtr<NSDictionary> FontAttributes::createDictionary() const
+{
+ NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
+ if (font)
+ attributes[NSFontAttributeName] = font.get();
+
+ if (foregroundColor.isValid())
+ attributes[NSForegroundColorAttributeName] = platformColor(foregroundColor);
+
+ if (backgroundColor.isValid())
+ attributes[NSBackgroundColorAttributeName] = platformColor(backgroundColor);
+
+ if (fontShadow.color.isValid() && (!fontShadow.offset.isEmpty() || fontShadow.blurRadius)) {
+ auto shadow = fontShadow.createShadow();
+ attributes[NSShadowAttributeName] = shadow.get();
+ }
+
+ if (subscriptOrSuperscript == SubscriptOrSuperscript::Subscript)
+ attributes[NSSuperscriptAttributeName] = @(-1);
+ else if (subscriptOrSuperscript == SubscriptOrSuperscript::Superscript)
+ attributes[NSSuperscriptAttributeName] = @1;
+
+ if (hasUnderline)
+ attributes[NSUnderlineStyleAttributeName] = @(NSUnderlineStyleSingle);
+
+ if (hasStrikeThrough)
+ attributes[NSStrikethroughStyleAttributeName] = @(NSUnderlineStyleSingle);
+
+ return attributes;
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/editing/cocoa/FontShadowCocoa.mm (0 => 236445)
--- trunk/Source/WebCore/editing/cocoa/FontShadowCocoa.mm (rev 0)
+++ trunk/Source/WebCore/editing/cocoa/FontShadowCocoa.mm 2018-09-25 00:17:29 UTC (rev 236445)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2018 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 "FontShadow.h"
+
+#import "ColorCocoa.h"
+#import "ColorMac.h"
+
+#if PLATFORM(IOS)
+SOFT_LINK_FRAMEWORK_FOR_SOURCE(WebCore, UIKit)
+SOFT_LINK_CLASS_FOR_SOURCE(WebCore, UIKit, NSShadow)
+#endif
+
+namespace WebCore {
+
+RetainPtr<NSShadow> FontShadow::createShadow() const
+{
+#if USE(APPKIT)
+ auto shadow = adoptNS([NSShadow new]);
+#elif PLATFORM(IOS)
+ auto shadow = adoptNS([get_UIKit_NSShadowClass() new]);
+#endif
+ [shadow setShadowColor:platformColor(color)];
+ [shadow setShadowOffset:offset];
+ [shadow setShadowBlurRadius:blurRadius];
+ return shadow;
+}
+
+}
Modified: trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm (236444 => 236445)
--- trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm 2018-09-25 00:17:29 UTC (rev 236445)
@@ -32,6 +32,7 @@
#import "CSSPrimitiveValue.h"
#import "CachedImage.h"
#import "CharacterData.h"
+#import "ColorCocoa.h"
#import "ColorMac.h"
#import "Document.h"
#import "DocumentLoader.h"
@@ -205,7 +206,6 @@
@interface UIColor : NSObject
+ (UIColor *)clearColor;
- (CGFloat)alphaComponent;
-+ (UIColor *)_disambiguated_due_to_CIImage_colorWithCGColor:(CGColorRef)cgColor;
@end
@interface NSColor : UIColor
@@ -863,16 +863,6 @@
bundle = [NSBundle bundleWithPath:[_NSSystemLibraryPath() stringByAppendingPathComponent:@"Frameworks/WebKit.framework"]];
return bundle;
}
-
-static inline UIColor *_platformColor(Color color)
-{
- return [getUIColorClass() _disambiguated_due_to_CIImage_colorWithCGColor:cachedCGColor(color)];
-}
-#else
-static inline NSColor *_platformColor(Color color)
-{
- return nsColor(color);
-}
#endif
static inline NSShadow *_shadowForShadowStyle(NSString *shadowStyle)
@@ -1020,7 +1010,7 @@
Color result = _caches->colorPropertyValueForNode(element, propertyId);
if (!result.isValid())
return nil;
- PlatformColor *platformResult = _platformColor(result);
+ PlatformColor *platformResult = platformColor(result);
if ([[PlatformColorClass clearColor] isEqual:platformResult] || ([platformResult alphaComponent] == 0.0))
return nil;
return platformResult;
Added: trunk/Source/WebCore/platform/graphics/cocoa/ColorCocoa.h (0 => 236445)
--- trunk/Source/WebCore/platform/graphics/cocoa/ColorCocoa.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/ColorCocoa.h 2018-09-25 00:17:29 UTC (rev 236445)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#pragma once
+
+OBJC_CLASS NSColor;
+OBJC_CLASS UIColor;
+
+namespace WebCore {
+
+class Color;
+
+#if USE(APPKIT)
+NSColor *platformColor(const Color&);
+#endif
+
+#if PLATFORM(IOS)
+UIColor *platformColor(const Color&);
+#endif
+
+} // namespace WebCore
Added: trunk/Source/WebCore/platform/graphics/cocoa/ColorCocoa.mm (0 => 236445)
--- trunk/Source/WebCore/platform/graphics/cocoa/ColorCocoa.mm (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/ColorCocoa.mm 2018-09-25 00:17:29 UTC (rev 236445)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2018 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 "ColorCocoa.h"
+
+#import "ColorMac.h"
+#import <wtf/SoftLinking.h>
+
+#if PLATFORM(IOS)
+#import <pal/spi/ios/UIKitSPI.h>
+
+SOFT_LINK_FRAMEWORK_FOR_SOURCE(WebCore, UIKit)
+SOFT_LINK_CLASS_FOR_SOURCE(WebCore, UIKit, UIColor)
+#endif
+
+namespace WebCore {
+
+#if USE(APPKIT)
+
+NSColor *platformColor(const Color& color)
+{
+ return nsColor(color);
+}
+
+#endif
+
+#if PLATFORM(IOS)
+
+UIColor *platformColor(const Color& color)
+{
+ return [get_UIKit_UIColorClass() _disambiguated_due_to_CIImage_colorWithCGColor:cachedCGColor(color)];
+}
+
+#endif
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/metal/GPURenderPassDescriptorMetal.mm (236444 => 236445)
--- trunk/Source/WebCore/platform/graphics/metal/GPURenderPassDescriptorMetal.mm 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/platform/graphics/metal/GPURenderPassDescriptorMetal.mm 2018-09-25 00:17:29 UTC (rev 236445)
@@ -32,6 +32,7 @@
#import "GPURenderPassDepthAttachmentDescriptor.h"
#import "Logging.h"
#import <Metal/Metal.h>
+#import <wtf/Vector.h>
namespace WebCore {
Modified: trunk/Source/WebCore/platform/mac/WebCoreNSFontManagerExtras.mm (236444 => 236445)
--- trunk/Source/WebCore/platform/mac/WebCoreNSFontManagerExtras.mm 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/platform/mac/WebCoreNSFontManagerExtras.mm 2018-09-25 00:17:29 UTC (rev 236445)
@@ -136,8 +136,8 @@
NSShadow *convertedShadow = [convertedAttributesA objectForKey:NSShadowAttributeName];
if (convertedShadow) {
- auto offset = convertedShadow.shadowOffset;
- changes.setShadow({ colorFromNSColor(convertedShadow.shadowColor ?: NSColor.blackColor), offset.width, offset.height, convertedShadow.shadowBlurRadius });
+ FloatSize offset { static_cast<float>(convertedShadow.shadowOffset.width), static_cast<float>(convertedShadow.shadowOffset.height) };
+ changes.setShadow({ colorFromNSColor(convertedShadow.shadowColor ?: NSColor.blackColor), offset, convertedShadow.shadowBlurRadius });
} else if (![convertedAttributesB objectForKey:NSShadowAttributeName])
changes.setShadow({ });
Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h (236444 => 236445)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h 2018-09-25 00:17:29 UTC (rev 236445)
@@ -32,6 +32,7 @@
#include "RealtimeIncomingVideoSource.h"
using CMSampleBufferRef = struct opaqueCMSampleBuffer*;
+using CVPixelBufferPoolRef = struct __CVPixelBufferPool*;
using CVPixelBufferRef = struct __CVBuffer*;
namespace WebCore {
Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm (236444 => 236445)
--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm 2018-09-25 00:17:29 UTC (rev 236445)
@@ -32,6 +32,7 @@
#include "Logging.h"
#include "MediaSampleAVFObjC.h"
+#include "RealtimeVideoUtilities.h"
#include <pal/cf/CoreMediaSoftLink.h>
ALLOW_UNUSED_PARAMETERS_BEGIN
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (236444 => 236445)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2018-09-25 00:17:29 UTC (rev 236445)
@@ -1,3 +1,19 @@
+2018-09-24 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Refactor Editor::fontAttributesForSelectionStart to be platform-agnostic
+ https://bugs.webkit.org/show_bug.cgi?id=189918
+ Work towards <rdar://problem/44648705>
+
+ Reviewed by Tim Horton.
+
+ Replace call sites of fontAttributesForSelectionStart() to fontAttributesAtSelectionStart().createDictionary().
+
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView _selectionStartFontAttributesAsRTF]):
+ (-[WebHTMLView _updateFontPanel]):
+ * WebView/WebView.mm:
+ (-[WebView typingAttributes]):
+
2018-09-17 Darin Adler <da...@apple.com>
Use OpaqueJSString rather than JSRetainPtr inside WebKit
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm (236444 => 236445)
--- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm 2018-09-25 00:17:29 UTC (rev 236445)
@@ -96,6 +96,7 @@
#import <WebCore/FocusController.h>
#import <WebCore/Font.h>
#import <WebCore/FontAttributeChanges.h>
+#import <WebCore/FontAttributes.h>
#import <WebCore/FontCache.h>
#import <WebCore/Frame.h>
#import <WebCore/FrameLoader.h>
@@ -5057,7 +5058,7 @@
{
Frame* coreFrame = core([self _frame]);
auto string = adoptNS([[NSAttributedString alloc] initWithString:@"x"
- attributes:coreFrame ? coreFrame->editor().fontAttributesForSelectionStart().get() : nil]);
+ attributes:coreFrame ? coreFrame->editor().fontAttributesAtSelectionStart().createDictionary().get() : nil]);
return [string RTFFromRange:NSMakeRange(0, [string length]) documentAttributes:@{ }];
}
@@ -5704,7 +5705,7 @@
if (Frame* coreFrame = core([self _frame])) {
if (const Font* fd = coreFrame->editor().fontForSelection(multipleFonts))
font = (NSFont *)fd->platformData().registeredFont();
- attributes = coreFrame->editor().fontAttributesForSelectionStart();
+ attributes = coreFrame->editor().fontAttributesAtSelectionStart().createDictionary();
}
// FIXME: for now, return a bogus font that distinguishes the empty selection from the non-empty
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (236444 => 236445)
--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2018-09-25 00:05:32 UTC (rev 236444)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2018-09-25 00:17:29 UTC (rev 236445)
@@ -144,6 +144,7 @@
#import <WebCore/EventHandler.h>
#import <WebCore/FileSystem.h>
#import <WebCore/FocusController.h>
+#import <WebCore/FontAttributes.h>
#import <WebCore/FontCache.h>
#import <WebCore/Frame.h>
#import <WebCore/FrameLoader.h>
@@ -8623,9 +8624,8 @@
- (NSDictionary *)typingAttributes
{
- Frame* coreFrame = core([self _selectedOrMainFrame]);
- if (coreFrame)
- return coreFrame->editor().fontAttributesForSelectionStart().autorelease();
+ if (auto* coreFrame = core([self _selectedOrMainFrame]))
+ return coreFrame->editor().fontAttributesAtSelectionStart().createDictionary().autorelease();
return nil;
}