[iOS] Upstream changes to WebCore/style
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Aug 2013 17:35:01 +0000 (17:35 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Aug 2013 17:35:01 +0000 (17:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=120173

Reviewed by Darin Adler.

* style/StyleResolveTree.cpp:
(WebCore::Style::elementImplicitVisibility): Added; specific to iOS.
(WebCore::Style::CheckForVisibilityChangeOnRecalcStyle::CheckForVisibilityChangeOnRecalcStyle): Added; specific to iOS.
(WebCore::Style::CheckForVisibilityChangeOnRecalcStyle::~CheckForVisibilityChangeOnRecalcStyle): Added; specific to iOS.
(WebCore::Style::resolveTree): Modified to instantiate CheckForVisibilityChangeOnRecalcStyle when building on iOS.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154820 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/style/StyleResolveTree.cpp

index 2a5cee7..ac3a331 100644 (file)
@@ -1,3 +1,16 @@
+2013-08-29  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Upstream changes to WebCore/style
+        https://bugs.webkit.org/show_bug.cgi?id=120173
+
+        Reviewed by Darin Adler.
+
+        * style/StyleResolveTree.cpp:
+        (WebCore::Style::elementImplicitVisibility): Added; specific to iOS.
+        (WebCore::Style::CheckForVisibilityChangeOnRecalcStyle::CheckForVisibilityChangeOnRecalcStyle): Added; specific to iOS.
+        (WebCore::Style::CheckForVisibilityChangeOnRecalcStyle::~CheckForVisibilityChangeOnRecalcStyle): Added; specific to iOS.
+        (WebCore::Style::resolveTree): Modified to instantiate CheckForVisibilityChangeOnRecalcStyle when building on iOS.
+
 2013-08-29  Arnaud Renevier  <a.renevier@samsung.com>
 
         [cairo] canvas drawing on itself doesn't work with accelerated canvas
index 928e549..6601015 100644 (file)
 #include "StyleResolver.h"
 #include "Text.h"
 
+#if PLATFORM(IOS)
+#include "CSSFontSelector.h"
+#include "WKContentObservation.h"
+#endif
+
 namespace WebCore {
 
 namespace Style {
@@ -685,6 +690,60 @@ static void resolveShadowTree(ShadowRoot* shadowRoot, RenderStyle* parentElement
     shadowRoot->clearChildNeedsStyleRecalc();
 }
 
+#if PLATFORM(IOS)
+static EVisibility elementImplicitVisibility(const Element* element)
+{
+    RenderObject* renderer = element->renderer();
+    if (!renderer)
+        return VISIBLE;
+
+    RenderStyle* style = renderer->style();
+    if (!style)
+        return VISIBLE;
+
+    Length width(style->width());
+    Length height(style->height());
+    if ((width.isFixed() && width.value() <= 0) || (height.isFixed() && height.value() <= 0))
+        return HIDDEN;
+
+    Length top(style->top());
+    Length left(style->left());
+    if (left.isFixed() && width.isFixed() && -left.value() >= width.value())
+        return HIDDEN;
+
+    if (top.isFixed() && height.isFixed() && -top.value() >= height.value())
+        return HIDDEN;
+    return VISIBLE;
+}
+
+class CheckForVisibilityChangeOnRecalcStyle {
+public:
+    CheckForVisibilityChangeOnRecalcStyle(Element* element, RenderStyle* currentStyle)
+        : m_element(element)
+        , m_previousDisplay(currentStyle ? currentStyle->display() : NONE)
+        , m_previousVisibility(currentStyle ? currentStyle->visibility() : HIDDEN)
+        , m_previousImplicitVisibility(WKObservingContentChanges() && WKContentChange() != WKContentVisibilityChange ? elementImplicitVisibility(element) : VISIBLE)
+    {
+    }
+    ~CheckForVisibilityChangeOnRecalcStyle()
+    {
+        if (!WKObservingContentChanges())
+            return;
+        RenderStyle* style = m_element->renderStyle();
+        if (!style)
+            return;
+        if ((m_previousDisplay == NONE && style->display() != NONE) || (m_previousVisibility == HIDDEN && style->visibility() != HIDDEN)
+            || (m_previousImplicitVisibility == HIDDEN && elementImplicitVisibility(m_element.get()) == VISIBLE))
+            WKSetObservedContentChange(WKContentVisibilityChange);
+    }
+private:
+    RefPtr<Element> m_element;
+    EDisplay m_previousDisplay;
+    EVisibility m_previousVisibility;
+    EVisibility m_previousImplicitVisibility;
+};
+#endif // PLATFORM(IOS)
+
 void resolveTree(Element* current, Change change)
 {
     ASSERT(change != Detach);
@@ -699,6 +758,10 @@ void resolveTree(Element* current, Change change)
     bool hasDirectAdjacentRules = current->childrenAffectedByDirectAdjacentRules();
     bool hasIndirectAdjacentRules = current->childrenAffectedByForwardPositionalRules();
 
+#if PLATFORM(IOS)
+    CheckForVisibilityChangeOnRecalcStyle checkForVisibilityChange(current, current->renderStyle());
+#endif
+
     if (change > NoChange || current->needsStyleRecalc())
         current->resetComputedStyle();
 
@@ -759,6 +822,16 @@ void resolveTree(Document* document, Change change)
     if (resolveRootStyle) {
         RefPtr<RenderStyle> documentStyle = resolveForDocument(document);
 
+#if PLATFORM(IOS)
+        // Inserting the pictograph font at the end of the font fallback list is done by the
+        // font selector, so set a font selector if needed.
+        if (Settings* settings = document->settings()) {
+            StyleResolver* styleResolver = document->styleResolverIfExists();
+            if (settings->fontFallbackPrefersPictographs() && styleResolver)
+                documentStyle->font().update(styleResolver->fontSelector());
+        }
+#endif
+
         Style::Change documentChange = determineChange(documentStyle.get(), document->renderer()->style(), document->settings());
         if (documentChange != NoChange)
             document->renderer()->setStyle(documentStyle.release());