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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 Document* document = frame->document(); | 147 Document* document = frame->document(); |
148 if (!document) | 148 if (!document) |
149 return; | 149 return; |
150 | 150 |
151 if (!frame->view()) | 151 if (!frame->view()) |
152 return; | 152 return; |
153 | 153 |
154 // Select the document body. | 154 // Select the document body. |
155 RefPtr<Range> range(document->createRange()); | 155 RefPtr<Range> range(document->createRange()); |
156 TrackExceptionState exceptionState; | 156 TrackExceptionState exceptionState; |
157 range->selectNodeContents(document->documentElement(), exceptionState); | 157 range->selectNodeContents(document, exceptionState); |
158 | 158 |
159 if (!exceptionState.had_exception()) { | 159 if (!exceptionState.had_exception()) { |
160 // The text iterator will walk nodes giving us text. This is similar to | 160 // The text iterator will walk nodes giving us text. This is similar to |
161 // the plainText() function in core/editing/TextIterator.h, but we imple
ment the maximum | 161 // the plainText() function in core/editing/TextIterator.h, but we imple
ment the maximum |
162 // size and also copy the results directly into a wstring, avoiding the | 162 // size and also copy the results directly into a wstring, avoiding the |
163 // string conversion. | 163 // string conversion. |
164 for (TextIterator it(range.get()); !it.atEnd(); it.advance()) { | 164 for (TextIterator it(range.get()); !it.atEnd(); it.advance()) { |
165 it.appendTextToStringBuilder(output, 0, maxChars - output.length()); | 165 it.appendTextToStringBuilder(output, 0, maxChars - output.length()); |
166 if (output.length() >= maxChars) | 166 if (output.length() >= maxChars) |
167 return; // Filled up the buffer. | 167 return; // Filled up the buffer. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 void WebLocalFrameImpl::unmarkText() | 286 void WebLocalFrameImpl::unmarkText() |
287 { | 287 { |
288 frame()->inputMethodController().cancelComposition(); | 288 frame()->inputMethodController().cancelComposition(); |
289 } | 289 } |
290 | 290 |
291 bool WebLocalFrameImpl::hasMarkedText() const | 291 bool WebLocalFrameImpl::hasMarkedText() const |
292 { | 292 { |
293 return frame()->inputMethodController().hasComposition(); | 293 return frame()->inputMethodController().hasComposition(); |
294 } | 294 } |
295 | 295 |
296 WebRange WebLocalFrameImpl::markedRange() const | |
297 { | |
298 return frame()->inputMethodController().compositionRange(); | |
299 } | |
300 | |
301 bool WebLocalFrameImpl::firstRectForCharacterRange(unsigned location, unsigned l
ength, WebRect& rect) const | |
302 { | |
303 if ((location + length < location) && (location + length)) | |
304 length = 0; | |
305 | |
306 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); | |
307 ASSERT(editable); | |
308 RefPtr<Range> range = PlainTextRange(location, location + length).createRang
e(*editable); | |
309 if (!range) | |
310 return false; | |
311 IntRect intRect = frame()->editor().firstRectForRange(range.get()); | |
312 rect = WebRect(intRect); | |
313 rect = frame()->view()->contentsToWindow(rect); | |
314 return true; | |
315 } | |
316 | |
317 size_t WebLocalFrameImpl::characterIndexForPoint(const WebPoint& webPoint) const | |
318 { | |
319 if (!frame()) | |
320 return kNotFound; | |
321 | |
322 IntPoint point = frame()->view()->windowToContents(webPoint); | |
323 HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(point, H
itTestRequest::ReadOnly | HitTestRequest::Active); | |
324 RefPtr<Range> range = frame()->rangeForPoint(result.roundedPointInInnerNodeF
rame()); | |
325 if (!range) | |
326 return kNotFound; | |
327 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); | |
328 ASSERT(editable); | |
329 return PlainTextRange::create(*editable, *range.get()).start(); | |
330 } | |
331 | |
332 bool WebLocalFrameImpl::executeCommand(const WebString& name, const WebNode& nod
e) | 296 bool WebLocalFrameImpl::executeCommand(const WebString& name, const WebNode& nod
e) |
333 { | 297 { |
334 ASSERT(frame()); | 298 ASSERT(frame()); |
335 | 299 |
336 if (name.length() <= 2) | 300 if (name.length() <= 2) |
337 return false; | 301 return false; |
338 | 302 |
339 // Since we don't have NSControl, we will convert the format of command | 303 // Since we don't have NSControl, we will convert the format of command |
340 // string and call the function on Editor directly. | 304 // string and call the function on Editor directly. |
341 String command = name; | 305 String command = name; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 | 574 |
611 void WebLocalFrameImpl::setInputEventsTransformForEmulation(const IntSize& offse
t, float contentScaleFactor) | 575 void WebLocalFrameImpl::setInputEventsTransformForEmulation(const IntSize& offse
t, float contentScaleFactor) |
612 { | 576 { |
613 m_inputEventsOffsetForEmulation = offset; | 577 m_inputEventsOffsetForEmulation = offset; |
614 m_inputEventsScaleFactorForEmulation = contentScaleFactor; | 578 m_inputEventsScaleFactorForEmulation = contentScaleFactor; |
615 if (frame()->view()) | 579 if (frame()->view()) |
616 frame()->view()->setInputEventsTransformForEmulation(m_inputEventsOffset
ForEmulation, m_inputEventsScaleFactorForEmulation); | 580 frame()->view()->setInputEventsTransformForEmulation(m_inputEventsOffset
ForEmulation, m_inputEventsScaleFactorForEmulation); |
617 } | 581 } |
618 | 582 |
619 } // namespace blink | 583 } // namespace blink |
OLD | NEW |