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

Side by Side Diff: Source/core/html/forms/PasswordInputType.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
« no previous file with comments | « Source/core/html/forms/PasswordInputType.h ('k') | Source/core/html/forms/RadioInputType.h » ('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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 29 matching lines...) Expand all
40 #include "core/html/forms/InputTypeNames.h" 40 #include "core/html/forms/InputTypeNames.h"
41 #include "core/page/Chrome.h" 41 #include "core/page/Chrome.h"
42 #include "core/page/ChromeClient.h" 42 #include "core/page/ChromeClient.h"
43 #include "core/page/Page.h" 43 #include "core/page/Page.h"
44 #include "core/page/Settings.h" 44 #include "core/page/Settings.h"
45 #include "wtf/Assertions.h" 45 #include "wtf/Assertions.h"
46 #include "wtf/PassOwnPtr.h" 46 #include "wtf/PassOwnPtr.h"
47 47
48 namespace WebCore { 48 namespace WebCore {
49 49
50 PassRefPtr<InputType> PasswordInputType::create(HTMLInputElement* element) 50 PassRefPtr<InputType> PasswordInputType::create(HTMLInputElement& element)
51 { 51 {
52 return adoptRef(new PasswordInputType(element)); 52 return adoptRef(new PasswordInputType(element));
53 } 53 }
54 54
55 HTMLElement* PasswordInputType::passwordGeneratorButtonElement() const 55 HTMLElement* PasswordInputType::passwordGeneratorButtonElement() const
56 { 56 {
57 return m_generatorButton.get(); 57 return m_generatorButton.get();
58 } 58 }
59 59
60 bool PasswordInputType::isPasswordGenerationEnabled() const 60 bool PasswordInputType::isPasswordGenerationEnabled() const
61 { 61 {
62 if (isPasswordGenerationDecorationEnabled()) 62 if (isPasswordGenerationDecorationEnabled())
63 return true; 63 return true;
64 if (Page* page = element()->document().page()) 64 if (Page* page = element().document().page())
65 return page->chrome().client().isPasswordGenerationEnabled(); 65 return page->chrome().client().isPasswordGenerationEnabled();
66 return false; 66 return false;
67 } 67 }
68 68
69 bool PasswordInputType::isPasswordGenerationDecorationEnabled() const 69 bool PasswordInputType::isPasswordGenerationDecorationEnabled() const
70 { 70 {
71 if (Page* page = element()->document().page()) 71 if (Page* page = element().document().page())
72 return page->settings().passwordGenerationDecorationEnabled(); 72 return page->settings().passwordGenerationDecorationEnabled();
73 return false; 73 return false;
74 } 74 }
75 75
76 bool PasswordInputType::needsContainer() const 76 bool PasswordInputType::needsContainer() const
77 { 77 {
78 return BaseTextInputType::needsContainer() || isPasswordGenerationEnabled(); 78 return BaseTextInputType::needsContainer() || isPasswordGenerationEnabled();
79 } 79 }
80 80
81 void PasswordInputType::createShadowSubtree() 81 void PasswordInputType::createShadowSubtree()
82 { 82 {
83 BaseTextInputType::createShadowSubtree(); 83 BaseTextInputType::createShadowSubtree();
84 if (!isPasswordGenerationEnabled()) 84 if (!isPasswordGenerationEnabled())
85 return; 85 return;
86 ShadowRoot* root = element()->userAgentShadowRoot(); 86 ShadowRoot* root = element().userAgentShadowRoot();
87 RefPtr<HTMLDivElement> wrapper = HTMLDivElement::create(element()->document( )); 87 RefPtr<HTMLDivElement> wrapper = HTMLDivElement::create(element().document() );
88 wrapper->setInlineStyleProperty(CSSPropertyDisplay, CSSValueFlex); 88 wrapper->setInlineStyleProperty(CSSPropertyDisplay, CSSValueFlex);
89 wrapper->setInlineStyleProperty(CSSPropertyAlignItems, CSSValueCenter); 89 wrapper->setInlineStyleProperty(CSSPropertyAlignItems, CSSValueCenter);
90 ASSERT(root->childNodeCount() == 1); 90 ASSERT(root->childNodeCount() == 1);
91 root->firstElementChild()->setInlineStyleProperty(CSSPropertyFlexGrow, 1.0, CSSPrimitiveValue::CSS_NUMBER); 91 root->firstElementChild()->setInlineStyleProperty(CSSPropertyFlexGrow, 1.0, CSSPrimitiveValue::CSS_NUMBER);
92 wrapper->appendChild(root->firstElementChild()); 92 wrapper->appendChild(root->firstElementChild());
93 m_generatorButton = PasswordGeneratorButtonElement::create(element()->docume nt()); 93 m_generatorButton = PasswordGeneratorButtonElement::create(element().documen t());
94 if (!isPasswordGenerationDecorationEnabled()) 94 if (!isPasswordGenerationDecorationEnabled())
95 m_generatorButton->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNo ne); 95 m_generatorButton->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNo ne);
96 wrapper->appendChild(m_generatorButton.get()); 96 wrapper->appendChild(m_generatorButton.get());
97 element()->userAgentShadowRoot()->appendChild(wrapper); 97 element().userAgentShadowRoot()->appendChild(wrapper);
98 } 98 }
99 99
100 void PasswordInputType::destroyShadowSubtree() 100 void PasswordInputType::destroyShadowSubtree()
101 { 101 {
102 BaseTextInputType::destroyShadowSubtree(); 102 BaseTextInputType::destroyShadowSubtree();
103 m_generatorButton = 0; 103 m_generatorButton = 0;
104 } 104 }
105 105
106 const AtomicString& PasswordInputType::formControlType() const 106 const AtomicString& PasswordInputType::formControlType() const
107 { 107 {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return true; 148 return true;
149 } 149 }
150 150
151 bool PasswordInputType::isPasswordField() const 151 bool PasswordInputType::isPasswordField() const
152 { 152 {
153 return true; 153 return true;
154 } 154 }
155 155
156 void PasswordInputType::enableSecureTextInput() 156 void PasswordInputType::enableSecureTextInput()
157 { 157 {
158 if (element()->document().frame()) 158 if (element().document().frame())
159 element()->document().setUseSecureKeyboardEntryWhenActive(true); 159 element().document().setUseSecureKeyboardEntryWhenActive(true);
160 } 160 }
161 161
162 void PasswordInputType::disableSecureTextInput() 162 void PasswordInputType::disableSecureTextInput()
163 { 163 {
164 if (element()->document().frame()) 164 if (element().document().frame())
165 element()->document().setUseSecureKeyboardEntryWhenActive(false); 165 element().document().setUseSecureKeyboardEntryWhenActive(false);
166 } 166 }
167 167
168 } // namespace WebCore 168 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/forms/PasswordInputType.h ('k') | Source/core/html/forms/RadioInputType.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698