Changeset 260854 in webkit


Ignore:
Timestamp:
Apr 28, 2020 4:35:05 PM (4 years ago)
Author:
dbates@webkit.org
Message:

[WebKitLegacy] Implement -hidePlaceholder and -showPlaceholderIfNecessary in terms of setCanShowPlaceholder()
https://bugs.webkit.org/show_bug.cgi?id=211139

Reviewed by Simon Fraser.

Source/WebCore:

Remove hidePlaceholder() and showPlaceholderIfNecessary() as they are no longer needed.
Callers should use setCanShowPlaceholder() instead.

  • html/HTMLTextFormControlElement.cpp:

(WebCore::HTMLTextFormControlElement::hidePlaceholder): Deleted.
(WebCore::HTMLTextFormControlElement::showPlaceholderIfNecessary): Deleted.

  • html/HTMLTextFormControlElement.h:

Source/WebKitLegacy/mac:

Implement -hidePlaceholder and -showPlaceholderIfNecessary in terms of setCanShowPlaceholder()
because:

  1. Unlike -hidePlaceholder and -showPlaceholderIfNecessary, setCanShowPlaceholder() does NOT of reach into the guts of the control and mutate its CSS.
  1. Because of (1), it works correctly should future code be written that modifies the structure of the guts or the CSS of the placeholder element (which is inside the guts of the control).
  1. Unlike -hidePlaceholder and -showPlaceholderIfNecessary, there is test coverage for setCanShowPlaceholder() to ensure (2).
  • DOM/WebDOMOperations.mm:

(-[DOMNode hidePlaceholder]):
(-[DOMNode showPlaceholderIfNecessary]):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r260852 r260854  
     12020-04-28  Daniel Bates  <dabates@apple.com>
     2
     3        [WebKitLegacy] Implement -hidePlaceholder and -showPlaceholderIfNecessary in terms of setCanShowPlaceholder()
     4        https://bugs.webkit.org/show_bug.cgi?id=211139
     5
     6        Reviewed by Simon Fraser.
     7
     8        Remove hidePlaceholder() and showPlaceholderIfNecessary() as they are no longer needed.
     9        Callers should use setCanShowPlaceholder() instead.
     10
     11        * html/HTMLTextFormControlElement.cpp:
     12        (WebCore::HTMLTextFormControlElement::hidePlaceholder): Deleted.
     13        (WebCore::HTMLTextFormControlElement::showPlaceholderIfNecessary): Deleted.
     14        * html/HTMLTextFormControlElement.h:
     15
    1162020-04-28  ChangSeok Oh  <changseok@webkit.org>
    217
  • trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp

    r259933 r260854  
    678678}
    679679
    680 #if PLATFORM(IOS_FAMILY)
    681 void HTMLTextFormControlElement::hidePlaceholder()
    682 {
    683     if (RefPtr<HTMLElement> placeholder = placeholderElement())
    684         placeholder->setInlineStyleProperty(CSSPropertyVisibility, CSSValueHidden, true);
    685 }
    686 
    687 void HTMLTextFormControlElement::showPlaceholderIfNecessary()
    688 {
    689     if (RefPtr<HTMLElement> placeholder = placeholderElement())
    690         placeholder->setInlineStyleProperty(CSSPropertyVisibility, CSSValueVisible, true);
    691 }
    692 #endif
    693 
    694680static void getNextSoftBreak(RootInlineBox*& line, Node*& breakNode, unsigned& breakOffset)
    695681{
  • trunk/Source/WebCore/html/HTMLTextFormControlElement.h

    r259933 r260854  
    100100
    101101    void setTextAsOfLastFormControlChangeEvent(const String& text) { m_textAsOfLastFormControlChangeEvent = text; }
    102 #if PLATFORM(IOS_FAMILY)
    103     WEBCORE_EXPORT void hidePlaceholder();
    104     WEBCORE_EXPORT void showPlaceholderIfNecessary();
    105 #endif
    106102
    107103    WEBCORE_EXPORT virtual bool isInnerTextElementEditable() const;
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r260777 r260854  
     12020-04-28  Daniel Bates  <dabates@apple.com>
     2
     3        [WebKitLegacy] Implement -hidePlaceholder and -showPlaceholderIfNecessary in terms of setCanShowPlaceholder()
     4        https://bugs.webkit.org/show_bug.cgi?id=211139
     5
     6        Reviewed by Simon Fraser.
     7
     8        Implement -hidePlaceholder and -showPlaceholderIfNecessary in terms of setCanShowPlaceholder()
     9        because:
     10
     11            1. Unlike -hidePlaceholder and -showPlaceholderIfNecessary, setCanShowPlaceholder() does NOT of
     12               reach into the guts of the control and mutate its CSS.
     13
     14            2. Because of (1), it works correctly should future code be written that modifies the structure
     15               of the guts or the CSS of the placeholder element (which is inside the guts of the control).
     16
     17            3. Unlike -hidePlaceholder and -showPlaceholderIfNecessary, there is test coverage for setCanShowPlaceholder()
     18               to ensure (2).
     19
     20        * DOM/WebDOMOperations.mm:
     21        (-[DOMNode hidePlaceholder]):
     22        (-[DOMNode showPlaceholderIfNecessary]):
     23
    1242020-04-27  Antoine Quint  <graouts@apple.com>
    225
  • trunk/Source/WebKitLegacy/mac/DOM/WebDOMOperations.mm

    r251425 r260854  
    4949#import <WebCore/HTMLInputElement.h>
    5050#import <WebCore/HTMLParserIdioms.h>
     51#import <WebCore/HTMLTextFormControlElement.h>
    5152#import <WebCore/JSElement.h>
    5253#import <WebCore/LegacyWebArchive.h>
     
    9899
    99100#if PLATFORM(IOS_FAMILY)
     101
    100102- (BOOL)isHorizontalWritingMode
    101103{
     
    113115- (void)hidePlaceholder
    114116{
    115     if (![self isKindOfClass:[DOMHTMLInputElement class]]
    116         && ![self isKindOfClass:[DOMHTMLTextAreaElement class]])
    117         return;
    118    
    119     Node *node = core(self);
    120     HTMLTextFormControlElement *formControl = static_cast<HTMLTextFormControlElement *>(node);
    121     formControl->hidePlaceholder();
     117    if (auto node = core(self); is<HTMLTextFormControlElement>(node))
     118        downcast<HTMLTextFormControlElement>(*node).setCanShowPlaceholder(false);
    122119}
    123120
    124121- (void)showPlaceholderIfNecessary
    125122{
    126     if (![self isKindOfClass:[DOMHTMLInputElement class]]
    127         && ![self isKindOfClass:[DOMHTMLTextAreaElement class]])
    128         return;
    129    
    130     HTMLTextFormControlElement *formControl = static_cast<HTMLTextFormControlElement *>(core(self));
    131     formControl->showPlaceholderIfNecessary();
    132 }
     123    if (auto node = core(self); is<HTMLTextFormControlElement>(node))
     124        downcast<HTMLTextFormControlElement>(*node).setCanShowPlaceholder(true);
     125}
     126
    133127#endif
    134128
Note: See TracChangeset for help on using the changeset viewer.