<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[173528] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/173528">173528</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2014-09-11 12:26:16 -0700 (Thu, 11 Sep 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use tighter typing for Document::ownerElement() return value
https://bugs.webkit.org/show_bug.cgi?id=136746

Reviewed by Ryosuke Niwa.

Use tighter typing for Document::ownerElement() return value at call
sites to increase code readability a bit and allow the compiler to
generate slightly more efficient code in some cases. In particular,
the more efficient HTMLElement::hasTagName(HTMLQualifiedName) is
now called in several cases instead of the one on Node. This bypasses
unnecessary isHTMLElement() checks.

No new tests, no behavior change.

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::alternativeTextForWebArea):
* dom/Document.cpp:
(WebCore::Document::updateLayout):
(WebCore::Document::topDocument):
* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::insertedInto):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollRectToVisible):
* rendering/RenderView.cpp:
(WebCore::RenderView::paintBoxDecorations):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAccessibilityNodeObjectcpp">trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLBodyElementcpp">trunk/Source/WebCore/html/HTMLBodyElement.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxModelObjectcpp">trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayercpp">trunk/Source/WebCore/rendering/RenderLayer.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderViewcpp">trunk/Source/WebCore/rendering/RenderView.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (173527 => 173528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-09-11 19:22:06 UTC (rev 173527)
+++ trunk/Source/WebCore/ChangeLog        2014-09-11 19:26:16 UTC (rev 173528)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2014-09-11  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Use tighter typing for Document::ownerElement() return value
+        https://bugs.webkit.org/show_bug.cgi?id=136746
+
+        Reviewed by Ryosuke Niwa.
+
+        Use tighter typing for Document::ownerElement() return value at call
+        sites to increase code readability a bit and allow the compiler to
+        generate slightly more efficient code in some cases. In particular,
+        the more efficient HTMLElement::hasTagName(HTMLQualifiedName) is
+        now called in several cases instead of the one on Node. This bypasses
+        unnecessary isHTMLElement() checks.
+
+        No new tests, no behavior change.
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::alternativeTextForWebArea):
+        * dom/Document.cpp:
+        (WebCore::Document::updateLayout):
+        (WebCore::Document::topDocument):
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::insertedInto):
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollRectToVisible):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::paintBoxDecorations):
+
</ins><span class="cx"> 2014-09-10  Roger Fong  &lt;roger_fong@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Check for varying packing restrictions per program instead of per shader.
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAccessibilityNodeObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (173527 => 173528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp        2014-09-11 19:22:06 UTC (rev 173527)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp        2014-09-11 19:26:16 UTC (rev 173528)
</span><span class="lines">@@ -1461,25 +1461,21 @@
</span><span class="cx">             return ariaLabel;
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    Node* owner = document-&gt;ownerElement();
-    if (owner) {
</del><ins>+    if (HTMLFrameOwnerElement* owner = document-&gt;ownerElement()) {
</ins><span class="cx">         if (owner-&gt;hasTagName(frameTag) || owner-&gt;hasTagName(iframeTag)) {
</span><del>-            const AtomicString&amp; title = toElement(owner)-&gt;getAttribute(titleAttr);
</del><ins>+            const AtomicString&amp; title = owner-&gt;getAttribute(titleAttr);
</ins><span class="cx">             if (!title.isEmpty())
</span><span class="cx">                 return title;
</span><del>-            return toElement(owner)-&gt;getNameAttribute();
</del><span class="cx">         }
</span><del>-        if (owner-&gt;isHTMLElement())
-            return toHTMLElement(owner)-&gt;getNameAttribute();
</del><ins>+        return owner-&gt;getNameAttribute();
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     String documentTitle = document-&gt;title();
</span><span class="cx">     if (!documentTitle.isEmpty())
</span><span class="cx">         return documentTitle;
</span><span class="cx">     
</span><del>-    owner = document-&gt;body();
-    if (owner &amp;&amp; owner-&gt;isHTMLElement())
-        return toHTMLElement(owner)-&gt;getNameAttribute();
</del><ins>+    if (HTMLElement* body = document-&gt;body())
+        return body-&gt;getNameAttribute();
</ins><span class="cx">     
</span><span class="cx">     return String();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (173527 => 173528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2014-09-11 19:22:06 UTC (rev 173527)
+++ trunk/Source/WebCore/dom/Document.cpp        2014-09-11 19:26:16 UTC (rev 173528)
</span><span class="lines">@@ -1808,8 +1808,8 @@
</span><span class="cx"> 
</span><span class="cx">     RenderView::RepaintRegionAccumulator repaintRegionAccumulator(renderView());
</span><span class="cx"> 
</span><del>-    if (Element* oe = ownerElement())
-        oe-&gt;document().updateLayout();
</del><ins>+    if (HTMLFrameOwnerElement* owner = ownerElement())
+        owner-&gt;document().updateLayout();
</ins><span class="cx"> 
</span><span class="cx">     updateStyleIfNeeded();
</span><span class="cx"> 
</span><span class="lines">@@ -4388,7 +4388,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     Document* document = const_cast&lt;Document*&gt;(this);
</span><del>-    while (Element* element = document-&gt;ownerElement())
</del><ins>+    while (HTMLFrameOwnerElement* element = document-&gt;ownerElement())
</ins><span class="cx">         document = &amp;element-&gt;document();
</span><span class="cx">     return *document;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLBodyElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLBodyElement.cpp (173527 => 173528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLBodyElement.cpp        2014-09-11 19:22:06 UTC (rev 173527)
+++ trunk/Source/WebCore/html/HTMLBodyElement.cpp        2014-09-11 19:26:16 UTC (rev 173528)
</span><span class="lines">@@ -174,7 +174,7 @@
</span><span class="cx">     // FIXME: It's surprising this is web compatible since it means a marginwidth and marginheight attribute can
</span><span class="cx">     // magically appear on the &lt;body&gt; of all documents embedded through &lt;iframe&gt; or &lt;frame&gt;.
</span><span class="cx">     // FIXME: Perhaps this code should be in attach() instead of here.
</span><del>-    Element* ownerElement = document().ownerElement();
</del><ins>+    HTMLFrameOwnerElement* ownerElement = document().ownerElement();
</ins><span class="cx">     if (ownerElement &amp;&amp; isHTMLFrameElementBase(*ownerElement)) {
</span><span class="cx">         HTMLFrameElementBase&amp; ownerFrameElement = toHTMLFrameElementBase(*ownerElement);
</span><span class="cx">         int marginWidth = ownerFrameElement.marginWidth();
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (173527 => 173528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2014-09-11 19:22:06 UTC (rev 173527)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2014-09-11 19:26:16 UTC (rev 173528)
</span><span class="lines">@@ -773,7 +773,7 @@
</span><span class="cx">     if (isRoot) {
</span><span class="cx">         isOpaqueRoot = true;
</span><span class="cx">         if (!bgLayer-&gt;next() &amp;&amp; !(bgColor.isValid() &amp;&amp; bgColor.alpha() == 255)) {
</span><del>-            Element* ownerElement = document().ownerElement();
</del><ins>+            HTMLFrameOwnerElement* ownerElement = document().ownerElement();
</ins><span class="cx">             if (ownerElement) {
</span><span class="cx">                 if (!ownerElement-&gt;hasTagName(frameTag)) {
</span><span class="cx">                     // Locate the &lt;body&gt; element using the DOM.  This is easier than trying
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (173527 => 173528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.cpp        2014-09-11 19:22:06 UTC (rev 173527)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp        2014-09-11 19:26:16 UTC (rev 173528)
</span><span class="lines">@@ -2374,7 +2374,7 @@
</span><span class="cx">             newRect = LayoutRect(box-&gt;localToAbsoluteQuad(FloatQuad(FloatRect(localExposeRect)), UseTransforms).boundingBox());
</span><span class="cx">         }
</span><span class="cx">     } else if (!parentLayer &amp;&amp; renderer().isBox() &amp;&amp; renderBox()-&gt;canBeProgramaticallyScrolled()) {
</span><del>-        Element* ownerElement = renderer().document().ownerElement();
</del><ins>+        HTMLFrameOwnerElement* ownerElement = renderer().document().ownerElement();
</ins><span class="cx"> 
</span><span class="cx">         if (ownerElement &amp;&amp; ownerElement-&gt;renderer()) {
</span><span class="cx">             HTMLFrameElementBase* frameElementBase = nullptr;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderView.cpp (173527 => 173528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderView.cpp        2014-09-11 19:22:06 UTC (rev 173527)
+++ trunk/Source/WebCore/rendering/RenderView.cpp        2014-09-11 19:26:16 UTC (rev 173528)
</span><span class="lines">@@ -537,9 +537,8 @@
</span><span class="cx">     // layers with reflections, or transformed layers.
</span><span class="cx">     // FIXME: This needs to be dynamic.  We should be able to go back to blitting if we ever stop being inside
</span><span class="cx">     // a transform, transparency layer, etc.
</span><del>-    Element* elt;
-    for (elt = document().ownerElement(); elt &amp;&amp; elt-&gt;renderer(); elt = elt-&gt;document().ownerElement()) {
-        RenderLayer* layer = elt-&gt;renderer()-&gt;enclosingLayer();
</del><ins>+    for (HTMLFrameOwnerElement* element = document().ownerElement(); element &amp;&amp; element-&gt;renderer(); element = element-&gt;document().ownerElement()) {
+        RenderLayer* layer = element-&gt;renderer()-&gt;enclosingLayer();
</ins><span class="cx">         if (layer-&gt;cannotBlitToWindow()) {
</span><span class="cx">             frameView().setCannotBlitToWindow();
</span><span class="cx">             break;
</span></span></pre>
</div>
</div>

</body>
</html>