OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 PassOwnPtr<ValidationMessage> ValidationMessage::create(HTMLFormControlElement*
element) | 53 PassOwnPtr<ValidationMessage> ValidationMessage::create(HTMLFormControlElement*
element) |
54 { | 54 { |
55 return adoptPtr(new ValidationMessage(element)); | 55 return adoptPtr(new ValidationMessage(element)); |
56 } | 56 } |
57 | 57 |
58 ValidationMessageClient* ValidationMessage::validationMessageClient() const | 58 ValidationMessageClient* ValidationMessage::validationMessageClient() const |
59 { | 59 { |
60 Page* page = m_element->document().page(); | 60 Page* page = m_element->document().page(); |
61 if (!page) | 61 if (!page) |
62 return 0; | 62 return 0; |
63 // The form valdiation feature requires ValidationMessageClient. | 63 |
64 ASSERT(page->validationMessageClient()); | 64 return &page->validationMessageClient(); |
65 return page->validationMessageClient(); | |
66 } | 65 } |
67 | 66 |
68 void ValidationMessage::updateValidationMessage(const String& message) | 67 void ValidationMessage::updateValidationMessage(const String& message) |
69 { | 68 { |
70 ValidationMessageClient* client = validationMessageClient(); | 69 ValidationMessageClient* client = validationMessageClient(); |
71 if (!client) | 70 if (!client) |
72 return; | 71 return; |
73 if (message.isEmpty()) | 72 if (message.isEmpty()) |
74 requestToHideMessage(); | 73 requestToHideMessage(); |
75 else | 74 else |
76 client->showValidationMessage(*m_element, message); | 75 client->showValidationMessage(*m_element, message); |
77 } | 76 } |
78 | 77 |
79 void ValidationMessage::requestToHideMessage() | 78 void ValidationMessage::requestToHideMessage() |
80 { | 79 { |
81 if (ValidationMessageClient* client = validationMessageClient()) | 80 if (ValidationMessageClient* client = validationMessageClient()) |
82 client->hideValidationMessage(*m_element); | 81 client->hideValidationMessage(*m_element); |
83 } | 82 } |
84 | 83 |
85 bool ValidationMessage::isVisible() const | 84 bool ValidationMessage::isVisible() const |
86 { | 85 { |
87 if (ValidationMessageClient* client = validationMessageClient()) | 86 if (ValidationMessageClient* client = validationMessageClient()) |
88 return client->isValidationMessageVisible(*m_element); | 87 return client->isValidationMessageVisible(*m_element); |
89 return false; | 88 return false; |
90 } | 89 } |
91 | 90 |
92 } // namespace WebCore | 91 } // namespace WebCore |
OLD | NEW |