bool DumpRenderTreeSupportEfl::selectedRange(Evas_Object* ewkView, int* start, int* length) { if (!(start && length)) return false; DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false); if (!page->focusController() || !page->focusController()->focusedOrMainFrame()) return false; WebCore::Frame* frame = page->focusController()->focusedOrMainFrame(); RefPtr<WebCore::Range> range = frame->selection()->toNormalizedRange().get(); if (!range) return false; WebCore::Element* selectionRoot = frame->selection()->rootEditableElement(); WebCore::Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement(); RefPtr<WebCore::Range> testRange = WebCore::Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset()); *start = WebCore::TextIterator::rangeLength(testRange.get()); WebCore::ExceptionCode ec; testRange->setEnd(range->endContainer(), range->endOffset(), ec); *length = WebCore::TextIterator::rangeLength(testRange.get()); return true; }
// static WebRange WebRange::fromDocumentRange(WebFrame* frame, int start, int length) { WebCore::Frame* webFrame = static_cast<WebFrameImpl*>(frame)->frame(); Element* selectionRoot = webFrame->selection()->rootEditableElement(); Element* scope = selectionRoot ? selectionRoot : webFrame->document()->documentElement(); return TextIterator::rangeFromLocationAndLength(scope, start, length); }
WebCore::IntRect DumpRenderTreeSupportEfl::selectionRectangle(const Evas_Object* ewkFrame) { WebCore::Frame* frame = EWKPrivate::coreFrame(ewkFrame); if (!frame) return WebCore::IntRect(); return enclosingIntRect(frame->selection()->bounds()); }
void wxWebView::OnKillFocus(wxFocusEvent& event) { WebCore::Frame* frame = 0; if (m_mainFrame) frame = m_mainFrame->GetFrame(); if (frame) { frame->selection()->setFocused(false); } event.Skip(); }
void wxWebView::OnKillFocus(wxFocusEvent& event) { WebCore::Frame* frame = 0; if (m_mainFrame) frame = m_mainFrame->GetFrame(); if (frame) { m_impl->page->focusController()->setActive(false); frame->selection()->setFocused(false); } event.Skip(); }
QVariantList DumpRenderTreeSupportQt::selectedRange(QWebPageAdapter *adapter) { WebCore::Frame* frame = adapter->page->focusController()->focusedOrMainFrame(); QVariantList selectedRange; RefPtr<Range> range = frame->selection()->toNormalizedRange().get(); Element* selectionRoot = frame->selection()->rootEditableElement(); Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement(); RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset()); ASSERT(testRange->startContainer() == scope); int startPosition = TextIterator::rangeLength(testRange.get()); ExceptionCode ec; testRange->setEnd(range->endContainer(), range->endOffset(), ec); ASSERT(testRange->startContainer() == scope); int endPosition = TextIterator::rangeLength(testRange.get()); selectedRange << startPosition << (endPosition - startPosition); return selectedRange; }
QVariantList DumpRenderTreeSupportQt::firstRectForCharacterRange(QWebPageAdapter *adapter, int location, int length) { WebCore::Frame* frame = adapter->page->focusController()->focusedOrMainFrame(); QVariantList rect; if ((location + length < location) && (location + length)) length = 0; RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame->selection()->rootEditableElementOrDocumentElement(), location, length); if (!range) return QVariantList(); QRect resultRect = frame->editor()->firstRectForRange(range.get()); rect << resultRect.x() << resultRect.y() << resultRect.width() << resultRect.height(); return rect; }
WebCore::IntRect DumpRenderTreeSupportEfl::firstRectForCharacterRange(Evas_Object* ewkView, int location, int length) { DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, WebCore::IntRect()); if (!page->focusController() || !page->focusController()->focusedOrMainFrame()) return WebCore::IntRect(); if ((location + length < location) && (location + length)) length = 0; WebCore::Frame* frame = page->focusController()->focusedOrMainFrame(); RefPtr<WebCore::Range> range = WebCore::TextIterator::rangeFromLocationAndLength(frame->selection()->rootEditableElementOrDocumentElement(), location, length); if (!range) return WebCore::IntRect(); return frame->editor().firstRectForRange(range.get()); }
WebCore::IntRect DumpRenderTreeSupportEfl::firstRectForCharacterRange(Evas_Object* ewkView, int location, int length) { WebCore::Page* page = EWKPrivate::corePage(ewkView); if (!page || !page->focusController() || !page->focusController()->focusedOrMainFrame() || !page->focusController()->focusedOrMainFrame()->editor()) return WebCore::IntRect(); if ((location + length < location) && (location + length)) length = 0; WebCore::Frame* frame = page->focusController()->focusedOrMainFrame(); WebCore::Editor* editor = frame->editor(); RefPtr<WebCore::Range> range = WebCore::TextIterator::rangeFromLocationAndLength(frame->selection()->rootEditableElementOrDocumentElement(), location, length); if (!range) return WebCore::IntRect(); return editor->firstRectForRange(range.get()); }
static gboolean webkit_web_view_key_press_event(GtkWidget* widget, GdkEventKey* event) { // WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); WebCore::Frame* frame = core(webView_s)->focusController()->focusedOrMainFrame(); PlatformKeyboardEvent keyboardEvent(event); if (frame->eventHandler()->keyEvent(keyboardEvent)) return TRUE; FrameView* view = frame->view(); SelectionController::EAlteration alteration; if (event->state & GDK_SHIFT_MASK) alteration = SelectionController::EXTEND; else alteration = SelectionController::MOVE; // TODO: We probably want to use GTK+ key bindings here and perhaps take an // approach more like the Win and Mac ports for key handling. switch (event->keyval) { case GDK_Down: view->scrollBy(IntSize(0, (int)Scrollbar::pixelsPerLineStep())); return TRUE; case GDK_Up: view->scrollBy(IntSize(0, (int)-Scrollbar::pixelsPerLineStep())); return TRUE; case GDK_Right: view->scrollBy(IntSize((int)Scrollbar::pixelsPerLineStep(), 0)); return TRUE; case GDK_Left: view->scrollBy(IntSize((int)-Scrollbar::pixelsPerLineStep(), 0)); return TRUE; case GDK_Home: frame->selection()->modify(alteration, SelectionController::BACKWARD, DocumentBoundary, true); return TRUE; case GDK_End: frame->selection()->modify(alteration, SelectionController::FORWARD, DocumentBoundary, true); return TRUE; case GDK_Escape: gtk_main_quit(); return true; case GDK_F1: webView_s->goBack(); return true; case GDK_F2: webView_s->goForward(); return true; case GDK_F3: // We ignore the return value as we are not interested // in whether the zoom occurred. webView_s->zoomPageIn(); return true; case GDK_F4: // Same comment as above. webView_s->zoomPageOut(); return true; } /* Chain up to our parent class for binding activation */ return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_press_event(widget, event); }