Clean up the difference between painting focus rings and adding PDF annotations
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 May 2014 20:03:13 +0000 (20:03 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 May 2014 20:03:13 +0000 (20:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132638

Follow-up comments from Darin Adler.

* rendering/RenderInline.cpp:
(WebCore::RenderInline::paintOutline): Move "else if" to a separate "if" for clarity.
* rendering/RenderObject.cpp:
(WebCore::RenderObject::paintFocusRing): Don't guard against outlineIsAuto(). ASSERT instead.
(WebCore::RenderObject::addPDFURLRect): Give "rect" variable a better name.
(WebCore::RenderObject::paintOutline): Move "else if" to a separate "if" for clarity.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168437 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderObject.cpp

index 31918f0..1226a14 100644 (file)
@@ -1,3 +1,17 @@
+2014-05-07  Dean Jackson  <dino@apple.com>
+
+        Clean up the difference between painting focus rings and adding PDF annotations
+        https://bugs.webkit.org/show_bug.cgi?id=132638
+
+        Follow-up comments from Darin Adler.
+
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::paintOutline): Move "else if" to a separate "if" for clarity.
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::paintFocusRing): Don't guard against outlineIsAuto(). ASSERT instead.
+        (WebCore::RenderObject::addPDFURLRect): Give "rect" variable a better name.
+        (WebCore::RenderObject::paintOutline): Move "else if" to a separate "if" for clarity.
+
 2014-05-07  Alexey Proskuryakov  <ap@apple.com>
 
         Make blob size computation lazy
 2014-05-07  Alexey Proskuryakov  <ap@apple.com>
 
         Make blob size computation lazy
