OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All |
7 * rights reserved. | 7 * rights reserved. |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 return false; | 361 return false; |
362 | 362 |
363 // rule (d) above | 363 // rule (d) above |
364 CharDecompositionType decompType = decompositionType(c); | 364 CharDecompositionType decompType = decompositionType(c); |
365 if (decompType == DecompositionFont || decompType == DecompositionCompat) | 365 if (decompType == DecompositionFont || decompType == DecompositionCompat) |
366 return false; | 366 return false; |
367 | 367 |
368 return true; | 368 return true; |
369 } | 369 } |
370 | 370 |
371 static Widget* widgetForElement(const Element& focusedElement) { | 371 static FrameViewBase* widgetForElement(const Element& focusedElement) { |
372 LayoutObject* layoutObject = focusedElement.layoutObject(); | 372 LayoutObject* layoutObject = focusedElement.layoutObject(); |
373 if (!layoutObject || !layoutObject->isLayoutPart()) | 373 if (!layoutObject || !layoutObject->isLayoutPart()) |
374 return 0; | 374 return 0; |
375 return toLayoutPart(layoutObject)->widget(); | 375 return toLayoutPart(layoutObject)->widget(); |
376 } | 376 } |
377 | 377 |
378 static bool acceptsEditingFocus(const Element& element) { | 378 static bool acceptsEditingFocus(const Element& element) { |
379 DCHECK(hasEditableStyle(element)); | 379 DCHECK(hasEditableStyle(element)); |
380 | 380 |
381 return element.document().frame() && rootEditableElement(element); | 381 return element.document().frame() && rootEditableElement(element); |
(...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2053 styleEngine().updateActiveStyle(); | 2053 styleEngine().updateActiveStyle(); |
2054 } | 2054 } |
2055 | 2055 |
2056 void Document::updateStyle() { | 2056 void Document::updateStyle() { |
2057 DCHECK(!view()->shouldThrottleRendering()); | 2057 DCHECK(!view()->shouldThrottleRendering()); |
2058 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle"); | 2058 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle"); |
2059 double startTime = monotonicallyIncreasingTime(); | 2059 double startTime = monotonicallyIncreasingTime(); |
2060 | 2060 |
2061 unsigned initialElementCount = styleEngine().styleForElementCount(); | 2061 unsigned initialElementCount = styleEngine().styleForElementCount(); |
2062 | 2062 |
2063 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 2063 HTMLFrameOwnerElement::UpdateSuspendScope |
| 2064 suspendFrameViewBaseHierarchyUpdates; |
2064 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); | 2065 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); |
2065 | 2066 |
2066 StyleRecalcChange change = NoChange; | 2067 StyleRecalcChange change = NoChange; |
2067 if (getStyleChangeType() >= SubtreeStyleChange) | 2068 if (getStyleChangeType() >= SubtreeStyleChange) |
2068 change = Force; | 2069 change = Force; |
2069 | 2070 |
2070 NthIndexCache nthIndexCache(*this); | 2071 NthIndexCache nthIndexCache(*this); |
2071 | 2072 |
2072 // FIXME: Cannot access the ensureStyleResolver() before calling | 2073 // FIXME: Cannot access the ensureStyleResolver() before calling |
2073 // styleForDocument below because apparently the StyleResolver's constructor | 2074 // styleForDocument below because apparently the StyleResolver's constructor |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2449 RELEASE_ASSERT(!m_frame || m_frame->tree().childCount() == 0); | 2450 RELEASE_ASSERT(!m_frame || m_frame->tree().childCount() == 0); |
2450 if (!isActive()) | 2451 if (!isActive()) |
2451 return; | 2452 return; |
2452 | 2453 |
2453 // Frame navigation can cause a new Document to be attached. Don't allow that, | 2454 // Frame navigation can cause a new Document to be attached. Don't allow that, |
2454 // since that will cause a situation where LocalFrame still has a Document | 2455 // since that will cause a situation where LocalFrame still has a Document |
2455 // attached after this finishes! Normally, it shouldn't actually be possible | 2456 // attached after this finishes! Normally, it shouldn't actually be possible |
2456 // to trigger navigation here. However, plugins (see below) can cause lots of | 2457 // to trigger navigation here. However, plugins (see below) can cause lots of |
2457 // crazy things to happen, since plugin detach involves nested message loops. | 2458 // crazy things to happen, since plugin detach involves nested message loops. |
2458 FrameNavigationDisabler navigationDisabler(*m_frame); | 2459 FrameNavigationDisabler navigationDisabler(*m_frame); |
2459 // Defer widget updates to avoid plugins trying to run script inside | 2460 // Defer FrameViewBase updates to avoid plugins trying to run script inside |
2460 // ScriptForbiddenScope, which will crash the renderer after | 2461 // ScriptForbiddenScope, which will crash the renderer after |
2461 // https://crrev.com/200984 | 2462 // https://crrev.com/200984 |
2462 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 2463 HTMLFrameOwnerElement::UpdateSuspendScope |
| 2464 suspendFrameViewBaseHierarchyUpdates; |
2463 // Don't allow script to run in the middle of detachLayoutTree() because a | 2465 // Don't allow script to run in the middle of detachLayoutTree() because a |
2464 // detaching Document is not in a consistent state. | 2466 // detaching Document is not in a consistent state. |
2465 ScriptForbiddenScope forbidScript; | 2467 ScriptForbiddenScope forbidScript; |
2466 | 2468 |
2467 view()->dispose(); | 2469 view()->dispose(); |
2468 | 2470 |
2469 // If the widget of the document's frame owner doesn't match view() then | 2471 // If the FrameViewBase of the document's frame owner doesn't match view() |
2470 // FrameView::dispose() didn't clear the owner's widget. If we don't clear it | 2472 // then FrameView::dispose() didn't clear the owner's FrameViewBase. If we |
2471 // here, it may be clobbered later in LocalFrame::createView(). See also | 2473 // don't clear it here, it may be clobbered later in LocalFrame::createView(). |
2472 // https://crbug.com/673170 and the comment in FrameView::dispose(). | 2474 // See also https://crbug.com/673170 and the comment in FrameView::dispose(). |
2473 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); | 2475 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); |
2474 if (ownerElement) | 2476 if (ownerElement) |
2475 ownerElement->setWidget(nullptr); | 2477 ownerElement->setWidget(nullptr); |
2476 | 2478 |
2477 m_markers->prepareForDestruction(); | 2479 m_markers->prepareForDestruction(); |
2478 | 2480 |
2479 m_lifecycle.advanceTo(DocumentLifecycle::Stopping); | 2481 m_lifecycle.advanceTo(DocumentLifecycle::Stopping); |
2480 | 2482 |
2481 if (page()) | 2483 if (page()) |
2482 page()->documentDetached(this); | 2484 page()->documentDetached(this); |
(...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4029 params.sourceCapabilities); | 4031 params.sourceCapabilities); |
4030 | 4032 |
4031 if (m_focusedElement) { | 4033 if (m_focusedElement) { |
4032 // handler shifted focus | 4034 // handler shifted focus |
4033 focusChangeBlocked = true; | 4035 focusChangeBlocked = true; |
4034 newFocusedElement = nullptr; | 4036 newFocusedElement = nullptr; |
4035 } | 4037 } |
4036 } | 4038 } |
4037 | 4039 |
4038 if (view()) { | 4040 if (view()) { |
4039 Widget* oldWidget = widgetForElement(*oldFocusedElement); | 4041 FrameViewBase* oldFrameViewBase = widgetForElement(*oldFocusedElement); |
4040 if (oldWidget) | 4042 if (oldFrameViewBase) |
4041 oldWidget->setFocused(false, params.type); | 4043 oldFrameViewBase->setFocused(false, params.type); |
4042 else | 4044 else |
4043 view()->setFocused(false, params.type); | 4045 view()->setFocused(false, params.type); |
4044 } | 4046 } |
4045 } | 4047 } |
4046 | 4048 |
4047 if (newFocusedElement) | 4049 if (newFocusedElement) |
4048 updateStyleAndLayoutTreeForNode(newFocusedElement); | 4050 updateStyleAndLayoutTreeForNode(newFocusedElement); |
4049 if (newFocusedElement && newFocusedElement->isFocusable()) { | 4051 if (newFocusedElement && newFocusedElement->isFocusable()) { |
4050 if (isRootEditableElement(*newFocusedElement) && | 4052 if (isRootEditableElement(*newFocusedElement) && |
4051 !acceptsEditingFocus(*newFocusedElement)) { | 4053 !acceptsEditingFocus(*newFocusedElement)) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4103 goto SetFocusedElementDone; | 4105 goto SetFocusedElementDone; |
4104 } | 4106 } |
4105 } | 4107 } |
4106 | 4108 |
4107 if (isRootEditableElement(*m_focusedElement)) | 4109 if (isRootEditableElement(*m_focusedElement)) |
4108 frame()->spellChecker().didBeginEditing(m_focusedElement.get()); | 4110 frame()->spellChecker().didBeginEditing(m_focusedElement.get()); |
4109 | 4111 |
4110 // eww, I suck. set the qt focus correctly | 4112 // eww, I suck. set the qt focus correctly |
4111 // ### find a better place in the code for this | 4113 // ### find a better place in the code for this |
4112 if (view()) { | 4114 if (view()) { |
4113 Widget* focusWidget = widgetForElement(*m_focusedElement); | 4115 FrameViewBase* focusFrameViewBase = widgetForElement(*m_focusedElement); |
4114 if (focusWidget) { | 4116 if (focusFrameViewBase) { |
4115 // Make sure a widget has the right size before giving it focus. | 4117 // Make sure a FrameViewBase has the right size before giving it focus. |
4116 // Otherwise, we are testing edge cases of the Widget code. | 4118 // Otherwise, we are testing edge cases of the FrameViewBase code. |
4117 // Specifically, in WebCore this does not work well for text fields. | 4119 // Specifically, in WebCore this does not work well for text fields. |
4118 updateStyleAndLayout(); | 4120 updateStyleAndLayout(); |
4119 // Re-get the widget in case updating the layout changed things. | 4121 // Re-get the FrameViewBase in case updating the layout changed things. |
4120 focusWidget = widgetForElement(*m_focusedElement); | 4122 focusFrameViewBase = widgetForElement(*m_focusedElement); |
4121 } | 4123 } |
4122 if (focusWidget) | 4124 if (focusFrameViewBase) |
4123 focusWidget->setFocused(true, params.type); | 4125 focusFrameViewBase->setFocused(true, params.type); |
4124 else | 4126 else |
4125 view()->setFocused(true, params.type); | 4127 view()->setFocused(true, params.type); |
4126 } | 4128 } |
4127 } | 4129 } |
4128 | 4130 |
4129 if (!focusChangeBlocked && m_focusedElement) { | 4131 if (!focusChangeBlocked && m_focusedElement) { |
4130 // Create the AXObject cache in a focus change because Chromium relies on | 4132 // Create the AXObject cache in a focus change because Chromium relies on |
4131 // it. | 4133 // it. |
4132 if (AXObjectCache* cache = axObjectCache()) | 4134 if (AXObjectCache* cache = axObjectCache()) |
4133 cache->handleFocusedUIElementChanged(oldFocusedElement, | 4135 cache->handleFocusedUIElementChanged(oldFocusedElement, |
(...skipping 2525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6659 } | 6661 } |
6660 | 6662 |
6661 void showLiveDocumentInstances() { | 6663 void showLiveDocumentInstances() { |
6662 WeakDocumentSet& set = liveDocumentSet(); | 6664 WeakDocumentSet& set = liveDocumentSet(); |
6663 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6665 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
6664 for (blink::Document* document : set) | 6666 for (blink::Document* document : set) |
6665 fprintf(stderr, "- Document %p URL: %s\n", document, | 6667 fprintf(stderr, "- Document %p URL: %s\n", document, |
6666 document->url().getString().utf8().data()); | 6668 document->url().getString().utf8().data()); |
6667 } | 6669 } |
6668 #endif | 6670 #endif |
OLD | NEW |