Title: [208398] trunk/Source/WebCore
Revision
208398
Author
[email protected]
Date
2016-11-04 14:04:28 -0700 (Fri, 04 Nov 2016)

Log Message

Apply post-landing review comments for r208347

* dom/Element.cpp:
(WebCore::Element::findAnchorElementForLink):
Use attributeWithoutSynchronization.

* page/PrintContext.cpp:
(WebCore::PrintContext::spoolPage):
(WebCore::PrintContext::spoolRect):
(WebCore::PrintContext::collectLinkedDestinations):
(WebCore::PrintContext::outputLinkedDestinations):
* page/PrintContext.h:
Pass Document by reference instead of Node by pointer,
use ElementTraversal instead of NodeTraversal to avoid
having to locally check the type, and null-check renderers.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (208397 => 208398)


--- trunk/Source/WebCore/ChangeLog	2016-11-04 20:48:18 UTC (rev 208397)
+++ trunk/Source/WebCore/ChangeLog	2016-11-04 21:04:28 UTC (rev 208398)
@@ -1,3 +1,21 @@
+2016-11-04  Tim Horton  <[email protected]>
+
+        Apply post-landing review comments for r208347
+
+        * dom/Element.cpp:
+        (WebCore::Element::findAnchorElementForLink):
+        Use attributeWithoutSynchronization.
+
+        * page/PrintContext.cpp:
+        (WebCore::PrintContext::spoolPage):
+        (WebCore::PrintContext::spoolRect):
+        (WebCore::PrintContext::collectLinkedDestinations):
+        (WebCore::PrintContext::outputLinkedDestinations):
+        * page/PrintContext.h:
+        Pass Document by reference instead of Node by pointer,
+        use ElementTraversal instead of NodeTraversal to avoid
+        having to locally check the type, and null-check renderers.
+
 2016-11-04  Myles C. Maxfield  <[email protected]>
 
         Implement WebGL2RenderingContext::copyBufferSubData()

Modified: trunk/Source/WebCore/dom/Element.cpp (208397 => 208398)


--- trunk/Source/WebCore/dom/Element.cpp	2016-11-04 20:48:18 UTC (rev 208397)
+++ trunk/Source/WebCore/dom/Element.cpp	2016-11-04 21:04:28 UTC (rev 208398)
@@ -3749,7 +3749,7 @@
     if (!isLink())
         return nullptr;
 
-    const AtomicString& href = ""
+    const AtomicString& href = ""
     if (href.isNull())
         return nullptr;
 

Modified: trunk/Source/WebCore/page/PrintContext.cpp (208397 => 208398)


--- trunk/Source/WebCore/page/PrintContext.cpp	2016-11-04 20:48:18 UTC (rev 208397)
+++ trunk/Source/WebCore/page/PrintContext.cpp	2016-11-04 21:04:28 UTC (rev 208398)
@@ -21,11 +21,11 @@
 #include "config.h"
 #include "PrintContext.h"
 
+#include "ElementTraversal.h"
 #include "GraphicsContext.h"
 #include "Frame.h"
 #include "FrameView.h"
 #include "HTMLNames.h"
-#include "NodeTraversal.h"
 #include "RenderView.h"
 #include "StyleInheritedData.h"
 #include "StyleResolver.h"
@@ -191,7 +191,7 @@
     ctx.translate(-pageRect.x(), -pageRect.y());
     ctx.clip(pageRect);
     m_frame->view()->paintContents(ctx, pageRect);
-    outputLinkedDestinations(ctx, m_frame->document(), pageRect);
+    outputLinkedDestinations(ctx, *m_frame->document(), pageRect);
     ctx.restore();
 }
 
@@ -202,7 +202,7 @@
     ctx.translate(-rect.x(), -rect.y());
     ctx.clip(rect);
     m_frame->view()->paintContents(ctx, rect);
-    outputLinkedDestinations(ctx, m_frame->document(), rect);
+    outputLinkedDestinations(ctx, *m_frame->document(), rect);
     ctx.restore();
 }
 
@@ -250,19 +250,16 @@
     return -1;
 }
 
-void PrintContext::collectLinkedDestinations(Node& node)
+void PrintContext::collectLinkedDestinations(Document& document)
 {
-    for (Node* child = &node; child; child = NodeTraversal::next(*child)) {
-        if (!is<Element>(child))
-            continue;
-
+    for (Element* child = document.documentElement(); child; child = ElementTraversal::next(*child)) {
         String outAnchorName;
-        if (Element* element = downcast<Element>(child)->findAnchorElementForLink(outAnchorName))
-            m_linkedDestinations->set(outAnchorName, *element);
+        if (Element* element = child->findAnchorElementForLink(outAnchorName))
+            m_linkedDestinations->add(outAnchorName, *element);
     }
 }
 
-void PrintContext::outputLinkedDestinations(GraphicsContext& graphicsContext, Node* node, const IntRect& pageRect)
+void PrintContext::outputLinkedDestinations(GraphicsContext& graphicsContext, Document& document, const IntRect& pageRect)
 {
     if (!graphicsContext.supportsInternalLinks())
         return;
@@ -269,11 +266,15 @@
 
     if (!m_linkedDestinations) {
         m_linkedDestinations = std::make_unique<HashMap<String, Ref<Element>>>();
-        collectLinkedDestinations(*node);
+        collectLinkedDestinations(document);
     }
 
     for (const auto& it : *m_linkedDestinations) {
-        FloatPoint point = it.value->renderer()->anchorRect().minXMinYCorner();
+        RenderElement* renderer = it.value->renderer();
+        if (!renderer)
+            continue;
+
+        FloatPoint point = renderer->anchorRect().minXMinYCorner();
         point.expandedTo(FloatPoint());
 
         if (!pageRect.contains(roundedIntPoint(point)))

Modified: trunk/Source/WebCore/page/PrintContext.h (208397 => 208398)


--- trunk/Source/WebCore/page/PrintContext.h	2016-11-04 20:48:18 UTC (rev 208397)
+++ trunk/Source/WebCore/page/PrintContext.h	2016-11-04 21:04:28 UTC (rev 208398)
@@ -27,6 +27,7 @@
 
 namespace WebCore {
 
+class Document;
 class Element;
 class Frame;
 class FloatRect;
@@ -101,8 +102,8 @@
 private:
     void computePageRectsWithPageSizeInternal(const FloatSize& pageSizeInPixels, bool allowHorizontalTiling);
     bool beginAndComputePageRectsWithPageSize(Frame&, const FloatSize& pageSizeInPixels);
-    void collectLinkedDestinations(Node&);
-    void outputLinkedDestinations(GraphicsContext&, Node*, const IntRect& pageRect);
+    void collectLinkedDestinations(Document&);
+    void outputLinkedDestinations(GraphicsContext&, Document&, const IntRect& pageRect);
 
     // Used to prevent misuses of begin() and end() (e.g., call end without begin).
     bool m_isPrinting { false };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to