Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 474143002: Rename some functions of which names contain 'WebCore.' (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | public/web/WebFrame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 { 312 {
313 ASSERT(pageLoadDeferrerStack().size()); 313 ASSERT(pageLoadDeferrerStack().size());
314 314
315 delete pageLoadDeferrerStack().last(); 315 delete pageLoadDeferrerStack().last();
316 pageLoadDeferrerStack().removeLast(); 316 pageLoadDeferrerStack().removeLast();
317 } 317 }
318 318
319 void WebViewImpl::setMainFrame(WebFrame* frame) 319 void WebViewImpl::setMainFrame(WebFrame* frame)
320 { 320 {
321 if (frame->isWebLocalFrame()) 321 if (frame->isWebLocalFrame())
322 toWebLocalFrameImpl(frame)->initializeWebCoreFrame(&page()->frameHost(), 0, nullAtom, nullAtom); 322 toWebLocalFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0, nullAtom, nullAtom);
323 else 323 else
324 toWebRemoteFrameImpl(frame)->initializeWebCoreFrame(&page()->frameHost() , 0, nullAtom); 324 toWebRemoteFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0 , nullAtom);
325 } 325 }
326 326
327 void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient) 327 void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient)
328 { 328 {
329 m_autofillClient = autofillClient; 329 m_autofillClient = autofillClient;
330 } 330 }
331 331
332 void WebViewImpl::setDevToolsAgentClient(WebDevToolsAgentClient* devToolsClient) 332 void WebViewImpl::setDevToolsAgentClient(WebDevToolsAgentClient* devToolsClient)
333 { 333 {
334 if (devToolsClient) 334 if (devToolsClient)
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 870
871 void WebViewImpl::setShowScrollBottleneckRects(bool show) 871 void WebViewImpl::setShowScrollBottleneckRects(bool show)
872 { 872 {
873 if (m_layerTreeView) 873 if (m_layerTreeView)
874 m_layerTreeView->setShowScrollBottleneckRects(show); 874 m_layerTreeView->setShowScrollBottleneckRects(show);
875 m_showScrollBottleneckRects = show; 875 m_showScrollBottleneckRects = show;
876 } 876 }
877 877
878 void WebViewImpl::getSelectionRootBounds(WebRect& bounds) const 878 void WebViewImpl::getSelectionRootBounds(WebRect& bounds) const
879 { 879 {
880 const Frame* frame = focusedWebCoreFrame(); 880 const Frame* frame = focusedCoreFrame();
881 if (!frame || !frame->isLocalFrame()) 881 if (!frame || !frame->isLocalFrame())
882 return; 882 return;
883 883
884 Element* root = toLocalFrame(frame)->selection().rootEditableElementOrDocume ntElement(); 884 Element* root = toLocalFrame(frame)->selection().rootEditableElementOrDocume ntElement();
885 if (!root) 885 if (!root)
886 return; 886 return;
887 887
888 // If the selection is inside a form control, the root will be a <div> that 888 // If the selection is inside a form control, the root will be a <div> that
889 // behaves as the editor but we want to return the actual element's bounds. 889 // behaves as the editor but we want to return the actual element's bounds.
890 // In practice, that means <textarea> and <input> controls that behave like 890 // In practice, that means <textarea> and <input> controls that behave like
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); 936 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
937 if (m_pagePopup) { 937 if (m_pagePopup) {
938 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 938 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
939 // We need to ignore the next Char event after this otherwise pressing 939 // We need to ignore the next Char event after this otherwise pressing
940 // enter when selecting an item in the popup will go to the page. 940 // enter when selecting an item in the popup will go to the page.
941 if (WebInputEvent::RawKeyDown == event.type) 941 if (WebInputEvent::RawKeyDown == event.type)
942 m_suppressNextKeypressEvent = true; 942 m_suppressNextKeypressEvent = true;
943 return true; 943 return true;
944 } 944 }
945 945
946 RefPtr<Frame> focusedFrame = focusedWebCoreFrame(); 946 RefPtr<Frame> focusedFrame = focusedCoreFrame();
947 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) { 947 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) {
948 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT emporary(focusedFrame.get())); 948 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT emporary(focusedFrame.get()));
949 webFrame->client()->forwardInputEvent(&event); 949 webFrame->client()->forwardInputEvent(&event);
950 return true; 950 return true;
951 } 951 }
952 952
953 if (!focusedFrame || !focusedFrame->isLocalFrame()) 953 if (!focusedFrame || !focusedFrame->isLocalFrame())
954 return false; 954 return false;
955 955
956 RefPtr<LocalFrame> frame = toLocalFrame(focusedFrame.get()); 956 RefPtr<LocalFrame> frame = toLocalFrame(focusedFrame.get());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 bool suppress = m_suppressNextKeypressEvent; 999 bool suppress = m_suppressNextKeypressEvent;
1000 m_suppressNextKeypressEvent = false; 1000 m_suppressNextKeypressEvent = false;
1001 1001
1002 // If there is a select popup, it should be the one processing the event, 1002 // If there is a select popup, it should be the one processing the event,
1003 // not the page. 1003 // not the page.
1004 if (m_selectPopup) 1004 if (m_selectPopup)
1005 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); 1005 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
1006 if (m_pagePopup) 1006 if (m_pagePopup)
1007 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 1007 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
1008 1008
1009 LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); 1009 LocalFrame* frame = toLocalFrame(focusedCoreFrame());
1010 if (!frame) 1010 if (!frame)
1011 return suppress; 1011 return suppress;
1012 1012
1013 EventHandler& handler = frame->eventHandler(); 1013 EventHandler& handler = frame->eventHandler();
1014 1014
1015 PlatformKeyboardEventBuilder evt(event); 1015 PlatformKeyboardEventBuilder evt(event);
1016 if (!evt.isCharacterKey()) 1016 if (!evt.isCharacterKey())
1017 return true; 1017 return true;
1018 1018
1019 // Accesskeys are triggered by char events and can't be suppressed. 1019 // Accesskeys are triggered by char events and can't be suppressed.
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 if (!page()->mainFrame()->isLocalFrame()) 1376 if (!page()->mainFrame()->isLocalFrame())
1377 return; 1377 return;
1378 m_contextMenuAllowed = true; 1378 m_contextMenuAllowed = true;
1379 page()->contextMenuController().clearContextMenu(); 1379 page()->contextMenuController().clearContextMenu();
1380 page()->contextMenuController().showContextMenuAtPoint(page()->deprecatedLoc alMainFrame(), x, y, menuProvider); 1380 page()->contextMenuController().showContextMenuAtPoint(page()->deprecatedLoc alMainFrame(), x, y, menuProvider);
1381 m_contextMenuAllowed = false; 1381 m_contextMenuAllowed = false;
1382 } 1382 }
1383 1383
1384 bool WebViewImpl::keyEventDefault(const WebKeyboardEvent& event) 1384 bool WebViewImpl::keyEventDefault(const WebKeyboardEvent& event)
1385 { 1385 {
1386 LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); 1386 LocalFrame* frame = toLocalFrame(focusedCoreFrame());
1387 if (!frame) 1387 if (!frame)
1388 return false; 1388 return false;
1389 1389
1390 switch (event.type) { 1390 switch (event.type) {
1391 case WebInputEvent::Char: 1391 case WebInputEvent::Char:
1392 if (event.windowsKeyCode == VKEY_SPACE) { 1392 if (event.windowsKeyCode == VKEY_SPACE) {
1393 int keyCode = ((event.modifiers & WebInputEvent::ShiftKey) ? VKEY_PR IOR : VKEY_NEXT); 1393 int keyCode = ((event.modifiers & WebInputEvent::ShiftKey) ? VKEY_PR IOR : VKEY_NEXT);
1394 return scrollViewWithKeyboard(keyCode, event.modifiers); 1394 return scrollViewWithKeyboard(keyCode, event.modifiers);
1395 } 1395 }
1396 break; 1396 break;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 if (modifiers & WebMouseEvent::ControlKey) { 1435 if (modifiers & WebMouseEvent::ControlKey) {
1436 if (keyCode == VKEY_UP) 1436 if (keyCode == VKEY_UP)
1437 keyCode = VKEY_PRIOR; 1437 keyCode = VKEY_PRIOR;
1438 else if (keyCode == VKEY_DOWN) 1438 else if (keyCode == VKEY_DOWN)
1439 keyCode = VKEY_NEXT; 1439 keyCode = VKEY_NEXT;
1440 } 1440 }
1441 #endif 1441 #endif
1442 if (!mapKeyCodeForScroll(keyCode, &scrollDirection, &scrollGranularity)) 1442 if (!mapKeyCodeForScroll(keyCode, &scrollDirection, &scrollGranularity))
1443 return false; 1443 return false;
1444 1444
1445 LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); 1445 if (LocalFrame* frame = toLocalFrame(focusedCoreFrame()))
1446 if (!frame) 1446 return frame->eventHandler().bubblingScroll(scrollDirection, scrollGranu larity);
1447 return false; 1447 return false;
1448 return frame->eventHandler().bubblingScroll(scrollDirection, scrollGranulari ty);
1449 } 1448 }
1450 1449
1451 bool WebViewImpl::mapKeyCodeForScroll( 1450 bool WebViewImpl::mapKeyCodeForScroll(
1452 int keyCode, 1451 int keyCode,
1453 ScrollDirection* scrollDirection, 1452 ScrollDirection* scrollDirection,
1454 ScrollGranularity* scrollGranularity) 1453 ScrollGranularity* scrollGranularity)
1455 { 1454 {
1456 switch (keyCode) { 1455 switch (keyCode) {
1457 case VKEY_LEFT: 1456 case VKEY_LEFT:
1458 *scrollDirection = ScrollLeft; 1457 *scrollDirection = ScrollLeft;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 { 1541 {
1543 ASSERT(popup); 1542 ASSERT(popup);
1544 WebPagePopupImpl* popupImpl = toWebPagePopupImpl(popup); 1543 WebPagePopupImpl* popupImpl = toWebPagePopupImpl(popup);
1545 ASSERT(m_pagePopup.get() == popupImpl); 1544 ASSERT(m_pagePopup.get() == popupImpl);
1546 if (m_pagePopup.get() != popupImpl) 1545 if (m_pagePopup.get() != popupImpl)
1547 return; 1546 return;
1548 m_pagePopup->closePopup(); 1547 m_pagePopup->closePopup();
1549 m_pagePopup = nullptr; 1548 m_pagePopup = nullptr;
1550 } 1549 }
1551 1550
1552 Frame* WebViewImpl::focusedWebCoreFrame() const 1551 Frame* WebViewImpl::focusedCoreFrame() const
1553 { 1552 {
1554 return m_page ? m_page->focusController().focusedOrMainFrame() : 0; 1553 return m_page ? m_page->focusController().focusedOrMainFrame() : 0;
1555 } 1554 }
1556 1555
1557 WebViewImpl* WebViewImpl::fromPage(Page* page) 1556 WebViewImpl* WebViewImpl::fromPage(Page* page)
1558 { 1557 {
1559 if (!page) 1558 if (!page)
1560 return 0; 1559 return 0;
1561 return static_cast<WebViewImpl*>(page->chrome().client().webView()); 1560 return static_cast<WebViewImpl*>(page->chrome().client().webView());
1562 } 1561 }
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 } 2056 }
2058 } 2057 }
2059 } 2058 }
2060 2059
2061 bool WebViewImpl::setComposition( 2060 bool WebViewImpl::setComposition(
2062 const WebString& text, 2061 const WebString& text,
2063 const WebVector<WebCompositionUnderline>& underlines, 2062 const WebVector<WebCompositionUnderline>& underlines,
2064 int selectionStart, 2063 int selectionStart,
2065 int selectionEnd) 2064 int selectionEnd)
2066 { 2065 {
2067 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); 2066 LocalFrame* focused = toLocalFrame(focusedCoreFrame());
2068 if (!focused || !m_imeAcceptEvents) 2067 if (!focused || !m_imeAcceptEvents)
2069 return false; 2068 return false;
2070 2069
2071 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) 2070 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
2072 return plugin->setComposition(text, underlines, selectionStart, selectio nEnd); 2071 return plugin->setComposition(text, underlines, selectionStart, selectio nEnd);
2073 2072
2074 // The input focus has been moved to another WebWidget object. 2073 // The input focus has been moved to another WebWidget object.
2075 // We should use this |editor| object only to complete the ongoing 2074 // We should use this |editor| object only to complete the ongoing
2076 // composition. 2075 // composition.
2077 InputMethodController& inputMethodController = focused->inputMethodControlle r(); 2076 InputMethodController& inputMethodController = focused->inputMethodControlle r();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 return confirmComposition(WebString(), selectionBehavior); 2122 return confirmComposition(WebString(), selectionBehavior);
2124 } 2123 }
2125 2124
2126 bool WebViewImpl::confirmComposition(const WebString& text) 2125 bool WebViewImpl::confirmComposition(const WebString& text)
2127 { 2126 {
2128 return confirmComposition(text, DoNotKeepSelection); 2127 return confirmComposition(text, DoNotKeepSelection);
2129 } 2128 }
2130 2129
2131 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe havior selectionBehavior) 2130 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe havior selectionBehavior)
2132 { 2131 {
2133 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); 2132 LocalFrame* focused = toLocalFrame(focusedCoreFrame());
2134 if (!focused || !m_imeAcceptEvents) 2133 if (!focused || !m_imeAcceptEvents)
2135 return false; 2134 return false;
2136 2135
2137 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) 2136 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused))
2138 return plugin->confirmComposition(text, selectionBehavior); 2137 return plugin->confirmComposition(text, selectionBehavior);
2139 2138
2140 return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp utMethodController::DoNotKeepSelection); 2139 return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp utMethodController::DoNotKeepSelection);
2141 } 2140 }
2142 2141
2143 bool WebViewImpl::compositionRange(size_t* location, size_t* length) 2142 bool WebViewImpl::compositionRange(size_t* location, size_t* length)
2144 { 2143 {
2145 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); 2144 LocalFrame* focused = toLocalFrame(focusedCoreFrame());
2146 if (!focused || !m_imeAcceptEvents) 2145 if (!focused || !m_imeAcceptEvents)
2147 return false; 2146 return false;
2148 2147
2149 RefPtrWillBeRawPtr<Range> range = focused->inputMethodController().compositi onRange(); 2148 RefPtrWillBeRawPtr<Range> range = focused->inputMethodController().compositi onRange();
2150 if (!range) 2149 if (!range)
2151 return false; 2150 return false;
2152 2151
2153 Element* editable = focused->selection().rootEditableElementOrDocumentElemen t(); 2152 Element* editable = focused->selection().rootEditableElementOrDocumentElemen t();
2154 ASSERT(editable); 2153 ASSERT(editable);
2155 PlainTextRange plainTextRange(PlainTextRange::create(*editable, *range.get() )); 2154 PlainTextRange plainTextRange(PlainTextRange::create(*editable, *range.get() ));
2156 if (plainTextRange.isNull()) 2155 if (plainTextRange.isNull())
2157 return false; 2156 return false;
2158 *location = plainTextRange.start(); 2157 *location = plainTextRange.start();
2159 *length = plainTextRange.length(); 2158 *length = plainTextRange.length();
2160 return true; 2159 return true;
2161 } 2160 }
2162 2161
2163 WebTextInputInfo WebViewImpl::textInputInfo() 2162 WebTextInputInfo WebViewImpl::textInputInfo()
2164 { 2163 {
2165 WebTextInputInfo info; 2164 WebTextInputInfo info;
2166 2165
2167 Frame* focusedFrame = focusedWebCoreFrame(); 2166 Frame* focusedFrame = focusedCoreFrame();
2168 if (!focusedFrame->isLocalFrame()) 2167 if (!focusedFrame->isLocalFrame())
2169 return info; 2168 return info;
2170 2169
2171 LocalFrame* focused = toLocalFrame(focusedFrame); 2170 LocalFrame* focused = toLocalFrame(focusedFrame);
2172 if (!focused) 2171 if (!focused)
2173 return info; 2172 return info;
2174 2173
2175 FrameSelection& selection = focused->selection(); 2174 FrameSelection& selection = focused->selection();
2176 Element* element = selection.selection().rootEditableElement(); 2175 Element* element = selection.selection().rootEditableElement();
2177 if (!element) 2176 if (!element)
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2319 if (isHTMLTextAreaElement(*element)) { 2318 if (isHTMLTextAreaElement(*element)) {
2320 const HTMLTextAreaElement& textarea = toHTMLTextAreaElement(*element); 2319 const HTMLTextAreaElement& textarea = toHTMLTextAreaElement(*element);
2321 return textarea.fastGetAttribute(HTMLNames::inputmodeAttr).lower(); 2320 return textarea.fastGetAttribute(HTMLNames::inputmodeAttr).lower();
2322 } 2321 }
2323 2322
2324 return WebString(); 2323 return WebString();
2325 } 2324 }
2326 2325
2327 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const 2326 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const
2328 { 2327 {
2329 const Frame* frame = focusedWebCoreFrame(); 2328 const Frame* frame = focusedCoreFrame();
2330 if (!frame || !frame->isLocalFrame()) 2329 if (!frame || !frame->isLocalFrame())
2331 return false; 2330 return false;
2332 2331
2333 const LocalFrame* localFrame = toLocalFrame(frame); 2332 const LocalFrame* localFrame = toLocalFrame(frame);
2334 if (!localFrame) 2333 if (!localFrame)
2335 return false; 2334 return false;
2336 FrameSelection& selection = localFrame->selection(); 2335 FrameSelection& selection = localFrame->selection();
2337 2336
2338 if (selection.isCaret()) { 2337 if (selection.isCaret()) {
2339 anchor = focus = selection.absoluteCaretBounds(); 2338 anchor = focus = selection.absoluteCaretBounds();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2378 if (!selection.selection().isBaseFirst()) 2377 if (!selection.selection().isBaseFirst())
2379 std::swap(anchor, focus); 2378 std::swap(anchor, focus);
2380 return true; 2379 return true;
2381 } 2380 }
2382 2381
2383 InputMethodContext* WebViewImpl::inputMethodContext() 2382 InputMethodContext* WebViewImpl::inputMethodContext()
2384 { 2383 {
2385 if (!m_imeAcceptEvents) 2384 if (!m_imeAcceptEvents)
2386 return 0; 2385 return 0;
2387 2386
2388 LocalFrame* focusedFrame = toLocalFrame(focusedWebCoreFrame()); 2387 LocalFrame* focusedFrame = toLocalFrame(focusedCoreFrame());
2389 if (!focusedFrame) 2388 if (!focusedFrame)
2390 return 0; 2389 return 0;
2391 2390
2392 Element* target = focusedFrame->document()->focusedElement(); 2391 Element* target = focusedFrame->document()->focusedElement();
2393 if (target && target->hasInputMethodContext()) 2392 if (target && target->hasInputMethodContext())
2394 return &target->inputMethodContext(); 2393 return &target->inputMethodContext();
2395 2394
2396 return 0; 2395 return 0;
2397 } 2396 }
2398 2397
(...skipping 18 matching lines...) Expand all
2417 } 2416 }
2418 2417
2419 void WebViewImpl::didHideCandidateWindow() 2418 void WebViewImpl::didHideCandidateWindow()
2420 { 2419 {
2421 if (InputMethodContext* context = inputMethodContext()) 2420 if (InputMethodContext* context = inputMethodContext())
2422 context->dispatchCandidateWindowHideEvent(); 2421 context->dispatchCandidateWindowHideEvent();
2423 } 2422 }
2424 2423
2425 bool WebViewImpl::selectionTextDirection(WebTextDirection& start, WebTextDirecti on& end) const 2424 bool WebViewImpl::selectionTextDirection(WebTextDirection& start, WebTextDirecti on& end) const
2426 { 2425 {
2427 const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); 2426 const LocalFrame* frame = toLocalFrame(focusedCoreFrame());
2428 if (!frame) 2427 if (!frame)
2429 return false; 2428 return false;
2430 FrameSelection& selection = frame->selection(); 2429 FrameSelection& selection = frame->selection();
2431 if (!selection.toNormalizedRange()) 2430 if (!selection.toNormalizedRange())
2432 return false; 2431 return false;
2433 start = toWebTextDirection(selection.start().primaryDirection()); 2432 start = toWebTextDirection(selection.start().primaryDirection());
2434 end = toWebTextDirection(selection.end().primaryDirection()); 2433 end = toWebTextDirection(selection.end().primaryDirection());
2435 return true; 2434 return true;
2436 } 2435 }
2437 2436
2438 bool WebViewImpl::isSelectionAnchorFirst() const 2437 bool WebViewImpl::isSelectionAnchorFirst() const
2439 { 2438 {
2440 if (const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame())) 2439 if (const LocalFrame* frame = toLocalFrame(focusedCoreFrame()))
2441 return frame->selection().selection().isBaseFirst(); 2440 return frame->selection().selection().isBaseFirst();
2442 return false; 2441 return false;
2443 } 2442 }
2444 2443
2445 WebVector<WebCompositionUnderline> WebViewImpl::compositionUnderlines() const 2444 WebVector<WebCompositionUnderline> WebViewImpl::compositionUnderlines() const
2446 { 2445 {
2447 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); 2446 const LocalFrame* focused = toLocalFrame(focusedCoreFrame());
2448 if (!focused) 2447 if (!focused)
2449 return WebVector<WebCompositionUnderline>(); 2448 return WebVector<WebCompositionUnderline>();
2450 const Vector<CompositionUnderline>& underlines = focused->inputMethodControl ler().customCompositionUnderlines(); 2449 const Vector<CompositionUnderline>& underlines = focused->inputMethodControl ler().customCompositionUnderlines();
2451 WebVector<WebCompositionUnderline> results(underlines.size()); 2450 WebVector<WebCompositionUnderline> results(underlines.size());
2452 for (size_t index = 0; index < underlines.size(); ++index) { 2451 for (size_t index = 0; index < underlines.size(); ++index) {
2453 CompositionUnderline underline = underlines[index]; 2452 CompositionUnderline underline = underlines[index];
2454 results[index] = WebCompositionUnderline(underline.startOffset, underlin e.endOffset, static_cast<WebColor>(underline.color.rgb()), underline.thick, stat ic_cast<WebColor>(underline.backgroundColor.rgb())); 2453 results[index] = WebCompositionUnderline(underline.startOffset, underlin e.endOffset, static_cast<WebColor>(underline.color.rgb()), underline.thick, stat ic_cast<WebColor>(underline.backgroundColor.rgb()));
2455 } 2454 }
2456 return results; 2455 return results;
2457 } 2456 }
2458 2457
2459 WebColor WebViewImpl::backgroundColor() const 2458 WebColor WebViewImpl::backgroundColor() const
2460 { 2459 {
2461 if (isTransparent()) 2460 if (isTransparent())
2462 return Color::transparent; 2461 return Color::transparent;
2463 if (!m_page) 2462 if (!m_page)
2464 return m_baseBackgroundColor; 2463 return m_baseBackgroundColor;
2465 if (!m_page->mainFrame()) 2464 if (!m_page->mainFrame())
2466 return m_baseBackgroundColor; 2465 return m_baseBackgroundColor;
2467 if (!m_page->mainFrame()->isLocalFrame()) 2466 if (!m_page->mainFrame()->isLocalFrame())
2468 return m_baseBackgroundColor; 2467 return m_baseBackgroundColor;
2469 FrameView* view = m_page->deprecatedLocalMainFrame()->view(); 2468 FrameView* view = m_page->deprecatedLocalMainFrame()->view();
2470 return view->documentBackgroundColor().rgb(); 2469 return view->documentBackgroundColor().rgb();
2471 } 2470 }
2472 2471
2473 bool WebViewImpl::caretOrSelectionRange(size_t* location, size_t* length) 2472 bool WebViewImpl::caretOrSelectionRange(size_t* location, size_t* length)
2474 { 2473 {
2475 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); 2474 const LocalFrame* focused = toLocalFrame(focusedCoreFrame());
2476 if (!focused) 2475 if (!focused)
2477 return false; 2476 return false;
2478 2477
2479 PlainTextRange selectionOffsets = focused->inputMethodController().getSelect ionOffsets(); 2478 PlainTextRange selectionOffsets = focused->inputMethodController().getSelect ionOffsets();
2480 if (selectionOffsets.isNull()) 2479 if (selectionOffsets.isNull())
2481 return false; 2480 return false;
2482 2481
2483 *location = selectionOffsets.start(); 2482 *location = selectionOffsets.start();
2484 *length = selectionOffsets.length(); 2483 *length = selectionOffsets.length();
2485 return true; 2484 return true;
2486 } 2485 }
2487 2486
2488 void WebViewImpl::setTextDirection(WebTextDirection direction) 2487 void WebViewImpl::setTextDirection(WebTextDirection direction)
2489 { 2488 {
2490 // The Editor::setBaseWritingDirection() function checks if we can change 2489 // The Editor::setBaseWritingDirection() function checks if we can change
2491 // the text direction of the selected node and updates its DOM "dir" 2490 // the text direction of the selected node and updates its DOM "dir"
2492 // attribute and its CSS "direction" property. 2491 // attribute and its CSS "direction" property.
2493 // So, we just call the function as Safari does. 2492 // So, we just call the function as Safari does.
2494 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); 2493 const LocalFrame* focused = toLocalFrame(focusedCoreFrame());
2495 if (!focused) 2494 if (!focused)
2496 return; 2495 return;
2497 2496
2498 Editor& editor = focused->editor(); 2497 Editor& editor = focused->editor();
2499 if (!editor.canEdit()) 2498 if (!editor.canEdit())
2500 return; 2499 return;
2501 2500
2502 switch (direction) { 2501 switch (direction) {
2503 case WebTextDirectionDefault: 2502 case WebTextDirectionDefault:
2504 editor.setBaseWritingDirection(NaturalWritingDirection); 2503 editor.setBaseWritingDirection(NaturalWritingDirection);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2613 relativeToFrame = mainFrame(); 2612 relativeToFrame = mainFrame();
2614 Frame* frame = toWebLocalFrameImpl(relativeToFrame)->frame(); 2613 Frame* frame = toWebLocalFrameImpl(relativeToFrame)->frame();
2615 frame = frame->tree().find(name); 2614 frame = frame->tree().find(name);
2616 if (!frame || !frame->isLocalFrame()) 2615 if (!frame || !frame->isLocalFrame())
2617 return 0; 2616 return 0;
2618 return WebLocalFrameImpl::fromFrame(toLocalFrame(frame)); 2617 return WebLocalFrameImpl::fromFrame(toLocalFrame(frame));
2619 } 2618 }
2620 2619
2621 WebFrame* WebViewImpl::focusedFrame() 2620 WebFrame* WebViewImpl::focusedFrame()
2622 { 2621 {
2623 return WebFrame::fromFrame(focusedWebCoreFrame()); 2622 return WebFrame::fromFrame(focusedCoreFrame());
2624 } 2623 }
2625 2624
2626 void WebViewImpl::setFocusedFrame(WebFrame* frame) 2625 void WebViewImpl::setFocusedFrame(WebFrame* frame)
2627 { 2626 {
2628 if (!frame) { 2627 if (!frame) {
2629 // Clears the focused frame if any. 2628 // Clears the focused frame if any.
2630 Frame* focusedFrame = focusedWebCoreFrame(); 2629 Frame* focusedFrame = focusedCoreFrame();
2631 if (focusedFrame && focusedFrame->isLocalFrame()) 2630 if (focusedFrame && focusedFrame->isLocalFrame())
2632 toLocalFrame(focusedFrame)->selection().setFocused(false); 2631 toLocalFrame(focusedFrame)->selection().setFocused(false);
2633 return; 2632 return;
2634 } 2633 }
2635 LocalFrame* webcoreFrame = toWebLocalFrameImpl(frame)->frame(); 2634 LocalFrame* coreFrame = toWebLocalFrameImpl(frame)->frame();
2636 webcoreFrame->page()->focusController().setFocusedFrame(webcoreFrame); 2635 coreFrame->page()->focusController().setFocusedFrame(coreFrame);
2637 } 2636 }
2638 2637
2639 void WebViewImpl::setInitialFocus(bool reverse) 2638 void WebViewImpl::setInitialFocus(bool reverse)
2640 { 2639 {
2641 if (!m_page) 2640 if (!m_page)
2642 return; 2641 return;
2643 Frame* frame = page()->focusController().focusedOrMainFrame(); 2642 Frame* frame = page()->focusController().focusedOrMainFrame();
2644 if (frame->isLocalFrame()) { 2643 if (frame->isLocalFrame()) {
2645 if (Document* document = toLocalFrame(frame)->document()) 2644 if (Document* document = toLocalFrame(frame)->document())
2646 document->setFocusedElement(nullptr); 2645 document->setFocusedElement(nullptr);
2647 } 2646 }
2648 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward); 2647 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward);
2649 } 2648 }
2650 2649
2651 void WebViewImpl::clearFocusedElement() 2650 void WebViewImpl::clearFocusedElement()
2652 { 2651 {
2653 RefPtr<Frame> frame = focusedWebCoreFrame(); 2652 RefPtr<Frame> frame = focusedCoreFrame();
2654 if (!frame || !frame->isLocalFrame()) 2653 if (!frame || !frame->isLocalFrame())
2655 return; 2654 return;
2656 2655
2657 LocalFrame* localFrame = toLocalFrame(frame.get()); 2656 LocalFrame* localFrame = toLocalFrame(frame.get());
2658 2657
2659 RefPtrWillBeRawPtr<Document> document = localFrame->document(); 2658 RefPtrWillBeRawPtr<Document> document = localFrame->document();
2660 if (!document) 2659 if (!document)
2661 return; 2660 return;
2662 2661
2663 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement(); 2662 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement();
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
3564 3563
3565 page()->contextMenuController().clearContextMenu(); 3564 page()->contextMenuController().clearContextMenu();
3566 m_contextMenuAllowed = true; 3565 m_contextMenuAllowed = true;
3567 if (LocalFrame* focusedFrame = toLocalFrame(page()->focusController().focuse dOrMainFrame())) 3566 if (LocalFrame* focusedFrame = toLocalFrame(page()->focusController().focuse dOrMainFrame()))
3568 focusedFrame->eventHandler().sendContextMenuEventForKey(); 3567 focusedFrame->eventHandler().sendContextMenuEventForKey();
3569 m_contextMenuAllowed = false; 3568 m_contextMenuAllowed = false;
3570 } 3569 }
3571 3570
3572 void WebViewImpl::extractSmartClipData(WebRect rect, WebString& clipText, WebStr ing& clipHtml, WebRect& clipRect) 3571 void WebViewImpl::extractSmartClipData(WebRect rect, WebString& clipText, WebStr ing& clipHtml, WebRect& clipRect)
3573 { 3572 {
3574 LocalFrame* localFrame = toLocalFrame(focusedWebCoreFrame()); 3573 LocalFrame* localFrame = toLocalFrame(focusedCoreFrame());
3575 if (!localFrame) 3574 if (!localFrame)
3576 return; 3575 return;
3577 SmartClipData clipData = SmartClip(localFrame).dataForRect(rect); 3576 SmartClipData clipData = SmartClip(localFrame).dataForRect(rect);
3578 clipText = clipData.clipData(); 3577 clipText = clipData.clipData();
3579 clipRect = clipData.rect(); 3578 clipRect = clipData.rect();
3580 3579
3581 WebLocalFrameImpl* frame = mainFrameImpl(); 3580 WebLocalFrameImpl* frame = mainFrameImpl();
3582 if (!frame) 3581 if (!frame)
3583 return; 3582 return;
3584 WebPoint startPoint(rect.x, rect.y); 3583 WebPoint startPoint(rect.x, rect.y);
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
4258 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4257 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4259 4258
4260 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4259 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4261 return false; 4260 return false;
4262 4261
4263 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4262 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4264 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4263 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4265 } 4264 }
4266 4265
4267 } // namespace blink 4266 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | public/web/WebFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698