| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 Google Inc. All Rights Reserved. | 2 * Copyright 2007 Google Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * ***** BEGIN LICENSE BLOCK ***** | 6 * ***** BEGIN LICENSE BLOCK ***** |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 *enable_ime = node->shouldUseInputMethod() && | 1185 *enable_ime = node->shouldUseInputMethod() && |
| 1186 !controller->isInPasswordField(); | 1186 !controller->isInPasswordField(); |
| 1187 const FrameView* view = node->document()->view(); | 1187 const FrameView* view = node->document()->view(); |
| 1188 if (!view) | 1188 if (!view) |
| 1189 return false; | 1189 return false; |
| 1190 const IntRect rect(view->contentsToWindow(controller->absoluteCaretBounds())); | 1190 const IntRect rect(view->contentsToWindow(controller->absoluteCaretBounds())); |
| 1191 caret_rect->SetRect(rect.x(), rect.y(), rect.width(), rect.height()); | 1191 caret_rect->SetRect(rect.x(), rect.y(), rect.width(), rect.height()); |
| 1192 return true; | 1192 return true; |
| 1193 } | 1193 } |
| 1194 | 1194 |
| 1195 void WebViewImpl::SetTextDirection(WebTextDirection direction) { |
| 1196 // The Editor::setBaseWritingDirection() function checks if we can change |
| 1197 // the text direction of the selected node and updates its DOM "dir" |
| 1198 // attribute and its CSS "direction" property. |
| 1199 // So, we just call the function as Safari does. |
| 1200 const Frame* focused = GetFocusedWebCoreFrame(); |
| 1201 if (!focused) |
| 1202 return; |
| 1203 Editor* editor = focused->editor(); |
| 1204 if (!editor || !editor->canEdit()) |
| 1205 return; |
| 1206 |
| 1207 switch (direction) { |
| 1208 case WEB_TEXT_DIRECTION_DEFAULT: |
| 1209 editor->setBaseWritingDirection(WebCore::NaturalWritingDirection); |
| 1210 break; |
| 1211 |
| 1212 case WEB_TEXT_DIRECTION_LTR: |
| 1213 editor->setBaseWritingDirection(WebCore::LeftToRightWritingDirection); |
| 1214 break; |
| 1215 |
| 1216 case WEB_TEXT_DIRECTION_RTL: |
| 1217 editor->setBaseWritingDirection(WebCore::RightToLeftWritingDirection); |
| 1218 break; |
| 1219 |
| 1220 default: |
| 1221 NOTIMPLEMENTED(); |
| 1222 break; |
| 1223 } |
| 1224 } |
| 1225 |
| 1195 void WebViewImpl::RestoreFocus() { | 1226 void WebViewImpl::RestoreFocus() { |
| 1196 if (last_focused_frame_.get()) { | 1227 if (last_focused_frame_.get()) { |
| 1197 if (last_focused_frame_->page()) { | 1228 if (last_focused_frame_->page()) { |
| 1198 // last_focused_frame_ can be detached from the frame tree, thus, | 1229 // last_focused_frame_ can be detached from the frame tree, thus, |
| 1199 // its page can be null. | 1230 // its page can be null. |
| 1200 last_focused_frame_->page()->focusController()->setFocusedFrame( | 1231 last_focused_frame_->page()->focusController()->setFocusedFrame( |
| 1201 last_focused_frame_.get()); | 1232 last_focused_frame_.get()); |
| 1202 } | 1233 } |
| 1203 if (last_focused_node_.get()) { | 1234 if (last_focused_node_.get()) { |
| 1204 // last_focused_node_ may be null, make sure it's valid before trying to | 1235 // last_focused_node_ may be null, make sure it's valid before trying to |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 Frame* frame = page_->focusController()->focusedFrame(); | 1737 Frame* frame = page_->focusController()->focusedFrame(); |
| 1707 if (!frame) | 1738 if (!frame) |
| 1708 return NULL; | 1739 return NULL; |
| 1709 | 1740 |
| 1710 Document* document = frame->document(); | 1741 Document* document = frame->document(); |
| 1711 if (!document) | 1742 if (!document) |
| 1712 return NULL; | 1743 return NULL; |
| 1713 | 1744 |
| 1714 return document->focusedNode(); | 1745 return document->focusedNode(); |
| 1715 } | 1746 } |
| OLD | NEW |