Diff
Modified: trunk/LayoutTests/ChangeLog (106636 => 106637)
--- trunk/LayoutTests/ChangeLog 2012-02-03 08:19:06 UTC (rev 106636)
+++ trunk/LayoutTests/ChangeLog 2012-02-03 08:30:59 UTC (rev 106637)
@@ -1,3 +1,21 @@
+2012-02-03 Shinya Kawanaka <[email protected]>
+
+ Reimplement DETAILS and SUMMARY using selector query.
+ https://bugs.webkit.org/show_bug.cgi?id=75930
+
+ Since the implementation of DETAILS shadow tree, the path of caret position is also changed.
+
+ Reviewed by Hajime Morita.
+
+ * platform/chromium-win/fast/html/details-remove-summary-1-and-click-expected.txt:
+ * platform/chromium-win/fast/html/details-remove-summary-4-and-click-expected.txt:
+ * platform/gtk/fast/html/details-remove-summary-1-and-click-expected.txt:
+ * platform/gtk/fast/html/details-remove-summary-4-and-click-expected.txt:
+ * platform/mac/fast/html/details-remove-summary-1-and-click-expected.txt:
+ * platform/mac/fast/html/details-remove-summary-4-and-click-expected.txt:
+ * platform/qt/fast/html/details-remove-summary-1-and-click-expected.txt:
+ * platform/qt/fast/html/details-remove-summary-4-and-click-expected.txt:
+
2012-02-02 Alexei Filippov <[email protected]>
Web Inspector: Always show percents together with counters in heap inspector.
Modified: trunk/LayoutTests/platform/chromium-win/fast/html/details-remove-summary-1-and-click-expected.txt (106636 => 106637)
--- trunk/LayoutTests/platform/chromium-win/fast/html/details-remove-summary-1-and-click-expected.txt 2012-02-03 08:19:06 UTC (rev 106636)
+++ trunk/LayoutTests/platform/chromium-win/fast/html/details-remove-summary-1-and-click-expected.txt 2012-02-03 08:30:59 UTC (rev 106637)
@@ -8,4 +8,4 @@
RenderDetailsMarker {DIV} at (0,5) size 10x10: down
RenderText {#text} at (16,0) size 41x19
text run at (16,0) width 41: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
Modified: trunk/LayoutTests/platform/chromium-win/fast/html/details-remove-summary-4-and-click-expected.txt (106636 => 106637)
--- trunk/LayoutTests/platform/chromium-win/fast/html/details-remove-summary-4-and-click-expected.txt 2012-02-03 08:19:06 UTC (rev 106636)
+++ trunk/LayoutTests/platform/chromium-win/fast/html/details-remove-summary-4-and-click-expected.txt 2012-02-03 08:30:59 UTC (rev 106637)
@@ -8,4 +8,4 @@
RenderDetailsMarker {DIV} at (0,5) size 10x10: right
RenderText {#text} at (16,0) size 41x19
text run at (16,0) width 41: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
Modified: trunk/LayoutTests/platform/gtk/fast/html/details-remove-summary-1-and-click-expected.txt (106636 => 106637)
--- trunk/LayoutTests/platform/gtk/fast/html/details-remove-summary-1-and-click-expected.txt 2012-02-03 08:19:06 UTC (rev 106636)
+++ trunk/LayoutTests/platform/gtk/fast/html/details-remove-summary-1-and-click-expected.txt 2012-02-03 08:30:59 UTC (rev 106637)
@@ -8,4 +8,4 @@
RenderDetailsMarker {DIV} at (0,4) size 10x10: down
RenderText {#text} at (16,0) size 46x17
text run at (16,0) width 46: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
Modified: trunk/LayoutTests/platform/gtk/fast/html/details-remove-summary-4-and-click-expected.txt (106636 => 106637)
--- trunk/LayoutTests/platform/gtk/fast/html/details-remove-summary-4-and-click-expected.txt 2012-02-03 08:19:06 UTC (rev 106636)
+++ trunk/LayoutTests/platform/gtk/fast/html/details-remove-summary-4-and-click-expected.txt 2012-02-03 08:30:59 UTC (rev 106637)
@@ -8,4 +8,4 @@
RenderDetailsMarker {DIV} at (0,4) size 10x10: right
RenderText {#text} at (16,0) size 46x17
text run at (16,0) width 46: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
Modified: trunk/LayoutTests/platform/mac/fast/html/details-remove-summary-1-and-click-expected.txt (106636 => 106637)
--- trunk/LayoutTests/platform/mac/fast/html/details-remove-summary-1-and-click-expected.txt 2012-02-03 08:19:06 UTC (rev 106636)
+++ trunk/LayoutTests/platform/mac/fast/html/details-remove-summary-1-and-click-expected.txt 2012-02-03 08:30:59 UTC (rev 106637)
@@ -8,4 +8,4 @@
RenderDetailsMarker {DIV} at (0,4) size 10x10: down
RenderText {#text} at (16,0) size 44x18
text run at (16,0) width 44: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
Modified: trunk/LayoutTests/platform/mac/fast/html/details-remove-summary-4-and-click-expected.txt (106636 => 106637)
--- trunk/LayoutTests/platform/mac/fast/html/details-remove-summary-4-and-click-expected.txt 2012-02-03 08:19:06 UTC (rev 106636)
+++ trunk/LayoutTests/platform/mac/fast/html/details-remove-summary-4-and-click-expected.txt 2012-02-03 08:30:59 UTC (rev 106637)
@@ -8,4 +8,4 @@
RenderDetailsMarker {DIV} at (0,4) size 10x10: right
RenderText {#text} at (16,0) size 44x18
text run at (16,0) width 44: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
Modified: trunk/LayoutTests/platform/qt/fast/html/details-remove-summary-1-and-click-expected.txt (106636 => 106637)
--- trunk/LayoutTests/platform/qt/fast/html/details-remove-summary-1-and-click-expected.txt 2012-02-03 08:19:06 UTC (rev 106636)
+++ trunk/LayoutTests/platform/qt/fast/html/details-remove-summary-1-and-click-expected.txt 2012-02-03 08:30:59 UTC (rev 106637)
@@ -8,4 +8,4 @@
RenderDetailsMarker {DIV} at (0,6) size 10x10: down
RenderText {#text} at (16,0) size 50x21
text run at (16,0) width 50: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
Modified: trunk/LayoutTests/platform/qt/fast/html/details-remove-summary-4-and-click-expected.txt (106636 => 106637)
--- trunk/LayoutTests/platform/qt/fast/html/details-remove-summary-4-and-click-expected.txt 2012-02-03 08:19:06 UTC (rev 106636)
+++ trunk/LayoutTests/platform/qt/fast/html/details-remove-summary-4-and-click-expected.txt 2012-02-03 08:30:59 UTC (rev 106637)
@@ -8,4 +8,4 @@
RenderDetailsMarker {DIV} at (0,6) size 10x10: right
RenderText {#text} at (16,0) size 50x21
text run at (16,0) width 50: "Details"
-caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body
+caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of child 0 {DIV} of {#shadow-root} of child 1 {DETAILS} of body
Modified: trunk/Source/WebCore/ChangeLog (106636 => 106637)
--- trunk/Source/WebCore/ChangeLog 2012-02-03 08:19:06 UTC (rev 106636)
+++ trunk/Source/WebCore/ChangeLog 2012-02-03 08:30:59 UTC (rev 106637)
@@ -1,3 +1,34 @@
+2012-02-03 Shinya Kawanaka <[email protected]>
+
+ Reimplement DETAILS and SUMMARY using selector query.
+ https://bugs.webkit.org/show_bug.cgi?id=75930
+
+ Reviewed by Hajime Morita.
+
+ DETAILS is reimplemented using content element and its fallback feature.
+ We don't need to recreate DOM even if SUMMARY is removed from or added into DETAILS.
+
+ No new tests, should be covered by existing tests.
+
+ * html/HTMLDetailsElement.cpp:
+ (WebCore::DetailsSummaryElement::fallbackSummary):
+ Takes fallback element of content summary.
+ (DetailsSummaryElement):
+ (WebCore::DetailsSummaryElement::create):
+ Creates a fallback element also.
+ (WebCore):
+ (WebCore::HTMLDetailsElement::create):
+ (WebCore::HTMLDetailsElement::HTMLDetailsElement):
+ (WebCore::HTMLDetailsElement::createShadowSubtree):
+ (WebCore::HTMLDetailsElement::findMainSummary):
+ (WebCore::HTMLDetailsElement::parseMappedAttribute):
+ (WebCore::HTMLDetailsElement::childShouldCreateRenderer):
+ (WebCore::HTMLDetailsElement::toggleOpen):
+ * html/HTMLDetailsElement.h:
+ (HTMLDetailsElement):
+ * html/HTMLSummaryElement.cpp:
+ (WebCore::HTMLSummaryElement::isMainSummary):
+
2012-02-03 Jochen Eisinger <[email protected]>
Crash when trying to add a timer to a detached document.
Modified: trunk/Source/WebCore/html/HTMLDetailsElement.cpp (106636 => 106637)
--- trunk/Source/WebCore/html/HTMLDetailsElement.cpp 2012-02-03 08:19:06 UTC (rev 106636)
+++ trunk/Source/WebCore/html/HTMLDetailsElement.cpp 2012-02-03 08:30:59 UTC (rev 106637)
@@ -62,6 +62,12 @@
public:
static PassRefPtr<DetailsSummaryElement> create(Document*);
+ Element* fallbackSummary()
+ {
+ ASSERT(firstChild() && firstChild()->hasTagName(summaryTag));
+ return toElement(firstChild());
+ }
+
private:
DetailsSummaryElement(Document* document)
: HTMLContentElement(HTMLNames::divTag, document)
@@ -72,20 +78,24 @@
PassRefPtr<DetailsSummaryElement> DetailsSummaryElement::create(Document* document)
{
- return adoptRef(new DetailsSummaryElement(document));
+ RefPtr<HTMLSummaryElement> defaultSummary = HTMLSummaryElement::create(summaryTag, document);
+ defaultSummary->appendChild(Text::create(document, defaultDetailsSummaryText()), ASSERT_NO_EXCEPTION);
+
+ DetailsSummaryElement* elem = new DetailsSummaryElement(document);
+ elem->appendChild(defaultSummary);
+ return adoptRef(elem);
}
PassRefPtr<HTMLDetailsElement> HTMLDetailsElement::create(const QualifiedName& tagName, Document* document)
{
- RefPtr<HTMLDetailsElement> result = adoptRef(new HTMLDetailsElement(tagName, document));
- result->ensureShadowSubtreeOf(ForwardingSummary);
- return result;
+ RefPtr<HTMLDetailsElement> elem = adoptRef(new HTMLDetailsElement(tagName, document));
+ elem->createShadowSubtree();
+
+ return elem.release();
}
HTMLDetailsElement::HTMLDetailsElement(const QualifiedName& tagName, Document* document)
: HTMLElement(tagName, document)
- , m_summaryType(NoSummary)
- , m_mainSummary(0)
, m_isOpen(false)
{
ASSERT(hasTagName(detailsTag));
@@ -96,85 +106,23 @@
return new (arena) RenderDetails(this);
}
-void HTMLDetailsElement::ensureShadowSubtreeOf(SummaryType type)
+void HTMLDetailsElement::createShadowSubtree()
{
- if (type == m_summaryType)
- return;
- m_summaryType = type;
- removeShadowRoot();
- createShadowSubtree();
+ ASSERT(!shadowRoot());
+ ensureShadowRoot()->appendChild(DetailsSummaryElement::create(document()), ASSERT_NO_EXCEPTION, true);
+ ensureShadowRoot()->appendChild(DetailsContentElement::create(document()), ASSERT_NO_EXCEPTION, true);
}
-static Node* findSummaryFor(PassRefPtr<ContainerNode> container)
+Element* HTMLDetailsElement::findMainSummary() const
{
- for (Node* child = container->firstChild(); child; child = child->nextSibling()) {
+ for (Node* child = firstChild(); child; child = child->nextSibling()) {
if (child->hasTagName(summaryTag))
- return child;
+ return toElement(child);
}
- return 0;
+ return static_cast<DetailsSummaryElement*>(shadowRoot()->firstChild())->fallbackSummary();
}
-Node* HTMLDetailsElement::ensureMainSummary()
-{
- Node* summary = findSummaryFor(this);
- if (summary) {
- ensureShadowSubtreeOf(ForwardingSummary);
- return summary;
- }
-
- ensureShadowSubtreeOf(DefaultSummary);
- return findSummaryFor(shadowRoot());
-}
-
-void HTMLDetailsElement::refreshMainSummary(RefreshRenderer refreshRenderer)
-{
- RefPtr<Node> oldSummary = m_mainSummary;
- m_mainSummary = ensureMainSummary();
-
- if (oldSummary == m_mainSummary || !attached())
- return;
-
- if (oldSummary && oldSummary->parentNodeForRenderingAndStyle())
- oldSummary->reattach();
- if (m_mainSummary && refreshRenderer == RefreshRendererAllowed)
- m_mainSummary->reattach();
-}
-
-void HTMLDetailsElement::createShadowSubtree()
-{
- ASSERT(!shadowRoot());
- ExceptionCode ec = 0;
- if (m_summaryType == DefaultSummary) {
- RefPtr<HTMLSummaryElement> defaultSummary = HTMLSummaryElement::create(summaryTag, document());
- defaultSummary->appendChild(Text::create(document(), defaultDetailsSummaryText()), ec);
- ensureShadowRoot()->appendChild(defaultSummary, ec, true);
- ensureShadowRoot()->appendChild(DetailsContentElement::create(document()), ec, true);
- } else {
- ASSERT(m_summaryType == ForwardingSummary);
- ensureShadowRoot()->appendChild(DetailsSummaryElement::create(document()), ec, true);
- ensureShadowRoot()->appendChild(DetailsContentElement::create(document()), ec, true);
- }
-}
-
-
-void HTMLDetailsElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
-{
- HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
- // If childCountDelta is less then zero and the main summary has changed it must be because previous main
- // summary was removed. The new main summary was then inside the unrevealed content and needs to be
- // reattached to create its renderer. If childCountDelta is not less then zero then a new <summary> element
- // has been added and it will be attached without our help.
- if (!changedByParser)
- refreshMainSummary(childCountDelta < 0 ? RefreshRendererAllowed : RefreshRendererSupressed);
-}
-
-void HTMLDetailsElement::finishParsingChildren()
-{
- HTMLElement::finishParsingChildren();
- refreshMainSummary(RefreshRendererAllowed);
-}
-
void HTMLDetailsElement::parseMappedAttribute(Attribute* attr)
{
if (attr->name() == openAttr) {
@@ -188,7 +136,13 @@
bool HTMLDetailsElement::childShouldCreateRenderer(Node* child) const
{
- return m_isOpen || child == m_mainSummary;
+ if (m_isOpen)
+ return true;
+
+ if (!child->hasTagName(summaryTag))
+ return false;
+
+ return child == findMainSummary();
}
void HTMLDetailsElement::toggleOpen()
Modified: trunk/Source/WebCore/html/HTMLDetailsElement.h (106636 => 106637)
--- trunk/Source/WebCore/html/HTMLDetailsElement.h 2012-02-03 08:19:06 UTC (rev 106636)
+++ trunk/Source/WebCore/html/HTMLDetailsElement.h 2012-02-03 08:30:59 UTC (rev 106637)
@@ -28,37 +28,20 @@
class HTMLDetailsElement : public HTMLElement {
public:
static PassRefPtr<HTMLDetailsElement> create(const QualifiedName& tagName, Document* document);
- Node* mainSummary() const { return m_mainSummary; }
void toggleOpen();
-private:
- enum RefreshRenderer {
- RefreshRendererAllowed,
- RefreshRendererSupressed,
- };
+ Element* findMainSummary() const;
- enum SummaryType {
- NoSummary,
- DefaultSummary,
- ForwardingSummary
- };
-
+private:
HTMLDetailsElement(const QualifiedName&, Document*);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
- virtual void childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta);
- virtual void finishParsingChildren();
void parseMappedAttribute(Attribute*);
bool childShouldCreateRenderer(Node*) const;
- Node* ensureMainSummary();
- void refreshMainSummary(RefreshRenderer);
- void ensureShadowSubtreeOf(SummaryType);
void createShadowSubtree();
- SummaryType m_summaryType;
- Node* m_mainSummary;
bool m_isOpen;
};
Modified: trunk/Source/WebCore/html/HTMLSummaryElement.cpp (106636 => 106637)
--- trunk/Source/WebCore/html/HTMLSummaryElement.cpp 2012-02-03 08:19:06 UTC (rev 106636)
+++ trunk/Source/WebCore/html/HTMLSummaryElement.cpp 2012-02-03 08:30:59 UTC (rev 106637)
@@ -89,8 +89,9 @@
bool HTMLSummaryElement::isMainSummary() const
{
if (HTMLDetailsElement* details = detailsElement())
- return details->mainSummary() == this;
- return 0;
+ return details->findMainSummary() == this;
+
+ return false;
}
static bool isClickableControl(Node* node)