Diff
Modified: branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog (179070 => 179071)
--- branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog 2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog 2015-01-24 20:16:36 UTC (rev 179071)
@@ -1,5 +1,21 @@
2015-01-24 David Kilzer <[email protected]>
+ Merge r176262.
+
+ 2014-11-17 David Hyatt <[email protected]>
+
+ Improve Ruby selection (getting rid of overlap and improving gap filling)
+ https://bugs.webkit.org/show_bug.cgi?id=138250
+
+ Reviewed by Dean Jackson.
+
+ Added fast/repaint/selection-ruby-rl.html
+
+ * fast/repaint/selection-ruby-rl-expected.txt: Added.
+ * fast/repaint/selection-ruby-rl.html: Added.
+
+2015-01-24 David Kilzer <[email protected]>
+
Merge r174860.
2014-10-18 Chris Fleizach <[email protected]>
Added: branches/safari-600.1.4.15-branch/LayoutTests/fast/repaint/selection-ruby-rl-expected.txt (0 => 179071)
--- branches/safari-600.1.4.15-branch/LayoutTests/fast/repaint/selection-ruby-rl-expected.txt (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/fast/repaint/selection-ruby-rl-expected.txt 2015-01-24 20:16:36 UTC (rev 179071)
@@ -0,0 +1,14 @@
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.Some ruby
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.
+(repaint rects
+ (rect 774 39 18 83)
+)
+
Added: branches/safari-600.1.4.15-branch/LayoutTests/fast/repaint/selection-ruby-rl.html (0 => 179071)
--- branches/safari-600.1.4.15-branch/LayoutTests/fast/repaint/selection-ruby-rl.html (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/fast/repaint/selection-ruby-rl.html 2015-01-24 20:16:36 UTC (rev 179071)
@@ -0,0 +1,29 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+<script>
+function repaintTest() {
+ if (eventSender) {
+ eventSender.mouseMoveTo(790, 40);
+ eventSender.mouseDown();
+ eventSender.mouseMoveTo(790, 40);
+ eventSender.mouseMoveTo(790, 120);
+ eventSender.mouseUp();
+ }
+}
+</script>
+
+</head>
+<body style="-webkit-writing-mode:vertical-rl" _onload_="runRepaintTest()">
+<span>Testing both hit testing</span> and painting of selection.<br>
+Testing both hit testing and painting of selection.<br>
+<ruby>Testing both hit testing and painting of selection.<rt>Some ruby</rt></ruby><br>
+Testing both hit testing and painting of selection.<br>
+Testing both hit testing and painting of selection.<br>
+Testing both hit testing and painting of selection.<br>
+Testing both hit testing and painting of selection.<br>
+Testing both hit testing and painting of selection.<br>
+Testing both hit testing and painting of selection.<br>
+Testing both hit testing and painting of selection.<br>
+</body>
Modified: branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog (179070 => 179071)
--- branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog 2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog 2015-01-24 20:16:36 UTC (rev 179071)
@@ -1,5 +1,40 @@
2015-01-24 David Kilzer <[email protected]>
+ Merge r176262.
+
+ 2014-11-17 David Hyatt <[email protected]>
+
+ Improve Ruby selection (getting rid of overlap and improving gap filling)
+ https://bugs.webkit.org/show_bug.cgi?id=138250
+
+ Reviewed by Dean Jackson.
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::selectionGaps):
+ (WebCore::RenderBlock::blockSelectionGaps):
+ Add Ruby text in along with the Ruby base.
+
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::inlineSelectionGaps):
+ Don't let block gaps get filled in here.
+
+ * rendering/RenderRubyBase.h:
+ Expose accessor to the ruby run.
+
+ * rendering/RenderRubyText.cpp:
+ (WebCore::RenderRubyText::rubyRun):
+ * rendering/RenderRubyText.h:
+ Add accessor to the ruby run.
+
+ * rendering/RootInlineBox.cpp:
+ (WebCore::RootInlineBox::selectionTop):
+ (WebCore::RootInlineBox::selectionBottom):
+ Improve selectionTop and selectionBottom of ruby bases to avoid the
+ ruby text. Improve the selectionTop and selectionBottom of ruby texts
+ to fill the gap up to the previous/next line as appropriate.
+
+2015-01-24 David Kilzer <[email protected]>
+
Merge r175260.
2014-10-28 David Hyatt <[email protected]>
Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlock.cpp (179070 => 179071)
--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlock.cpp 2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlock.cpp 2015-01-24 20:16:36 UTC (rev 179071)
@@ -1965,7 +1965,7 @@
result = blockSelectionGaps(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, cache, paintInfo);
// Go ahead and fill the vertical gap all the way to the bottom of our block if the selection extends past our block.
- if (&rootBlock == this && (selectionState() != SelectionBoth && selectionState() != SelectionEnd) && !isRubyBase()) {
+ if (&rootBlock == this && (selectionState() != SelectionBoth && selectionState() != SelectionEnd) && !isRubyBase() && !isRubyText()) {
result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock,
lastLogicalTop, lastLogicalLeft, lastLogicalRight, logicalHeight(), cache, paintInfo));
}
@@ -2010,7 +2010,7 @@
}
bool paintsOwnSelection = curr->shouldPaintSelectionGaps() || curr->isTable(); // FIXME: Eventually we won't special-case table like this.
- bool fillBlockGaps = !isRubyBase() && (paintsOwnSelection || (curr->canBeSelectionLeaf() && childState != SelectionNone));
+ bool fillBlockGaps = (paintsOwnSelection || (curr->canBeSelectionLeaf() && childState != SelectionNone)) && !isRubyBase() && !isRubyText();
if (fillBlockGaps) {
// We need to fill the vertical gap above this object.
if (childState == SelectionEnd || childState == SelectionInside) {
Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlockFlow.cpp (179070 => 179071)
--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlockFlow.cpp 2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlockFlow.cpp 2015-01-24 20:16:36 UTC (rev 179071)
@@ -3003,7 +3003,7 @@
LayoutUnit selHeight = curr->selectionHeightAdjustedForPrecedingBlock();
if (!containsStart && !lastSelectedLine &&
- selectionState() != SelectionStart && selectionState() != SelectionBoth)
+ selectionState() != SelectionStart && selectionState() != SelectionBoth && !isRubyBase())
result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, selTop, cache, paintInfo));
LayoutRect logicalRect(curr->logicalLeft(), selTop, curr->logicalWidth(), selTop + selHeight);
Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyBase.h (179070 => 179071)
--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyBase.h 2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyBase.h 2015-01-24 20:16:36 UTC (rev 179071)
@@ -46,6 +46,8 @@
virtual bool isRubyBase() const { return true; }
+ RenderRubyRun* rubyRun() const;
+
private:
virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const;
virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const;
@@ -56,12 +58,12 @@
void moveInlineChildren(RenderRubyBase* toBase, RenderObject* beforeChild = 0);
void moveBlockChildren(RenderRubyBase* toBase, RenderObject* beforeChild = 0);
- RenderRubyRun* rubyRun() const;
-
// Allow RenderRubyRun to manipulate the children within ruby bases.
friend class RenderRubyRun;
};
+RENDER_OBJECT_TYPE_CASTS(RenderRubyBase, isRubyBase())
+
} // namespace WebCore
#endif // RenderRubyBase_h
Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.cpp (179070 => 179071)
--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.cpp 2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.cpp 2015-01-24 20:16:36 UTC (rev 179071)
@@ -32,6 +32,7 @@
#include "config.h"
#include "RenderRubyText.h"
+#include "RenderRubyRun.h"
namespace WebCore {
@@ -44,6 +45,12 @@
{
}
+RenderRubyRun* RenderRubyText::rubyRun() const
+{
+ ASSERT(parent());
+ return toRenderRubyRun(parent());
+}
+
bool RenderRubyText::isChildAllowed(const RenderObject& child, const RenderStyle&) const
{
return child.isInline();
Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.h (179070 => 179071)
--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.h 2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.h 2015-01-24 20:16:36 UTC (rev 179071)
@@ -43,6 +43,8 @@
Element& element() const { return toElement(nodeForNonAnonymous()); }
virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const override;
+
+ RenderRubyRun* rubyRun() const;
private:
virtual const char* renderName() const override { return "RenderRubyText"; }
@@ -54,6 +56,8 @@
virtual void adjustInlineDirectionLineBounds(int expansionOpportunityCount, float& logicalLeft, float& logicalWidth) const override;
};
+RENDER_OBJECT_TYPE_CASTS(RenderRubyText, isRubyText())
+
} // namespace WebCore
#endif // RenderRubyText_h
Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RootInlineBox.cpp (179070 => 179071)
--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RootInlineBox.cpp 2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RootInlineBox.cpp 2015-01-24 20:16:36 UTC (rev 179071)
@@ -33,6 +33,9 @@
#include "Page.h"
#include "PaintInfo.h"
#include "RenderFlowThread.h"
+#include "RenderRubyBase.h"
+#include "RenderRubyRun.h"
+#include "RenderRubyText.h"
#include "RenderView.h"
#include "VerticalPositionCache.h"
#include <wtf/NeverDestroyed.h>
@@ -596,13 +599,41 @@
LayoutUnit RootInlineBox::selectionTop() const
{
LayoutUnit selectionTop = m_lineTop;
-
+
if (m_hasAnnotationsBefore)
selectionTop -= !renderer().style().isFlippedLinesWritingMode() ? computeOverAnnotationAdjustment(m_lineTop) : computeUnderAnnotationAdjustment(m_lineTop);
if (renderer().style().isFlippedLinesWritingMode())
return selectionTop;
+ if (renderer().isRubyBase()) {
+ // The ruby base selection should avoid intruding into the ruby text. This is only the case if there is an actual ruby text above us.
+ RenderRubyBase* base = &toRenderRubyBase(renderer());
+ RenderRubyRun* run = base->rubyRun();
+ if (run) {
+ RenderRubyText* text = run->rubyText();
+ if (text && text->logicalTop() < base->logicalTop()) {
+ // The ruby text is above the ruby base. Just return now in order to avoid painting on top of the ruby text.
+ return selectionTop;
+ }
+ }
+ } else if (renderer().isRubyText()) {
+ // The ruby text selection should go all the way to the selection top of the containing line.
+ RenderRubyText* text = &toRenderRubyText(renderer());
+ RenderRubyRun* run = text->rubyRun();
+ if (run && run->inlineBoxWrapper()) {
+ RenderRubyBase* base = run->rubyBase();
+ if (base && text->logicalTop() < base->logicalTop()) {
+ // The ruby text is above the ruby base.
+ const RootInlineBox& containingLine = run->inlineBoxWrapper()->root();
+ LayoutUnit enclosingSelectionTop = containingLine.selectionTop();
+ LayoutUnit deltaBetweenObjects = text->logicalTop() + run->logicalTop();
+ LayoutUnit selectionTopInRubyTextCoords = enclosingSelectionTop - deltaBetweenObjects;
+ return std::min(selectionTop, selectionTopInRubyTextCoords);
+ }
+ }
+ }
+
LayoutUnit prevBottom = prevRootBox() ? prevRootBox()->selectionBottom() : blockFlow().borderAndPaddingBefore();
if (prevBottom < selectionTop && blockFlow().containsFloats()) {
// This line has actually been moved further down, probably from a large line-height, but possibly because the
@@ -651,9 +682,37 @@
if (m_hasAnnotationsAfter)
selectionBottom += !renderer().style().isFlippedLinesWritingMode() ? computeUnderAnnotationAdjustment(m_lineBottom) : computeOverAnnotationAdjustment(m_lineBottom);
-
+
if (!renderer().style().isFlippedLinesWritingMode() || !nextRootBox())
return selectionBottom;
+
+ if (renderer().isRubyBase()) {
+ // The ruby base selection should avoid intruding into the ruby text. This is only the case if there is an actual ruby text below us.
+ RenderRubyBase* base = &toRenderRubyBase(renderer());
+ RenderRubyRun* run = base->rubyRun();
+ if (run) {
+ RenderRubyText* text = run->rubyText();
+ if (text && text->logicalTop() > base->logicalTop()) {
+ // The ruby text is below the ruby base. Just return now in order to avoid painting on top of the ruby text.
+ return selectionBottom;
+ }
+ }
+ } else if (renderer().isRubyText()) {
+ // The ruby text selection should go all the way to the selection bottom of the containing line.
+ RenderRubyText* text = &toRenderRubyText(renderer());
+ RenderRubyRun* run = text->rubyRun();
+ if (run && run->inlineBoxWrapper()) {
+ RenderRubyBase* base = run->rubyBase();
+ if (base && text->logicalTop() > base->logicalTop()) {
+ // The ruby text is above the ruby base.
+ const RootInlineBox& containingLine = run->inlineBoxWrapper()->root();
+ LayoutUnit enclosingSelectionBottom = containingLine.selectionBottom();
+ LayoutUnit deltaBetweenObjects = text->logicalTop() + run->logicalTop();
+ LayoutUnit selectionBottomInRubyTextCoords = enclosingSelectionBottom - deltaBetweenObjects;
+ return std::min(selectionBottom, selectionBottomInRubyTextCoords);
+ }
+ }
+ }
LayoutUnit nextTop = nextRootBox()->selectionTop();
if (nextTop > selectionBottom && blockFlow().containsFloats()) {