index 0867fd1..843e177 100644 (file)
@@ -1490,12 +1490,13 @@ void RenderInline::paintOutline(PaintInfo& paintInfo, const LayoutPoint& paintOf
 {
     if (!hasOutline())
         return;
 {
     if (!hasOutline())
         return;
-    
+
     RenderStyle& styleToUse = style();
     // Only paint the focus ring by hand if the theme isn't able to draw it.
     if (styleToUse.outlineStyleIsAuto() && !theme().supportsFocusRing(&styleToUse))
         paintFocusRing(paintInfo, paintOffset, &styleToUse);
     RenderStyle& styleToUse = style();
     // Only paint the focus ring by hand if the theme isn't able to draw it.
     if (styleToUse.outlineStyleIsAuto() && !theme().supportsFocusRing(&styleToUse))
         paintFocusRing(paintInfo, paintOffset, &styleToUse);
-    else if (hasOutlineAnnotation() && !theme().supportsFocusRing(&styleToUse))
+
+    if (hasOutlineAnnotation() && !styleToUse.outlineStyleIsAuto() && !theme().supportsFocusRing(&styleToUse))
         addPDFURLRect(paintInfo, paintOffset);
 
     GraphicsContext* graphicsContext = paintInfo.context;
         addPDFURLRect(paintInfo, paintOffset);
 
     GraphicsContext* graphicsContext = paintInfo.context;
index 7e6b5fe..8a3fa3e 100644 (file)
@@ -999,27 +999,27 @@ void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, float x1
 
 void RenderObject::paintFocusRing(PaintInfo& paintInfo, const LayoutPoint& paintOffset, RenderStyle* style)
 {
 
 void RenderObject::paintFocusRing(PaintInfo& paintInfo, const LayoutPoint& paintOffset, RenderStyle* style)
 {
-    if (style->outlineStyleIsAuto()) {
-        Vector<IntRect> focusRingRects;
-        addFocusRingRects(focusRingRects, paintOffset, paintInfo.paintContainer);
+    ASSERT(style->outlineStyleIsAuto());
+
+    Vector<IntRect> focusRingRects;
+    addFocusRingRects(focusRingRects, paintOffset, paintInfo.paintContainer);
 #if PLATFORM(MAC)
 #if PLATFORM(MAC)
-        bool needsRepaint;
-        paintInfo.context->drawFocusRing(focusRingRects, style->outlineWidth(), style->outlineOffset(), document().page()->focusController().timeSinceFocusWasSet(), needsRepaint);
-        if (needsRepaint)
-            document().page()->focusController().setFocusedElementNeedsRepaint();
+    bool needsRepaint;
+    paintInfo.context->drawFocusRing(focusRingRects, style->outlineWidth(), style->outlineOffset(), document().page()->focusController().timeSinceFocusWasSet(), needsRepaint);
+    if (needsRepaint)
+        document().page()->focusController().setFocusedElementNeedsRepaint();
 #else
 #else
-        paintInfo.context->drawFocusRing(focusRingRects, style->outlineWidth(), style->outlineOffset(), style->visitedDependentColor(CSSPropertyOutlineColor));
+    paintInfo.context->drawFocusRing(focusRingRects, style->outlineWidth(), style->outlineOffset(), style->visitedDependentColor(CSSPropertyOutlineColor));
 #endif
 #endif
-    }
 }
 
 void RenderObject::addPDFURLRect(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
     Vector<IntRect> focusRingRects;
     addFocusRingRects(focusRingRects, paintOffset, paintInfo.paintContainer);
 }
 
 void RenderObject::addPDFURLRect(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
     Vector<IntRect> focusRingRects;
     addFocusRingRects(focusRingRects, paintOffset, paintInfo.paintContainer);
-    IntRect rect = unionRect(focusRingRects);
+    IntRect urlRect = unionRect(focusRingRects);
 
 
-    if (rect.isEmpty())
+    if (urlRect.isEmpty())
         return;
     Node* n = node();
     if (!n || !n->isLink() || !n->isElementNode())
         return;
     Node* n = node();
     if (!n || !n->isLink() || !n->isElementNode())
@@ -1027,7 +1027,7 @@ void RenderObject::addPDFURLRect(PaintInfo& paintInfo, const LayoutPoint& paintO
     const AtomicString& href = toElement(n)->getAttribute(hrefAttr);
     if (href.isNull())
         return;
     const AtomicString& href = toElement(n)->getAttribute(hrefAttr);
     if (href.isNull())
         return;
-    paintInfo.context->setURLForRect(n->document().completeURL(href), pixelSnappedIntRect(rect));
+    paintInfo.context->setURLForRect(n->document().completeURL(href), pixelSnappedIntRect(urlRect));
 }
 
 void RenderObject::paintOutline(PaintInfo& paintInfo, const LayoutRect& paintRect)
 }
 
 void RenderObject::paintOutline(PaintInfo& paintInfo, const LayoutRect& paintRect)
@@ -1043,7 +1043,8 @@ void RenderObject::paintOutline(PaintInfo& paintInfo, const LayoutRect& paintRec
     // Only paint the focus ring by hand if the theme isn't able to draw it.
     if (styleToUse.outlineStyleIsAuto() && !theme().supportsFocusRing(&styleToUse))
         paintFocusRing(paintInfo, paintRect.location(), &styleToUse);
     // Only paint the focus ring by hand if the theme isn't able to draw it.
     if (styleToUse.outlineStyleIsAuto() && !theme().supportsFocusRing(&styleToUse))
         paintFocusRing(paintInfo, paintRect.location(), &styleToUse);
-    else if (hasOutlineAnnotation() && !theme().supportsFocusRing(&styleToUse))
+
+    if (hasOutlineAnnotation() && !styleToUse.outlineStyleIsAuto() && !theme().supportsFocusRing(&styleToUse))
         addPDFURLRect(paintInfo, paintRect.location());
 
     if (styleToUse.outlineStyleIsAuto() || styleToUse.outlineStyle() == BNONE)
         addPDFURLRect(paintInfo, paintRect.location());
 
     if (styleToUse.outlineStyleIsAuto() || styleToUse.outlineStyle() == BNONE)