Native text selection UI is incorrectly suppressed in Microsoft Visio
[WebKit-https.git] / Source / WebCore / rendering / InlineElementBox.cpp
index 2126128..b0d6c23 100644 (file)
 #include "config.h"
 #include "InlineElementBox.h"
 
+#include "InlineFlowBox.h"
 #include "PaintInfo.h"
 #include "RenderBlock.h"
 #include "RenderBox.h"
 #include "RenderLineBreak.h"
+#include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {
 
+WTF_MAKE_ISO_ALLOCATED_IMPL(InlineElementBox);
+
 void InlineElementBox::deleteLine()
 {
     if (!extracted()) {
-        if (renderer().isBox())
-            toRenderBox(renderer()).setInlineBoxWrapper(nullptr);
-        else if (renderer().isLineBreak())
-            toRenderLineBreak(renderer()).setInlineBoxWrapper(nullptr);
+        if (is<RenderBox>(renderer()))
+            downcast<RenderBox>(renderer()).setInlineBoxWrapper(nullptr);
+        else if (is<RenderLineBreak>(renderer()))
+            downcast<RenderLineBreak>(renderer()).setInlineBoxWrapper(nullptr);
     }
     delete this;
 }
@@ -47,59 +51,47 @@ void InlineElementBox::deleteLine()
 void InlineElementBox::extractLine()
 {
     setExtracted(true);
-    if (renderer().isBox())
-        toRenderBox(renderer()).setInlineBoxWrapper(nullptr);
-    else if (renderer().isLineBreak())
-        toRenderLineBreak(renderer()).setInlineBoxWrapper(nullptr);
+    if (is<RenderBox>(renderer()))
+        downcast<RenderBox>(renderer()).setInlineBoxWrapper(nullptr);
+    else if (is<RenderLineBreak>(renderer()))
+        downcast<RenderLineBreak>(renderer()).setInlineBoxWrapper(nullptr);
 }
 
 void InlineElementBox::attachLine()
 {
     setExtracted(false);
-    if (renderer().isBox())
-        toRenderBox(renderer()).setInlineBoxWrapper(this);
-    else if (renderer().isLineBreak())
-        toRenderLineBreak(renderer()).setInlineBoxWrapper(this);
+    if (is<RenderBox>(renderer()))
+        downcast<RenderBox>(renderer()).setInlineBoxWrapper(this);
+    else if (is<RenderLineBreak>(renderer()))
+        downcast<RenderLineBreak>(renderer()).setInlineBoxWrapper(this);
 }
 
 void InlineElementBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/)
 {
-    if (!paintInfo.shouldPaintWithinRoot(renderer()) || (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection))
+    if (!paintInfo.shouldPaintWithinRoot(renderer()))
+        return;
+
+    if (paintInfo.phase != PaintPhase::Foreground && paintInfo.phase != PaintPhase::Selection)
         return;
 
     LayoutPoint childPoint = paintOffset;
-    if (renderer().isBox() && parent()->renderer().style().isFlippedBlocksWritingMode()) // Faster than calling containingBlock().
-        childPoint = renderer().containingBlock()->flipForWritingModeForChild(&toRenderBox(renderer()), childPoint);
+    if (is<RenderBox>(renderer()) && parent()->renderer().style().isFlippedBlocksWritingMode()) // Faster than calling containingBlock().
+        childPoint = renderer().containingBlock()->flipForWritingModeForChild(&downcast<RenderBox>(renderer()), childPoint);
 
-    // 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, childPoint);
-    if (!preservePhase) {
-        info.phase = PaintPhaseChildBlockBackgrounds;
-        renderer().paint(info, childPoint);
-        info.phase = PaintPhaseFloat;
-        renderer().paint(info, childPoint);
-        info.phase = PaintPhaseForeground;
-        renderer().paint(info, childPoint);
-        info.phase = PaintPhaseOutline;
-        renderer().paint(info, childPoint);
-    }
+    renderer().paintAsInlineBlock(paintInfo, childPoint);
 }
 
-bool InlineElementBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/)
+bool InlineElementBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/,
+    HitTestAction)
 {
     // Hit test 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.)
     LayoutPoint childPoint = accumulatedOffset;
-    if (renderer().isBox() && parent()->renderer().style().isFlippedBlocksWritingMode()) // Faster than calling containingBlock().
-        childPoint = renderer().containingBlock()->flipForWritingModeForChild(&toRenderBox(renderer()), childPoint);
+    if (is<RenderBox>(renderer()) && parent()->renderer().style().isFlippedBlocksWritingMode()) // Faster than calling containingBlock().
+        childPoint = renderer().containingBlock()->flipForWritingModeForChild(&downcast<RenderBox>(renderer()), childPoint);
 
     return renderer().hitTest(request, result, locationInContainer, childPoint);
 }
 
-}
\ No newline at end of file
+}