OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 27 matching lines...) Expand all Loading... |
38 class CachedImage; | 38 class CachedImage; |
39 class HTMLInputElement; | 39 class HTMLInputElement; |
40 class ShadowRoot; | 40 class ShadowRoot; |
41 | 41 |
42 // A TextFieldDecorator object must live until all of text fields which were | 42 // A TextFieldDecorator object must live until all of text fields which were |
43 // decorated by it die. | 43 // decorated by it die. |
44 class TextFieldDecorator { | 44 class TextFieldDecorator { |
45 public: | 45 public: |
46 // Returns true if this TextFieldDecorator wants to add a | 46 // Returns true if this TextFieldDecorator wants to add a |
47 // decoration to the specified text field. | 47 // decoration to the specified text field. |
48 virtual bool willAddDecorationTo(HTMLInputElement*) = 0; | 48 virtual bool willAddDecorationTo(Handle<HTMLInputElement>) = 0; |
49 virtual bool visibleByDefault() = 0; | 49 virtual bool visibleByDefault() = 0; |
50 | 50 |
51 // A TextFieldDecorator object should own the CachedImage objects. | 51 // A TextFieldDecorator object should own the CachedImage objects. |
52 virtual CachedImage* imageForNormalState() = 0; | 52 virtual CachedImage* imageForNormalState() = 0; |
53 virtual CachedImage* imageForDisabledState() = 0; | 53 virtual CachedImage* imageForDisabledState() = 0; |
54 virtual CachedImage* imageForReadonlyState() = 0; | 54 virtual CachedImage* imageForReadonlyState() = 0; |
55 virtual CachedImage* imageForHoverState() = 0; | 55 virtual CachedImage* imageForHoverState() = 0; |
56 | 56 |
57 virtual void handleClick(HTMLInputElement*) = 0; | 57 virtual void handleClick(Handle<HTMLInputElement>) = 0; |
58 // This function is called just before detaching the decoration. It must not | 58 // This function is called just before detaching the decoration. It must not |
59 // call functions which updating state of the specified HTMLInputElement | 59 // call functions which updating state of the specified HTMLInputElement |
60 // object. | 60 // object. |
61 virtual void willDetach(HTMLInputElement*) = 0; | 61 virtual void willDetach(Handle<HTMLInputElement>) = 0; |
62 | 62 |
63 virtual ~TextFieldDecorator(); | 63 virtual ~TextFieldDecorator(); |
64 }; | 64 }; |
65 | 65 |
66 // A TextFieldDecorationElement object must be in a shadow tree of an | 66 // A TextFieldDecorationElement object must be in a shadow tree of an |
67 // HTMLInputElement. | 67 // HTMLInputElement. |
68 class TextFieldDecorationElement : public HTMLDivElement { | 68 class TextFieldDecorationElement : public HTMLDivElement { |
69 public: | 69 public: |
70 static PassRefPtr<TextFieldDecorationElement> create(Document*, TextFieldDec
orator*); | 70 static PassRefPtr<TextFieldDecorationElement> create(Document*, TextFieldDec
orator*); |
71 static TextFieldDecorationElement* fromShadowRoot(ShadowRoot*); | 71 static TextFieldDecorationElement* fromShadowRoot(ShadowRoot*); |
72 TextFieldDecorator* textFieldDecorator() { return m_textFieldDecorator; } | 72 TextFieldDecorator* textFieldDecorator() { return m_textFieldDecorator; } |
73 void decorate(HTMLInputElement*, bool visible); | 73 void decorate(Handle<HTMLInputElement>, bool visible); |
74 | 74 |
75 virtual bool willRespondToMouseMoveEvents() OVERRIDE; | 75 virtual bool willRespondToMouseMoveEvents() OVERRIDE; |
76 virtual bool willRespondToMouseClickEvents() OVERRIDE; | 76 virtual bool willRespondToMouseClickEvents() OVERRIDE; |
77 | 77 |
78 private: | 78 private: |
79 TextFieldDecorationElement(Document*, TextFieldDecorator*); | 79 TextFieldDecorationElement(Document*, TextFieldDecorator*); |
80 virtual bool isTextFieldDecoration() const OVERRIDE; | 80 virtual bool isTextFieldDecoration() const OVERRIDE; |
81 virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE; | 81 virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE; |
82 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE; | 82 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE; |
83 virtual void attach() OVERRIDE; | 83 virtual void attach() OVERRIDE; |
84 virtual void detach() OVERRIDE; | 84 virtual void detach() OVERRIDE; |
85 virtual bool isMouseFocusable() const OVERRIDE; | 85 virtual bool isMouseFocusable() const OVERRIDE; |
86 virtual void defaultEventHandler(Event*) OVERRIDE; | 86 virtual void defaultEventHandler(Event*) OVERRIDE; |
87 | 87 |
88 HTMLInputElement* hostInput(); | 88 Result<HTMLInputElement> hostInput(); |
89 void updateImage(); | 89 void updateImage(); |
90 | 90 |
91 TextFieldDecorator* m_textFieldDecorator; | 91 TextFieldDecorator* m_textFieldDecorator; |
92 bool m_isInHoverState; | 92 bool m_isInHoverState; |
93 }; | 93 }; |
94 | 94 |
95 inline TextFieldDecorationElement* toTextFieldDecorationElement(Node* node) | 95 inline TextFieldDecorationElement* toTextFieldDecorationElement(Node* node) |
96 { | 96 { |
97 ASSERT(node); | 97 ASSERT(node); |
98 ASSERT_WITH_SECURITY_IMPLICATION(node->isElementNode()); | 98 ASSERT_WITH_SECURITY_IMPLICATION(node->isElementNode()); |
99 ASSERT_WITH_SECURITY_IMPLICATION(toElement(node)->isTextFieldDecoration()); | 99 ASSERT_WITH_SECURITY_IMPLICATION(toElement(node)->isTextFieldDecoration()); |
100 return static_cast<TextFieldDecorationElement*>(node); | 100 return static_cast<TextFieldDecorationElement*>(node); |
101 } | 101 } |
102 | 102 |
103 } | 103 } |
104 #endif | 104 #endif |
OLD | NEW |