| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2010 Google 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 | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "core/page/Frame.h" | 41 #include "core/page/Frame.h" |
| 42 #include "core/page/SpeechInput.h" | 42 #include "core/page/SpeechInput.h" |
| 43 #include "core/page/SpeechInputEvent.h" | 43 #include "core/page/SpeechInputEvent.h" |
| 44 #include "core/rendering/RenderTextControlSingleLine.h" | 44 #include "core/rendering/RenderTextControlSingleLine.h" |
| 45 #include "core/rendering/RenderView.h" | 45 #include "core/rendering/RenderView.h" |
| 46 | 46 |
| 47 namespace WebCore { | 47 namespace WebCore { |
| 48 | 48 |
| 49 using namespace HTMLNames; | 49 using namespace HTMLNames; |
| 50 | 50 |
| 51 TextControlInnerContainer::TextControlInnerContainer(Document* document) | 51 TextControlInnerContainer::TextControlInnerContainer(Document& document) |
| 52 : HTMLDivElement(divTag, document) | 52 : HTMLDivElement(divTag, document) |
| 53 { | 53 { |
| 54 } | 54 } |
| 55 | 55 |
| 56 PassRefPtr<TextControlInnerContainer> TextControlInnerContainer::create(Document
* document) | 56 PassRefPtr<TextControlInnerContainer> TextControlInnerContainer::create(Document
& document) |
| 57 { | 57 { |
| 58 return adoptRef(new TextControlInnerContainer(document)); | 58 return adoptRef(new TextControlInnerContainer(document)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 RenderObject* TextControlInnerContainer::createRenderer(RenderStyle*) | 61 RenderObject* TextControlInnerContainer::createRenderer(RenderStyle*) |
| 62 { | 62 { |
| 63 return new RenderTextControlInnerContainer(this); | 63 return new RenderTextControlInnerContainer(this); |
| 64 } | 64 } |
| 65 | 65 |
| 66 TextControlInnerElement::TextControlInnerElement(Document* document) | 66 TextControlInnerElement::TextControlInnerElement(Document& document) |
| 67 : HTMLDivElement(divTag, document) | 67 : HTMLDivElement(divTag, document) |
| 68 { | 68 { |
| 69 setHasCustomStyleCallbacks(); | 69 setHasCustomStyleCallbacks(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 PassRefPtr<TextControlInnerElement> TextControlInnerElement::create(Document* do
cument) | 72 PassRefPtr<TextControlInnerElement> TextControlInnerElement::create(Document& do
cument) |
| 73 { | 73 { |
| 74 return adoptRef(new TextControlInnerElement(document)); | 74 return adoptRef(new TextControlInnerElement(document)); |
| 75 } | 75 } |
| 76 | 76 |
| 77 PassRefPtr<RenderStyle> TextControlInnerElement::customStyleForRenderer() | 77 PassRefPtr<RenderStyle> TextControlInnerElement::customStyleForRenderer() |
| 78 { | 78 { |
| 79 // FXIME: Move these styles to html.css. | 79 // FXIME: Move these styles to html.css. |
| 80 | 80 |
| 81 RefPtr<RenderStyle> innerBlockStyle = RenderStyle::create(); | 81 RefPtr<RenderStyle> innerBlockStyle = RenderStyle::create(); |
| 82 innerBlockStyle->inheritFrom(shadowHost()->renderStyle()); | 82 innerBlockStyle->inheritFrom(shadowHost()->renderStyle()); |
| 83 | 83 |
| 84 innerBlockStyle->setFlexGrow(1); | 84 innerBlockStyle->setFlexGrow(1); |
| 85 // min-width: 0; is needed for correct shrinking. | 85 // min-width: 0; is needed for correct shrinking. |
| 86 // FIXME: Remove this line when https://bugs.webkit.org/show_bug.cgi?id=1117
90 is fixed. | 86 // FIXME: Remove this line when https://bugs.webkit.org/show_bug.cgi?id=1117
90 is fixed. |
| 87 innerBlockStyle->setMinWidth(Length(0, Fixed)); | 87 innerBlockStyle->setMinWidth(Length(0, Fixed)); |
| 88 innerBlockStyle->setDisplay(BLOCK); | 88 innerBlockStyle->setDisplay(BLOCK); |
| 89 innerBlockStyle->setDirection(LTR); | 89 innerBlockStyle->setDirection(LTR); |
| 90 | 90 |
| 91 // We don't want the shadow dom to be editable, so we set this block to | 91 // We don't want the shadow dom to be editable, so we set this block to |
| 92 // read-only in case the input itself is editable. | 92 // read-only in case the input itself is editable. |
| 93 innerBlockStyle->setUserModify(READ_ONLY); | 93 innerBlockStyle->setUserModify(READ_ONLY); |
| 94 | 94 |
| 95 return innerBlockStyle.release(); | 95 return innerBlockStyle.release(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 // --------------------------- | 98 // --------------------------- |
| 99 | 99 |
| 100 inline TextControlInnerTextElement::TextControlInnerTextElement(Document* docume
nt) | 100 inline TextControlInnerTextElement::TextControlInnerTextElement(Document& docume
nt) |
| 101 : HTMLDivElement(divTag, document) | 101 : HTMLDivElement(divTag, document) |
| 102 { | 102 { |
| 103 setHasCustomStyleCallbacks(); | 103 setHasCustomStyleCallbacks(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 PassRefPtr<TextControlInnerTextElement> TextControlInnerTextElement::create(Docu
ment* document) | 106 PassRefPtr<TextControlInnerTextElement> TextControlInnerTextElement::create(Docu
ment& document) |
| 107 { | 107 { |
| 108 return adoptRef(new TextControlInnerTextElement(document)); | 108 return adoptRef(new TextControlInnerTextElement(document)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void TextControlInnerTextElement::defaultEventHandler(Event* event) | 111 void TextControlInnerTextElement::defaultEventHandler(Event* event) |
| 112 { | 112 { |
| 113 // FIXME: In the future, we should add a way to have default event listeners
. | 113 // FIXME: In the future, we should add a way to have default event listeners
. |
| 114 // Then we would add one to the text field's inner div, and we wouldn't need
this subclass. | 114 // Then we would add one to the text field's inner div, and we wouldn't need
this subclass. |
| 115 // Or possibly we could just use a normal event listener. | 115 // Or possibly we could just use a normal event listener. |
| 116 if (event->isBeforeTextInsertedEvent() || event->type() == eventNames().webk
itEditableContentChangedEvent) { | 116 if (event->isBeforeTextInsertedEvent() || event->type() == eventNames().webk
itEditableContentChangedEvent) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 136 { | 136 { |
| 137 RenderObject* parentRenderer = shadowHost()->renderer(); | 137 RenderObject* parentRenderer = shadowHost()->renderer(); |
| 138 if (!parentRenderer || !parentRenderer->isTextControl()) | 138 if (!parentRenderer || !parentRenderer->isTextControl()) |
| 139 return originalStyleForRenderer(); | 139 return originalStyleForRenderer(); |
| 140 RenderTextControl* textControlRenderer = toRenderTextControl(parentRenderer)
; | 140 RenderTextControl* textControlRenderer = toRenderTextControl(parentRenderer)
; |
| 141 return textControlRenderer->createInnerTextStyle(textControlRenderer->style(
)); | 141 return textControlRenderer->createInnerTextStyle(textControlRenderer->style(
)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 // ---------------------------- | 144 // ---------------------------- |
| 145 | 145 |
| 146 inline SearchFieldDecorationElement::SearchFieldDecorationElement(Document* docu
ment) | 146 inline SearchFieldDecorationElement::SearchFieldDecorationElement(Document& docu
ment) |
| 147 : HTMLDivElement(divTag, document) | 147 : HTMLDivElement(divTag, document) |
| 148 { | 148 { |
| 149 } | 149 } |
| 150 | 150 |
| 151 PassRefPtr<SearchFieldDecorationElement> SearchFieldDecorationElement::create(Do
cument* document) | 151 PassRefPtr<SearchFieldDecorationElement> SearchFieldDecorationElement::create(Do
cument& document) |
| 152 { | 152 { |
| 153 RefPtr<SearchFieldDecorationElement> element = adoptRef(new SearchFieldDecor
ationElement(document)); | 153 RefPtr<SearchFieldDecorationElement> element = adoptRef(new SearchFieldDecor
ationElement(document)); |
| 154 element->setAttribute(idAttr, ShadowElementNames::searchDecoration()); | 154 element->setAttribute(idAttr, ShadowElementNames::searchDecoration()); |
| 155 return element.release(); | 155 return element.release(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 const AtomicString& SearchFieldDecorationElement::part() const | 158 const AtomicString& SearchFieldDecorationElement::part() const |
| 159 { | 159 { |
| 160 DEFINE_STATIC_LOCAL(AtomicString, resultsDecorationId, ("-webkit-search-resu
lts-decoration", AtomicString::ConstructFromLiteral)); | 160 DEFINE_STATIC_LOCAL(AtomicString, resultsDecorationId, ("-webkit-search-resu
lts-decoration", AtomicString::ConstructFromLiteral)); |
| 161 DEFINE_STATIC_LOCAL(AtomicString, decorationId, ("-webkit-search-decoration"
, AtomicString::ConstructFromLiteral)); | 161 DEFINE_STATIC_LOCAL(AtomicString, decorationId, ("-webkit-search-decoration"
, AtomicString::ConstructFromLiteral)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 184 HTMLDivElement::defaultEventHandler(event); | 184 HTMLDivElement::defaultEventHandler(event); |
| 185 } | 185 } |
| 186 | 186 |
| 187 bool SearchFieldDecorationElement::willRespondToMouseClickEvents() | 187 bool SearchFieldDecorationElement::willRespondToMouseClickEvents() |
| 188 { | 188 { |
| 189 return true; | 189 return true; |
| 190 } | 190 } |
| 191 | 191 |
| 192 // ---------------------------- | 192 // ---------------------------- |
| 193 | 193 |
| 194 inline SearchFieldCancelButtonElement::SearchFieldCancelButtonElement(Document*
document) | 194 inline SearchFieldCancelButtonElement::SearchFieldCancelButtonElement(Document&
document) |
| 195 : HTMLDivElement(divTag, document) | 195 : HTMLDivElement(divTag, document) |
| 196 , m_capturing(false) | 196 , m_capturing(false) |
| 197 { | 197 { |
| 198 } | 198 } |
| 199 | 199 |
| 200 PassRefPtr<SearchFieldCancelButtonElement> SearchFieldCancelButtonElement::creat
e(Document* document) | 200 PassRefPtr<SearchFieldCancelButtonElement> SearchFieldCancelButtonElement::creat
e(Document& document) |
| 201 { | 201 { |
| 202 RefPtr<SearchFieldCancelButtonElement> element = adoptRef(new SearchFieldCan
celButtonElement(document)); | 202 RefPtr<SearchFieldCancelButtonElement> element = adoptRef(new SearchFieldCan
celButtonElement(document)); |
| 203 element->setPart(AtomicString("-webkit-search-cancel-button", AtomicString::
ConstructFromLiteral)); | 203 element->setPart(AtomicString("-webkit-search-cancel-button", AtomicString::
ConstructFromLiteral)); |
| 204 element->setAttribute(idAttr, ShadowElementNames::clearButton()); | 204 element->setAttribute(idAttr, ShadowElementNames::clearButton()); |
| 205 return element.release(); | 205 return element.release(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void SearchFieldCancelButtonElement::detach(const AttachContext& context) | 208 void SearchFieldCancelButtonElement::detach(const AttachContext& context) |
| 209 { | 209 { |
| 210 if (m_capturing) { | 210 if (m_capturing) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 if (input && !input->isDisabledOrReadOnly()) | 261 if (input && !input->isDisabledOrReadOnly()) |
| 262 return true; | 262 return true; |
| 263 | 263 |
| 264 return HTMLDivElement::willRespondToMouseClickEvents(); | 264 return HTMLDivElement::willRespondToMouseClickEvents(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 // ---------------------------- | 267 // ---------------------------- |
| 268 | 268 |
| 269 #if ENABLE(INPUT_SPEECH) | 269 #if ENABLE(INPUT_SPEECH) |
| 270 | 270 |
| 271 inline InputFieldSpeechButtonElement::InputFieldSpeechButtonElement(Document* do
cument) | 271 inline InputFieldSpeechButtonElement::InputFieldSpeechButtonElement(Document& do
cument) |
| 272 : HTMLDivElement(divTag, document) | 272 : HTMLDivElement(divTag, document) |
| 273 , m_capturing(false) | 273 , m_capturing(false) |
| 274 , m_state(Idle) | 274 , m_state(Idle) |
| 275 , m_listenerId(0) | 275 , m_listenerId(0) |
| 276 { | 276 { |
| 277 } | 277 } |
| 278 | 278 |
| 279 InputFieldSpeechButtonElement::~InputFieldSpeechButtonElement() | 279 InputFieldSpeechButtonElement::~InputFieldSpeechButtonElement() |
| 280 { | 280 { |
| 281 SpeechInput* speech = speechInput(); | 281 SpeechInput* speech = speechInput(); |
| 282 if (speech && m_listenerId) { // Could be null when page is unloading. | 282 if (speech && m_listenerId) { // Could be null when page is unloading. |
| 283 if (m_state != Idle) | 283 if (m_state != Idle) |
| 284 speech->cancelRecognition(m_listenerId); | 284 speech->cancelRecognition(m_listenerId); |
| 285 speech->unregisterListener(m_listenerId); | 285 speech->unregisterListener(m_listenerId); |
| 286 } | 286 } |
| 287 } | 287 } |
| 288 | 288 |
| 289 PassRefPtr<InputFieldSpeechButtonElement> InputFieldSpeechButtonElement::create(
Document* document) | 289 PassRefPtr<InputFieldSpeechButtonElement> InputFieldSpeechButtonElement::create(
Document& document) |
| 290 { | 290 { |
| 291 RefPtr<InputFieldSpeechButtonElement> element = adoptRef(new InputFieldSpeec
hButtonElement(document)); | 291 RefPtr<InputFieldSpeechButtonElement> element = adoptRef(new InputFieldSpeec
hButtonElement(document)); |
| 292 element->setPart(AtomicString("-webkit-input-speech-button", AtomicString::C
onstructFromLiteral)); | 292 element->setPart(AtomicString("-webkit-input-speech-button", AtomicString::C
onstructFromLiteral)); |
| 293 element->setAttribute(idAttr, ShadowElementNames::speechButton()); | 293 element->setAttribute(idAttr, ShadowElementNames::speechButton()); |
| 294 return element.release(); | 294 return element.release(); |
| 295 } | 295 } |
| 296 | 296 |
| 297 void InputFieldSpeechButtonElement::defaultEventHandler(Event* event) | 297 void InputFieldSpeechButtonElement::defaultEventHandler(Event* event) |
| 298 { | 298 { |
| 299 // For privacy reasons, only allow clicks directly coming from the user. | 299 // For privacy reasons, only allow clicks directly coming from the user. |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 } | 456 } |
| 457 | 457 |
| 458 void InputFieldSpeechButtonElement::stopSpeechInput() | 458 void InputFieldSpeechButtonElement::stopSpeechInput() |
| 459 { | 459 { |
| 460 if (m_state == Recording) | 460 if (m_state == Recording) |
| 461 speechInput()->stopRecording(m_listenerId); | 461 speechInput()->stopRecording(m_listenerId); |
| 462 } | 462 } |
| 463 #endif // ENABLE(INPUT_SPEECH) | 463 #endif // ENABLE(INPUT_SPEECH) |
| 464 | 464 |
| 465 } | 465 } |
| OLD | NEW |