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

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 as per review comments 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 }; 52 };
53 53
54 ~HTMLTextFormControlElement() override; 54 ~HTMLTextFormControlElement() override;
55 55
56 void forwardEvent(Event*); 56 void forwardEvent(Event*);
57 57
58 58
59 InsertionNotificationRequest insertedInto(ContainerNode*) override; 59 InsertionNotificationRequest insertedInto(ContainerNode*) override;
60 60
61 // The derived class should return true if placeholder processing is needed. 61 // The derived class should return true if placeholder processing is needed.
62 virtual bool isPlaceholderVisible() const = 0;
63 virtual void setPlaceholderVisibility(bool) = 0;
62 virtual bool supportsPlaceholder() const = 0; 64 virtual bool supportsPlaceholder() const = 0;
63 String strippedPlaceholder() const; 65 String strippedPlaceholder() const;
64 bool placeholderShouldBeVisible() const;
65 HTMLElement* placeholderElement() const; 66 HTMLElement* placeholderElement() const;
66 void updatePlaceholderVisibility(bool); 67 void updatePlaceholderVisibility();
67 68
68 VisiblePosition visiblePositionForIndex(int) const; 69 VisiblePosition visiblePositionForIndex(int) const;
69 int indexForVisiblePosition(const VisiblePosition&) const; 70 int indexForVisiblePosition(const VisiblePosition&) const;
70 int selectionStart() const; 71 int selectionStart() const;
71 int selectionEnd() const; 72 int selectionEnd() const;
72 const AtomicString& selectionDirection() const; 73 const AtomicString& selectionDirection() const;
73 void setSelectionStart(int); 74 void setSelectionStart(int);
74 void setSelectionEnd(int); 75 void setSelectionEnd(int);
75 void setSelectionDirection(const String&); 76 void setSelectionDirection(const String&);
76 void select(NeedToDispatchSelectEvent = DispatchSelectEvent); 77 void select(NeedToDispatchSelectEvent = DispatchSelectEvent);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 147
147 // 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.
148 virtual bool isEmptyValue() const = 0; 149 virtual bool isEmptyValue() const = 0;
149 // 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.
150 virtual bool isEmptySuggestedValue() const { return true; } 151 virtual bool isEmptySuggestedValue() const { return true; }
151 // Called in dispatchFocusEvent(), after placeholder process, before calling parent's dispatchFocusEvent(). 152 // Called in dispatchFocusEvent(), after placeholder process, before calling parent's dispatchFocusEvent().
152 virtual void handleFocusEvent(Element* /* oldFocusedNode */, WebFocusType) { } 153 virtual void handleFocusEvent(Element* /* oldFocusedNode */, WebFocusType) { }
153 // Called in dispatchBlurEvent(), after placeholder process, before calling parent's dispatchBlurEvent(). 154 // Called in dispatchBlurEvent(), after placeholder process, before calling parent's dispatchBlurEvent().
154 virtual void handleBlurEvent() { } 155 virtual void handleBlurEvent() { }
155 156
157 bool placeholderShouldBeVisible() const;
158
156 String m_textAsOfLastFormControlChangeEvent; 159 String m_textAsOfLastFormControlChangeEvent;
157 bool m_lastChangeWasUserEdit; 160 bool m_lastChangeWasUserEdit;
158 161
159 int m_cachedSelectionStart; 162 int m_cachedSelectionStart;
160 int m_cachedSelectionEnd; 163 int m_cachedSelectionEnd;
161 TextFieldSelectionDirection m_cachedSelectionDirection; 164 TextFieldSelectionDirection m_cachedSelectionDirection;
162 }; 165 };
163 166
164 inline bool isHTMLTextFormControlElement(const Element& element) 167 inline bool isHTMLTextFormControlElement(const Element& element)
165 { 168 {
166 return element.isTextFormControl(); 169 return element.isTextFormControl();
167 } 170 }
168 171
169 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLTextFormControlElement); 172 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLTextFormControlElement);
170 173
171 HTMLTextFormControlElement* enclosingTextFormControl(const Position&); 174 HTMLTextFormControlElement* enclosingTextFormControl(const Position&);
172 HTMLTextFormControlElement* enclosingTextFormControl(Node*); 175 HTMLTextFormControlElement* enclosingTextFormControl(Node*);
173 176
174 } // namespace 177 } // namespace
175 178
176 #endif 179 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698