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

Side by Side Diff: Source/core/html/forms/BaseChooserOnlyDateAndTimeInputType.cpp

Issue 27746003: Have InputType factories take an HTMLInputElement reference in parameter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 2 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
OLDNEW
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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 26 matching lines...) Expand all
37 37
38 namespace WebCore { 38 namespace WebCore {
39 39
40 BaseChooserOnlyDateAndTimeInputType::~BaseChooserOnlyDateAndTimeInputType() 40 BaseChooserOnlyDateAndTimeInputType::~BaseChooserOnlyDateAndTimeInputType()
41 { 41 {
42 closeDateTimeChooser(); 42 closeDateTimeChooser();
43 } 43 }
44 44
45 void BaseChooserOnlyDateAndTimeInputType::handleDOMActivateEvent(Event*) 45 void BaseChooserOnlyDateAndTimeInputType::handleDOMActivateEvent(Event*)
46 { 46 {
47 if (element()->isDisabledOrReadOnly() || !element()->renderer() || !UserGest ureIndicator::processingUserGesture() || element()->hasAuthorShadowRoot()) 47 if (element().isDisabledOrReadOnly() || !element().renderer() || !UserGestur eIndicator::processingUserGesture() || element().hasAuthorShadowRoot())
48 return; 48 return;
49 49
50 if (m_dateTimeChooser) 50 if (m_dateTimeChooser)
51 return; 51 return;
52 if (!element()->document().page()) 52 if (!element().document().page())
53 return; 53 return;
54 DateTimeChooserParameters parameters; 54 DateTimeChooserParameters parameters;
55 if (!element()->setupDateTimeChooserParameters(parameters)) 55 if (!element().setupDateTimeChooserParameters(parameters))
56 return; 56 return;
57 m_dateTimeChooser = element()->document().page()->chrome().openDateTimeChoos er(this, parameters); 57 m_dateTimeChooser = element().document().page()->chrome().openDateTimeChoose r(this, parameters);
58 } 58 }
59 59
60 void BaseChooserOnlyDateAndTimeInputType::createShadowSubtree() 60 void BaseChooserOnlyDateAndTimeInputType::createShadowSubtree()
61 { 61 {
62 DEFINE_STATIC_LOCAL(AtomicString, valueContainerPseudo, ("-webkit-date-and-t ime-value", AtomicString::ConstructFromLiteral)); 62 DEFINE_STATIC_LOCAL(AtomicString, valueContainerPseudo, ("-webkit-date-and-t ime-value", AtomicString::ConstructFromLiteral));
63 63
64 RefPtr<HTMLDivElement> valueContainer = HTMLDivElement::create(element()->do cument()); 64 RefPtr<HTMLDivElement> valueContainer = HTMLDivElement::create(element().doc ument());
65 valueContainer->setPart(valueContainerPseudo); 65 valueContainer->setPart(valueContainerPseudo);
66 element()->userAgentShadowRoot()->appendChild(valueContainer.get()); 66 element().userAgentShadowRoot()->appendChild(valueContainer.get());
67 updateAppearance(); 67 updateAppearance();
68 } 68 }
69 69
70 void BaseChooserOnlyDateAndTimeInputType::updateAppearance() 70 void BaseChooserOnlyDateAndTimeInputType::updateAppearance()
71 { 71 {
72 Node* node = element()->userAgentShadowRoot()->firstChild(); 72 Node* node = element().userAgentShadowRoot()->firstChild();
73 if (!node || !node->isHTMLElement()) 73 if (!node || !node->isHTMLElement())
74 return; 74 return;
75 String displayValue = visibleValue(); 75 String displayValue = visibleValue();
76 if (displayValue.isEmpty()) { 76 if (displayValue.isEmpty()) {
77 // Need to put something to keep text baseline. 77 // Need to put something to keep text baseline.
78 displayValue = " "; 78 displayValue = " ";
79 } 79 }
80 toHTMLElement(node)->setInnerText(displayValue, ASSERT_NO_EXCEPTION); 80 toHTMLElement(node)->setInnerText(displayValue, ASSERT_NO_EXCEPTION);
81 } 81 }
82 82
83 void BaseChooserOnlyDateAndTimeInputType::setValue(const String& value, bool val ueChanged, TextFieldEventBehavior eventBehavior) 83 void BaseChooserOnlyDateAndTimeInputType::setValue(const String& value, bool val ueChanged, TextFieldEventBehavior eventBehavior)
84 { 84 {
85 BaseDateAndTimeInputType::setValue(value, valueChanged, eventBehavior); 85 BaseDateAndTimeInputType::setValue(value, valueChanged, eventBehavior);
86 if (valueChanged) 86 if (valueChanged)
87 updateAppearance(); 87 updateAppearance();
88 } 88 }
89 89
90 void BaseChooserOnlyDateAndTimeInputType::detach() 90 void BaseChooserOnlyDateAndTimeInputType::detach()
91 { 91 {
92 closeDateTimeChooser(); 92 closeDateTimeChooser();
93 } 93 }
94 94
95 void BaseChooserOnlyDateAndTimeInputType::didChooseValue(const String& value) 95 void BaseChooserOnlyDateAndTimeInputType::didChooseValue(const String& value)
96 { 96 {
97 element()->setValue(value, DispatchInputAndChangeEvent); 97 element().setValue(value, DispatchInputAndChangeEvent);
98 } 98 }
99 99
100 void BaseChooserOnlyDateAndTimeInputType::didEndChooser() 100 void BaseChooserOnlyDateAndTimeInputType::didEndChooser()
101 { 101 {
102 m_dateTimeChooser.clear(); 102 m_dateTimeChooser.clear();
103 } 103 }
104 104
105 void BaseChooserOnlyDateAndTimeInputType::closeDateTimeChooser() 105 void BaseChooserOnlyDateAndTimeInputType::closeDateTimeChooser()
106 { 106 {
107 if (m_dateTimeChooser) 107 if (m_dateTimeChooser)
(...skipping 16 matching lines...) Expand all
124 } 124 }
125 125
126 void BaseChooserOnlyDateAndTimeInputType::accessKeyAction(bool sendMouseEvents) 126 void BaseChooserOnlyDateAndTimeInputType::accessKeyAction(bool sendMouseEvents)
127 { 127 {
128 BaseDateAndTimeInputType::accessKeyAction(sendMouseEvents); 128 BaseDateAndTimeInputType::accessKeyAction(sendMouseEvents);
129 BaseClickableWithKeyInputType::accessKeyAction(element(), sendMouseEvents); 129 BaseClickableWithKeyInputType::accessKeyAction(element(), sendMouseEvents);
130 } 130 }
131 131
132 } 132 }
133 #endif 133 #endif
OLDNEW
« no previous file with comments | « Source/core/html/forms/BaseChooserOnlyDateAndTimeInputType.h ('k') | Source/core/html/forms/BaseClickableWithKeyInputType.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698