| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 #include "core/frame/EventHandlerRegistry.h" | 136 #include "core/frame/EventHandlerRegistry.h" |
| 137 #include "core/frame/FrameConsole.h" | 137 #include "core/frame/FrameConsole.h" |
| 138 #include "core/frame/History.h" | 138 #include "core/frame/History.h" |
| 139 #include "core/frame/HostsUsingFeatures.h" | 139 #include "core/frame/HostsUsingFeatures.h" |
| 140 #include "core/frame/LocalDOMWindow.h" | 140 #include "core/frame/LocalDOMWindow.h" |
| 141 #include "core/frame/LocalFrame.h" | 141 #include "core/frame/LocalFrame.h" |
| 142 #include "core/frame/LocalFrameClient.h" | 142 #include "core/frame/LocalFrameClient.h" |
| 143 #include "core/frame/LocalFrameView.h" | 143 #include "core/frame/LocalFrameView.h" |
| 144 #include "core/frame/PerformanceMonitor.h" | 144 #include "core/frame/PerformanceMonitor.h" |
| 145 #include "core/frame/Settings.h" | 145 #include "core/frame/Settings.h" |
| 146 #include "core/frame/VisualViewport.h" |
| 146 #include "core/frame/csp/ContentSecurityPolicy.h" | 147 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 147 #include "core/html/DocumentNameCollection.h" | 148 #include "core/html/DocumentNameCollection.h" |
| 148 #include "core/html/HTMLAllCollection.h" | 149 #include "core/html/HTMLAllCollection.h" |
| 149 #include "core/html/HTMLAnchorElement.h" | 150 #include "core/html/HTMLAnchorElement.h" |
| 150 #include "core/html/HTMLBaseElement.h" | 151 #include "core/html/HTMLBaseElement.h" |
| 151 #include "core/html/HTMLBodyElement.h" | 152 #include "core/html/HTMLBodyElement.h" |
| 152 #include "core/html/HTMLCanvasElement.h" | 153 #include "core/html/HTMLCanvasElement.h" |
| 153 #include "core/html/HTMLCollection.h" | 154 #include "core/html/HTMLCollection.h" |
| 154 #include "core/html/HTMLDialogElement.h" | 155 #include "core/html/HTMLDialogElement.h" |
| 155 #include "core/html/HTMLDocument.h" | 156 #include "core/html/HTMLDocument.h" |
| (...skipping 6280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6436 !request.TouchMove()) { | 6437 !request.TouchMove()) { |
| 6437 // We are setting the :active chain and freezing it. If future moves | 6438 // We are setting the :active chain and freezing it. If future moves |
| 6438 // happen, they will need to reference this chain. | 6439 // happen, they will need to reference this chain. |
| 6439 for (Element* element = new_active_element; element; | 6440 for (Element* element = new_active_element; element; |
| 6440 element = FlatTreeTraversal::ParentElement(*element)) { | 6441 element = FlatTreeTraversal::ParentElement(*element)) { |
| 6441 user_action_elements_.SetInActiveChain(element, true); | 6442 user_action_elements_.SetInActiveChain(element, true); |
| 6442 } | 6443 } |
| 6443 SetActiveHoverElement(new_active_element); | 6444 SetActiveHoverElement(new_active_element); |
| 6444 } | 6445 } |
| 6445 } | 6446 } |
| 6447 |
| 6448 // Do not set hover state if event is from touch and on mobile. |
| 6449 bool allow_hover_changes = |
| 6450 !(request.TouchEvent() && GetPage() && |
| 6451 GetPage()->GetVisualViewport().ShouldDisableDesktopWorkarounds()); |
| 6452 |
| 6446 // If the mouse has just been pressed, set :active on the chain. Those (and | 6453 // If the mouse has just been pressed, set :active on the chain. Those (and |
| 6447 // only those) nodes should remain :active until the mouse is released. | 6454 // only those) nodes should remain :active until the mouse is released. |
| 6448 bool allow_active_changes = !old_active_element && ActiveHoverElement(); | 6455 bool allow_active_changes = !old_active_element && ActiveHoverElement(); |
| 6449 | 6456 |
| 6450 // If the mouse is down and if this is a mouse move event, we want to restrict | 6457 // If the mouse is down and if this is a mouse move event, we want to restrict |
| 6451 // changes in :hover/:active to only apply to elements that are in the :active | 6458 // changes in :hover/:active to only apply to elements that are in the :active |
| 6452 // chain that we froze at the time the mouse went down. | 6459 // chain that we froze at the time the mouse went down. |
| 6453 bool must_be_in_active_chain = request.Active() && request.Move(); | 6460 bool must_be_in_active_chain = request.Active() && request.Move(); |
| 6454 | 6461 |
| 6455 Element* old_hover_element = HoverElement(); | 6462 Element* old_hover_element = HoverElement(); |
| 6456 | 6463 |
| 6457 // The passed in innerElement may not be a result of a hit test for the | 6464 // The passed in innerElement may not be a result of a hit test for the |
| 6458 // current up-to-date flat/layout tree. That means the element may be | 6465 // current up-to-date flat/layout tree. That means the element may be |
| 6459 // display:none at this point. Skip up the ancestor chain until we reach an | 6466 // display:none at this point. Skip up the ancestor chain until we reach an |
| 6460 // element with a layoutObject or a display:contents element. | 6467 // element with a layoutObject or a display:contents element. |
| 6461 Element* new_hover_element = | 6468 Element* new_hover_element = |
| 6462 SkipDisplayNoneAncestors(inner_element_in_document); | 6469 SkipDisplayNoneAncestors(inner_element_in_document); |
| 6463 | 6470 |
| 6464 // Update our current hover element. | 6471 // Update our current hover element. |
| 6465 SetHoverElement(new_hover_element); | 6472 if (allow_hover_changes) |
| 6473 SetHoverElement(new_hover_element); |
| 6466 | 6474 |
| 6467 Node* ancestor_element = nullptr; | 6475 Node* ancestor_element = nullptr; |
| 6468 if (old_hover_element && old_hover_element->isConnected() && | 6476 if (old_hover_element && old_hover_element->isConnected() && |
| 6469 new_hover_element) { | 6477 new_hover_element) { |
| 6470 Node* ancestor = FlatTreeTraversal::CommonAncestor(*old_hover_element, | 6478 Node* ancestor = FlatTreeTraversal::CommonAncestor(*old_hover_element, |
| 6471 *new_hover_element); | 6479 *new_hover_element); |
| 6472 if (ancestor && ancestor->IsElementNode()) | 6480 if (ancestor && ancestor->IsElementNode()) |
| 6473 ancestor_element = ToElement(ancestor); | 6481 ancestor_element = ToElement(ancestor); |
| 6474 } | 6482 } |
| 6475 | 6483 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 6496 } | 6504 } |
| 6497 } | 6505 } |
| 6498 | 6506 |
| 6499 // Now set the hover state for our new object up to the root. | 6507 // Now set the hover state for our new object up to the root. |
| 6500 for (Element* curr = new_hover_element; curr; | 6508 for (Element* curr = new_hover_element; curr; |
| 6501 curr = FlatTreeTraversal::ParentElement(*curr)) { | 6509 curr = FlatTreeTraversal::ParentElement(*curr)) { |
| 6502 if (!must_be_in_active_chain || curr->InActiveChain()) | 6510 if (!must_be_in_active_chain || curr->InActiveChain()) |
| 6503 elements_to_add_to_chain.push_back(curr); | 6511 elements_to_add_to_chain.push_back(curr); |
| 6504 } | 6512 } |
| 6505 | 6513 |
| 6506 for (Element* element : elements_to_remove_from_chain) | 6514 if (allow_hover_changes) { |
| 6507 element->SetHovered(false); | 6515 for (Element* element : elements_to_remove_from_chain) |
| 6516 element->SetHovered(false); |
| 6517 } |
| 6508 | 6518 |
| 6509 bool saw_common_ancestor = false; | 6519 bool saw_common_ancestor = false; |
| 6510 for (Element* element : elements_to_add_to_chain) { | 6520 for (Element* element : elements_to_add_to_chain) { |
| 6511 // Elements past the common ancestor do not change hover state, but might | 6521 // Elements past the common ancestor do not change hover state, but might |
| 6512 // change active state. | 6522 // change active state. |
| 6513 if (element == ancestor_element) | 6523 if (element == ancestor_element) |
| 6514 saw_common_ancestor = true; | 6524 saw_common_ancestor = true; |
| 6515 if (allow_active_changes) | 6525 if (allow_active_changes) |
| 6516 element->SetActive(true); | 6526 element->SetActive(true); |
| 6517 if (!saw_common_ancestor || element == hover_element_) | 6527 if (allow_hover_changes && |
| 6528 (!saw_common_ancestor || element == hover_element_)) |
| 6518 element->SetHovered(true); | 6529 element->SetHovered(true); |
| 6519 } | 6530 } |
| 6520 } | 6531 } |
| 6521 | 6532 |
| 6522 bool Document::HaveScriptBlockingStylesheetsLoaded() const { | 6533 bool Document::HaveScriptBlockingStylesheetsLoaded() const { |
| 6523 return style_engine_->HaveScriptBlockingStylesheetsLoaded(); | 6534 return style_engine_->HaveScriptBlockingStylesheetsLoaded(); |
| 6524 } | 6535 } |
| 6525 | 6536 |
| 6526 bool Document::HaveRenderBlockingStylesheetsLoaded() const { | 6537 bool Document::HaveRenderBlockingStylesheetsLoaded() const { |
| 6527 if (RuntimeEnabledFeatures::CSSInBodyDoesNotBlockPaintEnabled()) | 6538 if (RuntimeEnabledFeatures::CSSInBodyDoesNotBlockPaintEnabled()) |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6874 } | 6885 } |
| 6875 | 6886 |
| 6876 void showLiveDocumentInstances() { | 6887 void showLiveDocumentInstances() { |
| 6877 WeakDocumentSet& set = liveDocumentSet(); | 6888 WeakDocumentSet& set = liveDocumentSet(); |
| 6878 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6889 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6879 for (blink::Document* document : set) | 6890 for (blink::Document* document : set) |
| 6880 fprintf(stderr, "- Document %p URL: %s\n", document, | 6891 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6881 document->Url().GetString().Utf8().data()); | 6892 document->Url().GetString().Utf8().data()); |
| 6882 } | 6893 } |
| 6883 #endif | 6894 #endif |
| OLD | NEW |