Title: [221603] trunk
Revision
221603
Author
[email protected]
Date
2017-09-04 20:29:46 -0700 (Mon, 04 Sep 2017)

Log Message

Fix a few minor problems found while working toward removing unneeded calls to updateStyle
https://bugs.webkit.org/show_bug.cgi?id=176279

Reviewed by Antti Koivisto.

Source/WebCore:

* dom/Document.cpp:
(WebCore::Document::updateTitleElement): Fix the algorithm so that an SVG title won't
ever become the title when the document element is not an SVG element. We had this wrong
before but we were passing the test because SVGTitleElement::insertedInto had a bug that
hid the problem.
(WebCore::Document::titleElementAdded): Pass a reference instead of a pointer.
(WebCore::Document::titleElementRemoved): Pass a reference instead of nullptr since we
want to know which element is being removed.

* dom/Document.h: Update the argument name and type for updateTitleElement.

* html/HTMLTitleElement.cpp:
(WebCore::HTMLTitleElement::insertedInto): Call titleElementAdded unconditionally.
The checks to see if the title element is connected to the document and not in the
shadow tree are now handled by the Document class.
(WebCore::HTMLTitleElement::removedFrom): Same for titleElementRemoved.

* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::applySize): Removed incorrect caching of FontCascade
objects; these need to be created each time we draw.
(WebCore::MockRealtimeVideoSource::drawText): Create all the fonts here. Since this is
a mock for testing, there is no real performance concern with doing this.
* platform/mock/MockRealtimeVideoSource.h: Removed the FontCascade data members.

* rendering/RenderTreeAsText.cpp:
(WebCore::updateLayoutIgnoringPendingStylesheetsIncludingSubframes): Added. Used below
to update layout more thoroughly.
(WebCore::externalRepresentation): Update layout of all descendant frames, not just
the top level frame.

* svg/SVGTitleElement.cpp:
(WebCore::SVGTitleElement::insertedInto): Removed bogus firstChild check, bogus isSVGDocument
check, and unneeded isConnected check and call titleElementAdded unconditionally. The checks
are now handled by the Document class.
(WebCore::SVGTitleElement::removedFrom): Same for titleElementRemoved.

* testing/Internals.cpp:
(WebCore::Internals::layerTreeAsText const): Added missing updateLayoutIgnorePendingStylesheets,
since dumping the layer tree without first doing a layout will yield stale results.
(WebCore::Internals::layerIDForElement): Added missing updateLayoutIgnorePendingStylesheets,
since using a renderer to check if a layer exists without first doing a layout will yield stale results.
(WebCore::Internals::setElementUsesDisplayListDrawing): Ditto.
(WebCore::Internals::setElementTracksDisplayListReplay): Ditto.
(WebCore::Internals::displayListForElement): Ditto.
(WebCore::Internals::replayDisplayListForElement): Ditto.
(WebCore::Internals::isSelectPopupVisible): Added missing updateLayoutIgnorePendingStylesheets,
since working with the RenderMenuList without first doing a layout will yield stale results.
Also removed unneeded strict handling of null renderer, instead just returning false.
(WebCore::Internals::isPluginUnavailabilityIndicatorObscured): Removed unnneeded check of
renderer class, since the HTMLPlugInElement::isReplacementObscured already handles that correctly.
(WebCore::Internals::pageOverlayLayerTreeAsText const): Use updateLayoutIgnorePendingStylesheets
instead of the normal updateLayout for consistency with the behavior of the other functions in this
file, and because we need a real answer here.
(WebCore::Internals::scrollSnapOffsets): Ditto. Also rearranged the code so the renderer check is
done after updating the renderer tree.

Tools:

* WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::AccessibilityUIElement::setSelectedChild const): Handle null here. The old code instead
would trigger an Objective-C exception unnecessarily.

LayoutTests:

* svg/hittest/svg-tooltip.svg: Made this test easier to run outside of WebKitTestRunnner,
by removing some overzealous checks.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (221602 => 221603)


--- trunk/LayoutTests/ChangeLog	2017-09-05 03:21:33 UTC (rev 221602)
+++ trunk/LayoutTests/ChangeLog	2017-09-05 03:29:46 UTC (rev 221603)
@@ -1,3 +1,13 @@
+2017-09-03  Darin Adler  <[email protected]>
+
+        Fix a few minor problems found while working toward removing unneeded calls to updateStyle
+        https://bugs.webkit.org/show_bug.cgi?id=176279
+
+        Reviewed by Antti Koivisto.
+
+        * svg/hittest/svg-tooltip.svg: Made this test easier to run outside of WebKitTestRunnner,
+        by removing some overzealous checks.
+
 2017-09-04  Sam Weinig  <[email protected]>
 
         [Canvas] Split CanvasRenderingContext2D.idl into separate IDLs to match current HTML spec

