Commit 49f4cb5f authored by podivilov@chromium.org's avatar podivilov@chromium.org
Browse files

2011-01-17 Pavel Podivilov <podivilov@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: add source column field to debugger call frames.
        https://bugs.webkit.org/show_bug.cgi?id=52443

        * bindings/js/JavaScriptCallFrame.cpp:
        (WebCore::JavaScriptCallFrame::JavaScriptCallFrame):
        * bindings/js/JavaScriptCallFrame.h:
        (WebCore::JavaScriptCallFrame::create):
        (WebCore::JavaScriptCallFrame::line):
        (WebCore::JavaScriptCallFrame::column):
        (WebCore::JavaScriptCallFrame::update):
        * bindings/js/ScriptDebugServer.cpp:
        (WebCore::ScriptDebugServer::createCallFrameAndPauseIfNeeded):
        (WebCore::ScriptDebugServer::updateCallFrameAndPauseIfNeeded):
        (WebCore::ScriptDebugServer::callEvent):
        (WebCore::ScriptDebugServer::atStatement):
        (WebCore::ScriptDebugServer::returnEvent):
        (WebCore::ScriptDebugServer::exception):
        (WebCore::ScriptDebugServer::willExecuteProgram):
        (WebCore::ScriptDebugServer::didExecuteProgram):
        (WebCore::ScriptDebugServer::didReachBreakpoint):
        * bindings/js/ScriptDebugServer.h:
        * bindings/v8/DebuggerScript.js:
        ():
        * bindings/v8/JavaScriptCallFrame.cpp:
        (WebCore::JavaScriptCallFrame::column):
        * bindings/v8/JavaScriptCallFrame.h:
        * inspector/InjectedScriptSource.js:
        ():
        * inspector/JavaScriptCallFrame.idl:

 2011-01-18  Antti Koivisto  <antti@apple.com>

        Reviewed by Dave Hyatt.

        https://bugs.webkit.org/show_bug.cgi?id=52370
        <rdar://problem/8856808>
        Style sharing optimization no longer works on major web sites

        The code in CSSStyleSelector::locateSharedStyle() that tries to share style information between element has been defeated
        by widespread use of certain CSS selectors (:first-child pseudo class and similar). The current implementation disables
        the sharing optimization for the whole page if one of these constructs is seen in any style sheet used by the page.

        This patch gets the style sharing back to 25-40% range on most web sites.

        * css/CSSMutableStyleDeclaration.h:
        (WebCore::CSSMutableStyleDeclaration::propertiesEqual):

            Needed to improve equality checking in NamedNodeMap::mappedMapsEquivalent.

        * css/CSSSelector.h:
        (WebCore::CSSSelector::isSiblingSelector):

            Test for selectors that are affected by the sibling elements.

        * css/CSSStyleSelector.cpp:
        (WebCore::elementCanUseSimpleDefaultStyle):
        (WebCore::collectSiblingRulesInDefaultStyle):
        (WebCore::assertNoSiblingRulesInDefaultStyle):

            Extract sibling rules from the MathML default stylesheet.
            Assert that no other default stylesheet has them.

        (WebCore::CSSStyleSelector::CSSStyleSelector):
        (WebCore::CSSStyleSelector::locateCousinList):
        (WebCore::CSSStyleSelector::matchesSiblingRules):
        (WebCore::CSSStyleSelector::canShareStyleWithElement):
        (WebCore::CSSStyleSelector::locateSharedStyle):
        (WebCore::CSSStyleSelector::styleForElement):
        (WebCore::collectIdsAndSiblingRulesFromList):
        (WebCore::CSSRuleSet::collectIdsAndSiblingRules):

            Track sibling rules and ids used in the stylesheets to allow much more fine-grained rejection of cases
            where style sharing can't be used.

        * css/CSSStyleSelector.h:
        * dom/NamedNodeMap.cpp:
        (WebCore::NamedNodeMap::mappedMapsEquivalent):

            Check also for CSSValue mutation from DOM.

        * mathml/MathMLMathElement.cpp:
        (WebCore::MathMLMathElement::insertedIntoDocument):
        * mathml/MathMLMathElement.h:

            MathML default style sheet has sibling rules which don't get noticed by the normal document
            stylesheet parsing.

        * rendering/style/RenderStyle.h:
        (WebCore::InheritedFlags::setFirstChildState):
        (WebCore::InheritedFlags::setLastChildState):
        (WebCore::InheritedFlags::setChildIndex):

            These all make style non-shareable (unique).

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76013 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 84c087a0
2011-01-17 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: add source column field to debugger call frames.
https://bugs.webkit.org/show_bug.cgi?id=52443
* bindings/js/JavaScriptCallFrame.cpp:
(WebCore::JavaScriptCallFrame::JavaScriptCallFrame):
* bindings/js/JavaScriptCallFrame.h:
(WebCore::JavaScriptCallFrame::create):
(WebCore::JavaScriptCallFrame::line):
(WebCore::JavaScriptCallFrame::column):
(WebCore::JavaScriptCallFrame::update):
* bindings/js/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::createCallFrameAndPauseIfNeeded):
(WebCore::ScriptDebugServer::updateCallFrameAndPauseIfNeeded):
(WebCore::ScriptDebugServer::callEvent):
(WebCore::ScriptDebugServer::atStatement):
(WebCore::ScriptDebugServer::returnEvent):
(WebCore::ScriptDebugServer::exception):
(WebCore::ScriptDebugServer::willExecuteProgram):
(WebCore::ScriptDebugServer::didExecuteProgram):
(WebCore::ScriptDebugServer::didReachBreakpoint):
* bindings/js/ScriptDebugServer.h:
* bindings/v8/DebuggerScript.js:
():
* bindings/v8/JavaScriptCallFrame.cpp:
(WebCore::JavaScriptCallFrame::column):
* bindings/v8/JavaScriptCallFrame.h:
* inspector/InjectedScriptSource.js:
():
* inspector/JavaScriptCallFrame.idl:
2011-01-18 Antti Koivisto <antti@apple.com>
 
