Changeset 223012 in webkit


Ignore:
Timestamp:
Oct 6, 2017 5:09:48 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Source/WebKit:
[iOS] Respect the "caret-color" CSS property when editing
https://bugs.webkit.org/show_bug.cgi?id=177489
<rdar://problem/34600419>

Patch by Aishwarya Nirmal <anirmal@apple.com> on 2017-10-06
Reviewed by Tim Horton.

This change adds support for the caret-color property on iOS.

  • Shared/EditorState.cpp:

(WebKit::EditorState::PostLayoutData::encode const):
(WebKit::EditorState::PostLayoutData::decode):

  • Shared/EditorState.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView insertionPointColor]):

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::platformEditorState const):

Tools:
[iOS] Respect the "caret-color" CSS property when editing
https://bugs.webkit.org/show_bug.cgi?id=177489
<rdar://problem/34600419>

Patch by Aishwarya Nirmal <anirmal@apple.com> on 2017-10-06
Reviewed by Tim Horton.

Adds test for iOS caret color support.

  • TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm:

(TestWebKitAPI::TEST):

  • TestWebKitAPI/ios/UIKitSPI.h:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r223007 r223012  
     12017-10-06  Aishwarya Nirmal  <anirmal@apple.com>
     2
     3        [iOS] Respect the "caret-color" CSS property when editing
     4        https://bugs.webkit.org/show_bug.cgi?id=177489
     5        <rdar://problem/34600419>
     6
     7        Reviewed by Tim Horton.
     8
     9        This change adds support for the caret-color property on iOS.
     10
     11        * Shared/EditorState.cpp:
     12        (WebKit::EditorState::PostLayoutData::encode const):
     13        (WebKit::EditorState::PostLayoutData::decode):
     14        * Shared/EditorState.h:
     15        * UIProcess/ios/WKContentViewInteraction.mm:
     16        (-[WKContentView insertionPointColor]):
     17        * WebProcess/WebPage/ios/WebPageIOS.mm:
     18        (WebKit::WebPage::platformEditorState const):
     19
    1202017-10-06  Brian Burg  <bburg@apple.com>
    221
  • trunk/Source/WebKit/Shared/EditorState.cpp

    r222654 r223012  
    129129    encoder << insideFixedPosition;
    130130    encoder << hasPlainText;
     131    encoder << caretColor;
    131132#endif
    132133#if PLATFORM(MAC)
     
    180181    if (!decoder.decode(result.hasPlainText))
    181182        return false;
     183    if (!decoder.decode(result.caretColor))
     184        return false;
    182185#endif
    183186#if PLATFORM(MAC)
  • trunk/Source/WebKit/Shared/EditorState.h

    r222654 r223012  
    103103        bool insideFixedPosition { false };
    104104        bool hasPlainText { false };
     105        WebCore::Color caretColor;
    105106#endif
    106107#if PLATFORM(MAC)
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r222991 r223012  
    20262026- (UIColor *)insertionPointColor
    20272027{
     2028    if (!_page->editorState().isMissingPostLayoutData) {
     2029        WebCore::Color caretColor = _page->editorState().postLayoutData().caretColor;
     2030        if (caretColor.isValid())
     2031            return [UIColor colorWithCGColor:cachedCGColor(caretColor)];
     2032    }
    20282033    return [UIColor insertionPointColor];
    20292034}
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r222896 r223012  
    229229    postLayoutData.insideFixedPosition = startNodeIsInsideFixedPosition || endNodeIsInsideFixedPosition;
    230230    if (!selection.isNone()) {
    231         if (m_assistedNode && m_assistedNode->renderer())
     231        if (m_assistedNode && m_assistedNode->renderer()) {
    232232            postLayoutData.selectionClipRect = view->contentsToRootView(m_assistedNode->renderer()->absoluteBoundingBoxRect());
     233            postLayoutData.caretColor = m_assistedNode->renderer()->style().caretColor();
     234        }
    233235        computeEditableRootHasContentAndPlainText(selection, postLayoutData);
    234236    }
  • trunk/Tools/ChangeLog

    r223001 r223012  
     12017-10-06  Aishwarya Nirmal  <anirmal@apple.com>
     2
     3        [iOS] Respect the "caret-color" CSS property when editing
     4        https://bugs.webkit.org/show_bug.cgi?id=177489
     5        <rdar://problem/34600419>
     6
     7        Reviewed by Tim Horton.
     8
     9        Adds test for iOS caret color support.
     10
     11        * TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm:
     12        (TestWebKitAPI::TEST):
     13        * TestWebKitAPI/ios/UIKitSPI.h:
     14
    1152017-10-06  Alex Christensen  <achristensen@webkit.org>
    216
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm

    r222654 r223012  
    3434
    3535#if PLATFORM(IOS)
     36#import "UIKitSPI.h"
    3637#import <UIKit/UIKit.h>
    3738#endif
     
    299300}
    300301
     302TEST(EditorStateTests, CaretColorInContentEditable)
     303{
     304    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
     305    [webView synchronouslyLoadHTMLString:@"<body style=\"caret-color: red;\" contenteditable=\"true\"></body>"];
     306    [webView stringByEvaluatingJavaScript:@"document.body.focus()"];
     307    UIView<UITextInputTraits_Private> *textInput = (UIView<UITextInputTraits_Private> *) [webView textInputContentView];
     308    UIColor *insertionPointColor = textInput.insertionPointColor;
     309    UIColor *redColor = [UIColor redColor];
     310    auto colorSpace = adoptCF(CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB));
     311    auto cgInsertionPointColor = adoptCF(CGColorCreateCopyByMatchingToColorSpace(colorSpace.get(), kCGRenderingIntentDefault, insertionPointColor.CGColor, NULL));
     312    auto cgRedColor = adoptCF(CGColorCreateCopyByMatchingToColorSpace(colorSpace.get(), kCGRenderingIntentDefault, redColor.CGColor, NULL));
     313    EXPECT_TRUE(CGColorEqualToColor(cgInsertionPointColor.get(), cgRedColor.get()));
     314}
    301315#endif
    302316
  • trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h

    r222991 r223012  
    5757
    5858@protocol UITextInputTraits_Private <NSObject, UITextInputTraits>
     59@property (nonatomic, readonly) UIColor *insertionPointColor;
    5960@end
    6061
Note: See TracChangeset for help on using the changeset viewer.