Title: [123180] trunk/Source/WebCore
Revision
123180
Author
[email protected]
Date
2012-07-19 22:54:31 -0700 (Thu, 19 Jul 2012)

Log Message

Introduce Node::shadowHost()
https://bugs.webkit.org/show_bug.cgi?id=91814

Reviewed by Hajime Morita.

Introduce Node::shadowHost(), which return the host element, or 0.
Node::shadowAncestorNode() is used to obtain a shadow host. However it
is confusing because it returns 'this' if this is not in a shadow tree.

Replaces one callsite of shadowAncestorNode() with shadowHost().

No behavior change.

* dom/Node.cpp:
(WebCore::Node::shadowHost): Added.
* dom/Node.h:
(Node): Declare shadowHost(), and add a comment to shadowAncestorNode().
* html/shadow/CalendarPickerElement.cpp:
(WebCore::CalendarPickerElement::hostInput):
Replace shadowAncestorNode() with shaodwHost().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (123179 => 123180)


--- trunk/Source/WebCore/ChangeLog	2012-07-20 05:33:33 UTC (rev 123179)
+++ trunk/Source/WebCore/ChangeLog	2012-07-20 05:54:31 UTC (rev 123180)
@@ -1,5 +1,28 @@
 2012-07-19  Kent Tamura  <[email protected]>
 
+        Introduce Node::shadowHost()
+        https://bugs.webkit.org/show_bug.cgi?id=91814
+
+        Reviewed by Hajime Morita.
+
+        Introduce Node::shadowHost(), which return the host element, or 0.
+        Node::shadowAncestorNode() is used to obtain a shadow host. However it
+        is confusing because it returns 'this' if this is not in a shadow tree.
+
+        Replaces one callsite of shadowAncestorNode() with shadowHost().
+
+        No behavior change.
+
+        * dom/Node.cpp:
+        (WebCore::Node::shadowHost): Added.
+        * dom/Node.h:
+        (Node): Declare shadowHost(), and add a comment to shadowAncestorNode().
+        * html/shadow/CalendarPickerElement.cpp:
+        (WebCore::CalendarPickerElement::hostInput):
+        Replace shadowAncestorNode() with shaodwHost().
+
+2012-07-19  Kent Tamura  <[email protected]>
+
         Form state restore: Need to identify a form by its content
         https://bugs.webkit.org/show_bug.cgi?id=91209
 

Modified: trunk/Source/WebCore/dom/Node.cpp (123179 => 123180)


--- trunk/Source/WebCore/dom/Node.cpp	2012-07-20 05:33:33 UTC (rev 123179)
+++ trunk/Source/WebCore/dom/Node.cpp	2012-07-20 05:54:31 UTC (rev 123180)
@@ -1394,6 +1394,12 @@
     return parentOrHostNode() ? parentOrHostNode()->canStartSelection() : true;
 }
 
+Element* Node::shadowHost() const
+{
+    if (ShadowRoot* root = shadowRoot())
+        return root->host();
+    return 0;
+}
 
 Node* Node::shadowAncestorNode() const
 {

Modified: trunk/Source/WebCore/dom/Node.h (123179 => 123180)


--- trunk/Source/WebCore/dom/Node.h	2012-07-20 05:33:33 UTC (rev 123179)
+++ trunk/Source/WebCore/dom/Node.h	2012-07-20 05:54:31 UTC (rev 123180)
@@ -223,6 +223,10 @@
     bool hasAttrList() const { return getFlag(HasAttrListFlag); }
     bool hasCustomCallbacks() const { return getFlag(HasCustomCallbacksFlag); }
 
+    // If this node is in a shadow tree, returns its shadow host. Otherwise, returns 0.
+    Element* shadowHost() const;
+    // If this node is in a shadow tree, returns its shadow host. Otherwise, returns this.
+    // Deprecated. Should use shadowHost() and check the return value.
     Node* shadowAncestorNode() const;
     ShadowRoot* shadowRoot() const;
     ShadowRoot* youngestShadowRoot() const;

Modified: trunk/Source/WebCore/html/shadow/CalendarPickerElement.cpp (123179 => 123180)


--- trunk/Source/WebCore/html/shadow/CalendarPickerElement.cpp	2012-07-20 05:33:33 UTC (rev 123179)
+++ trunk/Source/WebCore/html/shadow/CalendarPickerElement.cpp	2012-07-20 05:54:31 UTC (rev 123180)
@@ -81,9 +81,11 @@
 
 inline HTMLInputElement* CalendarPickerElement::hostInput()
 {
-    ASSERT(shadowAncestorNode());
-    ASSERT(shadowAncestorNode()->hasTagName(inputTag));
-    return static_cast<HTMLInputElement*>(shadowAncestorNode());
+    // _javascript_ code can't create CalendarPickerElement objects. This is
+    // always in shadow of <input>.
+    ASSERT(shadowHost());
+    ASSERT(shadowHost()->hasTagName(inputTag));
+    return static_cast<HTMLInputElement*>(shadowHost());
 }
 
 void CalendarPickerElement::defaultEventHandler(Event* event)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to