Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: Source/core/html/HTMLTextFormControlElement.h

Issue 1280423002: CSS4: Implement :placeholder-shown pseudo class (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated testcase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
6 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. 6 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 }; 53 };
54 54
55 ~HTMLTextFormControlElement() override; 55 ~HTMLTextFormControlElement() override;
56 56
57 void forwardEvent(Event*); 57 void forwardEvent(Event*);
58 58
59 59
60 InsertionNotificationRequest insertedInto(ContainerNode*) override; 60 InsertionNotificationRequest insertedInto(ContainerNode*) override;
61 61
62 // The derived class should return true if placeholder processing is needed. 62 // The derived class should return true if placeholder processing is needed.
63 bool isPlaceholderVisible() const { return m_isPlaceholderVisible; }
esprehn 2015/08/21 10:18:10 virtual, HTMLInputElement and HTMLTextAreaElement
ramya.v 2015/08/25 10:24:45 Done.
63 virtual bool supportsPlaceholder() const = 0; 64 virtual bool supportsPlaceholder() const = 0;
64 String strippedPlaceholder() const; 65 String strippedPlaceholder() const;
65 bool placeholderShouldBeVisible() const;
66 HTMLElement* placeholderElement() const; 66 HTMLElement* placeholderElement() const;
67 void updatePlaceholderVisibility(bool); 67 void updatePlaceholderVisibility();
68 68
69 VisiblePosition visiblePositionForIndex(int) const; 69 VisiblePosition visiblePositionForIndex(int) const;
70 int indexForVisiblePosition(const VisiblePosition&) const; 70 int indexForVisiblePosition(const VisiblePosition&) const;
71 int selectionStart() const; 71 int selectionStart() const;
72 int selectionEnd() const; 72 int selectionEnd() const;
73 const AtomicString& selectionDirection() const; 73 const AtomicString& selectionDirection() const;
74 void setSelectionStart(int); 74 void setSelectionStart(int);
75 void setSelectionEnd(int); 75 void setSelectionEnd(int);
76 void setSelectionDirection(const String&); 76 void setSelectionDirection(const String&);
77 void select(NeedToDispatchSelectEvent = DispatchSelectEvent); 77 void select(NeedToDispatchSelectEvent = DispatchSelectEvent);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 // Returns true if user-editable value is empty. Used to check placeholder v isibility. 148 // Returns true if user-editable value is empty. Used to check placeholder v isibility.
149 virtual bool isEmptyValue() const = 0; 149 virtual bool isEmptyValue() const = 0;
150 // Returns true if suggested value is empty. Used to check placeholder visib ility. 150 // Returns true if suggested value is empty. Used to check placeholder visib ility.
151 virtual bool isEmptySuggestedValue() const { return true; } 151 virtual bool isEmptySuggestedValue() const { return true; }
152 // Called in dispatchFocusEvent(), after placeholder process, before calling parent's dispatchFocusEvent(). 152 // Called in dispatchFocusEvent(), after placeholder process, before calling parent's dispatchFocusEvent().
153 virtual void handleFocusEvent(Element* /* oldFocusedNode */, WebFocusType) { } 153 virtual void handleFocusEvent(Element* /* oldFocusedNode */, WebFocusType) { }
154 // Called in dispatchBlurEvent(), after placeholder process, before calling parent's dispatchBlurEvent(). 154 // Called in dispatchBlurEvent(), after placeholder process, before calling parent's dispatchBlurEvent().
155 virtual void handleBlurEvent() { } 155 virtual void handleBlurEvent() { }
156 156
157 bool placeholderShouldBeVisible() const;
158
157 String m_textAsOfLastFormControlChangeEvent; 159 String m_textAsOfLastFormControlChangeEvent;
158 bool m_lastChangeWasUserEdit; 160 bool m_lastChangeWasUserEdit;
159 161
160 int m_cachedSelectionStart; 162 int m_cachedSelectionStart;
161 int m_cachedSelectionEnd; 163 int m_cachedSelectionEnd;
162 TextFieldSelectionDirection m_cachedSelectionDirection; 164 TextFieldSelectionDirection m_cachedSelectionDirection;
165 bool m_isPlaceholderVisible;
esprehn 2015/08/21 10:18:10 This should be on HTMLInputElement and merged with
ramya.v 2015/08/25 10:24:45 Done.
163 }; 166 };
164 167
165 inline bool isHTMLTextFormControlElement(const Element& element) 168 inline bool isHTMLTextFormControlElement(const Element& element)
166 { 169 {
167 return element.isTextFormControl(); 170 return element.isTextFormControl();
168 } 171 }
169 172
170 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLTextFormControlElement); 173 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLTextFormControlElement);
171 174
172 HTMLTextFormControlElement* enclosingTextFormControl(const Position&); 175 HTMLTextFormControlElement* enclosingTextFormControl(const Position&);
173 HTMLTextFormControlElement* enclosingTextFormControl(Node*); 176 HTMLTextFormControlElement* enclosingTextFormControl(Node*);
174 177
175 } // namespace 178 } // namespace
176 179
177 #endif 180 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698