Changeset 84951 in webkit


Ignore:
Timestamp:
Apr 26, 2011 2:06:09 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-04-26 Robert Sesek <rsesek@chromium.org>

Reviewed by Dimitri Glazkov.

[Chromium] Implement WebKit methods to assist with Cocoa NSTextInput implementation
https://bugs.webkit.org/show_bug.cgi?id=54969

  • WebKit.gyp:
  • public/WebFrame.h:
  • public/WebWidget.h:
  • public/mac/WebSubstringUtil.h: Added.
  • src/WebFrameImpl.cpp: (WebKit::WebFrameImpl::firstRectForCharacterRange): Return the result rect in window coordinates (WebKit::WebFrameImpl::characterIndexForPoint): New method on WebFrame
  • src/WebFrameImpl.h:
  • src/WebPopupMenuImpl.cpp: (WebKit::WebPopupMenuImpl::compositionRange): New method on WebWidget; empty impl (WebKit::WebPopupMenuImpl::caretOrSelectionRange): New method on WebWidget; empty impl
  • src/WebPopupMenuImpl.h:
  • src/WebViewImpl.cpp: (WebKit::WebViewImpl::compositionRange): New method on WebWidget (WebKit::WebViewImpl::caretOrSelectionRange): New method on WebWidget
  • src/WebViewImpl.h:
  • src/mac/WebSubstringUtil.mm: Added. (WebKit::WebSubstringUtil::attributedSubstringInRange):
