Source/WebKit/chromium/ChangeLog

 12011-10-11 Nico Weber <[email protected]>
 2
 3 [chromium] Add a setSelectionToRange() method to WebFrame.
 4 https://bugs.webkit.org/show_bug.cgi?id=69846
 5
 6 Also add a method to WebRange to create a range given a frame and an
 7 interval.
 8
 9 This will be used to implement the "replacement range" feature of OS X
 10 IMEs, see http://codereview.chromium.org/8227018 (the change to
 11 render_widget.cc).
 12 The renderer will set the selection to the replacement range before
 13 calling confirmComposition(). This matches how WK2 does this, see
 14 Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm,
 15 WebPage::setComposition(). The function convertToRange() was taken
 16 from there, too.
 17
 18 Reviewed by NOBODY (OOPS!).
 19
 20 * public/WebFrame.h:
 21 (WebKit::WebFrame::setSelection):
 22 * src/WebFrameImpl.cpp:
 23 (WebKit::convertToRange):
 24 (WebKit::WebViewImpl::setSelection):
 25 * src/WebFrameImpl.h:
 26
1272011-10-10 Pavel Podivilov <[email protected]>
228
329 Unreviewed, mark CCThreadTest.startPostAndWaitOnCondition as flaky on win and mac.

Source/WebKit/chromium/public/WebFrame.h

@@public:
382382
383383 virtual WebRange markedRange() const = 0;
384384
 385 virtual void setSelectionToRange(const WebRange&) = 0;
 386
385387 // Returns the frame rectangle in window coordinate space of the given text
386388 // range.
387389 virtual bool firstRectForCharacterRange(unsigned location, unsigned length, WebRect&) const = 0;

Source/WebKit/chromium/public/WebRange.h

@@namespace WTF { template <typename T> class PassRefPtr; }
4040
4141namespace WebKit {
4242
 43class WebFrame;
4344class WebNode;
4445class WebRangePrivate;
4546class WebString;

@@public:
7071 WEBKIT_EXPORT WebString toHTMLText() const;
7172 WEBKIT_EXPORT WebString toPlainText() const;
7273
 74 WEBKIT_EXPORT static WebRange fromGlobalRange(WebFrame*, int start, int length);
 75
7376#if WEBKIT_IMPLEMENTATION
7477 WebRange(const WTF::PassRefPtr<WebCore::Range>&);
7578 WebRange& operator=(const WTF::PassRefPtr<WebCore::Range>&);

Source/WebKit/chromium/src/WebFrameImpl.cpp

@@WebRange WebFrameImpl::markedRange() const
10971097 return frame()->editor()->compositionRange();
10981098}
10991099
 1100void WebFrameImpl::setSelectionToRange(const WebRange& range)
 1101{
 1102 if (frame()->selection()->isContentEditable()) {
 1103 RefPtr<Range> replacementRange = static_cast<PassRefPtr<WebCore::Range> >(range);
 1104 frame()->selection()->setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY));
 1105 }
 1106}
 1107
11001108bool WebFrameImpl::firstRectForCharacterRange(unsigned location, unsigned length, WebRect& rect) const
11011109{
11021110 if ((location + length < location) && (location + length))

Source/WebKit/chromium/src/WebFrameImpl.h

3737#include "Frame.h"
3838#include "FrameLoaderClientImpl.h"
3939#include "PlatformString.h"
 40#include <wtf/Compiler.h>
4041#include <wtf/OwnPtr.h>
4142#include <wtf/RefCounted.h>
4243

@@public:
148149 virtual void unmarkText();
149150 virtual bool hasMarkedText() const;
150151 virtual WebRange markedRange() const;
 152 virtual void setSelectionToRange(const WebRange&) OVERRIDE;
151153 virtual bool firstRectForCharacterRange(unsigned location, unsigned length, WebRect&) const;
152154 virtual size_t characterIndexForPoint(const WebPoint&) const;
153155 virtual bool executeCommand(const WebString&, const WebNode& = WebNode());

Source/WebKit/chromium/src/WebRange.cpp

3131#include "config.h"
3232#include "WebRange.h"
3333
 34#include "Document.h"
 35#include "Frame.h"
3436#include "Range.h"
 37#include "TextIterator.h"
 38#include "WebFrameImpl.h"
3539#include "WebNode.h"
3640#include "WebString.h"
3741#include <wtf/PassRefPtr.h>

@@WebString WebRange::toPlainText() const
8690 return m_private->text();
8791}
8892
 93// static
 94WebRange WebRange::fromGlobalRange(WebFrame* frame, int start, int length)
 95{
 96 WebCore::Frame* webFrame = static_cast<WebFrameImpl*>(frame)->frame();
 97 Element* selectionRoot = webFrame->selection()->rootEditableElement();
 98 Element* scope = selectionRoot ? selectionRoot : webFrame->document()->documentElement();
 99 return TextIterator::rangeFromLocationAndLength(scope, start, length);
 100}
 101
89102WebRange::WebRange(const WTF::PassRefPtr<WebCore::Range>& range)
90103 : m_private(static_cast<WebRangePrivate*>(range.releaseRef()))
91104{