common = p.getLowestContainer();
} else {
common = EditModelQuery.getInstance().getCommonAncestor(start,
end);
}
DOMRange rt;
// This code is for h1-h6 only, it may need to be replaced.
if ((rt = replaceExistingH(start, end)) != null) {
return rt;
}
// replace existing p
if (getTag().equalsIgnoreCase(IHTMLConstants.TAG_P)) {
rt = replaceExistingP(start, end);
if (rt != null) {
return rt;
}
}
if (start.getContainerNode() == end.getContainerNode()) {
int offset1 = start.getOffset();
int offset2 = end.getOffset();
IDOMPosition old = start;
start = split(start);
// parent is splited
if (start != old) {
container = start.getNextSiblingNode();
offset2 -= offset1;
end = new DOMPosition(container, offset2);
}
end = split(end);
} else {
start = split(common, start);
end = split(common, end);
}
range = InsertStyleTag(new DOMRange(start, end));
}
return range;
}