OLD | NEW |
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) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 bool oldDisabled = m_disabled; | 152 bool oldDisabled = m_disabled; |
153 m_disabled = !value.isNull(); | 153 m_disabled = !value.isNull(); |
154 if (oldDisabled != m_disabled) | 154 if (oldDisabled != m_disabled) |
155 disabledAttributeChanged(); | 155 disabledAttributeChanged(); |
156 } else if (name == readonlyAttr) { | 156 } else if (name == readonlyAttr) { |
157 bool wasReadOnly = m_isReadOnly; | 157 bool wasReadOnly = m_isReadOnly; |
158 m_isReadOnly = !value.isNull(); | 158 m_isReadOnly = !value.isNull(); |
159 if (wasReadOnly != m_isReadOnly) { | 159 if (wasReadOnly != m_isReadOnly) { |
160 setNeedsWillValidateCheck(); | 160 setNeedsWillValidateCheck(); |
161 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing:
:fromAttribute(name)); | 161 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing:
:fromAttribute(name)); |
162 if (renderer() && renderer()->style()->hasAppearance()) | 162 if (layoutObject() && layoutObject()->style()->hasAppearance()) |
163 LayoutTheme::theme().stateChanged(renderer(), ReadOnlyControlSta
te); | 163 LayoutTheme::theme().stateChanged(layoutObject(), ReadOnlyContro
lState); |
164 } | 164 } |
165 } else if (name == requiredAttr) { | 165 } else if (name == requiredAttr) { |
166 bool wasRequired = m_isRequired; | 166 bool wasRequired = m_isRequired; |
167 m_isRequired = !value.isNull(); | 167 m_isRequired = !value.isNull(); |
168 if (wasRequired != m_isRequired) | 168 if (wasRequired != m_isRequired) |
169 requiredAttributeChanged(); | 169 requiredAttributeChanged(); |
170 UseCounter::count(document(), UseCounter::RequiredAttribute); | 170 UseCounter::count(document(), UseCounter::RequiredAttribute); |
171 } else if (name == autofocusAttr) { | 171 } else if (name == autofocusAttr) { |
172 HTMLElement::parseAttribute(name, value); | 172 HTMLElement::parseAttribute(name, value); |
173 UseCounter::count(document(), UseCounter::AutoFocusAttribute); | 173 UseCounter::count(document(), UseCounter::AutoFocusAttribute); |
174 } else | 174 } else |
175 HTMLElement::parseAttribute(name, value); | 175 HTMLElement::parseAttribute(name, value); |
176 } | 176 } |
177 | 177 |
178 void HTMLFormControlElement::disabledAttributeChanged() | 178 void HTMLFormControlElement::disabledAttributeChanged() |
179 { | 179 { |
180 setNeedsWillValidateCheck(); | 180 setNeedsWillValidateCheck(); |
181 pseudoStateChanged(CSSSelector::PseudoDisabled); | 181 pseudoStateChanged(CSSSelector::PseudoDisabled); |
182 pseudoStateChanged(CSSSelector::PseudoEnabled); | 182 pseudoStateChanged(CSSSelector::PseudoEnabled); |
183 if (renderer() && renderer()->style()->hasAppearance()) | 183 if (layoutObject() && layoutObject()->style()->hasAppearance()) |
184 LayoutTheme::theme().stateChanged(renderer(), EnabledControlState); | 184 LayoutTheme::theme().stateChanged(layoutObject(), EnabledControlState); |
185 if (isDisabledFormControl() && treeScope().adjustedFocusedElement() == this)
{ | 185 if (isDisabledFormControl() && treeScope().adjustedFocusedElement() == this)
{ |
186 // We might want to call blur(), but it's dangerous to dispatch events | 186 // We might want to call blur(), but it's dangerous to dispatch events |
187 // here. | 187 // here. |
188 document().setNeedsFocusedElementCheck(); | 188 document().setNeedsFocusedElementCheck(); |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
192 void HTMLFormControlElement::requiredAttributeChanged() | 192 void HTMLFormControlElement::requiredAttributeChanged() |
193 { | 193 { |
194 setNeedsValidityCheck(); | 194 setNeedsValidityCheck(); |
(...skipping 30 matching lines...) Expand all Loading... |
225 return false; | 225 return false; |
226 } | 226 } |
227 | 227 |
228 return true; | 228 return true; |
229 } | 229 } |
230 | 230 |
231 void HTMLFormControlElement::attach(const AttachContext& context) | 231 void HTMLFormControlElement::attach(const AttachContext& context) |
232 { | 232 { |
233 HTMLElement::attach(context); | 233 HTMLElement::attach(context); |
234 | 234 |
235 if (!renderer()) | 235 if (!layoutObject()) |
236 return; | 236 return; |
237 | 237 |
238 // The call to updateFromElement() needs to go after the call through | 238 // The call to updateFromElement() needs to go after the call through |
239 // to the base class's attach() because that can sometimes do a close | 239 // to the base class's attach() because that can sometimes do a close |
240 // on the renderer. | 240 // on the renderer. |
241 renderer()->updateFromElement(); | 241 layoutObject()->updateFromElement(); |
242 | 242 |
243 // FIXME: Autofocus handling should be moved to insertedInto according to | 243 // FIXME: Autofocus handling should be moved to insertedInto according to |
244 // the standard. | 244 // the standard. |
245 if (shouldAutofocusOnAttach(this)) | 245 if (shouldAutofocusOnAttach(this)) |
246 document().setAutofocusElement(this); | 246 document().setAutofocusElement(this); |
247 } | 247 } |
248 | 248 |
249 void HTMLFormControlElement::didMoveToNewDocument(Document& oldDocument) | 249 void HTMLFormControlElement::didMoveToNewDocument(Document& oldDocument) |
250 { | 250 { |
251 FormAssociatedElement::didMoveToNewDocument(oldDocument); | 251 FormAssociatedElement::didMoveToNewDocument(oldDocument); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 return m_isRequired; | 353 return m_isRequired; |
354 } | 354 } |
355 | 355 |
356 String HTMLFormControlElement::resultForDialogSubmit() | 356 String HTMLFormControlElement::resultForDialogSubmit() |
357 { | 357 { |
358 return fastGetAttribute(valueAttr); | 358 return fastGetAttribute(valueAttr); |
359 } | 359 } |
360 | 360 |
361 void HTMLFormControlElement::didRecalcStyle(StyleRecalcChange) | 361 void HTMLFormControlElement::didRecalcStyle(StyleRecalcChange) |
362 { | 362 { |
363 if (LayoutObject* renderer = this->renderer()) | 363 if (LayoutObject* renderer = this->layoutObject()) |
364 renderer->updateFromElement(); | 364 renderer->updateFromElement(); |
365 } | 365 } |
366 | 366 |
367 bool HTMLFormControlElement::supportsFocus() const | 367 bool HTMLFormControlElement::supportsFocus() const |
368 { | 368 { |
369 return !isDisabledFormControl(); | 369 return !isDisabledFormControl(); |
370 } | 370 } |
371 | 371 |
372 bool HTMLFormControlElement::isKeyboardFocusable() const | 372 bool HTMLFormControlElement::isKeyboardFocusable() const |
373 { | 373 { |
(...skipping 18 matching lines...) Expand all Loading... |
392 HTMLElement::dispatchFocusEvent(oldFocusedElement, type); | 392 HTMLElement::dispatchFocusEvent(oldFocusedElement, type); |
393 } | 393 } |
394 | 394 |
395 void HTMLFormControlElement::willCallDefaultEventHandler(const Event& event) | 395 void HTMLFormControlElement::willCallDefaultEventHandler(const Event& event) |
396 { | 396 { |
397 if (!m_wasFocusedByMouse) | 397 if (!m_wasFocusedByMouse) |
398 return; | 398 return; |
399 if (!event.isKeyboardEvent() || event.type() != EventTypeNames::keydown) | 399 if (!event.isKeyboardEvent() || event.type() != EventTypeNames::keydown) |
400 return; | 400 return; |
401 m_wasFocusedByMouse = false; | 401 m_wasFocusedByMouse = false; |
402 if (renderer()) | 402 if (layoutObject()) |
403 renderer()->setShouldDoFullPaintInvalidation(); | 403 layoutObject()->setShouldDoFullPaintInvalidation(); |
404 } | 404 } |
405 | 405 |
406 short HTMLFormControlElement::tabIndex() const | 406 short HTMLFormControlElement::tabIndex() const |
407 { | 407 { |
408 // Skip the supportsFocus check in HTMLElement. | 408 // Skip the supportsFocus check in HTMLElement. |
409 return Element::tabIndex(); | 409 return Element::tabIndex(); |
410 } | 410 } |
411 | 411 |
412 bool HTMLFormControlElement::recalcWillValidate() const | 412 bool HTMLFormControlElement::recalcWillValidate() const |
413 { | 413 { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 | 448 |
449 if (!m_willValidate) | 449 if (!m_willValidate) |
450 hideVisibleValidationMessage(); | 450 hideVisibleValidationMessage(); |
451 } | 451 } |
452 | 452 |
453 void HTMLFormControlElement::findCustomValidationMessageTextDirection(const Stri
ng& message, TextDirection &messageDir, String& subMessage, TextDirection &subMe
ssageDir) | 453 void HTMLFormControlElement::findCustomValidationMessageTextDirection(const Stri
ng& message, TextDirection &messageDir, String& subMessage, TextDirection &subMe
ssageDir) |
454 { | 454 { |
455 subMessage = fastGetAttribute(titleAttr); | 455 subMessage = fastGetAttribute(titleAttr); |
456 messageDir = determineDirectionality(message); | 456 messageDir = determineDirectionality(message); |
457 if (!subMessage.isEmpty()) | 457 if (!subMessage.isEmpty()) |
458 subMessageDir = renderer()->style()->direction(); | 458 subMessageDir = layoutObject()->style()->direction(); |
459 } | 459 } |
460 | 460 |
461 void HTMLFormControlElement::updateVisibleValidationMessage() | 461 void HTMLFormControlElement::updateVisibleValidationMessage() |
462 { | 462 { |
463 Page* page = document().page(); | 463 Page* page = document().page(); |
464 if (!page) | 464 if (!page) |
465 return; | 465 return; |
466 String message; | 466 String message; |
467 if (renderer() && willValidate()) | 467 if (layoutObject() && willValidate()) |
468 message = validationMessage().stripWhiteSpace(); | 468 message = validationMessage().stripWhiteSpace(); |
469 | 469 |
470 m_hasValidationMessage = true; | 470 m_hasValidationMessage = true; |
471 ValidationMessageClient* client = &page->validationMessageClient(); | 471 ValidationMessageClient* client = &page->validationMessageClient(); |
472 TextDirection messageDir = LTR; | 472 TextDirection messageDir = LTR; |
473 TextDirection subMessageDir = LTR; | 473 TextDirection subMessageDir = LTR; |
474 String subMessage = String(); | 474 String subMessage = String(); |
475 if (message.isEmpty()) | 475 if (message.isEmpty()) |
476 client->hideValidationMessage(*this); | 476 client->hideValidationMessage(*this); |
477 else | 477 else |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 | 534 |
535 bool HTMLFormControlElement::reportValidity() | 535 bool HTMLFormControlElement::reportValidity() |
536 { | 536 { |
537 WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElement> > unhandledInval
idControls; | 537 WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElement> > unhandledInval
idControls; |
538 bool isValid = checkValidity(&unhandledInvalidControls, CheckValidityDispatc
hInvalidEvent); | 538 bool isValid = checkValidity(&unhandledInvalidControls, CheckValidityDispatc
hInvalidEvent); |
539 if (isValid || unhandledInvalidControls.isEmpty()) | 539 if (isValid || unhandledInvalidControls.isEmpty()) |
540 return isValid; | 540 return isValid; |
541 ASSERT(unhandledInvalidControls.size() == 1); | 541 ASSERT(unhandledInvalidControls.size() == 1); |
542 ASSERT(unhandledInvalidControls[0].get() == this); | 542 ASSERT(unhandledInvalidControls[0].get() == this); |
543 // Update layout now before calling isFocusable(), which has | 543 // Update layout now before calling isFocusable(), which has |
544 // !renderer()->needsLayout() assertion. | 544 // !layoutObject()->needsLayout() assertion. |
545 document().updateLayoutIgnorePendingStylesheets(); | 545 document().updateLayoutIgnorePendingStylesheets(); |
546 if (isFocusable()) { | 546 if (isFocusable()) { |
547 showValidationMessage(); | 547 showValidationMessage(); |
548 return false; | 548 return false; |
549 } | 549 } |
550 if (document().frame()) { | 550 if (document().frame()) { |
551 String message("An invalid form control with name='%name' is not focusab
le."); | 551 String message("An invalid form control with name='%name' is not focusab
le."); |
552 message.replace("%name", name()); | 552 message.replace("%name", name()); |
553 document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSour
ce, ErrorMessageLevel, message)); | 553 document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSour
ce, ErrorMessageLevel, message)); |
554 } | 554 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 dispatchFormControlChangeEvent(); | 639 dispatchFormControlChangeEvent(); |
640 } | 640 } |
641 | 641 |
642 void HTMLFormControlElement::copyNonAttributePropertiesFromElement(const Element
& source) | 642 void HTMLFormControlElement::copyNonAttributePropertiesFromElement(const Element
& source) |
643 { | 643 { |
644 HTMLElement::copyNonAttributePropertiesFromElement(source); | 644 HTMLElement::copyNonAttributePropertiesFromElement(source); |
645 setNeedsValidityCheck(); | 645 setNeedsValidityCheck(); |
646 } | 646 } |
647 | 647 |
648 } // namespace blink | 648 } // namespace blink |
OLD | NEW |