Title: [116471] trunk
Revision
116471
Author
[email protected]
Date
2012-05-08 17:52:08 -0700 (Tue, 08 May 2012)

Log Message

Add stylesheet inheritance support to IFRAME_SEAMLESS
https://bugs.webkit.org/show_bug.cgi?id=85914

Reviewed by Ojan Vafai.

Source/WebCore:

This work is already guarded by IFRAME_SEAMLESS, as
Document::shouldDisplaySeamlesslyWithParent always returns false
when IFRAME_SEAMLESS is off.

This makes the child document use all author stylesheets from all parent documents,
per the seamless spec:
http://www.whatwg.org/specs/web-apps/current-work/#attr-iframe-seamless

This support is slightly inefficient as every time a sheet is added
to a parent document, the child document must do a full style selector recalc.
Normally author sheet additions have a fast-path which avoids the full selector recalc,
but such is not possible in the seamless case as we're inserting the parents sheets
earlier in the child's cascade (instead of just appending them to the end of the list).

The test covers both the static inheritance as well as addition of a stylesheet
to the parent and testing that it caused a recalc of the child.

Covered by fast/frames/seamless/seamless-css-cascade.html

* css/StyleResolver.cpp:
(WebCore::StyleResolver::StyleResolver):
(WebCore::StyleResolver::addStylesheetsFromSeamlessParents):
(WebCore):
* css/StyleResolver.h:
(StyleResolver):
* dom/Document.cpp:
(WebCore::Document::seamlessParentUpdatedStylesheets):
(WebCore):
(WebCore::Document::notifySeamlessChildDocumentsOfStylesheetUpdate):
(WebCore::Document::updateActiveStylesheets):
* dom/Document.h:
(Document):

LayoutTests:

Update the results (for both static and dynamic inheritance)
now that this support is landed.

* fast/frames/seamless/seamless-css-cascade-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (116470 => 116471)


--- trunk/LayoutTests/ChangeLog	2012-05-09 00:42:52 UTC (rev 116470)
+++ trunk/LayoutTests/ChangeLog	2012-05-09 00:52:08 UTC (rev 116471)
@@ -1,3 +1,15 @@
+2012-05-08  Eric Seidel  <[email protected]>
+
+        Add stylesheet inheritance support to IFRAME_SEAMLESS
+        https://bugs.webkit.org/show_bug.cgi?id=85914
+
+        Reviewed by Ojan Vafai.
+
+        Update the results (for both static and dynamic inheritance)
+        now that this support is landed.
+
+        * fast/frames/seamless/seamless-css-cascade-expected.txt:
+
 2012-05-08  Raymond Toy  <[email protected]>
 
         _javascript_AudioNode should not ASSERT if number of input channels is 0

Modified: trunk/LayoutTests/fast/frames/seamless/seamless-css-cascade-expected.txt (116470 => 116471)


--- trunk/LayoutTests/fast/frames/seamless/seamless-css-cascade-expected.txt	2012-05-09 00:42:52 UTC (rev 116470)
+++ trunk/LayoutTests/fast/frames/seamless/seamless-css-cascade-expected.txt	2012-05-09 00:52:08 UTC (rev 116471)
@@ -1,8 +1,8 @@
 Test that seamless iframes inherit styles from their parent iframe, and dymanically update when their parent document's styles update.
-FAIL window.getComputedStyle(one).color should be rgb(255, 255, 0). Was rgb(0, 0, 0).
+PASS window.getComputedStyle(one).color is "rgb(255, 255, 0)"
 PASS window.getComputedStyle(two).color is "rgb(128, 0, 128)"
-FAIL window.getComputedStyle(three).color should be rgb(255, 255, 255). Was rgb(0, 0, 0).
+PASS window.getComputedStyle(three).color is "rgb(255, 255, 255)"
 FAIL window.getComputedStyle(rootElement).color should be rgb(255, 165, 0). Was rgb(0, 0, 0).
 FAIL window.getComputedStyle(rootElement).color should be rgb(1, 2, 3). Was rgb(0, 0, 0).
-FAIL window.getComputedStyle(one).color should be rgb(3, 2, 1). Was rgb(0, 0, 0).
+PASS window.getComputedStyle(one).color is "rgb(3, 2, 1)"
 

Modified: trunk/Source/WebCore/ChangeLog (116470 => 116471)


--- trunk/Source/WebCore/ChangeLog	2012-05-09 00:42:52 UTC (rev 116470)
+++ trunk/Source/WebCore/ChangeLog	2012-05-09 00:52:08 UTC (rev 116471)
@@ -1,3 +1,43 @@
+2012-05-08  Eric Seidel  <[email protected]>
+
+        Add stylesheet inheritance support to IFRAME_SEAMLESS
+        https://bugs.webkit.org/show_bug.cgi?id=85914
+
+        Reviewed by Ojan Vafai.
+
+        This work is already guarded by IFRAME_SEAMLESS, as
+        Document::shouldDisplaySeamlesslyWithParent always returns false
+        when IFRAME_SEAMLESS is off.
+
+        This makes the child document use all author stylesheets from all parent documents,
+        per the seamless spec:
+        http://www.whatwg.org/specs/web-apps/current-work/#attr-iframe-seamless
+
+        This support is slightly inefficient as every time a sheet is added
+        to a parent document, the child document must do a full style selector recalc.
+        Normally author sheet additions have a fast-path which avoids the full selector recalc,
+        but such is not possible in the seamless case as we're inserting the parents sheets
+        earlier in the child's cascade (instead of just appending them to the end of the list).
+
+        The test covers both the static inheritance as well as addition of a stylesheet
+        to the parent and testing that it caused a recalc of the child.
+
+        Covered by fast/frames/seamless/seamless-css-cascade.html
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::StyleResolver):
+        (WebCore::StyleResolver::addStylesheetsFromSeamlessParents):
+        (WebCore):
+        * css/StyleResolver.h:
+        (StyleResolver):
+        * dom/Document.cpp:
+        (WebCore::Document::seamlessParentUpdatedStylesheets):
+        (WebCore):
+        (WebCore::Document::notifySeamlessChildDocumentsOfStylesheetUpdate):
+        (WebCore::Document::updateActiveStylesheets):
+        * dom/Document.h:
+        (Document):
+
 2012-05-08  Raphael Kubo da Costa  <[email protected]>
 
         [CMake] FindGStreamer: Fix the build with static WebCore.

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (116470 => 116471)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2012-05-09 00:42:52 UTC (rev 116470)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2012-05-09 00:52:08 UTC (rev 116471)
@@ -61,7 +61,7 @@
 #include "FrameSelection.h"
 #include "FrameView.h"
 #include "HTMLDocument.h"