Reviewed by Dave Hyatt.
......@@ -42,11 +42,11 @@ using namespace JSC;
namespace WebCore {
JavaScriptCallFrame::JavaScriptCallFrame(const DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, int line)
JavaScriptCallFrame::JavaScriptCallFrame(const DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition1& textPosition)
: m_debuggerCallFrame(debuggerCallFrame)
, m_caller(caller)
, m_sourceID(sourceID)
, m_line(line)
, m_textPosition(textPosition)
, m_isValid(true)
{
}
......
......@@ -33,14 +33,15 @@
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/text/TextPosition.h>
namespace WebCore {
class JavaScriptCallFrame : public RefCounted<JavaScriptCallFrame> {
public:
static PassRefPtr<JavaScriptCallFrame> create(const JSC::DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, int line)
static PassRefPtr<JavaScriptCallFrame> create(const JSC::DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition1& textPosition)
{
return adoptRef(new JavaScriptCallFrame(debuggerCallFrame, caller, sourceID, line));
return adoptRef(new JavaScriptCallFrame(debuggerCallFrame, caller, sourceID, textPosition));
}
void invalidate()
......@@ -54,11 +55,13 @@ public:
JavaScriptCallFrame* caller();
intptr_t sourceID() const { return m_sourceID; }
int line() const { return m_line; }
void update(const JSC::DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int line)
int line() const { return m_textPosition.m_line.oneBasedInt(); }
int column() const { return m_textPosition.m_column.oneBasedInt(); }
void update(const JSC::DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, const TextPosition1& textPosition)
{
m_debuggerCallFrame = debuggerCallFrame;
m_line = line;
m_textPosition = textPosition;
m_sourceID = sourceID;
m_isValid = true;
}
......@@ -72,12 +75,12 @@ public:
JSC::JSValue evaluate(const JSC::UString& script, JSC::JSValue& exception) const;
private:
JavaScriptCallFrame(const JSC::DebuggerCallFrame&, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, int line);
JavaScriptCallFrame(const JSC::DebuggerCallFrame&, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition1&);
JSC::DebuggerCallFrame m_debuggerCallFrame;
RefPtr<JavaScriptCallFrame> m_caller;
intptr_t m_sourceID;
int m_line;
TextPosition1 m_textPosition;
bool m_isValid;
};
......
......@@ -440,6 +440,24 @@ void ScriptDebugServer::setJavaScriptPaused(FrameView* view, bool paused)
}
}
void ScriptDebugServer::createCallFrameAndPauseIfNeeded(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
{
TextPosition1 textPosition(WTF::OneBasedNumber::fromOneBasedInt(lineNumber), WTF::OneBasedNumber::base());
m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, textPosition);
pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject()));
}
void ScriptDebugServer::updateCallFrameAndPauseIfNeeded(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
{
ASSERT(m_currentCallFrame);
if (!m_currentCallFrame)
return;
TextPosition1 textPosition(WTF::OneBasedNumber::fromOneBasedInt(lineNumber), WTF::OneBasedNumber::base());
m_currentCallFrame->update(debuggerCallFrame, sourceID, textPosition);
pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject()));
}
void ScriptDebugServer::pauseIfNeeded(Page* page)
{
if (m_paused)
......@@ -480,24 +498,14 @@ void ScriptDebugServer::pauseIfNeeded(Page* page)
void ScriptDebugServer::callEvent(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
{
if (m_paused)
return;
m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, lineNumber);
pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject()));
if (!m_paused)
createCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber);
}
void ScriptDebugServer::atStatement(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
{
if (m_paused)
return;
ASSERT(m_currentCallFrame);
if (!m_currentCallFrame)
return;
m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber);
pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject()));
if (!m_paused)
updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber);
}
void ScriptDebugServer::returnEvent(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
......@@ -505,12 +513,7 @@ void ScriptDebugServer::returnEvent(const DebuggerCallFrame& debuggerCallFrame,
if (m_paused)
return;
ASSERT(m_currentCallFrame);
if (!m_currentCallFrame)
return;
m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber);
pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject()));
updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber);
// detach may have been called during pauseIfNeeded
if (!m_currentCallFrame)
......@@ -527,24 +530,16 @@ void ScriptDebugServer::exception(const DebuggerCallFrame& debuggerCallFrame, in
if (m_paused)
return;
ASSERT(m_currentCallFrame);
if (!m_currentCallFrame)
return;
if (m_pauseOnExceptionsState == PauseOnAllExceptions || (m_pauseOnExceptionsState == PauseOnUncaughtExceptions && !hasHandler))
m_pauseOnNextStatement = true;
m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber);
pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject()));
updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber);
}
void ScriptDebugServer::willExecuteProgram(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
{
if (m_paused)
return;
m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, lineNumber);
pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject()));
if (!m_paused)
createCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber);
}
void ScriptDebugServer::didExecuteProgram(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
......@@ -552,12 +547,7 @@ void ScriptDebugServer::didExecuteProgram(const DebuggerCallFrame& debuggerCallF
if (m_paused)
return;
ASSERT(m_currentCallFrame);
if (!m_currentCallFrame)
return;
m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber);
pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject()));
updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber);
// Treat stepping over the end of a program like stepping out.
if (m_currentCallFrame == m_pauseOnCallFrame)
......@@ -570,13 +560,8 @@ void ScriptDebugServer::didReachBreakpoint(const DebuggerCallFrame& debuggerCall
if (m_paused)
return;
ASSERT(m_currentCallFrame);
if (!m_currentCallFrame)
return;
m_pauseOnNextStatement = true;
m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber);
pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject()));
updateCallFrameAndPauseIfNeeded(debuggerCallFrame, sourceID, lineNumber);
}
void ScriptDebugServer::recompileAllJSFunctionsSoon()
......
......@@ -118,6 +118,8 @@ private:
void dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, enum ScriptWorldType);
void dispatchFailedToParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, int errorLine, const String& errorMessage);
void createCallFrameAndPauseIfNeeded(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber);
void updateCallFrameAndPauseIfNeeded(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineNumber);
void pauseIfNeeded(Page*);
virtual void detach(JSC::JSGlobalObject*);
......
......@@ -201,8 +201,10 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame)
var script = func.script();
var sourceID = script && script.id();
// Get line number.
var line = DebuggerScript._v8ToWebkitLineNumber(frameMirror.sourceLine());
// Get location.
var location = frameMirror.sourceLocation();
var line = DebuggerScript._v8ToWebkitLineNumber(location.line);
var column = DebuggerScript._v8ToWebkitLineNumber(location.column);
// Get this object.
var thisObject = frameMirror.details_.receiver();
......@@ -250,6 +252,7 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame)
return {
"sourceID": sourceID,
"line": line,
"column": column,
"functionName": functionName,
"type": "function",
"thisObject": thisObject,
......
......@@ -80,6 +80,16 @@ int JavaScriptCallFrame::line() const
return 0;
}
int JavaScriptCallFrame::column() const
{
v8::HandleScope handleScope;
v8::Context::Scope contextScope(m_debuggerContext.get());
v8::Handle<v8::Value> result = m_callFrame.get()->Get(v8String("column"));
if (result->IsInt32())
return result->Int32Value();
return 0;
}
String JavaScriptCallFrame::functionName() const
{
v8::HandleScope handleScope;
......
......@@ -51,6 +51,7 @@ public:
int sourceID() const;
int line() const;
int column() const;
String functionName() const;
v8::Handle<v8::Value> scopeChain() const;
......
......@@ -543,6 +543,7 @@ InjectedScript.CallFrameProxy = function(id, callFrame)
this.functionName = (this.type === "function" ? callFrame.functionName : "");
this.sourceID = callFrame.sourceID;
this.line = callFrame.line;
this.column = callFrame.column;
this.scopeChain = this._wrapScopeChain(callFrame);
this.worldId = injectedScriptId;
}
......
......@@ -43,6 +43,7 @@ module inspector {
readonly attribute JavaScriptCallFrame caller;
readonly attribute long sourceID;
readonly attribute long line;
readonly attribute long column;
readonly attribute [CustomGetter] Array scopeChain;
[Custom] unsigned short scopeType(in int scopeIndex);
readonly attribute [CustomGetter] Object thisObject;
......
Supports Markdown
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