Modified: trunk/LayoutTests/svg/hittest/svg-tooltip.svg (221602 => 221603)


--- trunk/LayoutTests/svg/hittest/svg-tooltip.svg	2017-09-05 03:21:33 UTC (rev 221602)
+++ trunk/LayoutTests/svg/hittest/svg-tooltip.svg	2017-09-05 03:29:46 UTC (rev 221603)
@@ -19,9 +19,12 @@
 
     function testTooltipForElement(element)
     {
-        console.assert(window.internals);
         console.assert(element.id);
         var testCaseName = "<" + element.tagName + ' id="' + element.id + '"' + ">";
+        if (!window.internals) {
+            log("---- Could not test tooltip for " + testCaseName + "; no window.internals.");
+            return;
+        }
         var tooltip = internals.toolTipFromElement(element);
         var expectedTooltip = element.getAttribute("data-expected-tooltip");
         if (tooltip == expectedTooltip)
@@ -41,9 +44,6 @@
 
     function runTest()
     {
-        if (!window.testRunner || !window.internals)
-            return;
-
         testDocumentTitle();
         var testCases = document.querySelectorAll(".test-case");
         for (var i = 0; i < testCases.length; ++i)

Modified: trunk/Source/WebCore/ChangeLog (221602 => 221603)


--- trunk/Source/WebCore/ChangeLog	2017-09-05 03:21:33 UTC (rev 221602)
+++ trunk/Source/WebCore/ChangeLog	2017-09-05 03:29:46 UTC (rev 221603)
@@ -1,3 +1,66 @@
+2017-09-03  Darin Adler  <[email protected]>
+
+        Fix a few minor problems found while working toward removing unneeded calls to updateStyle
+        https://bugs.webkit.org/show_bug.cgi?id=176279
+
+        Reviewed by Antti Koivisto.
+
+        * dom/Document.cpp:
+        (WebCore::Document::updateTitleElement): Fix the algorithm so that an SVG title won't
+        ever become the title when the document element is not an SVG element. We had this wrong
+        before but we were passing the test because SVGTitleElement::insertedInto had a bug that
+        hid the problem.
+        (WebCore::Document::titleElementAdded): Pass a reference instead of a pointer.
+        (WebCore::Document::titleElementRemoved): Pass a reference instead of nullptr since we
+        want to know which element is being removed.
+
+        * dom/Document.h: Update the argument name and type for updateTitleElement.
+
+        * html/HTMLTitleElement.cpp:
+        (WebCore::HTMLTitleElement::insertedInto): Call titleElementAdded unconditionally.
+        The checks to see if the title element is connected to the document and not in the
+        shadow tree are now handled by the Document class.
+        (WebCore::HTMLTitleElement::removedFrom): Same for titleElementRemoved.
+
+        * platform/mock/MockRealtimeVideoSource.cpp:
+        (WebCore::MockRealtimeVideoSource::applySize): Removed incorrect caching of FontCascade
+        objects; these need to be created each time we draw.
+        (WebCore::MockRealtimeVideoSource::drawText): Create all the fonts here. Since this is
+        a mock for testing, there is no real performance concern with doing this.
+        * platform/mock/MockRealtimeVideoSource.h: Removed the FontCascade data members.
+
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::updateLayoutIgnoringPendingStylesheetsIncludingSubframes): Added. Used below
+        to update layout more thoroughly.
+        (WebCore::externalRepresentation): Update layout of all descendant frames, not just
+        the top level frame.
+
+        * svg/SVGTitleElement.cpp:
+        (WebCore::SVGTitleElement::insertedInto): Removed bogus firstChild check, bogus isSVGDocument
+        check, and unneeded isConnected check and call titleElementAdded unconditionally. The checks
+        are now handled by the Document class.
+        (WebCore::SVGTitleElement::removedFrom): Same for titleElementRemoved.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::layerTreeAsText const): Added missing updateLayoutIgnorePendingStylesheets,
+        since dumping the layer tree without first doing a layout will yield stale results.
+        (WebCore::Internals::layerIDForElement): Added missing updateLayoutIgnorePendingStylesheets,
+        since using a renderer to check if a layer exists without first doing a layout will yield stale results.
+        (WebCore::Internals::setElementUsesDisplayListDrawing): Ditto.
+        (WebCore::Internals::setElementTracksDisplayListReplay): Ditto.
+        (WebCore::Internals::displayListForElement): Ditto.
+        (WebCore::Internals::replayDisplayListForElement): Ditto.
+        (WebCore::Internals::isSelectPopupVisible): Added missing updateLayoutIgnorePendingStylesheets,
+        since working with the RenderMenuList without first doing a layout will yield stale results.
+        Also removed unneeded strict handling of null renderer, instead just returning false.
+        (WebCore::Internals::isPluginUnavailabilityIndicatorObscured): Removed unnneeded check of
+        renderer class, since the HTMLPlugInElement::isReplacementObscured already handles that correctly.
+        (WebCore::Internals::pageOverlayLayerTreeAsText const): Use updateLayoutIgnorePendingStylesheets
+        instead of the normal updateLayout for consistency with the behavior of the other functions in this
+        file, and because we need a real answer here.
+        (WebCore::Internals::scrollSnapOffsets): Ditto. Also rearranged the code so the renderer check is
+        done after updating the renderer tree.
+
 2017-09-04  Yusuke Suzuki  <[email protected]>
 
         Remove OS(SOLARIS) support