-#include "HTMLElement.h"
+#include "HTMLIFrameElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "HTMLOptionElement.h"
@@ -418,9 +418,25 @@
     }
 #endif
 
+    addStylesheetsFromSeamlessParents();
     appendAuthorStylesheets(0, document->styleSheets()->vector());
 }
 
+void StyleResolver::addStylesheetsFromSeamlessParents()
+{
+    // Build a list of stylesheet lists from our ancestors, and walk that
+    // list in reverse order so that the root-most sheets are appended first.
+    Document* childDocument = document();
+    Vector<StyleSheetList*> ancestorSheets;
+    while (HTMLIFrameElement* parentIFrame = childDocument->seamlessParentIFrame()) {
+        Document* parentDocument = parentIFrame->document();
+        ancestorSheets.append(parentDocument->styleSheets());
+        childDocument = parentDocument;
+    }
+    for (int i = ancestorSheets.size() - 1; i >= 0; i--)
+        appendAuthorStylesheets(0, ancestorSheets.at(i)->vector());
+}
+
 void StyleResolver::addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<CSSStyleSheet> >* userSheets, RuleSet& userStyle)
 {
     if (!userSheets)

Modified: trunk/Source/WebCore/css/StyleResolver.h (116470 => 116471)


--- trunk/Source/WebCore/css/StyleResolver.h	2012-05-09 00:42:52 UTC (rev 116470)
+++ trunk/Source/WebCore/css/StyleResolver.h	2012-05-09 00:52:08 UTC (rev 116471)
@@ -401,6 +401,7 @@
 private:
     static RenderStyle* s_styleNotYetAvailable;
 
+    void addStylesheetsFromSeamlessParents();
     void addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<CSSStyleSheet> >*, RuleSet& userStyle);
 
     void cacheBorderAndBackground();

Modified: trunk/Source/WebCore/dom/Document.cpp (116470 => 116471)


--- trunk/Source/WebCore/dom/Document.cpp	2012-05-09 00:42:52 UTC (rev 116470)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-05-09 00:52:08 UTC (rev 116471)
@@ -2864,6 +2864,11 @@
     styleResolverChanged(RecalcStyleImmediately);
 }
 
+void Document::seamlessParentUpdatedStylesheets()
+{
+    styleResolverChanged(RecalcStyleImmediately);
+}
+
 CSSStyleSheet* Document::elementSheet()
 {
     if (!m_elemSheet)
@@ -3490,6 +3495,22 @@
     return false;
 }
 
+void Document::notifySeamlessChildDocumentsOfStylesheetUpdate() const
+{
+    // If we're not in a frame yet any potential child documents won't have a StyleResolver to update.
+    if (!frame())
+        return;
+
+    // Seamless child frames are expected to notify their seamless children recursively, so we only do direct children.
+    for (Frame* child = frame()->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
+        Document* childDocument = child->document();
+        if (childDocument->shouldDisplaySeamlesslyWithParent()) {
+            ASSERT(childDocument->seamlessParentIFrame()->document() == this);
+            childDocument->seamlessParentUpdatedStylesheets();
+        }
+    }
+}
+
 bool Document::updateActiveStylesheets(StyleResolverUpdateFlag updateFlag)
 {
     if (m_inStyleRecalc) {
@@ -3521,7 +3542,9 @@
     m_usesRemUnits = styleSheetsUseRemUnits(m_styleSheets->vector());
     m_didCalculateStyleResolver = true;
     m_hasDirtyStyleResolver = false;
-    
+
+    notifySeamlessChildDocumentsOfStylesheetUpdate();
+
     return requiresFullStyleRecalc;
 }
 

Modified: trunk/Source/WebCore/dom/Document.h (116470 => 116471)


--- trunk/Source/WebCore/dom/Document.h	2012-05-09 00:42:52 UTC (rev 116470)
+++ trunk/Source/WebCore/dom/Document.h	2012-05-09 00:52:08 UTC (rev 116471)
@@ -1203,6 +1203,9 @@
     bool testAddedStylesheetRequiresStyleRecalc(StyleSheetInternal*);
     void analyzeStylesheetChange(StyleResolverUpdateFlag, const Vector<RefPtr<StyleSheet> >& newStylesheets, bool& requiresStyleResolverReset, bool& requiresFullStyleRecalc);
 
+    void seamlessParentUpdatedStylesheets();
+    void notifySeamlessChildDocumentsOfStylesheetUpdate() const;
+
     void deleteCustomFonts();
 
     PassRefPtr<NodeList> handleZeroPadding(const HitTestRequest&, HitTestResult&) const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to