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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 #include "core/rendering/RenderView.h" | 162 #include "core/rendering/RenderView.h" |
163 #include "core/rendering/style/StyleInheritedData.h" | 163 #include "core/rendering/style/StyleInheritedData.h" |
164 #include "core/timing/Performance.h" | 164 #include "core/timing/Performance.h" |
165 #include "platform/TraceEvent.h" | 165 #include "platform/TraceEvent.h" |
166 #include "platform/UserGestureIndicator.h" | 166 #include "platform/UserGestureIndicator.h" |
167 #include "platform/clipboard/ClipboardUtilities.h" | 167 #include "platform/clipboard/ClipboardUtilities.h" |
168 #include "platform/fonts/FontCache.h" | 168 #include "platform/fonts/FontCache.h" |
169 #include "platform/graphics/GraphicsContext.h" | 169 #include "platform/graphics/GraphicsContext.h" |
170 #include "platform/graphics/GraphicsLayerClient.h" | 170 #include "platform/graphics/GraphicsLayerClient.h" |
171 #include "platform/graphics/skia/SkiaUtils.h" | 171 #include "platform/graphics/skia/SkiaUtils.h" |
| 172 #include "platform/heap/Handle.h" |
172 #include "platform/network/ResourceRequest.h" | 173 #include "platform/network/ResourceRequest.h" |
173 #include "platform/scroll/ScrollbarTheme.h" | 174 #include "platform/scroll/ScrollbarTheme.h" |
174 #include "platform/scroll/ScrollTypes.h" | 175 #include "platform/scroll/ScrollTypes.h" |
175 #include "platform/weborigin/KURL.h" | 176 #include "platform/weborigin/KURL.h" |
176 #include "platform/weborigin/SchemeRegistry.h" | 177 #include "platform/weborigin/SchemeRegistry.h" |
177 #include "platform/weborigin/SecurityPolicy.h" | 178 #include "platform/weborigin/SecurityPolicy.h" |
178 #include "public/platform/Platform.h" | 179 #include "public/platform/Platform.h" |
179 #include "public/platform/WebFloatPoint.h" | 180 #include "public/platform/WebFloatPoint.h" |
180 #include "public/platform/WebFloatRect.h" | 181 #include "public/platform/WebFloatRect.h" |
181 #include "public/platform/WebLayer.h" | 182 #include "public/platform/WebLayer.h" |
(...skipping 21 matching lines...) Expand all Loading... |
203 return; | 204 return; |
204 | 205 |
205 if (!frame->view()) | 206 if (!frame->view()) |
206 return; | 207 return; |
207 | 208 |
208 // TextIterator iterates over the visual representation of the DOM. As such, | 209 // TextIterator iterates over the visual representation of the DOM. As such, |
209 // it requires you to do a layout before using it (otherwise it'll crash). | 210 // it requires you to do a layout before using it (otherwise it'll crash). |
210 document->updateLayout(); | 211 document->updateLayout(); |
211 | 212 |
212 // Select the document body. | 213 // Select the document body. |
213 RefPtr<Range> range(document->createRange()); | 214 RefPtrWillBeRawPtr<Range> range(document->createRange()); |
214 TrackExceptionState exceptionState; | 215 TrackExceptionState exceptionState; |
215 range->selectNodeContents(document->body(), exceptionState); | 216 range->selectNodeContents(document->body(), exceptionState); |
216 | 217 |
217 if (!exceptionState.hadException()) { | 218 if (!exceptionState.hadException()) { |
218 // The text iterator will walk nodes giving us text. This is similar to | 219 // The text iterator will walk nodes giving us text. This is similar to |
219 // the plainText() function in core/editing/TextIterator.h, but we imple
ment the maximum | 220 // the plainText() function in core/editing/TextIterator.h, but we imple
ment the maximum |
220 // size and also copy the results directly into a wstring, avoiding the | 221 // size and also copy the results directly into a wstring, avoiding the |
221 // string conversion. | 222 // string conversion. |
222 for (TextIterator it(range.get()); !it.atEnd(); it.advance()) { | 223 for (TextIterator it(range.get()); !it.atEnd(); it.advance()) { |
223 it.appendTextToStringBuilder(output, 0, maxChars - output.length()); | 224 it.appendTextToStringBuilder(output, 0, maxChars - output.length()); |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 return frame()->inputMethodController().compositionRange(); | 1078 return frame()->inputMethodController().compositionRange(); |
1078 } | 1079 } |
1079 | 1080 |
1080 bool WebFrameImpl::firstRectForCharacterRange(unsigned location, unsigned length
, WebRect& rect) const | 1081 bool WebFrameImpl::firstRectForCharacterRange(unsigned location, unsigned length
, WebRect& rect) const |
1081 { | 1082 { |
1082 if ((location + length < location) && (location + length)) | 1083 if ((location + length < location) && (location + length)) |
1083 length = 0; | 1084 length = 0; |
1084 | 1085 |
1085 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); | 1086 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); |
1086 ASSERT(editable); | 1087 ASSERT(editable); |
1087 RefPtr<Range> range = PlainTextRange(location, location + length).createRang
e(*editable); | 1088 RefPtrWillBeRawPtr<Range> range = PlainTextRange(location, location + length
).createRange(*editable); |
1088 if (!range) | 1089 if (!range) |
1089 return false; | 1090 return false; |
1090 IntRect intRect = frame()->editor().firstRectForRange(range.get()); | 1091 IntRect intRect = frame()->editor().firstRectForRange(range.get()); |
1091 rect = WebRect(intRect); | 1092 rect = WebRect(intRect); |
1092 rect = frame()->view()->contentsToWindow(rect); | 1093 rect = frame()->view()->contentsToWindow(rect); |
1093 return true; | 1094 return true; |
1094 } | 1095 } |
1095 | 1096 |
1096 size_t WebFrameImpl::characterIndexForPoint(const WebPoint& webPoint) const | 1097 size_t WebFrameImpl::characterIndexForPoint(const WebPoint& webPoint) const |
1097 { | 1098 { |
1098 if (!frame()) | 1099 if (!frame()) |
1099 return kNotFound; | 1100 return kNotFound; |
1100 | 1101 |
1101 IntPoint point = frame()->view()->windowToContents(webPoint); | 1102 IntPoint point = frame()->view()->windowToContents(webPoint); |
1102 HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(point, H
itTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ConfusingAndO
ftenMisusedDisallowShadowContent); | 1103 HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(point, H
itTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ConfusingAndO
ftenMisusedDisallowShadowContent); |
1103 RefPtr<Range> range = frame()->rangeForPoint(result.roundedPointInInnerNodeF
rame()); | 1104 RefPtrWillBeRawPtr<Range> range = frame()->rangeForPoint(result.roundedPoint
InInnerNodeFrame()); |
1104 if (!range) | 1105 if (!range) |
1105 return kNotFound; | 1106 return kNotFound; |
1106 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); | 1107 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); |
1107 ASSERT(editable); | 1108 ASSERT(editable); |
1108 return PlainTextRange::create(*editable, *range.get()).start(); | 1109 return PlainTextRange::create(*editable, *range.get()).start(); |
1109 } | 1110 } |
1110 | 1111 |
1111 bool WebFrameImpl::executeCommand(const WebString& name, const WebNode& node) | 1112 bool WebFrameImpl::executeCommand(const WebString& name, const WebNode& node) |
1112 { | 1113 { |
1113 ASSERT(frame()); | 1114 ASSERT(frame()); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 if (webElement.isNull()) | 1204 if (webElement.isNull()) |
1204 return; | 1205 return; |
1205 frame()->spellChecker().requestTextChecking(*webElement.constUnwrap<Element>
()); | 1206 frame()->spellChecker().requestTextChecking(*webElement.constUnwrap<Element>
()); |
1206 } | 1207 } |
1207 | 1208 |
1208 void WebFrameImpl::replaceMisspelledRange(const WebString& text) | 1209 void WebFrameImpl::replaceMisspelledRange(const WebString& text) |
1209 { | 1210 { |
1210 // If this caret selection has two or more markers, this function replace th
e range covered by the first marker with the specified word as Microsoft Word do
es. | 1211 // If this caret selection has two or more markers, this function replace th
e range covered by the first marker with the specified word as Microsoft Word do
es. |
1211 if (pluginContainerFromFrame(frame())) | 1212 if (pluginContainerFromFrame(frame())) |
1212 return; | 1213 return; |
1213 RefPtr<Range> caretRange = frame()->selection().toNormalizedRange(); | 1214 RefPtrWillBeRawPtr<Range> caretRange = frame()->selection().toNormalizedRang
e(); |
1214 if (!caretRange) | 1215 if (!caretRange) |
1215 return; | 1216 return; |
1216 Vector<DocumentMarker*> markers = frame()->document()->markers().markersInRa
nge(caretRange.get(), DocumentMarker::MisspellingMarkers()); | 1217 Vector<DocumentMarker*> markers = frame()->document()->markers().markersInRa
nge(caretRange.get(), DocumentMarker::MisspellingMarkers()); |
1217 if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset
()) | 1218 if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset
()) |
1218 return; | 1219 return; |
1219 RefPtr<Range> markerRange = Range::create(caretRange->ownerDocument(), caret
Range->startContainer(), markers[0]->startOffset(), caretRange->endContainer(),
markers[0]->endOffset()); | 1220 RefPtrWillBeRawPtr<Range> markerRange = Range::create(caretRange->ownerDocum
ent(), caretRange->startContainer(), markers[0]->startOffset(), caretRange->endC
ontainer(), markers[0]->endOffset()); |
1220 if (!markerRange) | 1221 if (!markerRange) |
1221 return; | 1222 return; |
1222 frame()->selection().setSelection(VisibleSelection(markerRange.get()), Chara
cterGranularity); | 1223 frame()->selection().setSelection(VisibleSelection(markerRange.get()), Chara
cterGranularity); |
1223 frame()->editor().replaceSelectionWithText(text, false, false); | 1224 frame()->editor().replaceSelectionWithText(text, false, false); |
1224 } | 1225 } |
1225 | 1226 |
1226 void WebFrameImpl::removeSpellingMarkers() | 1227 void WebFrameImpl::removeSpellingMarkers() |
1227 { | 1228 { |
1228 frame()->document()->markers().removeMarkers(DocumentMarker::MisspellingMark
ers()); | 1229 frame()->document()->markers().removeMarkers(DocumentMarker::MisspellingMark
ers()); |
1229 } | 1230 } |
(...skipping 12 matching lines...) Expand all Loading... |
1242 { | 1243 { |
1243 return frame()->selection().toNormalizedRange(); | 1244 return frame()->selection().toNormalizedRange(); |
1244 } | 1245 } |
1245 | 1246 |
1246 WebString WebFrameImpl::selectionAsText() const | 1247 WebString WebFrameImpl::selectionAsText() const |
1247 { | 1248 { |
1248 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); | 1249 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); |
1249 if (pluginContainer) | 1250 if (pluginContainer) |
1250 return pluginContainer->plugin()->selectionAsText(); | 1251 return pluginContainer->plugin()->selectionAsText(); |
1251 | 1252 |
1252 RefPtr<Range> range = frame()->selection().toNormalizedRange(); | 1253 RefPtrWillBeRawPtr<Range> range = frame()->selection().toNormalizedRange(); |
1253 if (!range) | 1254 if (!range) |
1254 return WebString(); | 1255 return WebString(); |
1255 | 1256 |
1256 String text = range->text(); | 1257 String text = range->text(); |
1257 #if OS(WIN) | 1258 #if OS(WIN) |
1258 replaceNewlinesWithWindowsStyleNewlines(text); | 1259 replaceNewlinesWithWindowsStyleNewlines(text); |
1259 #endif | 1260 #endif |
1260 replaceNBSPWithSpace(text); | 1261 replaceNBSPWithSpace(text); |
1261 return text; | 1262 return text; |
1262 } | 1263 } |
1263 | 1264 |
1264 WebString WebFrameImpl::selectionAsMarkup() const | 1265 WebString WebFrameImpl::selectionAsMarkup() const |
1265 { | 1266 { |
1266 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); | 1267 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); |
1267 if (pluginContainer) | 1268 if (pluginContainer) |
1268 return pluginContainer->plugin()->selectionAsMarkup(); | 1269 return pluginContainer->plugin()->selectionAsMarkup(); |
1269 | 1270 |
1270 RefPtr<Range> range = frame()->selection().toNormalizedRange(); | 1271 RefPtrWillBeRawPtr<Range> range = frame()->selection().toNormalizedRange(); |
1271 if (!range) | 1272 if (!range) |
1272 return WebString(); | 1273 return WebString(); |
1273 | 1274 |
1274 return createMarkup(range.get(), 0, AnnotateForInterchange, false, ResolveNo
nLocalURLs); | 1275 return createMarkup(range.get(), 0, AnnotateForInterchange, false, ResolveNo
nLocalURLs); |
1275 } | 1276 } |
1276 | 1277 |
1277 void WebFrameImpl::selectWordAroundPosition(LocalFrame* frame, VisiblePosition p
osition) | 1278 void WebFrameImpl::selectWordAroundPosition(LocalFrame* frame, VisiblePosition p
osition) |
1278 { | 1279 { |
1279 VisibleSelection selection(position); | 1280 VisibleSelection selection(position); |
1280 selection.expandUsingGranularity(WordGranularity); | 1281 selection.expandUsingGranularity(WordGranularity); |
(...skipping 12 matching lines...) Expand all Loading... |
1293 return true; | 1294 return true; |
1294 } | 1295 } |
1295 | 1296 |
1296 void WebFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent) | 1297 void WebFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent) |
1297 { | 1298 { |
1298 moveRangeSelection(base, extent); | 1299 moveRangeSelection(base, extent); |
1299 } | 1300 } |
1300 | 1301 |
1301 void WebFrameImpl::selectRange(const WebRange& webRange) | 1302 void WebFrameImpl::selectRange(const WebRange& webRange) |
1302 { | 1303 { |
1303 if (RefPtr<Range> range = static_cast<PassRefPtr<Range> >(webRange)) | 1304 if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Ran
ge> >(webRange)) |
1304 frame()->selection().setSelectedRange(range.get(), WebCore::VP_DEFAULT_A
FFINITY, false); | 1305 frame()->selection().setSelectedRange(range.get(), WebCore::VP_DEFAULT_A
FFINITY, false); |
1305 } | 1306 } |
1306 | 1307 |
1307 void WebFrameImpl::moveRangeSelection(const WebPoint& base, const WebPoint& exte
nt) | 1308 void WebFrameImpl::moveRangeSelection(const WebPoint& base, const WebPoint& exte
nt) |
1308 { | 1309 { |
1309 VisiblePosition basePosition = visiblePositionForWindowPoint(base); | 1310 VisiblePosition basePosition = visiblePositionForWindowPoint(base); |
1310 VisiblePosition extentPosition = visiblePositionForWindowPoint(extent); | 1311 VisiblePosition extentPosition = visiblePositionForWindowPoint(extent); |
1311 VisibleSelection newSelection = VisibleSelection(basePosition, extentPositio
n); | 1312 VisibleSelection newSelection = VisibleSelection(basePosition, extentPositio
n); |
1312 frame()->selection().setSelection(newSelection, CharacterGranularity); | 1313 frame()->selection().setSelection(newSelection, CharacterGranularity); |
1313 } | 1314 } |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 | 1972 |
1972 void WebFrameImpl::invalidateAll() const | 1973 void WebFrameImpl::invalidateAll() const |
1973 { | 1974 { |
1974 ASSERT(frame() && frame()->view()); | 1975 ASSERT(frame() && frame()->view()); |
1975 FrameView* view = frame()->view(); | 1976 FrameView* view = frame()->view(); |
1976 view->invalidateRect(view->frameRect()); | 1977 view->invalidateRect(view->frameRect()); |
1977 invalidateScrollbar(); | 1978 invalidateScrollbar(); |
1978 } | 1979 } |
1979 | 1980 |
1980 } // namespace blink | 1981 } // namespace blink |
OLD | NEW |