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