Modified: trunk/Source/WebCore/dom/Document.cpp (221602 => 221603)


--- trunk/Source/WebCore/dom/Document.cpp	2017-09-05 03:21:33 UTC (rev 221602)
+++ trunk/Source/WebCore/dom/Document.cpp	2017-09-05 03:29:46 UTC (rev 221603)
@@ -1541,18 +1541,54 @@
         updateTitle({ title, LTR });
 }
 
-void Document::updateTitleElement(Element* newTitleElement)
+void Document::updateTitleElement(Element& changingTitleElement)
 {
-    if (is<SVGSVGElement>(documentElement()))
-        m_titleElement = childrenOfType<SVGTitleElement>(*documentElement()).first();
+    auto findHTMLTitle = [] (Document& document) -> Element* {
+        return descendantsOfType<HTMLTitleElement>(document).first();
+    };
+    auto isHTMLTitle = [] (Element& element) {
+        return is<HTMLTitleElement>(element);
+    };
+    auto isHTMLTitleEligible = [] (Element& element) {
+        return element.isConnected() && !element.isInShadowTree();
+    };
+
+    auto findSVGTitle = [] (Document& document) -> Element* {
+        return childrenOfType<SVGTitleElement>(*document.documentElement()).first();
+    };
+    auto isSVGTitle = [] (Element& element) {
+        return is<SVGTitleElement>(element);
+    };
+    auto isSVGTitleEligible = [] (Element& element) {
+        return element.parentNode() == element.document().documentElement();
+    };
+
+    // Most documents use HTML title rules.
+    // Documents with SVG document elements use SVG title rules.
+    bool useSVGTitle = is<SVGSVGElement>(documentElement());
+    auto findTitle = useSVGTitle ? findSVGTitle : findHTMLTitle;
+    auto isTitle = useSVGTitle ? isSVGTitle : isHTMLTitle;
+    auto isTitleEligible = useSVGTitle ? isSVGTitleEligible : isHTMLTitleEligible;
+
+    if (!isTitle(changingTitleElement)) {
+        ASSERT(m_titleElement == findTitle(*this));
+        return;
+    }
+
+    Element* newTitleElement;
+    if (m_titleElement)
+        newTitleElement = findTitle(*this);
     else {
-        if (m_titleElement) {
-            if (isHTMLDocument() || isXHTMLDocument())
-                m_titleElement = descendantsOfType<HTMLTitleElement>(*this).first();
-        } else
-            m_titleElement = newTitleElement;
+        // Optimized common case: We have no title element yet.
+        // We can figure out which title element should be used without searching.
+        newTitleElement = isTitleEligible(changingTitleElement) ? &changingTitleElement : nullptr;
+        ASSERT(newTitleElement == findTitle(*this));
     }
 
+    if (m_titleElement == newTitleElement)
+        return;
+
+    m_titleElement = newTitleElement;
     updateTitleFromTitleElement();
 }
 
