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

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

Issue 1420693006: Introduce a struct to store arguments of Element::focus(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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) 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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 bool HTMLInputElement::isKeyboardFocusable() const 333 bool HTMLInputElement::isKeyboardFocusable() const
334 { 334 {
335 return m_inputType->isKeyboardFocusable(); 335 return m_inputType->isKeyboardFocusable();
336 } 336 }
337 337
338 bool HTMLInputElement::shouldShowFocusRingOnMouseFocus() const 338 bool HTMLInputElement::shouldShowFocusRingOnMouseFocus() const
339 { 339 {
340 return m_inputType->shouldShowFocusRingOnMouseFocus(); 340 return m_inputType->shouldShowFocusRingOnMouseFocus();
341 } 341 }
342 342
343 void HTMLInputElement::updateFocusAppearance(bool restorePreviousSelection) 343 void HTMLInputElement::updateFocusAppearance(SelectionBehaviorOnFocus selectionB ehavior)
344 { 344 {
345 if (isTextField()) { 345 if (isTextField()) {
346 if (!restorePreviousSelection) 346 switch (selectionBehavior) {
347 case SelectionBehaviorOnFocus::Reset:
347 select(NotDispatchSelectEvent); 348 select(NotDispatchSelectEvent);
348 else 349 break;
350 case SelectionBehaviorOnFocus::Restore:
349 restoreCachedSelection(); 351 restoreCachedSelection();
352 break;
353 }
350 if (document().frame()) 354 if (document().frame())
351 document().frame()->selection().revealSelection(); 355 document().frame()->selection().revealSelection();
352 } else { 356 } else {
353 HTMLTextFormControlElement::updateFocusAppearance(restorePreviousSelecti on); 357 HTMLTextFormControlElement::updateFocusAppearance(selectionBehavior);
354 } 358 }
355 } 359 }
356 360
357 void HTMLInputElement::beginEditing() 361 void HTMLInputElement::beginEditing()
358 { 362 {
359 ASSERT(document().isActive()); 363 ASSERT(document().isActive());
360 if (!document().isActive()) 364 if (!document().isActive())
361 return; 365 return;
362 366
363 if (!isTextField()) 367 if (!isTextField())
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 AttributeCollection attributes = attributesWithoutUpdate(); 501 AttributeCollection attributes = attributesWithoutUpdate();
498 if (const Attribute* height = attributes.find(heightAttr)) 502 if (const Attribute* height = attributes.find(heightAttr))
499 attributeChanged(heightAttr, height->value()); 503 attributeChanged(heightAttr, height->value());
500 if (const Attribute* width = attributes.find(widthAttr)) 504 if (const Attribute* width = attributes.find(widthAttr))
501 attributeChanged(widthAttr, width->value()); 505 attributeChanged(widthAttr, width->value());
502 if (const Attribute* align = attributes.find(alignAttr)) 506 if (const Attribute* align = attributes.find(alignAttr))
503 attributeChanged(alignAttr, align->value()); 507 attributeChanged(alignAttr, align->value());
504 } 508 }
505 509
506 if (document().focusedElement() == this) 510 if (document().focusedElement() == this)
507 document().updateFocusAppearanceSoon(true /* restore selection */); 511 document().updateFocusAppearanceSoon(SelectionBehaviorOnFocus::Restore);
508 512
509 setTextAsOfLastFormControlChangeEvent(value()); 513 setTextAsOfLastFormControlChangeEvent(value());
510 setChangedSinceLastFormControlChangeEvent(false); 514 setChangedSinceLastFormControlChangeEvent(false);
511 515
512 addToRadioButtonGroup(); 516 addToRadioButtonGroup();
513 517
514 setNeedsValidityCheck(); 518 setNeedsValidityCheck();
515 notifyFormStateChanged(); 519 notifyFormStateChanged();
516 } 520 }
517 521
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 } 828 }
825 829
826 void HTMLInputElement::attach(const AttachContext& context) 830 void HTMLInputElement::attach(const AttachContext& context)
827 { 831 {
828 HTMLTextFormControlElement::attach(context); 832 HTMLTextFormControlElement::attach(context);
829 833
830 m_inputTypeView->startResourceLoading(); 834 m_inputTypeView->startResourceLoading();
831 m_inputType->countUsage(); 835 m_inputType->countUsage();
832 836
833 if (document().focusedElement() == this) 837 if (document().focusedElement() == this)
834 document().updateFocusAppearanceSoon(true /* restore selection */); 838 document().updateFocusAppearanceSoon(SelectionBehaviorOnFocus::Restore);
835 } 839 }
836 840
837 void HTMLInputElement::detach(const AttachContext& context) 841 void HTMLInputElement::detach(const AttachContext& context)
838 { 842 {
839 HTMLTextFormControlElement::detach(context); 843 HTMLTextFormControlElement::detach(context);
840 m_needsToUpdateViewValue = true; 844 m_needsToUpdateViewValue = true;
841 m_inputTypeView->closePopupView(); 845 m_inputTypeView->closePopupView();
842 } 846 }
843 847
844 String HTMLInputElement::altText() const 848 String HTMLInputElement::altText() const
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 void HTMLInputElement::ensurePrimaryContent() 1947 void HTMLInputElement::ensurePrimaryContent()
1944 { 1948 {
1945 m_inputTypeView->ensurePrimaryContent(); 1949 m_inputTypeView->ensurePrimaryContent();
1946 } 1950 }
1947 1951
1948 bool HTMLInputElement::hasFallbackContent() const 1952 bool HTMLInputElement::hasFallbackContent() const
1949 { 1953 {
1950 return m_inputTypeView->hasFallbackContent(); 1954 return m_inputTypeView->hasFallbackContent();
1951 } 1955 }
1952 } // namespace 1956 } // namespace
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLInputElement.h ('k') | third_party/WebKit/Source/core/html/HTMLLabelElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698