Location:
trunk/Source/WebKit/chromium
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/chromium/ChangeLog

    r84933 r84951  
     12011-04-26  Robert Sesek  <rsesek@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        [Chromium] Implement WebKit methods to assist with Cocoa NSTextInput implementation
     6        https://bugs.webkit.org/show_bug.cgi?id=54969
     7
     8        * WebKit.gyp:
     9        * public/WebFrame.h:
     10        * public/WebWidget.h:
     11        * public/mac/WebSubstringUtil.h: Added.
     12        * src/WebFrameImpl.cpp:
     13        (WebKit::WebFrameImpl::firstRectForCharacterRange): Return the result rect in window coordinates
     14        (WebKit::WebFrameImpl::characterIndexForPoint): New method on WebFrame
     15        * src/WebFrameImpl.h:
     16        * src/WebPopupMenuImpl.cpp:
     17        (WebKit::WebPopupMenuImpl::compositionRange): New method on WebWidget; empty impl
     18        (WebKit::WebPopupMenuImpl::caretOrSelectionRange): New method on WebWidget; empty impl
     19        * src/WebPopupMenuImpl.h:
     20        * src/WebViewImpl.cpp:
     21        (WebKit::WebViewImpl::compositionRange): New method on WebWidget
     22        (WebKit::WebViewImpl::caretOrSelectionRange): New method on WebWidget
     23        * src/WebViewImpl.h:
     24        * src/mac/WebSubstringUtil.mm: Added.
     25        (WebKit::WebSubstringUtil::attributedSubstringInRange):
     26
    1272011-04-26  Adam Barth  <abarth@webkit.org>
    228
  • trunk/Source/WebKit/chromium/WebKit.gyp

    r84626 r84951  
    9797                'public/mac/WebSandboxSupport.h',
    9898                'public/mac/WebScreenInfoFactory.h',
     99                'public/mac/WebSubstringUtil.h',
    99100                'public/mac/WebThemeEngine.h',
    100101                'public/WebAccessibilityCache.h',
     
    385386                'src/mac/WebInputEventFactory.mm',
    386387                'src/mac/WebScreenInfoFactory.mm',
     388                'src/mac/WebSubstringUtil.mm',
    387389                'src/LocalFileSystemChromium.cpp',
    388390                'src/LocalizedStrings.cpp',
  • trunk/Source/WebKit/chromium/public/WebFrame.h

    r83972 r84951  
    397397    virtual WebRange markedRange() const = 0;
    398398
     399    // Returns the frame rectangle in window coordinate space of the given text
     400    // range.
    399401    virtual bool firstRectForCharacterRange(unsigned location, unsigned length, WebRect&) const = 0;
     402
     403    // Returns the index of a character in the Frame's text stream at the given
     404    // point. The point is in the window coordinate space. Will return
     405    // WTF::notFound if the point is invalid.
     406    virtual size_t characterIndexForPoint(const WebPoint&) const = 0;
    400407
    401408    // Supports commands like Undo, Redo, Cut, Copy, Paste, SelectAll,
  • trunk/Source/WebKit/chromium/public/WebWidget.h

    r83503 r84951  
    4141
    4242class WebInputEvent;
     43class WebRange;
    4344class WebString;
    4445struct WebPoint;
     
    121122    virtual bool confirmComposition(const WebString& text) = 0;
    122123
     124    // Fetches the character range of the current composition, also called the
     125    // "marked range." Returns true and fills the out-paramters on success;
     126    // returns false on failure.
     127    virtual bool compositionRange(size_t* location, size_t* length) = 0;
     128
    123129    // Returns the current text input type of this WebWidget.
    124130    virtual WebTextInputType textInputType() = 0;
     
    131137    // bottom of the selected line.
    132138    virtual bool selectionRange(WebPoint& start, WebPoint& end) const = 0;
     139
     140    // Fetch the current selection range of this WebWidget. If there is no
     141    // selection, it will output a 0-length range with the location at the
     142    // caret. Returns true and fills the out-paramters on success; returns false
     143    // on failure.
     144    virtual bool caretOrSelectionRange(size_t* location, size_t* length) = 0;
    133145
    134146    // Changes the text direction of the selected input node.
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp

    r84933 r84951  
    8686#include "Editor.h"
    8787#include "EventHandler.h"
     88#include "FocusController.h"
    8889#include "FormState.h"
    8990#include "FrameLoadRequest.h"
     
    9192#include "FrameTree.h"
    9293#include "FrameView.h"
    93 #include "HitTestResult.h"
    9494#include "HTMLCollection.h"
    9595#include "HTMLFormElement.h"
     
    100100#include "HTMLNames.h"
    101101#include "HistoryItem.h"
     102#include "HitTestResult.h"
    102103#include "InspectorController.h"
    103104#include "Page.h"
     
    11641165        return false;
    11651166    IntRect intRect = frame()->editor()->firstRectForRange(range.get());
    1166     rect = WebRect(intRect.x(), intRect.y(), intRect.width(), intRect.height());
     1167    rect = WebRect(intRect);
     1168    // When inside an text control, don't adjust the range.
     1169    if (!selectionRoot)
     1170        rect = frame()->view()->contentsToWindow(rect);
    11671171
    11681172    return true;
     1173}
     1174
     1175size_t WebFrameImpl::characterIndexForPoint(const WebPoint& webPoint) const
     1176{
     1177    if (!frame())
     1178        return notFound;
     1179
     1180    IntPoint point = frame()->view()->windowToContents(webPoint);
     1181    HitTestResult result = frame()->eventHandler()->hitTestResultAtPoint(point, false);
     1182    RefPtr<Range> range = frame()->rangeForPoint(result.point());
     1183    if (!range.get())
     1184        return notFound;
     1185
     1186    size_t location, length;
     1187    TextIterator::locationAndLengthFromRange(range.get(), location, length);
     1188    return location;
    11691189}
    11701190
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.h

    r83972 r84951  
    153153    virtual WebRange markedRange() const;
    154154    virtual bool firstRectForCharacterRange(unsigned location, unsigned length, WebRect&) const;
     155    virtual size_t characterIndexForPoint(const WebPoint&) const;
    155156    virtual bool executeCommand(const WebString&);
    156157    virtual bool executeCommand(const WebString&, const WebString& value);
  • trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp

    r77383 r84951  
    4444#include "WebInputEvent.h"
    4545#include "WebInputEventConversion.h"
     46#include "WebRange.h"
    4647#include "WebRect.h"
    4748#include "WebWidgetClient.h"
     
    253254}
    254255
     256bool WebPopupMenuImpl::compositionRange(size_t* location, size_t* length)
     257{
     258    *location = 0;
     259    *length = 0;
     260    return false;
     261}
     262
    255263WebTextInputType WebPopupMenuImpl::textInputType()
    256264{
     
    261269{
    262270    return WebRect();
     271}
     272
     273bool WebPopupMenuImpl::caretOrSelectionRange(size_t* location, size_t* length)
     274{
     275    *location = 0;
     276    *length = 0;
     277    return false;
    263278}
    264279
  • trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.h

    r83320 r84951  
    5252class WebMouseEvent;
    5353class WebMouseWheelEvent;
     54class WebRange;
    5455struct WebRect;
    5556
     
    7778    virtual bool confirmComposition();
    7879    virtual bool confirmComposition(const WebString& text);
     80    virtual bool compositionRange(size_t* location, size_t* length);
    7981    virtual WebTextInputType textInputType();
    8082    virtual WebRect caretOrSelectionBounds();
    8183    virtual bool selectionRange(WebPoint& start, WebPoint& end) const { return false; }
     84    virtual bool caretOrSelectionRange(size_t* location, size_t* length);
    8285    virtual void setTextDirection(WebTextDirection direction);
    8386    virtual bool isAcceleratedCompositingActive() const { return false; }
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r84933 r84951  
    9292#include "Settings.h"
    9393#include "SpeechInputClientImpl.h"
     94#include "TextIterator.h"
    9495#include "Timer.h"
    9596#include "TraceEvent.h"
     
    116117#include "WebPoint.h"
    117118#include "WebPopupMenuImpl.h"
     119#include "WebRange.h"
    118120#include "WebRect.h"
    119121#include "WebRuntimeFeatures.h"
     
    13951397}
    13961398
     1399bool WebViewImpl::compositionRange(size_t* location, size_t* length)
     1400{
     1401    Frame* focused = focusedWebCoreFrame();
     1402    if (!focused || !m_imeAcceptEvents)
     1403        return false;
     1404    Editor* editor = focused->editor();
     1405    if (!editor || !editor->hasComposition())
     1406        return false;
     1407
     1408    RefPtr<Range> range = editor->compositionRange();
     1409    if (!range.get())
     1410        return false;
     1411
     1412    if (TextIterator::locationAndLengthFromRange(range.get(), *location, *length))
     1413        return true;
     1414    return false;
     1415}
     1416
    13971417WebTextInputType WebViewImpl::textInputType()
    13981418{
     
    14841504    end = frame->view()->contentsToWindow(end);
    14851505    return true;
     1506}
     1507
     1508bool WebViewImpl::caretOrSelectionRange(size_t* location, size_t* length)
     1509{
     1510    const Frame* focused = focusedWebCoreFrame();
     1511    if (!focused)
     1512        return false;
     1513
     1514    SelectionController* controller = focused->selection();
     1515    if (!controller)
     1516        return false;
     1517
     1518    RefPtr<Range> range = controller->selection().firstRange();
     1519    if (!range.get())
     1520        return false;
     1521
     1522    if (TextIterator::locationAndLengthFromRange(range.get(), *location, *length))
     1523        return true;
     1524    return false;
    14861525}
    14871526
  • trunk/Source/WebKit/chromium/src/WebViewImpl.h

    r83658 r84951  
    108108    virtual bool confirmComposition();
    109109    virtual bool confirmComposition(const WebString& text);
     110    virtual bool compositionRange(size_t* location, size_t* length);
    110111    virtual WebTextInputType textInputType();
    111112    virtual WebRect caretOrSelectionBounds();
    112113    virtual bool selectionRange(WebPoint& start, WebPoint& end) const;
     114    virtual bool caretOrSelectionRange(size_t* location, size_t* length);
    113115    virtual void setTextDirection(WebTextDirection direction);
    114116    virtual bool isAcceleratedCompositingActive() const;
Note: See TracChangeset for help on using the changeset viewer.