OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 #include "Console.h" | 78 #include "Console.h" |
79 #include "DOMUtilitiesPrivate.h" | 79 #include "DOMUtilitiesPrivate.h" |
80 #include "DOMWindow.h" | 80 #include "DOMWindow.h" |
81 #include "Document.h" | 81 #include "Document.h" |
82 #include "DocumentFragment.h" // Only needed for ReplaceSelectionCommand.h :( | 82 #include "DocumentFragment.h" // Only needed for ReplaceSelectionCommand.h :( |
83 #include "DocumentLoader.h" | 83 #include "DocumentLoader.h" |
84 #include "DocumentMarker.h" | 84 #include "DocumentMarker.h" |
85 #include "DocumentMarkerController.h" | 85 #include "DocumentMarkerController.h" |
86 #include "Editor.h" | 86 #include "Editor.h" |
87 #include "EventHandler.h" | 87 #include "EventHandler.h" |
| 88 #include "FocusController.h" |
88 #include "FormState.h" | 89 #include "FormState.h" |
89 #include "FrameLoadRequest.h" | 90 #include "FrameLoadRequest.h" |
90 #include "FrameLoader.h" | 91 #include "FrameLoader.h" |
91 #include "FrameTree.h" | 92 #include "FrameTree.h" |
92 #include "FrameView.h" | 93 #include "FrameView.h" |
93 #include "HTMLCollection.h" | 94 #include "HTMLCollection.h" |
94 #include "HTMLFormElement.h" | 95 #include "HTMLFormElement.h" |
95 #include "HTMLFrameOwnerElement.h" | 96 #include "HTMLFrameOwnerElement.h" |
96 #include "HTMLHeadElement.h" | 97 #include "HTMLHeadElement.h" |
97 #include "HTMLInputElement.h" | 98 #include "HTMLInputElement.h" |
98 #include "HTMLLinkElement.h" | 99 #include "HTMLLinkElement.h" |
99 #include "HTMLNames.h" | 100 #include "HTMLNames.h" |
100 #include "HistoryItem.h" | 101 #include "HistoryItem.h" |
| 102 #include "HitTestResult.h" |
101 #include "InspectorController.h" | 103 #include "InspectorController.h" |
102 #include "Page.h" | 104 #include "Page.h" |
103 #include "painting/GraphicsContextBuilder.h" | 105 #include "painting/GraphicsContextBuilder.h" |
104 #include "Performance.h" | 106 #include "Performance.h" |
105 #include "PlatformBridge.h" | 107 #include "PlatformBridge.h" |
106 #include "PluginDocument.h" | 108 #include "PluginDocument.h" |
107 #include "PrintContext.h" | 109 #include "PrintContext.h" |
108 #include "RenderFrame.h" | 110 #include "RenderFrame.h" |
109 #include "RenderObject.h" | 111 #include "RenderObject.h" |
110 #include "RenderTreeAsText.h" | 112 #include "RenderTreeAsText.h" |
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 { | 1125 { |
1124 if ((location + length < location) && (location + length)) | 1126 if ((location + length < location) && (location + length)) |
1125 length = 0; | 1127 length = 0; |
1126 | 1128 |
1127 Element* selectionRoot = frame()->selection()->rootEditableElement(); | 1129 Element* selectionRoot = frame()->selection()->rootEditableElement(); |
1128 Element* scope = selectionRoot ? selectionRoot : frame()->document()->docume
ntElement(); | 1130 Element* scope = selectionRoot ? selectionRoot : frame()->document()->docume
ntElement(); |
1129 RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(scope, locati
on, length); | 1131 RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(scope, locati
on, length); |
1130 if (!range) | 1132 if (!range) |
1131 return false; | 1133 return false; |
1132 IntRect intRect = frame()->editor()->firstRectForRange(range.get()); | 1134 IntRect intRect = frame()->editor()->firstRectForRange(range.get()); |
1133 rect = WebRect(intRect.x(), intRect.y(), intRect.width(), intRect.height()); | 1135 rect = WebRect(intRect); |
| 1136 // When inside an text control, don't adjust the range. |
| 1137 if (!selectionRoot) |
| 1138 rect = frame()->view()->contentsToWindow(rect); |
1134 | 1139 |
1135 return true; | 1140 return true; |
1136 } | 1141 } |
1137 | 1142 |
| 1143 unsigned WebFrameImpl::characterIndexForPoint(const WebPoint& webPoint) const |
| 1144 { |
| 1145 if (!frame()) |
| 1146 return notFound; |
| 1147 |
| 1148 IntPoint point = frame()->view()->windowToContents(webPoint); |
| 1149 HitTestResult result = frame()->eventHandler()->hitTestResultAtPoint(point,
false); |
| 1150 RefPtr<Range> range = frame()->rangeForPoint(result.point()); |
| 1151 if (!range.get()) |
| 1152 return notFound; |
| 1153 |
| 1154 unsigned location, length; |
| 1155 range->getLocationAndLength(location, length); |
| 1156 return location; |
| 1157 } |
| 1158 |
1138 bool WebFrameImpl::executeCommand(const WebString& name) | 1159 bool WebFrameImpl::executeCommand(const WebString& name) |
1139 { | 1160 { |
1140 ASSERT(frame()); | 1161 ASSERT(frame()); |
1141 | 1162 |
1142 if (name.length() <= 2) | 1163 if (name.length() <= 2) |
1143 return false; | 1164 return false; |
1144 | 1165 |
1145 // Since we don't have NSControl, we will convert the format of command | 1166 // Since we don't have NSControl, we will convert the format of command |
1146 // string and call the function on Editor directly. | 1167 // string and call the function on Editor directly. |
1147 String command = name; | 1168 String command = name; |
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2287 | 2308 |
2288 String scriptResult; | 2309 String scriptResult; |
2289 if (!result.getString(scriptResult)) | 2310 if (!result.getString(scriptResult)) |
2290 return; | 2311 return; |
2291 | 2312 |
2292 if (!m_frame->navigationScheduler()->locationChangePending()) | 2313 if (!m_frame->navigationScheduler()->locationChangePending()) |
2293 m_frame->document()->loader()->writer()->replaceDocument(scriptResult); | 2314 m_frame->document()->loader()->writer()->replaceDocument(scriptResult); |
2294 } | 2315 } |
2295 | 2316 |
2296 } // namespace WebKit | 2317 } // namespace WebKit |
OLD | NEW |