@@ -1561,7 +1597,7 @@
     if (m_titleElement == &titleElement)
         return;
 
-    updateTitleElement(&titleElement);
+    updateTitleElement(titleElement);
 }
 
 void Document::titleElementRemoved(Element& titleElement)
@@ -1569,7 +1605,7 @@
     if (m_titleElement != &titleElement)
         return;
 
-    updateTitleElement(nullptr);
+    updateTitleElement(titleElement);
 }
 
 void Document::titleElementTextChanged(Element& titleElement)

Modified: trunk/Source/WebCore/dom/Document.h (221602 => 221603)


--- trunk/Source/WebCore/dom/Document.h	2017-09-05 03:21:33 UTC (rev 221602)
+++ trunk/Source/WebCore/dom/Document.h	2017-09-05 03:29:46 UTC (rev 221603)
@@ -1372,7 +1372,7 @@
 
     void detachFromFrame() { observeFrame(nullptr); }
 
-    void updateTitleElement(Element* newTitleElement);
+    void updateTitleElement(Element& changingTitleElement);
     void frameDestroyed() final;
 
     void commonTeardown();

Modified: trunk/Source/WebCore/html/HTMLTitleElement.cpp (221602 => 221603)


--- trunk/Source/WebCore/html/HTMLTitleElement.cpp	2017-09-05 03:21:33 UTC (rev 221602)
+++ trunk/Source/WebCore/html/HTMLTitleElement.cpp	2017-09-05 03:29:46 UTC (rev 221603)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2003, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2017 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -53,8 +53,7 @@
 Node::InsertionNotificationRequest HTMLTitleElement::insertedInto(ContainerNode& insertionPoint)
 {
     HTMLElement::insertedInto(insertionPoint);
-    if (isConnected() && !isInShadowTree())
-        document().titleElementAdded(*this);
+    document().titleElementAdded(*this);
     return InsertionDone;
 }
 
@@ -61,8 +60,7 @@
 void HTMLTitleElement::removedFrom(ContainerNode& insertionPoint)
 {
     HTMLElement::removedFrom(insertionPoint);
-    if (insertionPoint.isConnected() && !insertionPoint.isInShadowTree())
-        document().titleElementRemoved(*this);
+    document().titleElementRemoved(*this);
 }
 
 void HTMLTitleElement::childrenChanged(const ChildChange& change)

Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp (221602 => 221603)


--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp	2017-09-05 03:21:33 UTC (rev 221602)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp	2017-09-05 03:29:46 UTC (rev 221603)
@@ -192,29 +192,9 @@
 bool MockRealtimeVideoSource::applySize(const IntSize& size)
 {
     m_baseFontSize = size.height() * .08;
-    FontCascadeDescription fontDescription;
-    fontDescription.setOneFamily("Courier");
-    fontDescription.setSpecifiedSize(m_baseFontSize);
-    fontDescription.setComputedSize(m_baseFontSize);
-    fontDescription.setWeight(FontSelectionValue(500));
-
-    m_timeFont = FontCascade(fontDescription, 0, 0);
-    m_timeFont.update(nullptr);
-
     m_bipBopFontSize = m_baseFontSize * 2.5;
-    fontDescription.setSpecifiedSize(m_bipBopFontSize);
-    fontDescription.setComputedSize(m_bipBopFontSize);
-    m_bipBopFont = FontCascade(fontDescription, 0, 0);
-    m_bipBopFont.update(nullptr);
-
     m_statsFontSize = m_baseFontSize * .5;
-    fontDescription.setSpecifiedSize(m_statsFontSize);
-    fontDescription.setComputedSize(m_statsFontSize);
-    m_statsFont = FontCascade(fontDescription, 0, 0);
-    m_statsFont.update(nullptr);
-
     m_imageBuffer = nullptr;
-
     return true;
 }
 
@@ -313,24 +293,43 @@
     unsigned minutes = seconds / 60 % 60;
     unsigned hours = minutes / 60 % 60;
 
