* khtml/rendering/bidi.cpp:
(khtml::skipNonBreakingSpace): New helper.
(khtml::RenderBlock::skipWhitespace): Do not skip non-breaking spaces that are
at the start of a block. This was preventing users from typing spaces in empty
documents.
* layout-tests/editing/inserting/insert-space-in-empty-doc-expected.txt: Added.
* layout-tests/editing/inserting/insert-space-in-empty-doc.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7841
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
--- /dev/null
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {DIV} at (0,0) size 784x56 [border: (2px solid #FF0000)]
+ RenderText {TEXT} at (14,14) size 38x28
+ text run at (14,14) width 38: " foo"
+selection is CARET:
+start: position 4 of child 1 {TEXT} of child 1 {DIV} of root {BODY}
+upstream: position 4 of child 1 {TEXT} of child 1 {DIV} of root {BODY}
+downstream: position 4 of child 1 {TEXT} of child 1 {DIV} of root {BODY}
--- /dev/null
+<html>
+<head>
+
+<style>
+.editing {
+ border: 2px solid red;
+ padding: 12px;
+ font-size: 24px;
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+ typeCharacterCommand(" ");
+ typeCharacterCommand("f");
+ typeCharacterCommand("o");
+ typeCharacterCommand("o");
+}
+
+</script>
+
+<title>Editing Test</title>
+</head>
+<body id="root">
+<div contenteditable id="test" class="editing"></div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
+2004-10-14 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by Hyatt
+
+ * khtml/rendering/bidi.cpp:
+ (khtml::skipNonBreakingSpace): New helper.
+ (khtml::RenderBlock::skipWhitespace): Do not skip non-breaking spaces that are
+ at the start of a block. This was preventing users from typing spaces in empty
+ documents.
+ * layout-tests/editing/inserting/insert-space-in-empty-doc-expected.txt: Added.
+ * layout-tests/editing/inserting/insert-space-in-empty-doc.html: Added.
+
2004-10-14 Adele Amchan <adele@apple.com>
Reviewed by Darin and Ken.
static const ushort nonBreakingSpace = 0xa0;
+inline bool RenderBlock::skipNonBreakingSpace(BidiIterator &it)
+{
+ if (it.obj->style()->nbspMode() != SPACE || it.current().unicode() != nonBreakingSpace)
+ return false;
+
+ // Do not skip a non-breaking spaces if it is the first character
+ // on the first line of a block.
+ return !m_firstLine || !isLineEmpty;
+}
+
int RenderBlock::skipWhitespace(BidiIterator &it, BidiState &bidi)
{
int width = lineWidth(m_height);
while (!it.atEnd() && (it.obj->isInlineFlow() || (it.obj->style()->whiteSpace() != PRE && !it.obj->isBR() &&
(it.current() == ' ' || it.current() == '\n' ||
- (it.obj->style()->nbspMode() == SPACE && it.current().unicode() == nonBreakingSpace) || it.obj->isFloatingOrPositioned())))) {
+ skipNonBreakingSpace(it) || it.obj->isFloatingOrPositioned())))) {
if (it.obj->isFloatingOrPositioned()) {
RenderObject *o = it.obj;
// add to special objects...
private:
DOM::Position positionForBox(InlineBox *box, bool start=true) const;
DOM::Position positionForRenderer(RenderObject *renderer, bool start=true) const;
+ bool skipNonBreakingSpace(BidiIterator &it);
protected:
struct FloatingObject {