Changeset 74582 in webkit


Ignore:
Timestamp:
Dec 23, 2010 2:34:52 PM (13 years ago)
Author:
andersca@apple.com
Message:

2010-12-23 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

WKView should not try to do asynchronous validation for selectors that are not editor commands
https://bugs.webkit.org/show_bug.cgi?id=51555

  • UIProcess/API/mac/WKView.mm: (-[WKView validateUserInterfaceItem:]): Removed the special case for startSpeaking. Added call to commandIsSupportedFromMenuOrKeyBinding so we only try to do validation for commands that are supported. Tweaked comments and added some bug numbers. (-[WKView _setUserInterfaceItemState:enabled:state:]): Tweaked comment and added bug number.
Location:
trunk/WebKit2
Files:
1 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r74580 r74582  
    8686        (WebKit::WebFrame::createSubframe):
    8787        Send parent frameID in addition to our own in the message to UIProcess.
     88
     892010-12-23  Anders Carlsson  <andersca@apple.com>
     90
     91        Reviewed by Darin Adler.
     92
     93        Clean up the selection handling code
     94        https://bugs.webkit.org/show_bug.cgi?id=51550
     95
     96        * Shared/SelectionState.h: Added.
     97        Add SelectionState class which hold information about the current selection.
     98
     99        * UIProcess/API/mac/PageClientImpl.h:
     100        * UIProcess/API/mac/PageClientImpl.mm:
     101        Remove selectionChanged function.
     102
     103        * UIProcess/API/mac/WKView.mm:
     104        (-[WKView initWithFrame:contextRef:pageGroupRef:]):
     105        Remove all the selection related state; it lives in the WebPageProxy object now.
     106       
     107        (-[WKView insertText:]):
     108        (-[WKView selectedRange]):
     109        (-[WKView hasMarkedText]):
     110        Get the selection information from the WebPageProxy.
     111
     112        * UIProcess/API/mac/WKViewInternal.h:
     113        Remove _selectionChanged declaration.
     114
     115        * UIProcess/PageClient.h:
     116        Remove selectionChanged functions.
     117
     118        * UIProcess/WebPageProxy.cpp:
     119        (WebKit::WebPageProxy::selectionStateChanged):
     120        Update the selection state.
     121
     122        * UIProcess/WebPageProxy.h:
     123        (WebKit::WebPageProxy::selectionState):
     124        Return the selection state.
     125
     126        * UIProcess/WebPageProxy.messages.in:
     127        Add SelectionStateChanged message.
     128
     129        * UIProcess/win/WebView.cpp:
     130        (WebKit::WebView::WebView):
     131        Remove all the selection related state; it lives in the WebPageProxy object now.
     132
     133        (WebKit::WebView::compositionSelectionChanged):
     134        (WebKit::WebView::onIMEComposition):
     135        (WebKit::WebView::onIMEEndComposition):
     136        (WebKit::WebView::onIMERequestCharPosition):
     137        (WebKit::WebView::onIMERequest):
     138        Get the selection information from the WebPageProxy.
     139       
     140        * WebKit2.xcodeproj/project.pbxproj:
     141        Add SelectionState.h
     142
     143        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
     144        (WebKit::WebEditorClient::respondToChangedSelection):
     145        Send a SelectionStateChanged message with the updated state.
     146
     147        * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
     148        Remove mac specific code.
     149
     150        * WebProcess/WebPage/WebPage.cpp:
     151        (WebKit::WebPage::getLocationAndLengthFromRange):
     152        Rename this function from convertRangeToPlatformRange and move it out of WebPageMac.mm
     153
     154        * WebProcess/WebPage/mac/WebPageMac.mm:
     155        (WebKit::WebPage::getMarkedRange):
     156        (WebKit::WebPage::characterIndexForPoint):
     157        Call getLocationAndLengthFromRange.
     158
     159        * win/WebKit2.vcproj:
     160        Add SelectionState.h
    88161
    891622010-12-23  Anders Carlsson  <andersca@apple.com>
  • trunk/WebKit2/UIProcess/API/mac/PageClientImpl.h

    r74285 r74582  
    6565
    6666    virtual void didNotHandleKeyEvent(const NativeWebKeyboardEvent&);
    67     virtual void selectionChanged(bool, bool, bool, bool, uint64_t, uint64_t);
    6867
    6968    virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
  • trunk/WebKit2/UIProcess/API/mac/PageClientImpl.mm

    r74285 r74582  
    146146{
    147147
    148 }
    149 
    150 void PageClientImpl::selectionChanged(bool isNone, bool isContentEditable, bool isPasswordField, bool hasComposition, uint64_t location, uint64_t length)
    151 {
    152     [m_wkView _selectionChanged:isNone isEditable:isContentEditable isPassword:isPasswordField hasMarkedText:hasComposition range:NSMakeRange(location, length)];
    153148}
    154149
  • trunk/WebKit2/UIProcess/API/mac/WKView.mm

    r74580 r74582  
    110110    uint64_t _pluginComplexTextInputIdentifier;
    111111
    112     BOOL _isSelectionNone;
    113     BOOL _isSelectionEditable;
    114     BOOL _isSelectionInPasswordField;
    115     BOOL _hasMarkedText;
    116112    Vector<CompositionUnderline> _underlines;
    117113    unsigned _selectionStart;
    118114    unsigned _selectionEnd;
    119     NSRange _selectedRange;
    120115}
    121116@end
     
    165160    _data->_page->initializeWebPage(IntSize(frame.size));
    166161    _data->_page->setIsInWindow([self window]);
    167 
    168     _data->_isSelectionNone = YES;
    169     _data->_isSelectionEditable = NO;
    170     _data->_isSelectionInPasswordField = NO;
    171     _data->_hasMarkedText = NO;
    172     _data->_selectedRange = NSMakeRange(NSNotFound, 0);
    173162
    174163    WebContext::statistics().wkViewCount++;
     
    473462    LOG(TextInput, "insertText:\"%@\"", isAttributedString ? [string string] : string);
    474463    NSString *text;
    475     bool isFromInputMethod = _data->_hasMarkedText;
     464    bool isFromInputMethod = _data->_page->selectionState().hasComposition;
    476465
    477466    if (isAttributedString) {
     
    550539}
    551540
    552 - (void)_selectionChanged:(BOOL)isNone isEditable:(BOOL)isContentEditable isPassword:(BOOL)isPasswordField hasMarkedText:(BOOL)hasComposition range:(NSRange)newrange
    553 {
    554     _data->_isSelectionNone = isNone;
    555     _data->_isSelectionEditable = isContentEditable;
    556     _data->_isSelectionInPasswordField = isPasswordField;
    557     _data->_hasMarkedText = hasComposition;
    558     _data->_selectedRange = newrange;
    559 }
    560 
    561541- (Vector<KeypressCommand>&)_interceptKeyEvent:(NSEvent *)theEvent
    562542{
     
    617597- (NSRange)selectedRange
    618598{
    619     if (_data->_isSelectionNone || !_data->_isSelectionEditable)
     599    if (_data->_page->selectionState().isNone || !_data->_page->selectionState().isContentEditable)
    620600        return NSMakeRange(NSNotFound, 0);
    621601   
    622     LOG(TextInput, "selectedRange -> (%u, %u)", _data->_selectedRange.location, _data->_selectedRange.length);
    623     return _data->_selectedRange;
     602    LOG(TextInput, "selectedRange -> (%u, %u)", _data->_page->selectionState().selectedRangeStart, _data->_page->selectionState().selectedRangeLength);
     603    return NSMakeRange(_data->_page->selectionState().selectedRangeStart, _data->_page->selectionState().selectedRangeLength);
    624604}
    625605
    626606- (BOOL)hasMarkedText
    627607{
    628     LOG(TextInput, "hasMarkedText -> %u", _data-> _hasMarkedText);
    629     return _data->_hasMarkedText;
     608    LOG(TextInput, "hasMarkedText -> %u", _data->_page->selectionState().hasComposition);
     609    return _data->_page->selectionState().hasComposition;
    630610}
    631611
  • trunk/WebKit2/UIProcess/API/mac/WKViewInternal.h

    r74037 r74582  
    4444- (NSRect)_convertToDeviceSpace:(NSRect)rect;
    4545- (NSRect)_convertToUserSpace:(NSRect)rect;
    46 - (void)_selectionChanged:(BOOL)isNone isEditable:(BOOL)isContentEditable isPassword:(BOOL)isPasswordField hasMarkedText:(BOOL)hasComposition range:(NSRange)newrange;
    47 
    4846- (void)_setFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut;
    4947
  • trunk/WebKit2/UIProcess/PageClient.h

    r74285 r74582  
    7171#if PLATFORM(MAC)
    7272    virtual void interceptKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>&, uint32_t, uint32_t, Vector<WebCore::CompositionUnderline>&) = 0;
    73     virtual void selectionChanged(bool, bool, bool, bool, uint64_t, uint64_t) = 0;
    74 #else
    75     virtual void selectionChanged(bool, bool, bool, bool) = 0;
    7673#endif
    7774#if PLATFORM(WIN)
  • trunk/WebKit2/UIProcess/WebPageProxy.cpp

    r74571 r74582  
    15531553}
    15541554
     1555void WebPageProxy::selectionStateChanged(const SelectionState& selectionState)
     1556{
     1557    m_selectionState = selectionState;
     1558}
     1559
    15551560#if PLATFORM(MAC)
    1556 // Selection change support
    1557 void WebPageProxy::didSelectionChange(bool isNone, bool isContentEditable, bool isPasswordField, bool hasComposition, uint64_t location, uint64_t length)
    1558 {
    1559     m_pageClient->selectionChanged(isNone, isContentEditable, isPasswordField, hasComposition, location, length);
    1560 }
    1561 
    15621561// Complex text input support for plug-ins.
    15631562void WebPageProxy::sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput)
     
    15671566   
    15681567    process()->send(Messages::WebPage::SendComplexTextInputToPlugin(pluginComplexTextInputIdentifier, textInput), m_pageID);
    1569 }
    1570    
    1571 #else   
    1572 void WebPageProxy::didChangeSelection(bool isNone, bool isContentEditable, bool isPasswordField, bool hasComposition)
    1573 {
    1574     m_pageClient->selectionChanged(isNone, isContentEditable, isPasswordField, hasComposition);
    15751568}
    15761569#endif
  • trunk/WebKit2/UIProcess/WebPageProxy.h

    r74571 r74582  
    2929#include "APIObject.h"
    3030#include "DrawingAreaProxy.h"
     31#include "SelectionState.h"
    3132#include "SharedMemory.h"
    3233#include "WKBase.h"
     
    172173    void validateMenuItem(const String& commandName);
    173174
    174 // These are only used on Mac currently.
     175    const SelectionState& selectionState() const { return m_selectionState; }
     176
    175177#if PLATFORM(MAC)
    176178    void updateWindowIsVisible(bool windowIsVisible);
     
    179181    uint64_t characterIndexForPoint(const WebCore::IntPoint);
    180182    WebCore::IntRect firstRectForCharacterRange(uint64_t, uint64_t);
    181     void didSelectionChange(bool, bool, bool, bool, uint64_t, uint64_t);
    182183    void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
    183 #else
    184     void didChangeSelection(bool, bool, bool, bool);
    185184#endif
    186185#if PLATFORM(WIN)
     
    385384#endif
    386385
     386    // Selection
     387    void selectionStateChanged(const SelectionState&);
     388
    387389    // Back/Forward list management
    388390    void backForwardAddItem(uint64_t itemID);
     
    493495    String m_toolTip;
    494496
     497    SelectionState m_selectionState;
     498
    495499    // REMOVE: For demo purposes only.
    496500    String m_urlAtProcessExit;
  • trunk/WebKit2/UIProcess/WebPageProxy.messages.in

    r74571 r74582  
    132132   
    133133    # Selection messages.
    134 #if PLATFORM(MAC)
    135     DidSelectionChange(bool isNone, bool isContentEditable, bool isPasswordField, bool hasComposition, uint64_t location, uint64_t length)
    136 #endif
    137 #if !PLATFORM(MAC)
    138     DidChangeSelection(bool isNone, bool isContentEditable, bool isPasswordField, bool hasComposition)
    139 #endif
     134    SelectionStateChanged(WebKit::SelectionState selectionState)
     135
    140136#if PLATFORM(WIN)
    141137    DidChangeCompositionSelection(bool hasChanged)
  • trunk/WebKit2/UIProcess/win/WebView.cpp

    r74296 r74582  
    226226    , m_trackingMouseLeave(false)
    227227    , m_isBeingDestroyed(false)
    228     , m_selectionIsNone(true)
    229     , m_selectionIsEditable(false)
    230     , m_selectionInPasswordField(false)
    231     , m_hasMarkedText(false)
    232228    , m_inIMEComposition(0)
    233229{
     
    694690}
    695691
    696 void WebView::selectionChanged(bool isNone, bool isEditable, bool isPasswordField, bool hasComposition)
    697 {
    698     m_selectionIsNone = isNone;
    699     m_selectionIsEditable = isEditable;
    700     m_selectionInPasswordField = isPasswordField;
    701     m_hasMarkedText = hasComposition;
    702 }
    703 
    704692void WebView::compositionSelectionChanged(bool hasChanged)
    705693{
    706     if (m_hasMarkedText && !hasChanged)
     694    if (m_page->selectionState().hasComposition && !hasChanged)
    707695        resetIME();
    708696}
     
    812800        return true;
    813801
    814     if (!m_selectionIsEditable)
     802    if (!m_page->selectionState().isContentEditable)
    815803        return true;
    816804
     
    855843    // If the composition hasn't been confirmed yet, it needs to be cancelled.
    856844    // This happens after deleting the last character from inline input hole.
    857     if (m_hasMarkedText)
     845    if (m_page->selectionState().hasComposition)
    858846        m_page->confirmComposition(String());
    859847
     
    866854LRESULT WebView::onIMERequestCharPosition(IMECHARPOSITION* charPos)
    867855{
    868     if (charPos->dwCharPos && !m_hasMarkedText)
     856    if (charPos->dwCharPos && !m_page->selectionState().hasComposition)
    869857        return 0;
    870858    IntRect caret = m_page->firstRectForCharacterInSelectedRange(charPos->dwCharPos);
     
    898886{
    899887    LOG(TextInput, "onIMERequest %s", imeRequestName(request).latin1().data());
    900     if (!m_selectionIsEditable)
     888    if (!m_page->selectionState().isContentEditable)
    901889        return 0;
    902890
  • trunk/WebKit2/UIProcess/win/WebView.h

    r74296 r74582  
    118118    virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
    119119    virtual void didNotHandleKeyEvent(const NativeWebKeyboardEvent&);
    120     virtual void selectionChanged(bool, bool, bool, bool);
    121120    virtual void compositionSelectionChanged(bool);
    122121    virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
     
    152151    RefPtr<WebPageProxy> m_page;
    153152
    154     // Text input state values
    155     bool m_selectionIsNone;
    156     bool m_selectionIsEditable;
    157     bool m_selectionInPasswordField;
    158     bool m_hasMarkedText;
    159153    unsigned m_inIMEComposition;
    160154};
  • trunk/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r74384 r74582  
    158158                1AA417CB12C00CCA002BE67B /* TextChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA417C912C00CCA002BE67B /* TextChecker.h */; };
    159159                1AA417EF12C00D87002BE67B /* TextCheckerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA417ED12C00D87002BE67B /* TextCheckerMac.mm */; };
     160                1AA41AB512C02EC4002BE67B /* SelectionState.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA41AB412C02EC4002BE67B /* SelectionState.h */; };
    160161                1AA4792312A59FD9008236C3 /* PluginProcessMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA4792212A59FD9008236C3 /* PluginProcessMac.mm */; };
    161162                1AA479B012A5A436008236C3 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CD06100FA1BA0078DEBC /* Carbon.framework */; };
     
    814815                1AA417C912C00CCA002BE67B /* TextChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextChecker.h; sourceTree = "<group>"; };
    815816                1AA417ED12C00D87002BE67B /* TextCheckerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextCheckerMac.mm; sourceTree = "<group>"; };
     817                1AA41AB412C02EC4002BE67B /* SelectionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectionState.h; sourceTree = "<group>"; };
    816818                1AA4792212A59FD9008236C3 /* PluginProcessMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginProcessMac.mm; sourceTree = "<group>"; };
    817819                1AA56F2811E92BC80061B882 /* PluginController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginController.h; sourceTree = "<group>"; };
     
    16041606                                BC2D021612AC41CB00E732A3 /* SameDocumentNavigationType.h */,
    16051607                                1AAB4A8C1296F0A20023952F /* SandboxExtension.h */,
     1608                                1AA41AB412C02EC4002BE67B /* SelectionState.h */,
    16061609                                BCBD3C3A125BFA7A00D2C29F /* StringPairVector.h */,
    16071610                                BCB0B0DF12305AB100B1341E /* UserMessageCoders.h */,
     
    27712774                                BC858A2012C0357B00EDEB2E /* WebResourceLoadClient.h in Headers */,
    27722775                                1AA417CB12C00CCA002BE67B /* TextChecker.h in Headers */,
     2776                                1AA41AB512C02EC4002BE67B /* SelectionState.h in Headers */,
    27732777                        );
    27742778                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp

    r74164 r74582  
    2929#include "NotImplemented.h"
    3030
     31#include "SelectionState.h"
    3132#include "WebFrameLoaderClient.h"
    3233#include "WebPage.h"
     
    179180}
    180181
    181 #if !PLATFORM(MAC)
    182182void WebEditorClient::respondToChangedSelection()
    183183{
     
    188188        return;
    189189
    190     m_page->send(Messages::WebPageProxy::DidChangeSelection(frame->selection()->isNone(), frame->selection()->isContentEditable(), frame->selection()->isInPasswordField(), frame->editor()->hasComposition()));
     190    SelectionState selectionState;
     191    selectionState.isNone = frame->selection()->isNone();
     192    selectionState.isContentEditable = frame->selection()->isContentEditable();
     193    selectionState.isInPasswordField = frame->selection()->isInPasswordField();
     194    selectionState.hasComposition = frame->editor()->hasComposition();
     195
     196    WebPage::getLocationAndLengthFromRange(frame->selection()->toNormalizedRange().get(), selectionState.selectedRangeStart, selectionState.selectedRangeLength);
     197
     198    m_page->send(Messages::WebPageProxy::SelectionStateChanged(selectionState));
     199
    191200#if PLATFORM(WIN)
     201    // FIXME: This should also go into the selection state.
    192202    if (!frame->editor()->hasComposition() || frame->editor()->ignoreCompositionSelectionChange())
    193203        return;
     
    198208#endif
    199209}
    200 #endif
    201210   
    202211void WebEditorClient::didEndEditing()
  • trunk/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm

    r73796 r74582  
    5252
    5353using namespace WebCore;
    54 using namespace WTF;
    5554
    5655@interface NSAttributedString (WebNSAttributedStringDetails)
     
    6362
    6463namespace WebKit {
    65 
    66 void WebEditorClient::respondToChangedSelection()
    67 {
    68     static const String WebViewDidChangeSelectionNotification = "WebViewDidChangeSelectionNotification";
    69     m_page->injectedBundleEditorClient().didChangeSelection(m_page, WebViewDidChangeSelectionNotification.impl());
    70     WebCore::Frame* frame = m_page->corePage()->focusController()->focusedFrame();
    71     if (!frame)
    72         return;
    73     uint64_t location;
    74     uint64_t length;
    75     WebPage::convertRangeToPlatformRange(frame, frame->selection()->toNormalizedRange().get(), location, length);
    76     m_page->send(Messages::WebPageProxy::DidSelectionChange(frame->selection()->isNone(), frame->selection()->isContentEditable(), frame->selection()->isInPasswordField(), frame->editor()->hasComposition(), location, length));
    77 }
    7864   
    7965void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
  • trunk/WebKit2/WebProcess/WebPage/WebPage.cpp

    r74527 r74582  
    7777#include <WebCore/SharedBuffer.h>
    7878#include <WebCore/SubstituteData.h>
     79#include <WebCore/TextIterator.h>
    7980#include <runtime/JSLock.h>
    8081#include <runtime/JSValue.h>
     
    609610        m_contextMenu = WebContextMenu::create(this);
    610611    return m_contextMenu.get();
     612}
     613
     614void WebPage::getLocationAndLengthFromRange(Range* range, uint64_t& location, uint64_t& length)
     615{
     616    location = notFound;
     617    length = 0;
     618
     619    if (!range || !range->startContainer())
     620        return;
     621
     622    Element* selectionRoot = range->ownerDocument()->frame()->selection()->rootEditableElement();
     623    Element* scope = selectionRoot ? selectionRoot : range->ownerDocument()->documentElement();
     624   
     625    // Mouse events may cause TSM to attempt to create an NSRange for a portion of the view
     626    // that is not inside the current editable region.  These checks ensure we don't produce
     627    // potentially invalid data when responding to such requests.
     628    if (range->startContainer() != scope && !range->startContainer()->isDescendantOf(scope))
     629        return;
     630    if (range->endContainer() != scope && !range->endContainer()->isDescendantOf(scope))
     631        return;
     632
     633    RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset());
     634    ASSERT(testRange->startContainer() == scope);
     635    location = TextIterator::rangeLength(testRange.get());
     636   
     637    ExceptionCode ec;
     638    testRange->setEnd(range->endContainer(), range->endOffset(), ec);
     639    ASSERT(testRange->startContainer() == scope);
     640    length = TextIterator::rangeLength(testRange.get()) - location;
    611641}
    612642
  • trunk/WebKit2/WebProcess/WebPage/WebPage.h

    r74527 r74582  
    245245
    246246    SandboxExtensionTracker& sandboxExtensionTracker() { return m_sandboxExtensionTracker; }
    247    
     247
     248    static void getLocationAndLengthFromRange(WebCore::Range*, uint64_t& location, uint64_t& length);
     249
    248250#if PLATFORM(MAC)
    249251    void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
     
    252254    void characterIndexForPoint(const WebCore::IntPoint point, uint64_t& result);
    253255    void firstRectForCharacterRange(uint64_t location, uint64_t length, WebCore::IntRect& resultRect);
    254     static void convertRangeToPlatformRange(WebCore::Frame* frame, WebCore::Range *range, uint64_t& location, uint64_t& length);
    255256#elif PLATFORM(WIN)
    256257    void confirmComposition(const String& compositionString);
  • trunk/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

    r74131 r74582  
    124124}
    125125
    126 void WebPage::convertRangeToPlatformRange(WebCore::Frame* frame, WebCore::Range *range, uint64_t& location, uint64_t& length)
    127 {
    128     location = NSNotFound;
    129     length = 0;
    130     if (!range || !range->startContainer())
    131         return;
    132        
    133     Element* selectionRoot = frame->selection()->rootEditableElement();
    134     Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
    135    
    136     // Mouse events may cause TSM to attempt to create an NSRange for a portion of the view
    137     // that is not inside the current editable region.  These checks ensure we don't produce
    138     // potentially invalid data when responding to such requests.
    139     if (range->startContainer() != scope && !range->startContainer()->isDescendantOf(scope))
    140         return;
    141     if (range->endContainer() != scope && !range->endContainer()->isDescendantOf(scope))
    142         return;
    143            
    144     RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset());
    145     ASSERT(testRange->startContainer() == scope);
    146     location = TextIterator::rangeLength(testRange.get());
    147            
    148     ExceptionCode ec;
    149     testRange->setEnd(range->endContainer(), range->endOffset(), ec);
    150     ASSERT(testRange->startContainer() == scope);
    151     length = TextIterator::rangeLength(testRange.get()) - location;
    152 }
    153 
    154126void WebPage::sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput)
    155127{
     
    168140        return;
    169141   
    170     convertRangeToPlatformRange(frame, frame->editor()->compositionRange().get(), location, length);
     142    getLocationAndLengthFromRange(frame->editor()->compositionRange().get(), location, length);
    171143}
    172144
     
    207179   
    208180    Range *range = characterRangeAtPoint(frame, result.point());
     181    if (!range)
     182        return;
     183
    209184    uint64_t length;
    210     if (range)
    211         convertRangeToPlatformRange(frame, range, index, length);
     185    getLocationAndLengthFromRange(range, index, length);
    212186}
    213187
  • trunk/WebKit2/win/WebKit2.vcproj

    r74436 r74582  
    484484                        </File>
    485485                        <File
     486                                RelativePath="..\Shared\SelectionState.h"
     487                                >
     488                        </File>
     489                        <File
    486490                                RelativePath="..\Shared\StringPairVector.h"
    487491                                >
Note: See TracChangeset for help on using the changeset viewer.