OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 void RenderInputSpeech::adjustInputFieldSpeechButtonStyle(RenderStyle* style, El
ement*) | 47 void RenderInputSpeech::adjustInputFieldSpeechButtonStyle(RenderStyle* style, El
ement*) |
48 { | 48 { |
49 // Scale the button size based on the font size. | 49 // Scale the button size based on the font size. |
50 float fontScale = style->fontSize() / defaultControlFontPixelSize; | 50 float fontScale = style->fontSize() / defaultControlFontPixelSize; |
51 int speechButtonSize = lroundf(std::min(std::max(minSpeechButtonSize, defaul
tSpeechButtonSize * fontScale), maxSpeechButtonSize)); | 51 int speechButtonSize = lroundf(std::min(std::max(minSpeechButtonSize, defaul
tSpeechButtonSize * fontScale), maxSpeechButtonSize)); |
52 style->setWidth(Length(speechButtonSize, Fixed)); | 52 style->setWidth(Length(speechButtonSize, Fixed)); |
53 style->setHeight(Length(speechButtonSize, Fixed)); | 53 style->setHeight(Length(speechButtonSize, Fixed)); |
54 } | 54 } |
55 | 55 |
56 bool RenderInputSpeech::paintInputFieldSpeechButton(RenderObject* object, const
PaintInfo& paintInfo, const IntRect& rect) | 56 bool RenderInputSpeech::paintInputFieldSpeechButton(RenderObject* object, PaintI
nfo& paintInfo, const IntRect& rect) |
57 { | 57 { |
58 Element* element = object->node()->isElementNode() ? toElement(object->node(
)) : 0; | 58 Element* element = object->node()->isElementNode() ? toElement(object->node(
)) : 0; |
59 if (!element || !element->isInputFieldSpeechButtonElement()) | 59 if (!element || !element->isInputFieldSpeechButtonElement()) |
60 return false; | 60 return false; |
61 | 61 |
62 // Get the renderer of <input> element. | 62 // Get the renderer of <input> element. |
63 Node* input = object->node()->shadowHost(); | 63 Node* input = object->node()->shadowHost(); |
64 if (!input->renderer()->isBox()) | 64 if (!input->renderer()->isBox()) |
65 return false; | 65 return false; |
66 RenderBox* inputRenderBox = toRenderBox(input->renderer()); | 66 RenderBox* inputRenderBox = toRenderBox(input->renderer()); |
(...skipping 18 matching lines...) Expand all Loading... |
85 DEFINE_STATIC_LOCAL(RefPtr<Image>, imageStateNormal, (Image::loadPlatformRes
ource("inputSpeech"))); | 85 DEFINE_STATIC_LOCAL(RefPtr<Image>, imageStateNormal, (Image::loadPlatformRes
ource("inputSpeech"))); |
86 DEFINE_STATIC_LOCAL(RefPtr<Image>, imageStateRecording, (Image::loadPlatform
Resource("inputSpeechRecording"))); | 86 DEFINE_STATIC_LOCAL(RefPtr<Image>, imageStateRecording, (Image::loadPlatform
Resource("inputSpeechRecording"))); |
87 DEFINE_STATIC_LOCAL(RefPtr<Image>, imageStateWaiting, (Image::loadPlatformRe
source("inputSpeechWaiting"))); | 87 DEFINE_STATIC_LOCAL(RefPtr<Image>, imageStateWaiting, (Image::loadPlatformRe
source("inputSpeechWaiting"))); |
88 | 88 |
89 InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElemen
t(element); | 89 InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElemen
t(element); |
90 Image* image = imageStateNormal.get(); | 90 Image* image = imageStateNormal.get(); |
91 if (speechButton->state() == InputFieldSpeechButtonElement::Recording) | 91 if (speechButton->state() == InputFieldSpeechButtonElement::Recording) |
92 image = imageStateRecording.get(); | 92 image = imageStateRecording.get(); |
93 else if (speechButton->state() == InputFieldSpeechButtonElement::Recognizing
) | 93 else if (speechButton->state() == InputFieldSpeechButtonElement::Recognizing
) |
94 image = imageStateWaiting.get(); | 94 image = imageStateWaiting.get(); |
95 paintInfo.context->drawImage(image, pixelSnappedIntRect(buttonRect)); | 95 paintInfo.getContext()->drawImage(image, pixelSnappedIntRect(buttonRect)); |
96 | 96 |
97 return false; | 97 return false; |
98 } | 98 } |
99 | 99 |
100 } // namespace WebCore | 100 } // namespace WebCore |
101 | 101 |
102 #endif // ENABLE(INPUT_SPEECH) | 102 #endif // ENABLE(INPUT_SPEECH) |
OLD | NEW |