+    FontCascadeDescription fontDescription;
+    fontDescription.setOneFamily("Courier");
+    fontDescription.setWeight(FontSelectionValue(500));
+
+    fontDescription.setSpecifiedSize(m_baseFontSize);
+    fontDescription.setComputedSize(m_baseFontSize);
+    FontCascade timeFont { fontDescription, 0, 0 };
+    timeFont.update(nullptr);
+
+    fontDescription.setSpecifiedSize(m_bipBopFontSize);
+    fontDescription.setComputedSize(m_bipBopFontSize);
+    FontCascade bipBopFont { fontDescription, 0, 0 };
+    bipBopFont.update(nullptr);
+
+    fontDescription.setSpecifiedSize(m_statsFontSize);
+    fontDescription.setComputedSize(m_statsFontSize);
+    FontCascade statsFont { fontDescription, 0, 0 };
+    statsFont.update(nullptr);
+
     IntSize size = this->size();
     FloatPoint timeLocation(size.width() * .05, size.height() * .15);
     context.setFillColor(Color::white);
     context.setTextDrawingMode(TextModeFill);
     String string = String::format("%02u:%02u:%02u.%03u", hours, minutes, seconds, milliseconds % 1000);
-    context.drawText(m_timeFont, TextRun((StringView(string))), timeLocation);
+    context.drawText(timeFont, TextRun((StringView(string))), timeLocation);
 
     string = String::format("%06u", m_frameNumber++);
     timeLocation.move(0, m_baseFontSize);
-    context.drawText(m_timeFont, TextRun((StringView(string))), timeLocation);
+    context.drawText(timeFont, TextRun((StringView(string))), timeLocation);
 
     FloatPoint statsLocation(size.width() * .65, size.height() * .75);
     string = String::format("Frame rate: %ffps", frameRate());
-    context.drawText(m_statsFont, TextRun((StringView(string))), statsLocation);
+    context.drawText(statsFont, TextRun((StringView(string))), statsLocation);
 
     string = String::format("Size: %u x %u", size.width(), size.height());
     statsLocation.move(0, m_statsFontSize);
-    context.drawText(m_statsFont, TextRun((StringView(string))), statsLocation);
+    context.drawText(statsFont, TextRun((StringView(string))), statsLocation);
 
     const char* camera;
     switch (facingMode()) {
@@ -352,7 +351,7 @@
     }
     string = String::format("Camera: %s", camera);
     statsLocation.move(0, m_statsFontSize);
-    context.drawText(m_statsFont, TextRun((StringView(string))), statsLocation);
+    context.drawText(statsFont, TextRun((StringView(string))), statsLocation);
 
     FloatPoint bipBopLocation(size.width() * .6, size.height() * .6);
     unsigned frameMod = m_frameNumber % 60;
@@ -359,11 +358,11 @@
     if (frameMod <= 15) {
         context.setFillColor(Color::cyan);
         String bip(ASCIILiteral("Bip"));
-        context.drawText(m_bipBopFont, TextRun(StringView(bip)), bipBopLocation);
+        context.drawText(bipBopFont, TextRun(StringView(bip)), bipBopLocation);
     } else if (frameMod > 30 && frameMod <= 45) {
         context.setFillColor(Color::yellow);
         String bop(ASCIILiteral("Bop"));
-        context.drawText(m_bipBopFont, TextRun(StringView(bop)), bipBopLocation);
+        context.drawText(bipBopFont, TextRun(StringView(bop)), bipBopLocation);
     }
 }
 

Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h (221602 => 221603)


--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h	2017-09-05 03:21:33 UTC (rev 221602)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h	2017-09-05 03:29:46 UTC (rev 221603)
@@ -85,13 +85,8 @@
     void delaySamples(float) override;
 
     float m_baseFontSize { 0 };
-    FontCascade m_timeFont;
-
     float m_bipBopFontSize { 0 };
-    FontCascade m_bipBopFont;
-
     float m_statsFontSize { 0 };
-    FontCascade m_statsFont;
 
     mutable std::unique_ptr<ImageBuffer> m_imageBuffer;
 

Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (221602 => 221603)


--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp	2017-09-05 03:21:33 UTC (rev 221602)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp	2017-09-05 03:29:46 UTC (rev 221603)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -930,9 +930,25 @@
     return ts.release();
 }
 
