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

Side by Side Diff: Source/core/html/HTMLInputElement.cpp

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLImageElement.cpp ('k') | Source/core/html/HTMLKeygenElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) 7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 9 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
10 * Copyright (C) 2012 Samsung Electronics. All rights reserved. 10 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 HTMLInputElement::~HTMLInputElement() 149 HTMLInputElement::~HTMLInputElement()
150 { 150 {
151 // Need to remove form association while this is still an HTMLInputElement 151 // Need to remove form association while this is still an HTMLInputElement
152 // so that virtual functions are called correctly. 152 // so that virtual functions are called correctly.
153 setForm(0); 153 setForm(0);
154 // setForm(0) may register this to a document-level radio button group. 154 // setForm(0) may register this to a document-level radio button group.
155 // We should unregister it to avoid accessing a deleted object. 155 // We should unregister it to avoid accessing a deleted object.
156 if (isRadioButton()) 156 if (isRadioButton())
157 document()->formController()->checkedRadioButtons().removeButton(this); 157 document().formController()->checkedRadioButtons().removeButton(this);
158 if (m_hasTouchEventHandler) 158 if (m_hasTouchEventHandler)
159 document()->didRemoveEventTargetNode(this); 159 document().didRemoveEventTargetNode(this);
160 } 160 }
161 161
162 const AtomicString& HTMLInputElement::name() const 162 const AtomicString& HTMLInputElement::name() const
163 { 163 {
164 return m_name.isNull() ? emptyAtom : m_name; 164 return m_name.isNull() ? emptyAtom : m_name;
165 } 165 }
166 166
167 Vector<FileChooserFileInfo> HTMLInputElement::filesFromFileInputFormControlState (const FormControlState& state) 167 Vector<FileChooserFileInfo> HTMLInputElement::filesFromFileInputFormControlState (const FormControlState& state)
168 { 168 {
169 return FileInputType::filesFromFormControlState(state); 169 return FileInputType::filesFromFormControlState(state);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 return m_inputType->shouldShowFocusRingOnMouseFocus(); 345 return m_inputType->shouldShowFocusRingOnMouseFocus();
346 } 346 }
347 347
348 void HTMLInputElement::updateFocusAppearance(bool restorePreviousSelection) 348 void HTMLInputElement::updateFocusAppearance(bool restorePreviousSelection)
349 { 349 {
350 if (isTextField()) { 350 if (isTextField()) {
351 if (!restorePreviousSelection || !hasCachedSelection()) 351 if (!restorePreviousSelection || !hasCachedSelection())
352 select(); 352 select();
353 else 353 else
354 restoreCachedSelection(); 354 restoreCachedSelection();
355 if (document()->frame()) 355 if (document().frame())
356 document()->frame()->selection()->revealSelection(); 356 document().frame()->selection()->revealSelection();
357 } else 357 } else
358 HTMLTextFormControlElement::updateFocusAppearance(restorePreviousSelecti on); 358 HTMLTextFormControlElement::updateFocusAppearance(restorePreviousSelecti on);
359 } 359 }
360 360
361 void HTMLInputElement::beginEditing() 361 void HTMLInputElement::beginEditing()
362 { 362 {
363 if (!isTextField()) 363 if (!isTextField())
364 return; 364 return;
365 365
366 if (Frame* frame = document()->frame()) 366 if (Frame* frame = document().frame())
367 frame->editor().textAreaOrTextFieldDidBeginEditing(this); 367 frame->editor().textAreaOrTextFieldDidBeginEditing(this);
368 } 368 }
369 369
370 void HTMLInputElement::endEditing() 370 void HTMLInputElement::endEditing()
371 { 371 {
372 if (!isTextField()) 372 if (!isTextField())
373 return; 373 return;
374 374
375 if (Frame* frame = document()->frame()) 375 if (Frame* frame = document().frame())
376 frame->editor().textFieldDidEndEditing(this); 376 frame->editor().textFieldDidEndEditing(this);
377 } 377 }
378 378
379 bool HTMLInputElement::shouldUseInputMethod() 379 bool HTMLInputElement::shouldUseInputMethod()
380 { 380 {
381 return m_inputType->shouldUseInputMethod(); 381 return m_inputType->shouldUseInputMethod();
382 } 382 }
383 383
384 void HTMLInputElement::handleFocusEvent(Element* oldFocusedElement, FocusDirecti on direction) 384 void HTMLInputElement::handleFocusEvent(Element* oldFocusedElement, FocusDirecti on direction)
385 { 385 {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 if (wasAttached) 431 if (wasAttached)
432 detach(); 432 detach();
433 433
434 m_inputType = newType.release(); 434 m_inputType = newType.release();
435 m_inputTypeView = m_inputType; 435 m_inputTypeView = m_inputType;
436 m_inputType->createShadowSubtree(); 436 m_inputType->createShadowSubtree();
437 437
438 bool hasTouchEventHandler = m_inputTypeView->hasTouchEventHandler(); 438 bool hasTouchEventHandler = m_inputTypeView->hasTouchEventHandler();
439 if (hasTouchEventHandler != m_hasTouchEventHandler) { 439 if (hasTouchEventHandler != m_hasTouchEventHandler) {
440 if (hasTouchEventHandler) 440 if (hasTouchEventHandler)
441 document()->didAddTouchEventHandler(this); 441 document().didAddTouchEventHandler(this);
442 else 442 else
443 document()->didRemoveTouchEventHandler(this); 443 document().didRemoveTouchEventHandler(this);
444 m_hasTouchEventHandler = hasTouchEventHandler; 444 m_hasTouchEventHandler = hasTouchEventHandler;
445 } 445 }
446 446
447 setNeedsWillValidateCheck(); 447 setNeedsWillValidateCheck();
448 448
449 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute(); 449 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute();
450 450
451 if (didStoreValue && !willStoreValue && hasDirtyValue()) { 451 if (didStoreValue && !willStoreValue && hasDirtyValue()) {
452 setAttribute(valueAttr, m_valueIfDirty); 452 setAttribute(valueAttr, m_valueIfDirty);
453 m_valueIfDirty = String(); 453 m_valueIfDirty = String();
(...skipping 14 matching lines...) Expand all
468 if (const Attribute* height = getAttributeItem(heightAttr)) 468 if (const Attribute* height = getAttributeItem(heightAttr))
469 attributeChanged(heightAttr, height->value()); 469 attributeChanged(heightAttr, height->value());
470 if (const Attribute* width = getAttributeItem(widthAttr)) 470 if (const Attribute* width = getAttributeItem(widthAttr))
471 attributeChanged(widthAttr, width->value()); 471 attributeChanged(widthAttr, width->value());
472 if (const Attribute* align = getAttributeItem(alignAttr)) 472 if (const Attribute* align = getAttributeItem(alignAttr))
473 attributeChanged(alignAttr, align->value()); 473 attributeChanged(alignAttr, align->value());
474 } 474 }
475 475
476 if (wasAttached) { 476 if (wasAttached) {
477 lazyAttach(); 477 lazyAttach();
478 if (document()->focusedElement() == this) 478 if (document().focusedElement() == this)
479 document()->updateFocusAppearanceSoon(true /* restore selection */); 479 document().updateFocusAppearanceSoon(true /* restore selection */);
480 } 480 }
481 481
482 setChangedSinceLastFormControlChangeEvent(false); 482 setChangedSinceLastFormControlChangeEvent(false);
483 483
484 addToRadioButtonGroup(); 484 addToRadioButtonGroup();
485 485
486 setNeedsValidityCheck(); 486 setNeedsValidityCheck();
487 notifyFormStateChanged(); 487 notifyFormStateChanged();
488 } 488 }
489 489
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 // Search field and slider attributes all just cause updateFromElement t o be called through style recalcing. 691 // Search field and slider attributes all just cause updateFromElement t o be called through style recalcing.
692 setAttributeEventListener(eventNames().searchEvent, createAttributeEvent Listener(this, name, value)); 692 setAttributeEventListener(eventNames().searchEvent, createAttributeEvent Listener(this, name, value));
693 } else if (name == resultsAttr) { 693 } else if (name == resultsAttr) {
694 int oldResults = m_maxResults; 694 int oldResults = m_maxResults;
695 m_maxResults = !value.isNull() ? std::min(value.toInt(), maxSavedResults ) : -1; 695 m_maxResults = !value.isNull() ? std::min(value.toInt(), maxSavedResults ) : -1;
696 // FIXME: Detaching just for maxResults change is not ideal. We should figure out the right 696 // FIXME: Detaching just for maxResults change is not ideal. We should figure out the right
697 // time to relayout for this change. 697 // time to relayout for this change.
698 if (m_maxResults != oldResults && (m_maxResults <= 0 || oldResults <= 0) ) 698 if (m_maxResults != oldResults && (m_maxResults <= 0 || oldResults <= 0) )
699 lazyReattachIfAttached(); 699 lazyReattachIfAttached();
700 setNeedsStyleRecalc(); 700 setNeedsStyleRecalc();
701 UseCounter::count(document(), UseCounter::ResultsAttribute); 701 UseCounter::count(&document(), UseCounter::ResultsAttribute);
702 } else if (name == incrementalAttr) { 702 } else if (name == incrementalAttr) {
703 setNeedsStyleRecalc(); 703 setNeedsStyleRecalc();
704 UseCounter::count(document(), UseCounter::IncrementalAttribute); 704 UseCounter::count(&document(), UseCounter::IncrementalAttribute);
705 } else if (name == minAttr) { 705 } else if (name == minAttr) {
706 m_inputTypeView->minOrMaxAttributeChanged(); 706 m_inputTypeView->minOrMaxAttributeChanged();
707 m_inputType->sanitizeValueInResponseToMinOrMaxAttributeChange(); 707 m_inputType->sanitizeValueInResponseToMinOrMaxAttributeChange();
708 setNeedsValidityCheck(); 708 setNeedsValidityCheck();
709 UseCounter::count(document(), UseCounter::MinAttribute); 709 UseCounter::count(&document(), UseCounter::MinAttribute);
710 } else if (name == maxAttr) { 710 } else if (name == maxAttr) {
711 m_inputTypeView->minOrMaxAttributeChanged(); 711 m_inputTypeView->minOrMaxAttributeChanged();
712 setNeedsValidityCheck(); 712 setNeedsValidityCheck();
713 UseCounter::count(document(), UseCounter::MaxAttribute); 713 UseCounter::count(&document(), UseCounter::MaxAttribute);
714 } else if (name == multipleAttr) { 714 } else if (name == multipleAttr) {
715 m_inputTypeView->multipleAttributeChanged(); 715 m_inputTypeView->multipleAttributeChanged();
716 setNeedsValidityCheck(); 716 setNeedsValidityCheck();
717 } else if (name == stepAttr) { 717 } else if (name == stepAttr) {
718 m_inputTypeView->stepAttributeChanged(); 718 m_inputTypeView->stepAttributeChanged();
719 setNeedsValidityCheck(); 719 setNeedsValidityCheck();
720 UseCounter::count(document(), UseCounter::StepAttribute); 720 UseCounter::count(&document(), UseCounter::StepAttribute);
721 } else if (name == patternAttr) { 721 } else if (name == patternAttr) {
722 setNeedsValidityCheck(); 722 setNeedsValidityCheck();
723 UseCounter::count(document(), UseCounter::PatternAttribute); 723 UseCounter::count(&document(), UseCounter::PatternAttribute);
724 } else if (name == precisionAttr) { 724 } else if (name == precisionAttr) {
725 setNeedsValidityCheck(); 725 setNeedsValidityCheck();
726 UseCounter::count(document(), UseCounter::PrecisionAttribute); 726 UseCounter::count(&document(), UseCounter::PrecisionAttribute);
727 } else if (name == disabledAttr) { 727 } else if (name == disabledAttr) {
728 HTMLTextFormControlElement::parseAttribute(name, value); 728 HTMLTextFormControlElement::parseAttribute(name, value);
729 m_inputTypeView->disabledAttributeChanged(); 729 m_inputTypeView->disabledAttributeChanged();
730 } else if (name == readonlyAttr) { 730 } else if (name == readonlyAttr) {
731 HTMLTextFormControlElement::parseAttribute(name, value); 731 HTMLTextFormControlElement::parseAttribute(name, value);
732 m_inputTypeView->readonlyAttributeChanged(); 732 m_inputTypeView->readonlyAttributeChanged();
733 } else if (name == listAttr) { 733 } else if (name == listAttr) {
734 m_hasNonEmptyList = !value.isEmpty(); 734 m_hasNonEmptyList = !value.isEmpty();
735 if (m_hasNonEmptyList) { 735 if (m_hasNonEmptyList) {
736 resetListAttributeTargetObserver(); 736 resetListAttributeTargetObserver();
737 listAttributeTargetChanged(); 737 listAttributeTargetChanged();
738 } 738 }
739 UseCounter::count(document(), UseCounter::ListAttribute); 739 UseCounter::count(&document(), UseCounter::ListAttribute);
740 } 740 }
741 #if ENABLE(INPUT_SPEECH) 741 #if ENABLE(INPUT_SPEECH)
742 else if (name == webkitspeechAttr) { 742 else if (name == webkitspeechAttr) {
743 if (RuntimeEnabledFeatures::speechInputEnabled() && m_inputType->shouldR espectSpeechAttribute()) { 743 if (RuntimeEnabledFeatures::speechInputEnabled() && m_inputType->shouldR espectSpeechAttribute()) {
744 // This renderer and its children have quite different layouts and 744 // This renderer and its children have quite different layouts and
745 // styles depending on whether the speech button is visible or 745 // styles depending on whether the speech button is visible or
746 // not. So we reset the whole thing and recreate to get the right 746 // not. So we reset the whole thing and recreate to get the right
747 // styles and layout. 747 // styles and layout.
748 m_inputType->destroyShadowSubtree(); 748 m_inputType->destroyShadowSubtree();
749 lazyReattachIfAttached(); 749 lazyReattachIfAttached();
750 m_inputType->createShadowSubtree(); 750 m_inputType->createShadowSubtree();
751 setFormControlValueMatchesRenderer(false); 751 setFormControlValueMatchesRenderer(false);
752 } 752 }
753 UseCounter::count(document(), UseCounter::PrefixedSpeechAttribute); 753 UseCounter::count(&document(), UseCounter::PrefixedSpeechAttribute);
754 } else if (name == onwebkitspeechchangeAttr) 754 } else if (name == onwebkitspeechchangeAttr)
755 setAttributeEventListener(eventNames().webkitspeechchangeEvent, createAt tributeEventListener(this, name, value)); 755 setAttributeEventListener(eventNames().webkitspeechchangeEvent, createAt tributeEventListener(this, name, value));
756 #endif 756 #endif
757 else if (name == webkitdirectoryAttr) { 757 else if (name == webkitdirectoryAttr) {
758 HTMLTextFormControlElement::parseAttribute(name, value); 758 HTMLTextFormControlElement::parseAttribute(name, value);
759 UseCounter::count(document(), UseCounter::PrefixedDirectoryAttribute); 759 UseCounter::count(&document(), UseCounter::PrefixedDirectoryAttribute);
760 } 760 }
761 else 761 else
762 HTMLTextFormControlElement::parseAttribute(name, value); 762 HTMLTextFormControlElement::parseAttribute(name, value);
763 m_inputTypeView->attributeChanged(); 763 m_inputTypeView->attributeChanged();
764 } 764 }
765 765
766 void HTMLInputElement::finishParsingChildren() 766 void HTMLInputElement::finishParsingChildren()
767 { 767 {
768 m_parsingInProgress = false; 768 m_parsingInProgress = false;
769 HTMLTextFormControlElement::finishParsingChildren(); 769 HTMLTextFormControlElement::finishParsingChildren();
(...skipping 20 matching lines...) Expand all
790 PostAttachCallbackDisabler disabler(this); 790 PostAttachCallbackDisabler disabler(this);
791 791
792 if (!m_hasType) 792 if (!m_hasType)
793 updateType(); 793 updateType();
794 794
795 HTMLTextFormControlElement::attach(context); 795 HTMLTextFormControlElement::attach(context);
796 796
797 m_inputTypeView->attach(); 797 m_inputTypeView->attach();
798 m_inputType->countUsage(); 798 m_inputType->countUsage();
799 799
800 if (document()->focusedElement() == this) 800 if (document().focusedElement() == this)
801 document()->updateFocusAppearanceSoon(true /* restore selection */); 801 document().updateFocusAppearanceSoon(true /* restore selection */);
802 } 802 }
803 803
804 void HTMLInputElement::detach(const AttachContext& context) 804 void HTMLInputElement::detach(const AttachContext& context)
805 { 805 {
806 HTMLTextFormControlElement::detach(context); 806 HTMLTextFormControlElement::detach(context);
807 setFormControlValueMatchesRenderer(false); 807 setFormControlValueMatchesRenderer(false);
808 m_inputType->detach(); 808 m_inputType->detach();
809 } 809 }
810 810
811 String HTMLInputElement::altText() const 811 String HTMLInputElement::altText() const
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 buttons->updateCheckedState(this); 879 buttons->updateCheckedState(this);
880 if (renderer() && renderer()->style()->hasAppearance()) 880 if (renderer() && renderer()->style()->hasAppearance())
881 RenderTheme::theme().stateChanged(renderer(), CheckedState); 881 RenderTheme::theme().stateChanged(renderer(), CheckedState);
882 882
883 setNeedsValidityCheck(); 883 setNeedsValidityCheck();
884 884
885 // Ideally we'd do this from the render tree (matching 885 // Ideally we'd do this from the render tree (matching
886 // RenderTextView), but it's not possible to do it at the moment 886 // RenderTextView), but it's not possible to do it at the moment
887 // because of the way the code is structured. 887 // because of the way the code is structured.
888 if (renderer()) { 888 if (renderer()) {
889 if (AXObjectCache* cache = renderer()->document()->existingAXObjectCache ()) 889 if (AXObjectCache* cache = renderer()->document().existingAXObjectCache( ))
890 cache->checkedStateChanged(this); 890 cache->checkedStateChanged(this);
891 } 891 }
892 892
893 // Only send a change event for items in the document (avoid firing during 893 // Only send a change event for items in the document (avoid firing during
894 // parsing) and don't send a change event for a radio button that's getting 894 // parsing) and don't send a change event for a radio button that's getting
895 // unchecked to match other browsers. DOM is not a useful standard for this 895 // unchecked to match other browsers. DOM is not a useful standard for this
896 // because it says only to fire change events at "lose focus" time, which is 896 // because it says only to fire change events at "lose focus" time, which is
897 // definitely wrong in practice for these types of elements. 897 // definitely wrong in practice for these types of elements.
898 if (eventBehavior != DispatchNoEvent && inDocument() && m_inputType->shouldS endChangeEventAfterCheckedChanged()) { 898 if (eventBehavior != DispatchNoEvent && inDocument() && m_inputType->shouldS endChangeEventAfterCheckedChanged()) {
899 setTextAsOfLastFormControlChangeEvent(String()); 899 setTextAsOfLastFormControlChangeEvent(String());
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 void HTMLInputElement::setSize(unsigned size, ExceptionState& es) 1314 void HTMLInputElement::setSize(unsigned size, ExceptionState& es)
1315 { 1315 {
1316 if (!size) 1316 if (!size)
1317 es.throwDOMException(IndexSizeError); 1317 es.throwDOMException(IndexSizeError);
1318 else 1318 else
1319 setSize(size); 1319 setSize(size);
1320 } 1320 }
1321 1321
1322 KURL HTMLInputElement::src() const 1322 KURL HTMLInputElement::src() const
1323 { 1323 {
1324 return document()->completeURL(fastGetAttribute(srcAttr)); 1324 return document().completeURL(fastGetAttribute(srcAttr));
1325 } 1325 }
1326 1326
1327 void HTMLInputElement::setAutofilled(bool autofilled) 1327 void HTMLInputElement::setAutofilled(bool autofilled)
1328 { 1328 {
1329 if (autofilled == m_isAutofilled) 1329 if (autofilled == m_isAutofilled)
1330 return; 1330 return;
1331 1331
1332 m_isAutofilled = autofilled; 1332 m_isAutofilled = autofilled;
1333 setNeedsStyleRecalc(); 1333 setNeedsStyleRecalc();
1334 } 1334 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 imageLoader()->elementDidMoveToNewDocument(); 1460 imageLoader()->elementDidMoveToNewDocument();
1461 1461
1462 if (oldDocument) { 1462 if (oldDocument) {
1463 if (isRadioButton()) 1463 if (isRadioButton())
1464 oldDocument->formController()->checkedRadioButtons().removeButton(th is); 1464 oldDocument->formController()->checkedRadioButtons().removeButton(th is);
1465 if (m_hasTouchEventHandler) 1465 if (m_hasTouchEventHandler)
1466 oldDocument->didRemoveEventTargetNode(this); 1466 oldDocument->didRemoveEventTargetNode(this);
1467 } 1467 }
1468 1468
1469 if (m_hasTouchEventHandler) 1469 if (m_hasTouchEventHandler)
1470 document()->didAddTouchEventHandler(this); 1470 document().didAddTouchEventHandler(this);
1471 1471
1472 HTMLTextFormControlElement::didMoveToNewDocument(oldDocument); 1472 HTMLTextFormControlElement::didMoveToNewDocument(oldDocument);
1473 } 1473 }
1474 1474
1475 void HTMLInputElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) cons t 1475 void HTMLInputElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) cons t
1476 { 1476 {
1477 HTMLTextFormControlElement::addSubresourceAttributeURLs(urls); 1477 HTMLTextFormControlElement::addSubresourceAttributeURLs(urls);
1478 1478
1479 addSubresourceURL(urls, src()); 1479 addSubresourceURL(urls, src());
1480 } 1480 }
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 bool HTMLInputElement::capture() const 1716 bool HTMLInputElement::capture() const
1717 { 1717 {
1718 if (!isFileUpload() || !fastHasAttribute(captureAttr)) 1718 if (!isFileUpload() || !fastHasAttribute(captureAttr))
1719 return false; 1719 return false;
1720 1720
1721 // As per crbug.com/240252, emit a deprecation warning when the "capture" 1721 // As per crbug.com/240252, emit a deprecation warning when the "capture"
1722 // attribute is used as an enum. The spec has been updated and "capture" is 1722 // attribute is used as an enum. The spec has been updated and "capture" is
1723 // supposed to be used as a boolean. 1723 // supposed to be used as a boolean.
1724 bool hasDeprecatedUsage = !fastGetAttribute(captureAttr).isNull(); 1724 bool hasDeprecatedUsage = !fastGetAttribute(captureAttr).isNull();
1725 if (hasDeprecatedUsage) 1725 if (hasDeprecatedUsage)
1726 UseCounter::countDeprecation(document(), UseCounter::CaptureAttributeAsE num); 1726 UseCounter::countDeprecation(&document(), UseCounter::CaptureAttributeAs Enum);
1727 else 1727 else
1728 UseCounter::count(document(), UseCounter::CaptureAttributeAsEnum); 1728 UseCounter::count(&document(), UseCounter::CaptureAttributeAsEnum);
1729 1729
1730 return true; 1730 return true;
1731 } 1731 }
1732 #endif 1732 #endif
1733 1733
1734 bool HTMLInputElement::isInRequiredRadioButtonGroup() 1734 bool HTMLInputElement::isInRequiredRadioButtonGroup()
1735 { 1735 {
1736 ASSERT(isRadioButton()); 1736 ASSERT(isRadioButton());
1737 if (CheckedRadioButtons* buttons = checkedRadioButtons()) 1737 if (CheckedRadioButtons* buttons = checkedRadioButtons())
1738 return buttons->isInRequiredGroup(this); 1738 return buttons->isInRequiredGroup(this);
1739 return false; 1739 return false;
1740 } 1740 }
1741 1741
1742 HTMLInputElement* HTMLInputElement::checkedRadioButtonForGroup() const 1742 HTMLInputElement* HTMLInputElement::checkedRadioButtonForGroup() const
1743 { 1743 {
1744 if (CheckedRadioButtons* buttons = checkedRadioButtons()) 1744 if (CheckedRadioButtons* buttons = checkedRadioButtons())
1745 return buttons->checkedButtonForGroup(name()); 1745 return buttons->checkedButtonForGroup(name());
1746 return 0; 1746 return 0;
1747 } 1747 }
1748 1748
1749 CheckedRadioButtons* HTMLInputElement::checkedRadioButtons() const 1749 CheckedRadioButtons* HTMLInputElement::checkedRadioButtons() const
1750 { 1750 {
1751 if (!isRadioButton()) 1751 if (!isRadioButton())
1752 return 0; 1752 return 0;
1753 if (HTMLFormElement* formElement = form()) 1753 if (HTMLFormElement* formElement = form())
1754 return &formElement->checkedRadioButtons(); 1754 return &formElement->checkedRadioButtons();
1755 if (inDocument()) 1755 if (inDocument())
1756 return &document()->formController()->checkedRadioButtons(); 1756 return &document().formController()->checkedRadioButtons();
1757 return 0; 1757 return 0;
1758 } 1758 }
1759 1759
1760 inline void HTMLInputElement::addToRadioButtonGroup() 1760 inline void HTMLInputElement::addToRadioButtonGroup()
1761 { 1761 {
1762 if (CheckedRadioButtons* buttons = checkedRadioButtons()) 1762 if (CheckedRadioButtons* buttons = checkedRadioButtons())
1763 buttons->addButton(this); 1763 buttons->addButton(this);
1764 } 1764 }
1765 1765
1766 inline void HTMLInputElement::removeFromRadioButtonGroup() 1766 inline void HTMLInputElement::removeFromRadioButtonGroup()
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 if (!m_inputType->supportsSelectionAPI()) { 1820 if (!m_inputType->supportsSelectionAPI()) {
1821 es.throwDOMException(InvalidStateError); 1821 es.throwDOMException(InvalidStateError);
1822 return; 1822 return;
1823 } 1823 }
1824 1824
1825 HTMLTextFormControlElement::setRangeText(replacement, start, end, selectionM ode, es); 1825 HTMLTextFormControlElement::setRangeText(replacement, start, end, selectionM ode, es);
1826 } 1826 }
1827 1827
1828 bool HTMLInputElement::setupDateTimeChooserParameters(DateTimeChooserParameters& parameters) 1828 bool HTMLInputElement::setupDateTimeChooserParameters(DateTimeChooserParameters& parameters)
1829 { 1829 {
1830 if (!document()->view()) 1830 if (!document().view())
1831 return false; 1831 return false;
1832 1832
1833 parameters.type = type(); 1833 parameters.type = type();
1834 parameters.minimum = minimum(); 1834 parameters.minimum = minimum();
1835 parameters.maximum = maximum(); 1835 parameters.maximum = maximum();
1836 parameters.required = isRequired(); 1836 parameters.required = isRequired();
1837 if (!RuntimeEnabledFeatures::langAttributeAwareFormControlUIEnabled()) 1837 if (!RuntimeEnabledFeatures::langAttributeAwareFormControlUIEnabled())
1838 parameters.locale = defaultLanguage(); 1838 parameters.locale = defaultLanguage();
1839 else { 1839 else {
1840 AtomicString computedLocale = computeInheritedLanguage(); 1840 AtomicString computedLocale = computeInheritedLanguage();
1841 parameters.locale = computedLocale.isEmpty() ? AtomicString(defaultLangu age()) : computedLocale; 1841 parameters.locale = computedLocale.isEmpty() ? AtomicString(defaultLangu age()) : computedLocale;
1842 } 1842 }
1843 1843
1844 StepRange stepRange = createStepRange(RejectAny); 1844 StepRange stepRange = createStepRange(RejectAny);
1845 if (stepRange.hasStep()) { 1845 if (stepRange.hasStep()) {
1846 parameters.step = stepRange.step().toDouble(); 1846 parameters.step = stepRange.step().toDouble();
1847 parameters.stepBase = stepRange.stepBase().toDouble(); 1847 parameters.stepBase = stepRange.stepBase().toDouble();
1848 } else { 1848 } else {
1849 parameters.step = 1.0; 1849 parameters.step = 1.0;
1850 parameters.stepBase = 0; 1850 parameters.stepBase = 0;
1851 } 1851 }
1852 1852
1853 parameters.anchorRectInRootView = document()->view()->contentsToRootView(pix elSnappedBoundingBox()); 1853 parameters.anchorRectInRootView = document().view()->contentsToRootView(pixe lSnappedBoundingBox());
1854 parameters.currentValue = value(); 1854 parameters.currentValue = value();
1855 parameters.isAnchorElementRTL = computedStyle()->direction() == RTL; 1855 parameters.isAnchorElementRTL = computedStyle()->direction() == RTL;
1856 if (RuntimeEnabledFeatures::dataListElementEnabled()) { 1856 if (RuntimeEnabledFeatures::dataListElementEnabled()) {
1857 if (HTMLDataListElement* dataList = this->dataList()) { 1857 if (HTMLDataListElement* dataList = this->dataList()) {
1858 RefPtr<HTMLCollection> options = dataList->options(); 1858 RefPtr<HTMLCollection> options = dataList->options();
1859 for (unsigned i = 0; HTMLOptionElement* option = toHTMLOptionElement (options->item(i)); ++i) { 1859 for (unsigned i = 0; HTMLOptionElement* option = toHTMLOptionElement (options->item(i)); ++i) {
1860 if (!isValidValue(option->value())) 1860 if (!isValidValue(option->value()))
1861 continue; 1861 continue;
1862 parameters.suggestionValues.append(sanitizeValue(option->value() )); 1862 parameters.suggestionValues.append(sanitizeValue(option->value() ));
1863 parameters.localizedSuggestionValues.append(localizeValue(option ->value())); 1863 parameters.localizedSuggestionValues.append(localizeValue(option ->value()));
(...skipping 10 matching lines...) Expand all
1874 } 1874 }
1875 1875
1876 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) 1876 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
1877 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer() 1877 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer()
1878 { 1878 {
1879 return m_inputTypeView->customStyleForRenderer(originalStyleForRenderer()); 1879 return m_inputTypeView->customStyleForRenderer(originalStyleForRenderer());
1880 } 1880 }
1881 #endif 1881 #endif
1882 1882
1883 } // namespace 1883 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/HTMLImageElement.cpp ('k') | Source/core/html/HTMLKeygenElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698