Changeset 81035 in webkit
- Timestamp:
- Mar 14, 2011 10:35:17 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 92 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r81030 r81035 1 2011-02-28 Luiz Agostini <luiz.agostini@openbossa.org> 2 3 Reviewed by Dave Hyatt. 4 5 HTML5 <details> and <summary>: rendering 6 https://bugs.webkit.org/show_bug.cgi?id=51071 7 8 * fast/html/details-add-summary-1-and-click.html: Added. 9 * fast/html/details-add-summary-1.html: Added. 10 * fast/html/details-add-summary-10-and-click.html: Added. 11 * fast/html/details-add-summary-10.html: Added. 12 * fast/html/details-add-summary-2-and-click.html: Added. 13 * fast/html/details-add-summary-2.html: Added. 14 * fast/html/details-add-summary-3-and-click.html: Added. 15 * fast/html/details-add-summary-3.html: Added. 16 * fast/html/details-add-summary-4-and-click.html: Added. 17 * fast/html/details-add-summary-4.html: Added. 18 * fast/html/details-add-summary-5-and-click.html: Added. 19 * fast/html/details-add-summary-5.html: Added. 20 * fast/html/details-add-summary-6-and-click.html: Added. 21 * fast/html/details-add-summary-6.html: Added. 22 * fast/html/details-add-summary-7-and-click.html: Added. 23 * fast/html/details-add-summary-7.html: Added. 24 * fast/html/details-add-summary-8-and-click.html: Added. 25 * fast/html/details-add-summary-8.html: Added. 26 * fast/html/details-add-summary-9-and-click.html: Added. 27 * fast/html/details-add-summary-9.html: Added. 28 * fast/html/details-mouse-click-expected.txt: Added. 29 * fast/html/details-mouse-click.html: Added. 30 * fast/html/details-no-summary1.html: Added. 31 * fast/html/details-no-summary2.html: Added. 32 * fast/html/details-no-summary3.html: Added. 33 * fast/html/details-no-summary4.html: Added. 34 * fast/html/details-open-javascript.html: Added. 35 * fast/html/details-open1.html: Added. 36 * fast/html/details-open2.html: Added. 37 * fast/html/details-open3.html: Added. 38 * fast/html/details-open4.html: Added. 39 * fast/html/details-open5.html: Added. 40 * fast/html/details-open6.html: Added. 41 * fast/html/details-position.html: Added. 42 * fast/html/details-remove-summary-1-and-click.html: Added. 43 * fast/html/details-remove-summary-1.html: Added. 44 * fast/html/details-remove-summary-2-and-click.html: Added. 45 * fast/html/details-remove-summary-2.html: Added. 46 * fast/html/details-remove-summary-3-and-click.html: Added. 47 * fast/html/details-remove-summary-3.html: Added. 48 * fast/html/details-remove-summary-4-and-click.html: Added. 49 * fast/html/details-remove-summary-4.html: Added. 50 * fast/html/details-remove-summary-5-and-click.html: Added. 51 * fast/html/details-remove-summary-5.html: Added. 52 * fast/html/details-remove-summary-6-and-click.html: Added. 53 * fast/html/details-remove-summary-6.html: Added. 54 * fast/html/details-writing-mode.html: Added. 55 * platform/qt/fast/html/details-add-summary-1-and-click-expected.txt: Added. 56 * platform/qt/fast/html/details-add-summary-1-expected.txt: Added. 57 * platform/qt/fast/html/details-add-summary-10-and-click-expected.txt: Added. 58 * platform/qt/fast/html/details-add-summary-10-expected.txt: Added. 59 * platform/qt/fast/html/details-add-summary-2-and-click-expected.txt: Added. 60 * platform/qt/fast/html/details-add-summary-2-expected.txt: Added. 61 * platform/qt/fast/html/details-add-summary-3-and-click-expected.txt: Added. 62 * platform/qt/fast/html/details-add-summary-3-expected.txt: Added. 63 * platform/qt/fast/html/details-add-summary-4-and-click-expected.txt: Added. 64 * platform/qt/fast/html/details-add-summary-4-expected.txt: Added. 65 * platform/qt/fast/html/details-add-summary-5-and-click-expected.txt: Added. 66 * platform/qt/fast/html/details-add-summary-5-expected.txt: Added. 67 * platform/qt/fast/html/details-add-summary-6-and-click-expected.txt: Added. 68 * platform/qt/fast/html/details-add-summary-6-expected.txt: Added. 69 * platform/qt/fast/html/details-add-summary-7-and-click-expected.txt: Added. 70 * platform/qt/fast/html/details-add-summary-7-expected.txt: Added. 71 * platform/qt/fast/html/details-add-summary-8-and-click-expected.txt: Added. 72 * platform/qt/fast/html/details-add-summary-8-expected.txt: Added. 73 * platform/qt/fast/html/details-add-summary-9-and-click-expected.txt: Added. 74 * platform/qt/fast/html/details-add-summary-9-expected.txt: Added. 75 * platform/qt/fast/html/details-no-summary1-expected.txt: Added. 76 * platform/qt/fast/html/details-no-summary2-expected.txt: Added. 77 * platform/qt/fast/html/details-no-summary3-expected.txt: Added. 78 * platform/qt/fast/html/details-no-summary4-expected.txt: Added. 79 * platform/qt/fast/html/details-open-javascript-expected.txt: Added. 80 * platform/qt/fast/html/details-open1-expected.txt: Added. 81 * platform/qt/fast/html/details-open2-expected.txt: Added. 82 * platform/qt/fast/html/details-open3-expected.txt: Added. 83 * platform/qt/fast/html/details-open4-expected.txt: Added. 84 * platform/qt/fast/html/details-open5-expected.txt: Added. 85 * platform/qt/fast/html/details-open6-expected.txt: Added. 86 * platform/qt/fast/html/details-remove-summary-1-and-click-expected.txt: Added. 87 * platform/qt/fast/html/details-remove-summary-1-expected.txt: Added. 88 * platform/qt/fast/html/details-remove-summary-2-and-click-expected.txt: Added. 89 * platform/qt/fast/html/details-remove-summary-2-expected.txt: Added. 90 * platform/qt/fast/html/details-remove-summary-3-and-click-expected.txt: Added. 91 * platform/qt/fast/html/details-remove-summary-3-expected.txt: Added. 92 * platform/qt/fast/html/details-remove-summary-4-and-click-expected.txt: Added. 93 * platform/qt/fast/html/details-remove-summary-4-expected.txt: Added. 94 * platform/qt/fast/html/details-remove-summary-5-and-click-expected.txt: Added. 95 * platform/qt/fast/html/details-remove-summary-5-expected.txt: Added. 96 * platform/qt/fast/html/details-remove-summary-6-and-click-expected.txt: Added. 97 * platform/qt/fast/html/details-remove-summary-6-expected.txt: Added. 98 * platform/qt/fast/html/details-writing-mode-expected.txt: Added. 99 * platform/qt/fast/multicol/span/clone-anonymous-block-non-inline-child-crash-expected.txt: 100 1 101 2011-03-14 Sheriff Bot <webkit.review.bot@gmail.com> 2 102 -
trunk/LayoutTests/fast/html/details-element-render-inline-crash-expected.txt
r73681 r81035 1 1 PASS 2 3 -
trunk/LayoutTests/platform/qt/fast/multicol/span/clone-anonymous-block-non-inline-child-crash-expected.txt
r75609 r81035 17 17 text run at (0,0) width 107: "Some inline text" 18 18 RenderBlock (anonymous) at (0,21) size 379x21 19 Render Block{SUMMARY} at (0,0) size 379x2119 RenderSummary {SUMMARY} at (0,0) size 379x21 20 20 RenderText {#text} at (0,0) size 107x21 21 21 text run at (0,0) width 107: "Some block text" -
trunk/Source/WebCore/ChangeLog
r81034 r81035 1 2011-02-28 Luiz Agostini <luiz.agostini@openbossa.org> 2 3 Reviewed by Dave Hyatt. 4 5 HTML5 <details> and <summary>: rendering 6 https://bugs.webkit.org/show_bug.cgi?id=51071 7 8 Tests: fast/html/details-add-summary-1-and-click.html 9 fast/html/details-add-summary-1.html 10 fast/html/details-add-summary-10-and-click.html 11 fast/html/details-add-summary-10.html 12 fast/html/details-add-summary-2-and-click.html 13 fast/html/details-add-summary-2.html 14 fast/html/details-add-summary-3-and-click.html 15 fast/html/details-add-summary-3.html 16 fast/html/details-add-summary-4-and-click.html 17 fast/html/details-add-summary-4.html 18 fast/html/details-add-summary-5-and-click.html 19 fast/html/details-add-summary-5.html 20 fast/html/details-add-summary-6-and-click.html 21 fast/html/details-add-summary-6.html 22 fast/html/details-add-summary-7-and-click.html 23 fast/html/details-add-summary-7.html 24 fast/html/details-add-summary-8-and-click.html 25 fast/html/details-add-summary-8.html 26 fast/html/details-add-summary-9-and-click.html 27 fast/html/details-add-summary-9.html 28 fast/html/details-mouse-click.html 29 fast/html/details-no-summary1.html 30 fast/html/details-no-summary2.html 31 fast/html/details-no-summary3.html 32 fast/html/details-no-summary4.html 33 fast/html/details-open-javascript.html 34 fast/html/details-open1.html 35 fast/html/details-open2.html 36 fast/html/details-open3.html 37 fast/html/details-open4.html 38 fast/html/details-open5.html 39 fast/html/details-open6.html 40 fast/html/details-position.html 41 fast/html/details-remove-summary-1-and-click.html 42 fast/html/details-remove-summary-1.html 43 fast/html/details-remove-summary-2-and-click.html 44 fast/html/details-remove-summary-2.html 45 fast/html/details-remove-summary-3-and-click.html 46 fast/html/details-remove-summary-3.html 47 fast/html/details-remove-summary-4-and-click.html 48 fast/html/details-remove-summary-4.html 49 fast/html/details-remove-summary-5-and-click.html 50 fast/html/details-remove-summary-5.html 51 fast/html/details-remove-summary-6-and-click.html 52 fast/html/details-remove-summary-6.html 53 fast/html/details-writing-mode.html 54 55 http://www.w3.org/TR/html5/interactive-elements.html#the-details-element 56 57 The main <summary> element is the first <summary> element of a <details> element. 58 All other childs of the <details> element are rendered only if the attribute 'open' is set. 59 Click event toggles the 'open' attribute. 60 61 * html/HTMLDetailsElement.cpp: 62 (WebCore::HTMLDetailsElement::HTMLDetailsElement): 63 (WebCore::HTMLDetailsElement::findMainSummary): 64 (WebCore::HTMLDetailsElement::childrenChanged): 65 (WebCore::HTMLDetailsElement::finishParsingChildren): 66 (WebCore::HTMLDetailsElement::parseMappedAttribute): 67 (WebCore::HTMLDetailsElement::childShouldCreateRenderer): 68 (WebCore::HTMLDetailsElement::defaultEventHandler): 69 * html/HTMLDetailsElement.h: 70 (WebCore::HTMLDetailsElement::mainSummary): 71 72 Method createRenderer added to class HTMLSummaryElement. 73 74 * html/HTMLSummaryElement.cpp: 75 (WebCore::HTMLSummaryElement::createRenderer): 76 * html/HTMLSummaryElement.h: 77 78 The first <summary> element is positioned at the top of its <details> parent. 79 The area occupied by this main <summary> element is the interactive area of the 80 <details> element. If the <details> tag has no <summary> child an OwnedSummaryRenderer 81 is created and added to the corresponding RenderDetails object. 82 83 * rendering/RenderDetails.cpp: 84 (WebCore::RenderDetails::RenderDetails): 85 (WebCore::RenderDetails::destroy): 86 (WebCore::RenderDetails::summaryBlock): 87 (WebCore::RenderDetails::contentBlock): 88 (WebCore::RenderDetails::addChild): 89 (WebCore::RenderDetails::removeChild): 90 (WebCore::RenderDetails::setMarkerStyle): 91 (WebCore::RenderDetails::styleDidChange): 92 (WebCore::RenderDetails::getRenderPosition): 93 (WebCore::RenderDetails::markerDestroyed): 94 (WebCore::RenderDetails::summaryDestroyed): 95 (WebCore::RenderDetails::moveSummaryToContents): 96 (WebCore::RenderDetails::createSummaryStyle): 97 (WebCore::RenderDetails::replaceMainSummary): 98 (WebCore::RenderDetails::createDefaultSummary): 99 (WebCore::RenderDetails::checkMainSummary): 100 (WebCore::RenderDetails::layout): 101 (WebCore::RenderDetails::isOpen): 102 (WebCore::RenderDetails::getParentOfFirstLineBox): 103 (WebCore::RenderDetails::firstNonMarkerChild): 104 (WebCore::RenderDetails::updateMarkerLocation): 105 * rendering/RenderDetails.h: 106 (WebCore::RenderDetails::interactiveArea): 107 (WebCore::RenderDetails::removeLeftoverAnonymousBlock): 108 (WebCore::RenderDetails::createsAnonymousWrapper): 109 (WebCore::RenderDetails::requiresForcedStyleRecalcPropagation): 110 111 A marker is added to the main <summary> element to indicate the current value of the 'open' 112 attribute of the <details> element. 113 114 * rendering/RenderDetailsMarker.cpp: 115 (WebCore::RenderDetailsMarker::RenderDetailsMarker): 116 (WebCore::RenderDetailsMarker::destroy): 117 (WebCore::RenderDetailsMarker::lineHeight): 118 (WebCore::RenderDetailsMarker::baselinePosition): 119 (WebCore::RenderDetailsMarker::computePreferredLogicalWidths): 120 (WebCore::RenderDetailsMarker::layout): 121 (WebCore::RenderDetailsMarker::getRelativeMarkerRect): 122 (WebCore::RenderDetailsMarker::isOpen): 123 (WebCore::createPath): 124 (WebCore::createDownArrowPath): 125 (WebCore::createUpArrowPath): 126 (WebCore::createLeftArrowPath): 127 (WebCore::createRightArrowPath): 128 (WebCore::RenderDetailsMarker::orientation): 129 (WebCore::RenderDetailsMarker::getCanonicalPath): 130 (WebCore::RenderDetailsMarker::getPath): 131 (WebCore::RenderDetailsMarker::paint): 132 * rendering/RenderDetailsMarker.h: 133 (WebCore::toRenderDetailsMarker): 134 135 * rendering/RenderSummary.cpp: 136 (WebCore::RenderSummary::RenderSummary): 137 (WebCore::RenderSummary::destroy): 138 (WebCore::RenderSummary::parentDetails): 139 (WebCore::RenderSummary::styleDidChange): 140 * rendering/RenderSummary.h: 141 142 * rendering/RenderTreeAsText.cpp: 143 (WebCore::RenderTreeAsText::writeRenderObject): 144 1 145 2011-03-14 Brady Eidson <beidson@apple.com> 2 146 -
trunk/Source/WebCore/html/HTMLDetailsElement.cpp
r73346 r81035 1 1 /* 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)2 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies) 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 22 22 #include "HTMLDetailsElement.h" 23 23 24 #include "Frame.h" 24 25 #include "HTMLNames.h" 26 #include "MouseEvent.h" 27 #include "PlatformMouseEvent.h" 25 28 #include "RenderDetails.h" 26 29 … … 36 39 HTMLDetailsElement::HTMLDetailsElement(const QualifiedName& tagName, Document* document) 37 40 : HTMLElement(tagName, document) 41 , m_mainSummary(0) 42 , m_isOpen(false) 38 43 { 39 44 ASSERT(hasTagName(detailsTag)); … … 45 50 } 46 51 52 void HTMLDetailsElement::findMainSummary() 53 { 54 m_mainSummary = 0; 55 56 for (Node* child = firstChild(); child; child = child->nextSibling()) { 57 if (child->hasTagName(summaryTag)) { 58 m_mainSummary = child; 59 break; 60 } 61 } 47 62 } 63 64 void HTMLDetailsElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) 65 { 66 HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); 67 if (!changedByParser) { 68 Node* oldSummary = m_mainSummary; 69 findMainSummary(); 70 71 if (oldSummary != m_mainSummary && !m_isOpen && attached()) { 72 if (oldSummary && oldSummary->attached()) 73 oldSummary->detach(); 74 if (m_mainSummary && childCountDelta < 0 && !m_mainSummary->renderer()) { 75 // If childCountDelta is less then zero and the main summary has changed it must be because previous main 76 // summary was removed. The new main summary was then inside the unrevealed content and needs to be 77 // reattached to create its renderer. If childCountDelta is not less then zero then a new <summary> element 78 // has been added and it will be attached without our help. 79 m_mainSummary->detach(); 80 m_mainSummary->attach(); 81 } 82 } 83 } 84 } 85 86 void HTMLDetailsElement::finishParsingChildren() 87 { 88 HTMLElement::finishParsingChildren(); 89 findMainSummary(); 90 if (attached() && m_mainSummary && !m_mainSummary->renderer()) { 91 m_mainSummary->detach(); 92 m_mainSummary->attach(); 93 } 94 } 95 96 void HTMLDetailsElement::parseMappedAttribute(Attribute* attr) 97 { 98 if (attr->name() == openAttr) { 99 bool oldValue = m_isOpen; 100 m_isOpen = !attr->value().isNull(); 101 if (attached() && oldValue != m_isOpen) { 102 detach(); 103 attach(); 104 } 105 } else 106 HTMLElement::parseMappedAttribute(attr); 107 } 108 109 bool HTMLDetailsElement::childShouldCreateRenderer(Node* child) const 110 { 111 return m_isOpen || child == m_mainSummary; 112 } 113 114 void HTMLDetailsElement::defaultEventHandler(Event* event) 115 { 116 HTMLElement::defaultEventHandler(event); 117 118 if (!renderer() || !renderer()->isDetails() || !event->isMouseEvent() || event->type() != eventNames().clickEvent || event->defaultHandled()) 119 return; 120 121 MouseEvent* mouseEvent = static_cast<MouseEvent*>(event); 122 if (mouseEvent->button() != LeftButton) 123 return; 124 125 RenderDetails* renderDetails = static_cast<RenderDetails*>(renderer()); 126 127 float factor = document() && document()->frame() ? document()->frame()->pageZoomFactor() : 1.0; 128 FloatPoint pos = renderDetails->absoluteToLocal(FloatPoint(mouseEvent->pageX() * factor, mouseEvent->pageY() * factor)); 129 130 if (renderDetails->interactiveArea().contains(pos.x(), pos.y())) { 131 setAttribute(openAttr, m_isOpen ? String() : String("")); 132 event->setDefaultHandled(); 133 } 134 } 135 136 } -
trunk/Source/WebCore/html/HTMLDetailsElement.h
r73346 r81035 1 1 /* 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)2 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies) 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 29 29 public: 30 30 static PassRefPtr<HTMLDetailsElement> create(const QualifiedName& tagName, Document* document); 31 Node* mainSummary() const { return m_mainSummary; } 31 32 32 33 private: … … 34 35 35 36 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 37 virtual void childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta); 38 virtual void finishParsingChildren(); 39 40 void parseMappedAttribute(Attribute*); 41 bool childShouldCreateRenderer(Node*) const; 42 void defaultEventHandler(Event*); 43 44 void findMainSummary(); 45 46 Node* m_mainSummary; 47 bool m_isOpen; 36 48 37 49 }; -
trunk/Source/WebCore/html/HTMLSummaryElement.cpp
r78914 r81035 22 22 #include "HTMLSummaryElement.h" 23 23 24 #include "HTMLDetailsElement.h" 24 25 #include "HTMLNames.h" 26 #include "RenderSummary.h" 25 27 26 28 namespace WebCore { … … 39 41 } 40 42 43 RenderObject* HTMLSummaryElement::createRenderer(RenderArena* arena, RenderStyle*) 44 { 45 return new (arena) RenderSummary(this); 41 46 } 47 48 } -
trunk/Source/WebCore/html/HTMLSummaryElement.h
r78914 r81035 32 32 private: 33 33 HTMLSummaryElement(const QualifiedName&, Document*); 34 35 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 34 36 }; 35 37 -
trunk/Source/WebCore/rendering/RenderDetails.cpp
r73681 r81035 1 1 /* 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)2 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies) 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 22 22 #include "RenderDetails.h" 23 23 24 #include "CSSStyleSelector.h" 25 #include "HTMLDetailsElement.h" 26 #include "HTMLNames.h" 27 #include "LocalizedStrings.h" 28 #include "RenderDetailsMarker.h" 29 #include "RenderTextFragment.h" 30 #include "RenderView.h" 31 24 32 namespace WebCore { 25 33 26 RenderDetails::RenderDetails(Node* element) 27 : RenderBlock(element) 28 { 34 using namespace HTMLNames; 35 36 RenderDetails::RenderDetails(Node* node) 37 : RenderBlock(node) 38 , m_summaryBlock(0) 39 , m_contentBlock(0) 40 , m_defaultSummaryBlock(0) 41 , m_defaultSummaryText(0) 42 , m_marker(0) 43 , m_mainSummary(0) 44 { 45 } 46 47 void RenderDetails::destroy() 48 { 49 if (m_marker) 50 m_marker->destroy(); 51 52 RenderBlock::destroy(); 53 } 54 55 RenderBlock* RenderDetails::summaryBlock() 56 { 57 if (!m_summaryBlock) { 58 m_summaryBlock = createAnonymousBlock(); 59 RenderBlock::addChild(m_summaryBlock, m_contentBlock); 60 } 61 return m_summaryBlock; 62 } 63 64 RenderBlock* RenderDetails::contentBlock() 65 { 66 if (!m_contentBlock) { 67 m_contentBlock = createAnonymousBlock(); 68 RenderBlock::addChild(m_contentBlock); 69 } 70 return m_contentBlock; 71 } 72 73 void RenderDetails::addChild(RenderObject* newChild, RenderObject* beforeChild) 74 { 75 if (beforeChild && beforeChild == m_mainSummary) 76 beforeChild = getRenderPosition(m_mainSummary); 77 contentBlock()->addChild(newChild, beforeChild); 78 } 79 80 void RenderDetails::removeChild(RenderObject* oldChild) 81 { 82 if (oldChild == m_summaryBlock || oldChild == m_contentBlock) { 83 RenderBlock::removeChild(oldChild); 84 m_summaryBlock = 0; 85 return; 86 } 87 88 if (oldChild == m_mainSummary) { 89 m_summaryBlock->removeChild(m_mainSummary); 90 return; 91 } 92 93 if (m_contentBlock) { 94 m_contentBlock->removeChild(oldChild); 95 return; 96 } 97 98 ASSERT_NOT_REACHED(); 99 } 100 101 void RenderDetails::setMarkerStyle() 102 { 103 if (m_marker) { 104 RefPtr<RenderStyle> markerStyle = RenderStyle::create(); 105 markerStyle->inheritFrom(style()); 106 m_marker->setStyle(markerStyle.release()); 107 } 29 108 } 30 109 … … 32 111 { 33 112 RenderBlock::styleDidChange(diff, oldStyle); 113 114 if (m_defaultSummaryBlock) { 115 m_defaultSummaryBlock->setStyle(createSummaryStyle()); 116 m_defaultSummaryText->setStyle(m_defaultSummaryBlock->style()); 117 } 118 119 setMarkerStyle(); 34 120 35 121 // Ensure that if we ended up being inline that we set our replaced flag … … 38 124 } 39 125 40 } 126 RenderObject* RenderDetails::getRenderPosition(RenderObject* object) 127 { 128 if (!object || !object->node()) 129 return 0; 130 131 Node* element = object->node()->nextSibling(); 132 133 while (element && !element->renderer()) 134 element = element->nextSibling(); 135 136 return element ? element->renderer() : 0; 137 } 138 139 void RenderDetails::markerDestroyed() 140 { 141 m_marker = 0; 142 } 143 144 void RenderDetails::summaryDestroyed(RenderObject* summary) 145 { 146 if (summary == m_mainSummary) 147 m_mainSummary = 0; 148 } 149 150 void RenderDetails::moveSummaryToContents() 151 { 152 if (m_defaultSummaryBlock) { 153 ASSERT(!m_mainSummary); 154 m_defaultSummaryBlock->destroy(); 155 m_defaultSummaryBlock = 0; 156 m_defaultSummaryText = 0; 157 return; 158 } 159 160 if (!m_mainSummary) 161 return; 162 163 m_mainSummary->remove(); 164 contentBlock()->addChild(m_mainSummary, getRenderPosition(m_mainSummary)); 165 m_mainSummary = 0; 166 } 167 168 PassRefPtr<RenderStyle> RenderDetails::createSummaryStyle() 169 { 170 RefPtr<HTMLElement> summary(HTMLElement::create(summaryTag, document())); 171 return document()->styleSelector()->styleForElement(summary.get(), style(), true); 172 } 173 174 void RenderDetails::replaceMainSummary(RenderObject* newSummary) 175 { 176 ASSERT(newSummary); 177 if (m_mainSummary == newSummary) 178 return; 179 180 moveSummaryToContents(); 181 newSummary->remove(); 182 summaryBlock()->addChild(newSummary); 183 m_mainSummary = newSummary; 184 } 185 186 void RenderDetails::createDefaultSummary() 187 { 188 if (m_defaultSummaryBlock) 189 return; 190 191 moveSummaryToContents(); 192 193 m_defaultSummaryBlock = summaryBlock()->createAnonymousBlock(); 194 m_defaultSummaryBlock->setStyle(createSummaryStyle()); 195 196 m_defaultSummaryText = new (renderArena()) RenderTextFragment(document(), defaultDetailsSummaryText().impl()); 197 m_defaultSummaryText->setStyle(m_defaultSummaryBlock->style()); 198 m_defaultSummaryBlock->addChild(m_defaultSummaryText); 199 200 summaryBlock()->addChild(m_defaultSummaryBlock); 201 } 202 203 void RenderDetails::checkMainSummary() 204 { 205 if (!node() || !node()->hasTagName(detailsTag)) 206 return; 207 208 Node* mainSummaryNode = static_cast<HTMLDetailsElement*>(node())->mainSummary(); 209 210 if (!mainSummaryNode || !mainSummaryNode->renderer() || mainSummaryNode->renderer()->isFloatingOrPositioned()) 211 createDefaultSummary(); 212 else 213 replaceMainSummary(mainSummaryNode->renderer()); 214 215 } 216 217 void RenderDetails::layout() 218 { 219 ASSERT(needsLayout()); 220 221 checkMainSummary(); 222 ASSERT(m_summaryBlock); 223 224 if (!m_marker) { 225 m_marker = new (renderArena()) RenderDetailsMarker(this); 226 setMarkerStyle(); 227 } 228 updateMarkerLocation(); 229 230 RenderBlock::layout(); 231 232 m_interactiveArea = m_summaryBlock->frameRect(); 233 234 // FIXME: the following code will not be needed once absoluteToLocal get patched to handle flipped blocks writing modes. 235 switch (style()->writingMode()) { 236 case TopToBottomWritingMode: 237 case LeftToRightWritingMode: 238 break; 239 case RightToLeftWritingMode: { 240 m_interactiveArea.setX(width() - m_interactiveArea.x() - m_interactiveArea.width()); 241 break; 242 } 243 case BottomToTopWritingMode: { 244 m_interactiveArea.setY(height() - m_interactiveArea.y() - m_interactiveArea.height()); 245 break; 246 } 247 } 248 } 249 250 bool RenderDetails::isOpen() const 251 { 252 return node() && node()->isElementNode() ? !static_cast<Element*>(node())->getAttribute(openAttr).isNull() : false; 253 } 254 255 RenderObject* RenderDetails::getParentOfFirstLineBox(RenderBlock* curr) 256 { 257 RenderObject* firstChild = curr->firstChild(); 258 if (!firstChild) 259 return 0; 260 261 for (RenderObject* currChild = firstChild; currChild; currChild = currChild->nextSibling()) { 262 if (currChild == m_marker) 263 continue; 264 265 if (currChild->isInline() && (!currChild->isRenderInline() || curr->generatesLineBoxesForInlineChild(currChild))) 266 return curr; 267 268 if (currChild->isFloating() || currChild->isPositioned()) 269 continue; 270 271 if (currChild->isTable() || !currChild->isRenderBlock() || (currChild->isBox() && toRenderBox(currChild)->isWritingModeRoot())) 272 break; 273 274 if (currChild->isDetails()) 275 break; 276 277 RenderObject* lineBox = getParentOfFirstLineBox(toRenderBlock(currChild)); 278 if (lineBox) 279 return lineBox; 280 } 281 282 return 0; 283 } 284 285 RenderObject* RenderDetails::firstNonMarkerChild(RenderObject* parent) 286 { 287 RenderObject* result = parent->firstChild(); 288 while (result && result->isDetailsMarker()) 289 result = result->nextSibling(); 290 return result; 291 } 292 293 void RenderDetails::updateMarkerLocation() 294 { 295 // Sanity check the location of our marker. 296 if (m_marker) { 297 RenderObject* markerPar = m_marker->parent(); 298 RenderObject* lineBoxParent = getParentOfFirstLineBox(m_summaryBlock); 299 if (!lineBoxParent) { 300 // If the marker is currently contained inside an anonymous box, 301 // then we are the only item in that anonymous box (since no line box 302 // parent was found). It's ok to just leave the marker where it is 303 // in this case. 304 if (markerPar && markerPar->isAnonymousBlock()) 305 lineBoxParent = markerPar; 306 else 307 lineBoxParent = m_summaryBlock; 308 } 309 310 if (markerPar != lineBoxParent || m_marker->preferredLogicalWidthsDirty()) { 311 // Removing and adding the marker can trigger repainting in 312 // containers other than ourselves, so we need to disable LayoutState. 313 view()->disableLayoutState(); 314 m_marker->remove(); 315 if (!lineBoxParent) 316 lineBoxParent = m_summaryBlock; 317 lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent)); 318 319 if (m_marker->preferredLogicalWidthsDirty()) 320 m_marker->computePreferredLogicalWidths(); 321 322 view()->enableLayoutState(); 323 } 324 } 325 } 326 327 } // namespace WebCore 328 -
trunk/Source/WebCore/rendering/RenderDetails.h
r73681 r81035 1 1 /* 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)2 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies) 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 22 22 #define RenderDetails_h 23 23 24 #include "RenderBlock.h" 24 #include "RenderFlexibleBox.h" 25 #include "Timer.h" 26 #include <wtf/OwnPtr.h> 25 27 26 28 namespace WebCore { 29 30 class RenderDetailsMarker; 27 31 28 32 class RenderDetails : public RenderBlock { … … 30 34 explicit RenderDetails(Node*); 31 35 32 private:33 36 virtual const char* renderName() const { return "RenderDetails"; } 34 37 virtual bool isDetails() const { return true; } 38 39 bool isOpen() const; 40 IntRect interactiveArea() const { return m_interactiveArea; } 41 void markerDestroyed(); 42 void summaryDestroyed(RenderObject*); 43 44 private: 35 45 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle); 46 47 virtual void addChild(RenderObject* newChild, RenderObject *beforeChild = 0); 48 virtual void removeChild(RenderObject*); 49 virtual void removeLeftoverAnonymousBlock(RenderBlock*) { } 50 virtual bool createsAnonymousWrapper() const { return true; } 51 52 virtual bool requiresForcedStyleRecalcPropagation() const { return true; } 53 54 virtual void layout(); 55 virtual void destroy(); 56 57 void createDefaultSummary(); 58 void replaceMainSummary(RenderObject*); 59 void moveSummaryToContents(); 60 void checkMainSummary(); 61 RenderObject* getRenderPosition(RenderObject*); 62 PassRefPtr<RenderStyle> createSummaryStyle(); 63 void setMarkerStyle(); 64 65 RenderBlock* summaryBlock(); 66 RenderBlock* contentBlock(); 67 68 RenderObject* getParentOfFirstLineBox(RenderBlock* curr); 69 RenderObject* firstNonMarkerChild(RenderObject* parent); 70 void updateMarkerLocation(); 71 72 RenderBlock* m_summaryBlock; 73 RenderBlock* m_contentBlock; 74 75 RenderObject* m_defaultSummaryBlock; 76 RenderObject* m_defaultSummaryText; 77 78 IntRect m_interactiveArea; 79 80 RenderDetailsMarker* m_marker; 81 82 RenderObject* m_mainSummary; 36 83 }; 37 84 … … 45 92 void toRenderDetails(const RenderDetails*); 46 93 47 } 94 } // namespace WebCore 48 95 49 96 #endif // RenderDetails_h -
trunk/Source/WebCore/rendering/RenderDetailsMarker.cpp
r73346 r81035 1 1 /* 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)2 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies) 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 22 22 #include "RenderDetailsMarker.h" 23 23 24 #include "GraphicsContext.h" 25 #include "HTMLNames.h" 26 #include "PaintInfo.h" 27 #include "RenderDetails.h" 28 #include "RenderSummary.h" 29 24 30 namespace WebCore { 25 31 26 RenderDetailsMarker::RenderDetailsMarker(Node* element) 27 : RenderBlock(element) 28 { 29 } 30 31 } 32 using namespace HTMLNames; 33 34 RenderDetailsMarker::RenderDetailsMarker(RenderDetails* item) 35 : RenderBox(item->document()) 36 , m_details(item) 37 { 38 setInline(true); 39 setReplaced(true); 40 } 41 42 void RenderDetailsMarker::destroy() 43 { 44 if (m_details) 45 m_details->markerDestroyed(); 46 47 RenderBox::destroy(); 48 } 49 50 int RenderDetailsMarker::lineHeight(bool firstLine, LineDirectionMode direction, LinePositionMode) const 51 { 52 return m_details->lineHeight(firstLine, direction, PositionOfInteriorLineBoxes); 53 } 54 55 int RenderDetailsMarker::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode) const 56 { 57 return m_details->baselinePosition(baselineType, firstLine, direction, PositionOfInteriorLineBoxes); 58 } 59 60 void RenderDetailsMarker::computePreferredLogicalWidths() 61 { 62 ASSERT(preferredLogicalWidthsDirty()); 63 64 m_minPreferredLogicalWidth = 2 * style()->fontMetrics().ascent() / 3; 65 m_maxPreferredLogicalWidth = m_minPreferredLogicalWidth; 66 67 setPreferredLogicalWidthsDirty(false); 68 } 69 70 void RenderDetailsMarker::layout() 71 { 72 ASSERT(needsLayout()); 73 74 setLogicalWidth(minPreferredLogicalWidth()); 75 setLogicalHeight(style()->fontMetrics().height()); 76 77 setMarginStart(0); 78 setMarginEnd(style()->fontMetrics().ascent() - minPreferredLogicalWidth() + 1); 79 80 setNeedsLayout(false); 81 } 82 83 IntRect RenderDetailsMarker::getRelativeMarkerRect() const 84 { 85 IntRect relativeRect; 86 87 int bulletWidth = minPreferredLogicalWidth(); 88 relativeRect = IntRect((logicalWidth() - bulletWidth) / 2, (logicalHeight() - bulletWidth) / 2, bulletWidth, bulletWidth); 89 90 if (!style()->isHorizontalWritingMode()) { 91 relativeRect = relativeRect.transposedRect(); 92 relativeRect.setX(width() - relativeRect.x() - relativeRect.width()); 93 } 94 95 return relativeRect; 96 } 97 98 bool RenderDetailsMarker::isOpen() const 99 { 100 return m_details && m_details->isOpen(); 101 } 102 103 static Path createPath(const FloatPoint* path) 104 { 105 Path result; 106 result.moveTo(FloatPoint(path[0].x(), path[0].y())); 107 for (int i = 1; i < 4; ++i) 108 result.addLineTo(FloatPoint(path[i].x(), path[i].y())); 109 return result; 110 } 111 112 static Path createDownArrowPath() 113 { 114 FloatPoint points[4] = { FloatPoint(0.0, 0.07), FloatPoint(0.5, 0.93), FloatPoint(1.0, 0.07), FloatPoint(0.0, 0.07) }; 115 return createPath(points); 116 } 117 118 static Path createUpArrowPath() 119 { 120 FloatPoint points[4] = { FloatPoint(0.0, 0.93), FloatPoint(0.5, 0.07), FloatPoint(1.0, 0.93), FloatPoint(0.0, 0.93) }; 121 return createPath(points); 122 } 123 124 static Path createLeftArrowPath() 125 { 126 FloatPoint points[4] = { FloatPoint(1.0, 0.0), FloatPoint(0.14, 0.5), FloatPoint(1.0, 1.0), FloatPoint(1.0, 0.0) }; 127 return createPath(points); 128 } 129 130 static Path createRightArrowPath() 131 { 132 FloatPoint points[4] = { FloatPoint(0.0, 0.0), FloatPoint(0.86, 0.5), FloatPoint(0.0, 1.0), FloatPoint(0.0, 0.0) }; 133 return createPath(points); 134 } 135 136 RenderDetailsMarker::Orientation RenderDetailsMarker::orientation() const 137 { 138 switch (style()->writingMode()) { 139 case TopToBottomWritingMode: 140 if (style()->isLeftToRightDirection()) 141 return isOpen() ? Down : Right; 142 return isOpen() ? Down : Left; 143 case RightToLeftWritingMode: 144 if (style()->isLeftToRightDirection()) 145 return isOpen() ? Left : Down; 146 return isOpen() ? Left : Up; 147 case LeftToRightWritingMode: 148 if (style()->isLeftToRightDirection()) 149 return isOpen() ? Right : Down; 150 return isOpen() ? Right : Up; 151 case BottomToTopWritingMode: 152 if (style()->isLeftToRightDirection()) 153 return isOpen() ? Up : Right; 154 return isOpen() ? Up : Left; 155 } 156 return Right; 157 } 158 159 Path RenderDetailsMarker::getCanonicalPath() const 160 { 161 switch (orientation()) { 162 case Left: return createLeftArrowPath(); 163 case Right: return createRightArrowPath(); 164 case Up: return createUpArrowPath(); 165 case Down: return createDownArrowPath(); 166 } 167 168 return Path(); 169 } 170 171 Path RenderDetailsMarker::getPath(const IntPoint& origin) const 172 { 173 IntRect rect = getRelativeMarkerRect(); 174 Path result = getCanonicalPath(); 175 result.transform(AffineTransform().scale(rect.width())); 176 result.translate(FloatSize(origin.x() + rect.x(), origin.y() + rect.y())); 177 return result; 178 } 179 180 void RenderDetailsMarker::paint(PaintInfo& paintInfo, int tx, int ty) 181 { 182 if (paintInfo.phase != PaintPhaseForeground || style()->visibility() != VISIBLE) 183 return; 184 185 IntPoint boxOrigin(tx + x(), ty + y()); 186 IntRect overflowRect(visualOverflowRect()); 187 overflowRect.move(boxOrigin.x(), boxOrigin.y()); 188 overflowRect.inflate(maximalOutlineSize(paintInfo.phase)); 189 190 if (!paintInfo.rect.intersects(overflowRect)) 191 return; 192 193 const Color color(style()->visitedDependentColor(CSSPropertyColor)); 194 paintInfo.context->setStrokeColor(color, style()->colorSpace()); 195 paintInfo.context->setStrokeStyle(SolidStroke); 196 paintInfo.context->setStrokeThickness(1.0f); 197 paintInfo.context->setFillColor(color, style()->colorSpace()); 198 199 paintInfo.context->fillPath(getPath(boxOrigin)); 200 } 201 202 } -
trunk/Source/WebCore/rendering/RenderDetailsMarker.h
r73346 r81035 1 1 /* 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)2 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies) 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 22 22 #define RenderDetailsMarker_h 23 23 24 #include "RenderB lock.h"24 #include "RenderBox.h" 25 25 26 26 namespace WebCore { 27 27 28 class RenderDetailsMarker : public RenderBlock { 28 class RenderDetails; 29 30 class RenderDetailsMarker : public RenderBox { 29 31 public: 30 explicit RenderDetailsMarker(Node*); 32 RenderDetailsMarker(RenderDetails*); 33 34 enum Orientation { Up, Down, Left, Right }; 35 36 Orientation orientation() const; 37 38 virtual void computePreferredLogicalWidths(); 39 virtual void destroy(); 31 40 32 41 private: 33 42 virtual const char* renderName() const { return "RenderDetailsMarker"; } 34 43 virtual bool isDetailsMarker() const { return true; } 44 virtual void paint(PaintInfo&, int tx, int ty); 45 virtual void layout(); 46 virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 47 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 48 49 IntRect getRelativeMarkerRect() const; 50 51 bool isOpen() const; 52 Path getCanonicalPath() const; 53 Path getPath(const IntPoint& origin) const; 54 55 RenderDetails* m_details; 35 56 }; 36 57 37 58 inline RenderDetailsMarker* toRenderDetailsMarker(RenderObject* object) 38 59 { 39 ASSERT(!object || object->isDetails ());60 ASSERT(!object || object->isDetailsMarker()); 40 61 return static_cast<RenderDetailsMarker*>(object); 62 } 63 64 inline const RenderDetailsMarker* toRenderDetailsMarker(const RenderObject* object) 65 { 66 ASSERT(!object || object->isDetailsMarker()); 67 return static_cast<const RenderDetailsMarker*>(object); 41 68 } 42 69 -
trunk/Source/WebCore/rendering/RenderSummary.cpp
r73346 r81035 1 1 /* 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)2 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies) 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 22 22 #include "RenderSummary.h" 23 23 24 #include "RenderDetails.h" 25 24 26 namespace WebCore { 25 27 26 RenderSummary::RenderSummary(Node* element)27 : RenderBlock( element)28 RenderSummary::RenderSummary(Node* node) 29 : RenderBlock(node) 28 30 { 29 31 } 30 32 33 void RenderSummary::destroy() 34 { 35 RenderDetails* details = parentDetails(); 36 if (details) 37 details->summaryDestroyed(this); 38 39 RenderBlock::destroy(); 31 40 } 41 42 RenderDetails* RenderSummary::parentDetails() 43 { 44 RenderObject* obj = parent(); 45 while (obj && !obj->isDetails()) 46 obj = obj->parent(); 47 48 return static_cast<RenderDetails*>(obj); 49 } 50 51 void RenderSummary::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) 52 { 53 RenderBlock::styleDidChange(diff, oldStyle); 54 55 56 // Ensure that if we ended up being inline that we set our replaced flag 57 // so that we're treated like an inline-block. 58 setReplaced(isInline()); 59 } 60 61 } -
trunk/Source/WebCore/rendering/RenderSummary.h
r73346 r81035 1 1 /* 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)2 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies) 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 26 26 namespace WebCore { 27 27 28 class RenderDetails; 29 28 30 class RenderSummary : public RenderBlock { 29 31 public: 30 32 explicit RenderSummary(Node*); 31 33 34 virtual void destroy(); 35 32 36 private: 33 37 virtual const char* renderName() const { return "RenderSummary"; } 34 38 virtual bool isSummary() const { return true; } 39 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle); 40 41 RenderDetails* parentDetails(); 35 42 }; 36 43 -
trunk/Source/WebCore/rendering/RenderTreeAsText.cpp
r80996 r81035 36 36 #include "PrintContext.h" 37 37 #include "RenderBR.h" 38 #include "RenderDetailsMarker.h" 38 39 #include "RenderFileUploadControl.h" 39 40 #include "RenderInline.h" … … 373 374 } 374 375 376 if (o.isDetailsMarker()) { 377 ts << ": "; 378 switch (toRenderDetailsMarker(&o)->orientation()) { 379 case RenderDetailsMarker::Left: 380 ts << "left"; 381 break; 382 case RenderDetailsMarker::Right: 383 ts << "right"; 384 break; 385 case RenderDetailsMarker::Up: 386 ts << "up"; 387 break; 388 case RenderDetailsMarker::Down: 389 ts << "down"; 390 break; 391 } 392 } 393 375 394 if (o.isListMarker()) { 376 395 String text = toRenderListMarker(&o)->text();
Note: See TracChangeset
for help on using the changeset viewer.