+static void updateLayoutIgnoringPendingStylesheetsIncludingSubframes(Document& document)
+{
+    document.updateLayoutIgnorePendingStylesheets();
+    auto* frame = document.frame();
+    for (auto* subframe = frame; subframe; subframe = subframe->tree().traverseNext(frame)) {
+        if (auto* document = subframe->document())
+            document->updateLayoutIgnorePendingStylesheets();
+    }
+}
+
 String externalRepresentation(Frame* frame, RenderAsTextBehavior behavior)
 {
-    RenderView* renderer = frame->contentRenderer();
+    ASSERT(frame);
+    ASSERT(frame->document());
+
+    if (!(behavior & RenderAsTextDontUpdateLayout))
+        updateLayoutIgnoringPendingStylesheetsIncludingSubframes(*frame->document());
+
+    auto* renderer = frame->contentRenderer();
     if (!renderer)
         return String();
 
@@ -939,8 +955,6 @@
     PrintContext printContext(frame);
     if (behavior & RenderAsTextPrintingMode)
         printContext.begin(renderer->width());
-    if (!(behavior & RenderAsTextDontUpdateLayout))
-        frame->document()->updateLayout();
 
     return externalRepresentation(*renderer, behavior);
 }
@@ -947,14 +961,18 @@
 
 String externalRepresentation(Element* element, RenderAsTextBehavior behavior)
 {
-    RenderElement* renderer = element->renderer();
+    ASSERT(element);
+
+    // This function doesn't support printing mode.
+    ASSERT(!(behavior & RenderAsTextPrintingMode));
+
+    if (!(behavior & RenderAsTextDontUpdateLayout))
+        updateLayoutIgnoringPendingStylesheetsIncludingSubframes(element->document());
+
+    auto* renderer = element->renderer();
     if (!is<RenderBox>(renderer))
         return String();
-    // Doesn't support printing mode.
-    ASSERT(!(behavior & RenderAsTextPrintingMode));
-    if (!(behavior & RenderAsTextDontUpdateLayout))
-        element->document().updateLayout();
-    
+
     return externalRepresentation(downcast<RenderBox>(*renderer), behavior | RenderAsTextShowAllLayers);
 }
 

Modified: trunk/Source/WebCore/svg/SVGTitleElement.cpp (221602 => 221603)


--- trunk/Source/WebCore/svg/SVGTitleElement.cpp	2017-09-05 03:21:33 UTC (rev 221602)
+++ trunk/Source/WebCore/svg/SVGTitleElement.cpp	2017-09-05 03:29:46 UTC (rev 221603)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2004, 2005 Nikolas Zimmermann <[email protected]>
  * Copyright (C) 2004, 2005, 2006 Rob Buis <[email protected]>
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -24,7 +24,6 @@
 
 #include "Document.h"
 #include "SVGNames.h"
-#include "Text.h"
 
 namespace WebCore {
 
@@ -39,22 +38,17 @@
     return adoptRef(*new SVGTitleElement(tagName, document));
 }
 
-Node::InsertionNotificationRequest SVGTitleElement::insertedInto(ContainerNode& rootParent)
+Node::InsertionNotificationRequest SVGTitleElement::insertedInto(ContainerNode& insertionPoint)
 {
-    SVGElement::insertedInto(rootParent);
-    if (!rootParent.isConnected())
-        return InsertionDone;
-
-    if (firstChild() && document().isSVGDocument())
-        document().titleElementAdded(*this);
+    SVGElement::insertedInto(insertionPoint);
+    document().titleElementAdded(*this);
     return InsertionDone;
 }
 
-void SVGTitleElement::removedFrom(ContainerNode& rootParent)
+void SVGTitleElement::removedFrom(ContainerNode& insertionPoint)
 {
-    SVGElement::removedFrom(rootParent);
-    if (rootParent.isConnected() && document().isSVGDocument())
-        document().titleElementRemoved(*this);
+    SVGElement::removedFrom(insertionPoint);
+    document().titleElementRemoved(*this);
 }
 
 void SVGTitleElement::childrenChanged(const ChildChange& change)

Modified: trunk/Source/WebCore/testing/Internals.cpp (221602 => 221603)


--- trunk/Source/WebCore/testing/Internals.cpp	2017-09-05 03:21:33 UTC (rev 221602)
+++ trunk/Source/WebCore/testing/Internals.cpp	2017-09-05 03:29:46 UTC (rev 221603)
@@ -2242,6 +2242,7 @@
     if (!document.frame())
         return Exception { InvalidAccessError };
 
+    document.updateLayoutIgnorePendingStylesheets();
     return document.frame()->layerTreeAsText(toLayerTreeFlags(flags));
 }
 
@@ -2251,6 +2252,8 @@
     if (!document || !document->frame())
         return Exception { InvalidAccessError };
 
+    element.document().updateLayoutIgnorePendingStylesheets();
+
     if (!element.renderer() || !element.renderer()->hasLayer())
         return Exception { NotFoundError };
 
