Changeset 223947 in webkit
- Timestamp:
- Oct 24, 2017 6:35:45 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r223945 r223947 1 2017-10-24 Ryosuke Niwa <rniwa@webkit.org> 2 3 RenderSVGModelObject::checkIntersection triggers layout 4 https://bugs.webkit.org/show_bug.cgi?id=178710 5 6 Reviewed by Simon Fraser. 7 8 Added the support for SVG documents to js-test.js, and added a basic test for checkIntersection 9 and checkEnclosure using it. 10 11 * resources/js-test.js: 12 (ensureRootElement): Added. Creates a foreignObject element inside a SVG document. 13 (moveForeignObjectToTopIfNeeded): Added. In SVG, z-index order is determined by the element order. 14 In order to make the results visible, we move the foreignObject to the top by appending to the end 15 of the document element. 16 (getOrCreate): 17 (debug): Run innerHTML before appendChild as setting namespaceURI before running innerHTML would 18 result in span's being parsed as SVG elements. 19 (insertStyleSheet): 20 (finishJSTest): 21 * svg/custom/check-intersection-basic-expected.txt: Added. 22 * svg/custom/check-intersection-basic.svg: Added. 23 1 24 2017-10-24 Andy Estes <aestes@apple.com> 2 25 -
trunk/LayoutTests/resources/js-test.js
r217312 r223947 32 32 } 33 33 34 var rootElement = null; 35 function ensureRootElement() 36 { 37 if (!rootElement || !rootElement.isConnected) { 38 rootElement = document.body || document.documentElement; 39 if (document.documentElement.namespaceURI == 'http://www.w3.org/2000/svg') { 40 // FIXME: Make the test harness use SVG elements naively. 41 var foreignObject = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); 42 foreignObject.setAttribute('x', '0px'); 43 foreignObject.setAttribute('y', '0px'); 44 foreignObject.setAttribute('width', '100%'); 45 foreignObject.setAttribute('height', '100%'); 46 foreignObject.setAttribute('style', 'padding: 10px; background-color: rgba(255, 255, 255, 0.5)'); 47 document.documentElement.appendChild(foreignObject); 48 rootElement = foreignObject; 49 } 50 } 51 return rootElement; 52 } 53 54 moveForeignObjectToTopIfNeeded = function () { 55 if (rootElement && rootElement.localName == 'foreignObject') 56 document.documentElement.appendChild(rootElement); 57 } 58 34 59 function getOrCreate(id, tagName) 35 60 { … … 41 66 element.id = id; 42 67 var refNode; 43 var parent = document.body || document.documentElement; 68 var parent = ensureRootElement(); 69 44 70 if (id == "description") 45 71 refNode = getOrCreate("console", "div"); … … 70 96 { 71 97 var span = createHTMLElement("span"); 72 getOrCreate("console", "div").appendChild(span); // insert it first so XHTML knows the namespace73 98 span.innerHTML = msg + '<br />'; 99 getOrCreate("console", "div").appendChild(span); 74 100 }; 75 101 … … 92 118 var styleElement = createHTMLElement("style"); 93 119 styleElement.textContent = css; 94 (document.head || document.documentElement).appendChild(styleElement);120 (document.head || ensureRootElement()).appendChild(styleElement); 95 121 } 96 122 … … 749 775 return; 750 776 isSuccessfullyParsed(); 777 moveForeignObjectToTopIfNeeded(); 751 778 if (self.jsTestIsAsync && self.testRunner) 752 779 testRunner.notifyDone(); -
trunk/Source/WebCore/ChangeLog
r223945 r223947 1 2017-10-24 Ryosuke Niwa <rniwa@webkit.org> 2 3 RenderSVGModelObject::checkIntersection triggers layout 4 https://bugs.webkit.org/show_bug.cgi?id=178710 5 6 Reviewed by Simon Fraser. 7 8 Fixed the bug that checkIntersection and checkEnclosure no longer updates the layout after r223882. 9 10 Test: svg/custom/check-intersection-basic.svg 11 12 * svg/SVGSVGElement.cpp: 13 (WebCore::SVGSVGElement::collectIntersectionOrEnclosureList): 14 (WebCore::SVGSVGElement::checkIntersection): 15 (WebCore::SVGSVGElement::checkEnclosure): 16 * svg/SVGSVGElement.h: 17 1 18 2017-10-24 Andy Estes <aestes@apple.com> 2 19 -
trunk/Source/WebCore/svg/SVGSVGElement.cpp
r223882 r223947 324 324 } 325 325 326 Ref<NodeList> SVGSVGElement::collectIntersectionOrEnclosureList(SVGRect& rect, SVGElement* referenceElement, bool (*checkFunction)( const SVGElement*, SVGRect&))326 Ref<NodeList> SVGSVGElement::collectIntersectionOrEnclosureList(SVGRect& rect, SVGElement* referenceElement, bool (*checkFunction)(RefPtr<SVGElement>&&, SVGRect&)) 327 327 { 328 328 Vector<Ref<Element>> elements; … … 346 346 } 347 347 348 bool SVGSVGElement::checkIntersection(const SVGElement* element, SVGRect& rect) 349 { 350 return element && RenderSVGModelObject::checkIntersection(element->renderer(), rect.propertyReference()); 351 } 352 353 bool SVGSVGElement::checkEnclosure(const SVGElement* element, SVGRect& rect) 354 { 355 return element && RenderSVGModelObject::checkEnclosure(element->renderer(), rect.propertyReference()); 348 bool SVGSVGElement::checkIntersection(RefPtr<SVGElement>&& element, SVGRect& rect) 349 { 350 if (!element) 351 return false; 352 element->document().updateLayoutIgnorePendingStylesheets(); 353 return RenderSVGModelObject::checkIntersection(element->renderer(), rect.propertyReference()); 354 } 355 356 bool SVGSVGElement::checkEnclosure(RefPtr<SVGElement>&& element, SVGRect& rect) 357 { 358 if (!element) 359 return false; 360 element->document().updateLayoutIgnorePendingStylesheets(); 361 return RenderSVGModelObject::checkEnclosure(element->renderer(), rect.propertyReference()); 356 362 } 357 363 -
trunk/Source/WebCore/svg/SVGSVGElement.h
r223802 r223947 93 93 Ref<NodeList> getIntersectionList(SVGRect&, SVGElement* referenceElement); 94 94 Ref<NodeList> getEnclosureList(SVGRect&, SVGElement* referenceElement); 95 static bool checkIntersection( const SVGElement*, SVGRect&);96 static bool checkEnclosure( const SVGElement*, SVGRect&);95 static bool checkIntersection(RefPtr<SVGElement>&&, SVGRect&); 96 static bool checkEnclosure(RefPtr<SVGElement>&&, SVGRect&); 97 97 void deselectAll(); 98 98 … … 154 154 Frame* frameForCurrentScale() const; 155 155 void inheritViewAttributes(const SVGViewElement&); 156 Ref<NodeList> collectIntersectionOrEnclosureList(SVGRect&, SVGElement*, bool (*checkFunction)( const SVGElement*, SVGRect&));156 Ref<NodeList> collectIntersectionOrEnclosureList(SVGRect&, SVGElement*, bool (*checkFunction)(RefPtr<SVGElement>&&, SVGRect&)); 157 157 158 158 bool m_useCurrentView { false };
Note: See TracChangeset
for help on using the changeset viewer.