Reviewed by Hyatt
authorkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Oct 2004 23:51:47 +0000 (23:51 +0000)
committerkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Oct 2004 23:51:47 +0000 (23:51 +0000)
        * 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

LayoutTests/editing/inserting/insert-space-in-empty-doc-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-space-in-empty-doc.html [new file with mode: 0644]
WebCore/ChangeLog-2005-08-23
WebCore/khtml/rendering/bidi.cpp
WebCore/khtml/rendering/render_block.h

diff --git a/LayoutTests/editing/inserting/insert-space-in-empty-doc-expected.txt b/LayoutTests/editing/inserting/insert-space-in-empty-doc-expected.txt
new file mode 100644 (file)
index 0000000..cdbb989
--- /dev/null
@@ -0,0 +1,12 @@
+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}
diff --git a/LayoutTests/editing/inserting/insert-space-in-empty-doc.html b/LayoutTests/editing/inserting/insert-space-in-empty-doc.html
new file mode 100644 (file)
index 0000000..2a9cadc
--- /dev/null
@@ -0,0 +1,34 @@
+<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>
index 8dfd105253c4cee4fa3e134b6ea41e15ccc32cca..255f04a3785d92147c5f889e5cc11cae453ba9af 100644 (file)
@@ -1,3 +1,15 @@
+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.
index fc0682502b8d8c8b8cd0809c43d34c9dd42440ef..95e534c0e43ee133da06684cee6eda333776721b 100644 (file)
@@ -1734,12 +1734,22 @@ bool RenderBlock::matchedEndLine(const BidiIterator& start, const BidiIterator&
 
 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...
index efb380e228c728096ebd4d192b6169606a27e34c..67875f5daae6d841b0317bae283205ee5c79ff6d 100644 (file)
@@ -260,6 +260,7 @@ protected:
 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 {