Changeset 106637 in webkit
- Timestamp:
- Feb 3, 2012 12:30:59 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r106633 r106637 1 2012-02-03 Shinya Kawanaka <shinyak@google.com> 2 3 Reimplement DETAILS and SUMMARY using selector query. 4 https://bugs.webkit.org/show_bug.cgi?id=75930 5 6 Since the implementation of DETAILS shadow tree, the path of caret position is also changed. 7 8 Reviewed by Hajime Morita. 9 10 * platform/chromium-win/fast/html/details-remove-summary-1-and-click-expected.txt: 11 * platform/chromium-win/fast/html/details-remove-summary-4-and-click-expected.txt: 12 * platform/gtk/fast/html/details-remove-summary-1-and-click-expected.txt: 13 * platform/gtk/fast/html/details-remove-summary-4-and-click-expected.txt: 14 * platform/mac/fast/html/details-remove-summary-1-and-click-expected.txt: 15 * platform/mac/fast/html/details-remove-summary-4-and-click-expected.txt: 16 * platform/qt/fast/html/details-remove-summary-1-and-click-expected.txt: 17 * platform/qt/fast/html/details-remove-summary-4-and-click-expected.txt: 18 1 19 2012-02-02 Alexei Filippov <alexeif@chromium.org> 2 20 -
trunk/LayoutTests/platform/chromium-win/fast/html/details-remove-summary-1-and-click-expected.txt
r87461 r106637 9 9 RenderText {#text} at (16,0) size 41x19 10 10 text run at (16,0) width 41: "Details" 11 caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body11 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 -
trunk/LayoutTests/platform/chromium-win/fast/html/details-remove-summary-4-and-click-expected.txt
r87461 r106637 9 9 RenderText {#text} at (16,0) size 41x19 10 10 text run at (16,0) width 41: "Details" 11 caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body11 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 -
trunk/LayoutTests/platform/gtk/fast/html/details-remove-summary-1-and-click-expected.txt
r101368 r106637 9 9 RenderText {#text} at (16,0) size 46x17 10 10 text run at (16,0) width 46: "Details" 11 caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body11 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 -
trunk/LayoutTests/platform/gtk/fast/html/details-remove-summary-4-and-click-expected.txt
r101368 r106637 9 9 RenderText {#text} at (16,0) size 46x17 10 10 text run at (16,0) width 46: "Details" 11 caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body11 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 -
trunk/LayoutTests/platform/mac/fast/html/details-remove-summary-1-and-click-expected.txt
r84632 r106637 9 9 RenderText {#text} at (16,0) size 44x18 10 10 text run at (16,0) width 44: "Details" 11 caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body11 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 -
trunk/LayoutTests/platform/mac/fast/html/details-remove-summary-4-and-click-expected.txt
r84632 r106637 9 9 RenderText {#text} at (16,0) size 44x18 10 10 text run at (16,0) width 44: "Details" 11 caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body11 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 -
trunk/LayoutTests/platform/qt/fast/html/details-remove-summary-1-and-click-expected.txt
r98015 r106637 9 9 RenderText {#text} at (16,0) size 50x21 10 10 text run at (16,0) width 50: "Details" 11 caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body11 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 -
trunk/LayoutTests/platform/qt/fast/html/details-remove-summary-4-and-click-expected.txt
r98015 r106637 9 9 RenderText {#text} at (16,0) size 50x21 10 10 text run at (16,0) width 50: "Details" 11 caret: position 0 of child 0 {DIV} of {#shadow-root} of child 0 {SUMMARY} of {#shadow-root} of child 1 {DETAILS} of body11 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 -
trunk/Source/WebCore/ChangeLog
r106636 r106637 1 2012-02-03 Shinya Kawanaka <shinyak@google.com> 2 3 Reimplement DETAILS and SUMMARY using selector query. 4 https://bugs.webkit.org/show_bug.cgi?id=75930 5 6 Reviewed by Hajime Morita. 7 8 DETAILS is reimplemented using content element and its fallback feature. 9 We don't need to recreate DOM even if SUMMARY is removed from or added into DETAILS. 10 11 No new tests, should be covered by existing tests. 12 13 * html/HTMLDetailsElement.cpp: 14 (WebCore::DetailsSummaryElement::fallbackSummary): 15 Takes fallback element of content summary. 16 (DetailsSummaryElement): 17 (WebCore::DetailsSummaryElement::create): 18 Creates a fallback element also. 19 (WebCore): 20 (WebCore::HTMLDetailsElement::create): 21 (WebCore::HTMLDetailsElement::HTMLDetailsElement): 22 (WebCore::HTMLDetailsElement::createShadowSubtree): 23 (WebCore::HTMLDetailsElement::findMainSummary): 24 (WebCore::HTMLDetailsElement::parseMappedAttribute): 25 (WebCore::HTMLDetailsElement::childShouldCreateRenderer): 26 (WebCore::HTMLDetailsElement::toggleOpen): 27 * html/HTMLDetailsElement.h: 28 (HTMLDetailsElement): 29 * html/HTMLSummaryElement.cpp: 30 (WebCore::HTMLSummaryElement::isMainSummary): 31 1 32 2012-02-03 Jochen Eisinger <jochen@chromium.org> 2 33 -
trunk/Source/WebCore/html/HTMLDetailsElement.cpp
r105249 r106637 63 63 static PassRefPtr<DetailsSummaryElement> create(Document*); 64 64 65 Element* fallbackSummary() 66 { 67 ASSERT(firstChild() && firstChild()->hasTagName(summaryTag)); 68 return toElement(firstChild()); 69 } 70 65 71 private: 66 72 DetailsSummaryElement(Document* document) … … 73 79 PassRefPtr<DetailsSummaryElement> DetailsSummaryElement::create(Document* document) 74 80 { 75 return adoptRef(new DetailsSummaryElement(document)); 81 RefPtr<HTMLSummaryElement> defaultSummary = HTMLSummaryElement::create(summaryTag, document); 82 defaultSummary->appendChild(Text::create(document, defaultDetailsSummaryText()), ASSERT_NO_EXCEPTION); 83 84 DetailsSummaryElement* elem = new DetailsSummaryElement(document); 85 elem->appendChild(defaultSummary); 86 return adoptRef(elem); 76 87 } 77 88 78 89 PassRefPtr<HTMLDetailsElement> HTMLDetailsElement::create(const QualifiedName& tagName, Document* document) 79 90 { 80 RefPtr<HTMLDetailsElement> result = adoptRef(new HTMLDetailsElement(tagName, document)); 81 result->ensureShadowSubtreeOf(ForwardingSummary); 82 return result; 91 RefPtr<HTMLDetailsElement> elem = adoptRef(new HTMLDetailsElement(tagName, document)); 92 elem->createShadowSubtree(); 93 94 return elem.release(); 83 95 } 84 96 85 97 HTMLDetailsElement::HTMLDetailsElement(const QualifiedName& tagName, Document* document) 86 98 : HTMLElement(tagName, document) 87 , m_summaryType(NoSummary)88 , m_mainSummary(0)89 99 , m_isOpen(false) 90 100 { … … 97 107 } 98 108 99 void HTMLDetailsElement::ensureShadowSubtreeOf(SummaryType type)100 {101 if (type == m_summaryType)102 return;103 m_summaryType = type;104 removeShadowRoot();105 createShadowSubtree();106 }107 108 static Node* findSummaryFor(PassRefPtr<ContainerNode> container)109 {110 for (Node* child = container->firstChild(); child; child = child->nextSibling()) {111 if (child->hasTagName(summaryTag))112 return child;113 }114 115 return 0;116 }117 118 Node* HTMLDetailsElement::ensureMainSummary()119 {120 Node* summary = findSummaryFor(this);121 if (summary) {122 ensureShadowSubtreeOf(ForwardingSummary);123 return summary;124 }125 126 ensureShadowSubtreeOf(DefaultSummary);127 return findSummaryFor(shadowRoot());128 }129 130 void HTMLDetailsElement::refreshMainSummary(RefreshRenderer refreshRenderer)131 {132 RefPtr<Node> oldSummary = m_mainSummary;133 m_mainSummary = ensureMainSummary();134 135 if (oldSummary == m_mainSummary || !attached())136 return;137 138 if (oldSummary && oldSummary->parentNodeForRenderingAndStyle())139 oldSummary->reattach();140 if (m_mainSummary && refreshRenderer == RefreshRendererAllowed)141 m_mainSummary->reattach();142 }143 144 109 void HTMLDetailsElement::createShadowSubtree() 145 110 { 146 111 ASSERT(!shadowRoot()); 147 ExceptionCode ec = 0; 148 if (m_summaryType == DefaultSummary) { 149 RefPtr<HTMLSummaryElement> defaultSummary = HTMLSummaryElement::create(summaryTag, document()); 150 defaultSummary->appendChild(Text::create(document(), defaultDetailsSummaryText()), ec); 151 ensureShadowRoot()->appendChild(defaultSummary, ec, true); 152 ensureShadowRoot()->appendChild(DetailsContentElement::create(document()), ec, true); 153 } else { 154 ASSERT(m_summaryType == ForwardingSummary); 155 ensureShadowRoot()->appendChild(DetailsSummaryElement::create(document()), ec, true); 156 ensureShadowRoot()->appendChild(DetailsContentElement::create(document()), ec, true); 157 } 112 ensureShadowRoot()->appendChild(DetailsSummaryElement::create(document()), ASSERT_NO_EXCEPTION, true); 113 ensureShadowRoot()->appendChild(DetailsContentElement::create(document()), ASSERT_NO_EXCEPTION, true); 158 114 } 159 115 116 Element* HTMLDetailsElement::findMainSummary() const 117 { 118 for (Node* child = firstChild(); child; child = child->nextSibling()) { 119 if (child->hasTagName(summaryTag)) 120 return toElement(child); 121 } 160 122 161 void HTMLDetailsElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) 162 { 163 HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); 164 // If childCountDelta is less then zero and the main summary has changed it must be because previous main 165 // summary was removed. The new main summary was then inside the unrevealed content and needs to be 166 // reattached to create its renderer. If childCountDelta is not less then zero then a new <summary> element 167 // has been added and it will be attached without our help. 168 if (!changedByParser) 169 refreshMainSummary(childCountDelta < 0 ? RefreshRendererAllowed : RefreshRendererSupressed); 170 } 171 172 void HTMLDetailsElement::finishParsingChildren() 173 { 174 HTMLElement::finishParsingChildren(); 175 refreshMainSummary(RefreshRendererAllowed); 123 return static_cast<DetailsSummaryElement*>(shadowRoot()->firstChild())->fallbackSummary(); 176 124 } 177 125 … … 189 137 bool HTMLDetailsElement::childShouldCreateRenderer(Node* child) const 190 138 { 191 return m_isOpen || child == m_mainSummary; 139 if (m_isOpen) 140 return true; 141 142 if (!child->hasTagName(summaryTag)) 143 return false; 144 145 return child == findMainSummary(); 192 146 } 193 147 -
trunk/Source/WebCore/html/HTMLDetailsElement.h
r95901 r106637 29 29 public: 30 30 static PassRefPtr<HTMLDetailsElement> create(const QualifiedName& tagName, Document* document); 31 Node* mainSummary() const { return m_mainSummary; }32 31 void toggleOpen(); 33 32 33 Element* findMainSummary() const; 34 34 35 private: 35 enum RefreshRenderer {36 RefreshRendererAllowed,37 RefreshRendererSupressed,38 };39 40 enum SummaryType {41 NoSummary,42 DefaultSummary,43 ForwardingSummary44 };45 46 36 HTMLDetailsElement(const QualifiedName&, Document*); 47 37 48 38 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 49 virtual void childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta);50 virtual void finishParsingChildren();51 39 52 40 void parseMappedAttribute(Attribute*); 53 41 bool childShouldCreateRenderer(Node*) const; 54 42 55 Node* ensureMainSummary();56 void refreshMainSummary(RefreshRenderer);57 void ensureShadowSubtreeOf(SummaryType);58 43 void createShadowSubtree(); 59 44 60 SummaryType m_summaryType;61 Node* m_mainSummary;62 45 bool m_isOpen; 63 46 -
trunk/Source/WebCore/html/HTMLSummaryElement.cpp
r105249 r106637 90 90 { 91 91 if (HTMLDetailsElement* details = detailsElement()) 92 return details->mainSummary() == this; 93 return 0; 92 return details->findMainSummary() == this; 93 94 return false; 94 95 } 95 96
Note: See TracChangeset
for help on using the changeset viewer.