@@ -2316,6 +2319,8 @@
     if (!document || !document->renderView())
         return Exception { InvalidAccessError };
 
+    element.document().updateLayoutIgnorePendingStylesheets();
+
     if (!element.renderer())
         return Exception { InvalidAccessError };
 
@@ -2341,6 +2346,8 @@
     if (!document || !document->renderView())
         return Exception { InvalidAccessError };
 
+    element.document().updateLayoutIgnorePendingStylesheets();
+
     if (!element.renderer())
         return Exception { InvalidAccessError };
 
@@ -2366,6 +2373,8 @@
     if (!document || !document->renderView())
         return Exception { InvalidAccessError };
 
+    element.document().updateLayoutIgnorePendingStylesheets();
+
     if (!element.renderer())
         return Exception { InvalidAccessError };
 
@@ -2392,6 +2401,8 @@
     if (!document || !document->renderView())
         return Exception { InvalidAccessError };
 
+    element.document().updateLayoutIgnorePendingStylesheets();
+
     if (!element.renderer())
         return Exception { InvalidAccessError };
 
@@ -3033,9 +3044,10 @@
 
 bool Internals::isSelectPopupVisible(HTMLSelectElement& element)
 {
+    element.document().updateLayoutIgnorePendingStylesheets();
+
     auto* renderer = element.renderer();
-    ASSERT(renderer);
-    if (!is<RenderMenuList>(*renderer))
+    if (!is<RenderMenuList>(renderer))
         return false;
 
 #if !PLATFORM(IOS)
@@ -3142,8 +3154,7 @@
 
 ExceptionOr<bool> Internals::isPluginUnavailabilityIndicatorObscured(Element& element)
 {
-    auto* renderer = element.renderer();
-    if (!is<HTMLPlugInElement>(element) || !is<RenderEmbeddedObject>(renderer))
+    if (!is<HTMLPlugInElement>(element))
         return Exception { InvalidAccessError };
 
     return downcast<HTMLPlugInElement>(element).isReplacementObscured();
@@ -3519,7 +3530,7 @@
     if (!document || !document->frame())
         return Exception { InvalidAccessError };
 
-    document->updateLayout();
+    document->updateLayoutIgnorePendingStylesheets();
 
     return MockPageOverlayClient::singleton().layerTreeAsText(document->frame()->mainFrame(), toLayerTreeFlags(flags));
 }
@@ -3662,11 +3673,11 @@
 
 ExceptionOr<String> Internals::scrollSnapOffsets(Element& element)
 {
+    element.document().updateLayoutIgnorePendingStylesheets();
+
     if (!element.renderBox())
         return String();
 
-    element.document().updateLayout();
-
     RenderBox& box = *element.renderBox();
     ScrollableArea* scrollableArea;
 

Modified: trunk/Tools/ChangeLog (221602 => 221603)


--- trunk/Tools/ChangeLog	2017-09-05 03:21:33 UTC (rev 221602)
+++ trunk/Tools/ChangeLog	2017-09-05 03:29:46 UTC (rev 221603)
@@ -1,3 +1,14 @@
+2017-09-03  Darin Adler  <[email protected]>
+
+        Fix a few minor problems found while working toward removing unneeded calls to updateStyle
+        https://bugs.webkit.org/show_bug.cgi?id=176279
+
+        Reviewed by Antti Koivisto.
+
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+        (WTR::AccessibilityUIElement::setSelectedChild const): Handle null here. The old code instead
+        would trigger an Objective-C exception unnecessarily.
+
 2017-09-04  Wenson Hsieh  <[email protected]>
 
         [iOS DnD] Refactor drag and drop logic in WKContentView in preparation for supporting multiple drag items in a drag session

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm (221602 => 221603)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm	2017-09-05 03:21:33 UTC (rev 221602)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm	2017-09-05 03:29:46 UTC (rev 221603)
@@ -1415,7 +1415,7 @@
 void AccessibilityUIElement::setSelectedChild(AccessibilityUIElement* element) const
 {
     BEGIN_AX_OBJC_EXCEPTIONS
-    NSArray* array = [NSArray arrayWithObject:element->platformUIElement()];
+    NSArray* array = element ? [NSArray array] : [NSArray arrayWithObject:element->platformUIElement()];
     [m_element accessibilitySetValue:array forAttribute:NSAccessibilitySelectedChildrenAttribute];
     END_AX_OBJC_EXCEPTIONS    
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to