| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 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 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 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 Element* root = frame->selection().rootEditableElementOrDocumentElement(); | 850 Element* root = frame->selection().rootEditableElementOrDocumentElement(); |
| 851 if (!root) | 851 if (!root) |
| 852 return; | 852 return; |
| 853 | 853 |
| 854 // If the selection is inside a form control, the root will be a <div> that | 854 // If the selection is inside a form control, the root will be a <div> that |
| 855 // behaves as the editor but we want to return the actual element's bounds. | 855 // behaves as the editor but we want to return the actual element's bounds. |
| 856 // In practice, that means <textarea> and <input> controls that behave like | 856 // In practice, that means <textarea> and <input> controls that behave like |
| 857 // a text field. | 857 // a text field. |
| 858 Element* shadowHost = root->shadowHost(); | 858 Element* shadowHost = root->shadowHost(); |
| 859 if (shadowHost | 859 if (shadowHost |
| 860 && (shadowHost->hasTagName(HTMLNames::textareaTag) | 860 && (isHTMLTextAreaElement(*shadowHost) |
| 861 || (shadowHost->hasTagName(HTMLNames::inputTag) | 861 || (isHTMLInputElement(*shadowHost) |
| 862 && toHTMLInputElement(shadowHost)->isText()))) | 862 && toHTMLInputElement(*shadowHost).isText()))) |
| 863 root = shadowHost; | 863 root = shadowHost; |
| 864 | 864 |
| 865 IntRect boundingBox = root->pixelSnappedBoundingBox(); | 865 IntRect boundingBox = root->pixelSnappedBoundingBox(); |
| 866 boundingBox = root->document().frame()->view()->contentsToWindow(boundingBox
); | 866 boundingBox = root->document().frame()->view()->contentsToWindow(boundingBox
); |
| 867 boundingBox.scale(pageScaleFactor()); | 867 boundingBox.scale(pageScaleFactor()); |
| 868 bounds = boundingBox; | 868 bounds = boundingBox; |
| 869 } | 869 } |
| 870 | 870 |
| 871 bool WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event) | 871 bool WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event) |
| 872 { | 872 { |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2051 | 2051 |
| 2052 return info; | 2052 return info; |
| 2053 } | 2053 } |
| 2054 | 2054 |
| 2055 WebTextInputType WebViewImpl::textInputType() | 2055 WebTextInputType WebViewImpl::textInputType() |
| 2056 { | 2056 { |
| 2057 Element* element = focusedElement(); | 2057 Element* element = focusedElement(); |
| 2058 if (!element) | 2058 if (!element) |
| 2059 return WebTextInputTypeNone; | 2059 return WebTextInputTypeNone; |
| 2060 | 2060 |
| 2061 if (element->hasTagName(HTMLNames::inputTag)) { | 2061 if (isHTMLInputElement(*element)) { |
| 2062 HTMLInputElement* input = toHTMLInputElement(element); | 2062 HTMLInputElement& input = toHTMLInputElement(*element); |
| 2063 | 2063 |
| 2064 if (input->isDisabledOrReadOnly()) | 2064 if (input.isDisabledOrReadOnly()) |
| 2065 return WebTextInputTypeNone; | 2065 return WebTextInputTypeNone; |
| 2066 | 2066 |
| 2067 if (input->isPasswordField()) | 2067 if (input.isPasswordField()) |
| 2068 return WebTextInputTypePassword; | 2068 return WebTextInputTypePassword; |
| 2069 if (input->isSearchField()) | 2069 if (input.isSearchField()) |
| 2070 return WebTextInputTypeSearch; | 2070 return WebTextInputTypeSearch; |
| 2071 if (input->isEmailField()) | 2071 if (input.isEmailField()) |
| 2072 return WebTextInputTypeEmail; | 2072 return WebTextInputTypeEmail; |
| 2073 if (input->isNumberField()) | 2073 if (input.isNumberField()) |
| 2074 return WebTextInputTypeNumber; | 2074 return WebTextInputTypeNumber; |
| 2075 if (input->isTelephoneField()) | 2075 if (input.isTelephoneField()) |
| 2076 return WebTextInputTypeTelephone; | 2076 return WebTextInputTypeTelephone; |
| 2077 if (input->isURLField()) | 2077 if (input.isURLField()) |
| 2078 return WebTextInputTypeURL; | 2078 return WebTextInputTypeURL; |
| 2079 if (input->isDateField()) | 2079 if (input.isDateField()) |
| 2080 return WebTextInputTypeDate; | 2080 return WebTextInputTypeDate; |
| 2081 if (input->isDateTimeLocalField()) | 2081 if (input.isDateTimeLocalField()) |
| 2082 return WebTextInputTypeDateTimeLocal; | 2082 return WebTextInputTypeDateTimeLocal; |
| 2083 if (input->isMonthField()) | 2083 if (input.isMonthField()) |
| 2084 return WebTextInputTypeMonth; | 2084 return WebTextInputTypeMonth; |
| 2085 if (input->isTimeField()) | 2085 if (input.isTimeField()) |
| 2086 return WebTextInputTypeTime; | 2086 return WebTextInputTypeTime; |
| 2087 if (input->isWeekField()) | 2087 if (input.isWeekField()) |
| 2088 return WebTextInputTypeWeek; | 2088 return WebTextInputTypeWeek; |
| 2089 if (input->isTextField()) | 2089 if (input.isTextField()) |
| 2090 return WebTextInputTypeText; | 2090 return WebTextInputTypeText; |
| 2091 | 2091 |
| 2092 return WebTextInputTypeNone; | 2092 return WebTextInputTypeNone; |
| 2093 } | 2093 } |
| 2094 | 2094 |
| 2095 if (element->hasTagName(HTMLNames::textareaTag)) { | 2095 if (isHTMLTextAreaElement(*element)) { |
| 2096 if (toHTMLTextAreaElement(element)->isDisabledOrReadOnly()) | 2096 if (toHTMLTextAreaElement(*element).isDisabledOrReadOnly()) |
| 2097 return WebTextInputTypeNone; | 2097 return WebTextInputTypeNone; |
| 2098 return WebTextInputTypeTextArea; | 2098 return WebTextInputTypeTextArea; |
| 2099 } | 2099 } |
| 2100 | 2100 |
| 2101 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 2101 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
| 2102 if (element->isHTMLElement()) { | 2102 if (element->isHTMLElement()) { |
| 2103 if (toHTMLElement(element)->isDateTimeFieldElement()) | 2103 if (toHTMLElement(element)->isDateTimeFieldElement()) |
| 2104 return WebTextInputTypeDateTimeField; | 2104 return WebTextInputTypeDateTimeField; |
| 2105 } | 2105 } |
| 2106 #endif | 2106 #endif |
| 2107 | 2107 |
| 2108 if (element->shouldUseInputMethod()) | 2108 if (element->shouldUseInputMethod()) |
| 2109 return WebTextInputTypeContentEditable; | 2109 return WebTextInputTypeContentEditable; |
| 2110 | 2110 |
| 2111 return WebTextInputTypeNone; | 2111 return WebTextInputTypeNone; |
| 2112 } | 2112 } |
| 2113 | 2113 |
| 2114 WebString WebViewImpl::inputModeOfFocusedElement() | 2114 WebString WebViewImpl::inputModeOfFocusedElement() |
| 2115 { | 2115 { |
| 2116 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) | 2116 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) |
| 2117 return WebString(); | 2117 return WebString(); |
| 2118 | 2118 |
| 2119 Element* element = focusedElement(); | 2119 Element* element = focusedElement(); |
| 2120 if (!element) | 2120 if (!element) |
| 2121 return WebString(); | 2121 return WebString(); |
| 2122 | 2122 |
| 2123 if (element->hasTagName(HTMLNames::inputTag)) { | 2123 if (isHTMLInputElement(*element)) { |
| 2124 const HTMLInputElement* input = toHTMLInputElement(element); | 2124 const HTMLInputElement& input = toHTMLInputElement(*element); |
| 2125 if (input->supportsInputModeAttribute()) | 2125 if (input.supportsInputModeAttribute()) |
| 2126 return input->fastGetAttribute(HTMLNames::inputmodeAttr).lower(); | 2126 return input.fastGetAttribute(HTMLNames::inputmodeAttr).lower(); |
| 2127 return WebString(); | 2127 return WebString(); |
| 2128 } | 2128 } |
| 2129 if (element->hasTagName(HTMLNames::textareaTag)) { | 2129 if (isHTMLTextAreaElement(*element)) { |
| 2130 const HTMLTextAreaElement* textarea = toHTMLTextAreaElement(element); | 2130 const HTMLTextAreaElement& textarea = toHTMLTextAreaElement(*element); |
| 2131 return textarea->fastGetAttribute(HTMLNames::inputmodeAttr).lower(); | 2131 return textarea.fastGetAttribute(HTMLNames::inputmodeAttr).lower(); |
| 2132 } | 2132 } |
| 2133 | 2133 |
| 2134 return WebString(); | 2134 return WebString(); |
| 2135 } | 2135 } |
| 2136 | 2136 |
| 2137 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const | 2137 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const |
| 2138 { | 2138 { |
| 2139 const LocalFrame* frame = focusedWebCoreFrame(); | 2139 const LocalFrame* frame = focusedWebCoreFrame(); |
| 2140 if (!frame) | 2140 if (!frame) |
| 2141 return false; | 2141 return false; |
| (...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2984 view->setLayoutSize(layoutSize); | 2984 view->setLayoutSize(layoutSize); |
| 2985 else | 2985 else |
| 2986 updateMainFrameLayoutSize(); | 2986 updateMainFrameLayoutSize(); |
| 2987 } | 2987 } |
| 2988 | 2988 |
| 2989 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action, | 2989 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action, |
| 2990 const WebPoint& location) | 2990 const WebPoint& location) |
| 2991 { | 2991 { |
| 2992 HitTestResult result = hitTestResultForWindowPos(location); | 2992 HitTestResult result = hitTestResultForWindowPos(location); |
| 2993 RefPtr<Node> node = result.innerNonSharedNode(); | 2993 RefPtr<Node> node = result.innerNonSharedNode(); |
| 2994 if (!node->hasTagName(HTMLNames::videoTag) && !node->hasTagName(HTMLNames::a
udioTag)) | 2994 if (!isHTMLVideoElement(*node) && !isHTMLAudioElement(*node)) |
| 2995 return; | 2995 return; |
| 2996 | 2996 |
| 2997 RefPtr<HTMLMediaElement> mediaElement = | 2997 RefPtr<HTMLMediaElement> mediaElement = |
| 2998 static_pointer_cast<HTMLMediaElement>(node); | 2998 static_pointer_cast<HTMLMediaElement>(node); |
| 2999 switch (action.type) { | 2999 switch (action.type) { |
| 3000 case WebMediaPlayerAction::Play: | 3000 case WebMediaPlayerAction::Play: |
| 3001 if (action.enable) | 3001 if (action.enable) |
| 3002 mediaElement->play(); | 3002 mediaElement->play(); |
| 3003 else | 3003 else |
| 3004 mediaElement->pause(); | 3004 mediaElement->pause(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3015 default: | 3015 default: |
| 3016 ASSERT_NOT_REACHED(); | 3016 ASSERT_NOT_REACHED(); |
| 3017 } | 3017 } |
| 3018 } | 3018 } |
| 3019 | 3019 |
| 3020 void WebViewImpl::performPluginAction(const WebPluginAction& action, | 3020 void WebViewImpl::performPluginAction(const WebPluginAction& action, |
| 3021 const WebPoint& location) | 3021 const WebPoint& location) |
| 3022 { | 3022 { |
| 3023 HitTestResult result = hitTestResultForWindowPos(location); | 3023 HitTestResult result = hitTestResultForWindowPos(location); |
| 3024 RefPtr<Node> node = result.innerNonSharedNode(); | 3024 RefPtr<Node> node = result.innerNonSharedNode(); |
| 3025 if (!node->hasTagName(HTMLNames::objectTag) && !node->hasTagName(HTMLNames::
embedTag)) | 3025 if (!isHTMLObjectElement(*node) && !isHTMLEmbedElement(*node)) |
| 3026 return; | 3026 return; |
| 3027 | 3027 |
| 3028 RenderObject* object = node->renderer(); | 3028 RenderObject* object = node->renderer(); |
| 3029 if (object && object->isWidget()) { | 3029 if (object && object->isWidget()) { |
| 3030 Widget* widget = toRenderWidget(object)->widget(); | 3030 Widget* widget = toRenderWidget(object)->widget(); |
| 3031 if (widget && widget->isPluginContainer()) { | 3031 if (widget && widget->isPluginContainer()) { |
| 3032 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(widget); | 3032 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(widget); |
| 3033 switch (action.type) { | 3033 switch (action.type) { |
| 3034 case WebPluginAction::Rotate90Clockwise: | 3034 case WebPluginAction::Rotate90Clockwise: |
| 3035 plugin->plugin()->rotateView(WebPlugin::RotationType90Clockwise)
; | 3035 plugin->plugin()->rotateView(WebPlugin::RotationType90Clockwise)
; |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3910 | 3910 |
| 3911 if (touchHit.isContentEditable()) | 3911 if (touchHit.isContentEditable()) |
| 3912 return false; | 3912 return false; |
| 3913 | 3913 |
| 3914 Node* node = touchHit.innerNode(); | 3914 Node* node = touchHit.innerNode(); |
| 3915 if (!node || !node->isTextNode()) | 3915 if (!node || !node->isTextNode()) |
| 3916 return false; | 3916 return false; |
| 3917 | 3917 |
| 3918 // Ignore when tapping on links or nodes listening to click events, unless t
he click event is on the | 3918 // Ignore when tapping on links or nodes listening to click events, unless t
he click event is on the |
| 3919 // body element, in which case it's unlikely that the original node itself w
as intended to be clickable. | 3919 // body element, in which case it's unlikely that the original node itself w
as intended to be clickable. |
| 3920 for (; node && !node->hasTagName(HTMLNames::bodyTag); node = node->parentNod
e()) { | 3920 for (; node && !isHTMLBodyElement(*node); node = node->parentNode()) { |
| 3921 if (node->isLink() || node->willRespondToTouchEvents() || node->willResp
ondToMouseClickEvents()) | 3921 if (node->isLink() || node->willRespondToTouchEvents() || node->willResp
ondToMouseClickEvents()) |
| 3922 return false; | 3922 return false; |
| 3923 } | 3923 } |
| 3924 | 3924 |
| 3925 WebContentDetectionResult content = m_client->detectContentAround(touchHit); | 3925 WebContentDetectionResult content = m_client->detectContentAround(touchHit); |
| 3926 if (!content.isValid()) | 3926 if (!content.isValid()) |
| 3927 return false; | 3927 return false; |
| 3928 | 3928 |
| 3929 m_client->scheduleContentIntent(content.intent()); | 3929 m_client->scheduleContentIntent(content.intent()); |
| 3930 return true; | 3930 return true; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3998 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 3998 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
| 3999 | 3999 |
| 4000 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4000 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 4001 return false; | 4001 return false; |
| 4002 | 4002 |
| 4003 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4003 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 4004 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4004 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
| 4005 } | 4005 } |
| 4006 | 4006 |
| 4007 } // namespace blink | 4007 } // namespace blink |
| OLD | NEW |