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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 // Change the text zoom level by kTextSizeMultiplierRatio each time the user | 202 // Change the text zoom level by kTextSizeMultiplierRatio each time the user |
203 // zooms text in or out (ie., change by 20%). The min and max values limit | 203 // zooms text in or out (ie., change by 20%). The min and max values limit |
204 // text zoom to half and 3x the original text size. These three values match | 204 // text zoom to half and 3x the original text size. These three values match |
205 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm | 205 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm |
206 const double WebView::textSizeMultiplierRatio = 1.2; | 206 const double WebView::textSizeMultiplierRatio = 1.2; |
207 const double WebView::minTextSizeMultiplier = 0.5; | 207 const double WebView::minTextSizeMultiplier = 0.5; |
208 const double WebView::maxTextSizeMultiplier = 3.0; | 208 const double WebView::maxTextSizeMultiplier = 3.0; |
209 | 209 |
210 // Used to defer all page activity in cases where the embedder wishes to run | 210 // Used to defer all page activity in cases where the embedder wishes to run |
211 // a nested event loop. Using a stack enables nesting of message loop invocation s. | 211 // a nested event loop. Using a stack enables nesting of message loop invocation s. |
212 static Vector<ScopedPageLoadDeferrer*>& pageLoadDeferrerStack() | 212 static WillBeHeapVector<RawPtrWillBeMember<ScopedPageLoadDeferrer> >& pageLoadDe ferrerStack() |
213 { | 213 { |
214 DEFINE_STATIC_LOCAL(Vector<ScopedPageLoadDeferrer*>, deferrerStack, ()); | 214 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapVector<RawPtrWillBeMemb er<ScopedPageLoadDeferrer> > >, deferrerStack, (adoptPtrWillBeNoop(new WillBeHea pVector<RawPtrWillBeMember<ScopedPageLoadDeferrer> > ()))); |
215 return deferrerStack; | 215 return *deferrerStack; |
216 } | 216 } |
217 | 217 |
218 // Ensure that the WebDragOperation enum values stay in sync with the original | 218 // Ensure that the WebDragOperation enum values stay in sync with the original |
219 // DragOperation constants. | 219 // DragOperation constants. |
220 #define COMPILE_ASSERT_MATCHING_ENUM(coreName) \ | 220 #define COMPILE_ASSERT_MATCHING_ENUM(coreName) \ |
221 COMPILE_ASSERT(int(coreName) == int(Web##coreName), dummy##coreName) | 221 COMPILE_ASSERT(int(coreName) == int(Web##coreName), dummy##coreName) |
222 COMPILE_ASSERT_MATCHING_ENUM(DragOperationNone); | 222 COMPILE_ASSERT_MATCHING_ENUM(DragOperationNone); |
223 COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy); | 223 COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy); |
224 COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink); | 224 COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink); |
225 COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric); | 225 COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 | 308 |
309 void WebView::willEnterModalLoop() | 309 void WebView::willEnterModalLoop() |
310 { | 310 { |
311 pageLoadDeferrerStack().append(new ScopedPageLoadDeferrer()); | 311 pageLoadDeferrerStack().append(new ScopedPageLoadDeferrer()); |
312 } | 312 } |
313 | 313 |
314 void WebView::didExitModalLoop() | 314 void WebView::didExitModalLoop() |
315 { | 315 { |
316 ASSERT(pageLoadDeferrerStack().size()); | 316 ASSERT(pageLoadDeferrerStack().size()); |
317 | 317 |
318 delete pageLoadDeferrerStack().last(); | 318 ScopedPageLoadDeferrer* deferrer = pageLoadDeferrerStack().last(); |
319 #if ENABLE(OILPAN) | |
320 deferrer->dispose(); | |
321 #else | |
322 delete deferrer; | |
haraken
2014/09/08 07:25:59
Can we use OwnPtr<ScopedPageLoadDeferrer> and avoi
sof
2014/09/08 21:17:46
I don't quite see where you're going with this.
| |
323 #endif | |
319 pageLoadDeferrerStack().removeLast(); | 324 pageLoadDeferrerStack().removeLast(); |
320 } | 325 } |
321 | 326 |
322 void WebViewImpl::setMainFrame(WebFrame* frame) | 327 void WebViewImpl::setMainFrame(WebFrame* frame) |
323 { | 328 { |
324 if (frame->isWebLocalFrame()) | 329 if (frame->isWebLocalFrame()) { |
330 #if ENABLE(OILPAN) | |
331 m_localMainFrame = toWebLocalFrameImpl(frame); | |
332 m_remoteMainFrame.clear(); | |
haraken
2014/09/08 07:25:59
Can we add an ASSERT somewhere to verify that only
sof
2014/09/08 21:17:47
assert added to ~WebViewImpl.
| |
333 #endif | |
325 toWebLocalFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0, nullAtom, nullAtom); | 334 toWebLocalFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0, nullAtom, nullAtom); |
326 else | 335 } else { |
336 #if ENABLE(OILPAN) | |
337 m_localMainFrame.clear(); | |
338 m_remoteMainFrame = toWebRemoteFrameImpl(frame); | |
339 #endif | |
327 toWebRemoteFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0 , nullAtom); | 340 toWebRemoteFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0 , nullAtom); |
341 } | |
328 } | 342 } |
329 | 343 |
330 void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient) | 344 void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient) |
331 { | 345 { |
332 m_autofillClient = autofillClient; | 346 m_autofillClient = autofillClient; |
333 } | 347 } |
334 | 348 |
335 void WebViewImpl::setCredentialManagerClient(WebCredentialManagerClient* webCred entialManagerClient) | 349 void WebViewImpl::setCredentialManagerClient(WebCredentialManagerClient* webCred entialManagerClient) |
336 { | 350 { |
337 ASSERT(m_page); | 351 ASSERT(m_page); |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
947 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); | 961 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); |
948 if (m_pagePopup) { | 962 if (m_pagePopup) { |
949 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); | 963 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); |
950 // We need to ignore the next Char event after this otherwise pressing | 964 // We need to ignore the next Char event after this otherwise pressing |
951 // enter when selecting an item in the popup will go to the page. | 965 // enter when selecting an item in the popup will go to the page. |
952 if (WebInputEvent::RawKeyDown == event.type) | 966 if (WebInputEvent::RawKeyDown == event.type) |
953 m_suppressNextKeypressEvent = true; | 967 m_suppressNextKeypressEvent = true; |
954 return true; | 968 return true; |
955 } | 969 } |
956 | 970 |
957 RefPtr<Frame> focusedFrame = focusedCoreFrame(); | 971 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame(); |
958 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) { | 972 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) { |
959 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT emporary(focusedFrame.get())); | 973 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT emporary(focusedFrame.get())); |
960 webFrame->client()->forwardInputEvent(&event); | 974 webFrame->client()->forwardInputEvent(&event); |
961 return true; | 975 return true; |
962 } | 976 } |
963 | 977 |
964 if (!focusedFrame || !focusedFrame->isLocalFrame()) | 978 if (!focusedFrame || !focusedFrame->isLocalFrame()) |
965 return false; | 979 return false; |
966 | 980 |
967 RefPtr<LocalFrame> frame = toLocalFrame(focusedFrame.get()); | 981 LocalFrame* frame = toLocalFrame(focusedFrame.get()); |
968 | 982 |
969 PlatformKeyboardEventBuilder evt(event); | 983 PlatformKeyboardEventBuilder evt(event); |
970 | 984 |
971 if (frame->eventHandler().keyEvent(evt)) { | 985 if (frame->eventHandler().keyEvent(evt)) { |
972 if (WebInputEvent::RawKeyDown == event.type) { | 986 if (WebInputEvent::RawKeyDown == event.type) { |
973 // Suppress the next keypress event unless the focused node is a plu g-in node. | 987 // Suppress the next keypress event unless the focused node is a plu g-in node. |
974 // (Flash needs these keypress events to handle non-US keyboards.) | 988 // (Flash needs these keypress events to handle non-US keyboards.) |
975 Element* element = focusedElement(); | 989 Element* element = focusedElement(); |
976 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject()) | 990 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject()) |
977 m_suppressNextKeypressEvent = true; | 991 m_suppressNextKeypressEvent = true; |
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2013 { | 2027 { |
2014 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); | 2028 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); |
2015 m_mouseCaptureNode = nullptr; | 2029 m_mouseCaptureNode = nullptr; |
2016 } | 2030 } |
2017 | 2031 |
2018 void WebViewImpl::setFocus(bool enable) | 2032 void WebViewImpl::setFocus(bool enable) |
2019 { | 2033 { |
2020 m_page->focusController().setFocused(enable); | 2034 m_page->focusController().setFocused(enable); |
2021 if (enable) { | 2035 if (enable) { |
2022 m_page->focusController().setActive(true); | 2036 m_page->focusController().setActive(true); |
2023 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); | 2037 RefPtrWillBeRawPtr<Frame> focusedFrame = m_page->focusController().focus edFrame(); |
2024 if (focusedFrame && focusedFrame->isLocalFrame()) { | 2038 if (focusedFrame && focusedFrame->isLocalFrame()) { |
2025 LocalFrame* localFrame = toLocalFrame(focusedFrame.get()); | 2039 LocalFrame* localFrame = toLocalFrame(focusedFrame.get()); |
2026 Element* element = localFrame->document()->focusedElement(); | 2040 Element* element = localFrame->document()->focusedElement(); |
2027 if (element && localFrame->selection().selection().isNone()) { | 2041 if (element && localFrame->selection().selection().isNone()) { |
2028 // If the selection was cleared while the WebView was not | 2042 // If the selection was cleared while the WebView was not |
2029 // focused, then the focus element shows with a focus ring but | 2043 // focused, then the focus element shows with a focus ring but |
2030 // no caret and does respond to keyboard inputs. | 2044 // no caret and does respond to keyboard inputs. |
2031 if (element->isTextFormControl()) { | 2045 if (element->isTextFormControl()) { |
2032 element->updateFocusAppearance(true); | 2046 element->updateFocusAppearance(true); |
2033 } else if (element->isContentEditable()) { | 2047 } else if (element->isContentEditable()) { |
(...skipping 12 matching lines...) Expand all Loading... | |
2046 | 2060 |
2047 // Clear focus on the currently focused frame if any. | 2061 // Clear focus on the currently focused frame if any. |
2048 if (!m_page) | 2062 if (!m_page) |
2049 return; | 2063 return; |
2050 | 2064 |
2051 LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalF rame() | 2065 LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalF rame() |
2052 ? m_page->deprecatedLocalMainFrame() : 0; | 2066 ? m_page->deprecatedLocalMainFrame() : 0; |
2053 if (!frame) | 2067 if (!frame) |
2054 return; | 2068 return; |
2055 | 2069 |
2056 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); | 2070 RefPtrWillBeRawPtr<Frame> focusedFrame = m_page->focusController().focus edFrame(); |
2057 if (focusedFrame && focusedFrame->isLocalFrame()) { | 2071 if (focusedFrame && focusedFrame->isLocalFrame()) { |
2058 // Finish an ongoing composition to delete the composition node. | 2072 // Finish an ongoing composition to delete the composition node. |
2059 if (toLocalFrame(focusedFrame.get())->inputMethodController().hasCom position()) { | 2073 if (toLocalFrame(focusedFrame.get())->inputMethodController().hasCom position()) { |
2060 if (m_autofillClient) | 2074 if (m_autofillClient) |
2061 m_autofillClient->setIgnoreTextChanges(true); | 2075 m_autofillClient->setIgnoreTextChanges(true); |
2062 | 2076 |
2063 toLocalFrame(focusedFrame.get())->inputMethodController().confir mComposition(); | 2077 toLocalFrame(focusedFrame.get())->inputMethodController().confir mComposition(); |
2064 | 2078 |
2065 if (m_autofillClient) | 2079 if (m_autofillClient) |
2066 m_autofillClient->setIgnoreTextChanges(false); | 2080 m_autofillClient->setIgnoreTextChanges(false); |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2656 Frame* frame = page()->focusController().focusedOrMainFrame(); | 2670 Frame* frame = page()->focusController().focusedOrMainFrame(); |
2657 if (frame->isLocalFrame()) { | 2671 if (frame->isLocalFrame()) { |
2658 if (Document* document = toLocalFrame(frame)->document()) | 2672 if (Document* document = toLocalFrame(frame)->document()) |
2659 document->setFocusedElement(nullptr); | 2673 document->setFocusedElement(nullptr); |
2660 } | 2674 } |
2661 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward); | 2675 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward); |
2662 } | 2676 } |
2663 | 2677 |
2664 void WebViewImpl::clearFocusedElement() | 2678 void WebViewImpl::clearFocusedElement() |
2665 { | 2679 { |
2666 RefPtr<Frame> frame = focusedCoreFrame(); | 2680 RefPtrWillBeRawPtr<Frame> frame = focusedCoreFrame(); |
2667 if (!frame || !frame->isLocalFrame()) | 2681 if (!frame || !frame->isLocalFrame()) |
2668 return; | 2682 return; |
2669 | 2683 |
2670 LocalFrame* localFrame = toLocalFrame(frame.get()); | 2684 LocalFrame* localFrame = toLocalFrame(frame.get()); |
2671 | 2685 |
2672 RefPtrWillBeRawPtr<Document> document = localFrame->document(); | 2686 RefPtrWillBeRawPtr<Document> document = localFrame->document(); |
2673 if (!document) | 2687 if (!document) |
2674 return; | 2688 return; |
2675 | 2689 |
2676 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement(); | 2690 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement(); |
(...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4280 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); | 4294 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); |
4281 | 4295 |
4282 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4296 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4283 return false; | 4297 return false; |
4284 | 4298 |
4285 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4299 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4286 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); | 4300 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); |
4287 } | 4301 } |
4288 | 4302 |
4289 } // namespace blink | 4303 } // namespace blink |
OLD | NEW |