Diff
Modified: trunk/Source/WebCore/ChangeLog (97477 => 97478)
--- trunk/Source/WebCore/ChangeLog 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebCore/ChangeLog 2011-10-14 17:54:42 UTC (rev 97478)
@@ -1,3 +1,22 @@
+2011-10-12 Ryosuke Niwa <[email protected]>
+
+ Make the interface of locationAndLengthFromRange and rangeFromLocationAndLength consistent
+ https://bugs.webkit.org/show_bug.cgi?id=69964
+
+ Reviewed by Enrica Casucci.
+
+ Extracted the logic to determine the scope element as FrameSelection::rootEditableElementOrDocumentElement
+ and deployed it in WebKit layer. Made locationAndLengthFromRange take a scope element and renamed it to
+ getLocationAndLengthFromRange.
+
+ * WebCore.exp.in:
+ * editing/FrameSelection.cpp:
+ (WebCore::FrameSelection::rootEditableElementOrDocumentElement):
+ * editing/FrameSelection.h:
+ * editing/TextIterator.cpp:
+ (WebCore::TextIterator::getLocationAndLengthFromRange):
+ * editing/TextIterator.h:
+
2011-10-13 Arko Saha <[email protected]>
Microdata: Basic implementation of document.getItems() method.
Modified: trunk/Source/WebCore/WebCore.exp.in (97477 => 97478)
--- trunk/Source/WebCore/WebCore.exp.in 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebCore/WebCore.exp.in 2011-10-14 17:54:42 UTC (rev 97478)
@@ -294,7 +294,7 @@
__ZN7WebCore12SpellChecker8didCheckEiRKN3WTF6VectorINS_18TextCheckingResultELm0EEE
__ZN7WebCore12TextEncodingC1ERKN3WTF6StringE
__ZN7WebCore12TextIterator11rangeLengthEPKNS_5RangeEb
-__ZN7WebCore12TextIterator26locationAndLengthFromRangeEPKNS_5RangeERmS4_
+__ZN7WebCore12TextIterator29getLocationAndLengthFromRangeEPNS_7ElementEPKNS_5RangeERmS6_
__ZN7WebCore12TextIterator26rangeFromLocationAndLengthEPNS_7ElementEiib
__ZN7WebCore12TextIterator7advanceEv
__ZN7WebCore12TextIterator8subrangeEPNS_5RangeEii
@@ -1193,6 +1193,7 @@
__ZNK7WebCore14FrameSelection17isInPasswordFieldEv
__ZNK7WebCore14FrameSelection18isFocusedAndActiveEv
__ZNK7WebCore14FrameSelection31getClippedVisibleTextRectanglesERN3WTF6VectorINS_9FloatRectELm0EEE
+__ZNK7WebCore14FrameSelection36rootEditableElementOrDocumentElementEv
__ZNK7WebCore14FrameSelection6boundsEb
__ZNK7WebCore14RenderListItem10markerTextEv
__ZNK7WebCore14ResourceHandle10connectionEv
Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (97477 => 97478)
--- trunk/Source/WebCore/editing/FrameSelection.cpp 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp 2011-10-14 17:54:42 UTC (rev 97478)
@@ -114,6 +114,12 @@
m_selection.setIsDirectional(true);
}
+Element* FrameSelection::rootEditableElementOrDocumentElement() const
+{
+ Element* selectionRoot = m_selection.rootEditableElement();
+ return selectionRoot ? selectionRoot : m_frame->document()->documentElement();
+}
+
void FrameSelection::moveTo(const VisiblePosition &pos, EUserTriggered userTriggered, CursorAlignOnScroll align)
{
SetSelectionOptions options = CloseTyping | ClearTypingStyle | userTriggered;
Modified: trunk/Source/WebCore/editing/FrameSelection.h (97477 => 97478)
--- trunk/Source/WebCore/editing/FrameSelection.h 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebCore/editing/FrameSelection.h 2011-10-14 17:54:42 UTC (rev 97478)
@@ -126,6 +126,7 @@
FrameSelection(Frame* = 0);
Element* rootEditableElement() const { return m_selection.rootEditableElement(); }
+ Element* rootEditableElementOrDocumentElement() const;
bool isContentEditable() const { return m_selection.isContentEditable(); }
bool isContentRichlyEditable() const { return m_selection.isContentRichlyEditable(); }
Modified: trunk/Source/WebCore/editing/TextIterator.cpp (97477 => 97478)
--- trunk/Source/WebCore/editing/TextIterator.cpp 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebCore/editing/TextIterator.cpp 2011-10-14 17:54:42 UTC (rev 97478)
@@ -2476,7 +2476,7 @@
return resultRange.release();
}
-bool TextIterator::locationAndLengthFromRange(const Range* range, size_t& location, size_t& length)
+bool TextIterator::getLocationAndLengthFromRange(Element* scope, const Range* range, size_t& location, size_t& length)
{
location = notFound;
length = 0;
@@ -2484,9 +2484,6 @@
if (!range->startContainer())
return false;
- Element* selectionRoot = range->ownerDocument()->frame()->selection()->rootEditableElement();
- Element* scope = selectionRoot ? selectionRoot : range->ownerDocument()->documentElement();
-
// The critical assumption is that this only gets called with ranges that
// concentrate on a given area containing the selection root. This is done
// because of text fields and textareas. The DOM for those is not
Modified: trunk/Source/WebCore/editing/TextIterator.h (97477 => 97478)
--- trunk/Source/WebCore/editing/TextIterator.h 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebCore/editing/TextIterator.h 2011-10-14 17:54:42 UTC (rev 97478)
@@ -99,7 +99,7 @@
static int rangeLength(const Range*, bool spacesForReplacedElements = false);
static PassRefPtr<Range> rangeFromLocationAndLength(Element* scope, int rangeLocation, int rangeLength, bool spacesForReplacedElements = false);
- static bool locationAndLengthFromRange(const Range*, size_t& location, size_t& length);
+ static bool getLocationAndLengthFromRange(Element* scope, const Range*, size_t& location, size_t& length);
static PassRefPtr<Range> subrange(Range* entireRange, int characterOffset, int characterCount);
private:
Modified: trunk/Source/WebKit/chromium/ChangeLog (97477 => 97478)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-10-14 17:54:42 UTC (rev 97478)
@@ -1,3 +1,20 @@
+2011-10-12 Ryosuke Niwa <[email protected]>
+
+ Make the interface of locationAndLengthFromRange and rangeFromLocationAndLength consistent
+ https://bugs.webkit.org/show_bug.cgi?id=69964
+
+ Reviewed by Enrica Casucci.
+
+ * src/WebFrameImpl.cpp:
+ (WebKit::WebFrameImpl::firstRectForCharacterRange):
+ (WebKit::WebFrameImpl::characterIndexForPoint):
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::compositionRange):
+ (WebKit::WebViewImpl::getSelectionOffsetsAndTextInEditableContent):
+ (WebKit::WebViewImpl::caretOrSelectionRange):
+ * src/mac/WebSubstringUtil.mm:
+ (WebKit::WebSubstringUtil::attributedSubstringInRange):
+
2011-10-13 Arko Saha <[email protected]>
Microdata: Basic implementation of document.getItems() method.
Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp (97477 => 97478)
--- trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp 2011-10-14 17:54:42 UTC (rev 97478)
@@ -1114,9 +1114,7 @@
if ((location + length < location) && (location + length))
length = 0;
- Element* selectionRoot = frame()->selection()->rootEditableElement();
- Element* scope = selectionRoot ? selectionRoot : frame()->document()->documentElement();
- RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(scope, location, length);
+ RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame()->selection()->rootEditableElementOrDocumentElement(), location, length);
if (!range)
return false;
IntRect intRect = frame()->editor()->firstRectForRange(range.get());
@@ -1138,7 +1136,7 @@
return notFound;
size_t location, length;
- TextIterator::locationAndLengthFromRange(range.get(), location, length);
+ TextIterator::getLocationAndLengthFromRange(frame()->selection()->rootEditableElementOrDocumentElement(), range.get(), location, length);
return location;
}
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (97477 => 97478)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2011-10-14 17:54:42 UTC (rev 97478)
@@ -1443,7 +1443,7 @@
bool WebViewImpl::compositionRange(size_t* location, size_t* length)
{
Frame* focused = focusedWebCoreFrame();
- if (!focused || !m_imeAcceptEvents)
+ if (!focused || !focused->selection() || !m_imeAcceptEvents)
return false;
Editor* editor = focused->editor();
if (!editor || !editor->hasComposition())
@@ -1453,7 +1453,7 @@
if (!range.get())
return false;
- if (TextIterator::locationAndLengthFromRange(range.get(), *location, *length))
+ if (TextIterator::getLocationAndLengthFromRange(focused->selection()->rootEditableElementOrDocumentElement(), range.get(), *location, *length))
return true;
return false;
}
@@ -1519,7 +1519,7 @@
size_t location;
size_t length;
RefPtr<Range> range = selection->selection().firstRange();
- if (!range || !TextIterator::locationAndLengthFromRange(range.get(), location, length))
+ if (!range || !TextIterator::getLocationAndLengthFromRange(selection->rootEditableElementOrDocumentElement(), range.get(), location, length))
return false;
if (selection->selection().isBaseFirst()) {
@@ -1632,7 +1632,7 @@
if (!range.get())
return false;
- if (TextIterator::locationAndLengthFromRange(range.get(), *location, *length))
+ if (TextIterator::getLocationAndLengthFromRange(selection->rootEditableElementOrDocumentElement(), range.get(), *location, *length))
return true;
return false;
}
Modified: trunk/Source/WebKit/chromium/src/mac/WebSubstringUtil.mm (97477 => 97478)
--- trunk/Source/WebKit/chromium/src/mac/WebSubstringUtil.mm 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebKit/chromium/src/mac/WebSubstringUtil.mm 2011-10-14 17:54:42 UTC (rev 97478)
@@ -59,10 +59,7 @@
if (frame->view()->needsLayout())
frame->view()->layout();
- Element* selectionRoot = frame->selection()->rootEditableElement();
- selectionRoot = selectionRoot ? selectionRoot : frame->document()->documentElement();
-
- RefPtr<Range> range(TextIterator::rangeFromLocationAndLength(selectionRoot, location, length));
+ RefPtr<Range> range(TextIterator::rangeFromLocationAndLength(frame->selection()->rootEditableElementOrDocumentElement(), selectionRoot, location, length));
if (!range)
return nil;
Modified: trunk/Source/WebKit/gtk/ChangeLog (97477 => 97478)
--- trunk/Source/WebKit/gtk/ChangeLog 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebKit/gtk/ChangeLog 2011-10-14 17:54:42 UTC (rev 97478)
@@ -1,3 +1,13 @@
+2011-10-12 Ryosuke Niwa <[email protected]>
+
+ Make the interface of locationAndLengthFromRange and rangeFromLocationAndLength consistent
+ https://bugs.webkit.org/show_bug.cgi?id=69964
+
+ Reviewed by Enrica Casucci.
+
+ * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
+ (DumpRenderTreeSupportGtk::firstRectForCharacterRange):
+
2011-09-28 Martin Robinson <[email protected]>
[GTK] Move drag-and-drop code which can be shared with WebKit2 to WebCore
Modified: trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp (97477 => 97478)
--- trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp 2011-10-14 17:54:42 UTC (rev 97478)
@@ -616,9 +616,7 @@
if (!editor)
return false;
- Element* selectionRoot = frame->selection()->rootEditableElement();
- Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
- RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(scope, location, length);
+ RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame->selection()->rootEditableElementOrDocumentElement(), location, length);
if (!range)
return false;
Modified: trunk/Source/WebKit/mac/ChangeLog (97477 => 97478)
--- trunk/Source/WebKit/mac/ChangeLog 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebKit/mac/ChangeLog 2011-10-14 17:54:42 UTC (rev 97478)
@@ -1,3 +1,14 @@
+2011-10-12 Ryosuke Niwa <[email protected]>
+
+ Make the interface of locationAndLengthFromRange and rangeFromLocationAndLength consistent
+ https://bugs.webkit.org/show_bug.cgi?id=69964
+
+ Reviewed by Enrica Casucci.
+
+ * WebView/WebFrame.mm:
+ (-[WebFrame _convertToNSRange:]):
+ (-[WebFrame _convertToDOMRange:]):
+
2011-10-13 Mark Hahnenberg <[email protected]>
Rename virtual getConstructData to getConstructDataVirtual
Modified: trunk/Source/WebKit/mac/WebView/WebFrame.mm (97477 => 97478)
--- trunk/Source/WebKit/mac/WebView/WebFrame.mm 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebKit/mac/WebView/WebFrame.mm 2011-10-14 17:54:42 UTC (rev 97478)
@@ -666,7 +666,7 @@
size_t location;
size_t length;
- if (!TextIterator::locationAndLengthFromRange(range, location, length))
+ if (!TextIterator::getLocationAndLengthFromRange(_private->coreFrame->selection()->rootEditableElementOrDocumentElement(), range, location, length))
return NSMakeRange(NSNotFound, 0);
return NSMakeRange(location, length);
@@ -685,9 +685,7 @@
// directly in the document DOM, so serialization is problematic. Our solution is
// to use the root editable element of the selection start as the positional base.
// That fits with AppKit's idea of an input context.
- Element* selectionRoot = _private->coreFrame->selection()->rootEditableElement();
- Element* scope = selectionRoot ? selectionRoot : _private->coreFrame->document()->documentElement();
- return TextIterator::rangeFromLocationAndLength(scope, nsrange.location, nsrange.length);
+ return TextIterator::rangeFromLocationAndLength(_private->coreFrame->selection()->rootEditableElementOrDocumentElement(), nsrange.location, nsrange.length);
}
- (DOMRange *)convertNSRangeToDOMRange:(NSRange)nsrange
Modified: trunk/Source/WebKit/qt/ChangeLog (97477 => 97478)
--- trunk/Source/WebKit/qt/ChangeLog 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebKit/qt/ChangeLog 2011-10-14 17:54:42 UTC (rev 97478)
@@ -1,3 +1,13 @@
+2011-10-12 Ryosuke Niwa <[email protected]>
+
+ Make the interface of locationAndLengthFromRange and rangeFromLocationAndLength consistent
+ https://bugs.webkit.org/show_bug.cgi?id=69964
+
+ Reviewed by Enrica Casucci.
+
+ * WebCoreSupport/DumpRenderTreeSupportQt.cpp:
+ (DumpRenderTreeSupportQt::firstRectForCharacterRange):
+
2011-10-13 Adenilson Cavalcanti <[email protected]>
[Qt] GeolocationClient cleanups
Modified: trunk/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp (97477 => 97478)
--- trunk/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp 2011-10-14 17:54:42 UTC (rev 97478)
@@ -616,9 +616,7 @@
if ((location + length < location) && (location + length))
length = 0;
- Element* selectionRoot = frame->selection()->rootEditableElement();
- Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
- RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(scope, location, length);
+ RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame->selection()->rootEditableElementOrDocumentElement(), location, length);
if (!range)
return QVariantList();
Modified: trunk/Source/WebKit2/ChangeLog (97477 => 97478)
--- trunk/Source/WebKit2/ChangeLog 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebKit2/ChangeLog 2011-10-14 17:54:42 UTC (rev 97478)
@@ -1,3 +1,16 @@
+2011-10-12 Ryosuke Niwa <[email protected]>
+
+ Make the interface of locationAndLengthFromRange and rangeFromLocationAndLength consistent
+ https://bugs.webkit.org/show_bug.cgi?id=69964
+
+ Reviewed by Enrica Casucci.
+
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::getMarkedRange):
+ (WebKit::WebPage::getSelectedRange):
+ (WebKit::WebPage::characterIndexForPoint):
+ (WebKit::convertToRange):
+
2011-10-14 Nayan Kumar K <[email protected]>
[GTK] r97438: Inconsistent use of flattening vs flattering in function names/comments
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (97477 => 97478)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2011-10-14 17:23:39 UTC (rev 97477)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2011-10-14 17:54:42 UTC (rev 97478)
@@ -293,7 +293,7 @@
RefPtr<Range> range = frame->editor()->compositionRange();
size_t locationSize;
size_t lengthSize;
- if (range && TextIterator::locationAndLengthFromRange(range.get(), locationSize, lengthSize)) {
+ if (range && TextIterator::getLocationAndLengthFromRange(frame->selection()->rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) {
location = static_cast<uint64_t>(locationSize);
length = static_cast<uint64_t>(lengthSize);
}
@@ -310,7 +310,7 @@
size_t locationSize;
size_t lengthSize;
RefPtr<Range> range = frame->selection()->toNormalizedRange();
- if (range && TextIterator::locationAndLengthFromRange(range.get(), locationSize, lengthSize)) {
+ if (range && TextIterator::getLocationAndLengthFromRange(frame->selection()->rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) {
location = static_cast<uint64_t>(locationSize);
length = static_cast<uint64_t>(lengthSize);
}
@@ -360,7 +360,7 @@
size_t location;
size_t length;
- if (TextIterator::locationAndLengthFromRange(range.get(), location, length))
+ if (TextIterator::getLocationAndLengthFromRange(frame->selection()->rootEditableElementOrDocumentElement(), range.get(), location, length))
index = static_cast<uint64_t>(location);
}
@@ -377,9 +377,7 @@
// directly in the document DOM, so serialization is problematic. Our solution is
// to use the root editable element of the selection start as the positional base.
// That fits with AppKit's idea of an input context.
- Element* selectionRoot = frame->selection()->rootEditableElement();
- Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
- return TextIterator::rangeFromLocationAndLength(scope, nsrange.location, nsrange.length);
+ return TextIterator::rangeFromLocationAndLength(frame->selection()->rootEditableElementOrDocumentElement(), nsrange.location, nsrange.length);
}
void WebPage::firstRectForCharacterRange(uint64_t location, uint64_t length, WebCore::IntRect& resultRect)