void CharacterData::replaceData(unsigned offset, unsigned count, const String& arg, ExceptionCode& ec) { checkCharDataOperation(offset, ec); if (ec) return; unsigned realCount; if (offset + count > length()) realCount = length() - offset; else realCount = count; String newStr = m_data; newStr.remove(offset, realCount); newStr.insert(arg, offset); RefPtr<StringImpl> oldStr = m_data; m_data = newStr.impl(); if ((!renderer() || !rendererIsNeeded(renderer()->style())) && attached()) { detach(); attach(); } else if (renderer()) static_cast<RenderText*>(renderer())->setTextWithOffset(m_data, offset, count); dispatchModifiedEvent(oldStr.get()); // update the markers for spell checking and grammar checking document()->textRemoved(this, offset, realCount); document()->textInserted(this, offset, arg.length()); }
void CharacterData::deleteData(unsigned offset, unsigned count, ExceptionCode& ec) { checkCharDataOperation(offset, ec); if (ec) return; unsigned realCount; if (offset + count > length()) realCount = length() - offset; else realCount = count; String newStr = m_data; newStr.remove(offset, realCount); RefPtr<StringImpl> oldStr = m_data; m_data = newStr.impl(); if ((!renderer() || !rendererIsNeeded(renderer()->style())) && attached()) { detach(); attach(); } else if (renderer()) static_cast<RenderText*>(renderer())->setTextWithOffset(m_data, offset, count); dispatchModifiedEvent(oldStr.get()); document()->textRemoved(this, offset, realCount); }
String CharacterData::substringData(unsigned offset, unsigned count, ExceptionCode& ec) { checkCharDataOperation(offset, ec); if (ec) return String(); return m_data.substring(offset, count); }
void CharacterData::insertData(unsigned offset, const String& data, ExceptionCode& ec) { checkCharDataOperation(offset, ec); if (ec) return; String newStr = m_data; newStr.insert(data, offset); setDataAndUpdate(newStr, offset, 0, data.length()); document()->textInserted(this, offset, data.length()); }
void CharacterData::deleteData(unsigned offset, unsigned count, ExceptionCode& ec) { checkCharDataOperation(offset, ec); if (ec) return; count = std::min(count, length() - offset); String newStr = m_data; newStr.remove(offset, count); setDataAndUpdate(newStr, offset, count, 0); document().textRemoved(this, offset, count); }
void CharacterData::replaceData(unsigned offset, unsigned count, const String& data, ExceptionCode& ec) { checkCharDataOperation(offset, ec); if (ec) return; count = std::min(count, length() - offset); String newStr = m_data; newStr.remove(offset, count); newStr.insert(data, offset); setDataAndUpdate(newStr, offset, count, data.length()); // update the markers for spell checking and grammar checking document().textRemoved(this, offset, count); document().textInserted(this, offset, data.length()); }
void CharacterData::deleteData(unsigned offset, unsigned count, ExceptionCode& ec) { checkCharDataOperation(offset, ec); if (ec) return; unsigned realCount; if (offset + count > length()) realCount = length() - offset; else realCount = count; String newStr = m_data; newStr.remove(offset, realCount); setDataAndUpdate(newStr, offset, count, 0); document()->textRemoved(this, offset, realCount); }
void CharacterData::insertData(unsigned offset, const String& arg, ExceptionCode& ec) { checkCharDataOperation(offset, ec); if (ec) return; String newStr = m_data; newStr.insert(arg, offset); RefPtr<StringImpl> oldStr = m_data; m_data = newStr.impl(); if ((!renderer() || !rendererIsNeeded(renderer()->style())) && attached()) { detach(); attach(); } else if (renderer()) static_cast<RenderText*>(renderer())->setTextWithOffset(m_data, offset, 0); dispatchModifiedEvent(oldStr.get()); document()->textInserted(this, offset, arg.length()); }