[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

hyatt at apple.com hyatt at apple.com
Wed Dec 22 15:35:17 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 1a575c3a24629d3824c9a0b6f12a0eecbbc0e158
Author: hyatt at apple.com <hyatt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 8 21:12:00 2010 +0000

    https://bugs.webkit.org/show_bug.cgi?id=49126
    
    Reviewed by Dan Bernstein.
    
    RenderBlock::positionForPoint is not writing-mode aware.  Patch the function to examine lines in the correct
    writing-mode direction.  Patched and renamed a number of helpers used by positionForPoint.
    
    Fixed a bug with RenderReplaced's positionForPoint. There was a coordinate space mismatch between what the
    function expected (local coordinates) and what was passed in (containing block coords), which meant the function didn't even work.
    
    Fixed a bug with the propagation of selection state on RenderReplaced to its containing block.  The bit double propagated
    because both the base class function and the derived class function did the propagation, and the setter function did not
    do the right thing if this happened.
    
    Patched the localSelectionRect method on RenderReplaced so that selection draws in the right place in all writing modes.
    
    Added new tests of positionForPoint and replaced elements in fast/blockflow.
    
    WebCore:
    
    * editing/visible_units.cpp:
    (WebCore::previousLinePosition):
    (WebCore::nextLinePosition):
    * platform/graphics/IntPoint.h:
    (WebCore::IntPoint::transpose):
    * rendering/InlineBox.cpp:
    (WebCore::InlineBox::paint):
    * rendering/RenderBlock.cpp:
    (WebCore::RenderBlock::nodeAtPoint):
    (WebCore::RenderBlock::hitTestFloats):
    (WebCore::positionForPointRespectingEditingBoundaries):
    (WebCore::RenderBlock::positionForPointWithInlineChildren):
    (WebCore::RenderBlock::positionForPoint):
    * rendering/RenderReplaced.cpp:
    (WebCore::RenderReplaced::positionForPoint):
    (WebCore::RenderReplaced::localSelectionRect):
    (WebCore::RenderReplaced::setSelectionState):
    * rendering/RenderReplaced.h:
    * rendering/RenderText.cpp:
    (WebCore::RenderText::positionForPoint):
    * rendering/RootInlineBox.cpp:
    (WebCore::RootInlineBox::closestLeafChildForLogicalLeftPosition):
    * rendering/RootInlineBox.h:
    
    LayoutTests:
    
    * fast/blockflow/horizontal-bt-replaced-selection.html: Added.
    * fast/blockflow/vertical-lr-replaced-selection.html: Added.
    * fast/blockflow/vertical-rl-replaced-selection.html: Added.
    * platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.checksum: Added.
    * platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.png: Added.
    * platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.txt: Added.
    * platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.checksum: Added.
    * platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.png: Added.
    * platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.txt: Added.
    * platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.checksum: Added.
    * platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.png: Added.
    * platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.txt: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71563 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 9f1c516..eb8a0d0 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,36 @@
+2010-11-08  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        https://bugs.webkit.org/show_bug.cgi?id=49126
+        
+        RenderBlock::positionForPoint is not writing-mode aware.  Patch the function to examine lines in the correct
+        writing-mode direction.  Patched and renamed a number of helpers used by positionForPoint.
+        
+        Fixed a bug with RenderReplaced's positionForPoint. There was a coordinate space mismatch between what the
+        function expected (local coordinates) and what was passed in (containing block coords), which meant the function didn't even work.
+        
+        Fixed a bug with the propagation of selection state on RenderReplaced to its containing block.  The bit double propagated
+        because both the base class function and the derived class function did the propagation, and the setter function did not
+        do the right thing if this happened.
+        
+        Patched the localSelectionRect method on RenderReplaced so that selection draws in the right place in all writing modes.
+        
+        Added new tests of positionForPoint and replaced elements in fast/blockflow.
+
+        * fast/blockflow/horizontal-bt-replaced-selection.html: Added.
+        * fast/blockflow/vertical-lr-replaced-selection.html: Added.
+        * fast/blockflow/vertical-rl-replaced-selection.html: Added.
+        * platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.checksum: Added.
+        * platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.png: Added.
+        * platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.txt: Added.
+        * platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.checksum: Added.
+        * platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.png: Added.
+        * platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.txt: Added.
+        * platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.checksum: Added.
+        * platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.png: Added.
+        * platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.txt: Added.
+
 2010-11-08  Anders Carlsson  <andersca at apple.com>
 
         Reviewed by Adam Roben.
diff --git a/LayoutTests/fast/blockflow/horizontal-bt-replaced-selection.html b/LayoutTests/fast/blockflow/horizontal-bt-replaced-selection.html
new file mode 100644
index 0000000..ddf9a80
--- /dev/null
+++ b/LayoutTests/fast/blockflow/horizontal-bt-replaced-selection.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<head>
+<script>
+function selectStuff()
+{
+    document.body.offsetLeft;
+    if (eventSender) {
+        eventSender.mouseMoveTo(25, 590);
+        eventSender.mouseDown();
+        eventSender.mouseMoveTo(25, 590);
+        eventSender.mouseMoveTo(25, 470);
+        eventSender.mouseUp();
+    }
+}
+</script>
+</head>
+
+<body onload="selectStuff()" style="font-size:36px; -webkit-writing-mode:horizontal-bt">This is the first line of text.<br>
+<img style="-webkit-logical-width:20px;-webkit-logical-height:50px;background-color:green"> This is the second line of <img style="-webkit-logical-width:20px;-webkit-logical-height:100px;background-color:purple"> text.
\ No newline at end of file
diff --git a/LayoutTests/fast/blockflow/vertical-lr-replaced-selection.html b/LayoutTests/fast/blockflow/vertical-lr-replaced-selection.html
new file mode 100644
index 0000000..ac3b9ff
--- /dev/null
+++ b/LayoutTests/fast/blockflow/vertical-lr-replaced-selection.html
@@ -0,0 +1,18 @@
+<!doctype html><head>
+<script>
+function selectStuff()
+{
+    document.body.offsetLeft;
+    if (eventSender) {
+        eventSender.mouseMoveTo(10, 25);
+        eventSender.mouseDown();
+        eventSender.mouseMoveTo(10, 25);
+        eventSender.mouseMoveTo(130, 25);
+        eventSender.mouseUp();
+    }
+}
+</script>
+</head>
+
+<body onload="selectStuff()" style="font-size:36px; -webkit-writing-mode:vertical-lr">This is the first line of text.<br>
+<img style="-webkit-logical-width:20px;-webkit-logical-height:50px;background-color:green"> This is the second line of <img style="-webkit-logical-width:20px;-webkit-logical-height:100px;background-color:purple"> text.
\ No newline at end of file
diff --git a/LayoutTests/fast/blockflow/vertical-rl-replaced-selection.html b/LayoutTests/fast/blockflow/vertical-rl-replaced-selection.html
new file mode 100644
index 0000000..f0bf5eb
--- /dev/null
+++ b/LayoutTests/fast/blockflow/vertical-rl-replaced-selection.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<head>
+<script>
+function selectStuff()
+{
+    document.body.offsetLeft;
+    if (eventSender) {
+        eventSender.mouseMoveTo(790, 25);
+        eventSender.mouseDown();
+        eventSender.mouseMoveTo(790, 25);
+        eventSender.mouseMoveTo(670, 25);
+        eventSender.mouseUp();
+    }
+}
+</script>
+</head>
+
+<body onload="selectStuff()" style="font-size:36px; -webkit-writing-mode:vertical-rl">This is the first line of text.<br>
+<img style="-webkit-logical-width:20px;-webkit-logical-height:50px;background-color:green"> This is the second line of <img style="-webkit-logical-width:20px;-webkit-logical-height:100px;background-color:purple"> text.
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.checksum b/LayoutTests/platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.checksum
new file mode 100644
index 0000000..1ffed94
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.checksum
@@ -0,0 +1 @@
+729b5cc2440702d7ad7d1098bc11f00a
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.png b/LayoutTests/platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.png
new file mode 100644
index 0000000..9b86f8c
Binary files /dev/null and b/LayoutTests/platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.txt b/LayoutTests/platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.txt
new file mode 100644
index 0000000..78ad50d
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/horizontal-bt-replaced-selection-expected.txt
@@ -0,0 +1,16 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,434) size 800x166
+  RenderBlock {HTML} at (0,0) size 800x166
+    RenderBody {BODY} at (8,8) size 784x150
+      RenderText {#text} at (0,0) size 391x41
+        text run at (0,0) width 391: "This is the first line of text."
+      RenderBR {BR} at (391,0) size 0x41
+      RenderImage {IMG} at (0,50) size 20x50 [bgcolor=#008000]
+      RenderText {#text} at (20,41) size 379x41
+        text run at (20,41) width 379: " This is the second line of "
+      RenderImage {IMG} at (399,50) size 20x100 [bgcolor=#800080]
+      RenderText {#text} at (419,41) size 72x41
+        text run at (419,41) width 72: " text."
+selection start: position 1 of child 0 {#text} of body
+selection end:   position 1 of child 3 {IMG} of body
diff --git a/LayoutTests/platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.checksum b/LayoutTests/platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.checksum
new file mode 100644
index 0000000..dee2edf
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.checksum
@@ -0,0 +1 @@
+2882d4134c6730040db03f178f4738b6
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.png b/LayoutTests/platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.png
new file mode 100644
index 0000000..e930e38
Binary files /dev/null and b/LayoutTests/platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.txt b/LayoutTests/platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.txt
new file mode 100644
index 0000000..b070bc3
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/vertical-lr-replaced-selection-expected.txt
@@ -0,0 +1,16 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 166x600
+  RenderBlock {HTML} at (0,0) size 166x600
+    RenderBody {BODY} at (8,8) size 150x584
+      RenderText {#text} at (0,0) size 41x391
+        text run at (0,0) width 391: "This is the first line of text."
+      RenderBR {BR} at (0,391) size 41x0
+      RenderImage {IMG} at (50,0) size 50x20 [bgcolor=#008000]
+      RenderText {#text} at (41,20) size 41x379
+        text run at (41,20) width 379: " This is the second line of "
+      RenderImage {IMG} at (50,399) size 100x20 [bgcolor=#800080]
+      RenderText {#text} at (41,419) size 41x72
+        text run at (41,419) width 72: " text."
+selection start: position 1 of child 0 {#text} of body
+selection end:   position 1 of child 3 {IMG} of body
diff --git a/LayoutTests/platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.checksum b/LayoutTests/platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.checksum
new file mode 100644
index 0000000..09a0078
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.checksum
@@ -0,0 +1 @@
+b3edb644561400c75b3b24100966f03f
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.png b/LayoutTests/platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.png
new file mode 100644
index 0000000..44b1405
Binary files /dev/null and b/LayoutTests/platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.txt b/LayoutTests/platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.txt
new file mode 100644
index 0000000..db095ca
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/vertical-rl-replaced-selection-expected.txt
@@ -0,0 +1,16 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (634,0) size 166x600
+  RenderBlock {HTML} at (0,0) size 166x600
+    RenderBody {BODY} at (8,8) size 150x584
+      RenderText {#text} at (0,0) size 41x391
+        text run at (0,0) width 391: "This is the first line of text."
+      RenderBR {BR} at (0,391) size 41x0
+      RenderImage {IMG} at (91,0) size 50x20 [bgcolor=#008000]
+      RenderText {#text} at (109,20) size 41x379
+        text run at (109,20) width 379: " This is the second line of "
+      RenderImage {IMG} at (41,399) size 100x20 [bgcolor=#800080]
+      RenderText {#text} at (109,419) size 41x72
+        text run at (109,419) width 72: " text."
+selection start: position 1 of child 0 {#text} of body
+selection end:   position 1 of child 3 {IMG} of body
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2db8db1..2fe1b72 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,47 @@
+2010-11-08  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        https://bugs.webkit.org/show_bug.cgi?id=49126
+        
+        RenderBlock::positionForPoint is not writing-mode aware.  Patch the function to examine lines in the correct
+        writing-mode direction.  Patched and renamed a number of helpers used by positionForPoint.
+        
+        Fixed a bug with RenderReplaced's positionForPoint. There was a coordinate space mismatch between what the
+        function expected (local coordinates) and what was passed in (containing block coords), which meant the function didn't even work.
+        
+        Fixed a bug with the propagation of selection state on RenderReplaced to its containing block.  The bit double propagated
+        because both the base class function and the derived class function did the propagation, and the setter function did not
+        do the right thing if this happened.
+        
+        Patched the localSelectionRect method on RenderReplaced so that selection draws in the right place in all writing modes.
+        
+        Added new tests of positionForPoint and replaced elements in fast/blockflow.
+
+        * editing/visible_units.cpp:
+        (WebCore::previousLinePosition):
+        (WebCore::nextLinePosition):
+        * platform/graphics/IntPoint.h:
+        (WebCore::IntPoint::transpose):
+        * rendering/InlineBox.cpp:
+        (WebCore::InlineBox::paint):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::nodeAtPoint):
+        (WebCore::RenderBlock::hitTestFloats):
+        (WebCore::positionForPointRespectingEditingBoundaries):
+        (WebCore::RenderBlock::positionForPointWithInlineChildren):
+        (WebCore::RenderBlock::positionForPoint):
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::positionForPoint):
+        (WebCore::RenderReplaced::localSelectionRect):
+        (WebCore::RenderReplaced::setSelectionState):
+        * rendering/RenderReplaced.h:
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::positionForPoint):
+        * rendering/RootInlineBox.cpp:
+        (WebCore::RootInlineBox::closestLeafChildForLogicalLeftPosition):
+        * rendering/RootInlineBox.h:
+
 2010-11-08  Nate Chapin  <japhet at chromium.org>
 
         Reviewed by Alexey Proskuryakov.
diff --git a/WebCore/editing/visible_units.cpp b/WebCore/editing/visible_units.cpp
index 8b11013..d6e1a6e 100644
--- a/WebCore/editing/visible_units.cpp
+++ b/WebCore/editing/visible_units.cpp
@@ -607,7 +607,7 @@ VisiblePosition previousLinePosition(const VisiblePosition &visiblePosition, int
         FloatPoint absPos = containingBlock->localToAbsolute(FloatPoint());
         if (containingBlock->hasOverflowClip())
             absPos -= containingBlock->layer()->scrolledContentOffset();
-        RenderObject* renderer = root->closestLeafChildForXPos(x - absPos.x(), isEditablePosition(p))->renderer();
+        RenderObject* renderer = root->closestLeafChildForLogicalLeftPosition(x - absPos.x(), isEditablePosition(p))->renderer();
         Node* node = renderer->node();
         if (node && editingIgnoresContent(node))
             return Position(node->parent(), node->nodeIndex());
@@ -712,7 +712,7 @@ VisiblePosition nextLinePosition(const VisiblePosition &visiblePosition, int x)
         FloatPoint absPos = containingBlock->localToAbsolute(FloatPoint());
         if (containingBlock->hasOverflowClip())
             absPos -= containingBlock->layer()->scrolledContentOffset();
-        RenderObject* renderer = root->closestLeafChildForXPos(x - absPos.x(), isEditablePosition(p))->renderer();
+        RenderObject* renderer = root->closestLeafChildForLogicalLeftPosition(x - absPos.x(), isEditablePosition(p))->renderer();
         Node* node = renderer->node();
         if (node && editingIgnoresContent(node))
             return Position(node->parent(), node->nodeIndex());
diff --git a/WebCore/platform/graphics/IntPoint.h b/WebCore/platform/graphics/IntPoint.h
index d4ea2f2..cd5e4d4 100644
--- a/WebCore/platform/graphics/IntPoint.h
+++ b/WebCore/platform/graphics/IntPoint.h
@@ -109,6 +109,11 @@ public:
         *this = expandedTo(zero());
     }
 
+    IntPoint transposedPoint() const
+    {
+        return IntPoint(m_y, m_x);
+    }
+
 #if PLATFORM(CG)
     explicit IntPoint(const CGPoint&); // don't do this implicitly since it's lossy
     operator CGPoint() const;
diff --git a/WebCore/rendering/InlineBox.cpp b/WebCore/rendering/InlineBox.cpp
index b8f0ce1..145096b 100644
--- a/WebCore/rendering/InlineBox.cpp
+++ b/WebCore/rendering/InlineBox.cpp
@@ -164,22 +164,26 @@ void InlineBox::paint(PaintInfo& paintInfo, int tx, int ty)
     if (!paintInfo.shouldPaintWithinRoot(renderer()) || (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection))
         return;
 
+    IntPoint childPoint = IntPoint(tx, ty);
+    if (parent()->renderer()->style()->isFlippedBlocksWritingMode()) // Faster than calling containingBlock().
+        childPoint = renderer()->containingBlock()->flipForWritingMode(toRenderBox(renderer()), childPoint, RenderBox::ParentToChildFlippingAdjustment);
+    
     // Paint all phases of replaced elements atomically, as though the replaced element established its
     // own stacking context.  (See Appendix E.2, section 6.4 on inline block/table elements in the CSS2.1
     // specification.)
     bool preservePhase = paintInfo.phase == PaintPhaseSelection || paintInfo.phase == PaintPhaseTextClip;
     PaintInfo info(paintInfo);
     info.phase = preservePhase ? paintInfo.phase : PaintPhaseBlockBackground;
-    renderer()->paint(info, tx, ty);
+    renderer()->paint(info, childPoint.x(), childPoint.y());
     if (!preservePhase) {
         info.phase = PaintPhaseChildBlockBackgrounds;
-        renderer()->paint(info, tx, ty);
+        renderer()->paint(info, childPoint.x(), childPoint.y());
         info.phase = PaintPhaseFloat;
-        renderer()->paint(info, tx, ty);
+        renderer()->paint(info, childPoint.x(), childPoint.y());
         info.phase = PaintPhaseForeground;
-        renderer()->paint(info, tx, ty);
+        renderer()->paint(info, childPoint.x(), childPoint.y());
         info.phase = PaintPhaseOutline;
-        renderer()->paint(info, tx, ty);
+        renderer()->paint(info, childPoint.x(), childPoint.y());
     }
 }
 
diff --git a/WebCore/rendering/RenderBlock.cpp b/WebCore/rendering/RenderBlock.cpp
index 0d6a560..f7ab9eb 100644
--- a/WebCore/rendering/RenderBlock.cpp
+++ b/WebCore/rendering/RenderBlock.cpp
@@ -4135,7 +4135,7 @@ bool RenderBlock::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
     if (hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground) {
         IntRect boundsRect(tx, ty, width(), height());
         if (visibleToHitTesting() && boundsRect.intersects(result.rectForPoint(_x, _y))) {
-            updateHitTestResult(result, IntPoint(_x - tx, _y - ty));
+            updateHitTestResult(result, flipForWritingMode(IntPoint(_x - tx, _y - ty)));
             if (!result.addNodeToRectBasedTestResult(node(), _x, _y, boundsRect))
                 return true;
         }
@@ -4159,8 +4159,8 @@ bool RenderBlock::hitTestFloats(const HitTestRequest& request, HitTestResult& re
     for (it.toLast(); (floatingObject = it.current()); --it) {
         if (floatingObject->m_shouldPaint && !floatingObject->m_renderer->hasSelfPaintingLayer()) {
             int xOffset = floatingObject->left() + floatingObject->m_renderer->marginLeft() - floatingObject->m_renderer->x();
-            int yOffset =  floatingObject->top() + floatingObject->m_renderer->marginTop() - floatingObject->m_renderer->y();
-            IntPoint childPoint= flipForWritingMode(floatingObject->m_renderer, IntPoint(tx + xOffset, ty + yOffset), ParentToChildFlippingAdjustment);
+            int yOffset = floatingObject->top() + floatingObject->m_renderer->marginTop() - floatingObject->m_renderer->y();
+            IntPoint childPoint = flipForWritingMode(floatingObject->m_renderer, IntPoint(tx + xOffset, ty + yOffset), ParentToChildFlippingAdjustment);
             if (floatingObject->m_renderer->hitTest(request, result, IntPoint(x, y), childPoint.x(), childPoint.y())) {
                 updateHitTestResult(result, IntPoint(x - childPoint.x(), y - childPoint.y()));
                 return true;
@@ -4263,8 +4263,9 @@ Position RenderBlock::positionForRenderer(RenderObject* renderer, bool start) co
 // FIXME: This function should go on RenderObject as an instance method. Then
 // all cases in which positionForPoint recurs could call this instead to
 // prevent crossing editable boundaries. This would require many tests.
-static VisiblePosition positionForPointRespectingEditingBoundaries(RenderBox* parent, RenderBox* child, const IntPoint& pointInParentCoordinates)
+static VisiblePosition positionForPointRespectingEditingBoundaries(RenderBlock* parent, RenderBox* child, const IntPoint& pointInParentCoordinates)
 {
+    // FIXME: This is wrong if the child's writing-mode is different from the parent's.
     IntPoint pointInChildCoordinates(pointInParentCoordinates - child->location());
 
     // If this is an anonymous renderer, we just recur normally
@@ -4282,14 +4283,15 @@ static VisiblePosition positionForPointRespectingEditingBoundaries(RenderBox* pa
     if (!ancestor || ancestor->node()->isContentEditable() == childNode->isContentEditable())
         return child->positionForPoint(pointInChildCoordinates);
 
-    // Otherwise return before or after the child, depending on if the click was left or right of the child
-    int childMidX = child->width() / 2;
-    if (pointInChildCoordinates.x() < childMidX)
+    // Otherwise return before or after the child, depending on if the click was to the logical left or logical right of the child
+    int childMiddle = parent->logicalWidthForChild(child) / 2;
+    int logicalLeft = parent->style()->isHorizontalWritingMode() ? pointInChildCoordinates.x() : pointInChildCoordinates.y();
+    if (logicalLeft < childMiddle)
         return ancestor->createVisiblePosition(childNode->nodeIndex(), DOWNSTREAM);
     return ancestor->createVisiblePosition(childNode->nodeIndex() + 1, UPSTREAM);
 }
 
-VisiblePosition RenderBlock::positionForPointWithInlineChildren(const IntPoint& pointInContents)
+VisiblePosition RenderBlock::positionForPointWithInlineChildren(const IntPoint& pointInLogicalContents)
 {
     ASSERT(childrenInline());
 
@@ -4308,8 +4310,8 @@ VisiblePosition RenderBlock::positionForPointWithInlineChildren(const IntPoint&
         lastRootBoxWithChildren = root;
 
         // check if this root line box is located at this y coordinate
-        if (pointInContents.y() < root->selectionBottom()) {
-            closestBox = root->closestLeafChildForXPos(pointInContents.x());
+        if (pointInLogicalContents.y() < root->selectionBottom()) {
+            closestBox = root->closestLeafChildForLogicalLeftPosition(pointInLogicalContents.x());
             if (closestBox)
                 break;
         }
@@ -4319,17 +4321,22 @@ VisiblePosition RenderBlock::positionForPointWithInlineChildren(const IntPoint&
 
     if (!moveCaretToBoundary && !closestBox && lastRootBoxWithChildren) {
         // y coordinate is below last root line box, pretend we hit it
-        closestBox = lastRootBoxWithChildren->closestLeafChildForXPos(pointInContents.x());
+        closestBox = lastRootBoxWithChildren->closestLeafChildForLogicalLeftPosition(pointInLogicalContents.x());
     }
 
     if (closestBox) {
-        if (moveCaretToBoundary && pointInContents.y() < firstRootBoxWithChildren->selectionTop()) {
+        if (moveCaretToBoundary && pointInLogicalContents.y() < firstRootBoxWithChildren->selectionTop()) {
             // y coordinate is above first root line box, so return the start of the first
             return VisiblePosition(positionForBox(firstRootBoxWithChildren->firstLeafChild(), true), DOWNSTREAM);
         }
 
-        // pass the box a y position that is inside it
-        return closestBox->renderer()->positionForPoint(IntPoint(pointInContents.x(), closestBox->m_y));
+        // pass the box a top position that is inside it
+        IntPoint point(pointInLogicalContents.x(), closestBox->logicalTop());
+        if (!style()->isHorizontalWritingMode())
+            point = point.transposedPoint();
+        if (closestBox->renderer()->isReplaced())
+            return positionForPointRespectingEditingBoundaries(this, toRenderBox(closestBox->renderer()), point);
+        return closestBox->renderer()->positionForPoint(point);
     }
 
     if (lastRootBoxWithChildren) {
@@ -4355,9 +4362,13 @@ VisiblePosition RenderBlock::positionForPoint(const IntPoint& point)
         return RenderBox::positionForPoint(point);
 
     if (isReplaced()) {
-        if (point.y() < 0 || (point.y() < height() && point.x() < 0))
+        // FIXME: This seems wrong when the object's writing-mode doesn't match the line's writing-mode.
+        int pointLogicalLeft = style()->isHorizontalWritingMode() ? point.x() : point.y();
+        int pointLogicalTop = style()->isHorizontalWritingMode() ? point.y() : point.x();
+
+        if (pointLogicalTop < 0 || (pointLogicalTop < logicalHeight() && pointLogicalLeft < 0))
             return createVisiblePosition(caretMinOffset(), DOWNSTREAM);
-        if (point.y() >= height() || (point.y() >= 0 && point.x() >= width()))
+        if (pointLogicalTop >= logicalHeight() || (pointLogicalTop >= 0 && pointLogicalLeft >= logicalWidth()))
             return createVisiblePosition(caretMaxOffset(), DOWNSTREAM);
     } 
 
@@ -4365,11 +4376,14 @@ VisiblePosition RenderBlock::positionForPoint(const IntPoint& point)
     int contentsY = point.y();
     offsetForContents(contentsX, contentsY);
     IntPoint pointInContents(contentsX, contentsY);
+    IntPoint pointInLogicalContents(pointInContents);
+    if (!style()->isHorizontalWritingMode())
+        pointInLogicalContents = pointInLogicalContents.transposedPoint();
 
     if (childrenInline())
-        return positionForPointWithInlineChildren(pointInContents);
+        return positionForPointWithInlineChildren(pointInLogicalContents);
 
-    if (lastChildBox() && contentsY > lastChildBox()->y()) {
+    if (lastChildBox() && pointInContents.y() > lastChildBox()->logicalTop()) {
         for (RenderBox* childBox = lastChildBox(); childBox; childBox = childBox->previousSiblingBox()) {
             if (isChildHitTestCandidate(childBox))
                 return positionForPointRespectingEditingBoundaries(this, childBox, pointInContents);
@@ -4377,7 +4391,7 @@ VisiblePosition RenderBlock::positionForPoint(const IntPoint& point)
     } else {
         for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBox->nextSiblingBox()) {
             // We hit child if our click is above the bottom of its padding box (like IE6/7 and FF3).
-            if (isChildHitTestCandidate(childBox) && contentsY < childBox->frameRect().bottom())
+            if (isChildHitTestCandidate(childBox) && pointInContents.y() < childBox->logicalBottom())
                 return positionForPointRespectingEditingBoundaries(this, childBox, pointInContents);
         }
     }
diff --git a/WebCore/rendering/RenderReplaced.cpp b/WebCore/rendering/RenderReplaced.cpp
index a087038..f0c7e77 100644
--- a/WebCore/rendering/RenderReplaced.cpp
+++ b/WebCore/rendering/RenderReplaced.cpp
@@ -284,17 +284,20 @@ VisiblePosition RenderReplaced::positionForPoint(const IntPoint& point)
 
     RootInlineBox* root = box->root();
 
-    int top = root->lineTop();
-    int bottom = root->nextRootBox() ? root->nextRootBox()->lineTop() : root->lineBottom();
+    int top = root->selectionTop();
+    int bottom = root->selectionBottom();
 
-    if (point.y() + y() < top)
+    int blockDirectionPosition = box->isHorizontal() ? point.y() + y() : point.x() + x();
+    int lineDirectionPosition = box->isHorizontal() ? point.x() + x() : point.y() + y();
+
+    if (blockDirectionPosition < top)
         return createVisiblePosition(caretMinOffset(), DOWNSTREAM); // coordinates are above
     
-    if (point.y() + y() >= bottom)
+    if (blockDirectionPosition >= bottom)
         return createVisiblePosition(caretMaxOffset(), DOWNSTREAM); // coordinates are below
     
     if (node()) {
-        if (point.x() <= width() / 2)
+        if (lineDirectionPosition <= box->logicalWidth() / 2)
             return createVisiblePosition(0, DOWNSTREAM);
         return createVisiblePosition(1, DOWNSTREAM);
     }
@@ -326,25 +329,22 @@ IntRect RenderReplaced::localSelectionRect(bool checkWhetherSelected) const
     if (!m_inlineBoxWrapper)
         // We're a block-level replaced element.  Just return our own dimensions.
         return IntRect(0, 0, width(), height());
-
-    RenderBlock* cb =  containingBlock();
-    if (!cb)
-        return IntRect();
     
     RootInlineBox* root = m_inlineBoxWrapper->root();
-    return IntRect(0, root->selectionTop() - y(), width(), root->selectionHeight());
+    int newLogicalTop = root->block()->style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - root->selectionBottom() : root->selectionTop() - m_inlineBoxWrapper->logicalTop();
+    if (root->block()->style()->isHorizontalWritingMode())
+        return IntRect(0, newLogicalTop, width(), root->selectionHeight());
+    return IntRect(newLogicalTop, 0, root->selectionHeight(), height());
 }
 
 void RenderReplaced::setSelectionState(SelectionState s)
 {
-    RenderBox::setSelectionState(s);
+    RenderBox::setSelectionState(s); // The selection state for our containing block hierarchy is updated by the base class call.
     if (m_inlineBoxWrapper) {
         RootInlineBox* line = m_inlineBoxWrapper->root();
         if (line)
             line->setHasSelectedChildren(isSelected());
     }
-    
-    containingBlock()->setSelectionState(s);
 }
 
 bool RenderReplaced::isSelected() const
diff --git a/WebCore/rendering/RenderReplaced.h b/WebCore/rendering/RenderReplaced.h
index fbc5151..d6ebba6 100644
--- a/WebCore/rendering/RenderReplaced.h
+++ b/WebCore/rendering/RenderReplaced.h
@@ -53,7 +53,7 @@ protected:
 
     virtual void paint(PaintInfo&, int tx, int ty);
     bool shouldPaint(PaintInfo&, int& tx, int& ty);
-    IntRect localSelectionRect(bool checkWhetherSelected = true) const;
+    IntRect localSelectionRect(bool checkWhetherSelected = true) const; // This is in local coordinates, but it's a physical rect (so the top left corner is physical top left).
 
 private:
     virtual const char* renderName() const { return "RenderReplaced"; }
diff --git a/WebCore/rendering/RenderText.cpp b/WebCore/rendering/RenderText.cpp
index aa362b3..89e1e54 100644
--- a/WebCore/rendering/RenderText.cpp
+++ b/WebCore/rendering/RenderText.cpp
@@ -422,13 +422,13 @@ VisiblePosition RenderText::positionForPoint(const IntPoint& point)
     int pointBlockDirection = firstTextBox()->isHorizontal() ? point.y() : point.x();
     
     // FIXME: We should be able to roll these special cases into the general cases in the loop below.
-    if (firstTextBox() && pointBlockDirection <  firstTextBox()->root()->lineBottom() && pointLineDirection < firstTextBox()->logicalLeft()) {
+    if (firstTextBox() && pointBlockDirection <  firstTextBox()->root()->selectionBottom() && pointLineDirection < firstTextBox()->logicalLeft()) {
         // at the y coordinate of the first line or above
         // and the x coordinate is to the left of the first text box left edge
         offset = firstTextBox()->offsetForPosition(pointLineDirection);
         return createVisiblePosition(offset + firstTextBox()->start(), DOWNSTREAM);
     }
-    if (lastTextBox() && pointBlockDirection >= lastTextBox()->root()->lineTop() && pointLineDirection >= lastTextBox()->logicalRight()) {
+    if (lastTextBox() && pointBlockDirection >= lastTextBox()->root()->selectionTop() && pointLineDirection >= lastTextBox()->logicalRight()) {
         // at the y coordinate of the last line or below
         // and the x coordinate is to the right of the last text box right edge
         offset = lastTextBox()->offsetForPosition(pointLineDirection);
@@ -438,7 +438,7 @@ VisiblePosition RenderText::positionForPoint(const IntPoint& point)
     InlineTextBox* lastBoxAbove = 0;
     for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
         if (pointBlockDirection >= box->root()->lineTop()) {
-            int bottom = box->root()->nextRootBox() ? box->root()->nextRootBox()->lineTop() : box->root()->lineBottom();
+            int bottom = box->root()->nextRootBox() ? box->root()->nextRootBox()->selectionTop() : box->root()->selectionBottom();
             if (pointBlockDirection < bottom) {
                 offset = box->offsetForPosition(pointLineDirection);
 
diff --git a/WebCore/rendering/RootInlineBox.cpp b/WebCore/rendering/RootInlineBox.cpp
index 3e5b6c7..2a6706a 100644
--- a/WebCore/rendering/RootInlineBox.cpp
+++ b/WebCore/rendering/RootInlineBox.cpp
@@ -403,7 +403,7 @@ static bool isEditableLeaf(InlineBox* leaf)
     return leaf && leaf->renderer() && leaf->renderer()->node() && leaf->renderer()->node()->isContentEditable();
 }
 
-InlineBox* RootInlineBox::closestLeafChildForXPos(int x, bool onlyEditableLeaves)
+InlineBox* RootInlineBox::closestLeafChildForLogicalLeftPosition(int leftPosition, bool onlyEditableLeaves)
 {
     InlineBox* firstLeaf = firstLeafChild();
     InlineBox* lastLeaf = lastLeafChild();
@@ -411,13 +411,13 @@ InlineBox* RootInlineBox::closestLeafChildForXPos(int x, bool onlyEditableLeaves
         return firstLeaf;
 
     // Avoid returning a list marker when possible.
-    if (x <= firstLeaf->m_x && !firstLeaf->renderer()->isListMarker() && (!onlyEditableLeaves || isEditableLeaf(firstLeaf)))
-        // The x coordinate is less or equal to left edge of the firstLeaf.
+    if (leftPosition <= firstLeaf->logicalLeft() && !firstLeaf->renderer()->isListMarker() && (!onlyEditableLeaves || isEditableLeaf(firstLeaf)))
+        // The leftPosition coordinate is less or equal to left edge of the firstLeaf.
         // Return it.
         return firstLeaf;
 
-    if (x >= lastLeaf->m_x + lastLeaf->m_logicalWidth && !lastLeaf->renderer()->isListMarker() && (!onlyEditableLeaves || isEditableLeaf(lastLeaf)))
-        // The x coordinate is greater or equal to right edge of the lastLeaf.
+    if (leftPosition >= lastLeaf->logicalRight() && !lastLeaf->renderer()->isListMarker() && (!onlyEditableLeaves || isEditableLeaf(lastLeaf)))
+        // The leftPosition coordinate is greater or equal to right edge of the lastLeaf.
         // Return it.
         return lastLeaf;
 
@@ -425,7 +425,7 @@ InlineBox* RootInlineBox::closestLeafChildForXPos(int x, bool onlyEditableLeaves
     for (InlineBox* leaf = firstLeaf; leaf; leaf = leaf->nextLeafChild()) {
         if (!leaf->renderer()->isListMarker() && (!onlyEditableLeaves || isEditableLeaf(leaf))) {
             closestLeaf = leaf;
-            if (x < leaf->m_x + leaf->m_logicalWidth)
+            if (leftPosition < leaf->logicalRight())
                 // The x coordinate is less than the right edge of the box.
                 // Return it.
                 return leaf;
diff --git a/WebCore/rendering/RootInlineBox.h b/WebCore/rendering/RootInlineBox.h
index f13d00f..41ef630 100644
--- a/WebCore/rendering/RootInlineBox.h
+++ b/WebCore/rendering/RootInlineBox.h
@@ -110,7 +110,7 @@ public:
 
     RenderBlock* block() const;
 
-    InlineBox* closestLeafChildForXPos(int x, bool onlyEditableLeaves = false);
+    InlineBox* closestLeafChildForLogicalLeftPosition(int, bool onlyEditableLeaves = false);
 
     Vector<RenderBox*>& floats()
     {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list