Changeset 104025 in webkit
- Timestamp:
- Jan 4, 2012 3:31:11 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r104022 r104025 1 2012-01-03 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 3 [Qt] Clean up Qt specific part of editorState() 4 5 Reviewed by Simon Hausmann. 6 7 Use unsigned instead of int. 8 No need to clone the range as we don't modify it. 9 Support selections which include a composition. 10 If we are not in editable content make sure to use the document element 11 as the scope for calculating the positions and lengths. 12 Remove compositionStart/Length as there cannot be a selection and 13 composition at the same time. 14 15 Only tested manually as we don't have everything in place yet 16 to properly test this. 17 18 * Shared/EditorState.h: 19 * WebProcess/WebPage/WebPage.cpp: 20 (WebKit::WebPage::editorState): 21 1 22 2012-01-04 Mihnea Ovidenie <mihnea@adobe.com> 2 23 -
trunk/Source/WebKit2/Shared/EditorState.cpp
r102334 r104025 47 47 encoder->encode(microFocus); 48 48 encoder->encode(compositionRect); 49 encoder->encode(compositionStart);50 encoder->encode(compositionLength);51 49 encoder->encode(selectedText); 52 50 encoder->encode(surroundingText); … … 90 88 return false; 91 89 92 if (!decoder->decode(result.compositionStart))93 return false;94 95 if (!decoder->decode(result.compositionLength))96 return false;97 98 90 if (!decoder->decode(result.selectedText)) 99 91 return false; -
trunk/Source/WebKit2/Shared/EditorState.h
r102334 r104025 46 46 , cursorPosition(0) 47 47 , anchorPosition(0) 48 , compositionStart(0)49 , compositionLength(0)50 48 #endif 51 49 { … … 61 59 bool hasComposition; 62 60 #if PLATFORM(QT) 63 int cursorPosition; 64 int anchorPosition; 61 // The anchor, cursor represent either the selection or composition, depending 62 // whether a composition exists or not. 63 unsigned cursorPosition; 64 unsigned anchorPosition; 65 65 66 WebCore::IntRect microFocus; 66 67 WebCore::IntRect compositionRect; 67 int compositionStart;68 int compositionLength;69 68 WTF::String selectedText; 70 69 WTF::String surroundingText; -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r103925 r104025 391 391 size_t location = 0; 392 392 size_t length = 0; 393 Element* scope = frame->selection()->rootEditableElement(); 393 394 Element* selectionRoot = frame->selection()->rootEditableElement(); 395 Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement(); 394 396 395 397 RefPtr<Range> range; 396 398 if (result.hasComposition && (range = frame->editor()->compositionRange())) { 399 frame->editor()->getCompositionSelection(result.anchorPosition, result.cursorPosition); 400 401 result.compositionRect = frame->view()->contentsToWindow(range->boundingBox()); 402 } 403 404 if (!result.hasComposition && !result.selectionIsNone && (range = frame->selection()->selection().firstRange())) { 397 405 TextIterator::getLocationAndLengthFromRange(scope, range.get(), location, length); 398 result.compositionStart = location;399 result.compositionLength = length;400 result.compositionRect = range->boundingBox();401 }402 403 if (!result.selectionIsNone && (range = frame->selection()->selection().firstRange())) {404 TextIterator::getLocationAndLengthFromRange(scope, range.get(), location, length);405 406 ExceptionCode ec = 0;407 RefPtr<Range> tempRange = range->cloneRange(ec);408 tempRange->setStart(tempRange->startContainer(ec), tempRange->startOffset(ec) + location, ec);409 IntRect rect = frame->editor()->firstRectForRange(tempRange.get());410 406 bool baseIsFirst = frame->selection()->selection().isBaseFirst(); 411 407 412 408 result.cursorPosition = (baseIsFirst) ? location + length : location; 413 409 result.anchorPosition = (baseIsFirst) ? location : location + length; 414 result.microFocus = frame->view()->contentsToWindow(rect);415 410 result.selectedText = range->text(); 416 411 } 417 412 418 if (scope && result.isContentEditable && !result.isInPasswordField) { 413 if (range) 414 result.microFocus = frame->view()->contentsToWindow(frame->editor()->firstRectForRange(range.get())); 415 416 // FIXME: We should only transfer innerText when it changes and do this on the UI side. 417 if (result.isContentEditable && !result.isInPasswordField) { 419 418 result.surroundingText = scope->innerText(); 420 result.surroundingText.remove(result.compositionStart, result.compositionLength); 419 if (result.hasComposition) { 420 // The anchor is always the left position when they represent a composition. 421 result.surroundingText.remove(result.anchorPosition, result.cursorPosition - result.anchorPosition); 422 } 421 423 } 422 424 #endif
Note: See TracChangeset
for help on using the changeset viewer.