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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // Change the text zoom level by kTextSizeMultiplierRatio each time the user | 205 // Change the text zoom level by kTextSizeMultiplierRatio each time the user |
206 // zooms text in or out (ie., change by 20%). The min and max values limit | 206 // zooms text in or out (ie., change by 20%). The min and max values limit |
207 // text zoom to half and 3x the original text size. These three values match | 207 // text zoom to half and 3x the original text size. These three values match |
208 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm | 208 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm |
209 const double WebView::textSizeMultiplierRatio = 1.2; | 209 const double WebView::textSizeMultiplierRatio = 1.2; |
210 const double WebView::minTextSizeMultiplier = 0.5; | 210 const double WebView::minTextSizeMultiplier = 0.5; |
211 const double WebView::maxTextSizeMultiplier = 3.0; | 211 const double WebView::maxTextSizeMultiplier = 3.0; |
212 | 212 |
213 // Used to defer all page activity in cases where the embedder wishes to run | 213 // Used to defer all page activity in cases where the embedder wishes to run |
214 // a nested event loop. Using a stack enables nesting of message loop invocation
s. | 214 // a nested event loop. Using a stack enables nesting of message loop invocation
s. |
215 static Vector<ScopedPageLoadDeferrer*>& pageLoadDeferrerStack() | 215 static WillBeHeapVector<RawPtrWillBeMember<ScopedPageLoadDeferrer> >& pageLoadDe
ferrerStack() |
216 { | 216 { |
217 DEFINE_STATIC_LOCAL(Vector<ScopedPageLoadDeferrer*>, deferrerStack, ()); | 217 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapVector<RawPtrWillBeMemb
er<ScopedPageLoadDeferrer> > >, deferrerStack, (adoptPtrWillBeNoop(new WillBeHea
pVector<RawPtrWillBeMember<ScopedPageLoadDeferrer> > ()))); |
218 return deferrerStack; | 218 return *deferrerStack; |
219 } | 219 } |
220 | 220 |
221 // Ensure that the WebDragOperation enum values stay in sync with the original | 221 // Ensure that the WebDragOperation enum values stay in sync with the original |
222 // DragOperation constants. | 222 // DragOperation constants. |
223 #define COMPILE_ASSERT_MATCHING_ENUM(coreName) \ | 223 #define COMPILE_ASSERT_MATCHING_ENUM(coreName) \ |
224 COMPILE_ASSERT(int(coreName) == int(Web##coreName), dummy##coreName) | 224 COMPILE_ASSERT(int(coreName) == int(Web##coreName), dummy##coreName) |
225 COMPILE_ASSERT_MATCHING_ENUM(DragOperationNone); | 225 COMPILE_ASSERT_MATCHING_ENUM(DragOperationNone); |
226 COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy); | 226 COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy); |
227 COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink); | 227 COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink); |
228 COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric); | 228 COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 311 |
312 void WebView::willEnterModalLoop() | 312 void WebView::willEnterModalLoop() |
313 { | 313 { |
314 pageLoadDeferrerStack().append(new ScopedPageLoadDeferrer()); | 314 pageLoadDeferrerStack().append(new ScopedPageLoadDeferrer()); |
315 } | 315 } |
316 | 316 |
317 void WebView::didExitModalLoop() | 317 void WebView::didExitModalLoop() |
318 { | 318 { |
319 ASSERT(pageLoadDeferrerStack().size()); | 319 ASSERT(pageLoadDeferrerStack().size()); |
320 | 320 |
321 delete pageLoadDeferrerStack().last(); | 321 ScopedPageLoadDeferrer* deferrer = pageLoadDeferrerStack().last(); |
| 322 #if ENABLE(OILPAN) |
| 323 deferrer->dispose(); |
| 324 #else |
| 325 delete deferrer; |
| 326 #endif |
322 pageLoadDeferrerStack().removeLast(); | 327 pageLoadDeferrerStack().removeLast(); |
323 } | 328 } |
324 | 329 |
325 void WebViewImpl::setMainFrame(WebFrame* frame) | 330 void WebViewImpl::setMainFrame(WebFrame* frame) |
326 { | 331 { |
327 if (frame->isWebLocalFrame()) | 332 if (frame->isWebLocalFrame()) |
328 toWebLocalFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0,
nullAtom, nullAtom); | 333 toWebLocalFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0,
nullAtom, nullAtom); |
329 else | 334 else |
330 toWebRemoteFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0
, nullAtom); | 335 toWebRemoteFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0
, nullAtom); |
331 } | 336 } |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)
); | 956 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)
); |
952 if (m_pagePopup) { | 957 if (m_pagePopup) { |
953 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); | 958 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); |
954 // We need to ignore the next Char event after this otherwise pressing | 959 // We need to ignore the next Char event after this otherwise pressing |
955 // enter when selecting an item in the popup will go to the page. | 960 // enter when selecting an item in the popup will go to the page. |
956 if (WebInputEvent::RawKeyDown == event.type) | 961 if (WebInputEvent::RawKeyDown == event.type) |
957 m_suppressNextKeypressEvent = true; | 962 m_suppressNextKeypressEvent = true; |
958 return true; | 963 return true; |
959 } | 964 } |
960 | 965 |
961 RefPtr<Frame> focusedFrame = focusedCoreFrame(); | 966 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame(); |
962 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) { | 967 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) { |
963 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT
emporary(focusedFrame.get())); | 968 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT
emporary(focusedFrame.get())); |
964 webFrame->client()->forwardInputEvent(&event); | 969 webFrame->client()->forwardInputEvent(&event); |
965 return true; | 970 return true; |
966 } | 971 } |
967 | 972 |
968 if (!focusedFrame || !focusedFrame->isLocalFrame()) | 973 if (!focusedFrame || !focusedFrame->isLocalFrame()) |
969 return false; | 974 return false; |
970 | 975 |
971 RefPtr<LocalFrame> frame = toLocalFrame(focusedFrame.get()); | 976 LocalFrame* frame = toLocalFrame(focusedFrame.get()); |
972 | 977 |
973 PlatformKeyboardEventBuilder evt(event); | 978 PlatformKeyboardEventBuilder evt(event); |
974 | 979 |
975 if (frame->eventHandler().keyEvent(evt)) { | 980 if (frame->eventHandler().keyEvent(evt)) { |
976 if (WebInputEvent::RawKeyDown == event.type) { | 981 if (WebInputEvent::RawKeyDown == event.type) { |
977 // Suppress the next keypress event unless the focused node is a plu
g-in node. | 982 // Suppress the next keypress event unless the focused node is a plu
g-in node. |
978 // (Flash needs these keypress events to handle non-US keyboards.) | 983 // (Flash needs these keypress events to handle non-US keyboards.) |
979 Element* element = focusedElement(); | 984 Element* element = focusedElement(); |
980 if (!element || !element->renderer() || !element->renderer()->isEmbe
ddedObject()) | 985 if (!element || !element->renderer() || !element->renderer()->isEmbe
ddedObject()) |
981 m_suppressNextKeypressEvent = true; | 986 m_suppressNextKeypressEvent = true; |
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 { | 2027 { |
2023 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); | 2028 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); |
2024 m_mouseCaptureNode = nullptr; | 2029 m_mouseCaptureNode = nullptr; |
2025 } | 2030 } |
2026 | 2031 |
2027 void WebViewImpl::setFocus(bool enable) | 2032 void WebViewImpl::setFocus(bool enable) |
2028 { | 2033 { |
2029 m_page->focusController().setFocused(enable); | 2034 m_page->focusController().setFocused(enable); |
2030 if (enable) { | 2035 if (enable) { |
2031 m_page->focusController().setActive(true); | 2036 m_page->focusController().setActive(true); |
2032 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); | 2037 RefPtrWillBeRawPtr<Frame> focusedFrame = m_page->focusController().focus
edFrame(); |
2033 if (focusedFrame && focusedFrame->isLocalFrame()) { | 2038 if (focusedFrame && focusedFrame->isLocalFrame()) { |
2034 LocalFrame* localFrame = toLocalFrame(focusedFrame.get()); | 2039 LocalFrame* localFrame = toLocalFrame(focusedFrame.get()); |
2035 Element* element = localFrame->document()->focusedElement(); | 2040 Element* element = localFrame->document()->focusedElement(); |
2036 if (element && localFrame->selection().selection().isNone()) { | 2041 if (element && localFrame->selection().selection().isNone()) { |
2037 // If the selection was cleared while the WebView was not | 2042 // If the selection was cleared while the WebView was not |
2038 // focused, then the focus element shows with a focus ring but | 2043 // focused, then the focus element shows with a focus ring but |
2039 // no caret and does respond to keyboard inputs. | 2044 // no caret and does respond to keyboard inputs. |
2040 if (element->isTextFormControl()) { | 2045 if (element->isTextFormControl()) { |
2041 element->updateFocusAppearance(true); | 2046 element->updateFocusAppearance(true); |
2042 } else if (element->isContentEditable()) { | 2047 } else if (element->isContentEditable()) { |
(...skipping 12 matching lines...) Expand all Loading... |
2055 | 2060 |
2056 // Clear focus on the currently focused frame if any. | 2061 // Clear focus on the currently focused frame if any. |
2057 if (!m_page) | 2062 if (!m_page) |
2058 return; | 2063 return; |
2059 | 2064 |
2060 LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalF
rame() | 2065 LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalF
rame() |
2061 ? m_page->deprecatedLocalMainFrame() : 0; | 2066 ? m_page->deprecatedLocalMainFrame() : 0; |
2062 if (!frame) | 2067 if (!frame) |
2063 return; | 2068 return; |
2064 | 2069 |
2065 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); | 2070 RefPtrWillBeRawPtr<Frame> focusedFrame = m_page->focusController().focus
edFrame(); |
2066 if (focusedFrame && focusedFrame->isLocalFrame()) { | 2071 if (focusedFrame && focusedFrame->isLocalFrame()) { |
2067 // Finish an ongoing composition to delete the composition node. | 2072 // Finish an ongoing composition to delete the composition node. |
2068 if (toLocalFrame(focusedFrame.get())->inputMethodController().hasCom
position()) { | 2073 if (toLocalFrame(focusedFrame.get())->inputMethodController().hasCom
position()) { |
2069 if (m_autofillClient) | 2074 if (m_autofillClient) |
2070 m_autofillClient->setIgnoreTextChanges(true); | 2075 m_autofillClient->setIgnoreTextChanges(true); |
2071 | 2076 |
2072 toLocalFrame(focusedFrame.get())->inputMethodController().confir
mComposition(); | 2077 toLocalFrame(focusedFrame.get())->inputMethodController().confir
mComposition(); |
2073 | 2078 |
2074 if (m_autofillClient) | 2079 if (m_autofillClient) |
2075 m_autofillClient->setIgnoreTextChanges(false); | 2080 m_autofillClient->setIgnoreTextChanges(false); |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2674 Frame* frame = page()->focusController().focusedOrMainFrame(); | 2679 Frame* frame = page()->focusController().focusedOrMainFrame(); |
2675 if (frame->isLocalFrame()) { | 2680 if (frame->isLocalFrame()) { |
2676 if (Document* document = toLocalFrame(frame)->document()) | 2681 if (Document* document = toLocalFrame(frame)->document()) |
2677 document->setFocusedElement(nullptr); | 2682 document->setFocusedElement(nullptr); |
2678 } | 2683 } |
2679 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu
sTypeForward); | 2684 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu
sTypeForward); |
2680 } | 2685 } |
2681 | 2686 |
2682 void WebViewImpl::clearFocusedElement() | 2687 void WebViewImpl::clearFocusedElement() |
2683 { | 2688 { |
2684 RefPtr<Frame> frame = focusedCoreFrame(); | 2689 RefPtrWillBeRawPtr<Frame> frame = focusedCoreFrame(); |
2685 if (!frame || !frame->isLocalFrame()) | 2690 if (!frame || !frame->isLocalFrame()) |
2686 return; | 2691 return; |
2687 | 2692 |
2688 LocalFrame* localFrame = toLocalFrame(frame.get()); | 2693 LocalFrame* localFrame = toLocalFrame(frame.get()); |
2689 | 2694 |
2690 RefPtrWillBeRawPtr<Document> document = localFrame->document(); | 2695 RefPtrWillBeRawPtr<Document> document = localFrame->document(); |
2691 if (!document) | 2696 if (!document) |
2692 return; | 2697 return; |
2693 | 2698 |
2694 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement(); | 2699 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement(); |
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4317 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 4322 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
4318 | 4323 |
4319 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4324 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4320 return false; | 4325 return false; |
4321 | 4326 |
4322 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4327 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4323 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4328 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4324 } | 4329 } |
4325 | 4330 |
4326 } // namespace blink | 4331 } // namespace blink |
OLD | NEW |