diff options
author | Leon Clarke <leonclarke@google.com> | 2010-06-03 14:33:32 +0100 |
---|---|---|
committer | Leon Clarke <leonclarke@google.com> | 2010-06-08 12:24:51 +0100 |
commit | 5af96e2c7b73ebc627c6894727826a7576d31758 (patch) | |
tree | f9d5e6f6175ccd7e3d14de9b290f08937a0d17ba /WebCore/page | |
parent | 8cc4fcf4f6adcbc0e0aebfc24fbad9a4cddf2cfb (diff) | |
download | external_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.zip external_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.tar.gz external_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.tar.bz2 |
Merge webkit.org at r60469 : Initial merge by git.
Change-Id: I66a0047aa2af802f66bb0c7f2a8b02247a596234
Diffstat (limited to 'WebCore/page')
-rw-r--r-- | WebCore/page/Console.cpp | 13 | ||||
-rw-r--r-- | WebCore/page/Console.h | 2 | ||||
-rw-r--r-- | WebCore/page/Console.idl | 1 | ||||
-rw-r--r-- | WebCore/page/DOMSelection.cpp | 14 | ||||
-rw-r--r-- | WebCore/page/DOMTimer.cpp | 42 | ||||
-rw-r--r-- | WebCore/page/DOMTimer.h | 14 | ||||
-rw-r--r-- | WebCore/page/DOMWindow.cpp | 20 | ||||
-rw-r--r-- | WebCore/page/DragController.cpp | 7 | ||||
-rw-r--r-- | WebCore/page/EventHandler.cpp | 316 | ||||
-rw-r--r-- | WebCore/page/EventHandler.h | 7 | ||||
-rw-r--r-- | WebCore/page/Frame.cpp | 59 | ||||
-rw-r--r-- | WebCore/page/Frame.h | 40 | ||||
-rw-r--r-- | WebCore/page/FrameTree.cpp | 2 | ||||
-rw-r--r-- | WebCore/page/FrameView.cpp | 80 | ||||
-rw-r--r-- | WebCore/page/FrameView.h | 12 | ||||
-rw-r--r-- | WebCore/page/Geolocation.cpp | 11 | ||||
-rw-r--r-- | WebCore/page/Geolocation.h | 2 | ||||
-rw-r--r-- | WebCore/page/Page.cpp | 16 | ||||
-rw-r--r-- | WebCore/page/Page.h | 6 | ||||
-rw-r--r-- | WebCore/page/SuspendableTimer.cpp | 83 | ||||
-rw-r--r-- | WebCore/page/SuspendableTimer.h | 60 | ||||
-rw-r--r-- | WebCore/page/animation/AnimationBase.cpp | 4 |
22 files changed, 480 insertions, 331 deletions
diff --git a/WebCore/page/Console.cpp b/WebCore/page/Console.cpp index 864b834..1d6c095 100644 --- a/WebCore/page/Console.cpp +++ b/WebCore/page/Console.cpp @@ -427,6 +427,19 @@ void Console::group(ScriptCallStack* callStack) #endif } +void Console::groupCollapsed(ScriptCallStack* callStack) +{ +#if ENABLE(INSPECTOR) + Page* page = this->page(); + if (!page) + return; + + page->inspectorController()->startGroup(JSMessageSource, callStack, true); +#else + UNUSED_PARAM(callStack); +#endif +} + void Console::groupEnd() { #if ENABLE(INSPECTOR) diff --git a/WebCore/page/Console.h b/WebCore/page/Console.h index 9a6d88c..18e311f 100644 --- a/WebCore/page/Console.h +++ b/WebCore/page/Console.h @@ -62,6 +62,7 @@ enum MessageType { ObjectMessageType, TraceMessageType, StartGroupMessageType, + StartGroupCollapsedMessageType, EndGroupMessageType, AssertMessageType }; @@ -104,6 +105,7 @@ public: void time(const String&); void timeEnd(const String&, ScriptCallStack*); void group(ScriptCallStack*); + void groupCollapsed(ScriptCallStack*); void groupEnd(); static bool shouldPrintExceptions(); diff --git a/WebCore/page/Console.idl b/WebCore/page/Console.idl index b3c0c24..9a7cdc0 100644 --- a/WebCore/page/Console.idl +++ b/WebCore/page/Console.idl @@ -58,6 +58,7 @@ module window { void time(in [ConvertUndefinedOrNullToNullString] DOMString title); [CustomArgumentHandling] void timeEnd(in [ConvertUndefinedOrNullToNullString] DOMString title); [CustomArgumentHandling] void group(); + [CustomArgumentHandling] void groupCollapsed(); void groupEnd(); }; diff --git a/WebCore/page/DOMSelection.cpp b/WebCore/page/DOMSelection.cpp index a583176..d62051e 100644 --- a/WebCore/page/DOMSelection.cpp +++ b/WebCore/page/DOMSelection.cpp @@ -280,21 +280,21 @@ void DOMSelection::modify(const String& alterString, const String& directionStri SelectionController::EAlteration alter; if (equalIgnoringCase(alterString, "extend")) - alter = SelectionController::EXTEND; + alter = SelectionController::AlterationExtend; else if (equalIgnoringCase(alterString, "move")) - alter = SelectionController::MOVE; + alter = SelectionController::AlterationMove; else return; SelectionController::EDirection direction; if (equalIgnoringCase(directionString, "forward")) - direction = SelectionController::FORWARD; + direction = SelectionController::DirectionForward; else if (equalIgnoringCase(directionString, "backward")) - direction = SelectionController::BACKWARD; + direction = SelectionController::DirectionBackward; else if (equalIgnoringCase(directionString, "left")) - direction = SelectionController::LEFT; + direction = SelectionController::DirectionLeft; else if (equalIgnoringCase(directionString, "right")) - direction = SelectionController::RIGHT; + direction = SelectionController::DirectionRight; else return; @@ -424,7 +424,7 @@ void DOMSelection::deleteFromDocument() return; if (isCollapsed()) - selection->modify(SelectionController::EXTEND, SelectionController::BACKWARD, CharacterGranularity); + selection->modify(SelectionController::AlterationExtend, SelectionController::DirectionBackward, CharacterGranularity); RefPtr<Range> selectedRange = selection->selection().toNormalizedRange(); diff --git a/WebCore/page/DOMTimer.cpp b/WebCore/page/DOMTimer.cpp index 72dc9ac..eb7f84e 100644 --- a/WebCore/page/DOMTimer.cpp +++ b/WebCore/page/DOMTimer.cpp @@ -44,13 +44,8 @@ double DOMTimer::s_minTimerInterval = 0.010; // 10 milliseconds static int timerNestingLevel = 0; DOMTimer::DOMTimer(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int timeout, bool singleShot) - : ActiveDOMObject(context, this) + : SuspendableTimer(context) , m_action(action) - , m_nextFireInterval(0) - , m_repeatInterval(0) -#if !ASSERT_DISABLED - , m_suspended(false) -#endif { static int lastUsedTimeoutId = 0; ++lastUsedTimeoutId; @@ -155,50 +150,19 @@ void DOMTimer::fired() timerNestingLevel = 0; } -bool DOMTimer::hasPendingActivity() const -{ - return isActive(); -} - void DOMTimer::contextDestroyed() { - ActiveDOMObject::contextDestroyed(); + SuspendableTimer::contextDestroyed(); delete this; } void DOMTimer::stop() { - TimerBase::stop(); + SuspendableTimer::stop(); // Need to release JS objects potentially protected by ScheduledAction // because they can form circular references back to the ScriptExecutionContext // which will cause a memory leak. m_action.clear(); } -void DOMTimer::suspend() -{ -#if !ASSERT_DISABLED - ASSERT(!m_suspended); - m_suspended = true; -#endif - m_nextFireInterval = nextFireInterval(); - m_repeatInterval = repeatInterval(); - TimerBase::stop(); -} - -void DOMTimer::resume() -{ -#if !ASSERT_DISABLED - ASSERT(m_suspended); - m_suspended = false; -#endif - start(m_nextFireInterval, m_repeatInterval); -} - - -bool DOMTimer::canSuspend() const -{ - return true; -} - } // namespace WebCore diff --git a/WebCore/page/DOMTimer.h b/WebCore/page/DOMTimer.h index da38178..dc793da 100644 --- a/WebCore/page/DOMTimer.h +++ b/WebCore/page/DOMTimer.h @@ -27,9 +27,8 @@ #ifndef DOMTimer_h #define DOMTimer_h -#include "ActiveDOMObject.h" #include "ScheduledAction.h" -#include "Timer.h" +#include "SuspendableTimer.h" #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> @@ -37,7 +36,7 @@ namespace WebCore { class InspectorTimelineAgent; - class DOMTimer : public TimerBase, public ActiveDOMObject { + class DOMTimer : public SuspendableTimer { public: virtual ~DOMTimer(); // Creates a new timer owned by specified ScriptExecutionContext, starts it @@ -46,12 +45,8 @@ namespace WebCore { static void removeById(ScriptExecutionContext*, int timeoutId); // ActiveDOMObject - virtual bool hasPendingActivity() const; virtual void contextDestroyed(); virtual void stop(); - virtual bool canSuspend() const; - virtual void suspend(); - virtual void resume(); // The lowest allowable timer setting (in seconds, 0.001 == 1 ms). // Default is 10ms. @@ -66,11 +61,6 @@ namespace WebCore { int m_timeoutId; int m_nestingLevel; OwnPtr<ScheduledAction> m_action; - double m_nextFireInterval; - double m_repeatInterval; -#if !ASSERT_DISABLED - bool m_suspended; -#endif static double s_minTimerInterval; }; diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp index a564cf4..7f3151d 100644 --- a/WebCore/page/DOMWindow.cpp +++ b/WebCore/page/DOMWindow.cpp @@ -954,11 +954,15 @@ int DOMWindow::innerHeight() const if (!view) return 0; +<<<<<<< HEAD #if PLATFORM(ANDROID) return static_cast<int>(view->actualHeight() / m_frame->pageZoomFactor()); #else return static_cast<int>(view->height() / m_frame->pageZoomFactor()); #endif +======= + return static_cast<int>(view->height() / view->pageZoomFactor()); +>>>>>>> webkit.org at r60469 } int DOMWindow::innerWidth() const @@ -970,11 +974,15 @@ int DOMWindow::innerWidth() const if (!view) return 0; +<<<<<<< HEAD #if PLATFORM(ANDROID) return static_cast<int>(view->actualWidth() / m_frame->pageZoomFactor()); #else return static_cast<int>(view->width() / m_frame->pageZoomFactor()); #endif +======= + return static_cast<int>(view->width() / view->pageZoomFactor()); +>>>>>>> webkit.org at r60469 } int DOMWindow::screenX() const @@ -1012,11 +1020,15 @@ int DOMWindow::scrollX() const m_frame->document()->updateLayoutIgnorePendingStylesheets(); +<<<<<<< HEAD #if PLATFORM(ANDROID) return static_cast<int>(view->actualScrollX() / m_frame->pageZoomFactor()); #else return static_cast<int>(view->scrollX() / m_frame->pageZoomFactor()); #endif +======= + return static_cast<int>(view->scrollX() / view->pageZoomFactor()); +>>>>>>> webkit.org at r60469 } int DOMWindow::scrollY() const @@ -1030,11 +1042,15 @@ int DOMWindow::scrollY() const m_frame->document()->updateLayoutIgnorePendingStylesheets(); +<<<<<<< HEAD #if PLATFORM(ANDROID) return static_cast<int>(view->actualScrollY() / m_frame->pageZoomFactor()); #else return static_cast<int>(view->scrollY() / m_frame->pageZoomFactor()); #endif +======= + return static_cast<int>(view->scrollY() / view->pageZoomFactor()); +>>>>>>> webkit.org at r60469 } bool DOMWindow::closed() const @@ -1256,8 +1272,8 @@ void DOMWindow::scrollTo(int x, int y) const if (!view) return; - int zoomedX = static_cast<int>(x * m_frame->pageZoomFactor()); - int zoomedY = static_cast<int>(y * m_frame->pageZoomFactor()); + int zoomedX = static_cast<int>(x * view->pageZoomFactor()); + int zoomedY = static_cast<int>(y * view->pageZoomFactor()); view->setScrollPosition(IntPoint(zoomedX, zoomedY)); } diff --git a/WebCore/page/DragController.cpp b/WebCore/page/DragController.cpp index c603996..ec69ea0 100644 --- a/WebCore/page/DragController.cpp +++ b/WebCore/page/DragController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -268,7 +268,8 @@ static HTMLInputElement* asFileInput(Node* node) static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint& p) { - float zoomFactor = documentUnderMouse->frame()->pageZoomFactor(); + FrameView* view = documentUnderMouse->view(); + float zoomFactor = view ? view->pageZoomFactor() : 1; IntPoint point = roundedIntPoint(FloatPoint(p.x() * zoomFactor, p.y() * zoomFactor)); HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active); @@ -397,7 +398,7 @@ bool DragController::concludeEditDrag(DragData* dragData) } if (HTMLInputElement* fileInput = asFileInput(element)) { - if (!fileInput->isEnabledFormControl()) + if (fileInput->disabled()) return false; if (!dragData->containsFiles()) diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp index 579cecc..266881c 100644 --- a/WebCore/page/EventHandler.cpp +++ b/WebCore/page/EventHandler.cpp @@ -186,7 +186,7 @@ EventHandler::EventHandler(Frame* frame) , m_svgPan(false) #endif , m_resizeLayer(0) - , m_capturingMouseEventsNode(0) + , m_eventHandlerWillResetCapturingMouseEventsNode(0) , m_clickCount(0) , m_mouseDownTimestamp(0) , m_useLatchedWheelEventNode(false) @@ -440,8 +440,8 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve return true; #if ENABLE(SVG) - if (m_frame->document()->isSVGDocument() && - static_cast<SVGDocument*>(m_frame->document())->zoomAndPanEnabled()) { + if (m_frame->document()->isSVGDocument() + && static_cast<SVGDocument*>(m_frame->document())->zoomAndPanEnabled()) { if (event.event().shiftKey() && singleClick) { m_svgPan = true; static_cast<SVGDocument*>(m_frame->document())->startPan(event.event().pos()); @@ -473,8 +473,8 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve else swallowEvent = handleMousePressEventSingleClick(event); - m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect || - (m_mousePressNode && m_mousePressNode->renderBox() && m_mousePressNode->renderBox()->canBeProgramaticallyScrolled(true)); + m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect + || (m_mousePressNode && m_mousePressNode->renderBox() && m_mousePressNode->renderBox()->canBeProgramaticallyScrolled(true)); return swallowEvent; } @@ -695,7 +695,7 @@ bool EventHandler::handleMouseReleaseEvent(const MouseEventWithHitTestResults& e && m_frame->selection()->isRange() && event.event().button() != RightButton) { VisibleSelection newSelection; - Node *node = event.targetNode(); + Node* node = event.targetNode(); bool caretBrowsing = m_frame->settings()->caretBrowsingEnabled(); if (node && (caretBrowsing || node->isContentEditable()) && node->renderer()) { VisiblePosition pos = node->renderer()->positionForPoint(event.localPoint()); @@ -816,7 +816,7 @@ void EventHandler::updatePanScrollState() view->setCursor(middlePanningCursor()); } -#endif // ENABLE(PAN_SCROLLING) +#endif // ENABLE(PAN_SCROLLING) RenderObject* EventHandler::autoscrollRenderer() const { @@ -990,9 +990,13 @@ void EventHandler::setMousePressNode(PassRefPtr<Node> node) m_mousePressNode = node; } -bool EventHandler::scrollOverflow(ScrollDirection direction, ScrollGranularity granularity) +bool EventHandler::scrollOverflow(ScrollDirection direction, ScrollGranularity granularity, Node* startingNode) { - Node* node = m_frame->document()->focusedNode(); + Node* node = startingNode; + + if (!node) + node = m_frame->document()->focusedNode(); + if (!node) node = m_mousePressNode.get(); @@ -1007,9 +1011,9 @@ bool EventHandler::scrollOverflow(ScrollDirection direction, ScrollGranularity g return false; } -bool EventHandler::scrollRecursively(ScrollDirection direction, ScrollGranularity granularity) +bool EventHandler::scrollRecursively(ScrollDirection direction, ScrollGranularity granularity, Node* startingNode) { - bool handled = scrollOverflow(direction, granularity); + bool handled = scrollOverflow(direction, granularity, startingNode); if (!handled) { Frame* frame = m_frame; do { @@ -1103,117 +1107,117 @@ Cursor EventHandler::selectCursor(const MouseEventWithHitTestResults& event, Scr } switch (style ? style->cursor() : CURSOR_AUTO) { - case CURSOR_AUTO: { - bool editable = (node && node->isContentEditable()); - bool editableLinkEnabled = false; - - // If the link is editable, then we need to check the settings to see whether or not the link should be followed - if (editable) { - ASSERT(m_frame->settings()); - switch (m_frame->settings()->editableLinkBehavior()) { - default: - case EditableLinkDefaultBehavior: - case EditableLinkAlwaysLive: - editableLinkEnabled = true; - break; - - case EditableLinkNeverLive: - editableLinkEnabled = false; - break; - - case EditableLinkLiveWhenNotFocused: - editableLinkEnabled = nodeIsNotBeingEdited(node, m_frame) || event.event().shiftKey(); - break; - - case EditableLinkOnlyLiveWithShiftKey: - editableLinkEnabled = event.event().shiftKey(); - break; - } - } + case CURSOR_AUTO: { + bool editable = (node && node->isContentEditable()); + bool editableLinkEnabled = false; + + // If the link is editable, then we need to check the settings to see whether or not the link should be followed + if (editable) { + ASSERT(m_frame->settings()); + switch (m_frame->settings()->editableLinkBehavior()) { + default: + case EditableLinkDefaultBehavior: + case EditableLinkAlwaysLive: + editableLinkEnabled = true; + break; + + case EditableLinkNeverLive: + editableLinkEnabled = false; + break; + + case EditableLinkLiveWhenNotFocused: + editableLinkEnabled = nodeIsNotBeingEdited(node, m_frame) || event.event().shiftKey(); + break; - if ((event.isOverLink() || isSubmitImage(node)) && (!editable || editableLinkEnabled)) - return handCursor(); - bool inResizer = false; - if (renderer) { - if (RenderLayer* layer = renderer->enclosingLayer()) { - if (FrameView* view = m_frame->view()) - inResizer = layer->isPointInResizeControl(view->windowToContents(event.event().pos())); - } + case EditableLinkOnlyLiveWithShiftKey: + editableLinkEnabled = event.event().shiftKey(); + break; } - if ((editable || (renderer && renderer->isText() && node->canStartSelection())) && !inResizer && !scrollbar) - return iBeamCursor(); - return pointerCursor(); } - case CURSOR_CROSS: - return crossCursor(); - case CURSOR_POINTER: + + if ((event.isOverLink() || isSubmitImage(node)) && (!editable || editableLinkEnabled)) return handCursor(); - case CURSOR_MOVE: - return moveCursor(); - case CURSOR_ALL_SCROLL: - return moveCursor(); - case CURSOR_E_RESIZE: - return eastResizeCursor(); - case CURSOR_W_RESIZE: - return westResizeCursor(); - case CURSOR_N_RESIZE: - return northResizeCursor(); - case CURSOR_S_RESIZE: - return southResizeCursor(); - case CURSOR_NE_RESIZE: - return northEastResizeCursor(); - case CURSOR_SW_RESIZE: - return southWestResizeCursor(); - case CURSOR_NW_RESIZE: - return northWestResizeCursor(); - case CURSOR_SE_RESIZE: - return southEastResizeCursor(); - case CURSOR_NS_RESIZE: - return northSouthResizeCursor(); - case CURSOR_EW_RESIZE: - return eastWestResizeCursor(); - case CURSOR_NESW_RESIZE: - return northEastSouthWestResizeCursor(); - case CURSOR_NWSE_RESIZE: - return northWestSouthEastResizeCursor(); - case CURSOR_COL_RESIZE: - return columnResizeCursor(); - case CURSOR_ROW_RESIZE: - return rowResizeCursor(); - case CURSOR_TEXT: + bool inResizer = false; + if (renderer) { + if (RenderLayer* layer = renderer->enclosingLayer()) { + if (FrameView* view = m_frame->view()) + inResizer = layer->isPointInResizeControl(view->windowToContents(event.event().pos())); + } + } + if ((editable || (renderer && renderer->isText() && node->canStartSelection())) && !inResizer && !scrollbar) return iBeamCursor(); - case CURSOR_WAIT: - return waitCursor(); - case CURSOR_HELP: - return helpCursor(); - case CURSOR_VERTICAL_TEXT: - return verticalTextCursor(); - case CURSOR_CELL: - return cellCursor(); - case CURSOR_CONTEXT_MENU: - return contextMenuCursor(); - case CURSOR_PROGRESS: - return progressCursor(); - case CURSOR_NO_DROP: - return noDropCursor(); - case CURSOR_ALIAS: - return aliasCursor(); - case CURSOR_COPY: - return copyCursor(); - case CURSOR_NONE: - return noneCursor(); - case CURSOR_NOT_ALLOWED: - return notAllowedCursor(); - case CURSOR_DEFAULT: - return pointerCursor(); - case CURSOR_WEBKIT_ZOOM_IN: - return zoomInCursor(); - case CURSOR_WEBKIT_ZOOM_OUT: - return zoomOutCursor(); - case CURSOR_WEBKIT_GRAB: - return grabCursor(); - case CURSOR_WEBKIT_GRABBING: - return grabbingCursor(); + return pointerCursor(); + } + case CURSOR_CROSS: + return crossCursor(); + case CURSOR_POINTER: + return handCursor(); + case CURSOR_MOVE: + return moveCursor(); + case CURSOR_ALL_SCROLL: + return moveCursor(); + case CURSOR_E_RESIZE: + return eastResizeCursor(); + case CURSOR_W_RESIZE: + return westResizeCursor(); + case CURSOR_N_RESIZE: + return northResizeCursor(); + case CURSOR_S_RESIZE: + return southResizeCursor(); + case CURSOR_NE_RESIZE: + return northEastResizeCursor(); + case CURSOR_SW_RESIZE: + return southWestResizeCursor(); + case CURSOR_NW_RESIZE: + return northWestResizeCursor(); + case CURSOR_SE_RESIZE: + return southEastResizeCursor(); + case CURSOR_NS_RESIZE: + return northSouthResizeCursor(); + case CURSOR_EW_RESIZE: + return eastWestResizeCursor(); + case CURSOR_NESW_RESIZE: + return northEastSouthWestResizeCursor(); + case CURSOR_NWSE_RESIZE: + return northWestSouthEastResizeCursor(); + case CURSOR_COL_RESIZE: + return columnResizeCursor(); + case CURSOR_ROW_RESIZE: + return rowResizeCursor(); + case CURSOR_TEXT: + return iBeamCursor(); + case CURSOR_WAIT: + return waitCursor(); + case CURSOR_HELP: + return helpCursor(); + case CURSOR_VERTICAL_TEXT: + return verticalTextCursor(); + case CURSOR_CELL: + return cellCursor(); + case CURSOR_CONTEXT_MENU: + return contextMenuCursor(); + case CURSOR_PROGRESS: + return progressCursor(); + case CURSOR_NO_DROP: + return noDropCursor(); + case CURSOR_ALIAS: + return aliasCursor(); + case CURSOR_COPY: + return copyCursor(); + case CURSOR_NONE: + return noneCursor(); + case CURSOR_NOT_ALLOWED: + return notAllowedCursor(); + case CURSOR_DEFAULT: + return pointerCursor(); + case CURSOR_WEBKIT_ZOOM_IN: + return zoomInCursor(); + case CURSOR_WEBKIT_ZOOM_OUT: + return zoomOutCursor(); + case CURSOR_WEBKIT_GRAB: + return grabCursor(); + case CURSOR_WEBKIT_GRABBING: + return grabbingCursor(); } return pointerCursor(); } @@ -1279,8 +1283,10 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) // Start capturing future events for this frame. We only do this if we didn't clear // the m_mousePressed flag, which may happen if an AppKit widget entered a modal event loop. m_capturesDragging = subframe->eventHandler()->capturesDragging(); - if (m_mousePressed && m_capturesDragging) + if (m_mousePressed && m_capturesDragging) { m_capturingMouseEventsNode = mev.targetNode(); + m_eventHandlerWillResetCapturingMouseEventsNode = true; + } invalidateClick(); return true; } @@ -1372,10 +1378,10 @@ bool EventHandler::handleMouseDoubleClickEvent(const PlatformMouseEvent& mouseEv HitTestRequest request(HitTestRequest::Active); MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); Frame* subframe = subframeForHitTestResult(mev); - if (subframe && passMousePressEventToSubframe(mev, subframe)) { + if (m_eventHandlerWillResetCapturingMouseEventsNode) m_capturingMouseEventsNode = 0; + if (subframe && passMousePressEventToSubframe(mev, subframe)) return true; - } m_clickCount = mouseEvent.clickCount(); bool swallowMouseUpEvent = dispatchMouseEvent(eventNames().mouseupEvent, mev.targetNode(), true, m_clickCount, mouseEvent, false); @@ -1563,10 +1569,10 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent) HitTestRequest request(HitTestRequest::MouseUp); MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); Frame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetNode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); - if (subframe && passMouseReleaseEventToSubframe(mev, subframe)) { + if (m_eventHandlerWillResetCapturingMouseEventsNode) m_capturingMouseEventsNode = 0; + if (subframe && passMouseReleaseEventToSubframe(mev, subframe)) return true; - } bool swallowMouseUpEvent = dispatchMouseEvent(eventNames().mouseupEvent, mev.targetNode(), true, m_clickCount, mouseEvent, false); @@ -1621,15 +1627,15 @@ bool EventHandler::canHandleDragAndDropForTarget(DragAndDropHandleType type, Nod Frame* frame = static_cast<HTMLFrameElementBase*>(target)->contentFrame(); if (frame) { switch (type) { - case UpdateDragAndDrop: - wasAccepted = frame->eventHandler()->updateDragAndDrop(event, clipboard); - break; - case CancelDragAndDrop: - frame->eventHandler()->cancelDragAndDrop(event, clipboard); - break; - case PerformDragAndDrop: - wasAccepted = frame->eventHandler()->performDragAndDrop(event, clipboard); - break; + case UpdateDragAndDrop: + wasAccepted = frame->eventHandler()->updateDragAndDrop(event, clipboard); + break; + case CancelDragAndDrop: + frame->eventHandler()->cancelDragAndDrop(event, clipboard); + break; + case PerformDragAndDrop: + wasAccepted = frame->eventHandler()->performDragAndDrop(event, clipboard); + break; } } } else @@ -1730,6 +1736,7 @@ void EventHandler::clearDragState() void EventHandler::setCapturingMouseEventsNode(PassRefPtr<Node> n) { m_capturingMouseEventsNode = n; + m_eventHandlerWillResetCapturingMouseEventsNode = false; } MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestRequest& request, const PlatformMouseEvent& mev) @@ -1874,9 +1881,9 @@ bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targe // will set a selection inside it, which will call setFocuseNodeIfNeeded. ExceptionCode ec = 0; Node* n = node->isShadowNode() ? node->shadowParentNode() : node; - if (m_frame->selection()->isRange() && - m_frame->selection()->toNormalizedRange()->compareNode(n, ec) == Range::NODE_INSIDE && - n->isDescendantOf(m_frame->document()->focusedNode())) + if (m_frame->selection()->isRange() + && m_frame->selection()->toNormalizedRange()->compareNode(n, ec) == Range::NODE_INSIDE + && n->isDescendantOf(m_frame->document()->focusedNode())) return false; break; @@ -1926,7 +1933,6 @@ bool EventHandler::handleWheelEvent(PlatformWheelEvent& e) Node* node; bool isOverWidget; - bool didSetLatchedNode = false; HitTestRequest request(HitTestRequest::ReadOnly); HitTestResult result(vPoint); @@ -1936,7 +1942,6 @@ bool EventHandler::handleWheelEvent(PlatformWheelEvent& e) if (!m_latchedWheelEventNode) { m_latchedWheelEventNode = result.innerNode(); m_widgetIsLatched = result.isOverWidget(); - didSetLatchedNode = true; } node = m_latchedWheelEventNode.get(); @@ -2019,11 +2024,11 @@ bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event) // FIXME: This should probably be configurable by embedders. Consider making it a WebPreferences setting. // See: https://bugs.webkit.org/show_bug.cgi?id=15279 #if !PLATFORM(GTK) && !PLATFORM(CHROMIUM) - if (!m_frame->selection()->contains(viewportPos) && + if (!m_frame->selection()->contains(viewportPos) // FIXME: In the editable case, word selection sometimes selects content that isn't underneath the mouse. // If the selection is non-editable, we do word selection to make it easier to use the contextual menu items // available for text selections. But only if we're above text. - (m_frame->selection()->isContentEditable() || (mev.targetNode() && mev.targetNode()->isTextNode()))) { + && (m_frame->selection()->isContentEditable() || (mev.targetNode() && mev.targetNode()->isTextNode()))) { m_mouseDownMayStartSelect = true; // context menu events are always allowed to perform a selection selectClosestWordOrLinkFromMouseEvent(mev); } @@ -2303,19 +2308,16 @@ void EventHandler::handleKeyboardSelectionMovement(KeyboardEvent* event) bool isCommanded = event->getModifierState("Meta"); if (key == "Up") { - m_frame->selection()->modify((isShifted) ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::BACKWARD, (isCommanded) ? DocumentBoundary : LineGranularity, true); + m_frame->selection()->modify((isShifted) ? SelectionController::AlterationExtend : SelectionController::AlterationMove, SelectionController::DirectionBackward, (isCommanded) ? DocumentBoundary : LineGranularity, true); event->setDefaultHandled(); - } - else if (key == "Down") { - m_frame->selection()->modify((isShifted) ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::FORWARD, (isCommanded) ? DocumentBoundary : LineGranularity, true); + } else if (key == "Down") { + m_frame->selection()->modify((isShifted) ? SelectionController::AlterationExtend : SelectionController::AlterationMove, SelectionController::DirectionForward, (isCommanded) ? DocumentBoundary : LineGranularity, true); event->setDefaultHandled(); - } - else if (key == "Left") { - m_frame->selection()->modify((isShifted) ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::LEFT, (isCommanded) ? LineBoundary : (isOptioned) ? WordGranularity : CharacterGranularity, true); + } else if (key == "Left") { + m_frame->selection()->modify((isShifted) ? SelectionController::AlterationExtend : SelectionController::AlterationMove, SelectionController::DirectionLeft, (isCommanded) ? LineBoundary : (isOptioned) ? WordGranularity : CharacterGranularity, true); event->setDefaultHandled(); - } - else if (key == "Right") { - m_frame->selection()->modify((isShifted) ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::RIGHT, (isCommanded) ? LineBoundary : (isOptioned) ? WordGranularity : CharacterGranularity, true); + } else if (key == "Right") { + m_frame->selection()->modify((isShifted) ? SelectionController::AlterationExtend : SelectionController::AlterationMove, SelectionController::DirectionRight, (isCommanded) ? LineBoundary : (isOptioned) ? WordGranularity : CharacterGranularity, true); event->setDefaultHandled(); } } @@ -2447,7 +2449,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event) if (m_mouseDownMayStartDrag && !dragState().m_dragSrc) { allowDHTMLDrag(dragState().m_dragSrcMayBeDHTML, dragState().m_dragSrcMayBeUA); if (!dragState().m_dragSrcMayBeDHTML && !dragState().m_dragSrcMayBeUA) - m_mouseDownMayStartDrag = false; // no element is draggable + m_mouseDownMayStartDrag = false; // no element is draggable } if (m_mouseDownMayStartDrag && !dragState().m_dragSrc) { @@ -2463,7 +2465,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event) dragState().m_dragSrc = 0; if (!dragState().m_dragSrc) - m_mouseDownMayStartDrag = false; // no element is draggable + m_mouseDownMayStartDrag = false; // no element is draggable else { // remember some facts about this source, while we have a HitTestResult handy node = result.URLElement(); @@ -2503,8 +2505,8 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event) DragOperation srcOp = DragOperationNone; - freeClipboard(); // would only happen if we missed a dragEnd. Do it anyway, just - // to make sure it gets numbified + freeClipboard(); // would only happen if we missed a dragEnd. Do it anyway, just + // to make sure it gets numbified dragState().m_dragClipboard = createDraggingClipboard(); if (dragState().m_dragSrcMayBeDHTML) { @@ -2768,6 +2770,12 @@ static PassRefPtr<TouchList> assembleTargetTouches(Touch* touchTarget, TouchList return targetTouches.release(); } +static float pageZoomFactor(Frame* frame) +{ + FrameView* view = frame->view(); + return view ? view->pageZoomFactor() : 1.0f; +} + bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) { RefPtr<TouchList> touches = TouchList::create(); @@ -2802,8 +2810,8 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) pagePoint = documentPointForWindowPoint(doc->frame(), point.pos()); } - int adjustedPageX = lroundf(pagePoint.x() / m_frame->pageZoomFactor()); - int adjustedPageY = lroundf(pagePoint.y() / m_frame->pageZoomFactor()); + int adjustedPageX = lroundf(pagePoint.x() / pageZoomFactor(m_frame)); + int adjustedPageY = lroundf(pagePoint.y() / pageZoomFactor(m_frame)); // Increment the platform touch id by 1 to avoid storing a key of 0 in the hashmap. unsigned touchPointTargetKey = point.id() + 1; diff --git a/WebCore/page/EventHandler.h b/WebCore/page/EventHandler.h index 39b165d..bf2003e 100644 --- a/WebCore/page/EventHandler.h +++ b/WebCore/page/EventHandler.h @@ -114,7 +114,7 @@ public: bool mousePressed() const { return m_mousePressed; } void setMousePressed(bool pressed) { m_mousePressed = pressed; } - void setCapturingMouseEventsNode(PassRefPtr<Node>); + void setCapturingMouseEventsNode(PassRefPtr<Node>); // A caller is responsible for resetting capturing node to 0. #if ENABLE(DRAG_SUPPORT) bool updateDragAndDrop(const PlatformMouseEvent&, Clipboard*); @@ -134,9 +134,9 @@ public: static Frame* subframeForTargetNode(Node*); - bool scrollOverflow(ScrollDirection, ScrollGranularity); + bool scrollOverflow(ScrollDirection, ScrollGranularity, Node* startingNode = 0); - bool scrollRecursively(ScrollDirection, ScrollGranularity); + bool scrollRecursively(ScrollDirection, ScrollGranularity, Node* startingNode = 0); #if ENABLE(DRAG_SUPPORT) bool shouldDragAutoNode(Node*, const IntPoint&) const; // -webkit-user-drag == auto @@ -396,6 +396,7 @@ private: RenderLayer* m_resizeLayer; RefPtr<Node> m_capturingMouseEventsNode; + bool m_eventHandlerWillResetCapturingMouseEventsNode; RefPtr<Node> m_nodeUnderMouse; RefPtr<Node> m_lastNodeUnderMouse; diff --git a/WebCore/page/Frame.cpp b/WebCore/page/Frame.cpp index 216f6b3..f0ce1f2 100644 --- a/WebCore/page/Frame.cpp +++ b/WebCore/page/Frame.cpp @@ -155,9 +155,6 @@ Frame::Frame(Page* page, HTMLFrameOwnerElement* ownerElement, FrameLoaderClient* , m_isDisconnected(false) , m_excludeFromTextSearch(false) { - Frame* parent = parentFromOwnerElement(ownerElement); - m_zoomFactor = parent ? parent->m_zoomFactor : 1.0f; - AtomicString::init(); HTMLNames::init(); QualifiedName::init(); @@ -614,56 +611,6 @@ void Frame::paintDragCaret(GraphicsContext* p, int tx, int ty, const IntRect& cl #endif } -ZoomMode Frame::zoomMode() const -{ - return m_page->settings()->zoomMode(); -} - -bool Frame::shouldApplyTextZoom() const -{ - return m_zoomFactor != 1.0f && zoomMode() == ZoomTextOnly; -} - -bool Frame::shouldApplyPageZoom() const -{ - return m_zoomFactor != 1.0f && zoomMode() == ZoomPage; -} - -void Frame::setZoomFactor(float percent, ZoomMode mode) -{ - if (m_zoomFactor == percent && zoomMode() == mode) - return; - -#if ENABLE(SVG) - // Respect SVGs zoomAndPan="disabled" property in standalone SVG documents. - // FIXME: How to handle compound documents + zoomAndPan="disabled"? Needs SVG WG clarification. - if (m_doc->isSVGDocument()) { - if (!static_cast<SVGDocument*>(m_doc.get())->zoomAndPanEnabled()) - return; - if (m_doc->renderer()) - m_doc->renderer()->setNeedsLayout(true); - } -#endif - - if (mode == ZoomPage) { - // Update the scroll position when doing a full page zoom, so the content stays in relatively the same position. - IntPoint scrollPosition = view()->scrollPosition(); - float percentDifference = (percent / m_zoomFactor); - view()->setScrollPosition(IntPoint(scrollPosition.x() * percentDifference, scrollPosition.y() * percentDifference)); - } - - m_zoomFactor = percent; - m_page->settings()->setZoomMode(mode); - - m_doc->recalcStyle(Node::Force); - - for (Frame* child = tree()->firstChild(); child; child = child->tree()->nextSibling()) - child->setZoomFactor(m_zoomFactor, mode); - - if (m_doc->renderer() && m_doc->renderer()->needsLayout() && view()->didFirstLayout()) - view()->layout(); -} - void Frame::setPrinting(bool printing, float minPageWidth, float maxPageWidth, bool adjustViewSize) { m_doc->setPrinting(printing); @@ -938,12 +885,6 @@ void Frame::applyEditingStyleToBodyElement() const applyEditingStyleToElement(static_cast<Element*>(list->item(i))); } -void Frame::removeEditingStyleFromBodyElement() const -{ - // FIXME: This function does nothing. We should either implement it - // or remove it along with all call sites. -} - void Frame::applyEditingStyleToElement(Element* element) const { if (!element) diff --git a/WebCore/page/Frame.h b/WebCore/page/Frame.h index f84952e..7e80370 100644 --- a/WebCore/page/Frame.h +++ b/WebCore/page/Frame.h @@ -149,9 +149,9 @@ namespace WebCore { void setInViewSourceMode(bool = true); void keepAlive(); // Used to keep the frame alive when running a script that might destroy it. - #ifndef NDEBUG +#ifndef NDEBUG static void cancelAllKeepAlive(); - #endif +#endif void setDocument(PassRefPtr<Document>); @@ -189,17 +189,6 @@ namespace WebCore { private: void lifeSupportTimerFired(Timer<Frame>*); - // === to be moved into FrameView - - public: - void setZoomFactor(float scale, ZoomMode); - float zoomFactor() const; - ZoomMode zoomMode() const; - bool shouldApplyTextZoom() const; - bool shouldApplyPageZoom() const; - float pageZoomFactor() const { return shouldApplyPageZoom() ? zoomFactor() : 1.0f; } - float textZoomFactor() const { return shouldApplyTextZoom() ? zoomFactor() : 1.0f; } - // === to be moved into Chrome public: @@ -225,7 +214,6 @@ namespace WebCore { void computeAndSetTypingStyle(CSSStyleDeclaration* , EditAction = EditActionUnspecified); String selectionStartStylePropertyValue(int stylePropertyID) const; void applyEditingStyleToBodyElement() const; - void removeEditingStyleFromBodyElement() const; void applyEditingStyleToElement(Element*) const; IntRect firstRectForRange(Range*) const; @@ -285,9 +273,10 @@ namespace WebCore { VisiblePosition visiblePositionForPoint(const IntPoint& framePoint); Document* documentAtPoint(const IntPoint& windowPoint); - - private: + #if ENABLE(TILED_BACKING_STORE) + + private: // TiledBackingStoreClient interface virtual void tiledBackingStorePaintBegin(); virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&); @@ -296,7 +285,7 @@ namespace WebCore { virtual IntRect tiledBackingStoreVisibleRect(); #endif - #if PLATFORM(MAC) +#if PLATFORM(MAC) // === undecided, would like to consider moving to another class @@ -305,9 +294,9 @@ namespace WebCore { NSString* searchForLabelsBeforeElement(NSArray* labels, Element*, size_t* resultDistance, bool* resultIsInCellAbove); NSString* matchLabelsAgainstElement(NSArray* labels, Element*); - #if ENABLE(DASHBOARD_SUPPORT) +#if ENABLE(DASHBOARD_SUPPORT) NSMutableDictionary* dashboardRegionsDictionary(); - #endif +#endif NSImage* selectionImage(bool forceBlackText = false) const; NSImage* snapshotDragImage(Node*, NSRect* imageRect, NSRect* elementRect) const; @@ -322,15 +311,15 @@ namespace WebCore { NSDictionary* fontAttributesForSelectionStart() const; NSWritingDirection baseWritingDirectionForSelectionStart() const; - #endif +#endif - #if PLATFORM(WIN) +#if PLATFORM(WIN) public: // FIXME - We should have a single version of nodeImage instead of using platform types. HBITMAP nodeImage(Node*) const; - #endif +#endif private: Page* m_page; @@ -350,8 +339,6 @@ namespace WebCore { String m_kjsStatusBarText; String m_kjsDefaultStatusBarText; - float m_zoomFactor; - mutable SelectionController m_selectionController; mutable VisibleSelection m_mark; mutable Editor m_editor; @@ -437,11 +424,6 @@ namespace WebCore { m_mark = s; } - inline float Frame::zoomFactor() const - { - return m_zoomFactor; - } - inline String Frame::jsStatusBarText() const { return m_kjsStatusBarText; diff --git a/WebCore/page/FrameTree.cpp b/WebCore/page/FrameTree.cpp index d6170e1..1f0604c 100644 --- a/WebCore/page/FrameTree.cpp +++ b/WebCore/page/FrameTree.cpp @@ -136,7 +136,7 @@ AtomicString FrameTree::uniqueChildName(const AtomicString& requestedName) const // Suffix buffer has more than enough space for: // 10 characters before the number - // a number (3 digits for the highest this gets in practice, 20 digits for the largest 64-bit integer) + // a number (20 digits for the largest 64-bit integer) // 6 characters after the number // trailing null byte // But we still use snprintf just to be extra-safe. diff --git a/WebCore/page/FrameView.cpp b/WebCore/page/FrameView.cpp index b4bfa74..d549ff4 100644 --- a/WebCore/page/FrameView.cpp +++ b/WebCore/page/FrameView.cpp @@ -116,6 +116,17 @@ struct ScheduledEvent : Noncopyable { RefPtr<Node> m_eventTarget; }; +static inline float parentZoomFactor(Frame* frame) +{ + Frame* parent = frame->tree()->parent(); + if (!parent) + return 1; + FrameView* parentView = parent->view(); + if (!parentView) + return 1; + return parentView->zoomFactor(); +} + FrameView::FrameView(Frame* frame) : m_frame(frame) , m_canHaveScrollbars(true) @@ -137,6 +148,7 @@ FrameView::FrameView(Frame* frame) , m_deferSetNeedsLayouts(0) , m_setNeedsLayoutWasDeferred(false) , m_scrollCorner(0) + , m_zoomFactor(parentZoomFactor(frame)) { init(); } @@ -2166,4 +2178,72 @@ IntPoint FrameView::convertFromContainingView(const IntPoint& parentPoint) const return parentPoint; } +bool FrameView::shouldApplyTextZoom() const +{ + if (m_zoomFactor == 1) + return false; + if (!m_frame) + return false; + Page* page = m_frame->page(); + return page && page->settings()->zoomMode() == ZoomTextOnly; +} + +bool FrameView::shouldApplyPageZoom() const +{ + if (m_zoomFactor == 1) + return false; + if (!m_frame) + return false; + Page* page = m_frame->page(); + return page && page->settings()->zoomMode() == ZoomPage; +} + +void FrameView::setZoomFactor(float percent, ZoomMode mode) +{ + if (!m_frame) + return; + + Page* page = m_frame->page(); + if (!page) + return; + + if (m_zoomFactor == percent && page->settings()->zoomMode() == mode) + return; + + Document* document = m_frame->document(); + if (!document) + return; + +#if ENABLE(SVG) + // Respect SVGs zoomAndPan="disabled" property in standalone SVG documents. + // FIXME: How to handle compound documents + zoomAndPan="disabled"? Needs SVG WG clarification. + if (document->isSVGDocument()) { + if (!static_cast<SVGDocument*>(document)->zoomAndPanEnabled()) + return; + if (document->renderer()) + document->renderer()->setNeedsLayout(true); + } +#endif + + if (mode == ZoomPage) { + // Update the scroll position when doing a full page zoom, so the content stays in relatively the same position. + IntPoint scrollPosition = this->scrollPosition(); + float percentDifference = (percent / m_zoomFactor); + setScrollPosition(IntPoint(scrollPosition.x() * percentDifference, scrollPosition.y() * percentDifference)); + } + + m_zoomFactor = percent; + page->settings()->setZoomMode(mode); + + document->recalcStyle(Node::Force); + + for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) { + if (FrameView* childView = child->view()) + childView->setZoomFactor(m_zoomFactor, mode); + } + + if (document->renderer() && document->renderer()->needsLayout() && didFirstLayout()) + layout(); +} + } // namespace WebCore diff --git a/WebCore/page/FrameView.h b/WebCore/page/FrameView.h index 6bd1c21..203dc86 100644 --- a/WebCore/page/FrameView.h +++ b/WebCore/page/FrameView.h @@ -214,6 +214,13 @@ public: bool isFrameViewScrollCorner(RenderScrollbarPart* scrollCorner) const { return m_scrollCorner == scrollCorner; } void invalidateScrollCorner(); + void setZoomFactor(float scale, ZoomMode); + float zoomFactor() const { return m_zoomFactor; } + bool shouldApplyTextZoom() const; + bool shouldApplyPageZoom() const; + float pageZoomFactor() const { return shouldApplyPageZoom() ? m_zoomFactor : 1.0f; } + float textZoomFactor() const { return shouldApplyTextZoom() ? m_zoomFactor : 1.0f; } + private: FrameView(Frame*); @@ -287,7 +294,8 @@ private: unsigned m_slowRepaintObjectCount; unsigned m_fixedObjectCount; - int m_borderX, m_borderY; + int m_borderX; + int m_borderY; Timer<FrameView> m_layoutTimer; bool m_delayedLayout; @@ -343,6 +351,8 @@ private: // Renderer to hold our custom scroll corner. RenderScrollbarPart* m_scrollCorner; + + float m_zoomFactor; }; #if ENABLE(INSPECTOR) diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp index 96fe564..7dcf0a1 100644 --- a/WebCore/page/Geolocation.cpp +++ b/WebCore/page/Geolocation.cpp @@ -221,17 +221,12 @@ Geolocation::~Geolocation() { } -void Geolocation::stop() -{ - m_oneShots.clear(); - m_watchers.clear(); - stopUpdating(); -} - void Geolocation::disconnectFrame() { if (m_frame && m_frame->page() && m_allowGeolocation == InProgress) m_frame->page()->chrome()->cancelGeolocationPermissionRequestForFrame(m_frame, this); + stopTimers(); + stopUpdating(); if (m_frame && m_frame->document()) m_frame->document()->setUsingGeolocation(false); m_frame = 0; @@ -688,8 +683,6 @@ Geolocation::~Geolocation() {} void Geolocation::setIsAllowed(bool) {} -void Geolocation::stop() {} - } #endif // ENABLE(GEOLOCATION) diff --git a/WebCore/page/Geolocation.h b/WebCore/page/Geolocation.h index 14aaac0..1d0050f 100644 --- a/WebCore/page/Geolocation.h +++ b/WebCore/page/Geolocation.h @@ -65,8 +65,6 @@ public: void suspend(); void resume(); - void stop(); - void setIsAllowed(bool); Frame* frame() const { return m_frame; } diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp index ae7c9ad..446f9f0 100644 --- a/WebCore/page/Page.cpp +++ b/WebCore/page/Page.cpp @@ -395,13 +395,17 @@ void Page::refreshPlugins(bool reload) HashSet<Page*>::iterator end = allPages->end(); for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it) { - (*it)->m_pluginData = 0; + Page* page = *it; + + // Clear out the page's plug-in data. + page->m_pluginData = 0; - if (reload) { - for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext()) { - if (frame->loader()->containsPlugins()) - framesNeedingReload.append(frame); - } + if (!reload) + continue; + + for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext()) { + if (frame->loader()->containsPlugins()) + framesNeedingReload.append(frame); } } diff --git a/WebCore/page/Page.h b/WebCore/page/Page.h index aa7bae1..b931092 100644 --- a/WebCore/page/Page.h +++ b/WebCore/page/Page.h @@ -232,6 +232,12 @@ namespace WebCore { #if ENABLE(INSPECTOR) InspectorTimelineAgent* inspectorTimelineAgent() const; #endif + + // Don't allow more than a certain number of frames in a page. + // This seems like a reasonable upper bound, and otherwise mutually + // recursive frameset pages can quickly bring the program to its knees + // with exponential growth in the number of frames. + static const int maxNumberOfFrames = 1000; private: void initGroup(); diff --git a/WebCore/page/SuspendableTimer.cpp b/WebCore/page/SuspendableTimer.cpp new file mode 100644 index 0000000..532b0ed --- /dev/null +++ b/WebCore/page/SuspendableTimer.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "config.h" +#include "SuspendableTimer.h" + +#include "ScriptExecutionContext.h" + +namespace WebCore { + +SuspendableTimer::SuspendableTimer(ScriptExecutionContext* context) + : ActiveDOMObject(context, this) + , m_nextFireInterval(0) + , m_repeatInterval(0) +#if !ASSERT_DISABLED + , m_suspended(false) +#endif +{ +} + +SuspendableTimer::~SuspendableTimer() +{ +} + +bool SuspendableTimer::hasPendingActivity() const +{ + return isActive(); +} + +void SuspendableTimer::stop() +{ + TimerBase::stop(); +} + +void SuspendableTimer::suspend() +{ +#if !ASSERT_DISABLED + ASSERT(!m_suspended); + m_suspended = true; +#endif + m_nextFireInterval = nextFireInterval(); + m_repeatInterval = repeatInterval(); + TimerBase::stop(); +} + +void SuspendableTimer::resume() +{ +#if !ASSERT_DISABLED + ASSERT(m_suspended); + m_suspended = false; +#endif + start(m_nextFireInterval, m_repeatInterval); +} + +bool SuspendableTimer::canSuspend() const +{ + return true; +} + +} // namespace WebCore diff --git a/WebCore/page/SuspendableTimer.h b/WebCore/page/SuspendableTimer.h new file mode 100644 index 0000000..eae6153 --- /dev/null +++ b/WebCore/page/SuspendableTimer.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef SuspendableTimer_h +#define SuspendableTimer_h + +#include "ActiveDOMObject.h" +#include "Timer.h" + +namespace WebCore { + +class SuspendableTimer : public TimerBase, public ActiveDOMObject { +public: + SuspendableTimer(ScriptExecutionContext*); + virtual ~SuspendableTimer(); + + // ActiveDOMObject + virtual bool hasPendingActivity() const; + virtual void stop(); + virtual bool canSuspend() const; + virtual void suspend(); + virtual void resume(); + +private: + virtual void fired() = 0; + + double m_nextFireInterval; + double m_repeatInterval; +#if !ASSERT_DISABLED + bool m_suspended; +#endif +}; + +} // namespace WebCore + +#endif // SuspendableTimer_h + diff --git a/WebCore/page/animation/AnimationBase.cpp b/WebCore/page/animation/AnimationBase.cpp index 6ab56e9..aa6a4c1 100644 --- a/WebCore/page/animation/AnimationBase.cpp +++ b/WebCore/page/animation/AnimationBase.cpp @@ -1226,10 +1226,6 @@ double AnimationBase::progress(double scale, double offset, const TimingFunction void AnimationBase::getTimeToNextEvent(double& time, bool& isLooping) const { // Decide when the end or loop event needs to fire - double totalDuration = -1; - if (m_animation->iterationCount() > 0) - totalDuration = m_animation->duration() * m_animation->iterationCount(); - const double elapsedDuration = max(beginAnimationUpdateTime() - m_startTime, 0.0); double durationLeft = 0; double nextIterationTime = m_totalDuration; |