Commit eb603446 authored by zhenw@chromium.org's avatar zhenw@chromium.org

Navigation transitions (web to native app): Hide/Show transition elements (Blink side)

We need a way to show hidden transition elements when coming back from native app (when back button is pressed).

This is the Blink side of the CL. The Chrome side is here: https://codereview.chromium.org/712183002/

BUG=370696

Review URL: https://codereview.chromium.org/715653004

git-svn-id: svn://svn.chromium.org/blink/trunk@185162 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 1ff1e196
...@@ -21,6 +21,7 @@ PASS transitionElementRects[1].left == boxTransitionElementBounds.left is true ...@@ -21,6 +21,7 @@ PASS transitionElementRects[1].left == boxTransitionElementBounds.left is true
PASS transitionElementRects[1].top == boxTransitionElementBounds.top is true PASS transitionElementRects[1].top == boxTransitionElementBounds.top is true
PASS transitionElementRects[1].width == boxTransitionElementBounds.width is true PASS transitionElementRects[1].width == boxTransitionElementBounds.width is true
PASS transitionElementRects[1].height == boxTransitionElementBounds.height is true PASS transitionElementRects[1].height == boxTransitionElementBounds.height is true
PASS postShowingTransitionElementOpacity == 1 is true
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
...@@ -57,6 +57,10 @@ window.onload = function() { ...@@ -57,6 +57,10 @@ window.onload = function() {
shouldBeTrue('transitionElementRects[1].width == boxTransitionElementBounds.width'); shouldBeTrue('transitionElementRects[1].width == boxTransitionElementBounds.width');
shouldBeTrue('transitionElementRects[1].height == boxTransitionElementBounds.height'); shouldBeTrue('transitionElementRects[1].height == boxTransitionElementBounds.height');
internals.showAllTransitionElements();
postShowingTransitionElementOpacity = window.getComputedStyle(transitionElement).opacity;
shouldBeTrue('postShowingTransitionElementOpacity == 1');
finishJSTest(); finishJSTest();
} }
} }
......
...@@ -5645,7 +5645,7 @@ void Document::getTransitionElementData(Vector<TransitionElementData>& elementDa ...@@ -5645,7 +5645,7 @@ void Document::getTransitionElementData(Vector<TransitionElementData>& elementDa
} }
} }
void Document::hideTransitionElements(const AtomicString& cssSelector) void Document::updateElementOpacity(const AtomicString& cssSelector, double opacity)
{ {
TrackExceptionState exceptionState; TrackExceptionState exceptionState;
RefPtrWillBeRawPtr<StaticElementList> elementList = querySelectorAll(cssSelector, exceptionState); RefPtrWillBeRawPtr<StaticElementList> elementList = querySelectorAll(cssSelector, exceptionState);
...@@ -5654,11 +5654,21 @@ void Document::hideTransitionElements(const AtomicString& cssSelector) ...@@ -5654,11 +5654,21 @@ void Document::hideTransitionElements(const AtomicString& cssSelector)
for (unsigned nodeIndex = 0; nodeIndex < nodeListLength; ++nodeIndex) { for (unsigned nodeIndex = 0; nodeIndex < nodeListLength; ++nodeIndex) {
Element* element = elementList->item(nodeIndex); Element* element = elementList->item(nodeIndex);
element->setInlineStyleProperty(CSSPropertyOpacity, 0.0, CSSPrimitiveValue::CSS_NUMBER); element->setInlineStyleProperty(CSSPropertyOpacity, opacity, CSSPrimitiveValue::CSS_NUMBER);
} }
} }
} }
void Document::hideTransitionElements(const AtomicString& cssSelector)
{
updateElementOpacity(cssSelector, 0.0);
}
void Document::showTransitionElements(const AtomicString& cssSelector)
{
updateElementOpacity(cssSelector, 1.0);
}
bool Document::hasFocus() const bool Document::hasFocus() const
{ {
Page* page = this->page(); Page* page = this->page();
......
...@@ -386,6 +386,7 @@ public: ...@@ -386,6 +386,7 @@ public:
bool isTransitionDocument() const { return m_isTransitionDocument; } bool isTransitionDocument() const { return m_isTransitionDocument; }
void setIsTransitionDocument() { m_isTransitionDocument = true; } void setIsTransitionDocument() { m_isTransitionDocument = true; }
void hideTransitionElements(const AtomicString& cssSelector); void hideTransitionElements(const AtomicString& cssSelector);
void showTransitionElements(const AtomicString& cssSelector);
struct TransitionElement { struct TransitionElement {
String id; String id;
...@@ -1167,6 +1168,8 @@ private: ...@@ -1167,6 +1168,8 @@ private:
using EventFactorySet = HashSet<OwnPtr<EventFactoryBase>>; using EventFactorySet = HashSet<OwnPtr<EventFactoryBase>>;
static EventFactorySet& eventFactories(); static EventFactorySet& eventFactories();
void updateElementOpacity(const AtomicString& cssSelector, double opacity);
DocumentLifecycle m_lifecycle; DocumentLifecycle m_lifecycle;
bool m_hasNodesWithPlaceholderStyle; bool m_hasNodesWithPlaceholderStyle;
......
...@@ -2308,6 +2308,16 @@ void Internals::hideAllTransitionElements() ...@@ -2308,6 +2308,16 @@ void Internals::hideAllTransitionElements()
frame()->document()->hideTransitionElements(AtomicString(iter->selector)); frame()->document()->hideTransitionElements(AtomicString(iter->selector));
} }
void Internals::showAllTransitionElements()
{
Vector<Document::TransitionElementData> elementData;
frame()->document()->getTransitionElementData(elementData);
Vector<Document::TransitionElementData>::iterator iter = elementData.begin();
for (; iter != elementData.end(); ++iter)
frame()->document()->showTransitionElements(AtomicString(iter->selector));
}
void Internals::forcePluginPlaceholder(HTMLElement* element, PassRefPtrWillBeRawPtr<DocumentFragment> fragment, ExceptionState& exceptionState) void Internals::forcePluginPlaceholder(HTMLElement* element, PassRefPtrWillBeRawPtr<DocumentFragment> fragment, ExceptionState& exceptionState)
{ {
if (!element->isPluginElement()) { if (!element->isPluginElement()) {
......
...@@ -328,6 +328,7 @@ public: ...@@ -328,6 +328,7 @@ public:
Vector<String> getTransitionElementIds(); Vector<String> getTransitionElementIds();
PassRefPtrWillBeRawPtr<ClientRectList> getTransitionElementRects(); PassRefPtrWillBeRawPtr<ClientRectList> getTransitionElementRects();
void hideAllTransitionElements(); void hideAllTransitionElements();
void showAllTransitionElements();
unsigned countHitRegions(CanvasRenderingContext2D*); unsigned countHitRegions(CanvasRenderingContext2D*);
......
...@@ -286,6 +286,7 @@ ...@@ -286,6 +286,7 @@
DOMString[] getTransitionElementIds(); DOMString[] getTransitionElementIds();
ClientRectList getTransitionElementRects(); ClientRectList getTransitionElementRects();
void hideAllTransitionElements(); void hideAllTransitionElements();
void showAllTransitionElements();
[RaisesException, TypeChecking=Interface] void forcePluginPlaceholder(HTMLElement plugin, DocumentFragment fragment); [RaisesException, TypeChecking=Interface] void forcePluginPlaceholder(HTMLElement plugin, DocumentFragment fragment);
[RaisesException, TypeChecking=Interface] void forcePluginPlaceholder(HTMLElement plugin, Dictionary options); [RaisesException, TypeChecking=Interface] void forcePluginPlaceholder(HTMLElement plugin, Dictionary options);
......
...@@ -296,6 +296,18 @@ void WebDocument::beginExitTransition(const WebString& cssSelector) ...@@ -296,6 +296,18 @@ void WebDocument::beginExitTransition(const WebString& cssSelector)
document->styleEngine()->enableExitTransitionStylesheets(); document->styleEngine()->enableExitTransitionStylesheets();
} }
void WebDocument::hideTransitionElements(const WebString& cssSelector)
{
RefPtrWillBeRawPtr<Document> document = unwrap<Document>();
document->hideTransitionElements(cssSelector);
}
void WebDocument::showTransitionElements(const WebString& cssSelector)
{
RefPtrWillBeRawPtr<Document> document = unwrap<Document>();
document->hideTransitionElements(cssSelector);
}
WebAXObject WebDocument::accessibilityObject() const WebAXObject WebDocument::accessibilityObject() const
{ {
const Document* document = constUnwrap<Document>(); const Document* document = constUnwrap<Document>();
......
...@@ -121,6 +121,8 @@ public: ...@@ -121,6 +121,8 @@ public:
BLINK_EXPORT WebSize maximumScrollOffset() const; BLINK_EXPORT WebSize maximumScrollOffset() const;
BLINK_EXPORT void setIsTransitionDocument(); BLINK_EXPORT void setIsTransitionDocument();
BLINK_EXPORT void beginExitTransition(const WebString& cssSelector); BLINK_EXPORT void beginExitTransition(const WebString& cssSelector);
BLINK_EXPORT void hideTransitionElements(const WebString& cssSelector);
BLINK_EXPORT void showTransitionElements(const WebString& cssSelector);
// Accessibility support. These methods should only be called on the // Accessibility support. These methods should only be called on the
// top-level document, because one accessibility cache spans all of // top-level document, because one accessibility cache spans all of
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment