void TextInputController::selectedRange(const CppArgumentList&, CppVariant* result) { result->setNull(); WebFrame* mainFrame = getMainFrame(); if (!mainFrame) return; WebRange range = mainFrame->selectionRange(); result->set(StringPrintf("%d,%d", range.startOffset(), range.endOffset())); }
void TextInputController::selectedRange(const CppArgumentList&, CppVariant* result) { result->setNull(); WebFrame* mainFrame = getMainFrame(); if (!mainFrame) return; WebRange range = mainFrame->selectionRange(); Vector<int> intArray(2); intArray[0] = range.startOffset(); intArray[1] = range.endOffset(); result->set(WebBindings::makeIntArray(intArray)); }
static void printRangeDescription(const WebRange& range) { if (range.isNull()) { fputs("(null)", stdout); return; } printf("range from %d of ", range.startOffset()); int exception = 0; WebNode startNode = range.startContainer(exception); printNodeDescription(startNode, exception); printf(" to %d of ", range.endOffset()); WebNode endNode = range.endContainer(exception); printNodeDescription(endNode, exception); }
void TextInputController::markedRange(const CppArgumentList&, CppVariant* result) { result->setNull(); WebFrame* mainFrame = m_webView->mainFrame(); if (!mainFrame) return; WebRange range = mainFrame->markedRange(); vector<int> intArray(2); intArray[0] = range.startOffset(); intArray[1] = range.endOffset(); NPObject* resultArray = WebBindings::makeIntArray(intArray); result->set(resultArray); WebBindings::releaseObject(resultArray); }
void PlainTextController::plainText(const CppArgumentList& arguments, CppVariant* result) { result->setNull(); if (arguments.size() < 1 || !arguments[0].isObject()) return; // Check that passed-in object is, in fact, a range. NPObject* npobject = NPVARIANT_TO_OBJECT(arguments[0]); if (!npobject) return; WebRange range; if (!WebBindings::getRange(npobject, &range)) return; // Extract the text using the Range's text() method WebString text = range.toPlainText(); result->set(text.utf8()); }